foodcourt apis for app

This commit is contained in:
Thein Lin Kyaw
2022-07-08 16:06:12 +06:30
parent 7485486868
commit 063345eae3
37 changed files with 785 additions and 171 deletions

View File

@@ -17,14 +17,18 @@ class Api::BillController < Api::ApiController
@status = false
@error_message = "Operation failed, Could not request bill!"
else
# for Multiple Cashier by Zone
table = DiningFacility.find(booking.dining_facility_id)
order = booking.orders.first
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
unless shift = ShiftSale.current_open_shift(current_login_employee)
# for Multiple Cashier by Zone
if booking.dining_facility_id
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
else
shift = ShiftSale.current_shift
end
end
#for multiple zone with terminal
if !shift.nil?
@@ -57,22 +61,22 @@ class Api::BillController < Api::ApiController
# Bind shift sale id to sale
# @sale_data.shift_sale_id = shift_by_terminal.id
# @sale_data.save
if @sale_data
if @sale_data && booking.dining_facility_id.present?
#check checkInOut pdf print
checkout_time = Lookup.collection_of('checkout_time')
terminal = DiningFacility.find_by_id(booking.dining_facility_id)
cashier_terminal = CashierTerminal.find_by_id(terminal.zone_id)
if (!checkout_time.empty?) && (ENV["SERVER_MODE"] != "cloud") #no print in cloud server
terminal = DiningFacility.find_by_id(booking.dining_facility_id)
cashier_terminal = CashierTerminal.find_by_id(terminal.zone_id)
unique_code = "CheckInOutPdf"
printer = PrintSetting.find_by_unique_code(unique_code)
# print when complete click
order_queue_printer = Printer::OrderQueuePrinter.new(printer)
if !printer.nil?
order_queue_printer.print_check_in_out(printer,cashier_terminal , booking, table)
# print when complete click
order_queue_printer = Printer::OrderQueuePrinter.new(printer)
order_queue_printer.print_check_in_out(printer, cashier_terminal, booking, table)
end
end
@@ -159,12 +163,11 @@ class Api::BillController < Api::ApiController
if !shift.nil?
cashier = Employee.find(shift.employee_id)
if (@booking.booking_id)
booking_order = BookingOrder.find_by_booking_id(@booking.booking_id)
order = Order.find(booking_order.order_id)
order = @booking.orders.first
if @sale_data = @booking.sale
@status = true
elsif @sale_data = Sale.generate_invoice_from_booking(@booking, current_login_employee, cashier, order.source,params[:current_checkin_induties_count])
elsif @sale_data = Sale.generate_invoice_from_booking(@booking, current_login_employee, cashier, order.source, params[:current_checkin_induties_count])
@status = true
else
@status = false