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 %>