diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.ts index 9da59b02c..09cc03455 100644 --- a/apps/api/src/app/portfolio/portfolio.service.ts +++ b/apps/api/src/app/portfolio/portfolio.service.ts @@ -65,6 +65,7 @@ import { max, parse, parseISO, + set, setDayOfYear, startOfDay, subDays, @@ -215,22 +216,40 @@ export class PortfolioService { investment: item.investment.toNumber() }; }); - } else { - investments = portfolioCalculator.getInvestments().map((item) => { - return { - date: item.date, - investment: item.investment.toNumber() - }; + + // Add investment of current month + const dateOfCurrentMonth = format( + set(new Date(), { date: 1 }), + DATE_FORMAT + ); + const investmentOfCurrentMonth = investments.filter(({ date }) => { + return date === dateOfCurrentMonth; }); + if (investmentOfCurrentMonth.length <= 0) { + investments.push({ + date: dateOfCurrentMonth, + investment: 0 + }); + } + } else { + investments = portfolioCalculator + .getInvestments() + .map(({ date, investment }) => { + return { + date, + investment: investment.toNumber() + }; + }); + // Add investment of today - const investmentOfToday = investments.filter((investment) => { - return investment.date === format(new Date(), DATE_FORMAT); + const investmentOfToday = investments.filter(({ date }) => { + return date === format(new Date(), DATE_FORMAT); }); if (investmentOfToday.length <= 0) { - const pastInvestments = investments.filter((investment) => { - return isBefore(parseDate(investment.date), new Date()); + const pastInvestments = investments.filter(({ date }) => { + return isBefore(parseDate(date), new Date()); }); const lastInvestment = pastInvestments[pastInvestments.length - 1]; diff --git a/apps/client/src/app/components/investment-chart/investment-chart.component.ts b/apps/client/src/app/components/investment-chart/investment-chart.component.ts index 65be1387d..74c82cf02 100644 --- a/apps/client/src/app/components/investment-chart/investment-chart.component.ts +++ b/apps/client/src/app/components/investment-chart/investment-chart.component.ts @@ -186,8 +186,10 @@ export class InvestmentChartComponent implements OnChanges, OnDestroy { grid: { borderColor: `rgba(${getTextColor()}, 0.1)`, color: `rgba(${getTextColor()}, 0.8)`, - display: false + display: false, + drawBorder: false }, + position: 'right', ticks: { callback: (value: number) => { return transformTickToAbbreviation(value);