From 671aa155cdb9c0e0e6875132dd12f687ee727d80 Mon Sep 17 00:00:00 2001 From: San Wai Lwin Date: Mon, 13 Aug 2018 14:37:41 +0630 Subject: [PATCH 1/5] Edit for checkin pdf --- app/controllers/api/bill_controller.rb | 5 ++++- app/controllers/api/check_in_process_controller.rb | 7 +++++-- app/controllers/origami/check_in_process_controller.rb | 6 +++++- app/controllers/origami/request_bills_controller.rb | 5 ++++- app/models/printer/order_queue_printer.rb | 4 ++-- 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/app/controllers/api/bill_controller.rb b/app/controllers/api/bill_controller.rb index e1eff050..85ace00d 100755 --- a/app/controllers/api/bill_controller.rb +++ b/app/controllers/api/bill_controller.rb @@ -63,6 +63,9 @@ class Api::BillController < Api::ApiController #check checkInOut pdf print check_booking = Booking.find_by_sale_id(@sale_id) checkout_time = Lookup.collection_of('checkout_time') + terminal_id = DiningFacility.find_by_id(check_booking.dining_facility_id) + terminal = CashierTerminal.find_by_id(terminal_id.zone_id) + if (!checkout_time.empty?) && (ENV["SERVER_MODE"] != "cloud") #no print in cloud server unique_code = "CheckInOutPdf" @@ -72,7 +75,7 @@ class Api::BillController < Api::ApiController order_queue_printer = Printer::OrderQueuePrinter.new(printer) if !printer.nil? - order_queue_printer.print_check_in_out(printer, check_booking, table) + order_queue_printer.print_check_in_out(printer,terminal, check_booking, table) end end diff --git a/app/controllers/api/check_in_process_controller.rb b/app/controllers/api/check_in_process_controller.rb index 1b8650f1..01985d89 100644 --- a/app/controllers/api/check_in_process_controller.rb +++ b/app/controllers/api/check_in_process_controller.rb @@ -76,9 +76,12 @@ class Api::CheckInProcessController < Api::ApiController dining_facility.status = "occupied" dining_facility.save! end + terminal_id = DiningFacility.find_by_id(booking.dining_facility_id) + terminal = CashierTerminal.find_by_id(terminal_id.zone_id) + if ENV["SERVER_MODE"] != "cloud" #no print in cloud server - + unique_code = "CheckInOutPdf" printer = PrintSetting.find_by_unique_code(unique_code) @@ -86,7 +89,7 @@ class Api::CheckInProcessController < Api::ApiController order_queue_printer = Printer::OrderQueuePrinter.new(printer) if !printer.nil? - order_queue_printer.print_check_in_out(printer, booking, dining_facility) + order_queue_printer.print_check_in_out(printer, terminal, booking, dining_facility) end end render :json => { :status => true, :checkout_at => booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M") } diff --git a/app/controllers/origami/check_in_process_controller.rb b/app/controllers/origami/check_in_process_controller.rb index 3d6b6d14..b6e67943 100644 --- a/app/controllers/origami/check_in_process_controller.rb +++ b/app/controllers/origami/check_in_process_controller.rb @@ -4,6 +4,7 @@ class Origami::CheckInProcessController < BaseOrigamiController 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| arr_time = checkout_time[0].split("-") @@ -26,6 +27,9 @@ class Origami::CheckInProcessController < BaseOrigamiController @booking = Booking.create({:dining_facility_id => params[:dining_id],:type => "TableBooking", :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 }) + terminal_id = DiningFacility.find_by_id(@booking.dining_facility_id) + terminal = CashierTerminal.find_by_id(terminal_id.zone_id) + if @booking.save! @dining_facility.status = "occupied" @dining_facility.save! @@ -43,7 +47,7 @@ class Origami::CheckInProcessController < BaseOrigamiController order_queue_printer = Printer::OrderQueuePrinter.new(printer) if !printer.nil? - order_queue_printer.print_check_in_out(printer, booking, table) + order_queue_printer.print_check_in_out(printer, terminal, booking, table) end end end diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index 5b71141e..fca27cb8 100755 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -70,6 +70,9 @@ class Origami::RequestBillsController < ApplicationController #check checkInOut pdf print check_booking = Booking.find_by_sale_id(@sale_id) checkout_time = Lookup.collection_of('checkout_time') + terminal_id = DiningFacility.find_by_id(check_booking.dining_facility_id) + terminal = CashierTerminal.find_by_id(terminal_id.zone_id) + if (!checkout_time.empty?) && (ENV["SERVER_MODE"] != "cloud") #no print in cloud server unique_code = "CheckInOutPdf" printer = PrintSetting.find_by_unique_code(unique_code) @@ -78,7 +81,7 @@ class Origami::RequestBillsController < ApplicationController order_queue_printer = Printer::OrderQueuePrinter.new(printer) if !printer.nil? - order_queue_printer.print_check_in_out(printer, check_booking, table) + order_queue_printer.print_check_in_out(printer, terminal, check_booking, table) end end end diff --git a/app/models/printer/order_queue_printer.rb b/app/models/printer/order_queue_printer.rb index 504dfab2..1d1d9d7f 100755 --- a/app/models/printer/order_queue_printer.rb +++ b/app/models/printer/order_queue_printer.rb @@ -299,7 +299,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker end # Check in-out time - def print_check_in_out(print_settings,booking, table) + def print_check_in_out(print_settings, terminal, booking, table) #Use CUPS service #Generate PDF #Print @@ -330,7 +330,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker #no print in cloud server if ENV["SERVER_MODE"] != "cloud" - self.print(filename, print_settings.printer_name) + self.print(filename, terminal.printer_name) end end end From 61e4b930c892a206f3bea5ae136ab5aca4aea0d3 Mon Sep 17 00:00:00 2001 From: San Wai Lwin Date: Tue, 14 Aug 2018 15:22:49 +0630 Subject: [PATCH 2/5] edit in check time --- app/controllers/api/bill_controller.rb | 6 +++--- app/controllers/api/check_in_process_controller.rb | 7 +++---- .../origami/check_in_process_controller.rb | 6 ++---- .../origami/request_bills_controller.rb | 6 +++--- app/models/printer/order_queue_printer.rb | 4 ++-- app/models/sale.rb | 2 -- config/initializers/action_controller.rb | 14 +++++++------- 7 files changed, 20 insertions(+), 25 deletions(-) diff --git a/app/controllers/api/bill_controller.rb b/app/controllers/api/bill_controller.rb index 85ace00d..c56f2d09 100755 --- a/app/controllers/api/bill_controller.rb +++ b/app/controllers/api/bill_controller.rb @@ -63,8 +63,8 @@ class Api::BillController < Api::ApiController #check checkInOut pdf print check_booking = Booking.find_by_sale_id(@sale_id) checkout_time = Lookup.collection_of('checkout_time') - terminal_id = DiningFacility.find_by_id(check_booking.dining_facility_id) - terminal = CashierTerminal.find_by_id(terminal_id.zone_id) + terminal = DiningFacility.find_by_id(check_booking.dining_facility_id) + cashier_terminal = CashierTerminal.find_by_id(terminal.zone_id) if (!checkout_time.empty?) && (ENV["SERVER_MODE"] != "cloud") #no print in cloud server @@ -75,7 +75,7 @@ class Api::BillController < Api::ApiController order_queue_printer = Printer::OrderQueuePrinter.new(printer) if !printer.nil? - order_queue_printer.print_check_in_out(printer,terminal, check_booking, table) + order_queue_printer.print_check_in_out(printer,cashier_terminal , check_booking, table) end end diff --git a/app/controllers/api/check_in_process_controller.rb b/app/controllers/api/check_in_process_controller.rb index 01985d89..fe98cf2a 100644 --- a/app/controllers/api/check_in_process_controller.rb +++ b/app/controllers/api/check_in_process_controller.rb @@ -76,9 +76,8 @@ class Api::CheckInProcessController < Api::ApiController dining_facility.status = "occupied" dining_facility.save! end - terminal_id = DiningFacility.find_by_id(booking.dining_facility_id) - terminal = CashierTerminal.find_by_id(terminal_id.zone_id) - + terminal = DiningFacility.find_by_id(booking.dining_facility_id) + cashier_terminal = CashierTerminal.find_by_id(terminal.zone_id) if ENV["SERVER_MODE"] != "cloud" #no print in cloud server @@ -89,7 +88,7 @@ class Api::CheckInProcessController < Api::ApiController order_queue_printer = Printer::OrderQueuePrinter.new(printer) if !printer.nil? - order_queue_printer.print_check_in_out(printer, terminal, booking, dining_facility) + order_queue_printer.print_check_in_out(printer, cashier_terminal, booking, dining_facility) end end render :json => { :status => true, :checkout_at => booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M") } diff --git a/app/controllers/origami/check_in_process_controller.rb b/app/controllers/origami/check_in_process_controller.rb index b6e67943..207163c5 100644 --- a/app/controllers/origami/check_in_process_controller.rb +++ b/app/controllers/origami/check_in_process_controller.rb @@ -27,8 +27,7 @@ class Origami::CheckInProcessController < BaseOrigamiController @booking = Booking.create({:dining_facility_id => params[:dining_id],:type => "TableBooking", :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 }) - terminal_id = DiningFacility.find_by_id(@booking.dining_facility_id) - terminal = CashierTerminal.find_by_id(terminal_id.zone_id) + cashier_terminal = CashierTerminal.find_by_id(@dining_facility.zone_id) if @booking.save! @dining_facility.status = "occupied" @@ -37,7 +36,6 @@ class Origami::CheckInProcessController < BaseOrigamiController end if ENV["SERVER_MODE"] != "cloud" #no print in cloud server - printer = PrintSetting.find_by_unique_code("CheckInOutPdf") unique_code = "CheckInOutPdf" booking = Booking.find_by_booking_id(@booking.booking_id) @@ -47,7 +45,7 @@ class Origami::CheckInProcessController < BaseOrigamiController order_queue_printer = Printer::OrderQueuePrinter.new(printer) if !printer.nil? - order_queue_printer.print_check_in_out(printer, terminal, booking, table) + order_queue_printer.print_check_in_out(printer, cashier_terminal, booking, table) end end end diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index fca27cb8..22c8d25c 100755 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -70,8 +70,8 @@ class Origami::RequestBillsController < ApplicationController #check checkInOut pdf print check_booking = Booking.find_by_sale_id(@sale_id) checkout_time = Lookup.collection_of('checkout_time') - terminal_id = DiningFacility.find_by_id(check_booking.dining_facility_id) - terminal = CashierTerminal.find_by_id(terminal_id.zone_id) + terminal = DiningFacility.find_by_id(check_booking.dining_facility_id) + cashier_terminal = CashierTerminal.find_by_id(terminal.zone_id) if (!checkout_time.empty?) && (ENV["SERVER_MODE"] != "cloud") #no print in cloud server unique_code = "CheckInOutPdf" @@ -81,7 +81,7 @@ class Origami::RequestBillsController < ApplicationController order_queue_printer = Printer::OrderQueuePrinter.new(printer) if !printer.nil? - order_queue_printer.print_check_in_out(printer, terminal, check_booking, table) + order_queue_printer.print_check_in_out(printer, cashier_terminal, check_booking, table) end end end diff --git a/app/models/printer/order_queue_printer.rb b/app/models/printer/order_queue_printer.rb index 1d1d9d7f..267772f2 100755 --- a/app/models/printer/order_queue_printer.rb +++ b/app/models/printer/order_queue_printer.rb @@ -299,7 +299,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker end # Check in-out time - def print_check_in_out(print_settings, terminal, booking, table) + def print_check_in_out(print_settings, cashier_terminal, booking, table) #Use CUPS service #Generate PDF #Print @@ -330,7 +330,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker #no print in cloud server if ENV["SERVER_MODE"] != "cloud" - self.print(filename, terminal.printer_name) + self.print(filename, cashier_terminal.printer_name) end end end diff --git a/app/models/sale.rb b/app/models/sale.rb index 129c211c..848245a7 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -163,9 +163,7 @@ class Sale < ApplicationRecord booking.sale_id = self.id if !booking.checkout_at.nil? - if booking.checkout_at < Time.now.utc.getlocal booking.checkout_at = Time.now.utc.getlocal - end else booking.checkout_at = Time.now.utc.getlocal end diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index fb212f13..04204a73 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -18,13 +18,13 @@ class ActionController::Base # redirect_to root_url(:host => request.domain) + "store_error" render :json => [{ status: false, message: 'Invalid Access!'}] end - else - # check for license file - if check_license - current_license(ENV["SX_PROVISION_URL"]) - else - redirect_to activate_path - end + # else + # # check for license file + # if check_license + # current_license(ENV["SX_PROVISION_URL"]) + # else + # redirect_to activate_path + # end end end From 400f48967c06f0d127a798be4f7af49a98169df2 Mon Sep 17 00:00:00 2001 From: San Wai Lwin Date: Tue, 14 Aug 2018 15:24:17 +0630 Subject: [PATCH 3/5] action.controller --- config/initializers/action_controller.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index 04204a73..fb212f13 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -18,13 +18,13 @@ class ActionController::Base # redirect_to root_url(:host => request.domain) + "store_error" render :json => [{ status: false, message: 'Invalid Access!'}] end - # else - # # check for license file - # if check_license - # current_license(ENV["SX_PROVISION_URL"]) - # else - # redirect_to activate_path - # end + else + # check for license file + if check_license + current_license(ENV["SX_PROVISION_URL"]) + else + redirect_to activate_path + end end end From ef2fe2ead2acaa3398799140084e8939d4e9e1cb Mon Sep 17 00:00:00 2001 From: San Wai Lwin Date: Tue, 14 Aug 2018 14:03:45 +0630 Subject: [PATCH 4/5] Edit booking_id erroe --- .../origami/check_in_process_controller.rb | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/app/controllers/origami/check_in_process_controller.rb b/app/controllers/origami/check_in_process_controller.rb index 207163c5..92fd8142 100644 --- a/app/controllers/origami/check_in_process_controller.rb +++ b/app/controllers/origami/check_in_process_controller.rb @@ -33,21 +33,22 @@ class Origami::CheckInProcessController < BaseOrigamiController @dining_facility.status = "occupied" @dining_facility.save! end + + if ENV["SERVER_MODE"] != "cloud" #no print in cloud server + printer = PrintSetting.find_by_unique_code("CheckInOutPdf") + unique_code = "CheckInOutPdf" + booking = Booking.find_by_booking_id(@booking.booking_id) + table = DiningFacility.find(params[:dining_id]) + + # print when complete click + order_queue_printer = Printer::OrderQueuePrinter.new(printer) + + if !printer.nil? + order_queue_printer.print_check_in_out(printer, cashier_terminal, booking, table) + end + end end - if ENV["SERVER_MODE"] != "cloud" #no print in cloud server - printer = PrintSetting.find_by_unique_code("CheckInOutPdf") - unique_code = "CheckInOutPdf" - booking = Booking.find_by_booking_id(@booking.booking_id) - table = DiningFacility.find(params[:dining_id]) - - # print when complete click - order_queue_printer = Printer::OrderQueuePrinter.new(printer) - - if !printer.nil? - order_queue_printer.print_check_in_out(printer, cashier_terminal, booking, table) - end - end end respond = {:status => 'ok'} respond_to do |format| From 3a3d2819696c130198f083690d04c611d4ab155e Mon Sep 17 00:00:00 2001 From: San Wai Lwin Date: Tue, 14 Aug 2018 14:04:57 +0630 Subject: [PATCH 5/5] Pull from master --- app/models/sale_payment.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 9aac5236..8b6bb646 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -878,9 +878,9 @@ class SalePayment < ApplicationRecord .joins("INNER JOIN orders o ON o.order_id = so.order_id") if params[:type] == "cashier" - query = query.where("(CASE WHEN (s.grand_total + s.amount_changed)=(select SUM(payment_amount) FROM sale_payments WHERE sale_id=s.sale_id AND payment_method!='creditnote') THEN NULL ELSE payment_method='creditnote' AND o.source='#{params[:type]}' OR o.source='emenu' END) and s.sale_status = 'completed' #{receipt_no} #{customer}") + query = query.where("(CASE WHEN (s.grand_total + s.amount_changed)=(select SUM(payment_amount) FROM sale_payments WHERE sale_id=s.sale_id AND payment_method!='creditnote') THEN NULL ELSE payment_method='creditnote' AND o.source='#{params[:type]}' OR o.source='emenu' END) and s.sale_status = 'completed' and s.payment_status='paid' #{receipt_no} #{customer}") else - query = query.where("(CASE WHEN (s.grand_total + s.amount_changed)=(select SUM(payment_amount) FROM sale_payments WHERE sale_id=s.sale_id AND payment_method!='creditnote') THEN NULL ELSE payment_method='creditnote' AND o.source='#{params[:type]}' END) and s.sale_status = 'completed' #{receipt_no} #{customer}") + query = query.where("(CASE WHEN (s.grand_total + s.amount_changed)=(select SUM(payment_amount) FROM sale_payments WHERE sale_id=s.sale_id AND payment_method!='creditnote') THEN NULL ELSE payment_method='creditnote' AND o.source='#{params[:type]}' END) and s.sale_status = 'completed' and s.payment_status='paid' #{receipt_no} #{customer}") end query = query.group("s.receipt_no") .order("s.receipt_date ASC, s.receipt_no ASC")