add column

This commit is contained in:
natib21
2026-06-22 07:54:07 +00:00
parent 00d722fa4f
commit bee47b231a
4 changed files with 40 additions and 0 deletions

View File

@@ -43,6 +43,20 @@ export class CreateFirstMile1810000000000 implements MigrationInterface {
default: 0,
isNullable: false,
},
{
name: 'estimated_km',
type: 'numeric',
precision: 10,
scale: 2,
isNullable: true,
},
{
name: 'exact_km',
type: 'numeric',
precision: 10,
scale: 2,
isNullable: true,
},
{ name: 'vehicle_id', type: 'uuid', isNullable: true },
{ name: 'created_at', type: 'timestamptz', default: 'now()' },
{ name: 'updated_at', type: 'timestamptz', default: 'now()' },

View File

@@ -34,7 +34,23 @@ export class CreateFirstMileDto {
@Min(0)
remainingPayment?: number;
@ApiPropertyOptional({ description: 'Planned distance for the leg, in km', example: 42.5 })
@IsOptional()
@Transform(toNumber)
@IsNumber()
@Min(0)
estimatedKm?: number;
@ApiPropertyOptional({ description: 'Actual distance travelled, in km', example: 44.1 })
@IsOptional()
@Transform(toNumber)
@IsNumber()
@Min(0)
exactKm?: number;
@ApiPropertyOptional({
type: String,
format: 'uuid',
description: 'Assigned vehicle (FK → vehicles.id). May be null until assigned.',
nullable: true,
})

View File

@@ -34,6 +34,12 @@ export class FirstMile extends BaseEntity {
@Column({ name: 'remaining_payment', type: 'numeric', precision: 14, scale: 2, default: 0 })
remainingPayment!: number;
@Column({ name: 'estimated_km', type: 'numeric', precision: 10, scale: 2, nullable: true })
estimatedKm?: number | null;
@Column({ name: 'exact_km', type: 'numeric', precision: 10, scale: 2, nullable: true })
exactKm?: number | null;
@Column({ name: 'vehicle_id', type: 'uuid', nullable: true })
vehicleId?: string | null;

View File

@@ -80,6 +80,8 @@ export class FirstMileService {
status: dto.status ?? 'PAYMENT_PENDING',
advancedPayment: dto.advancedPayment ?? 0,
remainingPayment: dto.remainingPayment ?? 0,
estimatedKm: dto.estimatedKm ?? null,
exactKm: dto.exactKm ?? null,
vehicleId: dto.vehicleId ?? null,
});
}
@@ -92,6 +94,8 @@ export class FirstMileService {
...(dto.status !== undefined ? { status: dto.status } : {}),
...(dto.advancedPayment !== undefined ? { advancedPayment: dto.advancedPayment } : {}),
...(dto.remainingPayment !== undefined ? { remainingPayment: dto.remainingPayment } : {}),
...(dto.estimatedKm !== undefined ? { estimatedKm: dto.estimatedKm } : {}),
...(dto.exactKm !== undefined ? { exactKm: dto.exactKm } : {}),
...(dto.vehicleId !== undefined ? { vehicleId: dto.vehicleId } : {}),
});