Skip to content

Commit 26fb761

Browse files
[goals] show total investment
1 parent 8fa191e commit 26fb761

File tree

16 files changed

+106
-45
lines changed

16 files changed

+106
-45
lines changed

internal/server/goal/retirement.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ func getRetirementDetail(db *gorm.DB, conf config.RetirementGoal) gin.H {
4949
savingsWithCapitalGains := accounting.FilterByGlob(query.Init(db).Like("Assets:%", "Income:CapitalGains:%").All(), conf.Savings)
5050
savingsWithCapitalGains = service.PopulateMarketPrice(db, savingsWithCapitalGains)
5151
savingsTotal := accounting.CurrentBalance(savings)
52+
investmentTotal := accounting.CostBalance(savings)
53+
gainsTotal := savingsTotal.Sub(investmentTotal)
5254

5355
yearlyExpenses := decimal.NewFromFloat(conf.YearlyExpenses)
5456
if !(yearlyExpenses.GreaterThan(decimal.Zero)) {
@@ -63,6 +65,8 @@ func getRetirementDetail(db *gorm.DB, conf config.RetirementGoal) gin.H {
6365
"icon": conf.Icon,
6466
"savingsTimeline": accounting.RunningBalance(db, savings),
6567
"savingsTotal": savingsTotal,
68+
"investmentTotal": investmentTotal,
69+
"gainTotal": gainsTotal,
6670
"swr": conf.SWR,
6771
"yearlyExpense": yearlyExpenses,
6872
"xirr": service.XIRR(db, savingsWithCapitalGains),

internal/server/goal/savings.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ func getSavingsDetail(db *gorm.DB, conf config.SavingsGoal) gin.H {
3232
savings := accounting.FilterByGlob(query.Init(db).Like("Assets:%").All(), conf.Accounts)
3333
savings = service.PopulateMarketPrice(db, savings)
3434
savingsTotal := accounting.CurrentBalance(savings)
35+
investmentTotal := accounting.CostBalance(savings)
3536

3637
savingsWithCapitalGains := accounting.FilterByGlob(query.Init(db).Like("Assets:%", "Income:CapitalGains:%").All(), conf.Accounts)
3738
savingsWithCapitalGains = service.PopulateMarketPrice(db, savingsWithCapitalGains)
@@ -42,8 +43,10 @@ func getSavingsDetail(db *gorm.DB, conf config.SavingsGoal) gin.H {
4243
"type": "savings",
4344
"name": conf.Name,
4445
"icon": conf.Icon,
45-
"savingsTimeline": accounting.RunningBalance(db, savings),
46+
"investmentTotal": investmentTotal,
4647
"savingsTotal": savingsTotal,
48+
"gainTotal": savingsTotal.Sub(investmentTotal),
49+
"savingsTimeline": accounting.RunningBalance(db, savings),
4750
"target": decimal.NewFromFloat(conf.Target),
4851
"targetDate": conf.TargetDate,
4952
"rate": conf.Rate,

src/app.scss

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,13 @@ svg text {
441441
}
442442

443443
.weekdays-grid {
444-
border-radius: $radius-small;
444+
div:first-child {
445+
border-radius: $radius-small 0 0 $radius-small !important;
446+
}
447+
448+
div:last-child {
449+
border-radius: 0 $radius-small $radius-small 0 !important;
450+
}
445451

446452
div {
447453
padding: 2px 0;
@@ -525,10 +531,13 @@ nav.level.grid-2 {
525531
}
526532

527533
.navbar {
528-
background-color: $white-bis !important;
534+
background-color: $white !important;
529535
color: rgba(0, 0, 0, 0.7);
530-
}
531536

537+
a.navbar-item {
538+
background-color: $white !important;
539+
}
540+
}
532541
.cm-editor {
533542
.cm-gutters {
534543
background-color: $white-ter;
@@ -1044,6 +1053,19 @@ textarea:invalid {
10441053
border-color: $danger;
10451054
}
10461055

1056+
.dropdown-trigger.dropdown-icon {
1057+
button {
1058+
height: 2rem;
1059+
padding: 0;
1060+
border: none;
1061+
background: none;
1062+
}
1063+
1064+
button:hover {
1065+
color: $link;
1066+
}
1067+
}
1068+
10471069
.nested.has-dropdown {
10481070
&:hover > .dropdown-menu {
10491071
display: block;

src/lib/components/Actions.svelte

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,10 @@
55
import { obscure } from "../../persisted_store";
66
import { goto } from "$app/navigation";
77
8-
let isLoading = false;
9-
108
async function syncWithLoader(request: Record<string, any>) {
11-
isLoading = true;
129
try {
1310
await sync(request);
1411
} finally {
15-
isLoading = false;
1612
refresh();
1713
}
1814
}
@@ -33,11 +29,11 @@
3329
let showLogout = isLoggedIn();
3430
</script>
3531

36-
<div class="dropdown {isMobile() ? 'is-left' : 'is-right'}" class:is-hoverable={!isLoading}>
37-
<div class="dropdown-trigger">
38-
<button class:is-loading={isLoading} class="button is-small" aria-haspopup="true">
39-
<span class="icon is-small">
40-
<i class="fas fa-caret-down" />
32+
<div class="dropdown ml-2 is-hoverable {isMobile() ? 'is-left' : 'is-right'}">
33+
<div class="dropdown-trigger dropdown-icon">
34+
<button class="button is-large" aria-haspopup="true">
35+
<span class="icon">
36+
<i class="fas fa-ellipsis-vertical" />
4137
</span>
4238
</button>
4339
</div>

src/lib/components/CreditCardCard.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
href="/liabilities/credit_cards/{encodeURIComponent(creditCard.account)}"
6060
>
6161
<span class="custom-icon">{iconText(creditCard.account)}</span>
62-
<span class="ml-1">{restName(restName(creditCard.account))}</span>
62+
<span>{restName(restName(creditCard.account))}</span>
6363
</a>
6464
</div>
6565
</div>

src/lib/components/GoalSummaryCard.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
{small}
6464
narrow
6565
title="Target"
66-
color={COLORS.secondary}
66+
color={COLORS.primary}
6767
value={formatCurrency(goal.target)}
6868
/>
6969
</nav>

src/lib/components/Navbar.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@
310310
</div>
311311
</nav>
312312

313-
<div class="mt-2 px-3 is-flex is-justify-content-space-between">
313+
<div class="mt-3 px-3 is-flex is-justify-content-space-between">
314314
{#if selectedLink}
315315
<nav
316316
style="margin-left: 0.73rem;"

src/lib/goals.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ export function renderProgress(
180180
const lineScale = d3
181181
.scaleOrdinal<string>()
182182
.domain(lineKeys)
183-
.range([COLORS.gainText, COLORS.secondary]);
183+
.range([COLORS.secondary, COLORS.primary]);
184184

185185
const x = d3.scaleTime().range([0, width]).domain([start, end]),
186186
y = d3
@@ -391,7 +391,7 @@ export function renderInvestmentTimeline(postings: Posting[], element: Element,
391391
if (pmt > 0) {
392392
g.append("line")
393393
.attr("fill", "none")
394-
.attr("stroke", COLORS.secondary)
394+
.attr("stroke", COLORS.primary)
395395
.attr("x1", 0)
396396
.attr("x2", width)
397397
.attr("y1", y(pmt))
@@ -406,7 +406,7 @@ export function renderInvestmentTimeline(postings: Posting[], element: Element,
406406
.attr("dy", "0.3em")
407407
.attr("x", width)
408408
.attr("y", y(pmt))
409-
.attr("fill", COLORS.secondary)
409+
.attr("fill", COLORS.primary)
410410
.text(formatCurrencyCrude(pmt));
411411
}
412412

@@ -415,9 +415,9 @@ export function renderInvestmentTimeline(postings: Posting[], element: Element,
415415
.data(points)
416416
.enter()
417417
.append("rect")
418-
.attr("stroke", (p) => (p.total <= 0 ? COLORS.lossText : COLORS.gainText))
419-
.attr("fill", (p) => (p.total <= 0 ? COLORS.lossText : COLORS.gainText))
420-
.attr("fill-opacity", 0.6)
418+
.attr("stroke", (p) => (p.total <= 0 ? COLORS.tertiary : COLORS.secondary))
419+
.attr("fill", (p) => (p.total <= 0 ? COLORS.tertiary : COLORS.secondary))
420+
.attr("fill-opacity", 0.5)
421421
.attr("data-tippy-content", (p) => {
422422
const group = groupSumBy(p.postings, (p) => p.account);
423423
return tooltip(

src/lib/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,8 @@ export interface AccountBudget {
356356

357357
export interface RetirementGoalProgress {
358358
savingsTotal: number;
359+
investmentTotal: number;
360+
gainTotal: number;
359361
savingsTimeline: Point[];
360362
swr: number;
361363
yearlyExpense: number;
@@ -368,6 +370,8 @@ export interface RetirementGoalProgress {
368370
}
369371

370372
export interface SavingsGoalProgress {
373+
investmentTotal: number;
374+
gainTotal: number;
371375
savingsTotal: number;
372376
savingsTimeline: Point[];
373377
target: number;

src/routes/(app)/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@
228228
<strong>Oops!</strong> You have not made any transactions in the last 3 months.
229229
</ZeroState>
230230

231-
<LegendCard legends={cashflowLegends} clazz="mb-2 overflow-x-scroll" />
231+
<LegendCard legends={cashflowLegends} clazz="mb-2 overflow-x-auto" />
232232

233233
<svg
234234
class:is-not-visible={_.isEmpty(cashFlows)}

0 commit comments

Comments
 (0)