sx cash payment api

This commit is contained in:
Myat Zin Wai Maw
2019-06-20 15:00:39 +06:30
parent 129e6a2a53
commit c06f0aade8
8 changed files with 184 additions and 6 deletions

View File

@@ -36,7 +36,7 @@ class SalePayment < ApplicationRecord
#route to payment type
case payment_method
when "cash"
payment_status = cash_payment(payment_for)
payment_status ,outstanding_amount ,balance_amount = cash_payment(payment_for)
when "creditnote"
if !self.sale.customer_id.nil?
payment_status = creditnote_payment(self.customer_id)
@@ -106,7 +106,7 @@ class SalePayment < ApplicationRecord
# end
end
return true, self.save,membership_data
return true, self.save,membership_data, outstanding_amount ,balance_amount
else
#record an payment in sale-audit
remark = "Payment failed - Grand Total [#{invoice.grand_total}] | Due [#{amount_due}] | Paid [#{invoice.amount_received}]"
@@ -336,7 +336,16 @@ class SalePayment < ApplicationRecord
if !payment_for
sale_update_payment_status(self.received_amount,status)
end
return payment_status
balance_amount =0.0
outstanding_amount =0.0
if self.sale.grand_total.to_f > self.received_amount.to_f
balance_amount = self.sale.grand_total.to_f - self.received_amount.to_f
outstanding_amount = 0.0
else
balance_amount = 0.0
outstanding_amount = self.received_amount.to_f - self.sale.grand_total.to_f
end
return payment_status , outstanding_amount.to_i, balance_amount.to_i
end
def foc_payment