|
|
@@ -15,6 +15,7 @@ import { |
|
|
TableHead, |
|
|
TableHead, |
|
|
TableRow, |
|
|
TableRow, |
|
|
Paper, |
|
|
Paper, |
|
|
|
|
|
Checkbox, |
|
|
TablePagination, |
|
|
TablePagination, |
|
|
Modal, |
|
|
Modal, |
|
|
} from "@mui/material"; |
|
|
} from "@mui/material"; |
|
|
@@ -490,25 +491,21 @@ const PickExecution: React.FC<Props> = ({ filterArgs }) => { |
|
|
console.log(`✅ Stock out line already exists for line ${matchingLot.pickOrderLineId}`); |
|
|
console.log(`✅ Stock out line already exists for line ${matchingLot.pickOrderLineId}`); |
|
|
existsCount++; |
|
|
existsCount++; |
|
|
} else { |
|
|
} else { |
|
|
const stockOutLineData: CreateStockOutLine = { |
|
|
|
|
|
consoCode: matchingLot.pickOrderConsoCode, |
|
|
|
|
|
pickOrderLineId: matchingLot.pickOrderLineId, |
|
|
|
|
|
inventoryLotLineId: matchingLot.lotId, |
|
|
|
|
|
qty: 0.0 |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
const stockOutLineUpdate = await updateStockOutLineStatus({ |
|
|
|
|
|
id: selectedLotForQr.stockOutLineId, |
|
|
|
|
|
status: 'checked', |
|
|
|
|
|
qty: selectedLotForQr.stockOutLineQty || 0 |
|
|
|
|
|
}); |
|
|
|
|
|
console.log(`Create stock out line result for line ${matchingLot.pickOrderLineId}:`,stockOutLineUpdate); |
|
|
|
|
|
|
|
|
console.log(`Creating stock out line for pick order line ${matchingLot.pickOrderLineId}:`, stockOutLineData); |
|
|
|
|
|
const result = await createStockOutLine(stockOutLineData); |
|
|
|
|
|
console.log(`Create stock out line result for line ${matchingLot.pickOrderLineId}:`, result); |
|
|
|
|
|
|
|
|
|
|
|
if (result && result.code === "EXISTS") { |
|
|
|
|
|
|
|
|
if (stockOutLineUpdate && stockOutLineUpdate.code === "EXISTS") { |
|
|
console.log(`✅ Stock out line already exists for line ${matchingLot.pickOrderLineId}`); |
|
|
console.log(`✅ Stock out line already exists for line ${matchingLot.pickOrderLineId}`); |
|
|
existsCount++; |
|
|
existsCount++; |
|
|
} else if (result && result.code === "SUCCESS") { |
|
|
|
|
|
|
|
|
} else if (stockOutLineUpdate && stockOutLineUpdate.code === "SUCCESS") { |
|
|
console.log(`✅ Stock out line created successfully for line ${matchingLot.pickOrderLineId}`); |
|
|
console.log(`✅ Stock out line created successfully for line ${matchingLot.pickOrderLineId}`); |
|
|
successCount++; |
|
|
successCount++; |
|
|
} else { |
|
|
} else { |
|
|
console.error(`❌ Failed to create stock out line for line ${matchingLot.pickOrderLineId}:`, result); |
|
|
|
|
|
|
|
|
console.error(`❌ Failed to create stock out line for line ${matchingLot.pickOrderLineId}:`, stockOutLineUpdate); |
|
|
errorCount++; |
|
|
errorCount++; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@@ -567,16 +564,15 @@ const PickExecution: React.FC<Props> = ({ filterArgs }) => { |
|
|
const lotId = selectedLotForQr.lotId; |
|
|
const lotId = selectedLotForQr.lotId; |
|
|
|
|
|
|
|
|
// Create stock out line |
|
|
// Create stock out line |
|
|
const stockOutLineData: CreateStockOutLine = { |
|
|
|
|
|
consoCode: selectedLotForQr.pickOrderConsoCode, // ✅ Use pickOrderConsoCode instead of pickOrderCode |
|
|
|
|
|
pickOrderLineId: selectedLotForQr.pickOrderLineId, |
|
|
|
|
|
inventoryLotLineId: selectedLotForQr.lotId, |
|
|
|
|
|
qty: 0.0 |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
await createStockOutLine(stockOutLineData); |
|
|
|
|
|
console.log("Stock out line created successfully!"); |
|
|
|
|
|
|
|
|
const stockOutLineUpdate = await updateStockOutLineStatus({ |
|
|
|
|
|
id: selectedLotForQr.stockOutLineId, |
|
|
|
|
|
status: 'checked', |
|
|
|
|
|
qty: selectedLotForQr.stockOutLineQty || 0 |
|
|
|
|
|
}); |
|
|
|
|
|
console.log("Stock out line updated successfully!"); |
|
|
|
|
|
|
|
|
// Close modal |
|
|
// Close modal |
|
|
setQrModalOpen(false); |
|
|
setQrModalOpen(false); |
|
|
@@ -907,30 +903,12 @@ const PickExecution: React.FC<Props> = ({ filterArgs }) => { |
|
|
}, []); |
|
|
}, []); |
|
|
|
|
|
|
|
|
// Pagination data with sorting by routerIndex |
|
|
// Pagination data with sorting by routerIndex |
|
|
const paginatedData = useMemo(() => { |
|
|
|
|
|
// ✅ Sort by routerIndex first, then by other criteria |
|
|
|
|
|
const sortedData = [...combinedLotData].sort((a, b) => { |
|
|
|
|
|
const aIndex = a.routerIndex || 0; |
|
|
|
|
|
const bIndex = b.routerIndex || 0; |
|
|
|
|
|
|
|
|
|
|
|
// Primary sort: by routerIndex |
|
|
|
|
|
if (aIndex !== bIndex) { |
|
|
|
|
|
return aIndex - bIndex; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Secondary sort: by pickOrderCode if routerIndex is the same |
|
|
|
|
|
if (a.pickOrderCode !== b.pickOrderCode) { |
|
|
|
|
|
return a.pickOrderCode.localeCompare(b.pickOrderCode); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Tertiary sort: by lotNo if everything else is the same |
|
|
|
|
|
return (a.lotNo || '').localeCompare(b.lotNo || ''); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const startIndex = paginationController.pageNum * paginationController.pageSize; |
|
|
|
|
|
const endIndex = startIndex + paginationController.pageSize; |
|
|
|
|
|
return sortedData.slice(startIndex, endIndex); |
|
|
|
|
|
}, [combinedLotData, paginationController]); |
|
|
|
|
|
|
|
|
// Remove the sorting logic and just do pagination |
|
|
|
|
|
const paginatedData = useMemo(() => { |
|
|
|
|
|
const startIndex = paginationController.pageNum * paginationController.pageSize; |
|
|
|
|
|
const endIndex = startIndex + paginationController.pageSize; |
|
|
|
|
|
return combinedLotData.slice(startIndex, endIndex); // ✅ No sorting needed |
|
|
|
|
|
}, [combinedLotData, paginationController]); |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<FormProvider {...formProps}> |
|
|
<FormProvider {...formProps}> |
|
|
@@ -980,7 +958,7 @@ const PickExecution: React.FC<Props> = ({ filterArgs }) => { |
|
|
<strong>{t("Shop Name")}:</strong> {fgPickOrders[0].shopName || '-'} |
|
|
<strong>{t("Shop Name")}:</strong> {fgPickOrders[0].shopName || '-'} |
|
|
</Typography> |
|
|
</Typography> |
|
|
<Typography variant="subtitle1"> |
|
|
<Typography variant="subtitle1"> |
|
|
<strong>{t("Delivery Date")}:</strong> {(fgPickOrders[0].deliveryDate || '-').split('T')[0]} |
|
|
|
|
|
|
|
|
<strong>{t("Pick Order Code")}:</strong>{fgPickOrders[0].pickOrderCode || '-'} |
|
|
</Typography> |
|
|
</Typography> |
|
|
<Typography variant="subtitle1"> |
|
|
<Typography variant="subtitle1"> |
|
|
<strong>{t("Departure Time")}:</strong> {fgPickOrders[0].DepartureTime || '-'} |
|
|
<strong>{t("Departure Time")}:</strong> {fgPickOrders[0].DepartureTime || '-'} |
|
|
@@ -1015,6 +993,7 @@ const PickExecution: React.FC<Props> = ({ filterArgs }) => { |
|
|
{/* <TableCell align="right">{t("Original Available Qty")}</TableCell> */} |
|
|
{/* <TableCell align="right">{t("Original Available Qty")}</TableCell> */} |
|
|
<TableCell align="center">{t("Lot Actual Pick Qty")}</TableCell> |
|
|
<TableCell align="center">{t("Lot Actual Pick Qty")}</TableCell> |
|
|
{/* <TableCell align="right">{t("Remaining Available Qty")}</TableCell> */} |
|
|
{/* <TableCell align="right">{t("Remaining Available Qty")}</TableCell> */} |
|
|
|
|
|
<TableCell align="right">{t("Finish Scan?")}</TableCell> |
|
|
<TableCell align="center">{t("Action")}</TableCell> |
|
|
<TableCell align="center">{t("Action")}</TableCell> |
|
|
</TableRow> |
|
|
</TableRow> |
|
|
</TableHead> |
|
|
</TableHead> |
|
|
@@ -1041,7 +1020,7 @@ const PickExecution: React.FC<Props> = ({ filterArgs }) => { |
|
|
> |
|
|
> |
|
|
<TableCell> |
|
|
<TableCell> |
|
|
<Typography variant="body2" fontWeight="bold"> |
|
|
<Typography variant="body2" fontWeight="bold"> |
|
|
{lot.routerIndex || index + 1} |
|
|
|
|
|
|
|
|
{index + 1} |
|
|
</Typography> |
|
|
</Typography> |
|
|
</TableCell> |
|
|
</TableCell> |
|
|
<TableCell> |
|
|
<TableCell> |
|
|
@@ -1070,7 +1049,7 @@ const PickExecution: React.FC<Props> = ({ filterArgs }) => { |
|
|
const inQty = lot.inQty || 0; |
|
|
const inQty = lot.inQty || 0; |
|
|
const outQty = lot.outQty || 0; |
|
|
const outQty = lot.outQty || 0; |
|
|
const result = inQty - outQty; |
|
|
const result = inQty - outQty; |
|
|
return result.toLocaleString(); |
|
|
|
|
|
|
|
|
return result.toLocaleString()+'('+lot.stockUnit+')'; |
|
|
})()} |
|
|
})()} |
|
|
</TableCell> |
|
|
</TableCell> |
|
|
<TableCell align="center"> |
|
|
<TableCell align="center"> |
|
|
@@ -1102,7 +1081,7 @@ const PickExecution: React.FC<Props> = ({ filterArgs }) => { |
|
|
{t("Scan")} |
|
|
{t("Scan")} |
|
|
</Button> |
|
|
</Button> |
|
|
) : ( |
|
|
) : ( |
|
|
// ✅ When stockOutLineId exists, show TextField + Issue button |
|
|
|
|
|
|
|
|
|
|
|
<Stack direction="row" spacing={1} alignItems="center"> |
|
|
<Stack direction="row" spacing={1} alignItems="center"> |
|
|
<TextField |
|
|
<TextField |
|
|
type="number" |
|
|
type="number" |
|
|
@@ -1162,6 +1141,19 @@ const PickExecution: React.FC<Props> = ({ filterArgs }) => { |
|
|
return result.toLocaleString(); |
|
|
return result.toLocaleString(); |
|
|
})()} |
|
|
})()} |
|
|
</TableCell> */} |
|
|
</TableCell> */} |
|
|
|
|
|
<TableCell align="center"> |
|
|
|
|
|
<Checkbox |
|
|
|
|
|
checked={lot.stockOutLineStatus?.toLowerCase() !== 'pending'} |
|
|
|
|
|
disabled={true} |
|
|
|
|
|
readOnly={true} |
|
|
|
|
|
sx={{ |
|
|
|
|
|
color: lot.stockOutLineStatus?.toLowerCase() !== 'pending' ? 'success.main' : 'grey.400', |
|
|
|
|
|
'&.Mui-checked': { |
|
|
|
|
|
color: 'success.main', |
|
|
|
|
|
}, |
|
|
|
|
|
}} |
|
|
|
|
|
/> |
|
|
|
|
|
</TableCell> |
|
|
<TableCell align="center"> |
|
|
<TableCell align="center"> |
|
|
<Stack direction="column" spacing={1} alignItems="center"> |
|
|
<Stack direction="column" spacing={1} alignItems="center"> |
|
|
<Button |
|
|
<Button |
|
|
|