update open cashier multiple
This commit is contained in:
@@ -81,11 +81,15 @@ class Sale < ApplicationRecord
|
|||||||
|
|
||||||
#Default Tax - Values
|
#Default Tax - Values
|
||||||
self.tax_type = "exclusive"
|
self.tax_type = "exclusive"
|
||||||
|
# current cashier login
|
||||||
|
open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
||||||
|
current_shift = ShiftSale.current_shift
|
||||||
|
# shift with terminal zone
|
||||||
|
table = DiningFacility.find(booking.dining_facility_id)
|
||||||
|
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||||
|
|
||||||
# set cashier
|
# set cashier
|
||||||
if order_source.downcase == "emenu"
|
if order_source.downcase == "emenu"
|
||||||
table = DiningFacility.find(booking.dining_facility_id)
|
|
||||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
|
||||||
shift = ShiftSale.where("shift_started_at is not null and shift_closed_at is null and cashier_terminal_id = #{cashier_zone.cashier_terminal_id}").first
|
shift = ShiftSale.where("shift_started_at is not null and shift_closed_at is null and cashier_terminal_id = #{cashier_zone.cashier_terminal_id}").first
|
||||||
#for multiple zone with terminal
|
#for multiple zone with terminal
|
||||||
if shift.nil?
|
if shift.nil?
|
||||||
@@ -98,24 +102,30 @@ class Sale < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
|
||||||
current_shift = ShiftSale.current_shift
|
|
||||||
shift = ShiftSale.current_open_shift(cashier.id)
|
shift = ShiftSale.current_open_shift(cashier.id)
|
||||||
end
|
end
|
||||||
# set cashier
|
# set cashier
|
||||||
if shift != nil
|
if shift != nil #if current login employee open shift
|
||||||
self.cashier_id = cashier.id
|
self.cashier_id = cashier.id
|
||||||
self.cashier_name = cashier.name
|
self.cashier_name = cashier.name
|
||||||
self.shift_sale_id = shift.id
|
self.shift_sale_id = shift.id
|
||||||
else
|
else
|
||||||
if open_cashier.count>0
|
if open_cashier.count>0 # if we have two open cashier
|
||||||
self.cashier_id = open_cashier[0].id
|
# table and terminal in multiple shift
|
||||||
self.cashier_name = open_cashier[0].name
|
shift = ShiftSale.where("shift_started_at is not null and shift_closed_at is null and cashier_terminal_id = #{cashier_zone.cashier_terminal_id}").first
|
||||||
shift_id = ShiftSale.current_open_shift(open_cashier[0].id)
|
if shift.nil?
|
||||||
if shift_id
|
self.cashier_id = open_cashier[0].id
|
||||||
self.shift_sale_id = shift_id.id
|
self.cashier_name = open_cashier[0].name
|
||||||
|
shift_id = ShiftSale.current_open_shift(open_cashier[0].id)
|
||||||
|
if shift_id
|
||||||
|
self.shift_sale_id = shift_id.id
|
||||||
|
else
|
||||||
|
self.shift_sale_id = current_shift.id
|
||||||
|
end
|
||||||
else
|
else
|
||||||
self.shift_sale_id = current_shift.id
|
self.cashier_id = shift.employee_id
|
||||||
|
self.cashier_name = Employee.find(shift.employee_id).name
|
||||||
|
self.shift_sale_id = shift.id
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
self.cashier_id = current_shift.employee_id
|
self.cashier_id = current_shift.employee_id
|
||||||
|
|||||||
Reference in New Issue
Block a user