|
|
@@ -17,14 +17,13 @@ import { Dispatch, SetStateAction, useCallback, useEffect, useMemo, useState } f |
|
|
|
import { FormProvider, SubmitErrorHandler, SubmitHandler, useForm } from "react-hook-form"; |
|
|
|
import { StockInLineRow } from "./PoInputGrid"; |
|
|
|
import { useTranslation } from "react-i18next"; |
|
|
|
import StockInForm from "./StockInForm"; |
|
|
|
import StockInFormVer2 from "./StockInFormVer2"; |
|
|
|
import QcComponent from "./QcComponent"; |
|
|
|
import { dummyPutAwayLine, dummyQCData } from "./dummyQcTemplate"; |
|
|
|
import PutAwayForm from "./PutAwayForm"; |
|
|
|
import { GridRowModes, useGridApiRef } from "@mui/x-data-grid"; |
|
|
|
import {submitDialogWithWarning} from "../Swal/CustomAlerts"; |
|
|
|
import { INPUT_DATE_FORMAT, arrayToDateString, arrayToInputDateString, dayjsToInputDateString } from "@/app/utils/formatUtil"; |
|
|
|
import { INPUT_DATE_FORMAT, arrayToDateString, dayjsToInputDateString } from "@/app/utils/formatUtil"; |
|
|
|
import dayjs from "dayjs"; |
|
|
|
import { fetchPoQrcode } from "@/app/api/pdf/actions"; |
|
|
|
import { downloadFile } from "@/app/utils/commonUtil"; |
|
|
@@ -103,12 +102,14 @@ const defaultNewValue = useMemo(() => { |
|
|
|
{ |
|
|
|
...itemDetail, |
|
|
|
status: itemDetail.status ?? "pending", |
|
|
|
dnDate: arrayToInputDateString(itemDetail.dnDate)?? dayjsToInputDateString(dayjs()), |
|
|
|
dnDate: arrayToDateString(itemDetail.dnDate, "input")?? dayjsToInputDateString(dayjs()), |
|
|
|
// putAwayLines: dummyPutAwayLine, |
|
|
|
// putAwayLines: itemDetail.putAwayLines.map((line) => (return {...line, printQty: 1})) ?? [], |
|
|
|
putAwayLines: itemDetail.putAwayLines?.map((line) => ({...line, printQty: 1, _isNew: false})) ?? [], |
|
|
|
// qcResult: (itemDetail.qcResult && itemDetail.qcResult?.length > 0) ? itemDetail.qcResult : [],//[...dummyQCData], |
|
|
|
escResult: (itemDetail.escResult && itemDetail.escResult?.length > 0) ? itemDetail.escResult : [], |
|
|
|
productionDate: itemDetail.productionDate ? arrayToDateString(itemDetail.productionDate, "input") : undefined, |
|
|
|
expiryDate: itemDetail.expiryDate ? arrayToDateString(itemDetail.expiryDate, "input") : undefined, |
|
|
|
receiptDate: itemDetail.receiptDate ?? dayjs().add(0, "month").format(INPUT_DATE_FORMAT), |
|
|
|
acceptQty: itemDetail.demandQty?? itemDetail.acceptedQty, |
|
|
|
warehouseId: itemDetail.defaultWarehouseId ?? 1 |
|
|
@@ -241,7 +242,7 @@ const [qcItems, setQcItems] = useState(dummyQCData) |
|
|
|
// if (qcAccept === undefined) { |
|
|
|
validationErrors.push(t("QC decision is required")); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Check if accept quantity is valid |
|
|
|
if (data.qcDecision == 2) { |
|
|
|
acceptQty = 0; |
|
|
@@ -282,10 +283,10 @@ const [qcItems, setQcItems] = useState(dummyQCData) |
|
|
|
|
|
|
|
const qcData = { |
|
|
|
dnNo : data.dnNo? data.dnNo : "DN00000", |
|
|
|
dnDate : data.dnDate? arrayToInputDateString(data.dnDate) : dayjsToInputDateString(dayjs()), |
|
|
|
productionDate : arrayToInputDateString(data.productionDate), |
|
|
|
expiryDate : arrayToInputDateString(data.expiryDate), |
|
|
|
receiptDate : arrayToInputDateString(data.receiptDate), |
|
|
|
dnDate : data.dnDate? arrayToDateString(data.dnDate, "input") : dayjsToInputDateString(dayjs()), |
|
|
|
productionDate : arrayToDateString(data.productionDate, "input"), |
|
|
|
expiryDate : arrayToDateString(data.expiryDate, "input"), |
|
|
|
receiptDate : arrayToDateString(data.receiptDate, "input"), |
|
|
|
|
|
|
|
qcAccept: qcAccept? qcAccept : false, |
|
|
|
acceptQty: acceptQty? acceptQty : 0, |
|
|
@@ -388,10 +389,10 @@ const [qcItems, setQcItems] = useState(dummyQCData) |
|
|
|
status: data.status, //TODO Fix it! |
|
|
|
// ...data, |
|
|
|
|
|
|
|
dnDate : data.dnDate? arrayToInputDateString(data.dnDate) : dayjsToInputDateString(dayjs()), |
|
|
|
productionDate : arrayToInputDateString(data.productionDate), |
|
|
|
expiryDate : arrayToInputDateString(data.expiryDate), |
|
|
|
receiptDate : arrayToInputDateString(data.receiptDate), |
|
|
|
dnDate : data.dnDate? arrayToDateString(data.dnDate) : dayjsToInputDateString(dayjs()), |
|
|
|
productionDate : arrayToDateString(data.productionDate, "input"), |
|
|
|
expiryDate : arrayToDateString(data.expiryDate, "input"), |
|
|
|
receiptDate : arrayToDateString(data.receiptDate, "input"), |
|
|
|
|
|
|
|
// for putaway data |
|
|
|
inventoryLotLines: data.putAwayLines?.filter((line) => line._isNew !== false) |
|
|
|