improve receipt/details reports and implement number formatting
1) eager load reports for receipt/details 2) introduce number_format lookups to replace print_settings for number formatting 3) implement NumberFormattable concern, reference number_format lookups or print_settings if not exist, to get number format settings and number formatting 4) replace rails NumberHelper.number_with_precision with NumberFormattable.number_format hopefully to reduce overhead, formatting numbers for huge lists of data
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
class OrderItemStarPdf < Prawn::Document
|
||||
include ActionView::Helpers::NumberHelper
|
||||
include NumberFormattable
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :margin_top, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
|
||||
|
||||
def initialize(print_settings,order_item, print_status, options, alt_name, before_updated_qty)
|
||||
@@ -48,7 +48,7 @@ class OrderItemStarPdf < Prawn::Document
|
||||
order_info(order_item.order_id, order_item.order_by,order_item.order_at)
|
||||
|
||||
# order items
|
||||
order_items(order_item, options, alt_name, print_settings.precision, before_updated_qty)
|
||||
order_items(order_item, options, alt_name, precision, before_updated_qty)
|
||||
end
|
||||
|
||||
# Write Order Information to PDF
|
||||
@@ -108,7 +108,7 @@ class OrderItemStarPdf < Prawn::Document
|
||||
end
|
||||
|
||||
bounding_box([self.item_width,y_position], :width => self.qty_width) do
|
||||
text "[#{number_with_precision(order_item.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
|
||||
text "[#{number_format(order_item.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([0,y_position], :width => self.item_width) do
|
||||
@@ -147,7 +147,7 @@ class OrderItemStarPdf < Prawn::Document
|
||||
# add option
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "* Change quantity [#{number_with_precision(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_with_precision(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
|
||||
text "* Change quantity [#{number_format(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_format(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user