File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ( ) ;
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments