add extra charge in oroder
This commit is contained in:
@@ -10,7 +10,7 @@ class Order < ApplicationRecord
|
||||
has_many :assigned_order_items
|
||||
|
||||
#internal references attributes for business logic control
|
||||
attr_accessor :items, :guest, :table_id, :new_booking, :booking_type, :employee_name, :booking_id, :extra_time
|
||||
attr_accessor :items, :guest, :table_id, :new_booking, :booking_type, :employee_name, :booking_id, :extra_time, :is_extra_time
|
||||
scope :active, -> { where("date BETWEEN '#{DateTime.now.utc.end_of_day}' AND '#{DateTime.now.utc.beginning_of_day}'") }
|
||||
#Main Controller method to create new order - validate all inputs and generate new order
|
||||
# order_item : {
|
||||
@@ -28,11 +28,28 @@ class Order < ApplicationRecord
|
||||
booking = Booking.create({:dining_facility_id => self.table_id,:type => "TableBooking",
|
||||
:checkin_at => Time.now.utc, :checkin_by => self.employee_name,
|
||||
:booking_status => "assign" })
|
||||
|
||||
table = DiningFacility.find(self.table_id)
|
||||
table.status = "occupied"
|
||||
table.save
|
||||
else
|
||||
booking = Booking.find(self.booking_id)
|
||||
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
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
booking.save!
|
||||
|
||||
Reference in New Issue
Block a user