Commit b808a05f 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 92dae2cf
Pipeline #14137 failed with stage
in 0 seconds
reference = ''
if context.getBankCountryCode():
reference = ' '.join((context.getBankCountryCode(),
context.getBankCode() or '',
context.getBranch() or '',
context.getBankAccountNumber() or '',
context.getBankAccountKey() or ''))
else:
reference = ' '.join((context.getBankCode() or '',
context.getBranch() or '',
context.getBankAccountNumber() or '',
context.getBankAccountKey() or ''))
if context.getIban():
return context.getIban()
reference = ' '.join(
part for part in (
context.getBankCountryCode(),
context.getBankCode(),
context.getBranch(),
context.getBankAccountNumber(),
context.getBankAccountKey(),)
if part
)
if not reference.strip():
return default or context.getTitleOrId()
......
......@@ -46,6 +46,7 @@
<value>
<list>
<string>title</string>
<string>iban</string>
<string>bank_country_code</string>
<string>bank_code</string>
<string>branch</string>
......
......@@ -888,6 +888,54 @@ class TestERP5Base(ERP5TypeTestCase):
self.portal.portal_workflow.doActionFor(bank_account, 'validate_action')
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):
# We can add Images inside Persons and Organisation
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