File tree Expand file tree Collapse file tree
components/financial-impact-card Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ export class FinancialImpactCardComponent implements OnInit {
6767 if ( this . usageCosts && this . usageCosts . length > 0 ) {
6868 this . costs . set ( this . usageCosts ) ;
6969 } else {
70- this . costService . list ( ) . then ( ( costs ) => {
70+ this . costService . listActive ( ) . then ( ( costs ) => {
7171 this . costs . set ( costs as CostDto [ ] ) ;
7272 this . calculateAll ( ) ;
7373 } ) ;
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ export class FinancialImpactComponent implements OnInit {
4343 ngOnInit ( ) {
4444 // Fetch all costs from the cost table
4545 this . costService . listActive ( ) . then ( ( costs ) => {
46+ console . log ( "Costs fetched:" , costs ) ;
4647 this . costs . set ( costs ) ;
4748 this . updateSpendingTrendChart ( costs as CostDto [ ] ) ;
4849 } ) ;
Original file line number Diff line number Diff line change @@ -17,6 +17,10 @@ type Costs = CostDto | CostAddDto;
1717 providedIn : 'root'
1818} )
1919export class CostService extends ServiceAbstract < Costs > {
20+ protected override dbService = inject ( DbService ) ;
21+ protected override dataUpdatedService = inject ( DataUpdatedService ) ;
22+ private substanceService = inject ( SubstanceService ) ;
23+
2024 protected override storeName = 'cost' as const ;
2125
2226 /**
@@ -38,11 +42,10 @@ export class CostService extends ServiceAbstract<Costs> {
3842 ] ) ;
3943
4044 const activeSubstanceIds = activeSubstances . map ( substance => substance . id ) ;
41- console . log ( "activeSubstanceIds" , activeSubstanceIds ) ;
42- console . log ( "allCosts" , allCosts ) ;
43- return ( allCosts as CostDto [ ] ) . filter ( cost =>
45+ const _return = ( allCosts as CostDto [ ] ) . filter ( cost =>
4446 activeSubstanceIds . includes ( cost . substance )
4547 ) ;
48+ return _return ;
4649 }
4750
4851 /**
@@ -65,7 +68,8 @@ export class CostService extends ServiceAbstract<Costs> {
6568 * Returns the total spent across all costs.
6669 */
6770 getTotalSpent ( ) {
68- return this . table . toArray ( ) . then ( data => {
71+ //return this.table.toArray().then(data => {
72+ return this . listActive ( ) . then ( data => {
6973 return data . reduce ( ( acc , item ) => {
7074 return acc + item . value ;
7175 } , 0 ) ;
You can’t perform that action at this time.
0 commit comments