feat(suppliers): show resolved supplier name on the PO list page

This commit is contained in:
DEls 2026-09-11 18:18:37 +02:00
parent 1c3adede0d
commit cdaa4493cf
2 changed files with 13 additions and 4 deletions

View file

@ -9,7 +9,7 @@ export default async function PurchasingPage() {
const pb = await pbAdmin();
const [pos, items, dns, sites, receivedAll] = await Promise.all([
pb.collection("purchase_orders").getFullList({ expand: "site" }),
pb.collection("purchase_orders").getFullList({ expand: "site,supplier_ref" }),
pb.collection("purchase_order_items").getFullList(),
// Only used here to compute each PO's own delivery-note count and
// pending-DN badge. The needs-review queue itself (the DN triage
@ -98,11 +98,16 @@ export default async function PurchasingPage() {
p.expand as { site?: { name?: string; project_code?: string } } | undefined
)?.site;
const projectCode = site?.project_code ?? "";
const supplierRef = (
p.expand as { supplier_ref?: { name?: string } } | undefined
)?.supplier_ref;
return {
id: p.id,
poNumber: p.purchase_order_number,
supplier: p.supplier,
supplierRefId: p.supplier_ref ?? null,
supplierRefName: supplierRef?.name ?? null,
projectCode,
projectName: site?.name ?? projectCode,
requiredByDate: p.required_by_date,

View file

@ -26,7 +26,7 @@ import {
SelectValue,
} from "@/components/ui/select";
import { Pagination } from "@/components/ui/pagination";
import { cn, formatCurrency, formatNumber, isUnknownSupplier } from "@/lib/utils";
import { cn, formatCurrency, formatNumber } from "@/lib/utils";
const PAGE_SIZE = 25;
const PO_BASE = "/dashboard/financial/purchase-orders";
@ -37,6 +37,10 @@ export interface PoRow {
projectCode: string;
projectName: string;
supplier: string;
/** Resolved supplier record id, if a match was made at upload or later. */
supplierRefId: string | null;
/** Display name of the linked supplier (mirrors supplierRefId's record). */
supplierRefName: string | null;
requiredByDate: string;
orderedBy: string;
totalValue: number;
@ -323,7 +327,7 @@ function PoListItem({ po }: { po: PoRow }) {
<div className="min-w-0 flex-1">
<div className="flex flex-wrap items-baseline gap-x-3 gap-y-1">
<span className="font-mono text-sm font-semibold">{po.poNumber}</span>
{isUnknownSupplier(po.supplier) ? (
{!po.supplierRefId ? (
<Badge
variant="outline"
className="gap-1 border-amber-500/40 bg-amber-500/15 text-amber-700 dark:text-amber-300"
@ -333,7 +337,7 @@ function PoListItem({ po }: { po: PoRow }) {
</Badge>
) : (
<span className="truncate text-sm text-foreground">
{po.supplier}
{po.supplierRefName}
</span>
)}
<Badge variant="outline" className="font-mono text-xs">