change top item

This commit is contained in:
phyusin
2017-12-15 11:54:41 +06:30
parent cb9cb72f8e
commit 909bde9798

View File

@@ -1107,7 +1107,7 @@ end
def self.top_items(today)
query = Sale.select("a.product_name as item_name, SUM(a.price) as item_total_price")
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
.where("sales.sale_status = 'completed' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
.where("(a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
.group("a.product_code")
.order("SUM(a.qty) DESC")
.first()