@ -462,10 +462,17 @@ export class PortfolioService {
} ) ;
} ) ;
const holdings : PortfolioDetails [ 'holdings' ] = { } ;
const holdings : PortfolioDetails [ 'holdings' ] = { } ;
const totalInvestment InBaseCurrency = currentPositions . totalInvestment . plus (
const totalValue InBaseCurrency = currentPositions . currentValue . plus (
cashDetails . balanceInBaseCurrency
cashDetails . balanceInBaseCurrency
) ;
) ;
let filteredValueInBaseCurrency = currentPositions . currentValue ;
const isFilteredByAccount = filters . some ( ( filter ) = > {
return filter . type === 'ACCOUNT' ;
} ) ;
let filteredValueInBaseCurrency = isFilteredByAccount
? totalValueInBaseCurrency
: currentPositions . currentValue ;
if (
if (
filters ? . length === 0 ||
filters ? . length === 0 ||
@ -564,12 +571,11 @@ export class PortfolioService {
} ;
} ;
}
}
if (
const isFilteredByCash = filters . some ( ( filter ) = > {
filters ? . length === 0 ||
return filter . type === 'ASSET_CLASS' && filter . id === 'CASH' ;
( filters ? . length === 1 &&
} ) ;
filters [ 0 ] . type === 'ASSET_CLASS' &&
filters [ 0 ] . id === 'CASH' )
if ( filters . length === 0 || isFilteredByCash || isFilteredByAccount ) {
) {
const cashPositions = await this . getCashPositions ( {
const cashPositions = await this . getCashPositions ( {
cashDetails ,
cashDetails ,
userCurrency ,
userCurrency ,
@ -595,7 +601,7 @@ export class PortfolioService {
filters [ 0 ] . id === EMERGENCY_FUND_TAG_ID &&
filters [ 0 ] . id === EMERGENCY_FUND_TAG_ID &&
filters [ 0 ] . type === 'TAG'
filters [ 0 ] . type === 'TAG'
) {
) {
const cashPositions = await this . getCashPositions ( {
const emergen cyFundC ashPositions = await this . getCashPositions ( {
cashDetails ,
cashDetails ,
userCurrency ,
userCurrency ,
value : filteredValueInBaseCurrency
value : filteredValueInBaseCurrency
@ -620,7 +626,7 @@ export class PortfolioService {
} ;
} ;
holdings [ userCurrency ] = {
holdings [ userCurrency ] = {
. . . cashPositions [ userCurrency ] ,
. . . emergen cyFundC ashPositions[ userCurrency ] ,
investment : emergencyFundInCash ,
investment : emergencyFundInCash ,
value : emergencyFundInCash
value : emergencyFundInCash
} ;
} ;