Files
edr-platform/apps/finance-api/src/modules/revenue/dto/revenue.dto.ts
2026-08-25 00:11:39 +03:00

114 lines
2.3 KiB
TypeScript

import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import {
IsBoolean,
IsIn,
IsISO8601,
IsNotEmpty,
IsOptional,
IsString,
IsUUID,
Matches,
MaxLength,
} from "class-validator";
import {
MAPPING_SOURCES,
type MappingSource,
} from "../entities/revenue-mapping.entity";
import {
INBOUND_EVENT_STATUSES,
type InboundEventStatus,
} from "../entities/inbound-event.entity";
export class RevenueMappingQueryDto {
@ApiPropertyOptional({ enum: MAPPING_SOURCES })
@IsOptional()
@IsIn(MAPPING_SOURCES)
sourceModule?: MappingSource;
@ApiPropertyOptional()
@IsOptional()
@IsString()
search?: string;
}
export class CreateRevenueMappingDto {
@ApiProperty({ enum: MAPPING_SOURCES })
@IsIn(MAPPING_SOURCES)
sourceModule!: MappingSource;
@ApiProperty({
example: "STORAGE_FEE",
description: "A freight invoice_lines.charge_type, or a passenger revenue key",
})
@IsString()
@IsNotEmpty()
@MaxLength(64)
matchValue!: string;
@ApiProperty()
@IsUUID()
accountId!: string;
@ApiProperty({ example: "INCIDENTAL" })
@IsString()
@IsNotEmpty()
@MaxLength(48)
revenueCategory!: string;
@ApiPropertyOptional()
@IsOptional()
@IsString()
notes?: string;
}
export class UpdateRevenueMappingDto {
@ApiPropertyOptional()
@IsOptional()
@IsUUID()
accountId?: string;
@ApiPropertyOptional()
@IsOptional()
@IsString()
@MaxLength(48)
revenueCategory?: string;
@ApiPropertyOptional()
@IsOptional()
@IsBoolean()
isActive?: boolean;
@ApiPropertyOptional()
@IsOptional()
@IsString()
notes?: string;
}
export class RevenueQueryDto {
@ApiProperty({ example: "2026-08-01", description: "ISO date (inclusive)" })
@IsISO8601()
dateFrom!: string;
@ApiProperty({ example: "2026-08-31", description: "ISO date (inclusive)" })
@IsISO8601()
dateTo!: string;
}
export class RecognizeRevenueDto {
@ApiProperty({ enum: MAPPING_SOURCES, example: "passenger" })
@IsIn(MAPPING_SOURCES)
sourceModule!: MappingSource;
@ApiProperty({ example: "2026-08", description: "YYYY-MM" })
@Matches(/^\d{4}-\d{2}$/, { message: "period must be YYYY-MM" })
period!: string;
}
export class InboundEventQueryDto {
@ApiPropertyOptional({ enum: INBOUND_EVENT_STATUSES })
@IsOptional()
@IsIn(INBOUND_EVENT_STATUSES)
status?: InboundEventStatus;
}