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