Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant into adminbsb_ui_changes
This commit is contained in:
@@ -806,12 +806,27 @@ def self.get_by_shift_sale(from,to,status)
|
||||
return query = query.where("shift_sales.shift_started_at >= ?" + " AND shift_sales.shift_closed_at <= ?", from,to)
|
||||
end
|
||||
|
||||
def self.get_item_query()
|
||||
query = Sale.select("acc.title as account_name,mi.account_id, i.item_instance_code as item_code,i.account_id as account_id, " +
|
||||
"SUM(i.qty * i.unit_price) as grand_total,SUM(i.qty) as total_item,i.qty as qty," +
|
||||
def self.get_item_query(type)
|
||||
|
||||
if type == "revenue" || type.nil?
|
||||
sale_type = "i.status IS NULL and i.qty >0 "
|
||||
elsif type == "all"
|
||||
sale_type = ""
|
||||
elsif type == "discount"
|
||||
sale_type = "i.status = 'Discount'"
|
||||
elsif type == "foc"
|
||||
sale_type = "i.status = 'foc' and i.qty > 0"
|
||||
elsif type == "void"
|
||||
sale_type = "i.status = 'void' and i.qty > 0"
|
||||
elsif type == "other"
|
||||
sale_type = "i.item_instance_code IS NULL"
|
||||
end
|
||||
query = Sale.select("acc.title as account_name,mi.account_id,
|
||||
i.item_instance_code as item_code,i.account_id as account_id, " +
|
||||
"SUM(i.qty * i.unit_price) as grand_total,
|
||||
SUM(i.qty) as total_item,i.qty as qty," +
|
||||
"i.status as status_type,"+
|
||||
" i.unit_price,i.price as price,i.product_name as product_name, mc.name as" +
|
||||
" menu_category_name,mc.id as menu_category_id ")
|
||||
"i.unit_price,i.price as 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_item_instances mii ON i.item_instance_code = mii.item_instance_code" +
|
||||
@@ -820,7 +835,7 @@ def self.get_item_query()
|
||||
" 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.item_instance_code IS NOT NULL")
|
||||
query = query.where("#{sale_type}")
|
||||
query = query.group("acc.title,mi.account_id,mi.menu_category_id,i.product_name,i.unit_price")
|
||||
.order("acc.title desc, mi.account_id desc, mi.menu_category_id desc, i.unit_price asc")
|
||||
end
|
||||
@@ -835,10 +850,15 @@ def self.get_other_charges()
|
||||
query = query.group("i.sale_item_id")
|
||||
end
|
||||
|
||||
def self.get_by_shift_items(shift_sale_range, shift, from, to, status)
|
||||
def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type)
|
||||
# date_type_selection = get_sql_function_for_report_type(report_type)
|
||||
query = self.get_item_query()
|
||||
|
||||
if type == "other"
|
||||
other_charges = self.get_other_charges()
|
||||
query = self.get_item_query(type)
|
||||
else
|
||||
query = self.get_item_query(type)
|
||||
end
|
||||
|
||||
discount_query = 0
|
||||
total_card_amount = 0
|
||||
total_cash_amount = 0
|
||||
|
||||
Reference in New Issue
Block a user