| @@ -67,12 +67,23 @@ const GoodsReceiptStatusNew: React.FC = () => { | |||||
| return selectedDate.format('YYYY-MM-DD'); | return selectedDate.format('YYYY-MM-DD'); | ||||
| }, [selectedDate]); | }, [selectedDate]); | ||||
| // Sort rows by supplier code alphabetically (A -> Z) | |||||
| const sortedData = useMemo(() => { | |||||
| return [...data].sort((a, b) => { | |||||
| const codeA = (a.supplierCode || '').toUpperCase(); | |||||
| const codeB = (b.supplierCode || '').toUpperCase(); | |||||
| if (codeA < codeB) return -1; | |||||
| if (codeA > codeB) return 1; | |||||
| return 0; | |||||
| }); | |||||
| }, [data]); | |||||
| const totalStatistics = useMemo(() => { | const totalStatistics = useMemo(() => { | ||||
| // Overall statistics should count ALL POs, including those hidden from the table | // Overall statistics should count ALL POs, including those hidden from the table | ||||
| const totalReceived = data.reduce((sum, row) => sum + (row.noOfOrdersReceivedAtDock || 0), 0); | |||||
| const totalExpected = data.reduce((sum, row) => sum + (row.expectedNoOfDelivery || 0), 0); | |||||
| const totalReceived = sortedData.reduce((sum, row) => sum + (row.noOfOrdersReceivedAtDock || 0), 0); | |||||
| const totalExpected = sortedData.reduce((sum, row) => sum + (row.expectedNoOfDelivery || 0), 0); | |||||
| return { received: totalReceived, expected: totalExpected }; | return { received: totalReceived, expected: totalExpected }; | ||||
| }, [data]); | |||||
| }, [sortedData]); | |||||
| type StatusKey = 'pending' | 'receiving' | 'accepted'; | type StatusKey = 'pending' | 'receiving' | 'accepted'; | ||||
| @@ -205,7 +216,7 @@ const GoodsReceiptStatusNew: React.FC = () => { | |||||
| </TableRow> | </TableRow> | ||||
| </TableHead> | </TableHead> | ||||
| <TableBody> | <TableBody> | ||||
| {data.length === 0 ? ( | |||||
| {sortedData.length === 0 ? ( | |||||
| <TableRow> | <TableRow> | ||||
| <TableCell colSpan={4} align="center"> | <TableCell colSpan={4} align="center"> | ||||
| <Typography variant="body2" color="text.secondary"> | <Typography variant="body2" color="text.secondary"> | ||||
| @@ -214,7 +225,7 @@ const GoodsReceiptStatusNew: React.FC = () => { | |||||
| </TableCell> | </TableCell> | ||||
| </TableRow> | </TableRow> | ||||
| ) : ( | ) : ( | ||||
| data | |||||
| sortedData | |||||
| .filter((row) => !row.hideFromDashboard) // hide completed/rejected POs from table only | .filter((row) => !row.hideFromDashboard) // hide completed/rejected POs from table only | ||||
| .map((row, index) => ( | .map((row, index) => ( | ||||
| <TableRow | <TableRow | ||||