feat: add recurring transactions (Wiederkehrende Buchungen)
Lets treasurers/captains/coaches define recurring fee/levy dues that are automatically booked for all active players on a monthly, quarterly, or yearly schedule via a daily cron job, instead of having to book them manually every cycle. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { Transform } from 'class-transformer';
|
||||
import {
|
||||
IsIn,
|
||||
IsInt,
|
||||
IsNotEmpty,
|
||||
IsNumber,
|
||||
IsString,
|
||||
Length,
|
||||
Max,
|
||||
Min,
|
||||
} from 'class-validator';
|
||||
import { TransactionTypeEnum } from 'src/transactions/transaction-type.enum';
|
||||
import { RecurringTransactionIntervalEnum } from '../recurring-transaction-interval.enum';
|
||||
|
||||
const ALLOWED_TYPES = [TransactionTypeEnum.fee, TransactionTypeEnum.levy];
|
||||
|
||||
export class CreateRecurringTransactionDTO {
|
||||
@ApiProperty({ example: 2342 })
|
||||
@IsInt()
|
||||
@Min(1)
|
||||
teamId: number;
|
||||
|
||||
@ApiProperty({ example: 'Monatsbeitrag' })
|
||||
@Transform(({ value }) =>
|
||||
typeof value === 'string' ? value.trim() : value,
|
||||
)
|
||||
@IsString()
|
||||
@Length(1, 120)
|
||||
description: string;
|
||||
|
||||
@ApiProperty({ example: 10 })
|
||||
@IsNumber({ maxDecimalPlaces: 2 })
|
||||
@Min(0.01)
|
||||
@Max(10000)
|
||||
amount: number;
|
||||
|
||||
@ApiProperty({ enum: ALLOWED_TYPES })
|
||||
@IsIn(ALLOWED_TYPES)
|
||||
type: TransactionTypeEnum;
|
||||
|
||||
@ApiProperty({ enum: RecurringTransactionIntervalEnum })
|
||||
@IsIn(Object.values(RecurringTransactionIntervalEnum))
|
||||
interval: RecurringTransactionIntervalEnum;
|
||||
|
||||
@ApiProperty({ example: 'isotimestring' })
|
||||
@IsNotEmpty()
|
||||
startDate: string;
|
||||
}
|
||||
Reference in New Issue
Block a user