add extra charge in oroder
This commit is contained in:
@@ -62,21 +62,23 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController
|
|||||||
def create
|
def create
|
||||||
Rails.logger.debug "Order Source - " + params[:order_source].to_s
|
Rails.logger.debug "Order Source - " + params[:order_source].to_s
|
||||||
Rails.logger.debug "Table ID - " + params[:table_id].to_s
|
Rails.logger.debug "Table ID - " + params[:table_id].to_s
|
||||||
extra_time = false
|
is_extra_time = false
|
||||||
time = ''
|
extra_time = ''
|
||||||
|
|
||||||
items_arr = []
|
items_arr = []
|
||||||
JSON.parse(params[:order_items]).each { |i|
|
JSON.parse(params[:order_items]).each { |i|
|
||||||
if i["item_instance_code"] == 'Exti60' || i["item_instance_code"] == 'Exti30'
|
if i["item_instance_code"] == 'Exti60' || i["item_instance_code"] == 'Exti30'
|
||||||
extra_time = true
|
is_extra_time = true
|
||||||
if i["item_instance_code"] == 'Exti30'
|
if i["item_instance_code"] == 'Exti30'
|
||||||
t = Time.now
|
t = Time.now
|
||||||
time = 30*i["quantity"]
|
time = 30*60*i["quantity"].to_i
|
||||||
|
extra_time = Time.at(time).utc.strftime("%H:%M:%S")
|
||||||
puts time
|
puts time
|
||||||
puts "timmmmmmmmmmmmmmmmmmm"
|
puts "timmmmmmmmmmmmmmmmmmm"
|
||||||
else
|
else
|
||||||
t = Time.now
|
t = Time.now
|
||||||
time = 1*i["quantity"]
|
time = 60*60*i["quantity"].to_i
|
||||||
|
extra_time = Time.at(time).utc.strftime("%H:%M:%S")
|
||||||
puts time
|
puts time
|
||||||
puts "timmmmmmmmmmmmmmmmmmm"
|
puts "timmmmmmmmmmmmmmmmmmm"
|
||||||
end
|
end
|
||||||
@@ -94,20 +96,20 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController
|
|||||||
@order.guest = params[:guest_info]
|
@order.guest = params[:guest_info]
|
||||||
@order.table_id = params[:table_id] # this is dining facilities's id
|
@order.table_id = params[:table_id] # this is dining facilities's id
|
||||||
@order.new_booking = true
|
@order.new_booking = true
|
||||||
@order.extra_time = true
|
|
||||||
@order.waiters = current_login_employee.name
|
@order.waiters = current_login_employee.name
|
||||||
@order.employee_name = current_login_employee.name
|
@order.employee_name = current_login_employee.name
|
||||||
|
|
||||||
|
@order.is_extra_time = is_extra_time
|
||||||
|
@order.extra_time = extra_time
|
||||||
#Create Table Booking or Room Booking
|
#Create Table Booking or Room Booking
|
||||||
if !params["booking_id"].nil?
|
if !params["booking_id"].nil?
|
||||||
# check booking id is already completed.
|
# check booking id is already completed.
|
||||||
booking = Booking.find(params[:booking_id])
|
booking = Booking.find(params[:booking_id])
|
||||||
puts "ssssssssssssssssssss"
|
|
||||||
if booking
|
if booking
|
||||||
if booking.dining_facility_id.to_i == params[:table_id].to_i && booking.booking_status != 'moved'
|
if booking.dining_facility_id.to_i == params[:table_id].to_i && booking.booking_status != 'moved'
|
||||||
if !booking.sale_id.nil?
|
if !booking.sale_id.nil?
|
||||||
sale_status = check_order_with_booking(booking)
|
sale_status = check_order_with_booking(booking)
|
||||||
puts "WWwwWWWWWWww"
|
|
||||||
puts sale_status
|
|
||||||
if sale_status
|
if sale_status
|
||||||
return return_json_status_with_code(400, "bill requested")
|
return return_json_status_with_code(400, "bill requested")
|
||||||
end
|
end
|
||||||
@@ -117,18 +119,13 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
sale_status = check_order_with_table(params[:table_id])
|
sale_status = check_order_with_table(params[:table_id])
|
||||||
puts "OOOOOOOOO"
|
|
||||||
puts sale_status
|
|
||||||
if sale_status
|
if sale_status
|
||||||
return return_json_status_with_code(400, "bill requested")
|
return return_json_status_with_code(400, "bill requested")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end #booking exists
|
end #booking exists
|
||||||
else
|
else
|
||||||
puts "seeeeeeeeeeeeeeeeee"
|
|
||||||
sale_status = check_order_with_table(params[:table_id])
|
sale_status = check_order_with_table(params[:table_id])
|
||||||
# puts "MMMMMMMM"
|
|
||||||
# puts sale_status
|
|
||||||
if sale_status
|
if sale_status
|
||||||
# return false , @message = "bill requested"
|
# return false , @message = "bill requested"
|
||||||
return return_json_status_with_code(400, "bill requested")
|
return return_json_status_with_code(400, "bill requested")
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class Order < ApplicationRecord
|
|||||||
has_many :assigned_order_items
|
has_many :assigned_order_items
|
||||||
|
|
||||||
#internal references attributes for business logic control
|
#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}'") }
|
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
|
#Main Controller method to create new order - validate all inputs and generate new order
|
||||||
# order_item : {
|
# order_item : {
|
||||||
@@ -28,11 +28,28 @@ class Order < ApplicationRecord
|
|||||||
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, :checkin_by => self.employee_name,
|
:checkin_at => Time.now.utc, :checkin_by => self.employee_name,
|
||||||
:booking_status => "assign" })
|
:booking_status => "assign" })
|
||||||
|
|
||||||
table = DiningFacility.find(self.table_id)
|
table = DiningFacility.find(self.table_id)
|
||||||
table.status = "occupied"
|
table.status = "occupied"
|
||||||
table.save
|
table.save
|
||||||
else
|
else
|
||||||
booking = Booking.find(self.booking_id)
|
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
|
end
|
||||||
|
|
||||||
booking.save!
|
booking.save!
|
||||||
|
|||||||
Reference in New Issue
Block a user