fixed report gift-voucher paymentmethod
This commit is contained in:
@@ -755,7 +755,7 @@ class Sale < ApplicationRecord
|
||||
payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
|
||||
|
||||
sales = select(Sale.column_names)
|
||||
.select("#{payment_methods.map { |method| "SUM(case when (sale_payments.payment_method='#{method}') then sale_payments.payment_amount else 0 end) as #{method == 'paypar' ? 'redeem' : method}"}.push('').join(', ')}
|
||||
.select("#{payment_methods.map { |method| "SUM(case when (sale_payments.payment_method='#{method}') then sale_payments.payment_amount else 0 end) as `#{method == 'paypar' ? 'redeem' : method}`"}.push('').join(', ')}
|
||||
SUM(case when (sale_payments.payment_method='cash') then sale_payments.payment_amount else 0 end) as cash_amount,
|
||||
SUM(case when (sale_payments.payment_method='creditnote') then sale_payments.payment_amount else 0 end) -
|
||||
SUM(case when (sale_payments.payment_method not in('creditnote') and sale_audits.sale_audit_id IS NOT NULL) then sale_payments.payment_amount else 0 end) as credit_amount,
|
||||
@@ -776,7 +776,7 @@ class Sale < ApplicationRecord
|
||||
(IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0)) - (IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) / 21) as net_sale,
|
||||
(IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0)) + (IFNULL(SUM(case when (sale_status='completed') then total_discount else 0 end),0)) as gross_sale,
|
||||
CAST((CONVERT_TZ(receipt_date,'+00:00','+06:30')) AS DATE) as sale_date,
|
||||
#{payment_methods.map { |method| pm = method == 'paypar' ? 'redeem' : method; "SUM(#{pm}) as #{pm}"}.push('').join(', ')}
|
||||
#{payment_methods.map { |method| pm = method == 'paypar' ? 'redeem' : method; "SUM(`#{pm}`) as `#{pm}`"}.push('').join(', ')}
|
||||
SUM(cash_amount) as cash_amount,
|
||||
SUM(credit_amount) as credit_amount,
|
||||
SUM(foc_amount) as foc_amount
|
||||
|
||||
Reference in New Issue
Block a user