Skip to content

fints-2.1.1 accountnumber vs account_number, etc. #59

@drcicero

Description

@drcicero

Hi! Trying fints-2.1.1 from pypi, I got this error, calling get_transactions:

...
  File "/home/dave/.local/lib/python3.6/site-packages/fints/client.py", line 497, in get_transactions
    'HIKAZ'
  File "/home/dave/.local/lib/python3.6/site-packages/fints/client.py", line 436, in _fetch_with_touchdowns
    seg = segment_factory(touchdown)
  File "/home/dave/.local/lib/python3.6/site-packages/fints/client.py", line 491, in <lambda>
    account=hkkaz._fields['account'].type.from_sepa_account(account),
  File "/home/dave/.local/lib/python3.6/site-packages/fints/formals.py", line 506, in from_sepa_account
    account_number=acc.accountnumber,
AttributeError: 'KTZ1' object has no attribute 'accountnumber'

The problem is related to the following code portions of formals.py:

class Account2 ...
     def from_sepa_account(cls, acc):
         return cls(
             account_number=acc.accountnumber,
             subaccount_number=acc.subaccount,
             country_identifier=BankIdentifier.COUNTRY_ALPHA_TO_NUMERIC[acc.bic[4:6]],
             bank_code=acc.blz,
         )

...

class Account3 ...
     def from_sepa_account(cls, acc):
         return cls(
             account_number=acc.accountnumber,
             subaccount_number=acc.subaccount,
             bank_identifier=BankIdentifier(
                 country_identifier=BankIdentifier.COUNTRY_ALPHA_TO_NUMERIC[acc.bic[4:6]],
                 bank_code=acc.blz
             )
         )

It seems to me that the KTZ1 properties were refactored from accountnumber to account_number and from blz to bank_identifier.bank_code, but not in this place? So the following fix works for me:

class Account2 ...
     def from_sepa_account(cls, acc):
         return cls(
             account_number=acc.account_number,
             subaccount_number=acc.subaccount_number,
             country_identifier=BankIdentifier.COUNTRY_ALPHA_TO_NUMERIC[acc.bic[4:6]],
             bank_code=acc.bank_identifier.bank_code,
         )

...

class Account3 ...
     def from_sepa_account(cls, acc):
         return cls(
             account_number=acc.account_number,
             subaccount_number=acc.subaccount_number,
             bank_identifier=acc.bank_identifier,
         )

I would guess country_identifier and bank_code in Account2 could be refactored to bank_identifier to increase consistency, too? Maybe someone is doing that?

My issue here was written after only a short glance at the source code, and I have no idea about the complete picture :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions