update add extra time

This commit is contained in:
Aung Myo
2018-01-02 12:30:57 +06:30
parent 26a11ebecd
commit b1fa5f1518
6 changed files with 54 additions and 27 deletions

View File

@@ -25,31 +25,33 @@ class Order < ApplicationRecord
booking = nil
if self.new_booking
booking = Booking.create({:dining_facility_id => self.table_id,:type => "TableBooking",
#add extra time
if self.is_extra_time && self.extra_time
booking = Booking.create({:dining_facility_id => self.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",
:checkin_at => Time.now.utc, :checkin_by => self.employee_name,
:booking_status => "assign" })
end
#end extra time
table = DiningFacility.find(self.table_id)
table.status = "occupied"
table.save
else
booking = Booking.find(self.booking_id)
#add extra time
if self.is_extra_time
if !booking.checkout_at.nil?
puts "sssssssssss"
date = booking.checkout_at.strftime("%Y-%m-%d")
time = Time.at(booking.checkout_at).utc.strftime("%H:%M:%S")
extra_time = self.extra_time
new_time = time.strftime("%H") + extra_time.strftime("%H")
puts time
puts extra_time
puts new_time
# booking.update_attributes(checkout_at: )
end
new_time = booking.checkout_at + self.extra_time.to_i
booking.update_attributes(checkout_at: new_time)
end
end
#end extra time
end
booking.save!