Refactoring (#2897)

pull/2898/head
Thomas Kaul 10 months ago committed by GitHub
parent 8d5f2fd91d
commit 6167f105fe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -79,7 +79,9 @@ export class PortfolioCalculator {
this.exchangeRateDataService = exchangeRateDataService; this.exchangeRateDataService = exchangeRateDataService;
this.orders = orders; 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() { public computeTransactionPoints() {
@ -150,7 +152,9 @@ export class PortfolioCalculator {
(transactionPointItem) => transactionPointItem.symbol !== order.symbol (transactionPointItem) => transactionPointItem.symbol !== order.symbol
); );
newItems.push(currentTransactionPointItem); 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) { if (lastDate !== currentDate || lastTransactionPoint === null) {
lastTransactionPoint = { lastTransactionPoint = {
date: currentDate, date: currentDate,
@ -767,8 +771,8 @@ export class PortfolioCalculator {
} }
} }
return sortBy(investments, (investment) => { return sortBy(investments, ({ date }) => {
return investment.date; return date;
}); });
} }

@ -349,8 +349,8 @@ export class PortfolioService {
} }
} }
investments = sortBy(investments, (investment) => { investments = sortBy(investments, ({ date }) => {
return investment.date; return date;
}); });
const startDate = this.getStartDate( const startDate = this.getStartDate(
@ -765,9 +765,9 @@ export class PortfolioService {
const currentPositions = const currentPositions =
await portfolioCalculator.getCurrentPositions(portfolioStart); await portfolioCalculator.getCurrentPositions(portfolioStart);
const position = currentPositions.positions.find( const position = currentPositions.positions.find(({ symbol }) => {
(item) => item.symbol === aSymbol return symbol === aSymbol;
); });
if (position) { if (position) {
const { const {
@ -2146,9 +2146,9 @@ export class PortfolioService {
} }
); );
historicalDataItems.sort( historicalDataItems.sort((a, b) => {
(a, b) => new Date(a.date).getTime() - new Date(b.date).getTime() return new Date(a.date).getTime() - new Date(b.date).getTime();
); });
return historicalDataItems; return historicalDataItems;
} }

Loading…
Cancel
Save