From ee17ddac92bd6e0a0a0ef298905da4f0c350fac2 Mon Sep 17 00:00:00 2001 From: phyusin Date: Wed, 31 Jan 2018 17:47:06 +0630 Subject: [PATCH 01/27] add rounding adj for table invoices --- .../origami/table_invoices_controller.rb | 30 +++++++++++++++++-- .../origami/table_invoices/index.html.erb | 4 +-- .../origami/table_invoices/show.html.erb | 4 +-- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/app/controllers/origami/table_invoices_controller.rb b/app/controllers/origami/table_invoices_controller.rb index 4571ba87..655083df 100755 --- a/app/controllers/origami/table_invoices_controller.rb +++ b/app/controllers/origami/table_invoices_controller.rb @@ -1,6 +1,7 @@ class Origami::TableInvoicesController < BaseOrigamiController def index @table = DiningFacility.find(params[:table_id]) + shop = Shop::ShopDetail puts "table bookig lenght" @sale_array = Array.new @table.bookings.each do |booking| @@ -9,7 +10,18 @@ class Origami::TableInvoicesController < BaseOrigamiController if booking.sale_id.nil? else sale = Sale.find(booking.sale_id) - + # rounding adjustment + if shop.is_rounding_adj + a = sale.grand_total % 25 # Modulus + b = sale.grand_total / 25 # Division + #not calculate rounding if modulus is 0 and division is even + #calculate rounding if modulus is zero or not zero and division are not even + if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0) + new_total = Sale.get_rounding_adjustment(sale.grand_total) + sale.rounding_adjustment = new_total-sale.grand_total + end + end + #end rounding adjustment if sale.sale_status != "completed" @sale_array.push(sale) end @@ -19,12 +31,24 @@ class Origami::TableInvoicesController < BaseOrigamiController def show @table = DiningFacility.find(params[:table_id]) + shop = Shop::ShopDetail @sale_array = Array.new @table.bookings.each do |booking| if booking.sale_id.nil? else - sale = Sale.find(booking.sale_id) - + sale = Sale.find(booking.sale_id) + # rounding adjustment + if shop.is_rounding_adj + a = sale.grand_total % 25 # Modulus + b = sale.grand_total / 25 # Division + #not calculate rounding if modulus is 0 and division is even + #calculate rounding if modulus is zero or not zero and division are not even + if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0) + new_total = Sale.get_rounding_adjustment(sale.grand_total) + sale.rounding_adjustment = new_total-sale.grand_total + end + end + #end rounding adjustment if sale.sale_status != "completed" && sale.sale_status != 'void' @sale_array.push(sale) end diff --git a/app/views/origami/table_invoices/index.html.erb b/app/views/origami/table_invoices/index.html.erb index eb98b9c0..b0c328be 100755 --- a/app/views/origami/table_invoices/index.html.erb +++ b/app/views/origami/table_invoices/index.html.erb @@ -75,8 +75,8 @@
- - +
diff --git a/app/views/origami/table_invoices/show.html.erb b/app/views/origami/table_invoices/show.html.erb index 5270202d..b70c2ffc 100755 --- a/app/views/origami/table_invoices/show.html.erb +++ b/app/views/origami/table_invoices/show.html.erb @@ -125,7 +125,7 @@ Rounding Adj: - <%= @obj_sale.rounding_adjustment rescue 0%> + <%= @sale.rounding_adjustment rescue 0%> Grand Total: @@ -140,7 +140,7 @@
- +
From 9efd54e68b7528a00995547feda942c7fe860be7 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Thu, 1 Feb 2018 15:30:30 +0630 Subject: [PATCH 02/27] update remove job from cable and cup control in print --- app/controllers/api/bill_controller.rb | 3 +- .../api/call_waiters_controller.rb | 3 +- app/models/dining_facility.rb | 10 +++- app/models/order.rb | 13 ++++- app/models/order_queue_station.rb | 47 +++++++++++++++++-- app/models/sale.rb | 39 ++++++++++++++- app/models/sale_payment.rb | 5 +- config/schedule.rb | 2 +- 8 files changed, 110 insertions(+), 12 deletions(-) diff --git a/app/controllers/api/bill_controller.rb b/app/controllers/api/bill_controller.rb index 387b7bf8..4b58e52d 100755 --- a/app/controllers/api/bill_controller.rb +++ b/app/controllers/api/bill_controller.rb @@ -46,7 +46,8 @@ class Api::BillController < Api::ApiController Promotion.promo_activate(@sale) - BillBroadcastJob.perform_later(table) + #BillBroadcastJob.perform_later(table) + ActionCable.server.broadcast "bill_channel",table: table else @status = false @error_message = "No Current Open Shift" diff --git a/app/controllers/api/call_waiters_controller.rb b/app/controllers/api/call_waiters_controller.rb index bfb1023a..7cf80a5d 100644 --- a/app/controllers/api/call_waiters_controller.rb +++ b/app/controllers/api/call_waiters_controller.rb @@ -5,7 +5,8 @@ class Api::CallWaitersController < ActionController::API @table_id = params[:dining_id] @time = params[:time] @table = DiningFacility.find(@table_id) - CallWaiterJob.perform_later(@table,@time) + # CallWaiterJob.perform_later(@table,@time) + ActionCable.server.broadcast "call_waiter_channel",table: @table,time:@time # get printer info @shop = Shop::ShopDetail diff --git a/app/models/dining_facility.rb b/app/models/dining_facility.rb index c4da3475..c897b278 100755 --- a/app/models/dining_facility.rb +++ b/app/models/dining_facility.rb @@ -155,6 +155,14 @@ class DiningFacility < ApplicationRecord def self.check_in_booking(table_id) table = DiningFacility.find(table_id) #Send to background job for processing - CheckInBookingJob.perform_later(table) + # CheckInBookingJob.perform_later(table) + ActionCable.server.broadcast "check_in_booking_channel",table: table + end + + def self.checkin_time + table = DiningFacility.get_checkin_booking + if table.length > 0 + ActionCable.server.broadcast "checkin_channel",table: table + end end end diff --git a/app/models/order.rb b/app/models/order.rb index 6c22cb92..16edc1fa 100755 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -279,6 +279,16 @@ class Order < ApplicationRecord def process_order_queue #Send to background job for processing OrderQueueProcessorJob.perform_later(self.id, self.table_id) + # order = Order.find(order_id) + + # #Execute orders and send to order stations + # if order + # oqs = OrderQueueStation.new + # oqs.process_order(order, table_id) + # end + + # assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id) + # ActionCable.server.broadcast "order_queue_station_channel",order: assign_order end @@ -287,7 +297,8 @@ class Order < ApplicationRecord table = DiningFacility.find(booking.dining_facility_id) type = 'order' #Send to background job for processing - OrderBroadcastJob.perform_later(table,type) + # OrderBroadcastJob.perform_later(table,type) + ActionCable.server.broadcast "order_channel",table: table,type:type end #Origami: Cashier : to view order Table diff --git a/app/models/order_queue_station.rb b/app/models/order_queue_station.rb index 2be68fb3..aea44395 100755 --- a/app/models/order_queue_station.rb +++ b/app/models/order_queue_station.rb @@ -123,9 +123,25 @@ class OrderQueueStation < ApplicationRecord 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="") + cup_status = `#{"sudo service cups status"}` + print_status = check_cup_status(cup_status) + + if print_status + order_queue_printer = Printer::OrderQueuePrinter.new(print_settings) + order_queue_printer.print_order_summary(print_settings, oqs,order.order_id, order_items, print_status="") + else + cup_start = `#{"sudo service cups start"}` + cup_status = `#{"sudo service cups status"}` + print_status = check_cup_status(cup_status) + + if print_status + order_queue_printer = Printer::OrderQueuePrinter.new(print_settings) + order_queue_printer.print_order_summary(print_settings, oqs,order.order_id, order_items, print_status="") + + end + end + AssignedOrderItem.where("order_id = '#{ order.order_id }'").find_each do |ai| # update print status for order items ai.print_status=true @@ -159,8 +175,23 @@ class OrderQueueStation < ApplicationRecord 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="" ) + + cup_status = `#{"sudo service cups status"}` + print_status = check_cup_status(cup_status) + + if print_status + 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="" ) + else + cup_start = `#{"sudo service cups start"}` + cup_status = `#{"sudo service cups status"}` + print_status = check_cup_status(cup_status) + + if print_status + 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="" ) + end + end # update print status for completed same order items assigned_order_item.each do |ai| @@ -168,4 +199,12 @@ class OrderQueueStation < ApplicationRecord ai.save end end + + def check_cup_status(status) + if status.include? "Active: active (running)" || "Active: active (exited)" #"Cup Server is already running" + return true + end + return false + end + end diff --git a/app/models/sale.rb b/app/models/sale.rb index f6aed95e..49f126af 100755 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -128,7 +128,9 @@ class Sale < ApplicationRecord booking.checkout_by = requested_by.name booking.save - InventoryJob.perform_now(self.id) + # InventoryJob.perform_now(self.id) + saleObj = Sale.find(self.id) + InventoryDefinition.calculate_product_count(saleObj) return true, self.id end @@ -137,6 +139,41 @@ class Sale < ApplicationRecord end + #fOR Quick Service pay and create + def self.request_bill(order,current_user,current_login_employee) + @sale = Sale.new + sale_order=SaleOrder.new + + if shift = ShiftSale.current_open_shift(current_user.id) + order_id = order.order_id # order_id + bk_order = BookingOrder.find_by_order_id(order_id) + check_booking = Booking.find_by_booking_id(bk_order.booking_id) + + if check_booking.sale_id.nil? + # Create Sale if it doesn't exist + # puts "current_login_employee" + # puts current_login_employee.name + @status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee, cashier = nil) + @sale_data = Sale.find_by_sale_id(@sale_id) + @sale_items = SaleItem.where("sale_id=?",@sale_id) + else + @sale_data = Sale.find_by_sale_id(check_booking.sale_id) + @sale_items = SaleItem.where("sale_id=?",@sale_data.sale_id) + end + + # Bind shift sale id to sale + @sale_data.shift_sale_id = shift.id + @sale_data.save + + # Promotion Activation + Promotion.promo_activate(@sale) + @status = true + return @status, @sale + else + @status = false + @message = "No Current Open Shift for This Employee" + end + end #This is when spilt bill is request - then we cannot link order to invoice #Cos there will be multiple orders - and items are spilt from there. #Unless order is spilt by then it is possible. diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index ed1b9170..9ba5a3bb 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -335,7 +335,7 @@ class SalePayment < ApplicationRecord #record an payment in sale-audit remark = "#{response} Rebate- for Customer #{self.sale.customer_id} | Sale Id [#{self.sale.sale_id}]| pay amount -> #{self.received_amount} " - sale_audit = SaleAudit.record_paymal(self.sale.sale_id, remark, 1) + sale_audit = SaleAudit.record_paymal(sObj.sale_id, remark, 1) if !response.nil? if response["status"] == true @@ -408,7 +408,8 @@ class SalePayment < ApplicationRecord type = 'payment' #Send to background job for processing - OrderBroadcastJob.perform_later(table,type) + # OrderBroadcastJob.perform_later(table,type) + ActionCable.server.broadcast "order_channel",table: table,type:type end end diff --git a/config/schedule.rb b/config/schedule.rb index 17f336a0..4b3f6a3b 100755 --- a/config/schedule.rb +++ b/config/schedule.rb @@ -11,5 +11,5 @@ every 30.minutes do end every 1.minutes do - runner "CheckinJob.perform" + runner "DiningFacility.checkin_time" end \ No newline at end of file From e9d7b9e2f5918671c4d91ea63311852b94063718 Mon Sep 17 00:00:00 2001 From: phyusin Date: Thu, 1 Feb 2018 15:31:48 +0630 Subject: [PATCH 03/27] change utc to utc.getlocal --- app/controllers/api/check_in_process_controller.rb | 6 +++--- app/controllers/origami/check_in_process_controller.rb | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/api/check_in_process_controller.rb b/app/controllers/api/check_in_process_controller.rb index 883fb1ea..45d3ed1a 100644 --- a/app/controllers/api/check_in_process_controller.rb +++ b/app/controllers/api/check_in_process_controller.rb @@ -41,12 +41,12 @@ class Api::CheckInProcessController < Api::ApiController lookup_checkout_time = Lookup.collection_of("checkout_time") if !lookup_checkout_time.empty? - checkout_at = Time.now.utc + checkout_at = Time.now.utc.getlocal 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") + start_time = Time.parse(arr_time[0].strip).utc.getlocal.strftime("%H:%M%p") + end_time = Time.parse(arr_time[1].strip).utc.getlocal.strftime("%H:%M%p") if start_time <= checkout_at && checkout_at <= end_time checkout_at = checkout_at + (checkout_time[1]).to_i.minutes end diff --git a/app/controllers/origami/check_in_process_controller.rb b/app/controllers/origami/check_in_process_controller.rb index 14d5c90c..8f28c365 100644 --- a/app/controllers/origami/check_in_process_controller.rb +++ b/app/controllers/origami/check_in_process_controller.rb @@ -2,12 +2,12 @@ class Origami::CheckInProcessController < BaseOrigamiController def check_in_process lookup_checkout_time = Lookup.collection_of("checkout_time") - checkout_at = Time.now.utc + checkout_at = Time.now.utc.getlocal if !lookup_checkout_time.empty? 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") + start_time = Time.parse(arr_time[0].strip).utc.getlocal.strftime("%H:%M%p") + end_time = Time.parse(arr_time[1].strip).utc.getlocal.strftime("%H:%M%p") if start_time <= checkout_at && checkout_at <= end_time checkout_at = checkout_at + (checkout_time[1]).to_i.minutes end From 73858fc29360e8a39619f01b700d95328772b8fe Mon Sep 17 00:00:00 2001 From: phyusin Date: Thu, 1 Feb 2018 18:19:35 +0630 Subject: [PATCH 04/27] change checkout time --- app/controllers/api/check_in_process_controller.rb | 2 +- app/controllers/origami/check_in_process_controller.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/check_in_process_controller.rb b/app/controllers/api/check_in_process_controller.rb index 45d3ed1a..12075a50 100644 --- a/app/controllers/api/check_in_process_controller.rb +++ b/app/controllers/api/check_in_process_controller.rb @@ -47,7 +47,7 @@ class Api::CheckInProcessController < Api::ApiController arr_time = checkout_time[0].split("-") start_time = Time.parse(arr_time[0].strip).utc.getlocal.strftime("%H:%M%p") end_time = Time.parse(arr_time[1].strip).utc.getlocal.strftime("%H:%M%p") - if start_time <= checkout_at && checkout_at <= end_time + if start_time <= checkout_at.strftime("%H:%M%p") && checkout_at.strftime("%H:%M%p") <= end_time checkout_at = checkout_at + (checkout_time[1]).to_i.minutes end end diff --git a/app/controllers/origami/check_in_process_controller.rb b/app/controllers/origami/check_in_process_controller.rb index 8f28c365..bab40a83 100644 --- a/app/controllers/origami/check_in_process_controller.rb +++ b/app/controllers/origami/check_in_process_controller.rb @@ -8,7 +8,7 @@ class Origami::CheckInProcessController < BaseOrigamiController arr_time = checkout_time[0].split("-") start_time = Time.parse(arr_time[0].strip).utc.getlocal.strftime("%H:%M%p") end_time = Time.parse(arr_time[1].strip).utc.getlocal.strftime("%H:%M%p") - if start_time <= checkout_at && checkout_at <= end_time + if start_time <= checkout_at.strftime("%H:%M%p") && checkout_at.strftime("%H:%M%p") <= end_time checkout_at = checkout_at + (checkout_time[1]).to_i.minutes end end From 383aeded6088c2e4136572a2fc330572a40893eb Mon Sep 17 00:00:00 2001 From: phyusin Date: Thu, 1 Feb 2018 16:16:26 +0630 Subject: [PATCH 05/27] check checkedin exist in lookups and void - sale --- .../api/check_in_process_controller.rb | 5 ++-- .../origami/check_in_process_controller.rb | 26 +++++++++---------- app/controllers/origami/void_controller.rb | 2 +- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/app/controllers/api/check_in_process_controller.rb b/app/controllers/api/check_in_process_controller.rb index 12075a50..a033c49a 100644 --- a/app/controllers/api/check_in_process_controller.rb +++ b/app/controllers/api/check_in_process_controller.rb @@ -25,9 +25,10 @@ class Api::CheckInProcessController < Api::ApiController alert_time_min = checkout_time[1].to_i end end + render :json => { :status => true, :check_in_time => check_in_time, :check_out_time => check_out_time, :alert_time_min => alert_time_min, :extra_minutes => extra_minutes } + else + render :json => { :status => true } end - - render :json => { :status => true, :check_in_time => check_in_time, :check_out_time => check_out_time, :alert_time_min => alert_time_min, :extra_minutes => extra_minutes } else render :json => { :status => false, :error_message => "No current booking!" } end diff --git a/app/controllers/origami/check_in_process_controller.rb b/app/controllers/origami/check_in_process_controller.rb index bab40a83..67191b6e 100644 --- a/app/controllers/origami/check_in_process_controller.rb +++ b/app/controllers/origami/check_in_process_controller.rb @@ -12,21 +12,21 @@ class Origami::CheckInProcessController < BaseOrigamiController checkout_at = checkout_at + (checkout_time[1]).to_i.minutes end end - end - @dining_facility = DiningFacility.find(params[:dining_id]) - @dining_facility.status = "occupied" - @dining_facility.save! - - if @dining_facility.type == "Table" - type = "TableBooking" - else - type = "RoomBooking" - end - @booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type, - :checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name }) - @booking.save! + @dining_facility = DiningFacility.find(params[:dining_id]) + @dining_facility.status = "occupied" + @dining_facility.save! + if @dining_facility.type == "Table" + type = "TableBooking" + else + type = "RoomBooking" + end + + @booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type, + :checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name }) + @booking.save! + end respond = {:status => 'ok'} respond_to do |format| format.json { render json: respond } diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb index 0d368224..52b2068c 100755 --- a/app/controllers/origami/void_controller.rb +++ b/app/controllers/origami/void_controller.rb @@ -87,7 +87,7 @@ class Origami::VoidController < BaseOrigamiController rebate = MembershipSetting.find_by_rebate(1) if customer.membership_id != nil && rebate member_info = Customer.get_member_account(customer) - rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no) + rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no) current_balance = SaleAudit.paymal_search(sale_id) end From 6c33040173f53d01162b27e97dc91a053af9e515 Mon Sep 17 00:00:00 2001 From: phyusin Date: Thu, 1 Feb 2018 16:25:11 +0630 Subject: [PATCH 06/27] remove checkin if checkin not used --- app/controllers/origami/home_controller.rb | 7 +++++++ app/controllers/origami/shifts_controller.rb | 6 ++++++ app/views/origami/home/show.html.erb | 4 +++- app/views/origami/shifts/show.html.erb | 4 +++- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 536defe7..e7116553 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -84,6 +84,13 @@ class Origami::HomeController < BaseOrigamiController end end end + + #for bank integration + bank_integration = Lookup.collection_of('bank_integration') + @bank_integration = 0 + if !bank_integration[0].nil? + @bank_integration = bank_integration[0][1] + end end diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb index 6d0fbe02..cb2cc830 100755 --- a/app/controllers/origami/shifts_controller.rb +++ b/app/controllers/origami/shifts_controller.rb @@ -4,6 +4,12 @@ class Origami::ShiftsController < BaseOrigamiController def show @shift = ShiftSale.current_open_shift(current_user.id) + #for bank integration + bank_integration = Lookup.collection_of('bank_integration') + @bank_integration = 0 + if !bank_integration[0].nil? + @bank_integration = bank_integration[0][1] + end end def new diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 8440f354..a77ac31a 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -431,7 +431,9 @@ <% else %> - + <% if @bank_integration == '1' %> + + <% end %> <% end %> "> diff --git a/app/views/origami/shifts/show.html.erb b/app/views/origami/shifts/show.html.erb index f2ee019e..4ea71dec 100755 --- a/app/views/origami/shifts/show.html.erb +++ b/app/views/origami/shifts/show.html.erb @@ -31,7 +31,9 @@
- + <% if @bank_integration == '1' %> + + <% end %>
From ae4746acfcb79432c88b0ea8c57fdf21a333cc64 Mon Sep 17 00:00:00 2001 From: phyusin Date: Thu, 1 Feb 2018 16:34:18 +0630 Subject: [PATCH 07/27] change checkin time checked --- app/controllers/origami/home_controller.rb | 8 ++------ app/views/origami/home/show.html.erb | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index e7116553..c00b39bf 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -86,12 +86,8 @@ class Origami::HomeController < BaseOrigamiController end #for bank integration - bank_integration = Lookup.collection_of('bank_integration') - @bank_integration = 0 - if !bank_integration[0].nil? - @bank_integration = bank_integration[0][1] - end - + @checkout_time = Lookup.collection_of('checkout_time') + @checkout_alert_time = Lookup.collection_of('checkout_alert_time') end private diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index a77ac31a..0b70e159 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -431,7 +431,7 @@ <% else %> - <% if @bank_integration == '1' %> + <% if !@checkout_time.empty? && !@checkout_alert_time.empty? %> <% end %> <% end %> From f608aa8516b28ffa28ed121bf055427f51a52f2f Mon Sep 17 00:00:00 2001 From: phyusin Date: Thu, 1 Feb 2018 17:00:57 +0630 Subject: [PATCH 08/27] check checkin time is available or valid time --- .../api/check_in_process_controller.rb | 27 ++++++++++------- .../origami/check_in_process_controller.rb | 29 ++++++++++--------- 2 files changed, 32 insertions(+), 24 deletions(-) diff --git a/app/controllers/api/check_in_process_controller.rb b/app/controllers/api/check_in_process_controller.rb index a033c49a..6f32c613 100644 --- a/app/controllers/api/check_in_process_controller.rb +++ b/app/controllers/api/check_in_process_controller.rb @@ -42,6 +42,7 @@ class Api::CheckInProcessController < Api::ApiController lookup_checkout_time = Lookup.collection_of("checkout_time") if !lookup_checkout_time.empty? + today = Time.now.utc.getlocal checkout_at = Time.now.utc.getlocal lookup_checkout_time.each do |checkout_time| @@ -53,20 +54,24 @@ class Api::CheckInProcessController < Api::ApiController end end - dining_facility.status = "occupied" - dining_facility.save! + if checkout_at.strftime("%Y-%m-%d %H:%M%p") > today.strftime("%Y-%m-%d %H:%M%p") + dining_facility.status = "occupied" + dining_facility.save! - if dining_facility.type == "Table" - type = "TableBooking" + if dining_facility.type == "Table" + type = "TableBooking" + else + type = "RoomBooking" + end + + booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type, + :checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name }) + booking.save! + + render :json => { :status => true, :checkout_at => booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M") } else - type = "RoomBooking" + render :json => { :status => true } end - - booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type, - :checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name }) - booking.save! - - render :json => { :status => true, :checkout_at => booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M") } else render :json => { :status => true } end diff --git a/app/controllers/origami/check_in_process_controller.rb b/app/controllers/origami/check_in_process_controller.rb index 67191b6e..2c5b0b38 100644 --- a/app/controllers/origami/check_in_process_controller.rb +++ b/app/controllers/origami/check_in_process_controller.rb @@ -2,6 +2,7 @@ class Origami::CheckInProcessController < BaseOrigamiController def check_in_process lookup_checkout_time = Lookup.collection_of("checkout_time") + today = Time.now.utc.getlocal checkout_at = Time.now.utc.getlocal if !lookup_checkout_time.empty? lookup_checkout_time.each do |checkout_time| @@ -12,20 +13,22 @@ class Origami::CheckInProcessController < BaseOrigamiController checkout_at = checkout_at + (checkout_time[1]).to_i.minutes end end - - @dining_facility = DiningFacility.find(params[:dining_id]) - @dining_facility.status = "occupied" - @dining_facility.save! - - if @dining_facility.type == "Table" - type = "TableBooking" - else - type = "RoomBooking" - end - @booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type, - :checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name }) - @booking.save! + if checkout_at.strftime("%Y-%m-%d %H:%M%p") > today.strftime("%Y-%m-%d %H:%M%p") + @dining_facility = DiningFacility.find(params[:dining_id]) + @dining_facility.status = "occupied" + @dining_facility.save! + + if @dining_facility.type == "Table" + type = "TableBooking" + else + type = "RoomBooking" + end + + @booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type, + :checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name }) + @booking.save! + end end respond = {:status => 'ok'} respond_to do |format| From 6657c11122c3bc5a7c74e4927cd14a98b34746a9 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Thu, 1 Feb 2018 17:14:34 +0630 Subject: [PATCH 09/27] update cups restart for order --- .../javascripts/channels/call_waiter.js | 22 +++++++-- app/models/order.rb | 35 ++++++++++---- app/models/order_queue_station.rb | 47 ++----------------- 3 files changed, 46 insertions(+), 58 deletions(-) diff --git a/app/assets/javascripts/channels/call_waiter.js b/app/assets/javascripts/channels/call_waiter.js index 941a6359..f0a804a2 100644 --- a/app/assets/javascripts/channels/call_waiter.js +++ b/app/assets/javascripts/channels/call_waiter.js @@ -7,15 +7,27 @@ App.call_waiter = App.cable.subscriptions.create('CallWaiterChannel', { received: function(data) { table = data.table + time = data.time // for Notificaiotn message var element = "#notify-wrapper" - var placementFrom = "top"; - var placementAlign = "center"; var animateEnter = ""; var animateExit = ""; - var colorName = "alert-warning"; - var text = " Calling Waiter
"+table.name ; + + if (time == 'print_error') { + var colorName = "alert-danger"; + var placementFrom = "center"; + var placementAlign = "center"; + var text = " Hello
"+table ; + style ="" + }else{ + var colorName = "alert-warning"; + var placementFrom = "top"; + var placementAlign = "center"; + var text = " Calling Waiter
"+table.name ; + style ="width:180px !important;" + } + if (text != null || colorName != null){ showNotification(element, colorName, text, placementFrom, placementAlign, animateEnter, animateExit); @@ -43,7 +55,7 @@ App.call_waiter = App.cable.subscriptions.create('CallWaiterChannel', { enter: animateEnter, exit: animateExit }, - template: '