diff --git a/apps/api/src/app/admin/admin.service.ts b/apps/api/src/app/admin/admin.service.ts index 348a8d8d3..1ef2abfde 100644 --- a/apps/api/src/app/admin/admin.service.ts +++ b/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 } : { diff --git a/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator.ts b/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator.ts index 4f053355c..18e0c30c8 100644 --- a/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator.ts +++ b/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) { diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.ts index a0a327712..d6f8bae78 100644 --- a/apps/api/src/app/portfolio/portfolio.service.ts +++ b/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, diff --git a/apps/api/src/app/user/user.controller.ts b/apps/api/src/app/user/user.controller.ts index c23870437..6b6b96fce 100644 --- a/apps/api/src/app/user/user.controller.ts +++ b/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, diff --git a/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts b/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts index a0f341cc6..75b7ca2b0 100644 --- a/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts +++ b/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;