@@ -36,6 +36,8 @@ const isEmpty = computed(() => !totalIncome.value || !totalExpenses.value);
3636
3737const 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 >
0 commit comments