move table

This commit is contained in:
Nweni
2017-06-21 17:53:44 +06:30
parent b889603ce6
commit 64210f30ac
16 changed files with 218 additions and 40 deletions

View File

@@ -15,6 +15,19 @@ class Booking < ApplicationRecord
booking.dining_facility_id = newd
booking.save
end
table = DiningFacility.find(newd)
if table
booking = table.get_current_booking
if booking
newtablebookingID= booking.booking_id
booking_arr.each do |booking|
booking.booking_orders.each do |booking_order|
booking_order.booking_id = newtablebookingID
booking_order.save
end
end
end
end
new_dining = DiningFacility.find(newd)
new_dining.make_occupied
old_dining = DiningFacility.find(old)

View File

@@ -19,11 +19,10 @@ class DiningFacility < ApplicationRecord
end
def get_current_booking
puts "enter 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)
if booking.count > 0 then
return booking[0].booking_id
return booking[0]
else
return nil
end

View File

@@ -4,7 +4,7 @@ class Order < ApplicationRecord
#primary key - need to be unique
before_create :generate_custom_id
before_create :set_order_date
has_many :sale_orders
belongs_to :customer
has_many :order_items, autosave: true , inverse_of: :order
has_many :assigned_order_items