total other amount added to SaleItemsPdf

This commit is contained in:
Zoey
2019-06-03 16:47:49 +06:30
parent fe0ae102f9
commit 4b73920e18
7 changed files with 95 additions and 36 deletions

View File

@@ -2,7 +2,7 @@ class SaleItemsPdf < 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,:text_width
def initialize(printer_settings, shop_details, period, type, account, from_date, to_date, shift, sale_items, acc_cate_count, menu_cate_count, total_by_acc)
def initialize(printer_settings, shop_details, period, type, account, from_date, to_date, shift, sale_items, total_other_charges, acc_cate_count, menu_cate_count, total_by_acc)
self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width
self.page_height = printer_settings.page_height
self.header_font_size = printer_settings.header_font_size.to_i
@@ -58,7 +58,7 @@ class SaleItemsPdf < Prawn::Document
sale_details(period, type, account, from_date, to_date, shift)
sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc)
sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc, total_other_charges)
end
def header (shop_details)
@@ -127,7 +127,7 @@ class SaleItemsPdf < Prawn::Document
move_down 10
end
def sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc)
def sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc, total_other_charges)
self.item_width = 73
self.price_width = 60
item_label_qty_front_width = (self.item_width+self.price_width) + 2
@@ -144,6 +144,7 @@ class SaleItemsPdf < Prawn::Document
total_amount = 0
total_qty = 0
sub_total = 0
flag = false
arr = Array.new
@@ -152,10 +153,14 @@ class SaleItemsPdf < Prawn::Document
if !arr.include?(item['menu_category_id'])
unless total_qty == 0 and sub_total == 0
if flag == true
move_down 5
stroke_horizontal_rule
total_details('Sub Total', total_qty, sub_total)
end
flag = true
total_qty = 0
sub_total = 0
@@ -173,7 +178,7 @@ class SaleItemsPdf < Prawn::Document
y_position = cursor
pad_top(15) {
text_box "Items", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
text_box "Price", :at =>[(self.item_width),y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :left, :overflow => :shrink_to_fix
text_box "Price", :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_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
text_box "Total", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
}
@@ -194,7 +199,7 @@ class SaleItemsPdf < Prawn::Document
text_box "#{item['grand_total'].to_i}", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
}
if item['total_item'].to_i > 0
if item['total_item'].to_i > 0 or item['status_type'] == 'foc' or item['status_type'] == 'void'
total_qty += item['total_item'].to_i
total_items += item['total_item'].to_i
end
@@ -204,11 +209,17 @@ class SaleItemsPdf < Prawn::Document
arr.push(item['menu_category_id'])
end
# stroke_horizontal_rule
move_down 5
stroke_horizontal_rule
total_details('Sub Total', total_qty, sub_total)
move_down 5
move_down 5
stroke_horizontal_rule
total_details('Total Amount', total_items, total_amount)
move_down 10
other_charges = get_other_charges(total_other_charges)
total_details('Total Other Amount', nil, other_charges)
move_down 20
end
end
@@ -220,8 +231,6 @@ class SaleItemsPdf < Prawn::Document
item_label_total_front_width = (self.item_width+self.price_width) + 2
item_label_total_end_width = 64
move_down 5
stroke_horizontal_rule
y_position = cursor
pad_top(15) {
text_box "#{col_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
@@ -230,4 +239,15 @@ class SaleItemsPdf < Prawn::Document
}
end
def get_other_charges(total_other_charges)
other_sub_total = 0
unless total_other_charges.nil?
total_other_charges.each do |charges|
other_sub_total += charges.grand_total
end
end
return other_sub_total
end
end