Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant into adminbsb_ui_changes

This commit is contained in:
phyusin
2018-08-08 17:48:47 +06:30
2 changed files with 49 additions and 43 deletions

View File

@@ -17,7 +17,10 @@ class Origami::PaymentsController < BaseOrigamiController
# else # else
# table = DiningFacility.find(bookings[0].dining_facility_id) # table = DiningFacility.find(bookings[0].dining_facility_id)
# end # end
shift = ShiftSale.current_open_shift(current_user.id)
if !shift.nil?
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
else
if bookings[0].dining_facility_id.to_i > 0 if bookings[0].dining_facility_id.to_i > 0
table = DiningFacility.find(bookings[0].dining_facility_id) table = DiningFacility.find(bookings[0].dining_facility_id)
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id) cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
@@ -26,6 +29,7 @@ class Origami::PaymentsController < BaseOrigamiController
shift = ShiftSale.find(saleObj.shift_sale_id) shift = ShiftSale.find(saleObj.shift_sale_id)
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id) cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
end end
end
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server # if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
@@ -141,6 +145,11 @@ class Origami::PaymentsController < BaseOrigamiController
# For Cashier by Zone # For Cashier by Zone
# bookings = Booking.where("sale_id='#{sale_id}'") # bookings = Booking.where("sale_id='#{sale_id}'")
bookings = Booking.find_by_sale_id(sale_id) bookings = Booking.find_by_sale_id(sale_id)
shift = ShiftSale.current_open_shift(current_user.id)
if !shift.nil?
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
else
if bookings.dining_facility_id.to_i > 0 if bookings.dining_facility_id.to_i > 0
table = DiningFacility.find(bookings.dining_facility_id) table = DiningFacility.find(bookings.dining_facility_id)
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id) cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
@@ -153,6 +162,7 @@ class Origami::PaymentsController < BaseOrigamiController
shift = ShiftSale.find(saleObj.shift_sale_id) shift = ShiftSale.find(saleObj.shift_sale_id)
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id) cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
end end
end
# For Print # For Print
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server # if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
@@ -443,7 +453,10 @@ class Origami::PaymentsController < BaseOrigamiController
# else # else
# table = DiningFacility.find(bookings[0].dining_facility_id) # table = DiningFacility.find(bookings[0].dining_facility_id)
# end # end
shift = ShiftSale.current_open_shift(current_user.id)
if !shift.nil?
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
else
if bookings[0].dining_facility_id.to_i > 0 if bookings[0].dining_facility_id.to_i > 0
table = DiningFacility.find(bookings[0].dining_facility_id) table = DiningFacility.find(bookings[0].dining_facility_id)
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id) cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
@@ -452,6 +465,7 @@ class Origami::PaymentsController < BaseOrigamiController
shift = ShiftSale.find(saleObj.shift_sale_id) shift = ShiftSale.find(saleObj.shift_sale_id)
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id) cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
end end
end
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server # if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
@@ -551,12 +565,11 @@ class Origami::PaymentsController < BaseOrigamiController
# For Cashier by Zone # For Cashier by Zone
bookings = Booking.where("sale_id='#{sale_id}'") bookings = Booking.where("sale_id='#{sale_id}'")
# if bookings.count > 1
# # for Multiple Booking shift = ShiftSale.current_open_shift(current_user.id)
# table = DiningFacility.find(bookings[0].dining_facility_id) if !shift.nil?
# else cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
# table = DiningFacility.find(bookings[0].dining_facility_id) else
# end
if bookings[0].dining_facility_id.to_i > 0 if bookings[0].dining_facility_id.to_i > 0
table = DiningFacility.find(bookings[0].dining_facility_id) table = DiningFacility.find(bookings[0].dining_facility_id)
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id) cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
@@ -565,7 +578,7 @@ class Origami::PaymentsController < BaseOrigamiController
shift = ShiftSale.find(saleObj.shift_sale_id) shift = ShiftSale.find(saleObj.shift_sale_id)
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id) cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
end end
end
# Re-call Sale Data # Re-call Sale Data
saleObj = Sale.find(sale_id) saleObj = Sale.find(sale_id)

View File

@@ -85,11 +85,11 @@ class Sale < ApplicationRecord
open_cashier = Employee.where("role = 'cashier' AND token_session <> ''") open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
current_shift = ShiftSale.current_shift current_shift = ShiftSale.current_shift
# shift with terminal zone # 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?
@@ -112,8 +112,6 @@ class Sale < ApplicationRecord
else else
if open_cashier.count>0 # if we have two open cashier if open_cashier.count>0 # if we have two open cashier
# table and terminal in multiple shift # table and terminal in multiple shift
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
if shift.nil?
self.cashier_id = open_cashier[0].id self.cashier_id = open_cashier[0].id
self.cashier_name = open_cashier[0].name self.cashier_name = open_cashier[0].name
shift_id = ShiftSale.current_open_shift(open_cashier[0].id) shift_id = ShiftSale.current_open_shift(open_cashier[0].id)
@@ -122,11 +120,6 @@ class Sale < ApplicationRecord
else else
self.shift_sale_id = current_shift.id self.shift_sale_id = current_shift.id
end end
else
self.cashier_id = shift.employee_id
self.cashier_name = Employee.find(shift.employee_id).name
self.shift_sale_id = shift.id
end
else else
self.cashier_id = current_shift.employee_id self.cashier_id = current_shift.employee_id
self.cashier_name = Employee.find(current_shift.employee_id).name self.cashier_name = Employee.find(current_shift.employee_id).name