change UI and query for dashboard and UI for Origami/Commissions

This commit is contained in:
phyusin
2017-11-23 11:56:49 +06:30
parent 86ec4c7c80
commit b64229aded
7 changed files with 120 additions and 101 deletions

View File

@@ -988,7 +988,7 @@ end
end
def self.total_payment_methods(today)
query = Sale.select("sp.payment_method")
query = Sale.select("distinct sp.payment_method")
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today)
.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
end
@@ -996,7 +996,7 @@ end
def self.payment_sale(payment_method, today)
query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
if payment_method == 'card'
query = query.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb"',today)
query = query.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb")',today)
else
query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
end