close cashier pdf and receipt bill pdf changes for credit payment

This commit is contained in:
phyusin
2018-07-12 15:50:58 +06:30
parent ebd3918cfa
commit 03abeabb4e
12 changed files with 116 additions and 52 deletions

View File

@@ -178,4 +178,11 @@ class ShiftSale < ApplicationRecord
end
def self.get_shift_sales_with_credit_payment(shift_id)
query = SalePayment.select("(CASE WHEN SUM(sale_payments.payment_amount) > 0 THEN SUM(sale_payments.payment_amount) ELSE 0 END) as total_credit_payments")
.joins(" JOIN sale_audits sa ON SUBSTRING_INDEX(sa.remark,'||',1)=sale_payments.sale_payment_id")
.where("SUBSTRING_INDEX(SUBSTRING_INDEX(sa.remark,'||',-1),' -> ',1) = #{shift_id}")
.first()
end
end