From c08c72d0cbc6a84212add8e6fc6dd21ac51e724c Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Wed, 16 May 2018 09:23:10 +0630 Subject: [PATCH 1/2] update cash in and out for shift --- .../origami/cash_ins_controller.rb | 25 ++++++++++++++++++- .../origami/cash_outs_controller.rb | 22 ++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/app/controllers/origami/cash_ins_controller.rb b/app/controllers/origami/cash_ins_controller.rb index 441cd94e..1207d486 100755 --- a/app/controllers/origami/cash_ins_controller.rb +++ b/app/controllers/origami/cash_ins_controller.rb @@ -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 diff --git a/app/controllers/origami/cash_outs_controller.rb b/app/controllers/origami/cash_outs_controller.rb index 8c81b5cb..d3716915 100755 --- a/app/controllers/origami/cash_outs_controller.rb +++ b/app/controllers/origami/cash_outs_controller.rb @@ -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 From d6a3c949f061f7f16f9175703ce3366a71c76b64 Mon Sep 17 00:00:00 2001 From: phyusin Date: Wed, 16 May 2018 09:49:49 +0630 Subject: [PATCH 2/2] comment remark for order reservation --- app/models/order_reservation.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/order_reservation.rb b/app/models/order_reservation.rb index d0fab31a..477ef631 100644 --- a/app/models/order_reservation.rb +++ b/app/models/order_reservation.rb @@ -62,7 +62,7 @@ class OrderReservation < ApplicationRecord end if order_reserve[:reservation_info] order_reservation.total_customer = order_reserve[:reservation_info][:total_user] - order_reservation.order_remark = order_reserve[:reservation_info][:reservation_note] + # order_reservation.order_remark = order_reserve[:reservation_info][:reservation_note] end order_reservation.save! if order_reserve[:order_info][:items]