diff --git a/src/components/desktop/TrendsChart.vue b/src/components/desktop/TrendsChart.vue index 90f3cb51..81983628 100644 --- a/src/components/desktop/TrendsChart.vue +++ b/src/components/desktop/TrendsChart.vue @@ -70,7 +70,7 @@ const emit = defineEmits<{ }>(); const theme = useTheme(); -const { tt, formatUnixTimeToShortYear, formatYearQuarter, formatUnixTimeToShortYearMonth, formatUnixTimeToFiscalYear, formatYearToFiscalYear, formatAmountWithCurrency } = useI18n(); +const { tt, formatUnixTimeToShortYear, formatYearQuarter, formatUnixTimeToShortYearMonth, formatUnixTimeToFiscalYear, formatAmountWithCurrency } = useI18n(); const { allDateRanges, getItemName, getColor } = useTrendsChartBase(props); const userStore = useUserStore(); @@ -155,10 +155,10 @@ const allSeries = computed(() => { dateRangeKey = dataItem.year.toString(); } else if (props.dateAggregationType === ChartDateAggregationType.FiscalYear.type) { const fiscalYear = getFiscalYearFromUnixTime( - getYearMonthFirstUnixTime({ year: dataItem.year, month: dataItem.month }), + getYearMonthFirstUnixTime({ year: dataItem.year, month: dataItem.month - 1 }), props.fiscalYearStart ); - dateRangeKey = formatYearToFiscalYear(fiscalYear); + dateRangeKey = fiscalYear.toString(); } else if (props.dateAggregationType === ChartDateAggregationType.Quarter.type) { dateRangeKey = `${dataItem.year}-${Math.floor((dataItem.month - 1) / 3) + 1}`; } else { // if (props.dateAggregationType === ChartDateAggregationType.Month.type) { @@ -178,7 +178,7 @@ const allSeries = computed(() => { if (props.dateAggregationType === ChartDateAggregationType.Year.type) { dateRangeKey = dateRange.year.toString(); } else if (props.dateAggregationType === ChartDateAggregationType.FiscalYear.type && 'year' in dateRange) { - dateRangeKey = formatYearToFiscalYear(dateRange.year); + dateRangeKey = dateRange.year.toString(); } else if (props.dateAggregationType === ChartDateAggregationType.Quarter.type && 'quarter' in dateRange) { dateRangeKey = `${dateRange.year}-${dateRange.quarter}`; } else if (props.dateAggregationType === ChartDateAggregationType.Month.type && 'month' in dateRange) { @@ -193,7 +193,7 @@ const allSeries = computed(() => { const dataItem = dataItems[i]; if (isNumber(dataItem[props.valueField])) { - amount += dataItem[props.valueField]; + amount += dataItem[props.valueField] as number; } } } diff --git a/src/components/mobile/TrendsBarChart.vue b/src/components/mobile/TrendsBarChart.vue index 104c9678..f4d5181d 100644 --- a/src/components/mobile/TrendsBarChart.vue +++ b/src/components/mobile/TrendsBarChart.vue @@ -148,7 +148,7 @@ const emit = defineEmits<{ (e: 'click', value: TrendsBarChartClickEvent): void; }>(); -const { tt, formatUnixTimeToShortYear, formatYearQuarter, formatUnixTimeToShortYearMonth, formatUnixTimeToFiscalYear, formatYearToFiscalYear, formatAmountWithCurrency } = useI18n(); +const { tt, formatUnixTimeToShortYear, formatYearQuarter, formatUnixTimeToShortYearMonth, formatUnixTimeToFiscalYear, formatAmountWithCurrency } = useI18n(); const { allDateRanges, getItemName, getColor } = useTrendsChartBase(props); const userStore = useUserStore(); @@ -191,10 +191,10 @@ const allDisplayDataItems = computed(() => { dateRangeKey = dataItem.year.toString(); } else if (props.dateAggregationType === ChartDateAggregationType.FiscalYear.type) { const fiscalYear = getFiscalYearFromUnixTime( - getYearMonthFirstUnixTime({ year: dataItem.year, month: dataItem.month }), + getYearMonthFirstUnixTime({ year: dataItem.year, month: dataItem.month - 1 }), props.fiscalYearStart ); - dateRangeKey = formatYearToFiscalYear(fiscalYear); + dateRangeKey = fiscalYear.toString(); } else if (props.dateAggregationType === ChartDateAggregationType.Quarter.type) { dateRangeKey = `${dataItem.year}-${Math.floor((dataItem.month - 1) / 3) + 1}`; } else { // if (props.dateAggregationType === ChartDateAggregationType.Month.type) { @@ -226,7 +226,7 @@ const allDisplayDataItems = computed(() => { if (props.dateAggregationType === ChartDateAggregationType.Year.type) { dateRangeKey = dateRange.year.toString(); } else if (props.dateAggregationType === ChartDateAggregationType.FiscalYear.type) { - dateRangeKey = formatYearToFiscalYear(dateRange.year); + dateRangeKey = dateRange.year.toString(); } else if (props.dateAggregationType === ChartDateAggregationType.Quarter.type && 'quarter' in dateRange) { dateRangeKey = `${dateRange.year}-${dateRange.quarter}`; } else if (props.dateAggregationType === ChartDateAggregationType.Month.type && 'month' in dateRange) { diff --git a/src/lib/datetime.ts b/src/lib/datetime.ts index 3a562130..717e9388 100644 --- a/src/lib/datetime.ts +++ b/src/lib/datetime.ts @@ -465,12 +465,10 @@ export function getAllFiscalYearsStartAndEndUnixTimes(startYearMonth: YearMonth fiscalYearStart = FiscalYearStart.Default; } - const fiscalYearStartMonth = fiscalYearStart.month; - // Loop over 1 year before and 1 year after the input date range // to include fiscal years that start in the previous calendar year. for (let year = range.startYearMonth.year - 1; year <= range.endYearMonth.year + 1; year++) { - const thisYearMonthUnixTime = getYearMonthFirstUnixTime({ year: year, month: fiscalYearStartMonth }); + const thisYearMonthUnixTime = getYearMonthFirstUnixTime({ year: year, month: fiscalYearStart.month - 1 }); const fiscalStartTime = getFiscalYearStartUnixTime(thisYearMonthUnixTime, fiscalYearStart.value); const fiscalEndTime = getFiscalYearEndUnixTime(thisYearMonthUnixTime, fiscalYearStart.value);