From c643b61a9ef841cb812170b9d5a7be03e03c3400 Mon Sep 17 00:00:00 2001 From: Tristan Hill Date: Tue, 25 Oct 2011 12:51:12 +0100 Subject: [PATCH] [IMP] add support for selecting faster payment mode --- .../data/banking_export_hsbc.xml | 14 +++++++--- account_banking_uk_hsbc/wizard/export_hsbc.py | 26 ++++++++++--------- account_banking_uk_hsbc/wizard/paymul.py | 5 ++-- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/account_banking_uk_hsbc/data/banking_export_hsbc.xml b/account_banking_uk_hsbc/data/banking_export_hsbc.xml index 0b2e75e1b..76a6e3cb5 100644 --- a/account_banking_uk_hsbc/data/banking_export_hsbc.xml +++ b/account_banking_uk_hsbc/data/banking_export_hsbc.xml @@ -1,13 +1,21 @@ - - HSBC - HSBC + + ACH or EZONE + not used + + Faster Payment + not used + + + diff --git a/account_banking_uk_hsbc/wizard/export_hsbc.py b/account_banking_uk_hsbc/wizard/export_hsbc.py index 44f2f7bc7..227deea59 100644 --- a/account_banking_uk_hsbc/wizard/export_hsbc.py +++ b/account_banking_uk_hsbc/wizard/export_hsbc.py @@ -149,11 +149,15 @@ class banking_export_hsbc_wizard(osv.osv_memory): ) transaction_kwargs = { 'charges': paymul.CHARGES_EACH_OWN, - 'means': paymul.MEANS_EZONE, } elif oe_account.country_id.code == 'GB': - sortcode, accountno = oe_account.acc_number.split(" ", 2) - + split = oe_account.acc_number.split(" ", 2) + if len(split) == 2: + sortcode, accountno = split + else: + raise osv.except_osv( + _('Error'), + "Invalid GB acccount number '%s'" % oe_account.acc_number) paymul_account = paymul.UKAccount( number=accountno, sortcode=sortcode, @@ -162,7 +166,6 @@ class banking_export_hsbc_wizard(osv.osv_memory): ) transaction_kwargs = { 'charges': paymul.CHARGES_PAYEE, - 'means': paymul.MEANS_ACH, } else: raise osv.except_osv( @@ -183,20 +186,19 @@ class banking_export_hsbc_wizard(osv.osv_memory): ) ) - try: - dest_account, transaction_kwargs = self._create_account( - line.bank_id) - except ValueError as exc: - raise osv.except_osv( - _('Error'), - _('Destination account invalid: ') + str(exc) - ) + dest_account, transaction_kwargs = self._create_account(line.bank_id) + + means = {'ACH or EZONE': paymul.MEANS_ACH_OR_EZONE, + 'Faster Payment': paymul.MEANS_FASTER_PAYMENT}.get(line.order_id.mode.type.name) + if means is None: + raise osv.except_osv('Error', "Invalid payment type mode for HSBC '%s'" % line.order_id.mode.type.name) try: return paymul.Transaction( amount=Decimal(str(line.amount_currency)), currency=line.currency.name, account=dest_account, + means=means, name_address=line.info_partner, customer_reference=line.name, payment_reference=line.name, diff --git a/account_banking_uk_hsbc/wizard/paymul.py b/account_banking_uk_hsbc/wizard/paymul.py index a5a60188c..5d0d34e6c 100644 --- a/account_banking_uk_hsbc/wizard/paymul.py +++ b/account_banking_uk_hsbc/wizard/paymul.py @@ -354,9 +354,10 @@ CHARGES_PAYEE = 13 CHARGES_EACH_OWN = 14 CHARGES_PAYER = 15 -MEANS_ACH = 2 -MEANS_EZONE = 2 +# values per section 2.8.5 "PAI, Payment Instructions" of "HSBC - CRG Paymul Message Implementation Guide" +MEANS_ACH_OR_EZONE = 2 MEANS_PRIORITY_PAYMENT = 52 +MEANS_FASTER_PAYMENT = 'FPS' CHANNEL_INTRA_COMPANY = 'Z24'