feat: add mmqr in shift sale report
This commit is contained in:
@@ -826,7 +826,8 @@ def self.get_by_shiftsales(from,to,shift)
|
||||
:shift_closed_at => shift_sale.shift_closed_at,
|
||||
:cash_sales => shift_sale.cash_sales,
|
||||
:credit_sales => shift_sale.credit_sales,
|
||||
:other_sales => shift_sale.other_sales.to_f,
|
||||
:other_sales => (shift_sale.other_sales.to_f - ShiftSale.get_by_shift_mmqr_payment(shift_sale.id).to_f).abs,
|
||||
:mmqr_sales => ShiftSale.get_by_shift_mmqr_payment(shift_sale.id).to_f,
|
||||
:foc_sales => foc,
|
||||
:grand_total => shift_sale.grand_total,
|
||||
:shift_id => shift_sale.id
|
||||
|
||||
@@ -152,6 +152,15 @@ class ShiftSale < ApplicationRecord
|
||||
return closing_balance
|
||||
end
|
||||
|
||||
def self.get_by_shift_mmqr_payment(shift)
|
||||
Sale.joins(:sale_payments)
|
||||
.where(shift_sale_id: shift, sale_status: 'completed')
|
||||
.where(sale_payments: { payment_method: 'mmqr' })
|
||||
.where.not(sale_payments: { payment_status: 'cancelled' })
|
||||
.where.not(sale_payments: { payment_amount: 0 })
|
||||
.sum("sale_payments.payment_amount")
|
||||
end
|
||||
|
||||
def self.get_by_shift_other_payment(shift)
|
||||
payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user