diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index d489fdf5..06350f6f 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -721,7 +721,8 @@ class SalePayment < ApplicationRecord # update for shift with credit payment def update_shift_for_credit_payment - shift = ShiftSale.find_by_id(self.sale.shift_sale_id) + shift_credit = ShiftSale.find_by_id(self.sale.shift_sale_id) + shift = ShiftSale.find_by_id(ShiftSale.current_shift) if !shift.nil? credit_payment_left = get_credit_payment_left[0].payment_amount.to_f if self.payment_method == "cash" @@ -739,9 +740,12 @@ class SalePayment < ApplicationRecord shift.other_sales = shift.other_sales.to_f + self.received_amount.to_f end if credit_payment_left == 0 || credit_payment_left >= self.received_amount.to_f - shift.credit_sales = shift.credit_sales.to_f - self.received_amount.to_f + if shift.id == shift_credit.id + shift.credit_sales = shift_credit.credit_sales.to_f - self.received_amount.to_f + end + else - shift.credit_sales = shift.credit_sales.to_f - (self.received_amount.to_f + credit_payment_left) + shift.credit_sales = shift_credit.credit_sales.to_f - (self.received_amount.to_f + credit_payment_left) end shift.save end diff --git a/config/puma_backup.rb b/config/puma_backup.rb index f0013d25..d24425ae 100755 --- a/config/puma_backup.rb +++ b/config/puma_backup.rb @@ -1,11 +1,11 @@ -# application_path="#{File.expand_path("../..", __FILE__)}" -# directory application_path -# #environment ENV.fetch("RAILS_ENV") { "production" } -# environment "production" -# pidfile "#{application_path}/tmp/puma/pid" -# state_path "#{application_path}/tmp/puma/state" -# stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" -# port ENV.fetch("PORT") { 62158 } -# workers 2 -# preload_app! -# threads 1,1 +application_path="#{File.expand_path("../..", __FILE__)}" +directory application_path +#environment ENV.fetch("RAILS_ENV") { "production" } +environment "production" +pidfile "#{application_path}/tmp/puma/pid" +state_path "#{application_path}/tmp/puma/state" +stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" +port ENV.fetch("PORT") { 62158 } +workers 2 +preload_app! +threads 1,1