update add extra time
This commit is contained in:
@@ -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!
|
||||
|
||||
@@ -114,7 +114,10 @@ class Sale < ApplicationRecord
|
||||
order.save
|
||||
|
||||
booking.sale_id = self.id
|
||||
booking.checkout_at = Time.now.utc.getlocal
|
||||
if booking.checkout_at < Time.now.utc.getlocal
|
||||
booking.checkout_at = Time.now.utc.getlocal
|
||||
end
|
||||
|
||||
booking.checkout_by = requested_by.name
|
||||
booking.save
|
||||
|
||||
@@ -222,8 +225,6 @@ class Sale < ApplicationRecord
|
||||
|
||||
sales_items.each do |item|
|
||||
#compute each item and added to total
|
||||
puts "item.sales_item_id ddd"
|
||||
puts item.sale_item_id
|
||||
subtotal_price = subtotal_price + item.price
|
||||
|
||||
# only calc tax when true
|
||||
|
||||
Reference in New Issue
Block a user