diff --git a/apps/api/src/app/order/order.service.ts b/apps/api/src/app/order/order.service.ts
index 696f5442e..63dd645e1 100644
--- a/apps/api/src/app/order/order.service.ts
+++ b/apps/api/src/app/order/order.service.ts
@@ -178,7 +178,7 @@ export class OrderService {
.plus(data.fee)
.toNumber();
- if (data.type === 'BUY') {
+ if (data.type === 'BUY' || data.type === 'DRIP') {
amount = new Big(amount).mul(-1).toNumber();
}
diff --git a/apps/api/src/app/portfolio/portfolio-calculator.ts b/apps/api/src/app/portfolio/portfolio-calculator.ts
index 9addb29dd..23b386d24 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)
);
@@ -931,6 +931,7 @@ export class PortfolioCalculator {
switch (type) {
case 'BUY':
+ case 'DRIP':
factor = 1;
break;
case 'SELL':
@@ -1156,7 +1157,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 aea522f40..1e52ba0eb 100644
--- a/apps/api/src/app/portfolio/portfolio.service.ts
+++ b/apps/api/src/app/portfolio/portfolio.service.ts
@@ -224,7 +224,7 @@ export class PortfolioService {
const activities = await this.orderService.getOrders({
filters,
userId,
- types: ['DIVIDEND'],
+ types: ['DIVIDEND', 'DRIP'],
userCurrency: this.request.user.Settings.settings.baseCurrency
});
@@ -730,7 +730,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,
@@ -1665,7 +1667,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
};
}
@@ -1694,7 +1696,7 @@ export class PortfolioService {
userCurrency,
userId,
withExcludedAccounts,
- types: ['BUY', 'SELL']
+ types: ['BUY', 'SELL', 'DRIP']
});
if (orders.length <= 0) {
diff --git a/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.html b/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.html
index 33a2f4c73..3df0d7206 100644
--- a/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.html
+++ b/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.html
@@ -15,6 +15,7 @@
Dividend
Item
Sell
+ DRIP
diff --git a/libs/ui/src/lib/activities-table/activities-table.component.html b/libs/ui/src/lib/activities-table/activities-table.component.html
index 5446f780e..955af8f7e 100644
--- a/libs/ui/src/lib/activities-table/activities-table.component.html
+++ b/libs/ui/src/lib/activities-table/activities-table.component.html
@@ -162,11 +162,16 @@
buy: element.type === 'BUY',
dividend: element.type === 'DIVIDEND',
item: element.type === 'ITEM',
- sell: element.type === 'SELL'
+ sell: element.type === 'SELL',
+ drip: element.type === 'DRIP'
}"
>