fix dis and payment foc and sale item report
This commit is contained in:
@@ -182,7 +182,7 @@ class Sale < ApplicationRecord
|
||||
sale_item.product_alt_name = "-"
|
||||
sale_item.qty = block_count
|
||||
sale_item.unit_price = chargeObj.unit_price
|
||||
sale_item.taxable_price = sale_item.qty * sale_item.unit_price
|
||||
sale_item.taxable_price = diningprice
|
||||
sale_item.is_taxable = chargeObj.taxable
|
||||
sale_item.sale_id = self.id
|
||||
sale_item.price = diningprice
|
||||
@@ -608,19 +608,33 @@ def self.get_by_shift_sale(from,to,status)
|
||||
end
|
||||
|
||||
def self.get_item_query()
|
||||
# query = SaleItem.select("acc.title as account_name,account_id, item_instance_code as item_code, " +
|
||||
# "SUM(qty * unit_price) as grand_total,SUM(qty) as total_item," +
|
||||
# " unit_price as unit_price,product_name as product_name, 'cat' as" +
|
||||
# " menu_category_name,'test' as menu_category_id ")
|
||||
|
||||
# query = query.joins("JOIN sales s ON s.sale_id = sale_items.sale_id" +
|
||||
# " JOIN shift_sales sh ON sh.`id` = sales.shift_sale_id")
|
||||
# # "JOIN employee_accesses ea ON ea.`employee_id` = sales.cashier_id ")
|
||||
|
||||
# query = query.joins(" JOIN accounts acc ON acc.id = account_id")
|
||||
# query = query.where("item_instance_code is not NULL")
|
||||
# query = query.group("item_instance_code").order("account_id")
|
||||
|
||||
query = Sale.select("acc.title as account_name,mi.account_id, i.item_instance_code as item_code, " +
|
||||
"(i.qty * i.unit_price) as grand_total,(i.qty) as total_item," +
|
||||
"SUM(i.qty * i.unit_price) as grand_total,SUM(i.qty) as total_item," +
|
||||
" i.unit_price as unit_price,i.product_name as product_name, mc.name as" +
|
||||
" menu_category_name,mc.id as menu_category_id ")
|
||||
|
||||
query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id" +
|
||||
" JOIN menu_items mi ON i.product_code = mi.item_code" +
|
||||
" JOIN menu_item_instances mii ON i.item_instance_code = mii.item_instance_code" +
|
||||
" JOIN menu_items mi ON mi.id = mii.menu_item_id" +
|
||||
" JOIN shift_sales sh ON sh.`id` = sales.shift_sale_id" +
|
||||
" JOIN menu_categories mc ON mc.id = mi.menu_category_id ")
|
||||
# "JOIN employee_accesses ea ON ea.`employee_id` = sales.cashier_id ")
|
||||
|
||||
query = query.joins(" JOIN accounts acc ON acc.id = mi.account_id")
|
||||
query = query.where("i.unit_price > 0")
|
||||
query = query.where("i.item_instance_code IS NOT NULL")
|
||||
query = query.group("i.item_instance_code").order("mi.account_id, mi.menu_category_id")
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user