payment
This commit is contained in:
@@ -106,7 +106,6 @@ class SalePayment < ApplicationRecord
|
||||
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
|
||||
self.payment_status = "paid"
|
||||
payment_method = self.save!
|
||||
|
||||
sale_update_payment_status(self.received_amount)
|
||||
|
||||
return payment_status
|
||||
@@ -205,30 +204,28 @@ class SalePayment < ApplicationRecord
|
||||
end
|
||||
|
||||
def sale_update_payment_status(paid_amount)
|
||||
puts "sale update"
|
||||
#update amount_outstanding
|
||||
self.sale.amount_received = self.sale.amount_received.to_f + paid_amount.to_f
|
||||
|
||||
self.sale.amount_changed = paid_amount.to_f - self.sale.amount_received.to_f
|
||||
|
||||
all_received_amount = 0.0
|
||||
sObj = self.sale
|
||||
sObj = Sale.find(self.sale_id)
|
||||
sObj.sale_payments.each do |spay|
|
||||
puts spay
|
||||
puts spay.payment_amount
|
||||
all_received_amount += spay.payment_amount.to_f
|
||||
end
|
||||
puts all_received_amount
|
||||
puts self.sale.grand_total
|
||||
|
||||
if (self.sale.grand_total <= all_received_amount)
|
||||
puts " sale update ......"
|
||||
self.sale.payment_status = "paid"
|
||||
self.sale.sale_status = "completed"
|
||||
self.sale.save!
|
||||
rebat()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def rebat
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
def generate_custom_id
|
||||
self.sale_payment_id = SeedGenerator.generate_id(self.class.name, "SPI")
|
||||
|
||||
Reference in New Issue
Block a user