add bill channel for req bill
This commit is contained in:
17
app/assets/javascripts/channels/bill.js
Normal file
17
app/assets/javascripts/channels/bill.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
App.order = App.cable.subscriptions.create('BillChannel', {
|
||||||
|
// App.messages = App.cable.subscriptions.create('MessagesChannel', {
|
||||||
|
|
||||||
|
connected: function() {},
|
||||||
|
|
||||||
|
disconnected: function() {},
|
||||||
|
|
||||||
|
received: function(data) {
|
||||||
|
|
||||||
|
$('.table_'+data.table.id).removeClass('blue');
|
||||||
|
$('.table_'+data.table.id).addClass('red');
|
||||||
|
$('.new_text_'+data.table.id).removeClass('hide')
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
@@ -11,4 +11,8 @@ module ApplicationCable
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Order Queue Station Channel
|
||||||
|
class BillChannel < ActionCable::Channel::Base
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
10
app/channels/bill_channel.rb
Normal file
10
app/channels/bill_channel.rb
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
class BillChannel < ApplicationCable::Channel
|
||||||
|
def subscribed
|
||||||
|
stream_from "bill_channel"
|
||||||
|
end
|
||||||
|
|
||||||
|
def unsubscribed
|
||||||
|
# Any cleanup needed when channel is unsubscribed
|
||||||
|
stop_all_streams
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -7,5 +7,4 @@ class OrderChannel < ApplicationCable::Channel
|
|||||||
stop_all_streams
|
stop_all_streams
|
||||||
# Any cleanup needed when channel is unsubscribed
|
# Any cleanup needed when channel is unsubscribed
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,8 +7,11 @@ class Api::BillController < Api::ApiController
|
|||||||
@error_message = "Order ID or Booking ID is require to request for a bill."
|
@error_message = "Order ID or Booking ID is require to request for a bill."
|
||||||
if ShiftSale.current_shift
|
if ShiftSale.current_shift
|
||||||
#create Bill by Booking ID
|
#create Bill by Booking ID
|
||||||
|
table = 0
|
||||||
if (params[:booking_id])
|
if (params[:booking_id])
|
||||||
booking = Booking.find(params[:booking_id])
|
booking = Booking.find(params[:booking_id])
|
||||||
|
# for Job
|
||||||
|
table = DiningFacility.find(booking.dining_facility_id)
|
||||||
|
|
||||||
if booking
|
if booking
|
||||||
if booking.sale_id.nil?
|
if booking.sale_id.nil?
|
||||||
@@ -23,8 +26,14 @@ class Api::BillController < Api::ApiController
|
|||||||
elsif (params[:order_id])
|
elsif (params[:order_id])
|
||||||
@sale = Sale.new
|
@sale = Sale.new
|
||||||
@status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee, get_cashier)
|
@status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee, get_cashier)
|
||||||
|
|
||||||
|
# for Job
|
||||||
|
booking = Booking.find_by_sale_id(@sale_id)
|
||||||
|
table = DiningFacility.find(booking.dining_facility_id)
|
||||||
end
|
end
|
||||||
Promotion.promo_activate(@sale)
|
Promotion.promo_activate(@sale)
|
||||||
|
|
||||||
|
BillBroadcastJob.perform_later(table)
|
||||||
else
|
else
|
||||||
@status = false
|
@status = false
|
||||||
@error_message = "No Current Open Shift"
|
@error_message = "No Current Open Shift"
|
||||||
|
|||||||
7
app/jobs/bill_broadcast_job.rb
Normal file
7
app/jobs/bill_broadcast_job.rb
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
class BillBroadcastJob < ApplicationJob
|
||||||
|
queue_as :default
|
||||||
|
|
||||||
|
def perform(table)
|
||||||
|
ActionCable.server.broadcast "bill_channel",table: table
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -3,6 +3,5 @@ class OrderBroadcastJob < ApplicationJob
|
|||||||
|
|
||||||
def perform(table)
|
def perform(table)
|
||||||
ActionCable.server.broadcast "order_channel",table: table
|
ActionCable.server.broadcast "order_channel",table: table
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ class OrderQueueProcessorJob < ApplicationJob
|
|||||||
|
|
||||||
order = Order.find(order_id)
|
order = Order.find(order_id)
|
||||||
assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
|
assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
|
||||||
#Loop through the order stations and process the items
|
|
||||||
#Execute orders and send to order stations
|
#Execute orders and send to order stations
|
||||||
if order
|
if order
|
||||||
oqs = OrderQueueStation.new
|
oqs = OrderQueueStation.new
|
||||||
|
|||||||
Reference in New Issue
Block a user