Skip to content

Commit 1f54a70

Browse files
committed
feat: consider surplus as deficit if it's negative
update localizations and add missing keys
1 parent bbf103e commit 1f54a70

File tree

13 files changed

+120
-65
lines changed

13 files changed

+120
-65
lines changed

src/app/pages/dashboard/overview/widgets/charts/DistributionChart.vue

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ const isEmpty = computed(() => !totalIncome.value || !totalExpenses.value);
3636
3737
const data = computed((): SankeyChartConfig => {
3838
const format = (v: number) => n(v, 'currency');
39+
40+
const endingBalance = state.overallBalance ?? 0;
3941
const labels: SankeyChartLabel[] = [];
4042
const links: SankeyChartLink[] = [];
4143
@@ -49,8 +51,7 @@ const data = computed((): SankeyChartConfig => {
4951
5052
labels.push(income);
5153
52-
if (settings.general.carryOver && state.overallBalance) {
53-
const endingBalance = state.overallBalance;
54+
if (settings.general.carryOver && endingBalance > 0) {
5455
const carryOverSource = uuid();
5556
const carryOverTarget = uuid();
5657
@@ -170,6 +171,40 @@ const data = computed((): SankeyChartConfig => {
170171
}
171172
}
172173
174+
if (settings.general.carryOver && endingBalance < 0) {
175+
const deficitSource = uuid();
176+
const deficitTarget = uuid();
177+
178+
labels.push({
179+
id: deficitSource,
180+
name: `${t('page.dashboard.lastYear')} (${format(endingBalance)})`,
181+
color: color(60 + 60 * (-endingBalance / totalIncome.value)),
182+
muted: props.highlight === 'income'
183+
});
184+
185+
labels.push({
186+
id: deficitTarget,
187+
name: `${t('page.dashboard.deficit')} (${format(endingBalance)})`,
188+
color: color(60 + 60 * (-endingBalance / totalIncome.value)),
189+
muted: props.highlight === 'income',
190+
align: 'left'
191+
});
192+
193+
links.push({
194+
target: deficitSource,
195+
source: income.id,
196+
value: -endingBalance,
197+
muted: props.highlight === 'income'
198+
});
199+
200+
links.push({
201+
target: deficitTarget,
202+
source: deficitSource,
203+
value: -endingBalance,
204+
muted: props.highlight === 'income'
205+
});
206+
}
207+
173208
return { labels, links };
174209
});
175210
</script>

src/i18n/locales/cze.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@
142142
"jumpToIncome": "Přejít na příjmy za {year}",
143143
"jumpToExpenses": "Přejít na výdaje za {year}",
144144
"lastYear": "Minulý rok",
145-
"surplus": "Přebytek"
145+
"surplus": "Přebytek",
146+
"deficit": "Deficit"
146147
}
147148
}
148149
}

src/i18n/locales/de.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@
142142
"jumpToIncome": "Springe zu den Einnahmen für {year}",
143143
"jumpToExpenses": "Springe zu den Ausgaben für {year}",
144144
"lastYear": "Letztes Jahr",
145-
"surplus": "Überschuss"
145+
"surplus": "Überschuss",
146+
"deficit": "Defizit"
146147
}
147148
}
148149
}

src/i18n/locales/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@
142142
"jumpToIncome": "Jump to income for {year}",
143143
"jumpToExpenses": "Jump to expenses for {year}",
144144
"lastYear": "Last Year",
145-
"surplus": "Surplus"
145+
"surplus": "Surplus",
146+
"deficit": "Deficit"
146147
}
147148
}
148149
}

src/i18n/locales/es.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@
142142
"jumpToIncome": "Ir a ingresos de {year}",
143143
"jumpToExpenses": "Ir a gastos de {year}",
144144
"lastYear": "Año pasado",
145-
"surplus": "Superávit"
145+
"surplus": "Superávit",
146+
"deficit": "Déficit"
146147
}
147148
}
148149
}

src/i18n/locales/fr.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@
142142
"jumpToIncome": "Aller au revenu pour {year}",
143143
"jumpToExpenses": "Aller aux dépenses pour {year}",
144144
"lastYear": "L'année dernière",
145-
"surplus": "Excédent"
145+
"surplus": "Excédent",
146+
"deficit": "Déficit"
146147
}
147148
}
148149
}

src/i18n/locales/hu.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@
142142
"jumpToIncome": "Ugrás a {year} évi bevételekhez",
143143
"jumpToExpenses": "Ugrás a {year} évi kiadásokhoz",
144144
"lastYear": "Múlt év",
145-
"surplus": "Többlet"
145+
"surplus": "Többlet",
146+
"deficit": "Hiány"
146147
}
147148
}
148149
}

src/i18n/locales/id.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@
142142
"jumpToIncome": "Loncat ke pemasukan untuk {year}",
143143
"jumpToExpenses": "Loncat ke pengeluaran untuk {year}",
144144
"lastYear": "Tahun lalu",
145-
"surplus": "Surplus"
145+
"surplus": "Surplus",
146+
"deficit": "Defisit"
146147
}
147148
}
148149
}

src/i18n/locales/it.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@
142142
"jumpToIncome": "Vai al reddito per {year}",
143143
"jumpToExpenses": "Vai alle spese per {year}",
144144
"lastYear": "Anno scorso",
145-
"surplus": "Eccedenza"
145+
"surplus": "Eccedenza",
146+
"deficit": "Deficit"
146147
}
147148
}
148149
}

src/i18n/locales/pl.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@
142142
"jumpToIncome": "Zobacz dochody za {year}",
143143
"jumpToExpenses": "Zobacz wydatki za {year}",
144144
"lastYear": "Ostatni rok",
145-
"surplus": "Nadwyżka"
145+
"surplus": "Nadwyżka",
146+
"deficit": "Deficyt"
146147
}
147148
}
148149
}

0 commit comments

Comments
 (0)