diff --git a/apps/red-ui/src/app/modules/admin/screens/license/components/license-analysis-capacity-usage/license-analysis-capacity-usage.component.ts b/apps/red-ui/src/app/modules/admin/screens/license/components/license-analysis-capacity-usage/license-analysis-capacity-usage.component.ts index 7995cd9bb..e99ef2cbf 100644 --- a/apps/red-ui/src/app/modules/admin/screens/license/components/license-analysis-capacity-usage/license-analysis-capacity-usage.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/license/components/license-analysis-capacity-usage/license-analysis-capacity-usage.component.ts @@ -3,7 +3,7 @@ import { LicenseService } from '@services/license.service'; import { map } from 'rxjs/operators'; import { ChartDataset } from 'chart.js'; import { ChartBlue, ChartGreen, ChartRed } from '../../utils/constants'; -import { getDataUntilCurrentMonth, getLabelsFromLicense, getLineConfig, isCurrentMonthAndYear } from '../../utils/functions'; +import { getDataUntilCurrentMonth, getLabelsFromLicense, getLineConfig, isCurrentMonth } from '../../utils/functions'; import { TranslateModule, TranslateService } from '@ngx-translate/core'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import { size } from '@iqser/common-ui/lib/utils'; @@ -43,7 +43,7 @@ export class LicenseAnalysisCapacityUsageComponent { #getCapacityDatasets(): ChartDataset[] { const monthlyData = [...this.licenseService.selectedLicenseReport.monthlyData]; const dataUntilCurrentMonth = getDataUntilCurrentMonth(monthlyData); - if (monthlyData.length === 1 || isCurrentMonthAndYear(monthlyData[0].startDate)) { + if (monthlyData.length === 1 || isCurrentMonth(monthlyData[0].startDate)) { const empty = { analysedFilesBytes: null } as ILicenseData; dataUntilCurrentMonth.splice(0, 0, empty); monthlyData.splice(0, 0, empty); diff --git a/apps/red-ui/src/app/modules/admin/screens/license/components/license-page-usage/license-page-usage.component.ts b/apps/red-ui/src/app/modules/admin/screens/license/components/license-page-usage/license-page-usage.component.ts index 7a3c1d3ab..88ebfde38 100644 --- a/apps/red-ui/src/app/modules/admin/screens/license/components/license-page-usage/license-page-usage.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/license/components/license-page-usage/license-page-usage.component.ts @@ -3,7 +3,7 @@ import { LicenseService } from '@services/license.service'; import { map } from 'rxjs/operators'; import { ChartDataset } from 'chart.js'; import { ChartBlue, ChartGreen, ChartRed } from '../../utils/constants'; -import { getDataUntilCurrentMonth, getLabelsFromLicense, getLineConfig, isCurrentMonthAndYear } from '../../utils/functions'; +import { getDataUntilCurrentMonth, getLabelsFromLicense, getLineConfig, isCurrentMonth } from '../../utils/functions'; import { TranslateModule, TranslateService } from '@ngx-translate/core'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import { ILicenseData } from '@red/domain'; @@ -40,7 +40,7 @@ export class LicensePageUsageComponent { #getPagesDatasets(): ChartDataset[] { const monthlyData = [...this.licenseService.selectedLicenseReport.monthlyData]; const dataUntilCurrentMonth = getDataUntilCurrentMonth(monthlyData); - if (monthlyData.length === 1 || isCurrentMonthAndYear(monthlyData[0].startDate)) { + if (monthlyData.length === 1 || isCurrentMonth(monthlyData[0].startDate)) { const empty = { numberOfAnalyzedPages: null } as ILicenseData; dataUntilCurrentMonth.splice(0, 0, empty); monthlyData.splice(0, 0, empty); diff --git a/apps/red-ui/src/app/modules/admin/screens/license/utils/functions.ts b/apps/red-ui/src/app/modules/admin/screens/license/utils/functions.ts index 2c3a9ce3e..a06f15c17 100644 --- a/apps/red-ui/src/app/modules/admin/screens/license/utils/functions.ts +++ b/apps/red-ui/src/app/modules/admin/screens/license/utils/functions.ts @@ -44,7 +44,7 @@ export const getLabelsFromLicense = (license: ILicenseReport) => { monthIterator = monthIterator.add(1, 'month'); } - if (startMonth.month() === endMonth.month() || startMonth.month() === currentMonth) { + if (startMonth.isSame(endMonth, 'month') || isCurrentMonth(startMonth.toDate())) { result.splice(0, 0, ''); } @@ -55,6 +55,6 @@ export const getDataUntilCurrentMonth = (monthlyData: ILicenseData[]) => { return monthlyData.filter(data => dayjs(data.startDate).isSameOrBefore(dayjs(Date.now()), 'month')); }; -export const isCurrentMonthAndYear = (date: Date | string) => { - return dayjs(date).isSame(dayjs(Date.now()), 'month') && dayjs(date).isSame(dayjs(Date.now()), 'year'); +export const isCurrentMonth = (date: Date | string) => { + return dayjs(date).isSame(dayjs(Date.now()), 'month'); };