Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use comodity name string if metadata is not defined #64

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/fava_portfolio_returns/api/portfolio.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def portfolio_allocation(
):
market_values: dict[tuple, Decimal] = defaultdict(Decimal)
for account in account_data_list:
commodity = account.commodity.meta["name"]
commodity = account.commodity.meta.get("name", account.commodity.currency)
currency = account.currency
market_value = get_market_value_of_inventory(pricer, target_currency, account.balance, end_date)
market_values[(currency, commodity)] += market_value
Expand Down
4 changes: 3 additions & 1 deletion src/fava_portfolio_returns/core/portfolio.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ def group_investments(config, account_data_map: dict[str, AccountData]):
for account in account_data_map.values():
if account.currency not in currencies:
currencies[account.currency] = InvestmentCurrency(
id=f"c:{account.currency}", currency=account.currency, name=account.commodity.meta["name"]
id=f"c:{account.currency}",
currency=account.currency,
name=account.commodity.meta.get("name", account.commodity.currency),
)
currencies_list = sorted(currencies.values(), key=lambda x: x.id)

Expand Down