support daily and yearly intervals for scheduled transactions

This commit is contained in:
MaysWind
2026-04-13 01:34:56 +08:00
parent c828db4988
commit 63ec0e4424
27 changed files with 233 additions and 33 deletions
@@ -4,8 +4,11 @@ import { useI18n } from '@/locales/helpers.ts';
import { useUserStore } from '@/stores/user.ts';
import type { TypeAndDisplayName } from '@/core/base.ts';
import { type TypeAndDisplayName, itemAndIndex } from '@/core/base.ts';
import { type DateTime } from '@/core/datetime.ts';
import { sortNumbersArray } from '@/lib/common.ts';
import { getCurrentDateTime } from '@/lib/datetime.ts';
export interface CommonScheduleFrequencySelectionProps {
type: number;
@@ -19,7 +22,8 @@ export function useScheduleFrequencySelectionBase() {
const {
getAllWeekDays,
getAvailableMonthDays,
getAllTransactionScheduledFrequencyTypes
getAllTransactionScheduledFrequencyTypes,
formatDateTimeToLongMonthDay
} = useI18n();
const userStore = useUserStore();
@@ -27,6 +31,33 @@ export function useScheduleFrequencySelectionBase() {
const allWeekDays = computed<TypeAndDisplayName[]>(() => getAllWeekDays(userStore.currentUserFirstDayOfWeek));
const allAvailableMonthDays = computed<TypeAndDisplayName[]>(() => getAvailableMonthDays(28, 3));
const allAvailableMonthAndDays = computed<TypeAndDisplayName[]>(() => {
const ret: TypeAndDisplayName[] = [];
const now: DateTime = getCurrentDateTime();
const maxDaysOfMonth: number[] = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
for (const [days, index] of itemAndIndex(maxDaysOfMonth)) {
const month = index + 1;
for (let day = 1; day <= days; day++) {
const dateTime = now.set({
month: month,
dayOfMonth: day,
hour: 0,
minute: 0,
second: 0,
millisecond: 0
});
ret.push({
type: month * 100 + day,
displayName: formatDateTimeToLongMonthDay(dateTime)
});
}
}
return ret;
});
function getFrequencyValues(value: string): number[] {
const values = value.split(',');
@@ -46,6 +77,7 @@ export function useScheduleFrequencySelectionBase() {
allTransactionScheduledFrequencyTypes,
allWeekDays,
allAvailableMonthDays,
allAvailableMonthAndDays,
// functions
getFrequencyValues
};