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, sectors,
symbol, symbol,
symbolMapping, symbolMapping,
tags,
...(dataSource === 'MANUAL' ...(dataSource === 'MANUAL'
? { assetClass, assetSubClass, name, url } ? { 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(order.quantity)
.mul(getFactor(order.type)); .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) { if (PortfolioCalculator.ENABLE_LOGGING) {

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

@ -1390,8 +1390,37 @@ export class PortfolioService {
userId: string; userId: string;
}) { }) {
userId = await this.getUserId(impersonationId, userId); userId = await this.getUserId(impersonationId, userId);
let symbolProfile = await this.symbolProfileService.getSymbolProfiles([
await this.orderService.assignTags({ dataSource, symbol, tags, userId }); {
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 @LogPerformance
@ -1762,7 +1791,9 @@ export class PortfolioService {
.plus(emergencyFundPositionsValueInBaseCurrency) .plus(emergencyFundPositionsValueInBaseCurrency)
.toNumber(); .toNumber();
const committedFunds = new Big(totalBuy).minus(totalSell); const committedFunds = new Big(totalBuy)
.minus(totalSell)
.minus(dividendInBaseCurrency);
const totalOfExcludedActivities = this.getSumOfActivityType({ const totalOfExcludedActivities = this.getSumOfActivityType({
userCurrency, 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({ return this.userService.updateUserSetting({
emitPortfolioChangedEvent, emitPortfolioChangedEvent,
userSettings, 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 // Add average price
this.historicalDataItems.push({ this.historicalDataItems.push({
date: this.firstBuyDate, date: this.firstBuyDate,
@ -390,6 +390,7 @@ export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit {
if ( if (
this.benchmarkDataItems[0]?.value === undefined && this.benchmarkDataItems[0]?.value === undefined &&
this.firstBuyDate &&
isSameMonth(parseISO(this.firstBuyDate), new Date()) isSameMonth(parseISO(this.firstBuyDate), new Date())
) { ) {
this.benchmarkDataItems[0].value = this.averagePrice; this.benchmarkDataItems[0].value = this.averagePrice;

Loading…
Cancel
Save