last mile

This commit is contained in:
natib21
2026-06-22 07:49:47 +00:00
parent f2d0a90065
commit 00d722fa4f
9 changed files with 405 additions and 0 deletions

View File

@@ -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;
}

View File

@@ -0,0 +1,5 @@
import { PartialType } from '@nestjs/mapped-types';
import { CreateFirstMileDto } from './create-first-mile.dto';
export class UpdateFirstMileDto extends PartialType(CreateFirstMileDto) {}