[hsbc] when adding support for `coming` transactions, account balance is incorrect (it includes `coming` transactions) - request for comments
Short version: hsbc (the website) shows an account balance that include the sum of the coming transactions (i.e. : available balance). I'd like to split it in two : balance
(ledger balance) and coming
(available balance - ledger balance).
Long version:
For the moment, woob
does not distinguish between coming
and non-coming
transactions in hsbc
module.
I would like to add support for those coming
transactions.
Why ? I'm trying to split apart the coming
transactions and the non-coming
ones, because a coming
transaction lacks details about the transaction itself (label only showing the transaction internal id, transaction type).
It's only after a transaction has been accounted for in hsbc that it gets its full label details.
e.g.:
- today is 2023-01-01, if have a transaction whose date is
2023-01-02
and label is only :VR SEPA EMIS XXX0XXX
- next day is 2023-01-02, the transaction date is unchanged, but the label is now :
VIREMENT SEPA EMIS YCO0 12345 COMMENT REFERENCE LABEL PAYEE
Having a transaction that 'changes' from one day to the next one is difficult to work with - I have no way to reconcile those apart from date + amount, which is not enough - and so I want to completely get rid of those coming
transactions.
Which looks quite easy, indeed, a raw patch looks like:
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
modified: modules/hsbc/browser.py
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
@ modules/hsbc/browser.py:662 @ def match_card(tr):
return history
elif self.life_insurance_useless.is_here():
return []
- elif not coming:
- return self._get_history()
else:
- raise NotImplementedError()
-
- def _get_history(self):
- for tr in self.page.get_history():
- yield tr
+ for tr in self.page.get_history():
+ if (tr._coming == coming):
+ yield tr
def get_investments(self, account, retry_li=True):
if not account.url:
With this, iter_history
only returns accounted for transactions, and iter_coming
only returns coming
transactions.
So far, so good.
But the issue now is that the account balance is incorrect. Indeed, the account balance (as retrieved from the hsbc web site) includes the coming
transactions.
I'd like to fix this, and was wondering what the best way was.
AFAIK the only "part" of the website that computes the value for us are the ofx
, txt
or csv
data export which do show the correct balance (ledger balancer).
So that could be one possibility (albeit looks slow and complex).
Another approach would be, in the account retrieval, to open the history page, identify the coming
transactions, compute the coming
balance and substract it from the available
balance.
What would be your recommended way ?
Notes: My hsbc account is a new_space
one.