update payment action cable

This commit is contained in:
Aung Myo
2018-01-25 15:33:52 +06:30
parent b3905a461e
commit 142bac74a8
5 changed files with 24 additions and 11 deletions

View File

@@ -14,6 +14,7 @@ App.order = App.cable.subscriptions.create('BillChannel', {
$('.table_'+data.table.id).addClass('red');
}
$('.new_text_'+data.table.id).removeClass('hide');
$('.new_text_'+data.table.id).text('billed');
}
});

View File

@@ -5,10 +5,17 @@ App.order = App.cable.subscriptions.create('OrderChannel', {
disconnected: function() {},
received: function(data) {
$('.table_'+data.table.id).removeClass('green');
$('.table_'+data.table.id).addClass('blue');
$('.new_text_'+data.table.id).removeClass('hide')
received: function(data) {
if (data.type == 'order') {
$('.table_'+data.table.id).removeClass('green');
$('.table_'+data.table.id).addClass('blue');
$('.new_text_'+data.table.id).removeClass('hide')
}else{
$('.table_'+data.table.id).removeClass('red');
$('.table_'+data.table.id).addClass('green');
$('.new_text_'+data.table.id).html('');
$('.new_text_'+data.table.id).removeClass('hide')
}
}
});

View File

@@ -1,7 +1,7 @@
class OrderBroadcastJob < ApplicationJob
queue_as :default
def perform(table)
ActionCable.server.broadcast "order_channel",table: table
def perform(table,type)
ActionCable.server.broadcast "order_channel",table: table,type:type
end
end

View File

@@ -285,8 +285,9 @@ class Order < ApplicationRecord
#send order items and send to order queue
def send_order_broadcast(booking)
table = DiningFacility.find(booking.dining_facility_id)
type = 'order'
#Send to background job for processing
OrderBroadcastJob.perform_later(table)
OrderBroadcastJob.perform_later(table,type)
end
#Origami: Cashier : to view order Table

View File

@@ -382,16 +382,17 @@ class SalePayment < ApplicationRecord
def table_update_status(sale_obj)
status = true
sale_count = 0
booking = Booking.find_by_sale_id(sale_obj.id)
if booking
table = DiningFacility.find(booking.dining_facility_id)
bookings = table.bookings
bookings.each do |tablebooking|
if tablebooking.booking_status != 'moved'
if tablebooking.sale_id
if tablebooking.sale.sale_status != 'completed' && tablebooking.sale.sale_status != 'void'
if tablebooking.sale.sale_status != 'completed' && tablebooking.sale.sale_status != 'void'
status = false
sale_count += 1
else
status = true
end
@@ -400,11 +401,14 @@ class SalePayment < ApplicationRecord
end
end
end
if status
if status && sale_count == 0
table.status = "available"
table.save
end
type = 'payment'
#Send to background job for processing
OrderBroadcastJob.perform_later(table,type)
end
end