add bill channel for req bill

This commit is contained in:
Yan
2017-09-07 15:35:00 +06:30
parent e9a305b573
commit f67d4197ec
8 changed files with 48 additions and 3 deletions

View 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')
},
});

View File

@@ -11,4 +11,8 @@ module ApplicationCable
end
# Order Queue Station Channel
class BillChannel < ActionCable::Channel::Base
end
end

View 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

View File

@@ -7,5 +7,4 @@ class OrderChannel < ApplicationCable::Channel
stop_all_streams
# Any cleanup needed when channel is unsubscribed
end
end

View File

@@ -7,8 +7,11 @@ class Api::BillController < Api::ApiController
@error_message = "Order ID or Booking ID is require to request for a bill."
if ShiftSale.current_shift
#create Bill by Booking ID
table = 0
if (params[:booking_id])
booking = Booking.find(params[:booking_id])
# for Job
table = DiningFacility.find(booking.dining_facility_id)
if booking
if booking.sale_id.nil?
@@ -23,8 +26,14 @@ class Api::BillController < Api::ApiController
elsif (params[:order_id])
@sale = Sale.new
@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
Promotion.promo_activate(@sale)
BillBroadcastJob.perform_later(table)
else
@status = false
@error_message = "No Current Open Shift"

View File

@@ -0,0 +1,7 @@
class BillBroadcastJob < ApplicationJob
queue_as :default
def perform(table)
ActionCable.server.broadcast "bill_channel",table: table
end
end

View File

@@ -3,6 +3,5 @@ class OrderBroadcastJob < ApplicationJob
def perform(table)
ActionCable.server.broadcast "order_channel",table: table
end
end

View File

@@ -7,7 +7,7 @@ class OrderQueueProcessorJob < ApplicationJob
order = Order.find(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
if order
oqs = OrderQueueStation.new