Skip to content

Commit 1806da6

Browse files
committed
update
1 parent f4ee046 commit 1806da6

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/app/features/salary/salary.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ export class SalaryComponent implements OnInit {
177177
this.totalExpense = this.totalExpenseFunction();
178178
this.totalIncome = this.filteredTransactions.reduce((acc, t) => acc + (t.amount || 0), 0);
179179
this.totalBudget = this.filteredTransactions.reduce((acc, t) => acc + (t.budget || 0), 0);
180-
this.totalSavings = this.savingsService.getTotalSavings() > 0 ? this.savingsService.getTotalSavings() : 0;
180+
this.totalSavings = this.savingsService.getTotalSavingsFromIncome() > 0 ? this.savingsService.getTotalSavingsFromIncome() : 0;
181181
this.salaryGrowth = this.salaryGrowthFunction(allTransactions);
182182
this.dateMetrics = this.dateMetricsFunction();
183183
this.dailyAllowed = this.dailyAllowedFunction();

src/app/service/localStorage/savings.service.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,10 @@ export class SavingsService {
111111
const all: Saving[] = this.getAll();
112112
return all.reduce((acc, item) => acc + item.amount, 0);
113113
}
114+
115+
getTotalSavingsFromIncome(): number {
116+
if (!this.isBrowser()) return 0;
117+
const all: Saving[] = this.getAll();
118+
return all.filter(item => item.is_from_income).reduce((acc, item) => acc + item.amount, 0);
119+
}
114120
}

0 commit comments

Comments
 (0)