Browse Source

Merge b5c299ad92 into 0ea66aebcb

pull/1963/merge
Eran Raskansky 2 years ago
committed by GitHub
parent
commit
f38fda2f59
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      apps/api/src/app/order/order.service.ts
  2. 5
      apps/api/src/app/portfolio/portfolio-calculator.ts
  3. 10
      apps/api/src/app/portfolio/portfolio.service.ts
  4. 1
      apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.html
  5. 9
      libs/ui/src/lib/activities-table/activities-table.component.html
  6. 4
      libs/ui/src/lib/activities-table/activities-table.component.scss
  7. 2
      prisma/migrations/20230511210534_added_drip_type/migration.sql
  8. 1
      prisma/schema.prisma

2
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();
}

5
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

10
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) {

1
apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.html

@ -15,6 +15,7 @@
<mat-option i18n value="DIVIDEND">Dividend</mat-option>
<mat-option i18n value="ITEM">Item</mat-option>
<mat-option i18n value="SELL">Sell</mat-option>
<mat-option i18n value="DRIP">DRIP</mat-option>
</mat-select>
</mat-form-field>
</div>

9
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'
}"
>
<ion-icon
*ngIf="element.type === 'BUY' || element.type === 'DIVIDEND'"
*ngIf="
element.type === 'BUY' ||
element.type === 'DIVIDEND' ||
element.type === 'DRIP'
"
name="arrow-up-circle-outline"
></ion-icon>
<ion-icon

4
libs/ui/src/lib/activities-table/activities-table.component.scss

@ -40,6 +40,10 @@
&.sell {
color: var(--orange);
}
&.drip {
color: var(--cyan);
}
}
}
}

2
prisma/migrations/20230511210534_added_drip_type/migration.sql

@ -0,0 +1,2 @@
-- AlterEnum
ALTER TYPE "Type" ADD VALUE 'DRIP';

1
prisma/schema.prisma

@ -238,6 +238,7 @@ enum Type {
DIVIDEND
ITEM
SELL
DRIP
}
enum ViewMode {

Loading…
Cancel
Save