@@ -110,6 +110,44 @@ class SignatureAlgorithm(DataElementGroup):
110110
111111
112112class BankIdentifier (DataElementGroup ):
113+ COUNTRY_ALPHA_TO_NUMERIC = {
114+ # Kapitel E.4 der SEPA-Geschäftsvorfälle
115+ 'BE' : '056' ,
116+ 'BG' : '100' ,
117+ 'DK' : '208' ,
118+ 'DE' : '280' ,
119+ 'FI' : '246' ,
120+ 'FR' : '250' ,
121+ 'GR' : '300' ,
122+ 'GB' : '826' ,
123+ 'IE' : '372' ,
124+ 'IS' : '352' ,
125+ 'IT' : '380' ,
126+ 'JP' : '392' ,
127+ 'CA' : '124' ,
128+ 'HR' : '191' ,
129+ 'LI' : '438' ,
130+ 'LU' : '442' ,
131+ 'NL' : '528' ,
132+ 'AT' : '040' ,
133+ 'PL' : '616' ,
134+ 'PT' : '620' ,
135+ 'RO' : '642' ,
136+ 'RU' : '643' ,
137+ 'SE' : '752' ,
138+ 'CH' : '756' ,
139+ 'SK' : '703' ,
140+ 'SI' : '705' ,
141+ 'ES' : '724' ,
142+ 'CZ' : '203' ,
143+ 'TR' : '792' ,
144+ 'HU' : '348' ,
145+ 'US' : '840' ,
146+ 'EU' : '978'
147+ }
148+ COUNTRY_NUMERIC_TO_ALPHA = {v : k for k , v in COUNTRY_ALPHA_TO_NUMERIC .items ()}
149+ COUNTRY_NUMERIC_TO_ALPHA ['276' ] = 'DE' # not yet in use by banks, but defined by ISO
150+
113151 country_identifier = DataElementField (type = 'ctr' )
114152 bank_code = DataElementField (type = 'an' , max_length = 30 )
115153
@@ -418,9 +456,6 @@ def as_sepa_account(self):
418456 from fints .models import SEPAAccount
419457 if not self .is_sepa :
420458 return None
421- if not self .bank_identifier .country_identifier == '280' :
422- # FIXME Limitation of SEPAAccount object
423- return None
424459 return SEPAAccount (self .iban , self .bic , self .account_number , self .subaccount_number , self .bank_identifier .bank_code )
425460
426461 @classmethod
@@ -432,7 +467,7 @@ def from_sepa_account(cls, acc):
432467 account_number = acc .accountnumber ,
433468 subaccount_number = acc .subaccount ,
434469 bank_identifier = BankIdentifier (
435- country_identifier = '280' ,
470+ country_identifier = BankIdentifier . COUNTRY_ALPHA_TO_NUMERIC [ acc . bic [ 4 : 6 ]] ,
436471 bank_code = acc .blz
437472 )
438473 )
@@ -470,7 +505,7 @@ def from_sepa_account(cls, acc):
470505 return cls (
471506 account_number = acc .accountnumber ,
472507 subaccount_number = acc .subaccount ,
473- country_identifier = '280' ,
508+ country_identifier = BankIdentifier . COUNTRY_ALPHA_TO_NUMERIC [ acc . bic [ 4 : 6 ]] ,
474509 bank_code = acc .blz ,
475510 )
476511
@@ -489,7 +524,7 @@ def from_sepa_account(cls, acc):
489524 account_number = acc .accountnumber ,
490525 subaccount_number = acc .subaccount ,
491526 bank_identifier = BankIdentifier (
492- country_identifier = '280' ,
527+ country_identifier = BankIdentifier . COUNTRY_ALPHA_TO_NUMERIC [ acc . bic [ 4 : 6 ]] ,
493528 bank_code = acc .blz
494529 )
495530 )
0 commit comments