refactor(materials): changes to allow exact and eom transfers
This commit is contained in:
@@ -1,19 +1,32 @@
|
|||||||
import { LstCard } from "@/components/extendedUI/LstCard";
|
import { LstCard } from "@/components/extendedUI/LstCard";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { CardHeader } from "@/components/ui/card";
|
import { CardContent, CardHeader } from "@/components/ui/card";
|
||||||
|
import { Input } from "@/components/ui/input";
|
||||||
|
import { Switch } from "@/components/ui/switch";
|
||||||
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||||
import { useAppForm } from "@/utils/formStuff";
|
import { useAppForm } from "@/utils/formStuff";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
|
import { Info } from "lucide-react";
|
||||||
|
import {
|
||||||
|
Tooltip,
|
||||||
|
TooltipContent,
|
||||||
|
TooltipTrigger,
|
||||||
|
} from "@/components/ui/tooltip";
|
||||||
|
|
||||||
export default function TransferToNextLot() {
|
export default function TransferToNextLot() {
|
||||||
const [gaylordFilled, setGaylordFilled] = useState([0]);
|
const [gaylordFilled, setGaylordFilled] = useState([0]);
|
||||||
|
const [actualAmount, setActualAmount] = useState(0);
|
||||||
|
const [tab, setTab] = useState("esitmate");
|
||||||
|
const [typeSwitch, setTypeSwitch] = useState(false);
|
||||||
|
|
||||||
const form = useAppForm({
|
const form = useAppForm({
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
runnungNumber: "",
|
runnungNumber: "",
|
||||||
lotNumber: "",
|
lotNumber: "",
|
||||||
originalAmount: "",
|
originalAmount: "",
|
||||||
|
amount: "",
|
||||||
},
|
},
|
||||||
onSubmit: async ({ value }) => {
|
onSubmit: async ({ value }) => {
|
||||||
//console.log(transferData);
|
//console.log(transferData);
|
||||||
@@ -32,11 +45,15 @@ export default function TransferToNextLot() {
|
|||||||
? 0.75
|
? 0.75
|
||||||
: gaylordFilled.length === 4 && 0.95
|
: gaylordFilled.length === 4 && 0.95
|
||||||
),
|
),
|
||||||
|
amount: actualAmount,
|
||||||
|
type: typeSwitch ? "eom" : "lot",
|
||||||
});
|
});
|
||||||
|
|
||||||
if (res.data.success) {
|
if (res.data.success) {
|
||||||
toast.success(`${res.data.message}`);
|
toast.success(`${res.data.message}`);
|
||||||
form.reset();
|
form.reset();
|
||||||
|
setGaylordFilled([0]);
|
||||||
|
setActualAmount(0);
|
||||||
}
|
}
|
||||||
//console.log(res.data);
|
//console.log(res.data);
|
||||||
|
|
||||||
@@ -64,15 +81,33 @@ export default function TransferToNextLot() {
|
|||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<div>
|
<div>
|
||||||
<LstCard className="">
|
<LstCard className="">
|
||||||
|
<Tabs
|
||||||
|
defaultValue={tab}
|
||||||
|
onValueChange={setTab}
|
||||||
|
>
|
||||||
|
<TabsList>
|
||||||
|
<TabsTrigger value="esitmate">
|
||||||
|
Estimate Amount
|
||||||
|
</TabsTrigger>
|
||||||
|
<TabsTrigger value="actual">
|
||||||
|
Actual Amount
|
||||||
|
</TabsTrigger>
|
||||||
|
</TabsList>
|
||||||
|
|
||||||
|
<TabsContent value="esitmate">
|
||||||
<div className="grid columns-1">
|
<div className="grid columns-1">
|
||||||
<button
|
<button
|
||||||
className={`box-border h-16 w-96 border-3 ${
|
className={`box-border h-16 w-96 border-3 ${
|
||||||
gaylordFilled.includes(4)
|
gaylordFilled.includes(
|
||||||
|
4
|
||||||
|
)
|
||||||
? " bg-green-500"
|
? " bg-green-500"
|
||||||
: ""
|
: ""
|
||||||
}`}
|
}`}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
setGaylordFilled([1, 2, 3, 4])
|
setGaylordFilled([
|
||||||
|
1, 2, 3, 4,
|
||||||
|
])
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<p className="text-center">
|
<p className="text-center">
|
||||||
@@ -81,12 +116,16 @@ export default function TransferToNextLot() {
|
|||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
className={`box-border h-16 w-96 border-3 ${
|
className={`box-border h-16 w-96 border-3 ${
|
||||||
gaylordFilled.includes(3)
|
gaylordFilled.includes(
|
||||||
|
3
|
||||||
|
)
|
||||||
? " bg-green-500"
|
? " bg-green-500"
|
||||||
: ""
|
: ""
|
||||||
}`}
|
}`}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
setGaylordFilled([1, 2, 3])
|
setGaylordFilled([
|
||||||
|
1, 2, 3,
|
||||||
|
])
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<p className="text-center">
|
<p className="text-center">
|
||||||
@@ -95,7 +134,9 @@ export default function TransferToNextLot() {
|
|||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
className={`box-border h-16 w-96 border-3 ${
|
className={`box-border h-16 w-96 border-3 ${
|
||||||
gaylordFilled.includes(2)
|
gaylordFilled.includes(
|
||||||
|
2
|
||||||
|
)
|
||||||
? " bg-green-500"
|
? " bg-green-500"
|
||||||
: ""
|
: ""
|
||||||
}`}
|
}`}
|
||||||
@@ -109,12 +150,16 @@ export default function TransferToNextLot() {
|
|||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
className={`box-border h-16 w-96 border-3 ${
|
className={`box-border h-16 w-96 border-3 ${
|
||||||
gaylordFilled.includes(1)
|
gaylordFilled.includes(
|
||||||
|
1
|
||||||
|
)
|
||||||
? " bg-green-500"
|
? " bg-green-500"
|
||||||
: ""
|
: ""
|
||||||
}`}
|
}`}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
setGaylordFilled(() => [1])
|
setGaylordFilled(() => [
|
||||||
|
1,
|
||||||
|
])
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<p className="text-center">
|
<p className="text-center">
|
||||||
@@ -131,6 +176,32 @@ export default function TransferToNextLot() {
|
|||||||
Reset Gaylord
|
Reset Gaylord
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
</TabsContent>
|
||||||
|
<TabsContent
|
||||||
|
value="actual"
|
||||||
|
className="w-96"
|
||||||
|
>
|
||||||
|
<CardHeader>
|
||||||
|
<p>
|
||||||
|
Enter the total amount of
|
||||||
|
the cage/gaylord
|
||||||
|
</p>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<Input
|
||||||
|
type="number"
|
||||||
|
//placeholder="35"
|
||||||
|
onChange={(e) =>
|
||||||
|
setActualAmount(
|
||||||
|
Number(
|
||||||
|
e.target.value
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</CardContent>
|
||||||
|
</TabsContent>
|
||||||
|
</Tabs>
|
||||||
</LstCard>
|
</LstCard>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
@@ -165,20 +236,104 @@ export default function TransferToNextLot() {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
{tab !== "actual" && (
|
||||||
<div className="mt-3 p-2">
|
<div className="mt-3 p-2">
|
||||||
<form.AppField
|
<form.AppField
|
||||||
name="originalAmount"
|
name="originalAmount"
|
||||||
children={(field) => (
|
children={(
|
||||||
|
field
|
||||||
|
) => (
|
||||||
<field.InputField
|
<field.InputField
|
||||||
label="Orignal Quantity"
|
label="Orignal Quantity"
|
||||||
inputType="number"
|
inputType="number"
|
||||||
required={true}
|
required={
|
||||||
|
true
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex justify-end p-2">
|
<div className="flex justify-between p-2">
|
||||||
|
<div className="flex items-center space-x-2">
|
||||||
|
<Switch
|
||||||
|
checked={typeSwitch}
|
||||||
|
onCheckedChange={
|
||||||
|
setTypeSwitch
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<span>
|
||||||
|
{typeSwitch ? (
|
||||||
|
<div className="flex items-center space-x-2">
|
||||||
|
<span>
|
||||||
|
"EOM
|
||||||
|
Transfer"
|
||||||
|
</span>
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipTrigger>
|
||||||
|
<Info className="h-[16px] w-[16px]" />
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipContent>
|
||||||
|
<p>
|
||||||
|
Click
|
||||||
|
the
|
||||||
|
toggle
|
||||||
|
if
|
||||||
|
you
|
||||||
|
will
|
||||||
|
be
|
||||||
|
transfering
|
||||||
|
at
|
||||||
|
EOM,
|
||||||
|
NOTE:
|
||||||
|
This
|
||||||
|
will
|
||||||
|
trigger
|
||||||
|
the
|
||||||
|
delayed
|
||||||
|
transfer.
|
||||||
|
</p>
|
||||||
|
</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="flex items-center space-x-2">
|
||||||
|
<span>
|
||||||
|
"Lot
|
||||||
|
Transfer"
|
||||||
|
</span>
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipTrigger>
|
||||||
|
<Info className="h-[16px] w-[16px]" />
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipContent>
|
||||||
|
<p>
|
||||||
|
Click
|
||||||
|
the
|
||||||
|
toggle
|
||||||
|
if
|
||||||
|
you
|
||||||
|
will
|
||||||
|
be
|
||||||
|
transfering
|
||||||
|
at
|
||||||
|
EOM,
|
||||||
|
NOTE:
|
||||||
|
This
|
||||||
|
will
|
||||||
|
trigger
|
||||||
|
the
|
||||||
|
delayed
|
||||||
|
transfer.
|
||||||
|
</p>
|
||||||
|
</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
<form.AppForm>
|
<form.AppForm>
|
||||||
<form.SubmitButton>
|
<form.SubmitButton>
|
||||||
Transfer To Lot
|
Transfer To Lot
|
||||||
@@ -197,49 +352,93 @@ export default function TransferToNextLot() {
|
|||||||
Moving material to the next lot.
|
Moving material to the next lot.
|
||||||
</p>
|
</p>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
|
{tab !== "actual" ? (
|
||||||
<div>
|
<div>
|
||||||
<ol>
|
<ol>
|
||||||
<li>
|
<li>
|
||||||
1. Grab the gaylord running number
|
1. Grab the gaylord running
|
||||||
from the gaylord at the line/next to
|
number from the gaylord at the
|
||||||
the tschritter
|
line/next to the tschritter
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
2. Grab the next lot number you are
|
2. Grab the next lot number you
|
||||||
going to be running (or the one that
|
are going to be running (or the
|
||||||
state no Main material prepared)
|
one that state no Main material
|
||||||
|
prepared)
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
3. Enter the total gaylord weight
|
3. Enter the total gaylord
|
||||||
(this is how much the gaylord
|
weight (this is how much the
|
||||||
weighed when it came in from the
|
gaylord weighed when it came in
|
||||||
supplier.)
|
from the supplier.)
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
4. *Click the level of the gaylord
|
4. *Click the level of the
|
||||||
(this is just an estimate to move to
|
gaylord (this is just an
|
||||||
the next lot.)
|
estimate to move to the next
|
||||||
|
lot.)
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
5. type in running number on the
|
5. type in running number on the
|
||||||
gaylord.
|
gaylord.
|
||||||
</li>
|
</li>
|
||||||
<li>6. Type in the new lot number.</li>
|
<li>
|
||||||
|
6. Type in the new lot number.
|
||||||
|
</li>
|
||||||
<li>7. Press "Transfer To Lot"</li>
|
<li>7. Press "Transfer To Lot"</li>
|
||||||
</ol>
|
</ol>
|
||||||
<br></br>
|
<br></br>
|
||||||
<p>
|
<p>
|
||||||
* to reduce the time needed to get the
|
* to reduce the time needed to get
|
||||||
lot going we will use an estimate of how
|
the lot going we will use an
|
||||||
full the gaylord is.
|
estimate of how full the gaylord is.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
NOTE: This is not the return process,
|
NOTE: This is not the return
|
||||||
this process will just get the gaylord
|
process, this process will just get
|
||||||
to the next lot.
|
the gaylord to the next lot.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
) : (
|
||||||
|
<div>
|
||||||
|
<ol>
|
||||||
|
<li>
|
||||||
|
1. Grab the gaylord running
|
||||||
|
number from the gaylord at the
|
||||||
|
line/next to the tschritter
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
2. Grab the next lot number you
|
||||||
|
are going to be running (or the
|
||||||
|
one that state no Main material
|
||||||
|
prepared)
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
3. Take the gaylord to the scale
|
||||||
|
and weight it
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
4. Enter the weight of the
|
||||||
|
gaylord minus the tar weight.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
5. type in running number on the
|
||||||
|
gaylord.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
6. Type in the new lot number.
|
||||||
|
</li>
|
||||||
|
<li>7. Press "Transfer To Lot"</li>
|
||||||
|
</ol>
|
||||||
|
<br></br>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
NOTE: This is not the return
|
||||||
|
process, this process will just get
|
||||||
|
the gaylord to the next lot.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</LstCard>
|
</LstCard>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
29
frontend/src/components/ui/switch.tsx
Normal file
29
frontend/src/components/ui/switch.tsx
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import * as React from "react"
|
||||||
|
import * as SwitchPrimitive from "@radix-ui/react-switch"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
function Switch({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof SwitchPrimitive.Root>) {
|
||||||
|
return (
|
||||||
|
<SwitchPrimitive.Root
|
||||||
|
data-slot="switch"
|
||||||
|
className={cn(
|
||||||
|
"peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<SwitchPrimitive.Thumb
|
||||||
|
data-slot="switch-thumb"
|
||||||
|
className={cn(
|
||||||
|
"bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0"
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</SwitchPrimitive.Root>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Switch }
|
||||||
@@ -17,6 +17,8 @@ export const consumeMaterial = async (data: Data, prod: any) => {
|
|||||||
const { runningNr, lotNum } = data;
|
const { runningNr, lotNum } = data;
|
||||||
// replace the rn
|
// replace the rn
|
||||||
|
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
const rnReplace = labelData.replaceAll("[rn]", runningNr);
|
const rnReplace = labelData.replaceAll("[rn]", runningNr);
|
||||||
|
|
||||||
let barcode;
|
let barcode;
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ type NewLotData = {
|
|||||||
lotNumber: number;
|
lotNumber: number;
|
||||||
originalAmount: number;
|
originalAmount: number;
|
||||||
level: number;
|
level: number;
|
||||||
|
amount: number;
|
||||||
|
type: "lot" | "eom";
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,8 +24,11 @@ type NewLotData = {
|
|||||||
* Lot number
|
* Lot number
|
||||||
* Orignal Quantity
|
* Orignal Quantity
|
||||||
* level of gaylord
|
* level of gaylord
|
||||||
|
* amount can be sent over as a precise amount
|
||||||
|
* type what way are we lots
|
||||||
*/
|
*/
|
||||||
export const lotMaterialTransfer = async (data: NewLotData) => {
|
export const lotMaterialTransfer = async (data: NewLotData) => {
|
||||||
|
let timeoutTrans: number = data.type === "lot" ? 1 : 10;
|
||||||
// get the barcode, and layoutID from the running number
|
// get the barcode, and layoutID from the running number
|
||||||
const { data: label, error: labelError } = (await tryCatch(
|
const { data: label, error: labelError } = (await tryCatch(
|
||||||
query(
|
query(
|
||||||
@@ -46,22 +51,21 @@ export const lotMaterialTransfer = async (data: NewLotData) => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (
|
if (label.data.length === 0) {
|
||||||
// label.data[0]?.stockStatus === "notOnStock" ||
|
createLog(
|
||||||
// label.data.length === 0
|
"error",
|
||||||
// ) {
|
"materials",
|
||||||
// createLog(
|
"ocp",
|
||||||
// "error",
|
`${data.runnungNumber}: dose not exist or no longer in stock.`
|
||||||
// "materials",
|
);
|
||||||
// "ocp",
|
return {
|
||||||
// `${data.runnungNumber}: dose not exist or no longer in stock.`
|
success: false,
|
||||||
// );
|
message: `${data.runnungNumber}: dose not exist or no longer in stock.`,
|
||||||
// return {
|
data: [],
|
||||||
// success: false,
|
};
|
||||||
// message: `${data.runnungNumber}: dose not exist or no longer in stock.`,
|
}
|
||||||
// data: [],
|
|
||||||
// };
|
//console.log(label);
|
||||||
// }
|
|
||||||
|
|
||||||
if (label.data[0]?.stockStatus === "onStock") {
|
if (label.data[0]?.stockStatus === "onStock") {
|
||||||
createLog(
|
createLog(
|
||||||
@@ -97,7 +101,12 @@ export const lotMaterialTransfer = async (data: NewLotData) => {
|
|||||||
}
|
}
|
||||||
// calculate the remaining amount bascially it will be orignal number * level sent over
|
// calculate the remaining amount bascially it will be orignal number * level sent over
|
||||||
// level should be sent in a decimal .25 .5 .75 .95 the 95 will allow basically the what looks to be a full gaylord but we always want to consume something
|
// level should be sent in a decimal .25 .5 .75 .95 the 95 will allow basically the what looks to be a full gaylord but we always want to consume something
|
||||||
const newQty = (data.originalAmount * data.level).toFixed(0);
|
const newQty =
|
||||||
|
data.amount > 0
|
||||||
|
? data.amount
|
||||||
|
: (data.originalAmount * data.level).toFixed(0);
|
||||||
|
|
||||||
|
//console.log(data.amount);
|
||||||
|
|
||||||
// reprint the label and send it to pdf24
|
// reprint the label and send it to pdf24
|
||||||
const reprintData = {
|
const reprintData = {
|
||||||
@@ -109,6 +118,8 @@ export const lotMaterialTransfer = async (data: NewLotData) => {
|
|||||||
quantity: newQty,
|
quantity: newQty,
|
||||||
} as any;
|
} as any;
|
||||||
|
|
||||||
|
//console.log(reprintData);
|
||||||
|
|
||||||
const { data: reprint, error: reprintError } = (await tryCatch(
|
const { data: reprint, error: reprintError } = (await tryCatch(
|
||||||
runProdApi({
|
runProdApi({
|
||||||
endpoint: "/public/v1.0/ProductionLabelling/ReprintLabel",
|
endpoint: "/public/v1.0/ProductionLabelling/ReprintLabel",
|
||||||
@@ -121,11 +132,11 @@ export const lotMaterialTransfer = async (data: NewLotData) => {
|
|||||||
"error",
|
"error",
|
||||||
"materials",
|
"materials",
|
||||||
"ocp",
|
"ocp",
|
||||||
`RN:${data.runnungNumber}, Error: ${reprint.data.data.message}`
|
`RN:${data.runnungNumber}, Reprinting Error: ${reprint.data.data.message}`
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: `RN:${data.runnungNumber}, Error: ${reprint.data.data.message}`,
|
message: `RN:${data.runnungNumber}, Reprinting Error: ${reprint.data.data.message}`,
|
||||||
data: reprint,
|
data: reprint,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -135,6 +146,8 @@ export const lotMaterialTransfer = async (data: NewLotData) => {
|
|||||||
barcode: label?.data[0].Barcode,
|
barcode: label?.data[0].Barcode,
|
||||||
laneId: 10001,
|
laneId: 10001,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//console.log(matReturnData);
|
||||||
const { data: matReturn, error: matReturError } = (await tryCatch(
|
const { data: matReturn, error: matReturError } = (await tryCatch(
|
||||||
runProdApi({
|
runProdApi({
|
||||||
endpoint:
|
endpoint:
|
||||||
@@ -148,11 +161,11 @@ export const lotMaterialTransfer = async (data: NewLotData) => {
|
|||||||
"error",
|
"error",
|
||||||
"materials",
|
"materials",
|
||||||
"ocp",
|
"ocp",
|
||||||
`RN:${data.runnungNumber}, Error ${matReturn.data.data.errors[0].message}`
|
`RN:${data.runnungNumber}, Return Error ${matReturn.data.data.errors[0].message}`
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: `RN:${data.runnungNumber}, Error ${matReturn.data.data.errors[0].message}`,
|
message: `RN:${data.runnungNumber}, Return Error ${matReturn.data.data.errors[0].message}`,
|
||||||
data: matReturn,
|
data: matReturn,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -161,7 +174,12 @@ export const lotMaterialTransfer = async (data: NewLotData) => {
|
|||||||
productionLot: data.lotNumber,
|
productionLot: data.lotNumber,
|
||||||
barcode: label?.data[0].Barcode,
|
barcode: label?.data[0].Barcode,
|
||||||
};
|
};
|
||||||
const { data: matConsume, error: matConsumeError } = (await tryCatch(
|
|
||||||
|
// sets the time out based on the type of transfer sent over.
|
||||||
|
setTimeout(
|
||||||
|
async () => {
|
||||||
|
const { data: matConsume, error: matConsumeError } =
|
||||||
|
(await tryCatch(
|
||||||
runProdApi({
|
runProdApi({
|
||||||
endpoint:
|
endpoint:
|
||||||
"/public/v1.0/IssueMaterial/ConsumeNonPreparedManualMaterial",
|
"/public/v1.0/IssueMaterial/ConsumeNonPreparedManualMaterial",
|
||||||
@@ -174,11 +192,11 @@ export const lotMaterialTransfer = async (data: NewLotData) => {
|
|||||||
"error",
|
"error",
|
||||||
"materials",
|
"materials",
|
||||||
"ocp",
|
"ocp",
|
||||||
`RN:${data.runnungNumber}, Error ${matConsume.data.data.errors[0].message}`
|
`RN:${data.runnungNumber}, Consume Error ${matConsume.data.data.errors[0].message}`
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: `RN:${data.runnungNumber}, Error ${matConsume.data.data.errors[0].message}`,
|
message: `RN:${data.runnungNumber}, Consume Error ${matConsume.data.data.errors[0].message}`,
|
||||||
data: matConsume,
|
data: matConsume,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -189,11 +207,23 @@ export const lotMaterialTransfer = async (data: NewLotData) => {
|
|||||||
"ocp",
|
"ocp",
|
||||||
`RN:${data.runnungNumber}: qty: ${newQty}, was transfered to lot:${data.lotNumber}`
|
`RN:${data.runnungNumber}: qty: ${newQty}, was transfered to lot:${data.lotNumber}`
|
||||||
);
|
);
|
||||||
|
},
|
||||||
|
data.type === "lot" ? timeoutTrans * 1000 : timeoutTrans * 1000 * 60
|
||||||
|
);
|
||||||
|
|
||||||
|
if (data.type === "eom") {
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: `RN:${data.runnungNumber}: qty: ${newQty}, will be transfered to:${data.lotNumber}, in ${timeoutTrans}min`,
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
} else {
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
message: `RN:${data.runnungNumber}: qty: ${newQty}, was transfered to lot:${data.lotNumber}`,
|
message: `RN:${data.runnungNumber}: qty: ${newQty}, was transfered to lot:${data.lotNumber}`,
|
||||||
data: [],
|
data: [],
|
||||||
};
|
};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// setTimeout(async () => {
|
// setTimeout(async () => {
|
||||||
|
|||||||
@@ -54,10 +54,12 @@ app.openapi(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(transferMaterial);
|
||||||
|
|
||||||
return c.json({
|
return c.json({
|
||||||
success: transferMaterial.success,
|
success: transferMaterial?.success,
|
||||||
message: transferMaterial.message,
|
message: transferMaterial?.message,
|
||||||
data: transferMaterial.data,
|
data: transferMaterial?.data,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user