raphaelm / python-fints

Pure-python FinTS (formerly known as HBCI) implementation
https://pypi.python.org/pypi/fints
GNU Lesser General Public License v3.0
323 stars 78 forks source link

Comdirect: credit card account is not a SEPA account #73

Open runiq opened 5 years ago

runiq commented 5 years ago

Using get_sepa_accounts() with a Comdirect FinTS object does not yield the credit card accounts:

>>> pprint(f.get_sepa_accounts())
[SEPAAccount(iban='XXX', bic='XXX', accountnumber='XXX', subaccount='Girokonto', blz='XXX'),
 SEPAAccount(iban='XXX', bic='XXX', accountnumber='XXX', subaccount='Tagesgeld PLUS', blz='XXX')]

Even though the very same account is listed when I use get_information() on the FinTS object:

>>> pprint(f.get_information())
{'accounts': [{'account_number': 'XXX',
               'bank_identifier': fints.formals.BankIdentifier(country_identifier='280', bank_code='XXX'),
               'currency': 'EUR',
               'customer_id': 'XXX',
               'iban': 'XXX',
               'owner_name': ['XXX'],
               'product_name': 'Girokonto',
               'subaccount_number': 'Girokonto',
               'supported_operations': {<FinTSOperations.GET_TRANSACTIONS_XML: ('HKCAZ',)>: False,
                                        <FinTSOperations.GET_CREDIT_CARD_TRANSACTIONS: ('DKKKU',)>: False,
                                        <FinTSOperations.GET_STATEMENT: ('HKEKA',)>: False,
                                        <FinTSOperations.GET_STATEMENT_PDF: ('HKEKP',)>: False,
                                        <FinTSOperations.GET_HOLDINGS: ('HKWPD',)>: False,
                                        <FinTSOperations.GET_SEPA_ACCOUNTS: ('HKSPA',)>: True,
                                        <FinTSOperations.GET_SCHEDULED_DEBITS_SINGLE: ('HKDBS',)>: False,
                                        <FinTSOperations.GET_SCHEDULED_DEBITS_MULTIPLE: ('HKDMB',)>: False,
                                        <FinTSOperations.GET_STATUS_PROTOCOL: ('HKPRO',)>: False,
                                        <FinTSOperations.SEPA_TRANSFER_SINGLE: ('HKCCS',)>: True,
                                        <FinTSOperations.SEPA_TRANSFER_MULTIPLE: ('HKCCM',)>: True,
                                        <FinTSOperations.SEPA_DEBIT_SINGLE: ('HKDSE',)>: False,
                                        <FinTSOperations.SEPA_DEBIT_MULTIPLE: ('HKDME',)>: False,
                                        <FinTSOperations.SEPA_DEBIT_SINGLE_COR1: ('HKDSC',)>: False,
                                        <FinTSOperations.SEPA_DEBIT_MULTIPLE_COR1: ('HKDMC',)>: False,
                                        <FinTSOperations.SEPA_STANDING_DEBIT_SINGLE_CREATE: ('HKDDE',)>: False,
                                        <FinTSOperations.GET_SEPA_STANDING_DEBITS_SINGLE: ('HKDDB',)>: False,
                                        <FinTSOperations.SEPA_STANDING_DEBIT_SINGLE_DELETE: ('HKDDL',)>: False,
                                        <FinTSOperations.GET_TRANSACTIONS: ('HKKAZ',)>: True,
                                        <FinTSOperations.GET_BALANCE: ('HKSAL',)>: True},
               'type': None},
              {'account_number': 'XXX',
               'bank_identifier': fints.formals.BankIdentifier(country_identifier='280', bank_code='20041144'),
               'currency': 'EUR',
               'customer_id': 'XXX',
               'iban': 'XXX',
               'owner_name': ['XXX'],
               'product_name': 'Tagesgeld PLUS',
               'subaccount_number': 'Tagesgeld PLUS',
               'supported_operations': {<FinTSOperations.GET_TRANSACTIONS_XML: ('HKCAZ',)>: False,
                                        <FinTSOperations.GET_CREDIT_CARD_TRANSACTIONS: ('DKKKU',)>: False,
                                        <FinTSOperations.GET_STATEMENT: ('HKEKA',)>: False,
                                        <FinTSOperations.GET_STATEMENT_PDF: ('HKEKP',)>: False,
                                        <FinTSOperations.GET_HOLDINGS: ('HKWPD',)>: False,
                                        <FinTSOperations.GET_SEPA_ACCOUNTS: ('HKSPA',)>: True,
                                        <FinTSOperations.GET_SCHEDULED_DEBITS_SINGLE: ('HKDBS',)>: False,
                                        <FinTSOperations.GET_SCHEDULED_DEBITS_MULTIPLE: ('HKDMB',)>: False,
                                        <FinTSOperations.GET_STATUS_PROTOCOL: ('HKPRO',)>: False,
                                        <FinTSOperations.SEPA_TRANSFER_SINGLE: ('HKCCS',)>: True,
                                        <FinTSOperations.SEPA_TRANSFER_MULTIPLE: ('HKCCM',)>: False,
                                        <FinTSOperations.SEPA_DEBIT_SINGLE: ('HKDSE',)>: False,
                                        <FinTSOperations.SEPA_DEBIT_MULTIPLE: ('HKDME',)>: False,
                                        <FinTSOperations.SEPA_DEBIT_SINGLE_COR1: ('HKDSC',)>: False,
                                        <FinTSOperations.SEPA_DEBIT_MULTIPLE_COR1: ('HKDMC',)>: False,
                                        <FinTSOperations.SEPA_STANDING_DEBIT_SINGLE_CREATE: ('HKDDE',)>: False,
                                        <FinTSOperations.GET_SEPA_STANDING_DEBITS_SINGLE: ('HKDDB',)>: False,
                                        <FinTSOperations.SEPA_STANDING_DEBIT_SINGLE_DELETE: ('HKDDL',)>: False,
                                        <FinTSOperations.GET_TRANSACTIONS: ('HKKAZ',)>: True,
                                        <FinTSOperations.GET_BALANCE: ('HKSAL',)>: True},
               'type': None},
              {'account_number': 'YYYYYY',
               'bank_identifier': fints.formals.BankIdentifier(country_identifier='280', bank_code='20041144'),
               'currency': 'EUR',
               'customer_id': 'XXX',
               'iban': None,
               'owner_name': ['XXX'],
               'product_name': 'Visa Prepaid-Kreditkarte',
               'subaccount_number': 'Visa Prepaid-Kreditkarte',
               'supported_operations': {<FinTSOperations.GET_TRANSACTIONS_XML: ('HKCAZ',)>: False,
                                        <FinTSOperations.GET_CREDIT_CARD_TRANSACTIONS: ('DKKKU',)>: True,
                                        <FinTSOperations.GET_STATEMENT: ('HKEKA',)>: False,
                                        <FinTSOperations.GET_STATEMENT_PDF: ('HKEKP',)>: False,
                                        <FinTSOperations.GET_HOLDINGS: ('HKWPD',)>: False,
                                        <FinTSOperations.GET_SEPA_ACCOUNTS: ('HKSPA',)>: True,
                                        <FinTSOperations.GET_SCHEDULED_DEBITS_SINGLE: ('HKDBS',)>: False,
                                        <FinTSOperations.GET_SCHEDULED_DEBITS_MULTIPLE: ('HKDMB',)>: False,
                                        <FinTSOperations.GET_STATUS_PROTOCOL: ('HKPRO',)>: False,
                                        <FinTSOperations.SEPA_TRANSFER_SINGLE: ('HKCCS',)>: False,
                                        <FinTSOperations.SEPA_TRANSFER_MULTIPLE: ('HKCCM',)>: False,
                                        <FinTSOperations.SEPA_DEBIT_SINGLE: ('HKDSE',)>: False,
                                        <FinTSOperations.SEPA_DEBIT_MULTIPLE: ('HKDME',)>: False,
                                        <FinTSOperations.SEPA_DEBIT_SINGLE_COR1: ('HKDSC',)>: False,
                                        <FinTSOperations.SEPA_DEBIT_MULTIPLE_COR1: ('HKDMC',)>: False,
                                        <FinTSOperations.SEPA_STANDING_DEBIT_SINGLE_CREATE: ('HKDDE',)>: False,
                                        <FinTSOperations.GET_SEPA_STANDING_DEBITS_SINGLE: ('HKDDB',)>: False,
                                        <FinTSOperations.SEPA_STANDING_DEBIT_SINGLE_DELETE: ('HKDDL',)>: False,
                                        <FinTSOperations.GET_TRANSACTIONS: ('HKKAZ',)>: False,
                                        <FinTSOperations.GET_BALANCE: ('HKSAL',)>: False},
               'type': None}],
 'auth': {XXX},
 'bank': {'name': 'comdirect bank',
          'supported_operations': {<FinTSOperations.GET_TRANSACTIONS_XML: ('HKCAZ',)>: False,
                                   <FinTSOperations.GET_CREDIT_CARD_TRANSACTIONS: ('DKKKU',)>: True,
                                   <FinTSOperations.GET_STATEMENT: ('HKEKA',)>: False,
                                   <FinTSOperations.GET_STATEMENT_PDF: ('HKEKP',)>: False,
                                   <FinTSOperations.GET_HOLDINGS: ('HKWPD',)>: True,
                                   <FinTSOperations.GET_SEPA_ACCOUNTS: ('HKSPA',)>: True,
                                   <FinTSOperations.GET_SCHEDULED_DEBITS_SINGLE: ('HKDBS',)>: False,
                                   <FinTSOperations.GET_SCHEDULED_DEBITS_MULTIPLE: ('HKDMB',)>: False,
                                   <FinTSOperations.GET_STATUS_PROTOCOL: ('HKPRO',)>: False,
                                   <FinTSOperations.SEPA_TRANSFER_SINGLE: ('HKCCS',)>: True,
                                   <FinTSOperations.SEPA_TRANSFER_MULTIPLE: ('HKCCM',)>: True,
                                   <FinTSOperations.SEPA_DEBIT_SINGLE: ('HKDSE',)>: False,
                                   <FinTSOperations.SEPA_DEBIT_MULTIPLE: ('HKDME',)>: False,
                                   <FinTSOperations.SEPA_DEBIT_SINGLE_COR1: ('HKDSC',)>: False,
                                   <FinTSOperations.SEPA_DEBIT_MULTIPLE_COR1: ('HKDMC',)>: False,
                                   <FinTSOperations.SEPA_STANDING_DEBIT_SINGLE_CREATE: ('HKDDE',)>: False,
                                   <FinTSOperations.GET_SEPA_STANDING_DEBITS_SINGLE: ('HKDDB',)>: False,
                                   <FinTSOperations.SEPA_STANDING_DEBIT_SINGLE_DELETE: ('HKDDL',)>: False,
                                   <FinTSOperations.GET_TRANSACTIONS: ('HKKAZ',)>: True,
                                   <FinTSOperations.GET_BALANCE: ('HKSAL',)>: True},
          'supported_sepa_formats': ['urn:iso:std:iso:20022:tech:xsd:pain.001.003.03',
                                     'urn:iso:std:iso:20022:tech:xsd:pain.001.003.03.xsd']}}

The third account is the credit card account. Notably, it does not have an IBAN and the account number is also markedly different from the other accounts (it is much longer and seemingly doesn't follow the same numbering scheme the other accounts do).

How can I use f.get_credit_card_transactions() if I don't have the account object? Can I try creating the account object manually somehow?

runiq commented 5 years ago

I can get transactions if I just use one of the other accounts in the f.get_sepa_accounts() list and provide the credit card number. Closing!

henryk commented 5 years ago

@runiq Can you reconfirm that you can get valid credit card transactions with get_credit_card_transactions()? Because I don't have a bank/card combo that supports that, so I just guessed when writing the function.

runiq commented 5 years ago

Yeah, the return value looks a little iffy:

[fints.segments.statement.DIKKU2(
  header=fints.formals.SegmentHeader('DIKKU', 5, 2, 3),
  _additional_data=[
    'XXX',
    None,
    ['C', '123,45', 'EUR', '20190609', '184152'],
    None,
    None,
    ['XXX', '20190529', '20190531', None, '16,1', 'EUR', 'D', '1,', '16,1', 'EUR', 'D', ' VENDOR STRING BLABLA', None, None, None, None, None, None, None, None, 'J', '119060195450101'],
    ['XXX', '20190515', '20190516', None, '12,75', 'EUR', 'D', '1,', '12,75', 'EUR', 'D', ' VENDOR STRING BLABLA', None, None, None, None, None, None, None, None, 'J', '119051647256401'],
    (…the list goes on…)
    ['XXX', '20170402', '20170403', None, '8,6', 'EUR', 'D', '1,', '8,6', 'EUR', 'D', ' VENDOR STRING BLABLA', None, None, None, None, None, None, None, None, 'J', '117040382318501'],
    ['XXX', '20170312', '20170313', None, '8,6', 'EUR', 'D', '1,', '8,6', 'EUR', 'D', ' VENDOR STRING BLABLA', None, None, None, None, None, None, None, None, 'J', '117031373950101']
  ]
)]

Some notes and observations:

I'd be glad to help you improve this function. Can you give me some pointers as to what you'd expect the output to look like?

henryk commented 5 years ago

I now remembered that I do have a test account and credit card with comdirect, just hadn't realized they implement DKKKU2. I'm tracking my work at https://github.com/henryk/python-fints/tree/implement-dikku2

henryk commented 5 years ago

(Note: The correct way to get the list of accounts and available operations is get_information(), we should document that. get_sepa_accounts() was a protocol level kludge for the SEPA change-over, and is now mostly mis-used to get an account inventory, but, as seen here, may have exceptions. The account list in get_information() should always be accurate and definitive.)

Ulli2k commented 5 years ago

I have the same issue. I am able to get the transactions of my bank accounts but I do not get it runnnig for my credit card account. I get the credit card information by get_information. But I do not know how to get the balance, transactions without an "sepa_account object"

Could you give me a hint?

cewee commented 5 years ago

I have the same problem as @Ulli2k , looking into the model it seems, that everywhere 'SEPAAccounts' are expected and the representation retrieved by e.g. : accounts = client.get_information()['accounts']

cannot be used to get transactions. I have to create the object manually as:

sepaAc = models.SEPAAccount(iban=account'iban'], bic='xxx', accountnumber=account['account_number'], subaccount=account['subaccount_number'], blz='xx') which works for Girokonto but again not for the credit card account.

neustifter commented 3 years ago

I have the very same problem. get_credit_card_transactions throws an exception that the operation is not supported.