change query

This commit is contained in:
phyusin
2018-07-23 18:01:27 +06:30
parent 23049eeccf
commit ec651b2e3e

View File

@@ -866,7 +866,7 @@ class SalePayment < ApplicationRecord
.joins("INNER JOIN orders o ON o.order_id = so.order_id") .joins("INNER JOIN orders o ON o.order_id = so.order_id")
.where("(CASE WHEN (s.grand_total + s.amount_changed)=(select SUM(payment_amount) FROM sale_payments WHERE sale_id=s.sale_id AND payment_method!='creditnote') THEN NULL ELSE payment_method='creditnote' END) and s.sale_status = 'completed' #{receipt_no} #{customer}") .where("(CASE WHEN (s.grand_total + s.amount_changed)=(select SUM(payment_amount) FROM sale_payments WHERE sale_id=s.sale_id AND payment_method!='creditnote') THEN NULL ELSE payment_method='creditnote' END) and s.sale_status = 'completed' #{receipt_no} #{customer}")
if params[:type] == "cashier" if params[:type] == "cashier"
query = query.where("and o.source='#{params[:type]}' OR 0.source='emenu'") query = query.where("and o.source='#{params[:type]}' OR o.source='emenu'")
else else
query = query.where("and o.source='#{params[:type]}'") query = query.where("and o.source='#{params[:type]}'")
end end