add billing cycle date range filter

This commit is contained in:
MaysWind
2024-12-16 23:44:20 +08:00
parent 8fdbb39ee4
commit 647cd3c33f
12 changed files with 226 additions and 23 deletions
@@ -152,6 +152,7 @@ import { useAccountsStore } from '@/stores/account.js';
import { useTransactionsStore } from '@/stores/transaction.js';
import { useStatisticsStore } from '@/stores/statistics.js';
import datetimeConstants from '@/consts/datetime.js';
import accountConstants from '@/consts/account.js';
import { copyObjectTo } from '@/lib/common.js';
import {
@@ -322,9 +323,15 @@ export default {
self.statisticsStore.updateTransactionStatisticsInvalidState(true);
}
} else if (this.type === 'transactionListCurrent') {
changed = self.transactionsStore.updateTransactionListFilter({
const filter = {
accountIds: isAllSelected ? '' : finalAccountIds
});
};
if (datetimeConstants.allBillingCycleDateRangesMap[self.transactionsStore.transactionsFilter.dateType] && !self.accountsStore.getAccountStatementDate(filter.accountIds)) {
filter.dateType = datetimeConstants.allDateRanges.Custom.type;
}
changed = self.transactionsStore.updateTransactionListFilter(filter);
if (changed) {
self.transactionsStore.updateTransactionListInvalidState(true);
+27 -7
View File
@@ -146,7 +146,7 @@
<span class="text-sm ml-3">{{ dateRange.displayName }}</span>
</div>
</v-list-item-title>
<div class="ml-3 smaller" v-if="dateRange.type === allDateRanges.Custom.type && query.dateType === allDateRanges.Custom.type && query.minTime && query.maxTime">
<div class="ml-3 smaller" v-if="((dateRange.isBillingCycle || dateRange.type === allDateRanges.Custom.type) && query.dateType === dateRange.type) && query.minTime && query.maxTime">
<span>{{ queryMinTime }}</span>
<span>&nbsp;-&nbsp;</span>
<br/>
@@ -615,7 +615,9 @@ import {
getBrowserTimezoneOffsetMinutes,
getActualUnixTimeForStore,
getShiftedDateRangeAndDateType,
getShiftedDateRangeAndDateTypeForBillingCycle,
getDateTypeByDateRange,
getDateRangeByBillingCycleDateType,
getDateRangeByDateType,
getRecentDateRangeType,
isDateRangeMatchOneMonth
@@ -743,7 +745,7 @@ export default {
return this.userStore.currentUserFirstDayOfWeek;
},
allDateRangesArray() {
return this.$locale.getAllDateRanges(datetimeConstants.allDateRangeScenes.Normal, true);
return this.$locale.getAllDateRanges(datetimeConstants.allDateRangeScenes.Normal, true, !!this.accountsStore.getAccountStatementDate(this.query.accountIds));
},
allDateRanges() {
return datetimeConstants.allDateRanges;
@@ -1115,7 +1117,7 @@ export default {
let dateRange = getDateRangeByDateType(query.dateType ? parseInt(query.dateType) : undefined, this.firstDayOfWeek);
if (!dateRange &&
query.dateType === datetimeConstants.allDateRanges.Custom.type.toString() &&
(datetimeConstants.allBillingCycleDateRangesMap[query.dateType] || query.dateType === datetimeConstants.allDateRanges.Custom.type.toString()) &&
parseInt(query.maxTime) > 0 && parseInt(query.minTime) > 0) {
dateRange = {
dateType: parseInt(query.dateType),
@@ -1209,7 +1211,15 @@ export default {
return;
}
const newDateRange = getShiftedDateRangeAndDateType(startTime, endTime, scale, this.firstDayOfWeek, datetimeConstants.allDateRangeScenes.Normal);
let newDateRange = null;
if (datetimeConstants.allBillingCycleDateRangesMap[this.query.dateType]) {
newDateRange = getShiftedDateRangeAndDateTypeForBillingCycle(this.query.dateType, scale, this.firstDayOfWeek, this.accountsStore.getAccountStatementDate(this.query.accountIds));
}
if (!newDateRange) {
newDateRange = getShiftedDateRangeAndDateType(startTime, endTime, scale, this.firstDayOfWeek, datetimeConstants.allDateRangeScenes.Normal);
}
const changed = this.transactionsStore.updateTransactionListFilter({
dateType: newDateRange.dateType,
@@ -1226,7 +1236,11 @@ export default {
},
changeDateFilter(dateRange) {
if (isNumber(dateRange)) {
dateRange = getDateRangeByDateType(dateRange, this.firstDayOfWeek);
if (datetimeConstants.allBillingCycleDateRangesMap[dateRange]) {
dateRange = getDateRangeByBillingCycleDateType(dateRange, this.firstDayOfWeek, this.accountsStore.getAccountStatementDate(this.query.accountIds));
} else {
dateRange = getDateRangeByDateType(dateRange, this.firstDayOfWeek);
}
}
if (dateRange.dateType === datetimeConstants.allDateRanges.Custom.type &&
@@ -1418,9 +1432,15 @@ export default {
return;
}
const changed = this.transactionsStore.updateTransactionListFilter({
const filter = {
accountIds: accountIds
});
};
if (datetimeConstants.allBillingCycleDateRangesMap[this.query.dateType] && !this.accountsStore.getAccountStatementDate(accountIds)) {
filter.dateType = datetimeConstants.allDateRanges.Custom.type;
}
const changed = this.transactionsStore.updateTransactionListFilter(filter);
if (changed) {
this.loading = true;