add sum item qty in receipt bill

This commit is contained in:
phyusin
2018-05-02 13:46:43 +06:30
parent 6d6b6c6791
commit 0e87ba87f3
2 changed files with 18 additions and 8 deletions

View File

@@ -202,10 +202,12 @@ class ReceiptBillA5Pdf < Prawn::Document
y_position = cursor
move_down line_move
sub_total = 0.0
total_qty = 0.0
sale_items.each do |item|
# check for item not to show
if item.price != 0
sub_total += item.price #(item.qty*item.unit_price) - comment for room charges
total_qty += item.qty
qty = item.qty
total_price = item.price #item.qty*item.unit_price - comment for room charges
price = item.unit_price
@@ -240,12 +242,15 @@ class ReceiptBillA5Pdf < Prawn::Document
move_down line_move
y_position = cursor
bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do
bounding_box([0,y_position], :width =>self.item_width + self.price_width, :height => self.item_height) do
text "Sub Total", :size => self.item_font_size,:align => :left
end
bounding_box([self.description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}" ,:delimiter => ',', :size => self.item_font_size,:align => :right
end
bounding_box([self.item_width + self.price_width + 11,y_position], :width =>self.qty_width, :height => self.item_height) do
text "#{number_with_precision(total_qty, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :center
end
bounding_box([self.item_width + self.price_width + 8,y_position], :width =>self.total_width, :height => self.item_height) do
text "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
end
end
def all_total(sale_data,precision,delimiter)

View File

@@ -196,10 +196,12 @@ class ReceiptBillPdf < Prawn::Document
y_position = cursor
move_down line_move
sub_total = 0.0
total_qty = 0.0
sale_items.each do |item|
# check for item not to show
if item.price != 0
sub_total += item.price #(item.qty*item.unit_price) - comment for room charges
total_qty += item.qty
qty = item.qty
total_price = item.price #item.qty*item.unit_price - comment for room charges
price = item.unit_price
@@ -235,12 +237,15 @@ class ReceiptBillPdf < Prawn::Document
move_down line_move
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
bounding_box([0,y_position], :width =>self.item_width + self.price_width, :height => self.item_height) do
text "Sub Total", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}" ,:delimiter => ',', :size => self.item_font_size,:align => :right
end
bounding_box([self.item_width + self.price_width + 11,y_position], :width =>self.qty_width, :height => self.item_height) do
text "#{number_with_precision(total_qty, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :center
end
bounding_box([self.item_width + self.price_width + 8,y_position], :width =>self.total_width, :height => self.item_height) do
text "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
end
end
def all_total(sale_data,precision,delimiter)