import {
    IsString, IsNotEmpty, IsNumber, IsOptional, IsBoolean,
    IsIn, IsMongoId, Min, Max, MaxLength, IsDateString,
} from 'class-validator';

export class CreateInvoiceDto {
    @IsNotEmpty()
    @IsMongoId()
    studentId: string;

    @IsNotEmpty()
    @IsNumber()
    @Min(1)
    @Max(10000000)
    amount: number;

    @IsOptional()
    @IsNumber()
    @Min(0)
    totalPaid?: number;

    @IsOptional()
    @IsString()
    @IsIn(['cash', 'upi', 'cheque', 'bank_transfer', 'online'])
    paymentMode?: 'cash' | 'upi' | 'cheque' | 'bank_transfer' | 'online';

    @IsOptional()
    @IsDateString()
    date?: string;

    @IsOptional()
    @IsString()
    @MaxLength(2000)
    notes?: string;

    // Real bank/UPI/cheque reference. When omitted on a paid/partial invoice
    // the service auto-generates a TXN-YYYY-NNNNNN identifier.
    @IsOptional()
    @IsString()
    @MaxLength(200)
    transactionId?: string;

    @IsOptional()
    @IsBoolean()
    isActive?: boolean;
}
