update cash in and out for shift

This commit is contained in:
Aung Myo
2018-05-16 09:23:10 +06:30
parent 1eb6cd5bcf
commit c08c72d0cb
2 changed files with 46 additions and 1 deletions

View File

@@ -11,7 +11,30 @@ class Origami::CashInsController < BaseOrigamiController
p_jour = PaymentJournal.new
p_jour.cash_in(reference, remark, amount, payment_method, payment_method_reference, current_user.id)
shift = ShiftSale.current_open_shift(current_user.id)
shift.cash_in = shift.cash_in + amount.to_i
current_shift = ShiftSale.current_shift
# set cashier
if shift != nil
shift = shift
else
open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
if open_cashier.count>0
shift = ShiftSale.current_open_shift(open_cashier[0].id)
if shift
shift = ShiftSale.current_open_shift(shift.id)
else
shift = ShiftSale.current_open_shift(current_shift.id)
end
else
shift = Employee.find(current_shift.employee_id).name
end
end
shift.cash_in = shift.cash_in + amount.to_f
shift.save
end

View File

@@ -9,6 +9,28 @@ class Origami::CashOutsController < BaseOrigamiController
p_jour = PaymentJournal.new
p_jour.cash_out(reference, remark, amount, current_user.id)
shift = ShiftSale.current_open_shift(current_user.id)
current_shift = ShiftSale.current_shift
# set cashier
if shift != nil
shift = shift
else
open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
if open_cashier.count>0
shift = ShiftSale.current_open_shift(open_cashier[0].id)
if shift
shift = ShiftSale.current_open_shift(shift.id)
else
shift = ShiftSale.current_open_shift(current_shift.id)
end
else
shift = Employee.find(current_shift.employee_id).name
end
end
shift.cash_out = shift.cash_out + amount.to_i
shift.save
end