From 0e39e4577f1e407eed2b86d7b7a8ba057f3e28bf Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Tue, 10 Apr 2018 10:51:33 +0630 Subject: [PATCH 1/2] update request bill check from quick service --- app/views/origami/pending_order/show.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/origami/pending_order/show.html.erb b/app/views/origami/pending_order/show.html.erb index de208374..0cc6f949 100644 --- a/app/views/origami/pending_order/show.html.erb +++ b/app/views/origami/pending_order/show.html.erb @@ -202,13 +202,13 @@ $(document).ready(function(){ // Bill Request $('#request_bills').click(function () { var order_id = $('#save_order_id').val(); - var ajax_url = "/origami/" + order_id + "/request_bills"; + var ajax_url = "../../../origami/" +order_id+ "/request_bills"; + console.log(ajax_url) $.ajax({ type: "GET", url: ajax_url, // data: 'order_id='+ order_id, success: function (result) { - console.log(result) if (!result.status) { swal("Information!", result.error_message); } From 0e5269c66fb93975b0de84eec913f9c418f8acdb Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Tue, 10 Apr 2018 17:29:02 +0630 Subject: [PATCH 2/2] update request bill msg box error --- app/assets/javascripts/addorder.js | 8 +++++--- .../origami/quick_service_controller.rb | 7 +++++-- .../origami/request_bills_controller.rb | 7 ++++++- app/models/sale.rb | 1 + app/views/origami/pending_order/index.html.erb | 18 +++++++++--------- 5 files changed, 26 insertions(+), 15 deletions(-) diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index 30ed8af2..07511458 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -974,7 +974,7 @@ console.log(d_option) dataType: "json", success:function(result){ if (result.status) { - + console.log(result) if (result.data == null){ swal({ title: "Please Open Shift !", @@ -984,11 +984,13 @@ console.log(d_option) confirmButtonText: "Ok", closeOnConfirm: false }, function () { - window.location.href = '/origami/quick_service/pending_order/' + $('#sale_id').text(); + window.location.href = '/origami/quick_service/pending_order/' + $('#sale_id').text(); }); + }else if(result.data == 'OK'){ + window.location.href = '/origami/quick_service/pending_order/' + $('#sale_id').text(); }else{ - window.location.href = "/origami/sale/"+result.data["sale_id"]+"/"+type+"/payment" + window.location.href = "/origami/sale/"+result.data["sale_id"]+"/"+type+"/payment" } } } diff --git a/app/controllers/origami/quick_service_controller.rb b/app/controllers/origami/quick_service_controller.rb index d2194bb5..d5d3437b 100644 --- a/app/controllers/origami/quick_service_controller.rb +++ b/app/controllers/origami/quick_service_controller.rb @@ -154,10 +154,13 @@ class Origami::QuickServiceController < ApplicationController result = {:status=> true, :data => @sale } render :json => result.to_json - end + end + elsif (params[:sale_id][0,3] == "BKI") + result = {:status=> true, :data => 'OK' } + render :json => result.to_json else result = {:status=> true, :data => nil } - render :json => result.to_json + render :json => result.to_json end end diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index cdd1f442..05dbdce4 100755 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -16,7 +16,12 @@ class Origami::RequestBillsController < ApplicationController bk_order = BookingOrder.find_by_order_id(order_id) order = Order.find(order_id) check_booking = Booking.find_by_booking_id(bk_order.booking_id) - table = DiningFacility.find(check_booking.dining_facility_id) + if check_booking.dining_facility_id.to_i > 0 + table = DiningFacility.find(check_booking.dining_facility_id) + else + table = nil + end + if check_booking.sale_id.nil? # Create Sale if it doesn't exist @status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee, current_user, order.source) diff --git a/app/models/sale.rb b/app/models/sale.rb index b9c0717e..f6ba19b8 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -2592,6 +2592,7 @@ end query = query.joins("join sale_orders as sale_orders on sale_orders.sale_id = sales.sale_id") .joins("join orders as orders on orders.order_id = sale_orders.order_id") query = query.where("sales.sale_status = 'new' AND orders.status = 'billed' AND orders.source =? ","quick_service") + .group("sales.sale_id") end def self.pending_order query = Booking.all diff --git a/app/views/origami/pending_order/index.html.erb b/app/views/origami/pending_order/index.html.erb index 2d4ba1d4..447612d1 100644 --- a/app/views/origami/pending_order/index.html.erb +++ b/app/views/origami/pending_order/index.html.erb @@ -10,19 +10,19 @@
<% @sale.each do |sale| %> -
+
<%= sale.receipt_no %>Billed
-
+
<% end %> - <% @order.each do |order| %> -
-
- <%= order.booking_id %>new -
-
- <% end %> + <% @order.each do |order| %> +
+
+ <%= order.booking_id %>new +
+
+ <% end %>