update taday list and addorder
This commit is contained in:
@@ -79,6 +79,130 @@ class MenuItem < ApplicationRecord
|
||||
|
||||
end
|
||||
|
||||
def self.get_items(menu)
|
||||
item = Array.new
|
||||
if menu.menu_items
|
||||
menu.menu_items do |item|
|
||||
if item.is_available
|
||||
# Format for attributes json
|
||||
attr_format = []
|
||||
# Format for attributes json
|
||||
if item.item_attributes.count > 0
|
||||
item.item_attributes.each do|attr_id|
|
||||
menu_attr = MenuItemAttribute.find(attr_id)
|
||||
if attr_format.count == 0
|
||||
attr_format.push({ type: menu_attr.attribute_type, values: [menu_attr.name] })
|
||||
next
|
||||
end
|
||||
|
||||
attr_format.each do |af|
|
||||
if menu_attr.attribute_type.in? attr_format.map {|k| k[:type]}
|
||||
if menu_attr.attribute_type == af[:type]
|
||||
af[:values].push(menu_attr.name)
|
||||
end
|
||||
else
|
||||
new_attr = {type: menu_attr.attribute_type, values: [ menu_attr.name ] }
|
||||
attr_format.push(new_attr)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Format for option json
|
||||
opt_format = []
|
||||
# Format for attributes json
|
||||
if item.item_options.count > 0
|
||||
item.item_options.each do|opt|
|
||||
menu_opt = MenuItemOption.find(opt)
|
||||
if opt_format.count == 0
|
||||
opt_format.push({ type: menu_opt.option_type, values: [menu_opt.name] })
|
||||
next
|
||||
end
|
||||
|
||||
opt_format.each do |of|
|
||||
if menu_opt.option_type.in? opt_format.map {|k| k[:type]}
|
||||
if menu_opt.option_type == of[:type]
|
||||
of[:values].push(menu_opt.name)
|
||||
end
|
||||
else
|
||||
new_opt = {type: menu_opt.option_type, values: [ menu_opt.name ] }
|
||||
opt_format.push(new_opt)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#Menu Item Information
|
||||
menu_items.id item.id
|
||||
menu_items.code item.item_code
|
||||
menu_items.name item.name
|
||||
menu_items.alt_name item.alt_name
|
||||
menu_items.image item.image_path.url
|
||||
menu_items.description item.description
|
||||
menu_items.information item.information
|
||||
menu_items.type item.type
|
||||
menu_items.account_id item.account_id
|
||||
menu_items.min_qty item.min_qty
|
||||
menu_items.is_available item.is_available
|
||||
menu_items.is_sub_item item.is_sub_item
|
||||
menu_items.unit item.unit
|
||||
|
||||
# Item Sets of Menu Item
|
||||
item_sets = Array.new()
|
||||
item.item_sets do |its|
|
||||
sets.id its.id
|
||||
sets.name its.name
|
||||
sets.alt_name its.alt_name
|
||||
sets.min_selectable_qty its.min_selectable_qty
|
||||
sets.max_selectable_qty its.max_selectable_qty
|
||||
instances = Array.new()
|
||||
its.menu_item_instances do |i|
|
||||
instan.id i.id
|
||||
instances.push(instan)
|
||||
end
|
||||
item_sets.push(sets)
|
||||
end
|
||||
|
||||
menu_items.attributes attr_format
|
||||
menu_items.options opt_format
|
||||
|
||||
instances = Array new()
|
||||
item.menu_item_instances do |is|
|
||||
if is.is_available
|
||||
# Convert id to name for attributes
|
||||
instance_attr = []
|
||||
|
||||
is.item_attributes.each do |ia|
|
||||
# mItemAttr = MenuItemAttribute.find(is)
|
||||
# instance_attr.push(ia)
|
||||
mItemAttr = MenuItemAttribute.find(ia).name
|
||||
instance_attr.push(mItemAttr)
|
||||
end
|
||||
|
||||
instance.id is.id
|
||||
instance.code is.item_instance_code
|
||||
instance.name is.item_instance_name
|
||||
instance.price is.price
|
||||
instance.is_available is.is_available
|
||||
instance.is_default is.is_default
|
||||
instance.is_on_promotion is.is_on_promotion
|
||||
instance.promotion_price is.promotion_price
|
||||
instance.values instance_attr
|
||||
# json.item_sets is.item_sets
|
||||
end
|
||||
instances.push(instance)
|
||||
end
|
||||
end
|
||||
item.push(menu_items)
|
||||
end
|
||||
return item
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
# private
|
||||
|
||||
# def generate_menu_item_code
|
||||
|
||||
@@ -46,10 +46,10 @@ class OrderQueueStation < ApplicationRecord
|
||||
# AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
|
||||
# else
|
||||
|
||||
# if (order_item.price != 0)
|
||||
if (order_item.qty > 0)
|
||||
AssignedOrderItem.assigned_order_item(order, order_item.item_code, order_item.item_instance_code, oqs)
|
||||
oqs_order_items.push(order_item)
|
||||
# end
|
||||
end
|
||||
# end
|
||||
end
|
||||
end
|
||||
@@ -81,10 +81,10 @@ class OrderQueueStation < ApplicationRecord
|
||||
# AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
|
||||
# else
|
||||
|
||||
# if (order_item.price != 0)
|
||||
if (order_item.qty > 0)
|
||||
AssignedOrderItem.assigned_order_item(order, order_item.item_code, order_item.item_instance_code, oqs)
|
||||
oqs_order_items.push(order_item)
|
||||
# end
|
||||
end
|
||||
# end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -242,7 +242,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
left join dining_facilities AS df ON df.id = b.dining_facility_id
|
||||
left join customers as cus ON cus.customer_id = orders.customer_id
|
||||
left join menu_items as item ON item.item_code = order_items.item_code")
|
||||
.where("order_items.order_items_id = '#{ id }' and order_items.qty > 0")
|
||||
.where("order_items.order_items_id = '#{ id }'")
|
||||
.group("order_items.item_code")
|
||||
elsif type == "order_summary"
|
||||
OrderItem.select("order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, order_items.set_menu_items, cus.name as customer, df.type, df.name as dining,item.alt_name as alt_name")
|
||||
@@ -252,7 +252,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
left join dining_facilities AS df ON df.id = b.dining_facility_id
|
||||
left join customers as cus ON cus.customer_id = orders.customer_id
|
||||
left join menu_items as item ON item.item_code = order_items.item_code")
|
||||
.where("orders.order_id = '#{ id }' and order_items.qty > 0")
|
||||
.where("orders.order_id = '#{ id }'")
|
||||
.group("order_items.order_items_id")
|
||||
else
|
||||
# order summary for booking
|
||||
@@ -263,7 +263,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
left join dining_facilities AS df ON df.id = b.dining_facility_id
|
||||
left join customers as cus ON cus.customer_id = orders.customer_id
|
||||
left join menu_items as item ON item.item_code = order_items.item_code")
|
||||
.where("b.booking_id = '#{ id }' and order_items.qty > 0")
|
||||
.where("b.booking_id = '#{ id }'")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -92,7 +92,12 @@ class Sale < ApplicationRecord
|
||||
self.cashier_id = open_cashier[0].id
|
||||
self.cashier_name = open_cashier[0].name
|
||||
shift_id = ShiftSale.current_open_shift(open_cashier[0].id)
|
||||
self.shift_sale_id = shift_id.id
|
||||
if shift_id
|
||||
self.shift_sale_id = shift_id.id
|
||||
else
|
||||
self.shift_sale_id = current_shift.id
|
||||
end
|
||||
|
||||
else
|
||||
self.cashier_id = current_shift.employee_id
|
||||
self.cashier_name = Employee.find(current_shift.employee_id).name
|
||||
|
||||
Reference in New Issue
Block a user