Update shift for credit payment
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user