Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Refactoring (#2897)

Thomas Kaul6167f105fe07
diff --git a/apps/api/src/app/portfolio/portfolio-calculator.ts b/apps/api/src/app/portfolio/portfolio-calculator.ts
index 8168e2bc2f..c072963d2f 100644
--- a/apps/api/src/app/portfolio/portfolio-calculator.ts
+++ b/apps/api/src/app/portfolio/portfolio-calculator.ts
@@ -79,7 +79,9 @@ export class PortfolioCalculator {
this.exchangeRateDataService = exchangeRateDataService;
this.orders = orders;
- this.orders.sort((a, b) => a.date?.localeCompare(b.date));
+ this.orders.sort((a, b) => {
+ return a.date?.localeCompare(b.date);
+ });
}
public computeTransactionPoints() {
@@ -150,7 +152,9 @@ export class PortfolioCalculator {
(transactionPointItem) => transactionPointItem.symbol !== order.symbol
);
newItems.push(currentTransactionPointItem);
- newItems.sort((a, b) => a.symbol?.localeCompare(b.symbol));
+ newItems.sort((a, b) => {
+ return a.symbol?.localeCompare(b.symbol);
+ });
if (lastDate !== currentDate || lastTransactionPoint === null) {
lastTransactionPoint = {
date: currentDate,
@@ -767,8 +771,8 @@ export class PortfolioCalculator {
}
}
- return sortBy(investments, (investment) => {
- return investment.date;
+ return sortBy(investments, ({ date }) => {
+ return date;
});
}
diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.ts
index bbd81a5012..359ec00797 100644
--- a/apps/api/src/app/portfolio/portfolio.service.ts
+++ b/apps/api/src/app/portfolio/portfolio.service.ts
@@ -349,8 +349,8 @@ export class PortfolioService {
}
}
- investments = sortBy(investments, (investment) => {
- return investment.date;
+ investments = sortBy(investments, ({ date }) => {
+ return date;
});
const startDate = this.getStartDate(
@@ -765,9 +765,9 @@ export class PortfolioService {
const currentPositions =
await portfolioCalculator.getCurrentPositions(portfolioStart);
- const position = currentPositions.positions.find(
- (item) => item.symbol === aSymbol
- );
+ const position = currentPositions.positions.find(({ symbol }) => {
+ return symbol === aSymbol;
+ });
if (position) {
const {
@@ -2146,9 +2146,9 @@ export class PortfolioService {
}
);
- historicalDataItems.sort(
- (a, b) => new Date(a.date).getTime() - new Date(b.date).getTime()
- );
+ historicalDataItems.sort((a, b) => {
+ return new Date(a.date).getTime() - new Date(b.date).getTime();
+ });
return historicalDataItems;
}