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(['online', 'offline'])
    paymentMode?: 'online' | 'offline';

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

    @IsOptional()
    @IsDateString()
    dueDate?: 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;

    // Per-invoice partial-payment policy. Required at creation. Once written,
    // immutable (UpdateInvoiceDto does not carry it).
    @IsBoolean()
    allowPartialPayment: boolean;
}
