fix table booking
This commit is contained in:
@@ -30,7 +30,7 @@ class Origami::SalesController < BaseOrigamiController
|
||||
Sale.transaction do
|
||||
table = DiningFacility.find(dining)
|
||||
booking = table.current_checkin_booking
|
||||
|
||||
|
||||
sale = Sale.find(sale_id)
|
||||
existing = sale.booking
|
||||
|
||||
|
||||
@@ -9,10 +9,10 @@ class DiningFacility < ApplicationRecord
|
||||
has_many :order_queue_stations, -> { where(is_active: true) }, through: :order_queue_process_by_zones
|
||||
|
||||
has_many :bookings
|
||||
has_many :current_bookings, -> { left_joins(:sale).assign.merge(Booking.where(checkout_at: nil).or(Booking.merge(Sale.where(sale_status: ['new', nil])))) }, class_name: "Booking"
|
||||
has_one :current_checkin_booking, -> { left_joins(:sale).assign.merge(Sale.where(sale_status: nil)) }, class_name: "Booking"
|
||||
has_one :current_checkout_booking, -> { left_joins(:sale).assign.where.not(checkout_at: nil).merge(Sale.where(sale_status: 'new')) }, class_name: "Booking"
|
||||
has_one :current_reserved_booking, -> { left_joins(:sale).assign.where.not(reserved_at: nil).merge(Sale.where(sale_status: nil)) }, class_name: "Booking"
|
||||
has_many :current_bookings, -> { left_joins(:sale).assign.merge(Booking.unscoped.where(checkout_at: nil).or(Booking.merge(Sale.unscoped.where(sale_status: ['new', nil])))) }, class_name: "Booking"
|
||||
has_one :current_checkin_booking, -> { left_joins(:sale).assign.merge(Sale.unscoped.where(sale_status: nil)) }, class_name: "Booking"
|
||||
has_one :current_checkout_booking, -> { left_joins(:sale).assign.where.not(checkout_at: nil).merge(Sale.unscoped.where(sale_status: 'new')) }, class_name: "Booking"
|
||||
has_one :current_reserved_booking, -> { left_joins(:sale).assign.where.not(reserved_at: nil).merge(Sale.unscoped.where(sale_status: nil)) }, class_name: "Booking"
|
||||
|
||||
has_many :current_sales, -> { where(sale_status: 'new').merge(Booking.assign) }, through: :bookings, class_name: "Sale", source: "sale"
|
||||
|
||||
|
||||
@@ -831,6 +831,7 @@
|
||||
var sale_id = this.id;
|
||||
window.location.href = '/origami/table/' + dining_id + "/table_invoice/" + sale_id;
|
||||
})
|
||||
|
||||
$(".tables").on('click', function () {
|
||||
localStorage.setItem('dinning_type','table');
|
||||
var customer_id = $(".customer-id").text();
|
||||
@@ -1156,32 +1157,35 @@
|
||||
})
|
||||
|
||||
$('#add_invoice').on('click', function () {
|
||||
$("#first_bill").prop('disabled',true);
|
||||
$("#pay").prop('disabled',true);
|
||||
var dining_id = "<%= @dining.id %>";
|
||||
var sale_id = $("#sale_id").val(); //<%= @obj_sale.sale_id rescue "" %>
|
||||
var ajax_url = "/origami/sale/append_order";
|
||||
// var tax_type = localStorage.getItem("tax_type");
|
||||
var tax_type = $("#check_tax").val();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: 'dining_id=' + dining_id + "&sale_id=" + sale_id + "&tax_type=" + tax_type,
|
||||
success: function (result) {
|
||||
swal({
|
||||
title: "Information!",
|
||||
text: "Invoice updated",
|
||||
html: true,
|
||||
closeOnConfirm: false,
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function () {
|
||||
$("#first_bill").removeAttr('disabled');
|
||||
$("#pay").removeAttr('disabled');
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
});
|
||||
$("#loading_wrapper").show();
|
||||
$("#add_invoice").prop('disable', true);
|
||||
$("#first_bill").prop('disabled',true);
|
||||
$("#pay").prop('disabled',true);
|
||||
var dining_id = "<%= @dining.id %>";
|
||||
var sale_id = $("#sale_id").val(); //<%= @obj_sale.sale_id rescue "" %>
|
||||
var ajax_url = "/origami/sale/append_order";
|
||||
// var tax_type = localStorage.getItem("tax_type");
|
||||
var tax_type = $("#check_tax").val();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: 'dining_id=' + dining_id + "&sale_id=" + sale_id + "&tax_type=" + tax_type,
|
||||
success: function (result) {
|
||||
swal({
|
||||
title: "Information!",
|
||||
text: "Invoice updated",
|
||||
html: true,
|
||||
closeOnConfirm: false,
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function () {
|
||||
$("#first_bill").removeAttr('disabled');
|
||||
$("#pay").removeAttr('disabled');
|
||||
window.location.reload();
|
||||
});
|
||||
$("#loading_wrapper").hide();
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
//show cusotmer rebate amount
|
||||
|
||||
Reference in New Issue
Block a user