To update close cashier

This commit is contained in:
San Wai Lwin
2018-02-20 17:35:54 +06:30
parent e50915aa3b
commit 51a243ea7c
5 changed files with 116 additions and 56 deletions

View File

@@ -1,8 +1,8 @@
class CloseCashierCustomerizePdf < Prawn::Document
class CloseCashierCustomisePdf < 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, shift_sale,shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,total_dinein,total_takeway)
def initialize(printer_settings, shift_sale,shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,total_dinein,total_takeway,total_other_charges)
self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width
self.page_height = printer_settings.page_height
self.margin = 5
@@ -54,7 +54,7 @@ class CloseCashierCustomerizePdf < Prawn::Document
stroke_horizontal_rule
shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,printer_settings.precision,delimiter,total_dinein,total_takeway)
shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,printer_settings.precision,delimiter,total_dinein,total_takeway,total_other_charges)
end
def header (shop_details)
@@ -70,7 +70,7 @@ class CloseCashierCustomerizePdf < Prawn::Document
stroke_horizontal_rule
end
def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_dinein,total_takeway)
def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_dinein,total_takeway,total_other_charges)
move_down 7
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
@@ -159,27 +159,76 @@ class CloseCashierCustomerizePdf < Prawn::Document
stroke_horizontal_rule
move_down 7
@total_grand_total = shift_sale.grand_total + @overall + @total_foc + shift_sale.total_void
#start total amount by Account Like Food / Beverage /..
total_discount_account = 0
total_discount_by_account.each do |amount|
total_discount_account = total_discount_account.to_f + amount.total_price.to_f
end
#end total amount by Account
#start total FOC amount
@total_foc = 0
other_payment.each do |other|
@total_foc = other.foc_amount.round(2)
end
#end total FOC amount
total_grand_total = shift_sale.grand_total + shift_sale.total_discounts + @total_foc.to_f + shift_sale.total_void.to_f - total_discount_account.to_f
# @total_grand_total = @shift_sale.grand_total + @overall + @total_foc + @shift_sale.total_void
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Grand Total :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{number_with_precision(shift_sale.cash_out, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
text "#{number_with_precision(total_grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Discount :", :size => self.item_font_size, :align => :right
#start total amount by Account Like Food / Beverage /..
total_discount_by_account.each do |amount|
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total #{amount.account_name} Discount:", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
end
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(@overall, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
#end total amount by Account
if total_member_discount[0].member_discount.present?
@member_discount = total_member_discount[0].member_discount rescue 0.0
@overall = shift_sale.total_discounts - @member_discount
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Member Discount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(@member_discount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
else
@overall = shift_sale.total_discounts
end
if @overall > 0
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Overall Discount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "-#{ number_with_precision(@overall, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total FOC :", :size => self.item_font_size, :align => :right
end
if @total_foc.nil?
@total_foc = 0
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "(#{ number_with_precision(@total_foc, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
end
@@ -248,13 +297,13 @@ class CloseCashierCustomerizePdf < Prawn::Document
text "#{ number_with_precision(other.jcb_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Reedem Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(other.paypar_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
# y_position = cursor
# bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
# text "Reedem Payment :", :size => self.item_font_size, :align => :right
# end
# bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
# text "#{ number_with_precision(other.paypar_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
# end
end
else
y_position = cursor
@@ -287,26 +336,32 @@ class CloseCashierCustomerizePdf < Prawn::Document
move_down -5
stroke_horizontal_rule
move_down 7
# start Dinein and Takeaway
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Dinein :", :size => self.item_font_size, :align => :right
end
if total_dinein.nil?
total_dinein = 0
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(total_dinein, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
text "#{ number_with_precision(total_dinein, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Takeaway :", :size => self.item_font_size, :align => :right
end
if total_takeway.nil?
total_takeway = 0
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(total_takeway, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
# stop Dinein and Takeaway
move_down -5
stroke_horizontal_rule
@@ -352,33 +407,18 @@ class CloseCashierCustomerizePdf < Prawn::Document
stroke_horizontal_rule
move_down 7
#start total amount by Account Like Food / Beverage /..
total_discount_by_account.each do |amount|
# total_discount_by_account.each do |amount|
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total #{amount.account_name} Discount:", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
end
end
# y_position = cursor
# bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
# text "Total #{amount.account_name} Discount:", :size => self.item_font_size, :align => :right
# end
# bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
# text "#{ number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
# end
# end
#end total amount by Account
if total_member_discount[0].member_discount.present?
@member_discount = total_member_discount[0].member_discount rescue 0.0
@overall = shift_sale.total_discounts - @member_discount
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Member Discount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(@member_discount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
else
@overall = shift_sale.total_discounts
end
# y_position = cursor
# bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
# text "Grand Total :", :size => self.item_font_size, :align => :right
@@ -400,6 +440,18 @@ class CloseCashierCustomerizePdf < Prawn::Document
end
#end total amount by Account
#start total other charges amount
if total_other_charges > 0
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Other Charges :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(total_other_charges, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
#end total other charges amount
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Dine-in Count :", :size => self.item_font_size, :align => :right