add junction pay

This commit is contained in:
Yan
2018-03-16 18:37:54 +06:30
parent c982da4264
commit fa125df355
8 changed files with 369 additions and 8 deletions

View File

@@ -48,6 +48,8 @@ class SalePayment < ApplicationRecord
payment_status = paypar_payment
when "foc"
payment_status = foc_payment
when "JunctionPay"
payment_status = junction_pay_payment
else
puts "it was something else"
end
@@ -297,6 +299,22 @@ class SalePayment < ApplicationRecord
end
def junction_pay_payment
payment_status = false
#Next time - validate if the vochure number is valid - within
self.payment_method = "JunctionPay"
self.payment_amount = self.received_amount
self.payment_reference = self.voucher_no
self.outstanding_amount = self.sale.grand_total- self.received_amount
self.payment_status = "paid"
payment_method = self.save!
sale_update_payment_status(self.received_amount)
return payment_status
end
def sale_update_payment_status(paid_amount,check_foc = false)
#update amount_outstanding
self.sale.amount_received = self.sale.amount_received.to_f + paid_amount.to_f