update add extra time after request
This commit is contained in:
@@ -16,12 +16,13 @@ class Origami::SalesController < BaseOrigamiController
|
|||||||
sale_id = params[:sale_id]
|
sale_id = params[:sale_id]
|
||||||
table = DiningFacility.find(dining)
|
table = DiningFacility.find(dining)
|
||||||
existing_booking = Booking.find_by_sale_id(sale_id)
|
existing_booking = Booking.find_by_sale_id(sale_id)
|
||||||
|
|
||||||
table.bookings.each do |booking|
|
table.bookings.each do |booking|
|
||||||
# if !booking.checkout_at.nil?
|
if !booking.checkout_at.nil? && !booking.sale_id.nil?
|
||||||
# existing_booking.update_attributes(checkout_at: checkout_at)
|
existing_booking.update_attributes(checkout_at: booking.checkout_at)
|
||||||
# end
|
end
|
||||||
if booking.sale_id.nil?
|
if booking.sale_id.nil?
|
||||||
booking.booking_orders.each do |booking_order|
|
booking.booking_orders.each do |booking_order|
|
||||||
|
|
||||||
booking.booking_status = 'moved'
|
booking.booking_status = 'moved'
|
||||||
order = Order.find(booking_order.order_id)
|
order = Order.find(booking_order.order_id)
|
||||||
@@ -40,7 +41,7 @@ class Origami::SalesController < BaseOrigamiController
|
|||||||
saleobj.save
|
saleobj.save
|
||||||
order.save
|
order.save
|
||||||
booking.save
|
booking.save
|
||||||
end
|
end
|
||||||
|
|
||||||
booking_order = BookingOrder.where('booking_id=?',booking)
|
booking_order = BookingOrder.where('booking_id=?',booking)
|
||||||
booking_order.each do |bo|
|
booking_order.each do |bo|
|
||||||
|
|||||||
@@ -27,8 +27,10 @@ class Order < ApplicationRecord
|
|||||||
if self.new_booking
|
if self.new_booking
|
||||||
#add extra time
|
#add extra time
|
||||||
if self.is_extra_time && self.extra_time
|
if self.is_extra_time && self.extra_time
|
||||||
|
old_booking = Booking.where("booking_id = #{self.booking_id} and sale_id NOT NULL").first
|
||||||
|
new_time = old_booking.checkout_at + self.extra_time.to_i
|
||||||
booking = Booking.create({:dining_facility_id => self.table_id,:type => "TableBooking",
|
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_at => Time.now.utc,:checkout_at => new_time,
|
||||||
:checkin_by => self.employee_name,
|
:checkin_by => self.employee_name,
|
||||||
:booking_status => "assign" })
|
:booking_status => "assign" })
|
||||||
else
|
else
|
||||||
@@ -38,7 +40,6 @@ class Order < ApplicationRecord
|
|||||||
end
|
end
|
||||||
#end extra time
|
#end extra time
|
||||||
|
|
||||||
|
|
||||||
table = DiningFacility.find(self.table_id)
|
table = DiningFacility.find(self.table_id)
|
||||||
table.status = "occupied"
|
table.status = "occupied"
|
||||||
table.save
|
table.save
|
||||||
|
|||||||
Reference in New Issue
Block a user