Edit Waste and Spoil report showing by menu category,sorting by menu category, product name Qty and UI change

This commit is contained in:
San Wai Lwin
2018-05-04 09:52:52 +06:30
parent 66a1d0bdad
commit 39264db517
2 changed files with 87 additions and 53 deletions

View File

@@ -1139,8 +1139,18 @@ def self.get_wastes_and_spoilages(from,to,status)
else
type = "and sales.sale_status = 'waste'"
end
query = Sale.all.where("sales.receipt_date between ? and ? #{type}",from,to)
.group("sales.receipt_no")
# query = Sale.all.where("sales.receipt_date between ? and ? #{type}",from,to)
# .group("sales.receipt_no")
# sales.receipt_no,menu_categories.id,sale_items.item_instance_code
query = Sale.select("sales.sale_id,sales.receipt_no,sales.created_at,sales.total_amount,sales.grand_total,sales.rounding_adjustment,sales.shift_sale_id,sale_items.product_name,sale_items.product_code,sale_items.item_instance_code,sale_items.qty,sale_items.price,sale_items.unit_price,menu_categories.name")
.joins("JOIN sale_items ON sales.sale_id = sale_items.sale_id" +
" JOIN menu_item_instances ON sale_items.item_instance_code = menu_item_instances.item_instance_code" +
" JOIN menu_items ON menu_item_instances.menu_item_id = menu_items.id" +
" JOIN menu_categories ON menu_items.menu_category_id = menu_categories.id")
.where("sales.receipt_date between ? and ? #{type}",from,to)
.group("sales.receipt_no,menu_categories.id,sale_items.item_instance_code")
.order("sales.sale_id,menu_categories.name,sale_items.product_name")
end
# def self.get_separate_tax(from,to,payment_method=nil)