Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍
TypeScript angularetffinancefintechghostfoliohacktoberfestinvestingnestjsosspersonal-financeportfolioprismasoftwarestocktrackertradingtypescriptwealth-managementweb
Feature/skip errors for custom asset profiles in portfolio snapshot calculation (#5175)
Thomas Kaule3546a53a5ce
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 409b667fe7..5f5ad94708 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0- Improved the label for asset profiles with `MANUAL` data source in the chart of the asset profile details dialog in the admin control panel- Improved the label for asset profiles with `MANUAL` data source in the chart of the holding detail dialog+- Skipped errors for the custom asset profiles in the portfolio snapshot calculation- Removed the date range query parameter from the search for the holdings in the assistant- Improved the language localization for Chinese (`zh`)- Improved the language localization for Dutch (`nl`)diff --git a/apps/api/src/app/portfolio/calculator/portfolio-calculator.ts b/apps/api/src/app/portfolio/calculator/portfolio-calculator.tsindex ac7e020273..185c1cd806 100644--- a/apps/api/src/app/portfolio/calculator/portfolio-calculator.ts+++ b/apps/api/src/app/portfolio/calculator/portfolio-calculator.ts@@ -446,7 +446,8 @@ export abstract class PortfolioCalculator {currentRateErrors.find(({ dataSource, symbol }) => {return dataSource === item.dataSource && symbol === item.symbol;})) &&- item.investment.gt(0)+ item.investment.gt(0) &&+ item.skipErrors === false) {errors.push({ dataSource: item.dataSource, symbol: item.symbol });}@@ -896,9 +897,14 @@ export abstract class PortfolioCalculator {unitPrice} of this.activities) {let currentTransactionPointItem: TransactionPointSymbol;- const oldAccumulatedSymbol = symbols[SymbolProfile.symbol];+ const currency = SymbolProfile.currency;+ const dataSource = SymbolProfile.dataSource;const factor = getFactor(type);+ const skipErrors = !!SymbolProfile.userId; // Skip errors for custom asset profiles+ const symbol = SymbolProfile.symbol;++ const oldAccumulatedSymbol = symbols[symbol];if (oldAccumulatedSymbol) {let investment = oldAccumulatedSymbol.investment;@@ -918,32 +924,34 @@ export abstract class PortfolioCalculator {}currentTransactionPointItem = {+ currency,+ dataSource,investment,+ skipErrors,+ symbol,averagePrice: newQuantity.gt(0)? investment.div(newQuantity): new Big(0),- currency: SymbolProfile.currency,- dataSource: SymbolProfile.dataSource,dividend: new Big(0),fee: oldAccumulatedSymbol.fee.plus(fee),firstBuyDate: oldAccumulatedSymbol.firstBuyDate,quantity: newQuantity,- symbol: SymbolProfile.symbol,tags: oldAccumulatedSymbol.tags.concat(tags),transactionCount: oldAccumulatedSymbol.transactionCount + 1};} else {currentTransactionPointItem = {+ currency,+ dataSource,fee,+ skipErrors,+ symbol,tags,averagePrice: unitPrice,- currency: SymbolProfile.currency,- dataSource: SymbolProfile.dataSource,dividend: new Big(0),firstBuyDate: date,investment: unitPrice.mul(quantity).mul(factor),quantity: quantity.mul(factor),- symbol: SymbolProfile.symbol,transactionCount: 1};}diff --git a/apps/api/src/app/portfolio/interfaces/portfolio-order.interface.ts b/apps/api/src/app/portfolio/interfaces/portfolio-order.interface.tsindex 63a936c32d..1c53430f65 100644--- a/apps/api/src/app/portfolio/interfaces/portfolio-order.interface.ts+++ b/apps/api/src/app/portfolio/interfaces/portfolio-order.interface.ts@@ -6,7 +6,7 @@ export interface PortfolioOrder extends Pick<Activity, 'tags' | 'type'> {quantity: Big;SymbolProfile: Pick<Activity['SymbolProfile'],- 'currency' | 'dataSource' | 'name' | 'symbol'+ 'currency' | 'dataSource' | 'name' | 'symbol' | 'userId'>;unitPrice: Big;}diff --git a/apps/api/src/app/portfolio/interfaces/transaction-point-symbol.interface.ts b/apps/api/src/app/portfolio/interfaces/transaction-point-symbol.interface.tsindex d15d02d3ae..0d648322f4 100644--- a/apps/api/src/app/portfolio/interfaces/transaction-point-symbol.interface.ts+++ b/apps/api/src/app/portfolio/interfaces/transaction-point-symbol.interface.ts@@ -10,6 +10,7 @@ export interface TransactionPointSymbol {firstBuyDate: string;investment: Big;quantity: Big;+ skipErrors: boolean;symbol: string;tags?: Tag[];transactionCount: number;