Merge branch 'adminbsb_material_ui'
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.
|
||||||
|
|||||||
@@ -62,9 +62,21 @@ 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
|
||||||
puts params[:order_items]
|
is_extra_time = false
|
||||||
|
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'
|
||||||
|
is_extra_time = true
|
||||||
|
if i["item_instance_code"] == 'Exti30'
|
||||||
|
time = 30*60*i["quantity"].to_i
|
||||||
|
extra_time = Time.at(time)
|
||||||
|
else
|
||||||
|
time = 60*60*i["quantity"].to_i
|
||||||
|
extra_time = Time.at(time)
|
||||||
|
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"]}
|
||||||
items_arr.push(items)
|
items_arr.push(items)
|
||||||
}
|
}
|
||||||
@@ -80,36 +92,34 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController
|
|||||||
@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.
|
||||||
booking = Booking.find(params[:booking_id])
|
booking = Booking.find(params[:booking_id])
|
||||||
if booking
|
|
||||||
if booking.dining_facility_id.to_i == params[:table_id].to_i && booking.booking_status != 'moved'
|
if booking
|
||||||
if !booking.sale_id.nil?
|
if booking.dining_facility_id.to_i == params[:table_id].to_i && booking.booking_status != 'moved'
|
||||||
sale_status = check_order_with_booking(booking)
|
if !booking.sale_id.nil?
|
||||||
# puts "WWwwWWWWWWww"
|
sale_status = check_order_with_booking(booking)
|
||||||
# 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
|
||||||
|
else
|
||||||
|
@order.new_booking = false
|
||||||
|
@order.booking_id = params[:booking_id]
|
||||||
|
end
|
||||||
|
else
|
||||||
|
sale_status = check_order_with_table(params[:table_id])
|
||||||
|
if sale_status
|
||||||
|
return return_json_status_with_code(400, "bill requested")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else
|
end #booking exists
|
||||||
@order.new_booking = false
|
|
||||||
@order.booking_id = params[:booking_id]
|
|
||||||
end
|
|
||||||
else
|
|
||||||
sale_status = check_order_with_table(params[:table_id])
|
|
||||||
# puts "OOOOOOOOO"
|
|
||||||
# puts sale_status
|
|
||||||
if sale_status
|
|
||||||
return return_json_status_with_code(400, "bill requested")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end #booking exists
|
|
||||||
else
|
else
|
||||||
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")
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
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 : {
|
||||||
@@ -25,14 +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 !booking.checkout_at.nil?
|
||||||
|
new_time = booking.checkout_at + self.extra_time.to_i
|
||||||
|
booking.update_attributes(checkout_at: new_time)
|
||||||
|
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 "" %>
|
||||||
|
|||||||
21
db/seeds.rb
21
db/seeds.rb
@@ -140,10 +140,11 @@ menu_options = MenuItemOption.create([{option_type: "Oil", name: "Less Oil", val
|
|||||||
menu_pkg_options = MenuItemOption.create([{option_type: "Package", name: "Bottle", value: "Bottle"},{option_type: "Package", name: "Can", value: "can"}])
|
menu_pkg_options = MenuItemOption.create([{option_type: "Package", name: "Bottle", value: "Bottle"},{option_type: "Package", name: "Can", value: "can"}])
|
||||||
|
|
||||||
# #Default Menu Category
|
# #Default Menu Category
|
||||||
# menu_category1 = MenuCategory.create({menu: menu, code:"C001", name: "Person", alt_name: "Person", order_by: 1, is_available: 1, created_by: "SYSTEM DEFAULT"})
|
# menu_category1 = MenuCategory.create({menu: menu, code:"C001", name: "Person", alt_name: "Person", order_by: 1, is_available: 1, created_by: "SYSTEM DEFAULT"})
|
||||||
# menu_category2 = MenuCategory.create({menu: menu, code:"C005", name: "Beef & Mutton", alt_name: "Beef_and_mutton", order_by: 2,created_by: "SYSTEM DEFAULT"})
|
# menu_category2 = MenuCategory.create({menu: menu, code:"C005", name: "Beef & Mutton", alt_name: "Beef_and_mutton", order_by: 2,created_by: "SYSTEM DEFAULT"})
|
||||||
# menu_category3 = MenuCategory.create({menu: menu, code:"C006", name: "Pork", alt_name: "Pork", order_by: 3,created_by: "SYSTEM DEFAULT"})
|
# menu_category3 = MenuCategory.create({menu: menu, code:"C006", name: "Pork", alt_name: "Pork", order_by: 3,created_by: "SYSTEM DEFAULT"})
|
||||||
# menu_category4 = MenuCategory.create({menu: menu, code:"C006", name: "Chicken", alt_name: "Chicken", order_by: 1, menu_category_id: menu_category3.id, created_by: "SYSTEM DEFAULT"})
|
# menu_category4 = MenuCategory.create({menu: menu, code:"C006", name: "Chicken", alt_name: "Chicken", order_by: 1, menu_category_id: menu_category3.id, created_by: "SYSTEM DEFAULT"})
|
||||||
|
# menu_category5 = MenuCategory.create({menu: menu, code:"C001", name: "Extra Time", alt_name: "Extra Time", order_by: 1, is_available: 1, created_by: "SYSTEM DEFAULT"})
|
||||||
#
|
#
|
||||||
# #Default Menu items
|
# #Default Menu items
|
||||||
# menu_category1_menu_item0 = SimpleMenuItem.create({item_code:"01001", name: "Single Pot", alt_name: "Single Pot",menu_category: menu_category1 , min_selectable_item: 1, max_selectable_item:1, account: food })
|
# menu_category1_menu_item0 = SimpleMenuItem.create({item_code:"01001", name: "Single Pot", alt_name: "Single Pot",menu_category: menu_category1 , min_selectable_item: 1, max_selectable_item:1, account: food })
|
||||||
@@ -162,11 +163,21 @@ menu_pkg_options = MenuItemOption.create([{option_type: "Package", name: "Bottle
|
|||||||
# menu_item_attribute_adult = MenuItemAttribute.create({attribute_type:"person", name: "Adult", value: "adult"})
|
# menu_item_attribute_adult = MenuItemAttribute.create({attribute_type:"person", name: "Adult", value: "adult"})
|
||||||
# menu_item_attribute_child = MenuItemAttribute.create({attribute_type:"person", name: "Child", value: "child"})
|
# menu_item_attribute_child = MenuItemAttribute.create({attribute_type:"person", name: "Child", value: "child"})
|
||||||
|
|
||||||
# menu_category1_menu_item0 = SimpleMenuItem.create({item_code:"P00001", name: "Adult", alt_name: "",menu_category: menu_category1 , min_qty: 1, account: person, :item_attributes => "['1']", created_by: "System" })
|
# menu_category1_menu_item0 = SimpleMenuItem.create({item_code:"P00001", name: "Adult", alt_name: "",menu_category: menu_category1 , min_qty: 1, account: person, :item_attributes => "['1']", created_by: "System" })
|
||||||
# menu_item0_instance = MenuItemInstance.create({item_instance_name:"",item_instance_code:"PI0001", menu_item: menu_category1_menu_item0, price:15000.00, is_on_promotion:false, is_default:true, :item_attributes => "['1']" })
|
# menu_item0_instance = MenuItemInstance.create({item_instance_name:"",item_instance_code:"PI0001", menu_item: menu_category1_menu_item0, price:15000.00, is_on_promotion:false, is_default:true, :item_attributes => "['1']" })
|
||||||
|
|
||||||
|
# menu_category1_menu_item1 = SimpleMenuItem.create({item_code:"P00002", name: "Child", alt_name: "",menu_category: menu_category1 , min_qty: 1, account: person, :item_attributes => "['2']", created_by: "System" })
|
||||||
|
# menu_item1_instance = MenuItemInstance.create({item_instance_name:"",item_instance_code:"PI0002", menu_item: menu_category1_menu_item1, price:10000.00, is_on_promotion:false, is_default:true, :item_attributes => "['2']" })
|
||||||
|
|
||||||
|
# menu_item_attribute_30_min = MenuItemAttribute.create({attribute_type:"Extra Time", name: "30 min", value: "30_min"})
|
||||||
|
# menu_item_attribute_60_min = MenuItemAttribute.create({attribute_type:"Extra Time", name: "1 hrs", value: "60_min"})
|
||||||
|
|
||||||
|
# menu_category1_menu_item2 = SimpleMenuItem.create({item_code:"Ext30", name: "30 minutes", alt_name: "",menu_category: menu_category5 , min_qty: 1, account: extra_time, :item_attributes => "['1']", created_by: "System" })
|
||||||
|
# menu_item0_instance = MenuItemInstance.create({item_instance_name:"",item_instance_code:"Exti30", menu_item: menu_category1_menu_item2, price:15000.00, is_on_promotion:false, is_default:true, :item_attributes => "['1']" })
|
||||||
|
|
||||||
|
# menu_category1_menu_item3 = SimpleMenuItem.create({item_code:"Ext60", name: "1 hour", alt_name: "",menu_category: menu_category5 , min_qty: 1, account: extra_time, :item_attributes => "['2']", created_by: "System" })
|
||||||
|
# menu_item1_instance = MenuItemInstance.create({item_instance_name:"",item_instance_code:"Exti60", menu_item: menu_category1_menu_item3, price:10000.00, is_on_promotion:false, is_default:true, :item_attributes => "['2']" })
|
||||||
|
|
||||||
# menu_category1_menu_item1 = SimpleMenuItem.create({item_code:"P00002", name: "Child", alt_name: "",menu_category: menu_category1 , min_qty: 1, account: person, :item_attributes => "['2']", created_by: "System" })
|
|
||||||
# menu_item1_instance = MenuItemInstance.create({item_instance_name:"",item_instance_code:"PI0002", menu_item: menu_category1_menu_item1, price:10000.00, is_on_promotion:false, is_default:true, :item_attributes => "['2']" })
|
|
||||||
# END
|
# END
|
||||||
|
|
||||||
menu_item_attribute_size_small = MenuItemAttribute.create({attribute_type:"size", name: "Small", value: "small"})
|
menu_item_attribute_size_small = MenuItemAttribute.create({attribute_type:"size", name: "Small", value: "small"})
|
||||||
|
|||||||
Reference in New Issue
Block a user