feat: add mmqr cancel and void amount in shift sale report.

This commit is contained in:
Htoi San Aung
2025-07-02 16:00:06 +06:30
parent c66980e1b3
commit 4790309150

View File

@@ -64,6 +64,7 @@ class CloseCashierPdf < Prawn::Document
end end
def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_waste,total_spoile,total_other_charges,total_credit_payments,payment_methods,foodcourt) def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_waste,total_spoile,total_other_charges,total_credit_payments,payment_methods,foodcourt)
total_void = get_shift_sale_audit_totals(shift_sale.id)
move_down 7 move_down 7
y_position = cursor y_position = cursor
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
@@ -320,7 +321,15 @@ class CloseCashierPdf < Prawn::Document
text "Total Void :", :size => self.item_font_size, :align => :right text "Total Void :", :size => self.item_font_size, :align => :right
end end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "(#{shift_sale.total_void})", :size => self.item_font_size, :align => :right text "(#{total_void[:void_amount]})", :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 "MMQR Cancel :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "(#{total_void[:mmqr_cancel_amount]})", :size => self.item_font_size, :align => :right
end end
y_position = cursor y_position = cursor
@@ -546,4 +555,23 @@ class CloseCashierPdf < Prawn::Document
text_box "#{sub_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 text_box "#{sub_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
} }
end end
def get_shift_sale_audit_totals(shift_sale_id)
sales = Sale.where(shift_sale_id: shift_sale_id)
.joins(:sale_audits)
.where(sale_audits: { action: ['CANCEL_MMQR_PAYMENT', 'SALEVOID'] })
results = sales.select(
"SUM(CASE WHEN sale_audits.action = 'CANCEL_MMQR_PAYMENT' THEN sales.grand_total ELSE 0 END) AS mmqr_cancel_amount",
"SUM(CASE WHEN sale_audits.action = 'SALEVOID' THEN sales.grand_total ELSE 0 END) AS void_amount",
"SUM(sales.grand_total) AS total_cancel_and_void_amount"
).first
{
mmqr_cancel_amount: results.mmqr_cancel_amount || 0,
void_amount: results.void_amount || 0,
total_cancel_and_void_amount: results.total_cancel_and_void_amount || 0
}
end
end end