This commit is contained in:
Marshal
2026-07-20 10:52:20 +00:00
committed by Hagernesh
parent 0727de0f4d
commit 540f4a1ff6
7 changed files with 64 additions and 23 deletions

View File

@@ -400,7 +400,9 @@ export default function TrainScheduleV2ListPage() {
cell: ({ row }) => (
<Group gap={6} wrap="nowrap">
<MetricChip value={row.original.bookingsCount} label="bkg" />
<MetricChip value={row.original.wagonCount} label="wgn" />
{/* Wagon SLOTS this schedule's bookings occupy — not the coupled
consist. A built train shows 0 here until bookings are allocated. */}
<MetricChip value={row.original.wagonCount} label="wgn used" />
<MetricChip value={`${row.original.totalWeightTons}T`} label="" subtle />
</Group>
),
@@ -950,7 +952,7 @@ function ScheduleCard({
</Group>
<Group gap={6} wrap="nowrap">
<MetricChip value={schedule.bookingsCount} label="bkg" />
<MetricChip value={schedule.wagonCount} label="wgn" />
<MetricChip value={schedule.wagonCount} label="wgn used" />
<MetricChip value={`${schedule.totalWeightTons}T`} label="" subtle />
</Group>
</Group>

View File

@@ -158,7 +158,14 @@ const BUSINESS_LICENSE_DOC_CODES = new Set([
"business_license",
"commercial_license",
"investment_license",
"trade_license",
]);
// Licences carried from the company profile are suffixed per file
// (`business_license_1`), so match on the stripped base code too.
const isBusinessLicenseCode = (code: string): boolean =>
BUSINESS_LICENSE_DOC_CODES.has(code) ||
BUSINESS_LICENSE_DOC_CODES.has(code.replace(/_\d+$/, ""));
const PROFILE_DOC_CODES = new Set([
"tin_certificate",
"national_id",
@@ -183,6 +190,15 @@ const KNOWN_FILE_LABELS: Record<string, string> = {
function fileLabel(f: AnyFile) {
if (KNOWN_FILE_LABELS[f.code]) return KNOWN_FILE_LABELS[f.code];
// Profile documents carried onto the contract are suffixed per file
// (`business_license_2`) — label them from the base code, numbered.
const base = f.code.replace(/_\d+$/, "");
if (KNOWN_FILE_LABELS[base]) {
const n = f.code.slice(base.length + 1);
return n && n !== "1"
? `${KNOWN_FILE_LABELS[base]} ${n}`
: KNOWN_FILE_LABELS[base];
}
// Ad-hoc uploads carry a generated code (custom_<ts>_<i>) — use the filename.
if (f.code.startsWith("custom_")) return f.name;
return f.code
@@ -245,7 +261,7 @@ export function DocumentsTab({ booking }: { booking: Freight.IBooking }) {
const contractFiles = (contract?.files ?? []) as AnyFile[];
const contractPdf = contractFiles.find((f) => f.code === "contract");
const licenseFiles = contractFiles.filter((f) =>
BUSINESS_LICENSE_DOC_CODES.has(f.code),
isBusinessLicenseCode(f.code),
);
const profileFiles = contractFiles.filter((f) => PROFILE_DOC_CODES.has(f.code));
@@ -428,7 +444,7 @@ export function DocumentsTab({ booking }: { booking: Freight.IBooking }) {
title={fileLabel(f)}
meta={
PROFILE_DOC_CODES.has(f.code) ||
BUSINESS_LICENSE_DOC_CODES.has(f.code)
isBusinessLicenseCode(f.code)
? "From your company profile"
: f.name
}

View File

@@ -26,6 +26,14 @@ const LABEL_BY_CODE = new Map<string, string>([
export function labelForDocCode(code: string): string {
const known = LABEL_BY_CODE.get(code);
if (known) return known;
// Profile documents carried onto a contract are suffixed per file
// ("business_license_2") — label from the base code, numbered past the first.
const base = code.replace(/_\d+$/, "");
const baseLabel = LABEL_BY_CODE.get(base);
if (baseLabel) {
const n = code.slice(base.length + 1);
return n && n !== "1" ? `${baseLabel} ${n}` : baseLabel;
}
return code
.replace(/^custom_\d+_\d+$/, "Additional document")
.replace(/[_-]+/g, " ")

View File

@@ -134,8 +134,15 @@ const BUSINESS_LICENSE_DOC_CODES = new Set([
"business_license",
"commercial_license",
"investment_license",
"trade_license",
]);
// Licences carried from the company profile are suffixed per file
// (`business_license_1`), so match on the stripped base code too.
const isBusinessLicenseCode = (code: string): boolean =>
BUSINESS_LICENSE_DOC_CODES.has(code) ||
BUSINESS_LICENSE_DOC_CODES.has(code.replace(/_\d+$/, ""));
// Onboarding / company-profile document codes seeded in file-upload-settings.
// These get attached to the contract at creation and belong under "Profile
// documents" rather than the clearance set.
@@ -196,7 +203,7 @@ function groupContractDocuments(
// The generated contract PDF lives in the contract list / home rows, not
// here. Signature images are baked into that PDF — skip both.
if (f.code === "contract" || f.code.startsWith("signature_")) continue;
else if (BUSINESS_LICENSE_DOC_CODES.has(f.code)) businessLicense.push(f);
else if (isBusinessLicenseCode(f.code)) businessLicense.push(f);
else if (PROFILE_DOC_CODES.has(f.code)) profile.push(f);
else if (includeClearance && isClearanceCode(f.code)) clearance.push(f);
else other.push(f);