update add extra time
This commit is contained in:
@@ -49,7 +49,25 @@ class Api::OrdersController < Api::ApiController
|
|||||||
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
|
||||||
|
#for extratime
|
||||||
|
is_extra_time = false
|
||||||
|
extra_time = ''
|
||||||
|
|
||||||
|
params[:order_items].each { |i|
|
||||||
|
if i["item_instance_code"] == 'Exti60' || i["item_instance_code"] == 'Exti30'
|
||||||
|
is_extra_time = true
|
||||||
|
if i["item_instance_code"] == 'Exti30'
|
||||||
|
t = Time.now
|
||||||
|
time = 30*60*i["quantity"].to_i
|
||||||
|
extra_time = Time.at(time)
|
||||||
|
else
|
||||||
|
t = Time.now
|
||||||
|
time = 60*60*i["quantity"].to_i
|
||||||
|
extra_time = Time.at(time)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
}
|
||||||
|
#end extra time
|
||||||
# begin
|
# begin
|
||||||
@order = Order.new
|
@order = Order.new
|
||||||
@order.source = params[:order_source]
|
@order.source = params[:order_source]
|
||||||
@@ -61,6 +79,9 @@ class Api::OrdersController < Api::ApiController
|
|||||||
@order.new_booking = true
|
@order.new_booking = 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.
|
||||||
|
|||||||
@@ -70,17 +70,11 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController
|
|||||||
if i["item_instance_code"] == 'Exti60' || i["item_instance_code"] == 'Exti30'
|
if i["item_instance_code"] == 'Exti60' || i["item_instance_code"] == 'Exti30'
|
||||||
is_extra_time = true
|
is_extra_time = true
|
||||||
if i["item_instance_code"] == 'Exti30'
|
if i["item_instance_code"] == 'Exti30'
|
||||||
t = Time.now
|
|
||||||
time = 30*60*i["quantity"].to_i
|
time = 30*60*i["quantity"].to_i
|
||||||
extra_time = Time.at(time).utc.strftime("%H:%M:%S")
|
extra_time = Time.at(time)
|
||||||
puts time
|
|
||||||
puts "timmmmmmmmmmmmmmmmmmm"
|
|
||||||
else
|
else
|
||||||
t = Time.now
|
|
||||||
time = 60*60*i["quantity"].to_i
|
time = 60*60*i["quantity"].to_i
|
||||||
extra_time = Time.at(time).utc.strftime("%H:%M:%S")
|
extra_time = Time.at(time)
|
||||||
puts time
|
|
||||||
puts "timmmmmmmmmmmmmmmmmmm"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"options": i["options"]}
|
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"options": i["options"]}
|
||||||
|
|||||||
@@ -15,9 +15,14 @@ class Origami::SalesController < BaseOrigamiController
|
|||||||
dining = params[:dining_id]
|
dining = params[:dining_id]
|
||||||
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)
|
||||||
table.bookings.each do |booking|
|
table.bookings.each do |booking|
|
||||||
|
# if !booking.checkout_at.nil?
|
||||||
|
# existing_booking.update_attributes(checkout_at: checkout_at)
|
||||||
|
# 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)
|
||||||
order.status = 'billed'
|
order.status = 'billed'
|
||||||
@@ -36,7 +41,7 @@ class Origami::SalesController < BaseOrigamiController
|
|||||||
order.save
|
order.save
|
||||||
booking.save
|
booking.save
|
||||||
end
|
end
|
||||||
existing_booking = Booking.find_by_sale_id(sale_id)
|
|
||||||
booking_order = BookingOrder.where('booking_id=?',booking)
|
booking_order = BookingOrder.where('booking_id=?',booking)
|
||||||
booking_order.each do |bo|
|
booking_order.each do |bo|
|
||||||
bo.booking_id = existing_booking.booking_id
|
bo.booking_id = existing_booking.booking_id
|
||||||
|
|||||||
@@ -25,31 +25,33 @@ class Order < ApplicationRecord
|
|||||||
booking = nil
|
booking = nil
|
||||||
|
|
||||||
if self.new_booking
|
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,
|
:checkin_at => Time.now.utc, :checkin_by => self.employee_name,
|
||||||
:booking_status => "assign" })
|
:booking_status => "assign" })
|
||||||
|
end
|
||||||
|
#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
|
||||||
else
|
else
|
||||||
booking = Booking.find(self.booking_id)
|
booking = Booking.find(self.booking_id)
|
||||||
|
#add extra time
|
||||||
if self.is_extra_time
|
if self.is_extra_time
|
||||||
if !booking.checkout_at.nil?
|
if !booking.checkout_at.nil?
|
||||||
puts "sssssssssss"
|
new_time = booking.checkout_at + self.extra_time.to_i
|
||||||
date = booking.checkout_at.strftime("%Y-%m-%d")
|
booking.update_attributes(checkout_at: new_time)
|
||||||
time = Time.at(booking.checkout_at).utc.strftime("%H:%M:%S")
|
end
|
||||||
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 extra time
|
||||||
end
|
end
|
||||||
|
|
||||||
booking.save!
|
booking.save!
|
||||||
|
|||||||
@@ -114,7 +114,10 @@ class Sale < ApplicationRecord
|
|||||||
order.save
|
order.save
|
||||||
|
|
||||||
booking.sale_id = self.id
|
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.checkout_by = requested_by.name
|
||||||
booking.save
|
booking.save
|
||||||
|
|
||||||
@@ -222,8 +225,6 @@ class Sale < ApplicationRecord
|
|||||||
|
|
||||||
sales_items.each do |item|
|
sales_items.each do |item|
|
||||||
#compute each item and added to total
|
#compute each item and added to total
|
||||||
puts "item.sales_item_id ddd"
|
|
||||||
puts item.sale_item_id
|
|
||||||
subtotal_price = subtotal_price + item.price
|
subtotal_price = subtotal_price + item.price
|
||||||
|
|
||||||
# only calc tax when true
|
# only calc tax when true
|
||||||
|
|||||||
@@ -143,7 +143,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<% elsif @status_sale == 'sale' %>
|
<% elsif @status_sale == 'sale' %>
|
||||||
<div><strong id="order-title">INVOICE DETAILS </strong> | Table <%= @dining.name rescue "" %>
|
<div><strong id="order-title">INVOICE DETAILS </strong> | Table <%= @dining.name rescue "" %>
|
||||||
<span class="float-right">Checkin Time : <%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %></span>
|
<% if !@booking.reserved_by.nil? && %>
|
||||||
|
<span class="float-right"><%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %> - <%= @booking.checkout_at.utc.getlocal.strftime("%I:%M %p") %></span>
|
||||||
|
<% else %>
|
||||||
|
<span class="float-right">Checkin Time : <%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %></span>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<strong id="order-title">ORDER DETAILS </strong> | Table <%= @dining.name rescue "" %>
|
<strong id="order-title">ORDER DETAILS </strong> | Table <%= @dining.name rescue "" %>
|
||||||
|
|||||||
Reference in New Issue
Block a user