|
|
@ -86,14 +86,13 @@ import { |
|
|
|
parseISO, |
|
|
|
set |
|
|
|
} from 'date-fns'; |
|
|
|
import Fuse from 'fuse.js'; |
|
|
|
import { isEmpty } from 'lodash'; |
|
|
|
|
|
|
|
import { PortfolioCalculator } from './calculator/portfolio-calculator'; |
|
|
|
import { PortfolioCalculatorFactory } from './calculator/portfolio-calculator.factory'; |
|
|
|
import { RulesService } from './rules.service'; |
|
|
|
|
|
|
|
const Fuse = require('fuse.js'); |
|
|
|
|
|
|
|
const asiaPacificMarkets = require('../../assets/countries/asia-pacific-markets.json'); |
|
|
|
const developedMarkets = require('../../assets/countries/developed-markets.json'); |
|
|
|
const emergingMarkets = require('../../assets/countries/emerging-markets.json'); |
|
|
@ -213,18 +212,32 @@ export class PortfolioService { |
|
|
|
|
|
|
|
public async getAccountsWithAggregations({ |
|
|
|
filters, |
|
|
|
query, |
|
|
|
userId, |
|
|
|
withExcludedAccounts = false |
|
|
|
}: { |
|
|
|
filters?: Filter[]; |
|
|
|
query?: string; |
|
|
|
userId: string; |
|
|
|
withExcludedAccounts?: boolean; |
|
|
|
}): Promise<AccountsResponse> { |
|
|
|
const accounts = await this.getAccounts({ |
|
|
|
let accounts = await this.getAccounts({ |
|
|
|
filters, |
|
|
|
userId, |
|
|
|
withExcludedAccounts |
|
|
|
}); |
|
|
|
|
|
|
|
if (query) { |
|
|
|
const fuse = new Fuse(accounts, { |
|
|
|
keys: ['name', 'platform.name'], |
|
|
|
threshold: 0.3 |
|
|
|
}); |
|
|
|
|
|
|
|
accounts = fuse.search(query).map(({ item }) => { |
|
|
|
return item; |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
let totalBalanceInBaseCurrency = new Big(0); |
|
|
|
let totalValueInBaseCurrency = new Big(0); |
|
|
|
let transactionCount = 0; |
|
|
|