Browse Source

Merge pull request #108 from dandevaud/bugfix/fix-some-bugs

Bugfix/fix some bugs
pull/5027/head
dandevaud 10 months ago
committed by GitHub
parent
commit
dbadb42531
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      apps/api/src/app/admin/admin.service.ts
  2. 7
      apps/api/src/app/portfolio/calculator/twr/portfolio-calculator.ts
  3. 37
      apps/api/src/app/portfolio/portfolio.service.ts
  4. 6
      apps/api/src/app/user/user.controller.ts
  5. 3
      apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts

1
apps/api/src/app/admin/admin.service.ts

@ -419,6 +419,7 @@ export class AdminService {
sectors,
symbol,
symbolMapping,
tags,
...(dataSource === 'MANUAL'
? { assetClass, assetSubClass, name, url }
: {

7
apps/api/src/app/portfolio/calculator/twr/portfolio-calculator.ts

@ -503,6 +503,13 @@ export class TWRPortfolioCalculator extends PortfolioCalculator {
.mul(order.quantity)
.mul(getFactor(order.type));
}
} else if (order.type === 'STAKE') {
transactionInvestment = new Big(0);
transactionInvestmentWithCurrencyEffect = new Big(0);
totalQuantityFromBuyTransactions =
totalQuantityFromBuyTransactions.plus(order.quantity);
}
if (PortfolioCalculator.ENABLE_LOGGING) {

37
apps/api/src/app/portfolio/portfolio.service.ts

@ -1390,8 +1390,37 @@ export class PortfolioService {
userId: string;
}) {
userId = await this.getUserId(impersonationId, userId);
await this.orderService.assignTags({ dataSource, symbol, tags, userId });
let symbolProfile = await this.symbolProfileService.getSymbolProfiles([
{
dataSource,
symbol
}
])[0];
await this.symbolProfileService.updateSymbolProfile({
assetClass: symbolProfile.assetClass,
assetSubClass: symbolProfile.assetSubClass,
countries: symbolProfile.countries,
currency: symbolProfile.currency,
dataSource,
holdings: symbolProfile.holdings,
name: symbolProfile.name,
sectors: symbolProfile.sectors,
symbol,
tags: {
connectOrCreate: tags.map(({ id, name }) => {
return {
create: {
id,
name
},
where: {
id
}
};
})
},
url: symbolProfile.url
});
}
@LogPerformance
@ -1762,7 +1791,9 @@ export class PortfolioService {
.plus(emergencyFundPositionsValueInBaseCurrency)
.toNumber();
const committedFunds = new Big(totalBuy).minus(totalSell);
const committedFunds = new Big(totalBuy)
.minus(totalSell)
.minus(dividendInBaseCurrency);
const totalOfExcludedActivities = this.getSumOfActivityType({
userCurrency,

6
apps/api/src/app/user/user.controller.ts

@ -158,6 +158,12 @@ export class UserController {
}
}
for (const key in data) {
if (data[key] !== false && data[key] !== null) {
userSettings[key] = data[key];
}
}
return this.userService.updateUserSetting({
emitPortfolioChangedEvent,
userSettings,

3
apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts

@ -350,7 +350,7 @@ export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit {
}
}
if (isToday(parseISO(this.firstBuyDate))) {
if (this.firstBuyDate && isToday(parseISO(this.firstBuyDate))) {
// Add average price
this.historicalDataItems.push({
date: this.firstBuyDate,
@ -390,6 +390,7 @@ export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit {
if (
this.benchmarkDataItems[0]?.value === undefined &&
this.firstBuyDate &&
isSameMonth(parseISO(this.firstBuyDate), new Date())
) {
this.benchmarkDataItems[0].value = this.averagePrice;

Loading…
Cancel
Save