import { PurchaseOrderFulfillmentForm } from "@/components/purchase-order-fulfillment-form"; import { PurchaseOrderForm } from "@/components/purchase-order-form"; import { formatCurrency, formatDate } from "@/lib/format"; import { getLowStockParts, getOrderItemOptions, getPurchaseOrderLineDetails, getPurchaseOrders, getVendors } from "@/lib/repository"; export default function PurchaseOrdersPage() { const vendors = getVendors(); const items = getOrderItemOptions(); const orders = getPurchaseOrders(); const orderLines = getPurchaseOrderLineDetails(); const lowStockParts = getLowStockParts(); return (

Create Purchase Order

Build the PO from real inventory items so receipts, costing, and restocking stay relational.

Purchase Orders

Review vendor demand, total value, and receiving progress without nested scrolling.

{orders.length === 0 ? ( ) : ( orders.map((order) => ( )) )}
OrderVendorStatusTotalQty ProgressCreated
No purchase orders yet.
{order.orderNumber} {order.vendorName} {order.status} {formatCurrency(order.totalAmount)} {order.fulfilledQuantity} / {order.orderedQuantity} {formatDate(order.createdAt)}

Receiving Flow

Receive relational order lines directly by entering quantities against the remaining balance on each line.

{orders.filter((order) => order.status !== "received").length === 0 ? (

No open or partial purchase orders need receiving right now.

) : ( orders .filter((order) => order.status !== "received") .map((order) => (

{order.orderNumber}

{order.vendorName} • {order.fulfilledQuantity} / {order.orderedQuantity} received • {formatCurrency(order.totalAmount)}

line.purchaseOrderId === order.id && line.remainingQuantity > 0)} />
)) )}

Restock Recommendations

Use this list to plan the next purchase order from items already below target.

{lowStockParts.length === 0 ? ( ) : ( lowStockParts.map((part) => ( )) )}
SKUNameOn HandReorder PointSuggested QtyLast Vendor
No parts currently need restocking.
{part.sku} {part.name} {part.quantityOnHand} {part.unitOfMeasure} {part.reorderPoint} {part.suggestedReorderQuantity} {part.preferredVendorName || "-"}
); }