mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-22 02:34:26 +08:00
check whether the billing cycle is chosen when set custom date range or backward/forward the date range
This commit is contained in:
+33
-5
@@ -488,11 +488,22 @@ export function getShiftedDateRangeAndDateType(minTime, maxTime, scale, firstDay
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getShiftedDateRangeAndDateTypeForBillingCycle(dateType, scale, firstDayOfWeek, statementDate) {
|
export function getShiftedDateRangeAndDateTypeForBillingCycle(minTime, maxTime, scale, firstDayOfWeek, scene, statementDate) {
|
||||||
if (dateType === dateTimeConstants.allDateRanges.PreviousBillingCycle.type && scale === 1) {
|
if (!dateTimeConstants.allDateRanges.PreviousBillingCycle.availableScenes[scene] || !dateTimeConstants.allDateRanges.CurrentBillingCycle.availableScenes[scene]) {
|
||||||
return getDateRangeByBillingCycleDateType(dateTimeConstants.allDateRanges.CurrentBillingCycle.type, firstDayOfWeek, statementDate);
|
return;
|
||||||
} else if (dateType === dateTimeConstants.allDateRanges.CurrentBillingCycle.type && scale === -1) {
|
}
|
||||||
return getDateRangeByBillingCycleDateType(dateTimeConstants.allDateRanges.PreviousBillingCycle.type, firstDayOfWeek, statementDate);
|
|
||||||
|
const previousBillingCycleRange = getDateRangeByBillingCycleDateType(dateTimeConstants.allDateRanges.PreviousBillingCycle.type, firstDayOfWeek, statementDate);
|
||||||
|
const currentBillingCycleRange = getDateRangeByBillingCycleDateType(dateTimeConstants.allDateRanges.CurrentBillingCycle.type, firstDayOfWeek, statementDate);
|
||||||
|
|
||||||
|
if (previousBillingCycleRange && getUnixTimeBeforeUnixTime(previousBillingCycleRange.maxTime, 1, 'months') === maxTime && getUnixTimeBeforeUnixTime(previousBillingCycleRange.minTime, 1, 'months') === minTime && scale === 1) {
|
||||||
|
return previousBillingCycleRange;
|
||||||
|
} else if (previousBillingCycleRange && previousBillingCycleRange.maxTime === maxTime && previousBillingCycleRange.minTime === minTime && scale === 1) {
|
||||||
|
return currentBillingCycleRange;
|
||||||
|
} else if (currentBillingCycleRange && currentBillingCycleRange.maxTime === maxTime && currentBillingCycleRange.minTime === minTime && scale === -1) {
|
||||||
|
return previousBillingCycleRange;
|
||||||
|
} else if (currentBillingCycleRange && getUnixTimeAfterUnixTime(currentBillingCycleRange.maxTime, 1, 'months') === maxTime && getUnixTimeAfterUnixTime(currentBillingCycleRange.minTime, 1, 'months') === minTime && scale === -1) {
|
||||||
|
return currentBillingCycleRange;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@@ -523,6 +534,23 @@ export function getDateTypeByDateRange(minTime, maxTime, firstDayOfWeek, scene)
|
|||||||
return newDateType;
|
return newDateType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getDateTypeByBillingCycleDateRange(minTime, maxTime, firstDayOfWeek, scene, statementDate) {
|
||||||
|
if (!dateTimeConstants.allDateRanges.PreviousBillingCycle.availableScenes[scene] || !dateTimeConstants.allDateRanges.CurrentBillingCycle.availableScenes[scene]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const previousBillingCycleRange = getDateRangeByBillingCycleDateType(dateTimeConstants.allDateRanges.PreviousBillingCycle.type, firstDayOfWeek, statementDate);
|
||||||
|
const currentBillingCycleRange = getDateRangeByBillingCycleDateType(dateTimeConstants.allDateRanges.CurrentBillingCycle.type, firstDayOfWeek, statementDate);
|
||||||
|
|
||||||
|
if (previousBillingCycleRange && previousBillingCycleRange.maxTime === maxTime && previousBillingCycleRange.minTime === minTime) {
|
||||||
|
return previousBillingCycleRange.dateType;
|
||||||
|
} else if (currentBillingCycleRange && currentBillingCycleRange.maxTime === maxTime && currentBillingCycleRange.minTime === minTime) {
|
||||||
|
return currentBillingCycleRange.dateType;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
export function getDateRangeByDateType(dateType, firstDayOfWeek) {
|
export function getDateRangeByDateType(dateType, firstDayOfWeek) {
|
||||||
let maxTime = 0;
|
let maxTime = 0;
|
||||||
let minTime = 0;
|
let minTime = 0;
|
||||||
|
|||||||
@@ -617,8 +617,9 @@ import {
|
|||||||
getShiftedDateRangeAndDateType,
|
getShiftedDateRangeAndDateType,
|
||||||
getShiftedDateRangeAndDateTypeForBillingCycle,
|
getShiftedDateRangeAndDateTypeForBillingCycle,
|
||||||
getDateTypeByDateRange,
|
getDateTypeByDateRange,
|
||||||
getDateRangeByBillingCycleDateType,
|
getDateTypeByBillingCycleDateRange,
|
||||||
getDateRangeByDateType,
|
getDateRangeByDateType,
|
||||||
|
getDateRangeByBillingCycleDateType,
|
||||||
getRecentDateRangeType,
|
getRecentDateRangeType,
|
||||||
isDateRangeMatchOneMonth
|
isDateRangeMatchOneMonth
|
||||||
} from '@/lib/datetime.js';
|
} from '@/lib/datetime.js';
|
||||||
@@ -1213,8 +1214,8 @@ export default {
|
|||||||
|
|
||||||
let newDateRange = null;
|
let newDateRange = null;
|
||||||
|
|
||||||
if (datetimeConstants.allBillingCycleDateRangesMap[this.query.dateType]) {
|
if (datetimeConstants.allBillingCycleDateRangesMap[this.query.dateType] || this.query.dateType === this.allDateRanges.Custom.type) {
|
||||||
newDateRange = getShiftedDateRangeAndDateTypeForBillingCycle(this.query.dateType, scale, this.firstDayOfWeek, this.accountsStore.getAccountStatementDate(this.query.accountIds));
|
newDateRange = getShiftedDateRangeAndDateTypeForBillingCycle(startTime, endTime, scale, this.firstDayOfWeek, datetimeConstants.allDateRangeScenes.Normal, this.accountsStore.getAccountStatementDate(this.query.accountIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!newDateRange) {
|
if (!newDateRange) {
|
||||||
@@ -1279,7 +1280,11 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const dateType = getDateTypeByDateRange(minTime, maxTime, this.firstDayOfWeek, datetimeConstants.allDateRangeScenes.Normal);
|
let dateType = getDateTypeByBillingCycleDateRange(minTime, maxTime, this.firstDayOfWeek, datetimeConstants.allDateRangeScenes.Normal, this.accountsStore.getAccountStatementDate(this.query.accountIds));
|
||||||
|
|
||||||
|
if (!dateType) {
|
||||||
|
dateType = getDateTypeByDateRange(minTime, maxTime, this.firstDayOfWeek, datetimeConstants.allDateRangeScenes.Normal);
|
||||||
|
}
|
||||||
|
|
||||||
if (this.query.dateType === dateType && this.query.maxTime === maxTime && this.query.minTime === minTime) {
|
if (this.query.dateType === dateType && this.query.maxTime === maxTime && this.query.minTime === minTime) {
|
||||||
this.showCustomDateRangeDialog = false;
|
this.showCustomDateRangeDialog = false;
|
||||||
|
|||||||
@@ -542,6 +542,7 @@ import {
|
|||||||
getShiftedDateRangeAndDateType,
|
getShiftedDateRangeAndDateType,
|
||||||
getShiftedDateRangeAndDateTypeForBillingCycle,
|
getShiftedDateRangeAndDateTypeForBillingCycle,
|
||||||
getDateTypeByDateRange,
|
getDateTypeByDateRange,
|
||||||
|
getDateTypeByBillingCycleDateRange,
|
||||||
getDateRangeByDateType,
|
getDateRangeByDateType,
|
||||||
getDateRangeByBillingCycleDateType
|
getDateRangeByBillingCycleDateType
|
||||||
} from '@/lib/datetime.js';
|
} from '@/lib/datetime.js';
|
||||||
@@ -909,7 +910,11 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const dateType = getDateTypeByDateRange(minTime, maxTime, this.firstDayOfWeek, datetimeConstants.allDateRangeScenes.Normal);
|
let dateType = getDateTypeByBillingCycleDateRange(minTime, maxTime, this.firstDayOfWeek, datetimeConstants.allDateRangeScenes.Normal, this.accountsStore.getAccountStatementDate(this.query.accountIds));
|
||||||
|
|
||||||
|
if (!dateType) {
|
||||||
|
dateType = getDateTypeByDateRange(minTime, maxTime, this.firstDayOfWeek, datetimeConstants.allDateRangeScenes.Normal);
|
||||||
|
}
|
||||||
|
|
||||||
const changed = this.transactionsStore.updateTransactionListFilter({
|
const changed = this.transactionsStore.updateTransactionListFilter({
|
||||||
dateType: dateType,
|
dateType: dateType,
|
||||||
@@ -1117,8 +1122,8 @@ export default {
|
|||||||
|
|
||||||
let newDateRange = null;
|
let newDateRange = null;
|
||||||
|
|
||||||
if (datetimeConstants.allBillingCycleDateRangesMap[this.query.dateType]) {
|
if (datetimeConstants.allBillingCycleDateRangesMap[this.query.dateType] || this.query.dateType === this.allDateRanges.Custom.type) {
|
||||||
newDateRange = getShiftedDateRangeAndDateTypeForBillingCycle(this.query.dateType, scale, this.firstDayOfWeek, this.accountsStore.getAccountStatementDate(this.query.accountIds));
|
newDateRange = getShiftedDateRangeAndDateTypeForBillingCycle(minTime, maxTime, scale, this.firstDayOfWeek, datetimeConstants.allDateRangeScenes.Normal, this.accountsStore.getAccountStatementDate(this.query.accountIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!newDateRange) {
|
if (!newDateRange) {
|
||||||
|
|||||||
Reference in New Issue
Block a user