multiple sale and order

This commit is contained in:
Nweni
2017-06-22 14:26:23 +06:30
parent 0ff10f2f32
commit 0ea2b778d1
13 changed files with 134 additions and 72 deletions

View File

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

View File

@@ -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)

View File

@@ -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"