diff --git a/pkg/models/transaction_template.go b/pkg/models/transaction_template.go index 8b3abccb..5d9e82b9 100644 --- a/pkg/models/transaction_template.go +++ b/pkg/models/transaction_template.go @@ -24,6 +24,8 @@ const ( TRANSACTION_SCHEDULE_FREQUENCY_TYPE_DISABLED TransactionScheduleFrequencyType = 0 TRANSACTION_SCHEDULE_FREQUENCY_TYPE_WEEKLY TransactionScheduleFrequencyType = 1 TRANSACTION_SCHEDULE_FREQUENCY_TYPE_MONTHLY TransactionScheduleFrequencyType = 2 + TRANSACTION_SCHEDULE_FREQUENCY_TYPE_DAILY TransactionScheduleFrequencyType = 3 + TRANSACTION_SCHEDULE_FREQUENCY_TYPE_YEARLY TransactionScheduleFrequencyType = 4 ) // TransactionTemplate represents transaction template stored in database diff --git a/pkg/services/transactions.go b/pkg/services/transactions.go index fbef17ba..1f8b80bc 100644 --- a/pkg/services/transactions.go +++ b/pkg/services/transactions.go @@ -683,7 +683,20 @@ func (s *TransactionService) CreateScheduledTransactions(c core.Context, current for i := 0; i < s.UserDataDBCount(); i++ { var templates []*models.TransactionTemplate - err := s.UserDataDBByIndex(i).NewSession(c).Where("deleted=? AND template_type=? AND (scheduled_frequency_type=? OR scheduled_frequency_type=?) AND (scheduled_start_time IS NULL OR scheduled_start_time<=?) AND (scheduled_end_time IS NULL OR scheduled_end_time>=?) AND scheduled_at>=? AND scheduled_at=?)"+ + " AND scheduled_at>=?"+ + " AND scheduled_at transactionUnixTime { diff --git a/src/components/base/ScheduleFrequencySelectionBase.ts b/src/components/base/ScheduleFrequencySelectionBase.ts index f4beb8b5..0bfd60fc 100644 --- a/src/components/base/ScheduleFrequencySelectionBase.ts +++ b/src/components/base/ScheduleFrequencySelectionBase.ts @@ -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(() => getAllWeekDays(userStore.currentUserFirstDayOfWeek)); const allAvailableMonthDays = computed(() => getAvailableMonthDays(28, 3)); + const allAvailableMonthAndDays = computed(() => { + 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 }; diff --git a/src/components/desktop/ScheduleFrequencySelect.vue b/src/components/desktop/ScheduleFrequencySelect.vue index 4a8255eb..3d7554ca 100644 --- a/src/components/desktop/ScheduleFrequencySelect.vue +++ b/src/components/desktop/ScheduleFrequencySelect.vue @@ -28,14 +28,18 @@ + + + -