+
Purchase Orders
+
+ {/* Metrics Overview */}
+
+
+
+ Total Orders
+
+
+ {receivingStatus?.order_count || 0}
+
+
+
+
+ Total Value
+
+
+
+ ${(receivingStatus?.total_value || 0).toFixed(2)}
+
+
+
+
+
+ Fulfillment Rate
+
+
+
+ {((receivingStatus?.fulfillment_rate || 0) * 100).toFixed(1)}%
+
+
+
+
+
+ Avg Cost per PO
+
+
+
+ ${(receivingStatus?.avg_cost || 0).toFixed(2)}
+
+
+
+
+
+ {/* Filters */}
+
+
+ setFilters(prev => ({ ...prev, search: e.target.value }))}
+ className="h-8 w-[300px]"
+ />
+
+
+
+
+
+
+
+ {/* Purchase Orders Table */}
+
+
+ Recent Purchase Orders
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Total Items
+ Total Quantity
+
+
+
+ Received
+
+
+
+
+
+
+ {purchaseOrders.map((po) => (
+
+ {po.id}
+ {po.vendor_name}
+ {new Date(po.order_date).toLocaleDateString()}
+ {getStatusBadge(po.status)}
+ {po.total_items}
+ {po.total_quantity}
+ ${po.total_cost.toFixed(2)}
+ {po.total_received}
+ {(po.fulfillment_rate * 100).toFixed(1)}%
+
+ ))}
+ {!purchaseOrders.length && (
+
+
+ No purchase orders found
+
+
+ )}
+
+
+
+
+
+ {/* Pagination */}
+ {pagination.pages > 1 && (
+
+
+
+
+ setPage(p => Math.max(1, p - 1))}
+ disabled={page === 1}
+ />
+
+ {Array.from({ length: pagination.pages }, (_, i) => i + 1).map((p) => (
+
+ setPage(p)}
+ isActive={p === page}
+ >
+ {p}
+
+
+ ))}
+
+ setPage(p => Math.min(pagination.pages, p + 1))}
+ disabled={page === pagination.pages}
+ />
+
+
+
+
+ )}
+
+ {/* Vendor Performance */}
+
+
+ Vendor Performance
+
+
+
+
+
+ Vendor
+ Total Orders
+ Avg Delivery Days
+ Fulfillment Rate
+ Avg Unit Cost
+ Total Spend
+
+
+
+ {vendorMetrics.map((vendor) => (
+
+ {vendor.vendor_name}
+ {vendor.total_orders}
+ {vendor.avg_delivery_days.toFixed(1)}
+ {(vendor.fulfillment_rate * 100).toFixed(1)}%
+ ${vendor.avg_unit_cost.toFixed(2)}
+ ${vendor.total_spend.toFixed(2)}
+
+ ))}
+
+
+
+
+
+ {/* Cost Analysis */}
+
+
+ Cost Analysis by Category
+
+
+
+
+
+ Category
+ Total Spend
+
+
+
+ {costAnalysis?.total_spend_by_category?.map((category) => (
+
+ {category.category}
+ ${category.total_spend.toFixed(2)}
+
+ )) || (
+
+
+ No cost analysis data available
+
+
+ )}
+
+
+
+
+
+ );
+}
\ No newline at end of file