mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-07 22:25:42 +00:00
fix
This commit is contained in:
@@ -0,0 +1,25 @@
|
|||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Per-km haulage rate on a vehicle (mainly trucks) plus the currency it's
|
||||||
|
* quoted in (ETB | USD, default ETB).
|
||||||
|
*/
|
||||||
|
export class AddVehiclePricePerKm1990000000000 implements MigrationInterface {
|
||||||
|
name = "AddVehiclePricePerKm1990000000000";
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`
|
||||||
|
ALTER TABLE freight.vehicles
|
||||||
|
ADD COLUMN IF NOT EXISTS price_per_km numeric(14,2),
|
||||||
|
ADD COLUMN IF NOT EXISTS currency varchar(8) NOT NULL DEFAULT 'ETB'
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`
|
||||||
|
ALTER TABLE freight.vehicles
|
||||||
|
DROP COLUMN IF EXISTS price_per_km,
|
||||||
|
DROP COLUMN IF EXISTS currency
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -65,4 +65,12 @@ export class CreateVehicleDto {
|
|||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsUUID()
|
@IsUUID()
|
||||||
locationId?: string;
|
locationId?: string;
|
||||||
|
|
||||||
|
@IsOptional()
|
||||||
|
@IsNumber()
|
||||||
|
pricePerKm?: number;
|
||||||
|
|
||||||
|
@IsOptional()
|
||||||
|
@IsString()
|
||||||
|
currency?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,6 +89,14 @@ export class Vehicle extends BaseEntity {
|
|||||||
@Column({ name: 'location_id', type: 'uuid', nullable: true })
|
@Column({ name: 'location_id', type: 'uuid', nullable: true })
|
||||||
locationId?: string;
|
locationId?: string;
|
||||||
|
|
||||||
|
// --- Haulage pricing ---
|
||||||
|
@Column({ name: 'price_per_km', type: 'numeric', precision: 14, scale: 2, nullable: true })
|
||||||
|
pricePerKm?: number;
|
||||||
|
|
||||||
|
/** Currency for pricePerKm: ETB | USD */
|
||||||
|
@Column({ name: 'currency', type: 'varchar', length: 8, default: 'ETB' })
|
||||||
|
currency?: string;
|
||||||
|
|
||||||
// --- Compliance / expiry tracking ---
|
// --- Compliance / expiry tracking ---
|
||||||
@Column({ name: 'vin', type: 'varchar', nullable: true })
|
@Column({ name: 'vin', type: 'varchar', nullable: true })
|
||||||
vin?: string;
|
vin?: string;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
Group,
|
Group,
|
||||||
Modal,
|
Modal,
|
||||||
NumberInput,
|
NumberInput,
|
||||||
|
Radio,
|
||||||
Select,
|
Select,
|
||||||
MultiSelect,
|
MultiSelect,
|
||||||
SimpleGrid,
|
SimpleGrid,
|
||||||
@@ -293,6 +294,26 @@ const FleetFormDialog = ({
|
|||||||
// only by verification and never hand-edited.
|
// only by verification and never hand-edited.
|
||||||
const isDisabled = Boolean(field.disabled || field.faydaLocked);
|
const isDisabled = Boolean(field.disabled || field.faydaLocked);
|
||||||
|
|
||||||
|
if (field.type === "radio") {
|
||||||
|
return (
|
||||||
|
<Radio.Group
|
||||||
|
key={field.name}
|
||||||
|
label={field.label}
|
||||||
|
value={value == null ? "" : String(value)}
|
||||||
|
onChange={(next) =>
|
||||||
|
setValues((current) => ({ ...current, [field.name]: next }))
|
||||||
|
}
|
||||||
|
error={error}
|
||||||
|
>
|
||||||
|
<Group gap="lg" mt={6}>
|
||||||
|
{(field.options ?? []).map((o) => (
|
||||||
|
<Radio key={o.value} value={o.value} label={o.label} disabled={isDisabled} />
|
||||||
|
))}
|
||||||
|
</Group>
|
||||||
|
</Radio.Group>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (field.type === "select") {
|
if (field.type === "select") {
|
||||||
return (
|
return (
|
||||||
<Select
|
<Select
|
||||||
|
|||||||
@@ -29,6 +29,11 @@ const VEHICLE_AVAILABILITY_OPTIONS = [
|
|||||||
{ label: "Busy", value: "BUSY" },
|
{ label: "Busy", value: "BUSY" },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const CURRENCY_OPTIONS = [
|
||||||
|
{ label: "ETB", value: "ETB" },
|
||||||
|
{ label: "USD", value: "USD" },
|
||||||
|
];
|
||||||
|
|
||||||
export const vehiclesConfig: FleetResourceConfig = {
|
export const vehiclesConfig: FleetResourceConfig = {
|
||||||
slug: "vehicles",
|
slug: "vehicles",
|
||||||
label: "Vehicles",
|
label: "Vehicles",
|
||||||
@@ -84,6 +89,8 @@ export const vehiclesConfig: FleetResourceConfig = {
|
|||||||
{ name: "locationId", label: "Location", type: "select", dynamicOptions: "yards" },
|
{ name: "locationId", label: "Location", type: "select", dynamicOptions: "yards" },
|
||||||
{ name: "estimatedDistanceKm", label: "Estimated Distance (KM)", type: "number" },
|
{ name: "estimatedDistanceKm", label: "Estimated Distance (KM)", type: "number" },
|
||||||
{ name: "actualDistanceKm", label: "Actual Distance (KM)", type: "number" },
|
{ name: "actualDistanceKm", label: "Actual Distance (KM)", type: "number" },
|
||||||
|
{ name: "pricePerKm", label: "Price per KM", type: "number" },
|
||||||
|
{ name: "currency", label: "Currency", type: "radio", options: CURRENCY_OPTIONS },
|
||||||
{ name: "status", label: "Status", type: "select", required: true, options: VEHICLE_STATUS_OPTIONS },
|
{ name: "status", label: "Status", type: "select", required: true, options: VEHICLE_STATUS_OPTIONS },
|
||||||
{ name: "availability", label: "Availability", type: "select", required: true, options: VEHICLE_AVAILABILITY_OPTIONS },
|
{ name: "availability", label: "Availability", type: "select", required: true, options: VEHICLE_AVAILABILITY_OPTIONS },
|
||||||
{ name: "description", label: "Description", type: "textarea" },
|
{ name: "description", label: "Description", type: "textarea" },
|
||||||
@@ -102,6 +109,8 @@ export const vehiclesConfig: FleetResourceConfig = {
|
|||||||
locationId: null,
|
locationId: null,
|
||||||
estimatedDistanceKm: "",
|
estimatedDistanceKm: "",
|
||||||
actualDistanceKm: "",
|
actualDistanceKm: "",
|
||||||
|
pricePerKm: "",
|
||||||
|
currency: "ETB",
|
||||||
status: "ACTIVE",
|
status: "ACTIVE",
|
||||||
availability: "FREE",
|
availability: "FREE",
|
||||||
description: "",
|
description: "",
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export type ColumnFormat =
|
|||||||
| "entityLabel"
|
| "entityLabel"
|
||||||
| "rateLabel";
|
| "rateLabel";
|
||||||
|
|
||||||
export type FormFieldType = "text" | "number" | "boolean" | "date" | "email" | "select" | "multiselect" | "textarea";
|
export type FormFieldType = "text" | "number" | "boolean" | "date" | "email" | "select" | "multiselect" | "textarea" | "radio";
|
||||||
|
|
||||||
export interface ResourceColumn {
|
export interface ResourceColumn {
|
||||||
id: string;
|
id: string;
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ export interface Vehicle {
|
|||||||
/** Odometer-derived distances (API sends numeric strings; coerce with Number). */
|
/** Odometer-derived distances (API sends numeric strings; coerce with Number). */
|
||||||
estimatedDistanceKm?: number | null;
|
estimatedDistanceKm?: number | null;
|
||||||
actualDistanceKm?: number | null;
|
actualDistanceKm?: number | null;
|
||||||
|
/** Haulage rate per km + its currency (ETB | USD). */
|
||||||
|
pricePerKm?: number | null;
|
||||||
|
currency?: string | null;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user