From 909bde979812435f590146ac482542d5ba7dbf61 Mon Sep 17 00:00:00 2001 From: phyusin Date: Fri, 15 Dec 2017 11:54:41 +0630 Subject: [PATCH] change top item --- app/models/sale.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/sale.rb b/app/models/sale.rb index 1598563f..29607c11 100755 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -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()