Skip to content

Commit

Permalink
G2P-1328: Added payee function and configuration view changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Dibik committed Oct 4, 2023
1 parent 77b23ad commit 4a7843f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
25 changes: 20 additions & 5 deletions g2p_payment_g2p_connect/models/payment_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,23 @@ class G2PPaymentManagerG2PConnect(models.Model):

payer_fa = fields.Char(string="Payer Financial Address", required=True)
payer_name = fields.Char(required=True)

payee_prefix = fields.Char()
payee_suffix = fields.Char()

locale = fields.Char(required=True)

@api.onchange("payee_id_type")
def _onchange_payee_id_type(self):
prefix_mapping = {
"bank_acc_no": "account_no:",
"bank_acc_iban": "iban:",
"phone": "phone:",
"email": "email:",
# TODO: Need to add key:value pair for reg_id
}
self.payee_prefix = prefix_mapping.get(self.payee_id_type)

def _send_payments(self, batches):
_logger.info("DEBUG! send_payments Manager: G2P Connect.")
for batch in batches:
Expand Down Expand Up @@ -141,18 +156,18 @@ def _get_payee_fa(self, payment):
if payee_id_type == "bank_acc_no":
# TODO: Compute which bank_acc_no to choose from bank account list
for bank_id in payment.partner_id.bank_ids:
return bank_id.acc_number
return f"{self.payee_prefix}{bank_id.acc_number}@{bank_id.bank_id.bic}"
elif payee_id_type == "bank_acc_iban":
# TODO: Compute which iban to choose from bank account list
for bank_id in payment.partner_id.bank_ids:
return bank_id.iban
return f"{self.payee_prefix}{bank_id.iban}@{bank_id.bank_id.bic}"
elif payee_id_type == "phone":
return payment.partner_id.phone
return f"{self.payee_prefix}{payment.partner_id.phone}"
elif payee_id_type == "email":
return payment.partner_id.email
return f"{self.payee_prefix}{payment.partner_id.email}"
elif payee_id_type == "reg_id":
for reg_id in payment.partner_id.reg_ids:
if reg_id.id_type.id == self.reg_id_type_for_payee_id.id:
return reg_id.value
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
12 changes: 11 additions & 1 deletion g2p_payment_g2p_connect/views/payment_manager_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ Part of OpenG2P. See LICENSE file for full copyright and licensing details.
attrs="{'invisible':[('payee_id_type','!=','reg_id')],
'required':[('payee_id_type','==','reg_id')]}"
/>
<field
name="payee_prefix"
attrs="{'invisible':[('payee_id_type','==', False)],
'required':[('payee_id_type','!=', True)]}"
/>
<field
name="payee_suffix"
attrs="{'invisible':[('payee_id_type','!=','reg_id')],
'required':[('payee_id_type','==','reg_id')]}"
/>
<field name="locale" />
</group>
</xpath>
Expand All @@ -61,7 +71,7 @@ Part of OpenG2P. See LICENSE file for full copyright and licensing details.
</record>

<record id="action_payment_manager_g2p_connect" model="ir.actions.act_window">
<field name="name">Payment Managers</field>
<field name="name">G2P Connect Payment Managers</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">g2p.program.payment.manager.g2p.connect</field>
<field name="view_mode">tree,form</field>
Expand Down
2 changes: 1 addition & 1 deletion g2p_payment_simple_mpesa/views/payment_manager_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Part of OpenG2P. See LICENSE file for full copyright and licensing details.
</record>

<record id="action_payment_manager_simple_mpesa" model="ir.actions.act_window">
<field name="name">Payment Managers</field>
<field name="name">Simple Mpesa Payment Managers</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">g2p.program.payment.manager.simple.mpesa</field>
<field name="view_mode">tree,form</field>
Expand Down

0 comments on commit 4a7843f

Please sign in to comment.