Browse Source

Calculate min / max for the full portfolio

pull/428/head
Thomas 4 years ago
parent
commit
334f80b2fe
  1. 16
      apps/api/src/app/portfolio/portfolio.service.ts

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

@ -187,7 +187,10 @@ export class PortfolioService {
DATE_FORMAT, DATE_FORMAT,
new Date() new Date()
); );
portfolioStart = this.getStartDate(aDateRange, portfolioStart);
// Get start date for the full portfolio because of because of the
// min and max calculation
portfolioStart = this.getStartDate('max', portfolioStart);
const timelineSpecification: TimelineSpecification[] = [ const timelineSpecification: TimelineSpecification[] = [
{ {
@ -226,10 +229,19 @@ export class PortfolioService {
isAllTimeHigh = false; isAllTimeHigh = false;
isAllTimeLow = false; isAllTimeLow = false;
} }
portfolioStart = this.getStartDate(
aDateRange,
parse(transactionPoints[0].date, DATE_FORMAT, new Date())
);
return { return {
isAllTimeHigh, isAllTimeHigh,
isAllTimeLow, isAllTimeLow,
items items: items.filter((item) => {
// Filter items of date range
return isBefore(portfolioStart, parseDate(item.date));
})
}; };
} }

Loading…
Cancel
Save