Commit 8bd539bd authored by Jérome Perrin's avatar Jérome Perrin

base: make BankAccount.getReference use BankAccount.getIban

When IBAN is defined, use it by default for reference. IBAN is used by
default all over europe, so when it's set it should be used by default for
reference.
Mixing IBAN and other properties does not make sense, so this change
should not have unexpected side effects.

We also update "edit_order" on BankAccount_view so that title properly
fallbacks on reference when reference is iban.
parent 4b516fe8
Pipeline #13853 canceled with stage
reference = '' if context.getIban():
if context.getBankCountryCode(): return context.getIban()
reference = ' '.join((context.getBankCountryCode(),
context.getBankCode() or '', reference = ' '.join(
context.getBranch() or '', part for part in (
context.getBankAccountNumber() or '', context.getBankCountryCode(),
context.getBankAccountKey() or '')) context.getBankCode(),
else: context.getBranch(),
reference = ' '.join((context.getBankCode() or '', context.getBankAccountNumber(),
context.getBranch() or '', context.getBankAccountKey(),)
context.getBankAccountNumber() or '', if part
context.getBankAccountKey() or '')) )
if not reference.strip(): if not reference.strip():
return default or context.getTitleOrId() return default or context.getTitleOrId()
......
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
<value> <value>
<list> <list>
<string>title</string> <string>title</string>
<string>iban</string>
<string>bank_country_code</string> <string>bank_country_code</string>
<string>bank_code</string> <string>bank_code</string>
<string>branch</string> <string>branch</string>
......
...@@ -888,6 +888,54 @@ class TestERP5Base(ERP5TypeTestCase): ...@@ -888,6 +888,54 @@ class TestERP5Base(ERP5TypeTestCase):
self.portal.portal_workflow.doActionFor(bank_account, 'validate_action') self.portal.portal_workflow.doActionFor(bank_account, 'validate_action')
self.assertEqual('validated', bank_account.getValidationState()) self.assertEqual('validated', bank_account.getValidationState())
def test_bank_account_reference_default_id(self):
bank_account = self.portal.organisation_module.newContent(
portal_type='Organisation',
).newContent(
portal_type='Bank Account',
id='bank_account_id',
)
self.assertEqual(bank_account.getReference(), 'bank_account_id')
def test_bank_account_reference_from_bank_code(self):
bank_account = self.portal.organisation_module.newContent(
portal_type='Organisation',
).newContent(
portal_type='Bank Account',
)
bank_account.setBankCode('bank-code')
bank_account.setBranch('branch-code')
bank_account.setBankAccountNumber('account-number')
bank_account.setBankAccountKey('account-key')
self.assertEqual(
bank_account.getReference(),
'bank-code branch-code account-number account-key',
)
bank_account.setBankCountryCode('bank-country-code')
self.assertEqual(
bank_account.getReference(),
'bank-country-code bank-code branch-code account-number account-key',
)
def test_bank_account_reference_from_iban(self):
bank_account = self.portal.organisation_module.newContent(
portal_type='Organisation',
).newContent(
portal_type='Bank Account',
)
bank_account.setIban('iban')
bank_account.setBicCode('bic-code')
self.assertEqual(bank_account.getReference(), 'iban')
# other codes are ignored if there's an iban
bank_account.setBankCode('bank-code')
bank_account.setBranch('branch-code')
bank_account.setBankAccountNumber('account-number')
bank_account.setBankAccountKey('account-key')
bank_account.setBankCountryCode('bank-country-code')
self.assertEqual(bank_account.getReference(), 'iban')
def test_CreateImage(self): def test_CreateImage(self):
# We can add Images inside Persons and Organisation # We can add Images inside Persons and Organisation
for entity in (self.getPersonModule().newContent(portal_type='Person'), for entity in (self.getPersonModule().newContent(portal_type='Person'),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment