diff --git a/app/pdf/order_item_pdf.rb b/app/pdf/order_item_pdf.rb index 2bd9f114..03ed4d21 100644 --- a/app/pdf/order_item_pdf.rb +++ b/app/pdf/order_item_pdf.rb @@ -1,4 +1,5 @@ class OrderItemPdf < Prawn::Document + include ActionView::Helpers::NumberHelper attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :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) self.page_width = 180 @@ -30,7 +31,7 @@ class OrderItemPdf < 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) + order_items(order_item, options, alt_name, print_settings.precision) end # Write Order Information to PDF @@ -58,11 +59,11 @@ class OrderItemPdf < Prawn::Document end # Write Order items to PDF - def order_items(order_item, options, alt_name) + def order_items(order_item, options, alt_name, precision) y_position = cursor #Add Order Item - add_order_items(order_item, options, alt_name) + add_order_items(order_item, options, alt_name, precision) dash(1, :space => 1, :phase => 1) stroke_horizontal_line 0, (self.page_width - self.margin) @@ -70,7 +71,7 @@ class OrderItemPdf < Prawn::Document end # Add order items under order info - def add_order_items(order_item, options, alt_name) + def add_order_items(order_item, options, alt_name, precision) y_position = cursor move_down 5 @@ -80,7 +81,7 @@ class OrderItemPdf < Prawn::Document end bounding_box([self.item_width,y_position], :width => self.qty_width) do - text "[#{order_item.qty.to_i}]", :size => self.item_font_size,:align => :left + text "[#{number_with_precision(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 diff --git a/app/pdf/order_summary_pdf.rb b/app/pdf/order_summary_pdf.rb index 0c3b7fd8..9ee459c8 100644 --- a/app/pdf/order_summary_pdf.rb +++ b/app/pdf/order_summary_pdf.rb @@ -1,4 +1,5 @@ class OrderSummaryPdf < Prawn::Document + include ActionView::Helpers::NumberHelper attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width def initialize(print_settings,order, print_status, order_items = nil,alt_name) self.page_width = 180 @@ -29,9 +30,9 @@ class OrderSummaryPdf < Prawn::Document # order items if order_items == nil - order_items(order, alt_name) + order_items(order, alt_name, print_settings.precision) else - order_items(order_items, alt_name) + order_items(order_items, alt_name, print_settings.precision) end end @@ -60,7 +61,7 @@ class OrderSummaryPdf < Prawn::Document end # Write Order items to PDF - def order_items(order_item, alt_name) + def order_items(order_item, alt_name, precision) y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do @@ -75,12 +76,12 @@ class OrderSummaryPdf < Prawn::Document move_down 5 #Add Order Item - add_order_items(order_item, alt_name) + add_order_items(order_item, alt_name, precision) end # Add order items under order info - def add_order_items(order_item, alt_name) + def add_order_items(order_item, alt_name, precision) y_position = cursor move_down 5 @@ -96,7 +97,7 @@ class OrderSummaryPdf < Prawn::Document end bounding_box([self.item_width,y_position], :width => self.qty_width) do - text "#{odi.qty}", :size => self.item_font_size,:align => :left + text "#{number_with_precision(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left end bounding_box([0,y_position], :width => self.item_width) do diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 9807b2d5..1baa5f2c 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -142,7 +142,7 @@ class ReceiptBillPdf < Prawn::Document pad_top(15) { text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix - text_box "#{qty}", :at =>[item_name_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix + text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_name_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[(item_name_width+4),y_position], :width =>self.total_width+3, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix } move_down 1 diff --git a/dump.rdb b/dump.rdb index e6612cd4..156cca62 100644 Binary files a/dump.rdb and b/dump.rdb differ