fix foodcourt sales transaction

This commit is contained in:
Thein Lin Kyaw
2023-08-24 10:40:31 +06:30
parent 5503852217
commit a97b6bff3f
22 changed files with 361 additions and 453 deletions

View File

@@ -173,12 +173,7 @@ class Booking < ApplicationRecord
end
def self.get_booking_id(order_no)
booking = Booking.joins(" JOIN booking_orders bo ON bo.booking_id = bookings.booking_id")
.joins(" JOIN orders o ON o.order_id=bo.order_id")
.where("o.order_id='#{order_no}'")
.first()
return booking.booking_id
return BookingOrder.where(order_id: order_no).first.booking_id
end
private

View File

@@ -10,11 +10,14 @@ class DiningFacility < ApplicationRecord
has_many :bookings
has_many :current_bookings, -> { left_joins(:sale).assign.merge(Booking.unscoped.where(checkout_at: nil).or(Booking.merge(Sale.unscoped.where(sale_status: ['new', nil])))) }, class_name: "Booking"
has_one :current_checkin_booking, -> { left_joins(:sale).assign.merge(Sale.unscoped.where(sale_status: nil)) }, class_name: "Booking"
has_one :current_checkin_booking, -> { left_joins(:sale).assign.where(sale_id: nil) }, class_name: "Booking"
has_one :current_checkout_booking, -> { left_joins(:sale).assign.where.not(checkout_at: nil).merge(Sale.unscoped.where(sale_status: 'new')) }, class_name: "Booking"
has_one :current_reserved_booking, -> { left_joins(:sale).assign.where.not(reserved_at: nil).merge(Sale.unscoped.where(sale_status: nil)) }, class_name: "Booking"
has_many :current_sales, -> { where(sale_status: 'new').merge(Booking.assign) }, through: :bookings, class_name: "Sale", source: "sale"
has_many :current_bookings, -> { left_joins(:sale).assign.merge(Booking.unscoped.where(checkout_at: nil).or(Booking.merge(Sale.unscoped.where(sale_status: ['new', nil])))) }, class_name: "Booking"
has_one :current_checkin_booking, -> { left_joins(:sale).assign.where(sale_id: nil) }, class_name: "Booking"
has_one :current_checkout_booking, -> { left_joins(:sale).assign.where.not(checkout_at: nil).merge(Sale.unscoped.where(sale_status: 'new')) }, class_name: "Booking"
has_one :current_reserved_booking, -> { left_joins(:sale).assign.where.not(reserved_at: nil).merge(Sale.unscoped.where(sale_status: nil)) }, class_name: "Booking"
TABLE_TYPE = "Table"
ROOM_TYPE = "Room"

View File

@@ -49,99 +49,36 @@ class OrderQueueStation < ApplicationRecord
end
end
def pay_process_order_queue (order_id, table_id)
oqs_stations = OrderQueueStation.active
order = Order.find(order_id)
order_items = order.order_items
# Order.pay_process_order_queue(order_id,table_id)
# if order
# oqs = OrderQueueStation.new
# oqs.process_order(order, table_id)
# end
# assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
# if ENV["SERVER_MODE"] == 'cloud'
# from = request.subdomain + "." + request.domain
# else
# from = ""
# end
# ActionCable.server.broadcast "order_queue_station_channel",order: assign_order,from:from
def pay_process_order_queue (order_id, table_id = nil)
if table_id.to_i > 0
# get dining
dining = DiningFacility.find(table_id)
oqs_by_zones = OrderQueueProcessByZone.where("zone_id=#{dining.zone_id}")
booking = Booking.find_by_dining_facility_id(dining.id)
# ToDo per item per printer
oqs_by_zones.each do |oqpbz|
oqs = OrderQueueStation.find(oqpbz.order_queue_station_id)
is_auto_printed = false
oqs_order_items = []
if oqs.is_active
#Get List of items -
pq_items = JSON.parse(oqs.processing_items)
#Loop through the processing items
pq_items.each do |pq_item|
#Processing through the looping items
order_items.each do |order_item|
if (pq_item == order_item.item_code)
if (order_item.qty > 0)
oqs_order_items.push(order_item)
end
end
end
end
if oqs.auto_print
if oqs_order_items.length > 0
if oqs.cut_per_item
print_slip_item(oqs, order, oqs_order_items)
else
print_slip(oqs, order, oqs_order_items)
end
is_auto_printed = true
end
end
end
end
oqs_stations = dining.order_queue_stations
else
oqs_stations.each do |oqs|
is_auto_printed = false
oqs_order_items = []
oqs_stations = OrderQueueStation.active
end
if oqs.is_active
#Get List of items -
pq_items = JSON.parse(oqs.processing_items)
#Loop through the processing items
pq_items.each do |pq_item|
#Processing through the looping items
order_items.each do |order_item|
if (pq_item == order_item.item_code)
if (order_item.qty > 0)
oqs_order_items.push(order_item)
end
end
end
end
order = Order.find(order_id)
order_items = order.order_items
if oqs.auto_print
if oqs_order_items.length > 0
if oqs.cut_per_item
print_slip_item(oqs, order, oqs_order_items)
else
print_slip(oqs, order, oqs_order_items)
end
is_auto_printed = true
end
assigned_order_items = []
oqs_order_items_by_zones = []
oqs_stations.each do |oqs|
oqs_order_items = order_items.select { |i| JSON.parse(oqs.processing_items).include? i.item_code }
oqs_order_items_by_zones << { oqs: oqs, oqs_order_items: oqs_order_items }
if oqs.auto_print
if oqs_order_items.length > 0
if oqs.cut_per_item
print_slip_item(oqs, order, oqs_order_items)
else
print_slip(oqs, order, oqs_order_items)
end
end
end
end #end else
end
end
private

View File

@@ -118,7 +118,6 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
if printed_status != 'Paid' || !Lookup.where(lookup_type: "ReceiptPdfView").pluck(:value).include?('1')
#no print in cloud server
puts "SERVER_MODE #{ENV["SERVER_MODE"]}"
if ENV["SERVER_MODE"] != "cloud"
self.print(filename, cashier_terminal.printer_name)
end