mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 09:58:12 +00:00
last mile
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { Transform } from 'class-transformer';
|
||||
import { IsIn, IsNumber, IsOptional, IsUUID, Min } from 'class-validator';
|
||||
|
||||
import { FIRST_MILE_STATUSES, FirstMileStatus } from '../entities/first-mile.entity';
|
||||
|
||||
const toNumber = ({ value }: { value: unknown }) =>
|
||||
value === '' || value == null ? undefined : Number(value);
|
||||
|
||||
export class CreateFirstMileDto {
|
||||
@ApiProperty({ description: 'Booking this first-mile leg belongs to (FK → bookings.id)' })
|
||||
@IsUUID()
|
||||
bookingId!: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
enum: FIRST_MILE_STATUSES,
|
||||
default: 'PAYMENT_PENDING',
|
||||
})
|
||||
@IsOptional()
|
||||
@IsIn(FIRST_MILE_STATUSES as unknown as string[])
|
||||
status?: FirstMileStatus;
|
||||
|
||||
@ApiPropertyOptional({ description: 'Amount already paid in advance', example: 4200 })
|
||||
@IsOptional()
|
||||
@Transform(toNumber)
|
||||
@IsNumber()
|
||||
@Min(0)
|
||||
advancedPayment?: number;
|
||||
|
||||
@ApiPropertyOptional({ description: 'Outstanding balance to be collected', example: 1800 })
|
||||
@IsOptional()
|
||||
@Transform(toNumber)
|
||||
@IsNumber()
|
||||
@Min(0)
|
||||
remainingPayment?: number;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description: 'Assigned vehicle (FK → vehicles.id). May be null until assigned.',
|
||||
nullable: true,
|
||||
})
|
||||
@IsOptional()
|
||||
@IsUUID()
|
||||
vehicleId?: string | null;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { PartialType } from '@nestjs/mapped-types';
|
||||
|
||||
import { CreateFirstMileDto } from './create-first-mile.dto';
|
||||
|
||||
export class UpdateFirstMileDto extends PartialType(CreateFirstMileDto) {}
|
||||
Reference in New Issue
Block a user