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 CloseCashierCustomisePdf < Prawn::Document
|
||||
include ActionView::Helpers::NumberHelper
|
||||
include NumberFormattable
|
||||
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,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
||||
@@ -39,22 +39,11 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
# font "public/fonts/Zawgyi-One.ttf"
|
||||
# font "public/fonts/padauk.ttf"
|
||||
|
||||
#precision checked
|
||||
if printer_settings.precision.to_i > 2
|
||||
printer_settings.precision = 2
|
||||
end
|
||||
#check delimiter
|
||||
if printer_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end
|
||||
|
||||
header( shop_details)
|
||||
|
||||
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,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
||||
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,total_waste,total_spoile,total_credit_payments)
|
||||
end
|
||||
|
||||
def header (shop_details)
|
||||
@@ -103,13 +92,13 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||
text "#{ shift_sale.shift_closed_at.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') }" , :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||
text "Opening Float : ", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||
text "#{ number_with_precision(shift_sale.opening_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
|
||||
text "#{ number_format(shift_sale.opening_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
@@ -117,8 +106,8 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Closing Float : ", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||
text "#{ number_with_precision(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
|
||||
# text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}"
|
||||
text "#{ number_format(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
|
||||
# text_box "#{number_format(total_price, :precision => precision.to_i, :delimiter => delimiter)}"
|
||||
end
|
||||
|
||||
|
||||
@@ -135,7 +124,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Received Amount :", :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.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{number_format(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
|
||||
end
|
||||
|
||||
@@ -144,7 +133,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Cash In :", :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_in, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{number_format(shift_sale.cash_in, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
@@ -152,7 +141,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Cash Out :", :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_format(shift_sale.cash_out, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
move_down -5
|
||||
@@ -165,7 +154,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
|
||||
total_discount_account = total_discount_account.to_f + amount.total_price.to_f
|
||||
end
|
||||
#end total amount by Account
|
||||
#end total amount by Account
|
||||
|
||||
#start total FOC amount
|
||||
@total_foc = 0
|
||||
@@ -173,7 +162,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
@total_foc = other.foc_amount.round(2)
|
||||
end
|
||||
|
||||
#end total FOC amount
|
||||
#end total FOC amount
|
||||
total_grand_total = shift_sale.grand_total + @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
|
||||
@@ -181,21 +170,21 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
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(total_grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{number_format(total_grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
#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
|
||||
text "#{ number_format(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
#end total amount by Account
|
||||
#end total amount by Account
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||
@@ -205,8 +194,8 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
@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
|
||||
text "(#{ number_format(@total_foc, :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
|
||||
@@ -218,7 +207,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
|
||||
move_down -5
|
||||
stroke_horizontal_rule
|
||||
move_down 7
|
||||
move_down 7
|
||||
|
||||
@total_foc = 0
|
||||
y_position = cursor
|
||||
@@ -226,7 +215,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Cash 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(shift_sale.cash_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(shift_sale.cash_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
@@ -234,9 +223,9 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Credit 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(shift_sale.credit_sales, :precision => precision.to_i, :delimiter => delimiter) }", :size => self.item_font_size, :align => :right
|
||||
text "#{number_format(shift_sale.credit_sales, :precision => precision.to_i, :delimiter => delimiter) }", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
#start other payment details
|
||||
#start other payment details
|
||||
if shift_sale.other_sales > 0
|
||||
other_payment.each do |other|
|
||||
@total_foc = other.foc_amount.round(2)
|
||||
@@ -246,7 +235,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "MPU 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.mpu_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.mpu_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -256,7 +245,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "VISA 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.visa_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{number_format(other.visa_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -266,7 +255,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Master 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.master_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.master_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -276,7 +265,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "JCB 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.jcb_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.jcb_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -286,7 +275,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "UNIONPAY 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.unionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.unionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -296,7 +285,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Alipay 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.alipay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.alipay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -306,7 +295,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "JunctionPay 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.junctionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.junctionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -316,7 +305,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Dinga 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.dinga_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.dinga_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -326,7 +315,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Redeem 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
|
||||
text "#{ number_format(other.paypar_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -336,7 +325,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Paymal 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.paymal_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.paymal_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -346,7 +335,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "GiftVoucher 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.giftvoucher_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.giftvoucher_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -356,7 +345,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Other 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(shift_sale.other_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(shift_sale.other_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -365,8 +354,8 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Rounding Adjustments :", :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.total_rounding, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
|
||||
text "#{ number_format(shift_sale.total_rounding, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
@@ -374,14 +363,14 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Gross Sale :", :style => :bold, :size => self.header_font_size - 1, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(shift_sale.grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :style => :bold, :size => self.header_font_size - 1, :align => :right
|
||||
text "#{ number_format(shift_sale.grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :style => :bold, :size => self.header_font_size - 1, :align => :right
|
||||
end
|
||||
|
||||
# end other payment details
|
||||
# end other payment details
|
||||
move_down -5
|
||||
stroke_horizontal_rule
|
||||
move_down 7
|
||||
|
||||
|
||||
# start Dinein and Takeaway
|
||||
|
||||
y_position = cursor
|
||||
@@ -392,7 +381,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
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_format(total_dinein, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
@@ -401,11 +390,11 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
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
|
||||
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_format(total_takeway, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
|
||||
# stop Dinein and Takeaway
|
||||
move_down -5
|
||||
@@ -419,7 +408,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "#{tax.tax_name} :", :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(tax.st_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(tax.st_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -428,7 +417,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Total Taxes :", :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.total_taxes, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(shift_sale.total_taxes, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
@@ -436,7 +425,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Net Sales :", :style => :bold, :size => self.header_font_size - 1, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{number_with_precision(shift_sale.nett_sales, :precision => precision.to_i, :delimiter => delimiter) }", :style => :bold , :size => self.header_font_size - 1, :align => :right
|
||||
text "#{number_format(shift_sale.nett_sales, :precision => precision.to_i, :delimiter => delimiter) }", :style => :bold , :size => self.header_font_size - 1, :align => :right
|
||||
end
|
||||
|
||||
if total_credit_payments && total_credit_payments.to_f > 0
|
||||
@@ -445,7 +434,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Total Credit 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(total_credit_payments, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(total_credit_payments, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
#end for service charges and commercial tax
|
||||
@@ -463,16 +452,16 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
move_down 7
|
||||
#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
|
||||
# text "#{ number_format(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
|
||||
# end
|
||||
# end
|
||||
#end total amount by Account
|
||||
#end total amount by Account
|
||||
|
||||
# y_position = cursor
|
||||
# bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||
@@ -481,19 +470,19 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
# bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
# text "#{shift_sale.grand_total}", :size => self.item_font_size, :align => :right
|
||||
# end
|
||||
|
||||
|
||||
|
||||
#start total amount by Account Like Food / Beverage /..
|
||||
total_amount_by_account.each do |amount|
|
||||
total_amount_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} Amount :", :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
|
||||
text "#{number_format(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
#end total amount by Account
|
||||
#end total amount by Account
|
||||
|
||||
#start total other charges amount
|
||||
if total_other_charges.present?
|
||||
@@ -502,9 +491,9 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
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
|
||||
text "#{ number_format(total_other_charges, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
end
|
||||
#end total other charges amount
|
||||
|
||||
move_down -5
|
||||
@@ -513,32 +502,32 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
|
||||
#start total over all discount
|
||||
if total_member_discount[0].member_discount.present?
|
||||
@member_discount = total_member_discount[0].member_discount rescue 0.0
|
||||
@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
|
||||
text "#{ number_format(@member_discount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
else
|
||||
@overall = shift_sale.total_discounts
|
||||
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 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
|
||||
text "-#{ number_format(@overall, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
move_down -5
|
||||
stroke_horizontal_rule
|
||||
move_down 7
|
||||
end
|
||||
end
|
||||
#end total over all discount
|
||||
|
||||
if total_waste.to_f > 0
|
||||
@@ -547,7 +536,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Total Waste :", :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_waste, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
|
||||
text "(#{ number_format(total_waste, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -557,7 +546,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Total Spoile :", :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_spoile, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
|
||||
text "(#{ number_format(total_spoile, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -591,4 +580,3 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
move_down 5
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user