updates
- qrpay selection when add orders - minor fixes
This commit is contained in:
@@ -249,6 +249,98 @@ class Foodcourt::QrpayController < BaseFoodcourtController
|
||||
end
|
||||
end
|
||||
|
||||
def req_bill
|
||||
sale_data =[]
|
||||
customer_id = params[:customer_id]
|
||||
if !ShiftSale.current_shift.nil?
|
||||
order_id = params[:order_id]
|
||||
order = Order.find(order_id)
|
||||
booking = order.booking
|
||||
if Customer.exists?(customer_id: customer_id)
|
||||
booking.orders.update_all(customer_id: customer_id)
|
||||
end
|
||||
if booking.checkin_at.utc > Time.now.utc && booking.checkout_at.nil?
|
||||
@status = false
|
||||
@error_message = "Operation failed, Could not request bill!"
|
||||
else
|
||||
table = DiningFacility.find_by(id: booking.dining_facility_id)
|
||||
|
||||
if booking.sale_id.nil?
|
||||
if sale_data = Sale.generate_invoice_from_booking(booking, current_login_employee, current_user, order.source, params[:current_checkin_induties_count])
|
||||
# in-duty update
|
||||
in_duties = InDuty.where("booking_id=?", booking.id)
|
||||
if !in_duties.empty?
|
||||
in_duties.each do |in_duty|
|
||||
induty = InDuty.find(in_duty.id)
|
||||
induty.sale_id = sale_data.sale_id
|
||||
induty.out_time = Time.now
|
||||
induty.save
|
||||
end
|
||||
end
|
||||
|
||||
action_by = current_user.name
|
||||
type = "REQUEST_BILL"
|
||||
|
||||
remark = "Request bill Receipt No #{sale_data.receipt_no}"
|
||||
sale_audit = SaleAudit.record_audit_sale(sale_data.sale_id,remark,action_by,type )
|
||||
|
||||
# Promotion Activation
|
||||
Promotion.promo_activate(sale_data)
|
||||
|
||||
#bill channel
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
from = request.host
|
||||
else
|
||||
from = ""
|
||||
end
|
||||
|
||||
if ["quick_service", "cashier"].include? order.source
|
||||
ActionCable.server.broadcast "bill_channel", table: table, from: from
|
||||
end
|
||||
|
||||
unless ["quick_service", "food_court"].include? order.source
|
||||
#check checkInOut pdf print
|
||||
checkout_time = Lookup.collection_of('checkout_time')
|
||||
if !booking.dining_facility_id.nil?
|
||||
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
|
||||
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)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@status = true
|
||||
sale_id = sale_data.sale_id
|
||||
else
|
||||
@status = false
|
||||
sale_id = nil
|
||||
end
|
||||
else
|
||||
@status = true
|
||||
sale_id = booking.sale_id
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.json { render :json => { :status => @status, :sale_id => sale_id } }
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
format.json {
|
||||
render :json => { :status => false, :error_message => "No Current Open Shift for This Employee" } }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_pay
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user