Skip to content

Commit

Permalink
Merge pull request #202 from lalithkota/15.0-develop
Browse files Browse the repository at this point in the history
Payments: Added check to fail when no ID or bank account available
  • Loading branch information
shibu-narayanan authored Mar 2, 2024
2 parents f8f8753 + dfab9e6 commit a6dffd9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions g2p_payment_g2p_connect/models/payment_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,17 @@ def _send_payments(self, batches):
"message": {"transaction_id": batch.name, "disbursements": []},
}
for payment in batch.payment_ids:
payee_fa = self._get_payee_fa(payment)
if not payee_fa:
# TODO: Deal with no bank acc and/or ID type not matching any available IDs
payment.state = "reconciled"
payment.status = "failed"
continue
batch_data["message"]["disbursements"].append(
{
"reference_id": payment.name,
"payer_fa": "",
"payee_fa": self._get_payee_fa(payment),
"payee_fa": payee_fa,
"amount": str(payment.amount_issued),
"payee_name": payment.partner_id.name,
"note": f"Payment for {batch.cycle_id.name} under {self.program_id.name}",
Expand Down Expand Up @@ -279,7 +285,6 @@ def _get_payee_fa(self, payment):
for reg_id in partner.reg_ids:
if reg_id.id_type.id == self.reg_id_type_for_payee_id.id:
return f"{self.payee_prefix}{reg_id.value}{self.payee_suffix}"
# TODO: Deal with no bank acc and/or ID type not matching any available IDs
return None

@api.model
Expand Down

0 comments on commit a6dffd9

Please sign in to comment.