+
setFilters(prev => ({ ...prev, search: e.target.value }))}
className="max-w-xs"
+ disabled={loading}
/>
{/* Purchase Orders Table */}
-
- Recent Purchase Orders
+
+ Purchase Orders & Receivings
+
+ {loading ? (
+
+ ) : (
+ `${summary?.order_count.toLocaleString()} orders`
+ )}
+
-
+ Type
+
+ !loading && handleSort('vendor_name')} disabled={loading}>
+ Vendor
- handleSort('vendor_name')}>
- Vendor
+ !loading && handleSort('order_date')} disabled={loading}>
+ Order Date
+ Rec'd Date
- handleSort('order_date')}>
- Order Date
-
-
-
- handleSort('status')}>
- Status
+ !loading && handleSort('status')} disabled={loading}>
+ Status
+ Notes
Total Items
Total Quantity
- handleSort('total_cost')}>
- Total Cost
+ !loading && handleSort('total_cost')} disabled={loading}>
+ Total Cost
Received
- handleSort('fulfillment_rate')}>
- Fulfillment
+ !loading && handleSort('fulfillment_rate')} disabled={loading}>
+ Fulfillment
- {purchaseOrders.map((po) => (
-
- {po.id}
- {po.vendor_name}
- {new Date(po.order_date).toLocaleDateString()}
- {getStatusBadge(po.status)}
- {po.total_items.toLocaleString()}
- {po.total_quantity.toLocaleString()}
- {formatCurrency(po.total_cost)}
- {po.total_received.toLocaleString()}
-
- {po.fulfillment_rate === null ? 'N/A' : formatPercent(po.fulfillment_rate)}
-
-
- ))}
- {!purchaseOrders.length && (
+ {loading ? (
+ // Skeleton rows for loading state
+ Array(50).fill(0).map((_, index) => (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ))
+ ) : purchaseOrders.length > 0 ? (
+ purchaseOrders.map((po) => {
+ // Determine row styling based on record type
+ let rowClassName = 'border-l-4 border-l-gray-300'; // Default
+
+ if (po.record_type === 'po_with_receiving') {
+ rowClassName = 'border-l-4 border-l-green-500';
+ } else if (po.record_type === 'po_only') {
+ rowClassName = 'border-l-4 border-l-blue-500';
+ } else if (po.record_type === 'receiving_only') {
+ rowClassName = 'border-l-4 border-l-amber-500';
+ }
+
+ return (
+
+
+ {po.id}
+
+
+ {getRecordTypeIndicator(po.record_type)}
+
+ {po.vendor_name}
+ {po.order_date ? new Date(po.order_date).toLocaleDateString() : ''}
+ {po.receiving_date ? new Date(po.receiving_date).toLocaleDateString() : ''}
+ {getStatusBadge(po.status, po.record_type)}
+
+ {po.short_note ? (
+
+
+
+
+ {po.short_note}
+
+
+ {po.short_note}
+
+
+
+ ) : 'N/A'}
+
+ {po.total_items.toLocaleString()}
+ {po.total_quantity.toLocaleString()}
+ {formatCurrency(po.total_cost)}
+ {po.total_received.toLocaleString()}
+
+ {po.fulfillment_rate === null ? 'N/A' : formatPercent(po.fulfillment_rate)}
+
+
+ );
+ })
+ ) : (
-
+
No purchase orders found
@@ -679,6 +1360,6 @@ export default function PurchaseOrders() {
)}
-
+
);
}
\ No newline at end of file
diff --git a/inventory/src/types/status-codes.ts b/inventory/src/types/status-codes.ts
index 1adfe06..3aaeefe 100644
--- a/inventory/src/types/status-codes.ts
+++ b/inventory/src/types/status-codes.ts
@@ -75,7 +75,7 @@ export function getPurchaseOrderStatusVariant(status: number): 'default' | 'seco
export function getReceivingStatusVariant(status: number): 'default' | 'secondary' | 'destructive' | 'outline' {
if (isReceivingCanceled(status)) return 'destructive';
- if (status === ReceivingStatus.Paid) return 'default';
+ if (status === ReceivingStatus.Paid || status === ReceivingStatus.FullReceived) return 'default';
if (status >= ReceivingStatus.PartialReceived) return 'secondary';
return 'outline';
}
\ No newline at end of file