Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant
This commit is contained in:
@@ -78,12 +78,25 @@ class Sale < ApplicationRecord
|
||||
self.tax_type = "exclusive"
|
||||
|
||||
# set cashier
|
||||
if cashier != nil
|
||||
open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
||||
current_shift = ShiftSale.current_shift
|
||||
shift = ShiftSale.current_open_shift(cashier.id)
|
||||
|
||||
# set cashier
|
||||
if shift != nil
|
||||
self.cashier_id = cashier.id
|
||||
self.cashier_name = cashier.name
|
||||
self.shift_sale_id = shift.id
|
||||
else
|
||||
self.cashier_id = requested_by.id
|
||||
self.cashier_name = requested_by.name
|
||||
if open_cashier.nil?
|
||||
self.cashier_id = requested_by.id
|
||||
self.cashier_name = requested_by.name
|
||||
self.shift_sale_id = current_shift.id
|
||||
else
|
||||
self.cashier_id = current_shift.employee_id
|
||||
self.cashier_name = Employee.find(current_shift.employee_id).name
|
||||
self.shift_sale_id = current_shift.id
|
||||
end
|
||||
end
|
||||
|
||||
# set waiter
|
||||
@@ -743,7 +756,7 @@ 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," +
|
||||
"i.remark as status_type,"+
|
||||
" mii.price as unit_price,i.price as price,i.product_name as product_name, mc.name as" +
|
||||
" 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" +
|
||||
@@ -754,7 +767,7 @@ def self.get_item_query()
|
||||
# "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.group("acc.title,mi.account_id,mi.menu_category_id,i.product_name")
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user