From b9aa1ec870a0e831e583dd001c07a14b7e4bfd96 Mon Sep 17 00:00:00 2001 From: Dev Team Date: Wed, 18 Jun 2025 13:38:40 +0630 Subject: [PATCH] updates - qrpay selection when add orders - minor fixes --- app/controllers/foodcourt/qrpay_controller.rb | 92 ++++++ .../foodcourt/orders/_read_modal.html.erb | 269 ++++++++++++++++++ .../foodcourt/orders/app_orders.html.erb | 28 +- config/routes.rb | 1 + 4 files changed, 383 insertions(+), 7 deletions(-) create mode 100644 app/views/foodcourt/orders/_read_modal.html.erb diff --git a/app/controllers/foodcourt/qrpay_controller.rb b/app/controllers/foodcourt/qrpay_controller.rb index 15d2168f..f669f4e1 100644 --- a/app/controllers/foodcourt/qrpay_controller.rb +++ b/app/controllers/foodcourt/qrpay_controller.rb @@ -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 diff --git a/app/views/foodcourt/orders/_read_modal.html.erb b/app/views/foodcourt/orders/_read_modal.html.erb new file mode 100644 index 00000000..423db09b --- /dev/null +++ b/app/views/foodcourt/orders/_read_modal.html.erb @@ -0,0 +1,269 @@ + + + + + + + + diff --git a/app/views/foodcourt/orders/app_orders.html.erb b/app/views/foodcourt/orders/app_orders.html.erb index 1cdd0fb6..b705c874 100644 --- a/app/views/foodcourt/orders/app_orders.html.erb +++ b/app/views/foodcourt/orders/app_orders.html.erb @@ -305,12 +305,18 @@ <% end%>
-
+
<% if @status == 'sale' %> -   Customer: <%= @pending.customer.name rescue "-" %> - <% else%> -   Customer: <%= @pending.orders.first.customer.name rescue "-" %> - <% end%> + " /> + + Customer: <%= @pending.customer.name rescue "-" %> + + <% else %> + " /> + + Customer: <%= @pending.orders.first.customer.name rescue "-" %> + + <% end %>
@@ -428,7 +434,7 @@
<% order_id = @pending.try(:orders).try(:first).try(:order_id) if @status == 'order' %> - + <%end%> @@ -510,10 +516,18 @@ -<%= render "layouts/read_modal" %> +<%= render "read_modal" %>