diff --git a/app/controllers/api/bill_controller.rb b/app/controllers/api/bill_controller.rb index ac12e453..108731b6 100755 --- a/app/controllers/api/bill_controller.rb +++ b/app/controllers/api/bill_controller.rb @@ -13,10 +13,15 @@ class Api::BillController < Api::ApiController # for Job table = DiningFacility.find(booking.dining_facility_id) + cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id) + + shift_by_terminal = ShiftSale.find_by_cashier_terminal_id(cashier_zone.cashier_terminal_id) + get_cashier_by_terminal = Employee.find(shift_by_terminal.employee_id) + if booking if booking.sale_id.nil? @sale = Sale.new - @status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee, get_cashier) + @status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee, get_cashier_by_terminal) else @status = true @sale_id = booking.sale_id diff --git a/app/models/sale.rb b/app/models/sale.rb index 420b1eda..d0004954 100755 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -71,8 +71,8 @@ class Sale < ApplicationRecord # set cashier if cashier != nil - self.cashier_id = cashier[0].id - self.cashier_name = cashier[0].name + self.cashier_id = cashier.id + self.cashier_name = cashier.name else self.cashier_id = requested_by.id self.cashier_name = requested_by.name