|
|
|
@@ -32,6 +32,7 @@ import { |
|
|
|
Radio, |
|
|
|
} from "@mui/material"; |
|
|
|
import { useTranslation } from "react-i18next"; |
|
|
|
import { submitDialogWithWarning } from "../Swal/CustomAlerts"; |
|
|
|
// import InputDataGrid, { TableRow } from "../InputDataGrid/InputDataGrid"; |
|
|
|
import { |
|
|
|
GridColDef, |
|
|
|
@@ -443,42 +444,54 @@ const PoDetail: React.FC<Props> = ({ po, warehouse, printerCombo }) => { |
|
|
|
[rows] |
|
|
|
); |
|
|
|
|
|
|
|
const handleStart = useCallback( |
|
|
|
() => { |
|
|
|
setTimeout(async () => { |
|
|
|
// post stock in line |
|
|
|
const currentDnNo = dnFormProps.watch("dnNo"); |
|
|
|
const oldId = row.id; |
|
|
|
const handleStart = useCallback( |
|
|
|
() => { |
|
|
|
const orderQty = Number(row?.qty) ?? 0; |
|
|
|
const acceptedQty = Number(polInputList[rowIndex].dnQty); |
|
|
|
if (isNaN(acceptedQty) || acceptedQty <= 0) { alert("來貨數量必須大於0!"); return; } // Temp check, need update |
|
|
|
|
|
|
|
if (isNaN(acceptedQty) || acceptedQty <= 0) { |
|
|
|
alert("來貨數量必須大於0!"); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (!Number.isInteger(acceptedQty)) { |
|
|
|
alert("來貨數量必須是整數(不能有小數)!"); |
|
|
|
return; |
|
|
|
} |
|
|
|
const postData = { |
|
|
|
dnNo: dnFormProps.watch("dnNo"), |
|
|
|
receiptDate: outputDateStringToInputDateString(dnFormProps.watch("receiptDate")), |
|
|
|
itemId: row.itemId, |
|
|
|
itemNo: row.itemNo, |
|
|
|
itemName: row.itemName, |
|
|
|
// purchaseOrderId: row.purchaseOrderId, |
|
|
|
purchaseOrderLineId: row.id, |
|
|
|
acceptedQty: acceptedQty, |
|
|
|
productLotNo: polInputList[rowIndex].lotNo || '', |
|
|
|
// acceptedQty: secondReceiveQty || 0, |
|
|
|
// acceptedQty: row.acceptedQty, |
|
|
|
|
|
|
|
const doSubmit = () => { |
|
|
|
setTimeout(async () => { |
|
|
|
const currentDnNo = dnFormProps.watch("dnNo"); |
|
|
|
const postData = { |
|
|
|
dnNo: dnFormProps.watch("dnNo"), |
|
|
|
receiptDate: outputDateStringToInputDateString(dnFormProps.watch("receiptDate")), |
|
|
|
itemId: row.itemId, |
|
|
|
itemNo: row.itemNo, |
|
|
|
itemName: row.itemName, |
|
|
|
purchaseOrderLineId: row.id, |
|
|
|
acceptedQty: acceptedQty, |
|
|
|
productLotNo: polInputList[rowIndex].lotNo || '', |
|
|
|
}; |
|
|
|
const res = await createStockInLine(postData); |
|
|
|
if (res) { |
|
|
|
fetchPoDetail(selectedPoId.toString(), true); |
|
|
|
} |
|
|
|
console.log(res); |
|
|
|
}, 200); |
|
|
|
}; |
|
|
|
// if (secondReceiveQty === 0) return |
|
|
|
const res = await createStockInLine(postData); |
|
|
|
if (res) { |
|
|
|
fetchPoDetail(selectedPoId.toString(), true); |
|
|
|
//dnFormProps.setValue("dnNo", currentDnNo); |
|
|
|
|
|
|
|
const exceedOrderBy10Percent = orderQty > 0 && acceptedQty > orderQty * 1.1; |
|
|
|
if (exceedOrderBy10Percent) { |
|
|
|
submitDialogWithWarning(doSubmit, t, { |
|
|
|
title: t("Confirm submit"), |
|
|
|
html: t("This batch quantity exceeds order quantity by more than 10%. Do you still want to submit?"), |
|
|
|
confirmButtonText: t("Submit"), |
|
|
|
}); |
|
|
|
} else { |
|
|
|
doSubmit(); |
|
|
|
} |
|
|
|
console.log(res); |
|
|
|
}, 200); |
|
|
|
}, |
|
|
|
[polInputList, row, dnFormProps], |
|
|
|
); |
|
|
|
}, |
|
|
|
[polInputList, row, rowIndex, dnFormProps, selectedPoId, fetchPoDetail, t], |
|
|
|
); |
|
|
|
|
|
|
|
const handleChange = useCallback(debounce((e: React.ChangeEvent<HTMLInputElement>) => { |
|
|
|
const raw = e.target.value; |
|
|
|
|