close cashier total foc fixed

This commit is contained in:
yarzar_code
2020-06-15 13:26:34 +06:30
parent a7f9fc1199
commit 160c43699e
2 changed files with 8 additions and 11 deletions

View File

@@ -152,11 +152,12 @@ class ShiftSale < ApplicationRecord
def self.get_by_shift_other_payment(shift)
payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
other_payment = Sale.select("sale_payments.payment_method as name,
other_payment = Sale.select("sales.sale_id,sale_payments.payment_method as name,
#{payment_methods.map { |method| "SUM(case when (sale_payments.payment_method='#{method}') then sale_payments.payment_amount else 0 end) as #{method}"}.join(', ')},
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.where("sales.shift_sale_id =? and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift.id)
return other_payment
end
def self.calculate_total_price_by_accounts(shift,type)