multiple sale and order
This commit is contained in:
@@ -9,6 +9,7 @@ class Booking < ApplicationRecord
|
||||
belongs_to :sale, :optional => true
|
||||
has_many :booking_orders
|
||||
has_many :orders, :through => :booking_orders
|
||||
scope :active, -> {where("booking_status != 'moved'")}
|
||||
|
||||
def self.update_dining_facility(booking_arr, newd, old)
|
||||
booking_arr.each do |booking|
|
||||
|
||||
@@ -18,6 +18,17 @@ class DiningFacility < ApplicationRecord
|
||||
self.save
|
||||
end
|
||||
|
||||
def get_booking
|
||||
booking = self.get_current_booking
|
||||
if booking
|
||||
if booking.dining_facility_id.to_i == self.id
|
||||
if booking.booking_status == 'assign'
|
||||
return booking
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def get_current_booking
|
||||
booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1)
|
||||
|
||||
|
||||
@@ -244,9 +244,11 @@ class SalePayment < ApplicationRecord
|
||||
table = DiningFacility.find(booking.dining_facility_id)
|
||||
bookings = table.bookings
|
||||
bookings.each do |tablebooking|
|
||||
if tablebooking.booking_status != 'moved'
|
||||
if tablebooking.sale.sale_status != 'completed'
|
||||
status = false
|
||||
end
|
||||
end
|
||||
end
|
||||
if status
|
||||
table.status = "available"
|
||||
|
||||
Reference in New Issue
Block a user