mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-14 06:57:35 +08:00
fix incorrect data aggregated by fiscal year in trend analysis
This commit is contained in:
@@ -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<TrendsChartDataItem[]>(() => {
|
||||
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<TrendsChartDataItem[]>(() => {
|
||||
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<TrendsChartDataItem[]>(() => {
|
||||
const dataItem = dataItems[i];
|
||||
|
||||
if (isNumber(dataItem[props.valueField])) {
|
||||
amount += dataItem[props.valueField];
|
||||
amount += dataItem[props.valueField] as number;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<TrendsBarChartData>(() => {
|
||||
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<TrendsBarChartData>(() => {
|
||||
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) {
|
||||
|
||||
+1
-3
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user