diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb index cea64868..c53f6e69 100755 --- a/app/controllers/origami/void_controller.rb +++ b/app/controllers/origami/void_controller.rb @@ -65,15 +65,7 @@ class Origami::VoidController < BaseOrigamiController current_balance = nil # For Cashier by Zone - bookings = Booking.where("sale_id='#{sale_id}'") - if bookings.count > 1 - # for Multiple Booking - if bookings[0].dining_facility_id.to_i>0 - table = DiningFacility.find(bookings[0].dining_facility_id) - end - end - - if bookings[0].dining_facility_id.to_i > 0 + if sale.booking.dining_facility_id.to_i > 0 cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id) cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id) else @@ -81,7 +73,6 @@ class Origami::VoidController < BaseOrigamiController cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id) end - # if ENV["SERVER_MODE"] != "cloud" #no print in cloud server # get printer info # print_settings = PrintSetting.find_by_unique_code('ReceiptBillPdf') # SaleItemsPdf diff --git a/app/models/employee.rb b/app/models/employee.rb index 0a103ab7..a061204e 100755 --- a/app/models/employee.rb +++ b/app/models/employee.rb @@ -36,7 +36,6 @@ class Employee < ApplicationRecord end end return nil - end def self.authenticate_by_token(session_token) @@ -44,7 +43,7 @@ class Employee < ApplicationRecord user = Employee.find_by_token_session(session_token) expiry_time = login_expiry_time - if user && user.session_expiry.utc > DateTime.now.utc + if user && user.session_expiry && user.session_expiry.utc > DateTime.now.utc #Extend the login time each time authenticatation take place user.session_expiry = user.session_expiry.utc + expiry_time.minutes user.save diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 854c4108..94506351 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -684,8 +684,11 @@ class SalePayment < ApplicationRecord end end sale.save! - table_update_status(sale) - update_shift + + if sale.sale_status == 'completed' + table_update_status(sale) + update_shift + end end # update for cashier shift diff --git a/app/models/shift_sale.rb b/app/models/shift_sale.rb index a3545863..dc96a425 100755 --- a/app/models/shift_sale.rb +++ b/app/models/shift_sale.rb @@ -28,7 +28,7 @@ class ShiftSale < ApplicationRecord #find open shift where is open today and is not closed and login by current cashier #DATE(shift_started_at)=? and today_date = DateTime.now.strftime("%Y-%m-%d") - shift = ShiftSale.where("shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}").take + shift = ShiftSale.where("shift_started_at is not null and shift_closed_at is null and employee_id = ?", current_user).take return shift #end end @@ -132,7 +132,7 @@ class ShiftSale < ApplicationRecord self.commercial_taxes = self.commercial_taxes.to_f - tax.to_f self.total_rounding = self.total_rounding - saleobj.rounding_adjustment self.total_void = self.total_void + saleobj.grand_total - + if saleobj.customer.customer_type == "Dinein" self.dining_count = self.dining_count - 1 else