MadeInPierre / finalynx

A minimalistic companion (CLI & web) to organize your investment portfolio, simulate its future, and reach your life goals.
https://finalynx.readthedocs.io
GNU General Public License v3.0
68 stars 13 forks source link

Error fetching "Credits accounts" #84

Closed nmathey closed 1 year ago

nmathey commented 1 year ago

Erreur à mon avis liée au merge attendu (cf Todo) de l'API Finary (issue#68)

╭───────────────────── Traceback (most recent call last) ──────────────────────╮
│                                                                              │
│ /Users/nicolas/Documents/finalynx/assistant_config.py:162 in <module>  │
│                                                                              │
│   159 │   │   hide_amounts=False,  # Display your portfolio with dots instea │
│   160 │   │   hide_root=False,  # Display your portfolio without the root (c │
│   161 │   │   show_data=True,  # Show what has been fetched online (e.g. fro │
│ ❱ 162 │   ).run()  # noqa                                                    │
│   163                                                                        │
│ /Users/nicolas/Documents/finalynx/finalynx/assistant.py:143 in run     │
│                                                                              │
│   140 │   │   """                                                            │
│   141 │   │                                                                  │
│   142 │   │   # Fill tree with current valuations fetched from Finary        │
│ ❱ 143 │   │   finary_tree = FetchFinary(self.portfolio, self.clear_cache, se │
│   144 │   │                                                                  │
│   145 │   │   # Mandatory step after fetching to process some targets and bu │
│   146 │   │   self.portfolio.process()                                       │
│                                                                              │
│ /Users/nicolas/Documents/finalynx/finalynx/fetch/fetch_finary.py:102   │
│ in fetch                                                                     │
│                                                                              │
│    99 │   │   │   if not session:                                            │
│   100 │   │   │   │   return Tree("Finary signin failed.")                   │
│   101 │   │   │                                                              │
│ ❱ 102 │   │   │   fetched_lines = self._fetch_data(session, tree)            │
│   103 │   │   │                                                              │
│   104 │   │   │   '''try:                                                    │
│   105 │   │   │   │   fetched_lines = self._fetch_data(session, tree)        │
│                                                                              │
│ /Users/nicolas/Documents/finalynx/finalynx/fetch/fetch_finary.py:374   │
│ in _fetch_data                                                               │
│                                                                              │
│   371 │   │   │   │   tree_node=node,                                        │
│   372 │   │   │   │   name=e["name"],                                        │
│   373 │   │   │   │   id=e["id"],                                            │
│ ❱ 374 │   │   │   │   account=e["account"]["name"],                          │
│   375 │   │   │   │   amount=-e["display_balance"],                          │
│   376 │   │   │   │   currency=e["display_currency"]["symbol"],              │
│   377 │   │   │   )                                                          │
╰──────────────────────────────────────────────────────────────────────────────╯
KeyError: 'account'

J'ai tenté mais j'ai perdu :D

 # Credit accounts # TODO: when https://github.com/lasconic/finary/pull/68 is merged, use get_credit_accounts
        node = start_step("Credit accounts", tree)
        #credits = session.get(f"{finary_api.constants.API_ROOT}/users/me/views/credit_accounts").json()["result"]
        for e in ff.get_credit_accounts(session)["result"]["data"]:
            self._register_fetchline(
                fetched_lines=fetched_lines,
                tree_node=node,
                name=e["name"],
                id=e["id"],
                account=e["account"]["name"],
                amount=-e["display_balance"],
                currency=e["display_currency"]["symbol"],
            )
nmathey commented 1 year ago

Je n'étais pas loin :)

account=e["account"]["name"] ==> account=e["name"]