| @@ -50,8 +50,8 @@ export interface PurchaseQCInput { | |||||
| export interface EscalationInput { | export interface EscalationInput { | ||||
| status: string | status: string | ||||
| handler: string | handler: string | ||||
| acceptedQty: number | |||||
| rejectedQty: number | |||||
| acceptedQty: number // this is the qty to be escalated | |||||
| // escalationQty: number | |||||
| } | } | ||||
| export interface PutawayInput { | export interface PutawayInput { | ||||
| status: string | status: string | ||||
| @@ -39,9 +39,12 @@ export interface StockInLine { | |||||
| acceptedQty: number | acceptedQty: number | ||||
| price: number | price: number | ||||
| priceUnit: string | priceUnit: string | ||||
| productDate: string | |||||
| shelfLifeDate: string | |||||
| productionDate: string | |||||
| expiryDate: string | |||||
| status: string | status: string | ||||
| supplier: string | |||||
| lotNo: string | |||||
| poCode: string | |||||
| } | } | ||||
| export const fetchPoList = cache(async () => { | export const fetchPoList = cache(async () => { | ||||
| @@ -76,9 +76,12 @@ const EscalationForm: React.FC<Props> = ({ | |||||
| } | } | ||||
| }, [itemDetail]) | }, [itemDetail]) | ||||
| const acceptedQty = watch("acceptedQty") | |||||
| const rejectedQty = watch("rejectedQty") | |||||
| // const acceptedQty = watch("acceptedQty") || 0 | |||||
| const acceptedQty = watch("acceptedQty") || 0 | |||||
| // console.log(acceptedQty) | |||||
| console.log(acceptedQty) | |||||
| console.log(itemDetail.acceptedQty) | |||||
| useEffect(() => { | useEffect(() => { | ||||
| console.log("triggered") | console.log("triggered") | ||||
| setValue("status", status) | setValue("status", status) | ||||
| @@ -93,7 +96,7 @@ const EscalationForm: React.FC<Props> = ({ | |||||
| </Grid> | </Grid> | ||||
| <Grid item xs={12}> | <Grid item xs={12}> | ||||
| <Typography variant="h6" display="block" marginBlockEnd={1}> | <Typography variant="h6" display="block" marginBlockEnd={1}> | ||||
| {t(`to be processed`)}: {itemDetail.acceptedQty - acceptedQty - rejectedQty} | |||||
| {t(`to be processed`)}: {itemDetail.acceptedQty - acceptedQty} | |||||
| </Typography> | </Typography> | ||||
| </Grid> | </Grid> | ||||
| <Grid | <Grid | ||||
| @@ -103,17 +106,6 @@ const EscalationForm: React.FC<Props> = ({ | |||||
| spacing={2} | spacing={2} | ||||
| sx={{ mt: 0.5 }} | sx={{ mt: 0.5 }} | ||||
| > | > | ||||
| {/* <Grid item xs={4}> | |||||
| <TextField | |||||
| label={t("handler")} | |||||
| fullWidth | |||||
| {...register("handler", { | |||||
| required: "handler required!", | |||||
| })} | |||||
| error={Boolean(errors.handler)} | |||||
| helperText={errors.handler?.message} | |||||
| /> | |||||
| </Grid> */} | |||||
| <Grid item xs={6}> | <Grid item xs={6}> | ||||
| <TextField | <TextField | ||||
| label={t("acceptedQty")} | label={t("acceptedQty")} | ||||
| @@ -122,24 +114,11 @@ const EscalationForm: React.FC<Props> = ({ | |||||
| required: "acceptedQty required!", | required: "acceptedQty required!", | ||||
| min: 0, | min: 0, | ||||
| valueAsNumber: true, | valueAsNumber: true, | ||||
| max: itemDetail.acceptedQty | |||||
| })} | })} | ||||
| // defaultValue={itemDetail.acceptedQty} | |||||
| // error={Boolean(errors.handler)} | |||||
| // helperText={errors.handler?.message} | |||||
| /> | |||||
| </Grid> | |||||
| <Grid item xs={6}> | |||||
| <TextField | |||||
| label={t("rejectedQty")} | |||||
| fullWidth | |||||
| {...register("rejectedQty", { | |||||
| required: "rejectedQty required!", | |||||
| min: 0, | |||||
| valueAsNumber: true, | |||||
| })} | |||||
| defaultValue={0} | |||||
| // error={Boolean(errors.handler)} | |||||
| // helperText={errors.handler?.message} | |||||
| defaultValue={itemDetail.acceptedQty} | |||||
| error={Boolean(errors.acceptedQty)} | |||||
| helperText={errors.acceptedQty?.message} | |||||
| /> | /> | ||||
| </Grid> | </Grid> | ||||
| </Grid> | </Grid> | ||||
| @@ -98,6 +98,7 @@ function PoInputGrid({ | |||||
| stockInLine, | stockInLine, | ||||
| warehouse, | warehouse, | ||||
| }: Props) { | }: Props) { | ||||
| console.log(itemDetail) | |||||
| const { t } = useTranslation("home"); | const { t } = useTranslation("home"); | ||||
| const apiRef = useGridApiRef(); | const apiRef = useGridApiRef(); | ||||
| const [rowModesModel, setRowModesModel] = useState<GridRowModesModel>({}); | const [rowModesModel, setRowModesModel] = useState<GridRowModesModel>({}); | ||||
| @@ -161,6 +161,20 @@ const PoQcStockInModal: React.FC<Props> = ({ | |||||
| [t, itemDetail] | [t, itemDetail] | ||||
| ); | ); | ||||
| const canSubmit = useMemo(() => { | |||||
| if (type === "qc") { | |||||
| // console.log(itemDetail.status) | |||||
| return formProps.formState.isValid | |||||
| } | |||||
| if (type === "stockIn") { | |||||
| return formProps.formState.isValid | |||||
| } | |||||
| if (type === "putaway") { | |||||
| return formProps.formState.isValid | |||||
| } | |||||
| return true | |||||
| }, [type, itemDetail]) | |||||
| console.log(canSubmit) | |||||
| return ( | return ( | ||||
| <> | <> | ||||
| <Modal open={open} onClose={closeHandler}> | <Modal open={open} onClose={closeHandler}> | ||||
| @@ -113,7 +113,7 @@ const PutawayForm: React.FC<Props> = ({ itemDetail, warehouse }) => { | |||||
| <Grid container justifyContent="flex-start" alignItems="flex-start"> | <Grid container justifyContent="flex-start" alignItems="flex-start"> | ||||
| <Grid item xs={12}> | <Grid item xs={12}> | ||||
| <Typography variant="h6" display="block" marginBlockEnd={1}> | <Typography variant="h6" display="block" marginBlockEnd={1}> | ||||
| {t("Qc Detail")} | |||||
| {t("Putaway Detail")} | |||||
| </Typography> | </Typography> | ||||
| </Grid> | </Grid> | ||||
| <Grid | <Grid | ||||
| @@ -123,9 +123,49 @@ const PutawayForm: React.FC<Props> = ({ itemDetail, warehouse }) => { | |||||
| spacing={2} | spacing={2} | ||||
| sx={{ mt: 0.5 }} | sx={{ mt: 0.5 }} | ||||
| > | > | ||||
| <Grid item xs={12}> | |||||
| <TextField | |||||
| label={t("LotNo")} | |||||
| fullWidth | |||||
| value={itemDetail.lotNo} | |||||
| disabled | |||||
| /> | |||||
| </Grid> | |||||
| <Grid item xs={6}> | |||||
| <TextField | |||||
| label={t("Supplier")} | |||||
| fullWidth | |||||
| value={itemDetail.supplier} | |||||
| disabled | |||||
| /> | |||||
| </Grid> | |||||
| <Grid item xs={6}> | |||||
| <TextField | |||||
| label={t("Po Code")} | |||||
| fullWidth | |||||
| value={itemDetail.poCode} | |||||
| disabled | |||||
| /> | |||||
| </Grid> | |||||
| <Grid item xs={6}> | |||||
| <TextField | |||||
| label={t("item name")} | |||||
| fullWidth | |||||
| value={itemDetail.itemName} | |||||
| disabled | |||||
| /> | |||||
| </Grid> | |||||
| <Grid item xs={6}> | |||||
| <TextField | |||||
| label={t("item no")} | |||||
| fullWidth | |||||
| value={itemDetail.itemNo} | |||||
| disabled | |||||
| /> | |||||
| </Grid> | |||||
| <Grid item xs={6}> | <Grid item xs={6}> | ||||
| <TextField | <TextField | ||||
| label={t("Total qty")} | |||||
| label={t("qty")} | |||||
| fullWidth | fullWidth | ||||
| value={itemDetail.acceptedQty} | value={itemDetail.acceptedQty} | ||||
| disabled | disabled | ||||
| @@ -133,24 +173,35 @@ const PutawayForm: React.FC<Props> = ({ itemDetail, warehouse }) => { | |||||
| </Grid> | </Grid> | ||||
| <Grid item xs={6}> | <Grid item xs={6}> | ||||
| <TextField | <TextField | ||||
| label={t("Total record qty")} | |||||
| label={t("productionDate")} | |||||
| fullWidth | fullWidth | ||||
| value={recordQty} | |||||
| value={itemDetail.productionDate} | |||||
| disabled | disabled | ||||
| /> | /> | ||||
| </Grid> | </Grid> | ||||
| <Grid item xs={4}> | |||||
| <Grid item xs={12}> | |||||
| <TextField | |||||
| label={t("expiryDate")} | |||||
| fullWidth | |||||
| value={itemDetail.expiryDate} | |||||
| disabled | |||||
| /> | |||||
| </Grid> | |||||
| <Grid item xs={6}> | |||||
| <TextField | <TextField | ||||
| label={t("acceptedQty")} | label={t("acceptedQty")} | ||||
| fullWidth | fullWidth | ||||
| {...register("acceptedQty", { | {...register("acceptedQty", { | ||||
| required: "acceptedQty required!", | required: "acceptedQty required!", | ||||
| min: 1, | |||||
| max: itemDetail.acceptedQty, | |||||
| valueAsNumber: true, | |||||
| })} | })} | ||||
| error={Boolean(errors.acceptedQty)} | error={Boolean(errors.acceptedQty)} | ||||
| helperText={errors.acceptedQty?.message} | helperText={errors.acceptedQty?.message} | ||||
| /> | /> | ||||
| </Grid> | </Grid> | ||||
| <Grid item xs={4}> | |||||
| <Grid item xs={6}> | |||||
| <FormControl fullWidth> | <FormControl fullWidth> | ||||
| <Autocomplete | <Autocomplete | ||||
| noOptionsText={t("No Warehouse")} | noOptionsText={t("No Warehouse")} | ||||