change top item
This commit is contained in:
@@ -1107,7 +1107,7 @@ end
|
|||||||
def self.top_items(today)
|
def self.top_items(today)
|
||||||
query = Sale.select("a.product_name as item_name, SUM(a.price) as item_total_price")
|
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")
|
.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")
|
.group("a.product_code")
|
||||||
.order("SUM(a.qty) DESC")
|
.order("SUM(a.qty) DESC")
|
||||||
.first()
|
.first()
|
||||||
|
|||||||
Reference in New Issue
Block a user