Merge branch 'oqs' of bitbucket.org:code2lab/sxrestaurant into adminbsb_material_ui
This commit is contained in:
@@ -38,6 +38,41 @@ class Order < ApplicationRecord
|
||||
booking.save!
|
||||
self.default_values
|
||||
|
||||
# cashier already opened?
|
||||
if self.save!
|
||||
|
||||
self.adding_line_items
|
||||
#Add Order Table and Room relation afrer order creation
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order => self})
|
||||
|
||||
#Send order to queue one it done!
|
||||
process_order_queue
|
||||
|
||||
#send order to broadcast job
|
||||
send_order_broadcast(booking)
|
||||
|
||||
return true, booking
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
def custom_generate
|
||||
booking = nil
|
||||
|
||||
if self.new_booking
|
||||
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)
|
||||
end
|
||||
|
||||
booking.save!
|
||||
self.default_values
|
||||
|
||||
# cashier already opened?
|
||||
if self.save!
|
||||
|
||||
@@ -58,7 +93,6 @@ class Order < ApplicationRecord
|
||||
return false
|
||||
|
||||
end
|
||||
|
||||
#Main Method - to update order / add items
|
||||
def modify
|
||||
|
||||
@@ -71,7 +105,12 @@ class Order < ApplicationRecord
|
||||
|
||||
#loop to add all items to order
|
||||
self.items.each do |item|
|
||||
|
||||
menu_item = MenuItem.search_by_item_code(item[:item_instance_code])
|
||||
|
||||
if menu_item.nil?
|
||||
menu_item = Product.search_by_product_code(item[:item_instance_code])
|
||||
end
|
||||
|
||||
#if (!menu_item.nil?)
|
||||
Rails.logger.debug menu_item
|
||||
|
||||
@@ -3,4 +3,24 @@ class Product < ApplicationRecord
|
||||
|
||||
# Product Image Uploader
|
||||
mount_uploader :image_path, ProductImageUploader
|
||||
|
||||
def self.search_by_product_code(item_code)
|
||||
menu_item_hash = Hash.new
|
||||
mt_instance = Product.find_by_item_code(item_code)
|
||||
if (!mt_instance.nil?)
|
||||
menu_item_hash[:type] = 'Product'
|
||||
menu_item_hash[:account_id] = 1
|
||||
menu_item_hash[:item_code] = mt_instance.item_code
|
||||
menu_item_hash[:item_instance_code] = mt_instance.item_code
|
||||
menu_item_hash[:name] = mt_instance.name.to_s
|
||||
menu_item_hash[:alt_name] = mt_instance.alt_name.to_s
|
||||
menu_item_hash[:price] = mt_instance.unit_price
|
||||
menu_item_hash[:promotion_price] = 0
|
||||
menu_item_hash[:is_on_promotion] = 0
|
||||
menu_item_hash[:is_available] = 0
|
||||
menu_item_hash[:taxable] = mt_instance.taxable
|
||||
|
||||
return menu_item_hash
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user