File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -817,10 +817,16 @@ export default class FinanceServices {
817817 }
818818 } ) ;
819819
820- const allTotalBudget = teams . reduce ( ( teamAcc , team ) => {
821- const teamBudget = team . projects . reduce ( ( projAcc , project ) => projAcc + project . budget , 0 ) ;
822- return teamAcc + teamBudget ;
823- } , 0 ) ;
820+ // project budgets no longer double counted if in multiple teams
821+ const projectsById = new Map < string , { budget : number } > ( ) ;
822+ for ( const team of teams ) {
823+ for ( const project of team . projects ) {
824+ if ( ! projectsById . has ( project . projectId ) ) {
825+ projectsById . set ( project . projectId , { budget : project . budget } ) ;
826+ }
827+ }
828+ }
829+ const allTotalBudget = [ ...projectsById . values ( ) ] . reduce ( ( acc , p ) => acc + p . budget , 0 ) ;
824830
825831 const cashTotalBudget =
826832 cashReimbursementRequests . reduce ( ( reqAcc , rr ) => {
You can’t perform that action at this time.
0 commit comments