origin pull master
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
class Menu < ApplicationRecord
|
||||
has_many :menu_categories, dependent: :destroy
|
||||
|
||||
validates_presence_of :name, :is_active, :valid_days, :valid_time_from, :valid_time_to
|
||||
|
||||
validates_presence_of :name, :valid_days, :valid_time_from, :valid_time_to
|
||||
validates_format_of :valid_days, :with => /\A([0-7]{1}(,[0-7]{1})*)?\Z/i
|
||||
#Default Scope to pull the active version only
|
||||
default_scope { where(is_active: true).order("created_at desc") }
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
class MenuItem < ApplicationRecord
|
||||
belongs_to :account
|
||||
belongs_to :menu_category, :optional => true
|
||||
has_many :menu_item_instances
|
||||
belongs_to :parent, :class_name => "MenuItem", foreign_key: "menu_item_id", :optional => true
|
||||
has_many :children, :class_name => "MenuItem", foreign_key: "menu_item_id"
|
||||
belongs_to :account
|
||||
|
||||
|
||||
validates_presence_of :item_code, :type, :min_qty, :taxable, :min_selectable_item, :max_selectable_item
|
||||
|
||||
default_scope { order('item_code asc') }
|
||||
|
||||
def self.collection
|
||||
|
||||
@@ -8,7 +8,6 @@ class Order < ApplicationRecord
|
||||
#internal references attributes for business logic control
|
||||
attr_accessor :items, :guest, :table_id, :new_booking, :booking_type, :employee_name, :booking_id
|
||||
|
||||
|
||||
#Main Controller method to create new order - validate all inputs and generate new order
|
||||
# order_item : {
|
||||
# order_item_code : "",
|
||||
@@ -17,6 +16,7 @@ class Order < ApplicationRecord
|
||||
# option_values : [],
|
||||
# sub_order_items : [],
|
||||
# }
|
||||
|
||||
def generate
|
||||
booking = nil
|
||||
|
||||
@@ -43,6 +43,9 @@ class Order < ApplicationRecord
|
||||
#Send order to queue one it done!
|
||||
process_order_queue
|
||||
|
||||
#send order to broadcast job
|
||||
send_order_broadcast
|
||||
|
||||
return true, booking
|
||||
|
||||
end
|
||||
@@ -202,6 +205,13 @@ class Order < ApplicationRecord
|
||||
OrderQueueProcessorJob.perform_later(self.id)
|
||||
end
|
||||
|
||||
|
||||
#send order items and send to order queue
|
||||
def send_order_broadcast
|
||||
#Send to background job for processing
|
||||
OrderBroadcastJob.perform_later(self.id)
|
||||
end
|
||||
|
||||
#Origami: Cashier : to view order type Table
|
||||
def self.get_order_table
|
||||
order_table = Order.select("orders.id as order_id,sum(order_items.qty*order_items.price) as total_price,
|
||||
@@ -211,7 +221,7 @@ class Order < ApplicationRecord
|
||||
left join dining_facilities on dining_facilities.id = bookings.dining_facility_id
|
||||
left join order_items on order_items.order_id = orders.id")
|
||||
.where("dining_facilities.type=? and orders.order_type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,"dine_in",true)
|
||||
.group("orders.id")
|
||||
.group("orders.id")
|
||||
end
|
||||
#Origami: Cashier : to view order type Room
|
||||
def self.get_order_rooms
|
||||
|
||||
@@ -8,7 +8,7 @@ class OrderQueueStation < ApplicationRecord
|
||||
|
||||
scope :active, -> {where(is_active: true)}
|
||||
|
||||
def process_order (order)
|
||||
def process_order (order)
|
||||
oqs_stations = OrderQueueStation.active
|
||||
|
||||
order_items = order.order_items
|
||||
@@ -20,10 +20,10 @@ class OrderQueueStation < ApplicationRecord
|
||||
#Loop through the processing items
|
||||
pq_items.each do |pq_item|
|
||||
#Processing through the looping items
|
||||
order_items.each do |order_item|
|
||||
order_items.each do |order_item|
|
||||
if (pq_item == order_item.item_code)
|
||||
#Same Order_items can appear in two location.
|
||||
AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
|
||||
AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
2
app/models/print_setting.rb
Normal file
2
app/models/print_setting.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
class PrintSetting < ApplicationRecord
|
||||
end
|
||||
@@ -1,22 +1,46 @@
|
||||
class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
|
||||
def print_order_item(order_queue_id)
|
||||
def print_order_item(printer_settings,order_id, item_code)
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
pdf = OrderItemPdf.new
|
||||
pdf.render_file "tmp/order_item_queue_#{order_id}_#{order_item_id}" + ".pdf"
|
||||
order_item= print_query('order_item', item_code) #OrderItem.find_by_item_code(item_code)
|
||||
pdf = OrderItemPdf.new(order_item[0],printer_settings)
|
||||
pdf.render_file "tmp/receipt.pdf"
|
||||
self.print("tmp/receipt.pdf")
|
||||
end
|
||||
|
||||
def print_order_summary(booking_id)
|
||||
def print_order_summary(printer_settings,booking_id)
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
order=print_query('booking',booking_id)
|
||||
filename = "tmp/order_summary_#{booking_id}" + ".pdf"
|
||||
pdf = OrderSummaryPdf.new
|
||||
pdf = OrderSummaryPdf.new(order,printer_settings)
|
||||
pdf.render_file filename
|
||||
|
||||
self.print(filename)
|
||||
end
|
||||
|
||||
# Query for OQS with status
|
||||
def print_query(type, code)
|
||||
if type == 'order_item'
|
||||
OrderItem.select("order_items.item_code, order_items.item_name,order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.name as dining")
|
||||
.joins("left join orders ON orders.id = order_items.order_id
|
||||
left join booking_orders AS bo ON bo.order_id=order_items.order_id
|
||||
left join bookings AS b ON b.id = bo.booking_id
|
||||
left join dining_facilities AS df ON df.id = b.dining_facility_id
|
||||
left join customers as cus ON cus.id = orders.customer_id")
|
||||
.where("order_items.item_code=" + code)
|
||||
.group("order_items.item_code")
|
||||
else
|
||||
OrderItem.select("order_items.item_code, order_items.item_name, df.name as dining")
|
||||
.joins("left join orders ON orders.id = order_items.order_id
|
||||
left join booking_orders AS bo ON bo.order_id=order_items.order_id
|
||||
left join bookings AS b ON b.id = bo.booking_id
|
||||
left join dining_facilities AS df ON df.id = b.dining_facility_id")
|
||||
.where("booking.id=" + code)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
class SaleDiscount < ApplicationRecord
|
||||
belongs_to :sale
|
||||
end
|
||||
2
app/models/test.rb
Normal file
2
app/models/test.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
class Test < ApplicationRecord
|
||||
end
|
||||
5
app/models/transactions.rb
Normal file
5
app/models/transactions.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
module Transactions
|
||||
def self.table_name_prefix
|
||||
'transactions_'
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user