diff --git a/apps/api/src/app/portfolio/portfolio-calculator.ts b/apps/api/src/app/portfolio/portfolio-calculator.ts index f71597e14..d8d772dcf 100644 --- a/apps/api/src/app/portfolio/portfolio-calculator.ts +++ b/apps/api/src/app/portfolio/portfolio-calculator.ts @@ -92,7 +92,7 @@ export class PortfolioCalculator { let investment = new Big(0); if (newQuantity.gt(0)) { - if (order.type === 'BUY') { + if (order.type === 'BUY' || order.type === 'DRIP') { investment = oldAccumulatedSymbol.investment.plus( order.quantity.mul(unitPrice) ); @@ -901,6 +901,7 @@ export class PortfolioCalculator { switch (type) { case 'BUY': + case 'DRIP': factor = 1; break; case 'SELL': @@ -1126,7 +1127,7 @@ export class PortfolioCalculator { } const transactionInvestment = - order.type === 'BUY' + order.type === 'BUY' || order.type === 'DRIP' ? order.quantity.mul(order.unitPrice).mul(this.getFactor(order.type)) : totalUnits.gt(0) ? totalInvestment diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.ts index 7755146f1..cba905b41 100644 --- a/apps/api/src/app/portfolio/portfolio.service.ts +++ b/apps/api/src/app/portfolio/portfolio.service.ts @@ -223,7 +223,7 @@ export class PortfolioService { const activities = await this.orderService.getOrders({ filters, userId, - types: ['DIVIDEND'], + types: ['DIVIDEND', 'DRIP'], userCurrency: this.request.user.Settings.settings.baseCurrency }); @@ -710,7 +710,9 @@ export class PortfolioService { .filter((order) => { tags = tags.concat(order.tags); - return order.type === 'BUY' || order.type === 'SELL'; + return ( + order.type === 'BUY' || order.type === 'SELL' || order.type === 'DRIP' + ); }) .map((order) => ({ currency: order.SymbolProfile.currency, @@ -1623,7 +1625,7 @@ export class PortfolioService { committedFunds: committedFunds.toNumber(), emergencyFund: emergencyFund.toNumber(), ordersCount: activities.filter(({ type }) => { - return type === 'BUY' || type === 'SELL'; + return type === 'BUY' || type === 'SELL' || type === 'DRIP'; }).length }; } @@ -1652,7 +1654,7 @@ export class PortfolioService { userCurrency, userId, withExcludedAccounts, - types: ['BUY', 'SELL'] + types: ['BUY', 'SELL', 'DRIP'] }); if (orders.length <= 0) {