udpdate qs

This commit is contained in:
Aung Myo
2018-02-14 13:46:22 +06:30
parent a844b51b39
commit 08e372cfb5
3 changed files with 26 additions and 62 deletions

View File

@@ -25,23 +25,30 @@ class Order < ApplicationRecord
booking = nil
if self.new_booking
if !self.table_id.nil?
table_id = self.table_id
else
table_id = nil
end
#add extra time
if self.is_extra_time && self.extra_time
booking = Booking.create({:dining_facility_id => self.table_id,:type => "TableBooking",
booking = Booking.create({:dining_facility_id => table_id,:type => "TableBooking",
:checkin_at => Time.now.utc,:checkout_at => Time.now.utc + self.extra_time.to_i,
:checkin_by => self.employee_name,
:booking_status => "assign" })
else
booking = Booking.create({:dining_facility_id => self.table_id,:type => "TableBooking",
booking = Booking.create({:dining_facility_id => table_id,:type => "TableBooking",
:checkin_at => Time.now.utc, :checkin_by => self.employee_name,
:booking_status => "assign" })
end
#end extra time
if !self.table_id.nil?
table = DiningFacility.find(self.table_id)
table.status = "occupied"
table.save
end
table = DiningFacility.find(self.table_id)
table.status = "occupied"
table.save
else
booking = Booking.find(self.booking_id)
#add extra time