Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant

This commit is contained in:
Yan
2018-01-17 12:06:29 +06:30
30 changed files with 450 additions and 247 deletions

View File

@@ -89,10 +89,14 @@ class Ability
can :manage, Inventory
can :index, :home
can :show, :home
elsif user.role == "cashier"
# can :overall_void, :void
can :index, :home
can :show, :home
can :read, Order
can :update, Order
can :menage, Booking
@@ -161,6 +165,7 @@ class Ability
can :create, :discount
can :remove_discount_items, :discount
can :remove_all_discount, :discount
can :member_discount, :discount
can :manage, Customer
can :manage, DiningQueue
@@ -176,6 +181,9 @@ class Ability
can :manage, Promotion
can :manage, Product
can :index, :home
can :show, :home
end
end
end

View File

@@ -80,11 +80,15 @@ class DiningFacility < ApplicationRecord
if booking
lookup_checkout_time = Lookup.collection_of("checkout_alert_time")
free_time_min = 0
if !lookup_checkout_time.nil?
if lookup_checkout_time[0][0] == 'min'
free_time_min = (lookup_checkout_time[0][1]).to_i
else
free_time_min = 15
if !lookup_checkout_time.empty?
now = Time.now.utc
lookup_checkout_time.each do |checkout_time|
arr_time = checkout_time[0].split("-")
start_time = Time.parse(arr_time[0].strip).utc.strftime("%H:%M%p")
end_time = Time.parse(arr_time[1].strip).utc.strftime("%H:%M%p")
if start_time <= now && now <= end_time
free_time_min = checkout_time[1].to_i
end
end
end
@@ -115,11 +119,15 @@ class DiningFacility < ApplicationRecord
if bookings
lookup_checkout_time = Lookup.collection_of("checkout_alert_time")
free_time_min = 0
if !lookup_checkout_time.nil?
if lookup_checkout_time[0][0] == 'min'
free_time_min = (lookup_checkout_time[0][1]).to_i
else
free_time_min = 15
if !lookup_checkout_time.empty?
now = Time.now.utc
lookup_checkout_time.each do |checkout_time|
arr_time = checkout_time[0].split("-")
start_time = Time.parse(arr_time[0].strip).utc.strftime("%H:%M%p")
end_time = Time.parse(arr_time[1].strip).utc.strftime("%H:%M%p")
if start_time <= now && now <= end_time
free_time_min = checkout_time[1].to_i
end
end
end

View File

@@ -14,6 +14,7 @@ class OrderQueueStation < ApplicationRecord
validates_presence_of :station_name, :printer_name
def process_order (order, table_id)
oqs_stations = OrderQueueStation.active
dining=DiningFacility.find(table_id)
# oqpbz = OrderQueueProcessByZone.find_by_zone_id(dining.zone_id)
@@ -77,47 +78,70 @@ class OrderQueueStation < ApplicationRecord
end
end
end
# if oqs.auto_print
# if oqs_order_items.length > 0
# print_slip(oqs, order, oqs_order_items)
# is_auto_printed = true
# end
# end
end
if oqs.auto_print
if oqs_order_items.length > 0
print_slip(oqs, order, oqs_order_items)
is_auto_printed = true
end
end
end
# if oqs.id == oqpbz.order_queue_station_id
# # Auto Printing
# if oqs.auto_print
# if oqs_order_items.length > 0
# print_slip(oqs, order, oqs_order_items)
# is_auto_printed = true
# end
# end
# end
end
# end
end
private
#Print order_items in 1 slip
def print_slip(oqs, order, order_items)
# unique_code="OrderSummaryPdf"
# print_settings=PrintSetting.find_by_unique_code(unique_code)
# order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
# order_queue_printer.print_order_summary(print_settings, oqs,order.order_id, order_items, print_status="")
def print_slip(oqs, order, order_items)
order_slim_pdf = Lookup.collection_of("order_slim_pdf") #order_slim_pdf
unique_code="OrderSummaryPdf"
if !order_slim_pdf.empty?
if order_slim_pdf[0][1] == '1'
unique_code="OrderSummarySlimPdf"
end
end
# AssignedOrderItem.where("order_id = '#{ order.order_id }'").find_each do |ai|
# # update print status for order items
# ai.print_status=true
# ai.save
# end
print_settings=PrintSetting.find_by_unique_code(unique_code)
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_order_summary(print_settings, oqs,order.order_id, order_items, print_status="")
AssignedOrderItem.where("order_id = '#{ order.order_id }'").find_each do |ai|
# update print status for order items
ai.print_status=true
ai.save
end
end
#Print order_item in 1 slip per item
def print_slip_item(oqs, assigned_item)
# unique_code="OrderItemPdf"
# order_item = OrderItem.where("order_id='#{assigned_item.order_id}' AND item_instance_code='#{assigned_item.instance_code}'").first()
# # print when complete click
# print_settings=PrintSetting.find_by_unique_code(unique_code)
# order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
# order_queue_printer.print_order_item(print_settings, oqs,item.order_id, order_item.order_items_id, print_status="" )
order_slim_pdf = Lookup.collection_of("order_slim_pdf") #order_slim_pdf
unique_code="OrderItemPdf"
if !order_slim_pdf.empty?
if order_slim_pdf[0][1] == '1'
unique_code="OrderItemSlimPdf"
end
end
order_item = OrderItem.where("order_id='#{assigned_item.order_id}' AND item_instance_code='#{assigned_item.instance_code}'").first()
# print when complete click
print_settings=PrintSetting.find_by_unique_code(unique_code)
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_order_item(print_settings, oqs,item.order_id, order_item.order_items_id, print_status="" )
# # update print status for completed same order items
# assigned_order_item.each do |ai|
# ai.print_status=true
# ai.save
# end
# update print status for completed same order items
assigned_order_item.each do |ai|
ai.print_status=true
ai.save
end
end
end

View File

@@ -14,9 +14,19 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
filename = "tmp/order_item_#{order_id}_#{order_item_id}" + ".pdf"
order_slim_pdf = Lookup.collection_of("order_slim_pdf") #order_slim_pdf
# check for item not to show
# if order_item[0].price != 0
pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name)
if !order_slim_pdf.empty?
if order_slim_pdf[0][1] == '1'
pdf = OrderItemSlimPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name)
else
pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name)
end
else
pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name)
end
pdf.render_file filename
if oqs.print_copy
@@ -43,6 +53,8 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
print_settings.save!
end
order_slim_pdf = Lookup.collection_of("order_slim_pdf") #order_slim_pdf
order=print_query('order_summary', order_id)
# For Print Per Item
if oqs.cut_per_item
@@ -55,7 +67,15 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
# check for item not to show
#if odi.price != 0
pdf = OrderItemPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name)
if !order_slim_pdf.empty?
if order_slim_pdf[0][1] == '1'
pdf = OrderItemSlimPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name)
else
pdf = OrderItemPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name)
end
else
pdf = OrderItemPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name)
end
# pdf.render_file "tmp/order_item.pdf"
pdf.render_file filename
if oqs.print_copy
@@ -71,7 +91,15 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
# For Print Order Summary
else
filename = "tmp/order_summary_#{order_id}" + ".pdf"
pdf = OrderSummaryPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name)
if !order_slim_pdf.empty?
if order_slim_pdf[0][1] == '1'
pdf = OrderSummarySlimPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name)
else
pdf = OrderSummaryPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name)
end
else
pdf = OrderSummaryPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name)
end
pdf.render_file filename
if oqs.print_copy
self.print(filename, oqs.printer_name)
@@ -94,6 +122,8 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
print_settings.save!
end
order_slim_pdf = Lookup.collection_of("order_slim_pdf") #order_slim_pdf
order=print_query('booking_summary', booking_id)
# For Print Per Item
if oqs.cut_per_item
@@ -104,7 +134,15 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
# check for item not to show
#if odi.price != 0
pdf = OrderItemPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name)
if !order_slim_pdf.empty?
if order_slim_pdf[0][1] == '1'
pdf = OrderItemSlimPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name)
else
pdf = OrderItemPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name)
end
else
pdf = OrderItemPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name)
end
pdf.render_file filename
if oqs.print_copy
@@ -122,8 +160,16 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
end
# For Print Order Summary
else
filename = "tmp/booking_summary_#{booking_id}" + ".pdf"
pdf = OrderSummaryPdf.new(print_settings,order, print_status,oqs.use_alternate_name)
filename = "tmp/booking_summary_#{booking_id}" + ".pdf"
if !order_slim_pdf.empty?
if order_slim_pdf[0][1] == '1'
pdf = OrderSummarySlimPdf.new(print_settings,order, print_status,oqs.use_alternate_name)
else
pdf = OrderSummaryPdf.new(print_settings,order, print_status,oqs.use_alternate_name)
end
else
pdf = OrderSummaryPdf.new(print_settings,order, print_status,oqs.use_alternate_name)
end
pdf.render_file filename
if oqs.print_copy
self.print(filename, oqs.printer_name)

View File

@@ -24,11 +24,11 @@ class Printer::PrinterWorker
end
end
def printers()
def self.printers()
Cups.show_destinations
end
def default_printer()
def self.default_printer()
Cups.default_printer
end

View File

@@ -4,7 +4,13 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
#Use CUPS service
#Generate PDF
#Print
order_slim_pdf = Lookup.collection_of("order_slim_pdf") #order_slim_pdf
pdf = OrderItemPdf.new
if !order_slim_pdf.empty?
if order_slim_pdf[0][1] == '1'
pdf = OrderItemSlimPdf.new
end
end
pdf.render_file "tmp/order_item_queue_#{order_id}_#{order_item_id}" + ".pdf"
self.print("tmp/receipt.pdf")
end
@@ -14,7 +20,13 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
#Generate PDF
#Print
filename = "tmp/order_summary_#{booking_id}" + ".pdf"
order_slim_pdf = Lookup.collection_of("order_slim_pdf") #order_slim_pdf
pdf = OrderSummaryPdf.new
if !order_slim_pdf.empty?
if order_slim_pdf[0][1] == '1'
pdf = OrderSummarySlimPdf.new
end
end
pdf.render_file filename
self.print(filename)
@@ -24,8 +36,14 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
#Use CUPS service
#Generate PDF
#Print
order_slim_pdf = Lookup.collection_of("order_slim_pdf") #order_slim_pdf
filename = "tmp/order_summary_#{booking_id}" + ".pdf"
pdf = OrderSummaryPdf.new
if !order_slim_pdf.empty?
if order_slim_pdf[0][1] == '1'
pdf = OrderSummarySlimPdf.new
end
end
pdf.render_file filename
self.print(filename)
@@ -35,8 +53,14 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
#Use CUPS service
#Generate PDF
#Print
order_slim_pdf = Lookup.collection_of("order_slim_pdf") #order_slim_pdf
filename = "tmp/order_summary_#{booking_id}" + ".pdf"
pdf = OrderSummaryPdf.new
if !order_slim_pdf.empty?
if order_slim_pdf[0][1] == '1'
pdf = OrderSummarySlimPdf.new
end
end
pdf.render_file filename
self.print(filename)
@@ -46,8 +70,14 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
#Use CUPS service
#Generate PDF
#Print
order_slim_pdf = Lookup.collection_of("order_slim_pdf") #order_slim_pdf
filename = "tmp/order_summary_#{booking_id}" + ".pdf"
pdf = OrderSummaryPdf.new
if !order_slim_pdf.empty?
if order_slim_pdf[0][1] == '1'
pdf = OrderSummarySlimPdf.new
end
end
pdf.render_file filename
self.print(filename)
@@ -57,8 +87,14 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
#Use CUPS service
#Generate PDF
#Print
order_slim_pdf = Lookup.collection_of("order_slim_pdf") #order_slim_pdf
filename = "tmp/order_summary_#{booking_id}" + ".pdf"
pdf = OrderSummaryPdf.new
if !order_slim_pdf.empty?
if order_slim_pdf[0][1] == '1'
pdf = OrderSummarySlimPdf.new
end
end
pdf.render_file filename
self.print(filename)

View File

@@ -665,7 +665,8 @@ def self.get_item_query()
# "JOIN employee_accesses ea ON ea.`employee_id` = sales.cashier_id ")
query = query.joins(" JOIN accounts acc ON acc.id = mi.account_id")
# query = query.where("i.item_instance_code IS NOT NULL")
query = query.group("acc.title,mi.account_id,i.product_name").order("acc.title desc, mi.account_id desc")
query = query.group("acc.title,mi.account_id,i.product_name")
.order("acc.title desc, mi.account_id desc, i.unit_price asc")
end
def self.get_other_charges()