From 7afb4cf0ebbb1e64e8b0bb5075cb1662a3b63a7e Mon Sep 17 00:00:00 2001 From: yarzar_code Date: Fri, 10 Jan 2020 15:05:02 +0630 Subject: [PATCH 1/2] Update shift credit with current user --- app/models/printer/printer_worker.rb | 22 +++++++++++----------- app/models/sale_payment.rb | 5 ++++- config/initializers/action_controller.rb | 10 +++++----- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/app/models/printer/printer_worker.rb b/app/models/printer/printer_worker.rb index d30af42d..5d7cce22 100755 --- a/app/models/printer/printer_worker.rb +++ b/app/models/printer/printer_worker.rb @@ -42,17 +42,17 @@ class Printer::PrinterWorker end def print(file_path, printer_destination = nil ) - if printer_destination.nil? - printer_destination = self.printer_destination - end + # if printer_destination.nil? + # printer_destination = self.printer_destination + # end - copy = self.print_copies - #Print only when printer information is not null - if !self.printer_destination.nil? - (1..copy).each do - page = Cups::PrintJob.new(file_path, printer_destination) - page.print - end - end + # copy = self.print_copies + # #Print only when printer information is not null + # if !self.printer_destination.nil? + # (1..copy).each do + # page = Cups::PrintJob.new(file_path, printer_destination) + # page.print + # end + # end end end diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 06350f6f..36bc6de3 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -722,7 +722,10 @@ class SalePayment < ApplicationRecord # update for shift with credit payment def update_shift_for_credit_payment shift_credit = ShiftSale.find_by_id(self.sale.shift_sale_id) - shift = ShiftSale.find_by_id(ShiftSale.current_shift) + shift = self.action_by.current_shift + if !shift.nil? + shift = ShiftSale.current_shift + end if !shift.nil? credit_payment_left = get_credit_payment_left[0].payment_amount.to_f if self.payment_method == "cash" diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index eb7ba401..2cf70a1b 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -20,11 +20,11 @@ class ActionController::Base end else # check for license file - if check_license - current_license(ENV["SX_PROVISION_URL"]) - else - redirect_to activate_path - end + # if check_license + # current_license(ENV["SX_PROVISION_URL"]) + # else + # redirect_to activate_path + # end end end From 44b568a5f4fe2f6f31fd54e0645297b172937c40 Mon Sep 17 00:00:00 2001 From: yarzar_code Date: Fri, 10 Jan 2020 15:05:36 +0630 Subject: [PATCH 2/2] Update shift credit with current_user --- app/models/printer/printer_worker.rb | 22 +++++++++++----------- config/initializers/action_controller.rb | 10 +++++----- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/models/printer/printer_worker.rb b/app/models/printer/printer_worker.rb index 5d7cce22..d30af42d 100755 --- a/app/models/printer/printer_worker.rb +++ b/app/models/printer/printer_worker.rb @@ -42,17 +42,17 @@ class Printer::PrinterWorker end def print(file_path, printer_destination = nil ) - # if printer_destination.nil? - # printer_destination = self.printer_destination - # end + if printer_destination.nil? + printer_destination = self.printer_destination + end - # copy = self.print_copies - # #Print only when printer information is not null - # if !self.printer_destination.nil? - # (1..copy).each do - # page = Cups::PrintJob.new(file_path, printer_destination) - # page.print - # end - # end + copy = self.print_copies + #Print only when printer information is not null + if !self.printer_destination.nil? + (1..copy).each do + page = Cups::PrintJob.new(file_path, printer_destination) + page.print + end + end end end diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index 2cf70a1b..eb7ba401 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -20,11 +20,11 @@ class ActionController::Base end else # check for license file - # if check_license - # current_license(ENV["SX_PROVISION_URL"]) - # else - # redirect_to activate_path - # end + if check_license + current_license(ENV["SX_PROVISION_URL"]) + else + redirect_to activate_path + end end end