Refactoring (#2897)
This commit is contained in:
parent
8d5f2fd91d
commit
6167f105fe
@ -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;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user