Skip to content

Commit 9210b25

Browse files
committed
Display sums on index assets card
1 parent 1db956f commit 9210b25

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/pages/net_worth_pages.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,18 @@ void budget::assets_card(budget::html_writer& w) {
4848

4949
if (group_style) {
5050
std::vector<std::string> groups;
51+
std::unordered_map<std::string, budget::money> group_sums;
5152

5253
for (const auto& [asset, amount] : w.cache.user_assets() | expand_value(w.cache) | not_zero) {
5354
std::string group = asset.name.substr(0, asset.name.find(separator));
5455

5556
if (!std::ranges::contains(groups, group)) {
5657
groups.emplace_back(std::move(group));
5758
}
59+
60+
if (amount) {
61+
group_sums[group] += amount * exchange_rate(asset.currency, budget::local_day());
62+
}
5863
}
5964

6065
for (const auto& group : groups) {
@@ -66,7 +71,7 @@ void budget::assets_card(budget::html_writer& w) {
6671

6772
if (!started) {
6873
w << "<div class=\"asset_group\">";
69-
w << group;
74+
w << group << " (" << group_sums[group] << " " << get_default_currency() << ")";
7075
w << "</div>";
7176

7277
started = true;

0 commit comments

Comments
 (0)