umwd-components 0.1.721 → 0.1.723
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/src/components/e-commerce/iro/IroItemDisplay.js +1 -1
- package/dist/cjs/src/components/e-commerce/iro/IroItemUpdater.js +1 -1
- package/dist/cjs/src/components/e-commerce/iro/ManageIROForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/iro/RmaForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/iro/TextualIROItemUpdater.js +1 -1
- package/dist/cjs/src/components/e-commerce/iro/TextualManageIROForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/opo/ManageOpoForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/opo/OpoItemDisplay.js +1 -1
- package/dist/cjs/src/components/e-commerce/opo/OpoItemUpdater.js +1 -1
- package/dist/cjs/src/components/e-commerce/opo/OpoSummary.js +1 -1
- package/dist/cjs/src/components/e-commerce/opo/TextualManageOpoForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/opo/TextualOpoItemUpdater.js +1 -1
- package/dist/cjs/src/components/logistics/ipo/IPOItemUpdater.js +1 -1
- package/dist/cjs/src/components/logistics/ipo/ManageIPOForm.js +1 -1
- package/dist/cjs/src/components/logistics/ipo/TextualIPOItemUpdater.js +1 -1
- package/dist/cjs/src/components/logistics/ipo/TextualManageIPOForm.js +1 -1
- package/dist/cjs/src/data/loaders/e-commerce/getAllOpos.js +1 -1
- package/dist/cjs/src/data/loaders/e-commerce-loaders.js +1 -1
- package/dist/cjs/src/lib/isEORIValid.js +1 -1
- package/dist/cjs/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/src/components/e-commerce/iro/IroItemDisplay.js +1 -1
- package/dist/esm/src/components/e-commerce/iro/IroItemUpdater.js +5 -5
- package/dist/esm/src/components/e-commerce/iro/ManageIROForm.js +3 -3
- package/dist/esm/src/components/e-commerce/iro/RmaForm.js +1 -1
- package/dist/esm/src/components/e-commerce/iro/TextualIROItemUpdater.js +8 -8
- package/dist/esm/src/components/e-commerce/iro/TextualManageIROForm.js +15 -15
- package/dist/esm/src/components/e-commerce/opo/ManageOpoForm.js +5 -5
- package/dist/esm/src/components/e-commerce/opo/OpoItemDisplay.js +1 -1
- package/dist/esm/src/components/e-commerce/opo/OpoItemUpdater.js +8 -7
- package/dist/esm/src/components/e-commerce/opo/OpoSummary.js +2 -2
- package/dist/esm/src/components/e-commerce/opo/TextualManageOpoForm.js +12 -12
- package/dist/esm/src/components/e-commerce/opo/TextualOpoItemUpdater.js +8 -8
- package/dist/esm/src/components/logistics/ipo/IPOItemUpdater.js +5 -5
- package/dist/esm/src/components/logistics/ipo/ManageIPOForm.js +4 -4
- package/dist/esm/src/components/logistics/ipo/TextualIPOItemUpdater.js +8 -8
- package/dist/esm/src/components/logistics/ipo/TextualManageIPOForm.js +12 -12
- package/dist/esm/src/data/loaders/e-commerce/getAllOpos.js +1 -1
- package/dist/esm/src/data/loaders/e-commerce-loaders.js +0 -1
- package/dist/esm/src/lib/isEORIValid.js +0 -1
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/types/data/services/archive-service.d.ts +2 -2
- package/dist/esm/types/data/services/common/cancellation-service.d.ts +1 -1
- package/dist/esm/types/data/services/common/confirmation-service.d.ts +1 -1
- package/dist/esm/types/types/e-commerce/iro/types.d.ts +5 -9
- package/dist/esm/types/types/e-commerce/opo/types.d.ts +5 -9
- package/dist/esm/types/types/logistics/Ipo.d.ts +5 -9
- package/package.json +1 -1
|
@@ -12,7 +12,7 @@ import ReportsDisplay from '../../logistics/report/ReportsDisplay.js';
|
|
|
12
12
|
|
|
13
13
|
function IroItemDisplay({ item, index, image }) {
|
|
14
14
|
const { line_item_number, product, returned_quantity, received_quantity, registered_quantity, released_quantity, reports, reason, other_reason, } = item;
|
|
15
|
-
return (jsxs(Stack, { spacing: 1, children: [item && (jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", children: [jsxs(Stack, { spacing: 1, sx: { width: "100%" }, children: [jsxs(Typography, { variant: "body1", children: ["Line Item Number: ", line_item_number] }), jsxs(Typography, { variant: "body1", children: ["Part Number: ", product?.product_number] })] }), jsxs(Stack, { spacing: 1, children: [jsxs(Typography, { variant: "body1", children: ["Reason: ", reason] }), other_reason !== undefined && (jsx(Typography, { variant: "body1", children: other_reason }))] }), image && (jsx(Fragment, { children: jsx(ImagePreviewTooltip, { image: image, label: item.product?.title }) }))] })), jsxs(Stack, { direction: "row", spacing: 1, justifyContent: "space-between", alignItems: "center", children: [jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(Typography, { variant: "caption", children: "Ordered" }), jsx(Typography, { variant: "h6", children: returned_quantity })] }), jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(Typography, { variant: "caption", children: "Received" }), jsx(Typography, { variant: "h6", children: received_quantity })] }), jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(Typography, { variant: "caption", children: "Registered" }), jsx(Typography, { variant: "h6", children: registered_quantity })] }), jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(Typography, { variant: "caption", children: "Released" }), jsx(Typography, { variant: "h6", children: released_quantity })] })] }), reports?.
|
|
15
|
+
return (jsxs(Stack, { spacing: 1, children: [item && (jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", children: [jsxs(Stack, { spacing: 1, sx: { width: "100%" }, children: [jsxs(Typography, { variant: "body1", children: ["Line Item Number: ", line_item_number] }), jsxs(Typography, { variant: "body1", children: ["Part Number: ", product?.product_number] })] }), jsxs(Stack, { spacing: 1, children: [jsxs(Typography, { variant: "body1", children: ["Reason: ", reason] }), other_reason !== undefined && (jsx(Typography, { variant: "body1", children: other_reason }))] }), image && (jsx(Fragment, { children: jsx(ImagePreviewTooltip, { image: image, label: item.product?.title }) }))] })), jsxs(Stack, { direction: "row", spacing: 1, justifyContent: "space-between", alignItems: "center", children: [jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(Typography, { variant: "caption", children: "Ordered" }), jsx(Typography, { variant: "h6", children: returned_quantity })] }), jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(Typography, { variant: "caption", children: "Received" }), jsx(Typography, { variant: "h6", children: received_quantity })] }), jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(Typography, { variant: "caption", children: "Registered" }), jsx(Typography, { variant: "h6", children: registered_quantity })] }), jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(Typography, { variant: "caption", children: "Released" }), jsx(Typography, { variant: "h6", children: released_quantity })] })] }), reports?.length > 0 && (jsxs(Stack, { spacing: 1, children: [jsx(Typography, { variant: "body1", children: "Reports:" }), jsx(ReportsDisplay, { reports: reports.filter((report) => "id" in report && !("pre_report" in report)) })] }))] }, index));
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export { IroItemDisplay as default };
|
|
@@ -19,13 +19,13 @@ import ReportsDisplay from '../../logistics/report/ReportsDisplay.js';
|
|
|
19
19
|
|
|
20
20
|
function IroItemUpdater({ item, index, handleUpdateQuantity, image, revalidateCallback, }) {
|
|
21
21
|
const { line_item_number, product, received_quantity, registered_quantity, released_quantity, returned_quantity, reports, reason, other_reason, } = item;
|
|
22
|
-
const received_bad_quantity = reports
|
|
23
|
-
? reports
|
|
22
|
+
const received_bad_quantity = reports !== undefined && reports.length > 0
|
|
23
|
+
? reports
|
|
24
24
|
.filter((report) => report.type === "received")
|
|
25
25
|
.reduce((a, b) => a + b.quantity, 0)
|
|
26
26
|
: 0;
|
|
27
|
-
const registered_bad_quantity = reports
|
|
28
|
-
? reports
|
|
27
|
+
const registered_bad_quantity = reports !== undefined && reports.length > 0
|
|
28
|
+
? reports
|
|
29
29
|
.filter((report) => report.type === "registered")
|
|
30
30
|
.reduce((a, b) => a + b.quantity, 0)
|
|
31
31
|
: 0;
|
|
@@ -34,7 +34,7 @@ function IroItemUpdater({ item, index, handleUpdateQuantity, image, revalidateCa
|
|
|
34
34
|
handleUpdateQuantity(newValue, item.id, "received_quantity");
|
|
35
35
|
} }), jsx(Typography, { variant: "body2", children: "Registered" }), jsx(AmountUpdater, { currentValue: registered_quantity, totalValue: returned_quantity + received_bad_quantity, minNewValue: 0 + released_quantity, maxNewValue: received_quantity + registered_bad_quantity, color: "info", handleChange: (newValue) => {
|
|
36
36
|
handleUpdateQuantity(newValue, item.id, "registered_quantity");
|
|
37
|
-
}, offsetEnd: registered_bad_quantity }), jsx(Divider, { sx: { p: 0 }, children: jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(Typography, { variant: "body2", children: "Irregularities / Corrections" }), jsx(IconButton, { onClick: () => setOpen(!open), children: jsx(ArrowButtonDownIcon, {}) })] }) }), jsx(Collapse, { in: open, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "body2", children: "Here you can report and correct for damages wrong items etc. Do not forget to click the button!" }), jsx(ReportsDisplay, { reports: reports
|
|
37
|
+
}, offsetEnd: registered_bad_quantity }), jsx(Divider, { sx: { p: 0 }, children: jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(Typography, { variant: "body2", children: "Irregularities / Corrections" }), jsx(IconButton, { onClick: () => setOpen(!open), children: jsx(ArrowButtonDownIcon, {}) })] }) }), jsx(Collapse, { in: open, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "body2", children: "Here you can report and correct for damages wrong items etc. Do not forget to click the button!" }), jsx(ReportsDisplay, { reports: reports }), jsx(ReportMakingComponent, { content: "content", quantity: 0, type: "registered", minValue: -(received_quantity + registered_bad_quantity), maxValue: received_quantity, related: [{ id: item.id, __type: "api::e-commerce.iro-item" }], revalidateCallback: revalidateCallback })] }) }), jsx(Typography, { variant: "body2", children: "Released" }), jsx(AmountUpdater, { currentValue: released_quantity || 0, totalValue: returned_quantity +
|
|
38
38
|
received_bad_quantity +
|
|
39
39
|
registered_bad_quantity, minNewValue: 0, maxNewValue: registered_quantity, color: "info", handleChange: (newValue) => {
|
|
40
40
|
handleUpdateQuantity(newValue, item.id, "released_quantity");
|
|
@@ -35,7 +35,7 @@ const INITIAL_STATE = {
|
|
|
35
35
|
function ManageIROForm({ data, sx, revalidateCallback, handleClose, role, }) {
|
|
36
36
|
// TODO bind to id of IRO
|
|
37
37
|
const [formState, formAction] = useFormState(updateIroAction, INITIAL_STATE);
|
|
38
|
-
const [items, setItems] = useState(data.iro_items
|
|
38
|
+
const [items, setItems] = useState(data.iro_items ? data.iro_items : []);
|
|
39
39
|
const [confirmDialogOpen, setConfirmDialogOpen] = useState(false);
|
|
40
40
|
const parseItems = (items) => {
|
|
41
41
|
return items.map((item) => {
|
|
@@ -50,8 +50,8 @@ function ManageIROForm({ data, sx, revalidateCallback, handleClose, role, }) {
|
|
|
50
50
|
return (jsx(Box, { sx: [
|
|
51
51
|
// You cannot spread `sx` directly because `SxProps` (typeof sx) can be an array.
|
|
52
52
|
...(Array.isArray(sx) ? sx : [sx]),
|
|
53
|
-
], children: jsxs(Grid, { container: true, spacing: 2, children: [jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsxs(Stack, { direction: "row", spacing: 2, justifyContent: "space-between", children: [jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h3", component: "h1", children: "Management Inbound Purchase Order" }), jsx(Typography, { variant: "body1", children: "Manage arrival, registration and recieval of purchase order" })] }), jsx(NoteTakingComponent, { content: "", related: [{ id: data.id, __type: "api::logistics.ipo" }], revalidateCallback: revalidateCallback })] }), jsx(Divider, {})] }) }), jsx(Grid, { item: true, xs: 6, children: jsxs(Stack, { spacing: 1, children: [jsx(Typography, { variant: "h5", children: "Details" }), jsxs(Stack, { direction: "row", spacing: 2, children: [jsx(Typography, { variant: "body1", width: "250px", children: "Purchase Order Number" }), jsx(Typography, { variant: "body2", children: data.return_number })] }), jsx(Stack, { direction: "row", spacing: 2, children: jsx(Typography, { variant: "body1", width: "250px", children: "Custom reference" }) }), jsxs(Stack, { direction: "row", spacing: 2, children: [jsx(Typography, { variant: "body1", width: "250px", children: "Order Date" }), jsx(Typography, { variant: "body2", children: data.return_date })] }), jsx(Stack, { direction: "row", spacing: 2, children: jsx(Typography, { variant: "body1", width: "250px", children: "Supplier" }) }), jsxs(Stack, { direction: "row", spacing: 2, children: [jsx(Typography, { variant: "body1", width: "250px", children: "Order Status" }), jsx(Typography, { variant: "body2", width: "250px", children: data.internal_status })] })] }) }), jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h5", children: "Documents" }), jsx(Paper, { sx: { p: 2 }, children: jsx(Stack, { spacing: 1, children: role === "enduser" && (jsx(Fragment, {})) }) })] }) }), data?.notes?.
|
|
54
|
-
data.iro_items.
|
|
53
|
+
], children: jsxs(Grid, { container: true, spacing: 2, children: [jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsxs(Stack, { direction: "row", spacing: 2, justifyContent: "space-between", children: [jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h3", component: "h1", children: "Management Inbound Purchase Order" }), jsx(Typography, { variant: "body1", children: "Manage arrival, registration and recieval of purchase order" })] }), jsx(NoteTakingComponent, { content: "", related: [{ id: data.id, __type: "api::logistics.ipo" }], revalidateCallback: revalidateCallback })] }), jsx(Divider, {})] }) }), jsx(Grid, { item: true, xs: 6, children: jsxs(Stack, { spacing: 1, children: [jsx(Typography, { variant: "h5", children: "Details" }), jsxs(Stack, { direction: "row", spacing: 2, children: [jsx(Typography, { variant: "body1", width: "250px", children: "Purchase Order Number" }), jsx(Typography, { variant: "body2", children: data.return_number })] }), jsx(Stack, { direction: "row", spacing: 2, children: jsx(Typography, { variant: "body1", width: "250px", children: "Custom reference" }) }), jsxs(Stack, { direction: "row", spacing: 2, children: [jsx(Typography, { variant: "body1", width: "250px", children: "Order Date" }), jsx(Typography, { variant: "body2", children: data.return_date })] }), jsx(Stack, { direction: "row", spacing: 2, children: jsx(Typography, { variant: "body1", width: "250px", children: "Supplier" }) }), jsxs(Stack, { direction: "row", spacing: 2, children: [jsx(Typography, { variant: "body1", width: "250px", children: "Order Status" }), jsx(Typography, { variant: "body2", width: "250px", children: data.internal_status })] })] }) }), jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h5", children: "Documents" }), jsx(Paper, { sx: { p: 2 }, children: jsx(Stack, { spacing: 1, children: role === "enduser" && (jsx(Fragment, {})) }) })] }) }), data?.notes?.length > 0 && (jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h5", children: "Notes" }), jsx(NotesDisplay, { notes: data.notes }), jsx(Divider, {})] }) })), jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 1, children: [jsx(Typography, { variant: "h5", children: "Items" }), jsx(Divider, {}), jsxs("form", { action: formAction, children: [jsx("input", { name: "id", type: "hidden", value: data.id }), data?.iro_items &&
|
|
54
|
+
data.iro_items.map((item, index) => {
|
|
55
55
|
console.log("item", item);
|
|
56
56
|
return (jsx(Paper, { sx: { p: 2, mb: 2 } }, index));
|
|
57
57
|
}), jsx(Paper, { sx: { p: 2 }, children: jsxs(Stack, { direction: "row", spacing: 2, justifyContent: "end", children: [jsx(SubmitButton, { text: "Update items", loadingText: "Loading..." }), jsx(StrapiErrors, { error: formState?.strapiErrors }), formState?.message && (jsx(Alert, { severity: "error", children: formState?.message }))] }) }), jsx("input", { type: "hidden", name: "items", value: JSON.stringify(parseItems(items)) })] })] }) })] }) }));
|
|
@@ -143,7 +143,7 @@ function RmaForm({ opo, sx, revalidateCallback, handleClose, }) {
|
|
|
143
143
|
});
|
|
144
144
|
}
|
|
145
145
|
}, [formState?.strapiErrors]);
|
|
146
|
-
return (jsx(Box, { sx: [...(Array.isArray(sx) ? sx : [sx])], children: jsx("form", { action: formAction, children: jsxs(Grid, { container: true, spacing: 2, children: [jsx(Grid, { item: true, xs: 12, children: jsx(Typography, { variant: "h6", children: "RMA Form" }) }), jsx("input", { type: "hidden", name: "opos", value: JSON.stringify([opo.id]) }), jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "body1", children: "Please fill out the form below to request a return merchandise authorization. Due to the sensitive nature of the products, only unopened packages can be returned." }), jsx(Alert, { severity: "warning", children: "We urge you to carefully photograph the items you are returning. These pictures can be requested at a later time by our team to verify the condition of the items." })] }) }), jsx(Grid, { item: true, xs: 12, children: opo.opo_items
|
|
146
|
+
return (jsx(Box, { sx: [...(Array.isArray(sx) ? sx : [sx])], children: jsx("form", { action: formAction, children: jsxs(Grid, { container: true, spacing: 2, children: [jsx(Grid, { item: true, xs: 12, children: jsx(Typography, { variant: "h6", children: "RMA Form" }) }), jsx("input", { type: "hidden", name: "opos", value: JSON.stringify([opo.id]) }), jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "body1", children: "Please fill out the form below to request a return merchandise authorization. Due to the sensitive nature of the products, only unopened packages can be returned." }), jsx(Alert, { severity: "warning", children: "We urge you to carefully photograph the items you are returning. These pictures can be requested at a later time by our team to verify the condition of the items." })] }) }), jsx(Grid, { item: true, xs: 12, children: opo.opo_items ? (jsx(Stack, { spacing: 1, children: opo.opo_items && (jsx(ItemLines, { items: opo.opo_items, itemsToReturn: itemsToReturn, setItemsToReturn: setItemsToReturn, selectedItems: selectedItems, setSelectedItems: setSelectedItems })) })) : (jsx(Typography, { variant: "body1", children: "No items" })) }), jsx(ConfirmRMADialog, { formState: formState, open: open, items: itemsToReturn.filter((item) => item.returned_quantity > 0), onClose: () => setOpen(!open), submitCallback: () => {
|
|
147
147
|
console.log("submit callback");
|
|
148
148
|
const formElement = document.querySelector("form");
|
|
149
149
|
if (formElement) {
|
|
@@ -23,23 +23,23 @@ function TextualIROItemUpdater({ item, index, handleAddReport, handleUpdateQuant
|
|
|
23
23
|
const { line_item_number, product, returned_quantity, received_quantity, registered_quantity, released_quantity, reports, reason, other_reason, } = item;
|
|
24
24
|
const [open, setOpen] = useState(false);
|
|
25
25
|
// these values where wrapped with useMemo before but that did not work well while updating values
|
|
26
|
-
reports
|
|
27
|
-
? reports
|
|
26
|
+
reports !== undefined && reports.length > 0
|
|
27
|
+
? reports
|
|
28
28
|
.filter((report) => report.type === "received")
|
|
29
29
|
.reduce((a, b) => a + b.quantity, 0)
|
|
30
30
|
: 0;
|
|
31
|
-
const registered_reports_quantity = reports
|
|
32
|
-
? reports
|
|
31
|
+
const registered_reports_quantity = reports !== undefined && reports.length > 0
|
|
32
|
+
? reports
|
|
33
33
|
.filter((report) => report.type === "registered")
|
|
34
34
|
.reduce((a, b) => a + b.quantity, 0)
|
|
35
35
|
: 0;
|
|
36
|
-
reports
|
|
37
|
-
? reports
|
|
36
|
+
reports !== undefined && reports.length > 0
|
|
37
|
+
? reports
|
|
38
38
|
.filter((report) => report.type === "released")
|
|
39
39
|
.reduce((a, b) => a + b.quantity, 0)
|
|
40
40
|
: 0;
|
|
41
|
-
const dbReports = item.reports?.
|
|
42
|
-
const preReports = item.reports?.
|
|
41
|
+
const dbReports = item.reports?.filter((report) => "id" in report) || [];
|
|
42
|
+
const preReports = item.reports?.filter((report) => Boolean("id" in report) === false) ||
|
|
43
43
|
[];
|
|
44
44
|
return (jsx(Stack, { spacing: 1, children: item && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsxs(Typography, { variant: "body1", children: ["Line Item Number: ", line_item_number] }), jsxs(Typography, { variant: "body1", children: ["Part Number: ", product?.product_number] }), image && (jsx(Fragment, { children: jsx(ImagePreviewTooltip, { image: image, label: item.product?.title }) }))] }), jsxs(Typography, { variant: "body1", children: ["Reason: ", reason, reason === "other" &&
|
|
45
45
|
other_reason !== undefined &&
|
|
@@ -55,7 +55,7 @@ function OverwritesDialog({ open, handleClose, overwrites, setOverwrites, iro, }
|
|
|
55
55
|
const query = qs.stringify({
|
|
56
56
|
filters: {
|
|
57
57
|
product_number: {
|
|
58
|
-
$in: iro.iro_items.
|
|
58
|
+
$in: iro.iro_items.map((item) => item.product?.product_number?.replace(/^r-/, "") || ""),
|
|
59
59
|
},
|
|
60
60
|
},
|
|
61
61
|
populate: {
|
|
@@ -76,7 +76,7 @@ function OverwritesDialog({ open, handleClose, overwrites, setOverwrites, iro, }
|
|
|
76
76
|
let totalExclVat = 0;
|
|
77
77
|
let totalInclVat = 0;
|
|
78
78
|
// Create line overwrites for each item
|
|
79
|
-
const lineOverwrites = iro.iro_items.
|
|
79
|
+
const lineOverwrites = iro.iro_items.map((item, index) => {
|
|
80
80
|
const product = item.product;
|
|
81
81
|
const correspondingProduct = correspondingProducts.find((p) => p.product_number === product?.product_number?.replace(/^r-/, "") ||
|
|
82
82
|
"");
|
|
@@ -110,7 +110,7 @@ function OverwritesDialog({ open, handleClose, overwrites, setOverwrites, iro, }
|
|
|
110
110
|
lines: lineOverwrites,
|
|
111
111
|
});
|
|
112
112
|
};
|
|
113
|
-
if (open && iro?.iro_items?.
|
|
113
|
+
if (open && iro?.iro_items?.length > 0) {
|
|
114
114
|
fetchProducts();
|
|
115
115
|
}
|
|
116
116
|
}, [open, iro]);
|
|
@@ -123,7 +123,7 @@ function OverwritesDialog({ open, handleClose, overwrites, setOverwrites, iro, }
|
|
|
123
123
|
}) }), jsx(TextField, { label: "Total incl. VAT", name: "total_incl_vat", type: "number", fullWidth: true, variant: "outlined", value: overwrites.total_incl_vat, onChange: (e) => setOverwrites({
|
|
124
124
|
...overwrites,
|
|
125
125
|
total_incl_vat: parseFloat(e.target.value),
|
|
126
|
-
}) })] })), iro?.iro_items?.
|
|
126
|
+
}) })] })), iro?.iro_items?.length > 0 && (jsxs(Fragment, { children: [jsx(DialogContentText, { variant: "h5", children: "Items" }), iro.iro_items.map((item, index) => {
|
|
127
127
|
return (jsxs(Stack, { spacing: 2, direction: "row", alignItems: "center", sx: { px: 2 }, children: [jsx(Typography, { sx: { minWidth: 100 }, children: item.line_item_number }), jsx(Typography, { sx: { minWidth: 150 }, children: item.product?.product_number }), jsx(Typography, { sx: { minWidth: 200 }, children: item.product?.title }), jsx(TextField, { size: "small", label: "VAT %", name: "vat_rate", type: "number", sx: { width: 100 }, value: overwrites?.lines?.[index]?.vat_rate ?? "", onChange: (e) => {
|
|
128
128
|
const newLines = [...(overwrites.lines || [])];
|
|
129
129
|
newLines[index] = {
|
|
@@ -166,7 +166,7 @@ function OverwritesDialog({ open, handleClose, overwrites, setOverwrites, iro, }
|
|
|
166
166
|
});
|
|
167
167
|
} })] }, item.id));
|
|
168
168
|
})] }))] }) }), jsxs(DialogActions, { children: [jsx(Button, { variant: "contained", onClick: (e) => {
|
|
169
|
-
confirmationService("iros", [iro.
|
|
169
|
+
confirmationService("iros", [iro.documentId], overwrites);
|
|
170
170
|
handleClose();
|
|
171
171
|
}, children: "Confirm" }), jsx(Button, { variant: "contained", onClick: handleClose, children: "Cancel" })] })] }));
|
|
172
172
|
}
|
|
@@ -246,7 +246,7 @@ function TextualManageIROForm({ data, sx,
|
|
|
246
246
|
revalidateCallback, handleClose, role, }) {
|
|
247
247
|
// TODO bind to id of IRO
|
|
248
248
|
const [formState, formAction] = useFormState(updateIroAction, INITIAL_STATE);
|
|
249
|
-
const [items, setItems] = useState(data.iro_items
|
|
249
|
+
const [items, setItems] = useState(data.iro_items ? data.iro_items : []);
|
|
250
250
|
const [confirmDialogOpen, setConfirmDialogOpen] = useState(false);
|
|
251
251
|
const [cancelDialogOpen, setCancelDialogOpen] = useState(false);
|
|
252
252
|
const [overwritesDialogOpen, setOverwritesDialogOpen] = useState(false);
|
|
@@ -271,7 +271,7 @@ revalidateCallback, handleClose, role, }) {
|
|
|
271
271
|
received_quantity: item.received_quantity,
|
|
272
272
|
registered_quantity: item.registered_quantity,
|
|
273
273
|
released_quantity: item.released_quantity,
|
|
274
|
-
reports: item.reports?.
|
|
274
|
+
reports: item.reports?.map((report) => {
|
|
275
275
|
return {
|
|
276
276
|
id: "id" in report ? report.id : undefined,
|
|
277
277
|
quantity: report.quantity,
|
|
@@ -294,23 +294,23 @@ revalidateCallback, handleClose, role, }) {
|
|
|
294
294
|
const handleAddReport = (report, itemID) => {
|
|
295
295
|
const newItems = [...items];
|
|
296
296
|
const index = newItems.findIndex((item) => item.id === itemID);
|
|
297
|
-
const reportsOnItem = newItems[index]?.reports
|
|
297
|
+
const reportsOnItem = newItems[index]?.reports || [];
|
|
298
298
|
const newReports = [...reportsOnItem, report];
|
|
299
299
|
if (newItems[index]?.reports == undefined) {
|
|
300
|
-
newItems[index] = { ...newItems[index], reports:
|
|
300
|
+
newItems[index] = { ...newItems[index], reports: [] };
|
|
301
301
|
}
|
|
302
|
-
newItems[index].reports
|
|
302
|
+
newItems[index].reports = newReports;
|
|
303
303
|
setItems(newItems);
|
|
304
304
|
};
|
|
305
305
|
const handleRemoveReportAtIndex = (itemID, index) => {
|
|
306
306
|
const newItems = [...items];
|
|
307
307
|
const itemIndex = newItems.findIndex((item) => item.id === itemID);
|
|
308
|
-
const reportsOnItem = newItems[itemIndex]?.reports
|
|
308
|
+
const reportsOnItem = newItems[itemIndex]?.reports || [];
|
|
309
309
|
const dbReports = reportsOnItem.filter((report) => "id" in report);
|
|
310
310
|
const preReports = reportsOnItem.filter((report) => !("id" in report));
|
|
311
311
|
preReports.splice(index, 1);
|
|
312
312
|
const newReports = [...dbReports, ...preReports];
|
|
313
|
-
newItems[itemIndex].reports
|
|
313
|
+
newItems[itemIndex].reports = newReports;
|
|
314
314
|
setItems(newItems);
|
|
315
315
|
};
|
|
316
316
|
const { handleAddMessage } = useSnackbar();
|
|
@@ -336,13 +336,13 @@ revalidateCallback, handleClose, role, }) {
|
|
|
336
336
|
}, [formState?.strapiErrors]);
|
|
337
337
|
useEffect(() => {
|
|
338
338
|
console.log("data", data);
|
|
339
|
-
if (data.iro_items
|
|
340
|
-
setItems(data.iro_items
|
|
339
|
+
if (data.iro_items) {
|
|
340
|
+
setItems(data.iro_items ? data.iro_items : []);
|
|
341
341
|
}
|
|
342
342
|
}, [data]);
|
|
343
343
|
return (jsx(Box, { sx: [...(Array.isArray(sx) ? sx : [sx])], children: jsxs(Grid, { container: true, spacing: 2, children: [jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsxs(Stack, { direction: "row", spacing: 2, justifyContent: "space-between", children: [jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h3", component: "h1", children: "Management Inbound Return" }), jsx(Typography, { variant: "body1", children: "Manage arrival, registration and release of returns" })] }), jsx(NoteTakingComponent, { content: "", related: [{ id: data.id, __type: "api::e-commerce.iro" }], revalidateCallback: revalidateCallback })] }), jsx(Divider, {})] }) }), jsx(Grid, { item: true, xs: 12, children: jsx(Typography, { variant: "h5", sx: { py: 1 }, children: "Details" }) }), jsx(Grid, { item: true, xs: 6, children: jsx(Paper, { elevation: 2, sx: { p: 2, height: "100%" }, children: jsxs(Stack, { spacing: 2, children: [jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(NumbersIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Return Number" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: data.return_number })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(AssignmentReturnIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "RMA Number" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: data.rma_number })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(DescriptionIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Customer Reference" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: data.customer_reference })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(CalendarTodayIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Return Date" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: data.return_date })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(BusinessIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Customer" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: data.customer?.business_credentials?.company_name })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(UpdateIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Return Status" }), jsx(IroStatusIndicator, { status: data.internal_status })] })] }) }) }), (data.internal_status === "requested" ||
|
|
344
344
|
data.internal_status === "finalising_process") &&
|
|
345
|
-
role === "enduser" && (jsx(Grid, { item: true, xs: 6, children: jsx(Paper, { elevation: 2, sx: { p: 2, height: "100%" }, children: jsxs(Stack, { spacing: 2, children: [jsx(Button, { variant: "contained", color: "primary", onClick: () => setConfirmDialogOpen(true), children: "Confirm order" }), data.internal_status === "requested" && (jsx(Alert, { severity: "warning", children: "Please confirm the order as soon as possible, only upon confirmation this order will be assigned an RMA number and will become available to the dispatcher. Status: requested - returning" })), data.internal_status === "finalising_process" && (jsx(Alert, { severity: "warning", children: "Please finalise this return order. Make sure the customer receives a return payment if eligible and then confirm this step. Status: finalising_process - done" })), data.internal_status === "finalising_process" && (jsx(Button, { variant: "contained", sx: { color: "yellow" }, children: "// TODO RE-PAYMENT PROCESS" })), jsx(Button, { variant: "contained", color: "error", onClick: () => setCancelDialogOpen(true), children: "Cancel order" }), jsx(ConfirmFormDialog, { open: confirmDialogOpen, handleClose: () => setConfirmDialogOpen(false), orderID: data.
|
|
345
|
+
role === "enduser" && (jsx(Grid, { item: true, xs: 6, children: jsx(Paper, { elevation: 2, sx: { p: 2, height: "100%" }, children: jsxs(Stack, { spacing: 2, children: [jsx(Button, { variant: "contained", color: "primary", onClick: () => setConfirmDialogOpen(true), children: "Confirm order" }), data.internal_status === "requested" && (jsx(Alert, { severity: "warning", children: "Please confirm the order as soon as possible, only upon confirmation this order will be assigned an RMA number and will become available to the dispatcher. Status: requested - returning" })), data.internal_status === "finalising_process" && (jsx(Alert, { severity: "warning", children: "Please finalise this return order. Make sure the customer receives a return payment if eligible and then confirm this step. Status: finalising_process - done" })), data.internal_status === "finalising_process" && (jsx(Button, { variant: "contained", sx: { color: "yellow" }, children: "// TODO RE-PAYMENT PROCESS" })), jsx(Button, { variant: "contained", color: "error", onClick: () => setCancelDialogOpen(true), children: "Cancel order" }), jsx(ConfirmFormDialog, { open: confirmDialogOpen, handleClose: () => setConfirmDialogOpen(false), orderID: data.documentId, currentStatus: data.internal_status, revalidateCallback: revalidateCallback, openOverwritesDialog: () => setOverwritesDialogOpen(true) }), jsx(OverwritesDialog, { open: overwritesDialogOpen, handleClose: () => setOverwritesDialogOpen(false), overwrites: overwrites, setOverwrites: setOverwrites, iro: data }), jsx(CancelIroDialog, { open: cancelDialogOpen, handleClose: () => setCancelDialogOpen(false), orderID: data.documentId, revalidateCallback: revalidateCallback })] }) }) })), jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h5", children: "Documents" }), jsx(Paper, { sx: { p: 2 }, children: jsx(Stack, { spacing: 1 }) })] }) }), data?.notes?.length > 0 && (jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h5", children: "Notes" }), jsx(NotesDisplay, { notes: data.notes }), jsx(Divider, {})] }) })), jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 1, children: [jsx(Typography, { variant: "h5", children: "Items" }), jsxs(Stack, { direction: "row", alignItems: "center", justifyContent: "flex-end", spacing: 2, component: Paper, p: 1, sx: {
|
|
346
346
|
bgcolor: "background.default",
|
|
347
347
|
border: "1px solid",
|
|
348
348
|
borderColor: "divider",
|
|
@@ -120,7 +120,7 @@ revalidateCallback, handleClose, role, }) {
|
|
|
120
120
|
const boundUpdateOpoAction = (prevState, formData) => updateOpoAction(opo.id, prevState, formData);
|
|
121
121
|
const [formState, formAction] = useFormState(boundUpdateOpoAction, INITIAL_STATE);
|
|
122
122
|
const { handleAddMessage } = useSnackbar();
|
|
123
|
-
const [items, setItems] = useState(opo.opo_items
|
|
123
|
+
const [items, setItems] = useState(opo.opo_items ? opo.opo_items : []);
|
|
124
124
|
const [confirmDialogOpen, setConfirmDialogOpen] = useState(false);
|
|
125
125
|
const parseItems = (items) => {
|
|
126
126
|
return items.map((item) => {
|
|
@@ -140,8 +140,8 @@ revalidateCallback, handleClose, role, }) {
|
|
|
140
140
|
setItems(newItems);
|
|
141
141
|
};
|
|
142
142
|
useEffect(() => {
|
|
143
|
-
if (opo.opo_items
|
|
144
|
-
setItems(opo.opo_items
|
|
143
|
+
if (opo.opo_items) {
|
|
144
|
+
setItems(opo.opo_items);
|
|
145
145
|
}
|
|
146
146
|
}, [opo]);
|
|
147
147
|
useEffect(() => {
|
|
@@ -169,9 +169,9 @@ revalidateCallback, handleClose, role, }) {
|
|
|
169
169
|
...(Array.isArray(sx) ? sx : [sx]),
|
|
170
170
|
], children: jsxs(Grid, { container: true, spacing: 2, children: [jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsxs(Stack, { direction: "row", spacing: 2, justifyContent: "space-between", children: [jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h3", component: "h1", children: "Manage Outbound Purchase Order" }), jsx(Typography, { variant: "body1", children: "Manage picking, packing and shipping of purchase order" })] }), jsx(NoteTakingComponent, { content: "", related: [{ id: opo.id, __type: "api::e-commerce.opo" }], revalidateCallback: revalidateCallback })] }), jsx(Divider, {})] }) }), jsx(Grid, { item: true, xs: 6, children: jsxs(Stack, { spacing: 1, children: [jsx(Typography, { variant: "h5", children: "Details" }), jsxs(Stack, { direction: "row", spacing: 2, children: [jsx(Typography, { variant: "body1", width: "250px", children: "Purchase Order Number" }), jsx(Typography, { variant: "body2", children: opo.opo_number })] }), jsxs(Stack, { direction: "row", spacing: 2, children: [jsx(Typography, { variant: "body1", width: "250px", children: "Custom reference" }), jsx(Typography, { variant: "body2", children: opo.customer_reference })] }), jsxs(Stack, { direction: "row", spacing: 2, children: [jsx(Typography, { variant: "body1", width: "250px", children: "Order Date" }), jsx(Typography, { variant: "body2", children: opo.order_date })] }), jsxs(Stack, { direction: "row", spacing: 2, children: [jsx(Typography, { variant: "body1", width: "250px", children: "Customer" }), jsx(Typography, { variant: "body2", children: opo.customer?.business_credentials?.company_name })] }), jsxs(Stack, { direction: "row", spacing: 2, children: [jsx(Typography, { variant: "body1", width: "250px", children: "Order Status" }), jsx(Typography, { variant: "body2", width: "250px", children: opo.internal_status })] }), (opo.internal_status === "placed" ||
|
|
171
171
|
opo.internal_status === "external_shipping_process") &&
|
|
172
|
-
role === "enduser" && (jsxs(Fragment, { children: [jsx(Button, { variant: "contained", color: "primary", onClick: () => setConfirmDialogOpen(true), children: "Confirm order" }), jsx(Alert, { severity: "warning", children: "Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher" }), jsx(ConfirmFormDialog, { open: confirmDialogOpen, handleClose: () => setConfirmDialogOpen(false), orderID: opo.
|
|
172
|
+
role === "enduser" && (jsxs(Fragment, { children: [jsx(Button, { variant: "contained", color: "primary", onClick: () => setConfirmDialogOpen(true), children: "Confirm order" }), jsx(Alert, { severity: "warning", children: "Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher" }), jsx(ConfirmFormDialog, { open: confirmDialogOpen, handleClose: () => setConfirmDialogOpen(false), orderID: opo.documentId, currentStatus: opo.internal_status, revalidateCallback: revalidateCallback })] }))] }) }), jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h5", children: "Documents" }), jsx(Paper, { sx: { p: 2 }, children: jsx(Stack, { spacing: 1, children: opo.delivery_note ? (jsxs(Fragment, { children: [jsx(Typography, { variant: "h6", children: "Delivery Note" }), jsx(Typography, { children: opo.delivery_note?.name }), jsx(Button, { variant: "contained", onClick: () => {
|
|
173
173
|
downloadBase64File(`api/opos/${opo.id}`, "delivery_note");
|
|
174
|
-
}, children: "Download" })] })) : (jsxs(Fragment, { children: [jsx(Typography, { variant: "h5", children: "Delivery Note" }), jsx(Typography, { variant: "body1", children: "Here you can upload the the delivery note for this order" }), jsx(Divider, {}), jsx(UploadBase64MediaForm, { reference: "api::e-commerce.opo", refID: opo.id, field: "delivery_note", multiple: false, accept: "text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document", path: "api/opos", componentName: "delivery_note", componentReference: "common.base64-encoded-media", revalidateCallback: revalidateCallback })] })) }) })] }) }), opo?.notes?.
|
|
174
|
+
}, children: "Download" })] })) : (jsxs(Fragment, { children: [jsx(Typography, { variant: "h5", children: "Delivery Note" }), jsx(Typography, { variant: "body1", children: "Here you can upload the the delivery note for this order" }), jsx(Divider, {}), jsx(UploadBase64MediaForm, { reference: "api::e-commerce.opo", refID: opo.id, field: "delivery_note", multiple: false, accept: "text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document", path: "api/opos", componentName: "delivery_note", componentReference: "common.base64-encoded-media", revalidateCallback: revalidateCallback })] })) }) })] }) }), opo?.notes?.length > 0 && (jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h5", children: "Notes" }), jsx(NotesDisplay, { notes: opo.notes }), jsx(Divider, {})] }) })), jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 1, children: [jsx(Typography, { variant: "h5", children: "Items" }), opo.internal_status === "placed" && (jsx(Alert, { severity: "warning", children: "Before confirmation you cannot update the items" })), jsx(Divider, {}), jsxs("form", { action: formAction, children: [jsx("input", { name: "id", type: "hidden", value: opo.id }), items &&
|
|
175
175
|
items.map((item, index) => {
|
|
176
176
|
console.log("item", item);
|
|
177
177
|
return (jsx(Paper, { sx: { p: 2, mb: 2 }, children: opo.internal_status === "placed" ? (jsx(OpoItemDisplay, { item: item, index: index, image: item?.product?.image })) : (jsx(OpoItemUpdater, { item: item, index: index, handleUpdateQuantity: handleUpdateQuantity, image: item?.product?.image, revalidateCallback: revalidateCallback })) }, index));
|
|
@@ -12,7 +12,7 @@ import ReportsDisplay from '../../logistics/report/ReportsDisplay.js';
|
|
|
12
12
|
|
|
13
13
|
function OpoItemDisplay({ item, index, image }) {
|
|
14
14
|
const { line_item_number, product, ordered_quantity, picked_quantity, packed_quantity, shipped_quantity, reports, } = item;
|
|
15
|
-
return (jsxs(Stack, { spacing: 1, children: [item && (jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", children: [jsxs(Stack, { spacing: 1, children: [jsxs(Typography, { variant: "body1", children: ["Line Item Number: ", line_item_number] }), jsxs(Typography, { variant: "body1", children: ["Part Number: ", product?.product_number] })] }), image && (jsx(Fragment, { children: jsx(ImagePreviewTooltip, { image: image, label: item.product?.title }) }))] })), jsxs(Stack, { direction: "row", spacing: 1, justifyContent: "space-between", alignItems: "center", children: [jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(Typography, { variant: "caption", children: "Ordered" }), jsx(Typography, { variant: "h6", children: ordered_quantity })] }), jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(Typography, { variant: "caption", children: "Received" }), jsx(Typography, { variant: "h6", children: picked_quantity })] }), jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(Typography, { variant: "caption", children: "Registered" }), jsx(Typography, { variant: "h6", children: packed_quantity })] }), jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(Typography, { variant: "caption", children: "Released" }), jsx(Typography, { variant: "h6", children: shipped_quantity })] })] }), reports?.
|
|
15
|
+
return (jsxs(Stack, { spacing: 1, children: [item && (jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", children: [jsxs(Stack, { spacing: 1, children: [jsxs(Typography, { variant: "body1", children: ["Line Item Number: ", line_item_number] }), jsxs(Typography, { variant: "body1", children: ["Part Number: ", product?.product_number] })] }), image && (jsx(Fragment, { children: jsx(ImagePreviewTooltip, { image: image, label: item.product?.title }) }))] })), jsxs(Stack, { direction: "row", spacing: 1, justifyContent: "space-between", alignItems: "center", children: [jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(Typography, { variant: "caption", children: "Ordered" }), jsx(Typography, { variant: "h6", children: ordered_quantity })] }), jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(Typography, { variant: "caption", children: "Received" }), jsx(Typography, { variant: "h6", children: picked_quantity })] }), jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(Typography, { variant: "caption", children: "Registered" }), jsx(Typography, { variant: "h6", children: packed_quantity })] }), jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(Typography, { variant: "caption", children: "Released" }), jsx(Typography, { variant: "h6", children: shipped_quantity })] })] }), reports?.length > 0 && (jsxs(Stack, { spacing: 1, children: [jsx(Typography, { variant: "body1", children: "Reports:" }), jsx(ReportsDisplay, { reports: reports.filter((report) => "documentId" in report && !("pre_report" in report)) })] }))] }, index));
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export { OpoItemDisplay as default };
|
|
@@ -23,22 +23,22 @@ revalidateCallback, }) {
|
|
|
23
23
|
const { line_item_number, product, ordered_quantity, picked_quantity, packed_quantity, shipped_quantity, reports, } = item;
|
|
24
24
|
const [open, setOpen] = useState(false);
|
|
25
25
|
React.useMemo(() => {
|
|
26
|
-
return reports
|
|
27
|
-
? reports
|
|
26
|
+
return reports !== undefined && reports.length > 0
|
|
27
|
+
? reports
|
|
28
28
|
.filter((report) => report.type === "picked")
|
|
29
29
|
.reduce((a, b) => a + b.quantity, 0)
|
|
30
30
|
: 0;
|
|
31
31
|
}, [reports]);
|
|
32
32
|
const packed_reports_quantity = React.useMemo(() => {
|
|
33
|
-
return reports
|
|
34
|
-
? reports
|
|
33
|
+
return reports !== undefined && reports.length > 0
|
|
34
|
+
? reports
|
|
35
35
|
.filter((report) => report.type === "packed")
|
|
36
36
|
.reduce((a, b) => a + b.quantity, 0)
|
|
37
37
|
: 0;
|
|
38
38
|
}, [reports]);
|
|
39
39
|
React.useMemo(() => {
|
|
40
|
-
return reports
|
|
41
|
-
? reports
|
|
40
|
+
return reports !== undefined && reports.length > 0
|
|
41
|
+
? reports
|
|
42
42
|
.filter((report) => report.type === "shipped")
|
|
43
43
|
.reduce((a, b) => a + b.quantity, 0)
|
|
44
44
|
: 0;
|
|
@@ -47,7 +47,8 @@ revalidateCallback, }) {
|
|
|
47
47
|
handleUpdateQuantity(newValue, item.id, "picked_quantity");
|
|
48
48
|
} }), jsx(Typography, { variant: "body2", children: "Packed" }), jsx(AmountUpdater, { currentValue: packed_quantity, totalValue: ordered_quantity, minNewValue: 0 + shipped_quantity, maxNewValue: picked_quantity + packed_reports_quantity, color: "info", handleChange: (newValue) => {
|
|
49
49
|
handleUpdateQuantity(newValue, item.id, "packed_quantity");
|
|
50
|
-
}, offsetEnd: packed_reports_quantity }), jsx(Divider, { sx: { p: 0 }, children: jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(Typography, { variant: "body2", children: "Irregularities / Corrections" }), jsx(IconButton, { onClick: () => setOpen(!open), children: jsx(ArrowButtonDownIcon, {}) })] }) }), jsx(Collapse, { in: open, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "body2", children: "Here you can report and correct for damages wrong items etc. Do not forget to click the button!" }), jsx(ReportsDisplay, { reports: reports.
|
|
50
|
+
}, offsetEnd: packed_reports_quantity }), jsx(Divider, { sx: { p: 0 }, children: jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(Typography, { variant: "body2", children: "Irregularities / Corrections" }), jsx(IconButton, { onClick: () => setOpen(!open), children: jsx(ArrowButtonDownIcon, {}) })] }) }), jsx(Collapse, { in: open, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "body2", children: "Here you can report and correct for damages wrong items etc. Do not forget to click the button!" }), jsx(ReportsDisplay, { reports: reports.filter((report) => "documentId" in report &&
|
|
51
|
+
typeof report.documentId === "string") }), jsx(ReportMakingComponent, { content: "content", quantity: 0, type: "packed", minValue: -(picked_quantity + packed_reports_quantity), maxValue: 0, related: [{ id: item.id, __type: "api::e-commerce.opo-item" }], revalidateCallback: revalidateCallback })] }) }), jsx(Typography, { variant: "body2", children: "Shipped" }), jsx(AmountUpdater, { currentValue: shipped_quantity, totalValue: ordered_quantity, minNewValue: 0, maxNewValue: packed_quantity, color: "info", handleChange: (newValue) => {
|
|
51
52
|
handleUpdateQuantity(newValue, item.id, "shipped_quantity");
|
|
52
53
|
} })] })) }, index));
|
|
53
54
|
}
|
|
@@ -23,8 +23,8 @@ function OpoSummary({ opo }) {
|
|
|
23
23
|
return jsx(Typography, { children: "Loading..." });
|
|
24
24
|
}
|
|
25
25
|
console.log("opo_items", opo_items);
|
|
26
|
-
return (jsx(Box, { sx: { p: { xs: 1, md: 2 } }, children: opo_items != null ? (jsxs(Table, { children: [jsx(TableHead, { children: jsxs(TableRow, { children: [jsx(TableCell, { children: "Amount" }), jsx(TableCell, { children: "Product Title" }), jsx(TableCell, { children: "Price Excl. VAT" }), jsx(TableCell, { children: "Price Incl. VAT" })] }) }), jsx(TableBody, { children: opo_items
|
|
27
|
-
opo_items.
|
|
26
|
+
return (jsx(Box, { sx: { p: { xs: 1, md: 2 } }, children: opo_items != null ? (jsxs(Table, { children: [jsx(TableHead, { children: jsxs(TableRow, { children: [jsx(TableCell, { children: "Amount" }), jsx(TableCell, { children: "Product Title" }), jsx(TableCell, { children: "Price Excl. VAT" }), jsx(TableCell, { children: "Price Incl. VAT" })] }) }), jsx(TableBody, { children: opo_items &&
|
|
27
|
+
opo_items.map((item) => (jsx(OpoSummaryRow, { data: item }, item.id))) }), jsxs(TableFooter, { children: [jsxs(TableRow, { children: [jsx(TableCell, { colSpan: 3, align: "right", children: "Total excl VAT" }), jsxs(TableCell, { colSpan: 1, align: "left", children: ["\u20AC ", opo.total_excl_vat] })] }), jsxs(TableRow, { children: [jsx(TableCell, { colSpan: 3, align: "right", children: "Total incl VAT" }), jsxs(TableCell, { colSpan: 1, align: "left", children: ["\u20AC ", opo.total_incl_vat] })] })] })] })) : (jsx(Typography, { children: "No products in cart" })) }));
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export { OpoSummary };
|
|
@@ -85,7 +85,7 @@ function TextualManageOPOForm({ opo, sx, revalidateCallback, handleClose, role,
|
|
|
85
85
|
const updateOpoWithIdAction = updateOpoAction.bind(null, opo.id);
|
|
86
86
|
const [formState, formAction] = useFormState(updateOpoWithIdAction, INITIAL_STATE);
|
|
87
87
|
const { handleAddMessage } = useSnackbar();
|
|
88
|
-
const [items, setItems] = useState(opo.opo_items
|
|
88
|
+
const [items, setItems] = useState(opo.opo_items ? opo.opo_items : []);
|
|
89
89
|
const [confirmDialogOpen, setConfirmDialogOpen] = useState(false);
|
|
90
90
|
const [cancelDialogOpen, setCancelDialogOpen] = useState(false);
|
|
91
91
|
const [showing, setShowing] = useState(["picked", "packed", "shipped", "reports"]);
|
|
@@ -113,8 +113,8 @@ function TextualManageOPOForm({ opo, sx, revalidateCallback, handleClose, role,
|
|
|
113
113
|
}, [formState?.strapiErrors]);
|
|
114
114
|
// Items state update
|
|
115
115
|
useEffect(() => {
|
|
116
|
-
if (opo.opo_items
|
|
117
|
-
setItems(opo.opo_items
|
|
116
|
+
if (opo.opo_items) {
|
|
117
|
+
setItems(opo.opo_items ? opo.opo_items : []);
|
|
118
118
|
}
|
|
119
119
|
}, [opo]);
|
|
120
120
|
const parseItems = (items) => {
|
|
@@ -125,7 +125,7 @@ function TextualManageOPOForm({ opo, sx, revalidateCallback, handleClose, role,
|
|
|
125
125
|
picked_quantity: item.picked_quantity,
|
|
126
126
|
packed_quantity: item.packed_quantity,
|
|
127
127
|
shipped_quantity: item.shipped_quantity,
|
|
128
|
-
reports: item.reports?.
|
|
128
|
+
reports: item.reports?.map((report) => {
|
|
129
129
|
return {
|
|
130
130
|
id: "id" in report ? report.id : undefined,
|
|
131
131
|
quantity: report.quantity,
|
|
@@ -148,30 +148,30 @@ function TextualManageOPOForm({ opo, sx, revalidateCallback, handleClose, role,
|
|
|
148
148
|
const handleAddReport = (report, itemID) => {
|
|
149
149
|
const newItems = [...items];
|
|
150
150
|
const index = newItems.findIndex((item) => item.id === itemID);
|
|
151
|
-
const reportsOnItem = newItems[index]?.reports
|
|
151
|
+
const reportsOnItem = newItems[index]?.reports || [];
|
|
152
152
|
const newReports = [...reportsOnItem, report];
|
|
153
153
|
if (newItems[index]?.reports == undefined) {
|
|
154
|
-
newItems[index] = { ...newItems[index], reports:
|
|
154
|
+
newItems[index] = { ...newItems[index], reports: [] };
|
|
155
155
|
}
|
|
156
|
-
newItems[index].reports
|
|
156
|
+
newItems[index].reports = newReports;
|
|
157
157
|
setItems(newItems);
|
|
158
158
|
};
|
|
159
159
|
const handleRemoveReportAtIndex = (itemID, index) => {
|
|
160
160
|
const newItems = [...items];
|
|
161
161
|
const itemIndex = newItems.findIndex((item) => item.id === itemID);
|
|
162
|
-
const reportsOnItem = newItems[itemIndex]?.reports
|
|
162
|
+
const reportsOnItem = newItems[itemIndex]?.reports || [];
|
|
163
163
|
const dbReports = reportsOnItem.filter((report) => "id" in report);
|
|
164
164
|
const preReports = reportsOnItem.filter((report) => !("id" in report));
|
|
165
165
|
preReports.splice(index, 1);
|
|
166
166
|
const newReports = [...dbReports, ...preReports];
|
|
167
|
-
newItems[itemIndex].reports
|
|
167
|
+
newItems[itemIndex].reports = newReports;
|
|
168
168
|
setItems(newItems);
|
|
169
169
|
};
|
|
170
170
|
return (jsx(Box, { sx: [...(Array.isArray(sx) ? sx : [sx])], children: jsxs(Grid, { container: true, spacing: 2, children: [jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsxs(Stack, { direction: "row", spacing: 2, justifyContent: "space-between", children: [jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h3", component: "h1", children: "Management Outbound Purchase Order" }), jsx(Typography, { variant: "body1", children: "Manage picking, packing and shipping of purchase order" })] }), jsx(NoteTakingComponent, { content: "", related: [{ id: opo.id, __type: "api::e-commerce.opo" }], revalidateCallback: revalidateCallback })] }), jsx(Divider, {})] }) }), jsx(Grid, { item: true, xs: 12, children: jsx(Typography, { variant: "h5", sx: { py: 1 }, children: "Details" }) }), jsx(Grid, { item: true, xs: 6, children: jsx(Paper, { elevation: 2, sx: { p: 2, height: "100%" }, children: jsxs(Stack, { spacing: 2, children: [jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(NumbersIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Purchase Order Number" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: opo.opo_number })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(DescriptionIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Custom reference" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: opo.customer_reference })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(CalendarTodayIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Order Date" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: opo.order_date })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(BusinessIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Customer" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: opo.customer?.business_credentials?.company_name })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(UpdateIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Order Status" }), jsx(OpoStatusIndicator, { status: opo.internal_status })] })] }) }) }), role === "enduser" && (jsx(Grid, { item: true, xs: 6, children: jsx(Paper, { elevation: 2, sx: { p: 2, height: "100%" }, children: jsxs(Stack, { spacing: 2, children: [(opo.internal_status === "placed" ||
|
|
171
|
-
opo.internal_status === "external_shipping_process") && (jsxs(Fragment, { children: [jsx(Button, { variant: "contained", color: "primary", onClick: () => setConfirmDialogOpen(true), children: "Confirm order" }), jsx(Alert, { severity: "warning", children: "Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher" }), jsx(ConfirmFormDialog, { open: confirmDialogOpen, handleClose: () => setConfirmDialogOpen(false), orderID: opo.
|
|
172
|
-
opo.internal_status === "ordered") && (jsxs(Fragment, { children: [jsx(Button, { variant: "contained", color: "error", onClick: () => setCancelDialogOpen(true), children: "Cancel order" }), jsx(CancelOpoDialog, { open: cancelDialogOpen, handleClose: () => setCancelDialogOpen(false), orderID: opo.
|
|
171
|
+
opo.internal_status === "external_shipping_process") && (jsxs(Fragment, { children: [jsx(Button, { variant: "contained", color: "primary", onClick: () => setConfirmDialogOpen(true), children: "Confirm order" }), jsx(Alert, { severity: "warning", children: "Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher" }), jsx(ConfirmFormDialog, { open: confirmDialogOpen, handleClose: () => setConfirmDialogOpen(false), orderID: opo.documentId, currentStatus: opo.internal_status, revalidateCallback: revalidateCallback })] })), (opo.internal_status === "placed" ||
|
|
172
|
+
opo.internal_status === "ordered") && (jsxs(Fragment, { children: [jsx(Button, { variant: "contained", color: "error", onClick: () => setCancelDialogOpen(true), children: "Cancel order" }), jsx(CancelOpoDialog, { open: cancelDialogOpen, handleClose: () => setCancelDialogOpen(false), orderID: opo.documentId, revalidateCallback: revalidateCallback })] }))] }) }) })), jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h5", children: "Documents" }), jsx(Paper, { sx: { p: 2 }, children: jsx(Stack, { spacing: 1, children: opo.delivery_note ? (jsxs(Fragment, { children: [jsx(Typography, { variant: "h6", children: "Delivery Note" }), jsx(Typography, { children: opo.delivery_note?.name }), jsx(Button, { variant: "contained", onClick: () => {
|
|
173
173
|
downloadBase64File(`api/ipos/${opo.id}`, "delivery_note");
|
|
174
|
-
}, children: "Download" })] })) : (jsxs(Fragment, { children: [jsx(Typography, { variant: "h5", children: "Delivery Note" }), jsx(Typography, { variant: "body1", children: "Here you can upload the the delivery note for this order" }), jsx(Divider, {}), jsx(UploadBase64MediaForm, { reference: "api::e-commerce.opo", refID: opo.id, field: "delivery_note", multiple: false, accept: "text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document", path: "api/ipos", componentName: "delivery_note", componentReference: "common.base64-encoded-media", revalidateCallback: revalidateCallback })] })) }) })] }) }), opo?.notes?.
|
|
174
|
+
}, children: "Download" })] })) : (jsxs(Fragment, { children: [jsx(Typography, { variant: "h5", children: "Delivery Note" }), jsx(Typography, { variant: "body1", children: "Here you can upload the the delivery note for this order" }), jsx(Divider, {}), jsx(UploadBase64MediaForm, { reference: "api::e-commerce.opo", refID: opo.id, field: "delivery_note", multiple: false, accept: "text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document", path: "api/ipos", componentName: "delivery_note", componentReference: "common.base64-encoded-media", revalidateCallback: revalidateCallback })] })) }) })] }) }), opo?.notes?.length > 0 && (jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h5", children: "Notes" }), jsx(NotesDisplay, { notes: opo.notes }), jsx(Divider, {})] }) })), jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 1, children: [jsx(Typography, { variant: "h5", children: "Items" }), jsxs(Stack, { direction: "row", alignItems: "center", justifyContent: "flex-end", spacing: 2, component: Paper, p: 1, children: [jsx(Typography, { variant: "body1", children: "Show:" }), options.map((option) => (jsx(FormControlLabel, { control: jsx(Checkbox, { checked: showing.includes(option), onChange: (e) => {
|
|
175
175
|
if (e.target.checked) {
|
|
176
176
|
setShowing([...showing, option]);
|
|
177
177
|
}
|
|
@@ -23,23 +23,23 @@ function TextualOpoItemUpdater({ item, index, handleAddReport, handleUpdateQuant
|
|
|
23
23
|
const { line_item_number, product, ordered_quantity, picked_quantity, packed_quantity, shipped_quantity, reports, } = item;
|
|
24
24
|
const [open, setOpen] = useState(false);
|
|
25
25
|
// these values where wrapped with useMemo before but that did not work well while updating values
|
|
26
|
-
reports
|
|
27
|
-
? reports
|
|
26
|
+
reports !== undefined && reports.length > 0
|
|
27
|
+
? reports
|
|
28
28
|
.filter((report) => report.type === "picked")
|
|
29
29
|
.reduce((a, b) => a + b.quantity, 0)
|
|
30
30
|
: 0;
|
|
31
|
-
const packed_reports_quantity = reports
|
|
32
|
-
? reports
|
|
31
|
+
const packed_reports_quantity = reports !== undefined && reports.length > 0
|
|
32
|
+
? reports
|
|
33
33
|
.filter((report) => report.type === "packed")
|
|
34
34
|
.reduce((a, b) => a + b.quantity, 0)
|
|
35
35
|
: 0;
|
|
36
|
-
reports
|
|
37
|
-
? reports
|
|
36
|
+
reports !== undefined && reports.length > 0
|
|
37
|
+
? reports
|
|
38
38
|
.filter((report) => report.type === "shipped")
|
|
39
39
|
.reduce((a, b) => a + b.quantity, 0)
|
|
40
40
|
: 0;
|
|
41
|
-
const dbReports = item.reports?.
|
|
42
|
-
const preReports = item.reports?.
|
|
41
|
+
const dbReports = item.reports?.filter((report) => "id" in report) || [];
|
|
42
|
+
const preReports = item.reports?.filter((report) => Boolean("id" in report) === false) ||
|
|
43
43
|
[];
|
|
44
44
|
return (jsx(Stack, { spacing: 1, children: item && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsxs(Typography, { variant: "body1", children: ["Line Item Number: ", line_item_number] }), jsxs(Typography, { variant: "body1", children: ["Part Number: ", product?.product_number] }), image && (jsx(Fragment, { children: jsx(ImagePreviewTooltip, { image: image, label: product?.title }) }))] }), jsx(Divider, { sx: { mb: 1 } }), showing && showing.includes("picked") && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsx(Typography, { variant: "body2", children: "Picked" }), jsx(TextualAmountUpdater, { label: "Picked", currentValue: picked_quantity, totalValue: ordered_quantity, minNewValue: 0 + packed_quantity, maxNewValue: ordered_quantity, color: "info", handleChange: (newValue) => {
|
|
45
45
|
handleUpdateQuantity(newValue, item.id, "picked_quantity");
|
|
@@ -19,13 +19,13 @@ import ReportsDisplay from '../report/ReportsDisplay.js';
|
|
|
19
19
|
|
|
20
20
|
function ItemUpdater({ item, index, handleUpdateQuantity, image, revalidateCallback, }) {
|
|
21
21
|
const { line_item_number, product, received_quantity, registered_quantity, released_quantity, ordered_quantity, reports, } = item;
|
|
22
|
-
const received_bad_quantity = reports
|
|
23
|
-
? reports
|
|
22
|
+
const received_bad_quantity = reports !== undefined && reports.length > 0
|
|
23
|
+
? reports
|
|
24
24
|
.filter((report) => report.type === "received")
|
|
25
25
|
.reduce((a, b) => a + b.quantity, 0)
|
|
26
26
|
: 0;
|
|
27
|
-
const registered_bad_quantity = reports
|
|
28
|
-
? reports
|
|
27
|
+
const registered_bad_quantity = reports !== undefined && reports.length > 0
|
|
28
|
+
? reports
|
|
29
29
|
.filter((report) => report.type === "registered")
|
|
30
30
|
.reduce((a, b) => a + b.quantity, 0)
|
|
31
31
|
: 0;
|
|
@@ -34,7 +34,7 @@ function ItemUpdater({ item, index, handleUpdateQuantity, image, revalidateCallb
|
|
|
34
34
|
handleUpdateQuantity(newValue, item.id, "received_quantity");
|
|
35
35
|
} }), jsx(Typography, { variant: "body2", children: "Registered" }), jsx(AmountUpdater, { currentValue: registered_quantity, totalValue: ordered_quantity + received_bad_quantity, minNewValue: 0 + released_quantity, maxNewValue: received_quantity + registered_bad_quantity, color: "info", handleChange: (newValue) => {
|
|
36
36
|
handleUpdateQuantity(newValue, item.id, "registered_quantity");
|
|
37
|
-
}, offsetEnd: registered_bad_quantity }), jsx(Divider, { sx: { p: 0 }, children: jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(Typography, { variant: "body2", children: "Irregularities / Corrections" }), jsx(IconButton, { onClick: () => setOpen(!open), children: jsx(ArrowButtonDownIcon, {}) })] }) }), jsx(Collapse, { in: open, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "body2", children: "Here you can report and correct for damages wrong items etc. Do not forget to click the button!" }), jsx(ReportsDisplay, { reports: reports
|
|
37
|
+
}, offsetEnd: registered_bad_quantity }), jsx(Divider, { sx: { p: 0 }, children: jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(Typography, { variant: "body2", children: "Irregularities / Corrections" }), jsx(IconButton, { onClick: () => setOpen(!open), children: jsx(ArrowButtonDownIcon, {}) })] }) }), jsx(Collapse, { in: open, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "body2", children: "Here you can report and correct for damages wrong items etc. Do not forget to click the button!" }), jsx(ReportsDisplay, { reports: reports }), jsx(ReportMakingComponent, { content: "content", quantity: 0, type: "registered", minValue: -(received_quantity + registered_bad_quantity), maxValue: received_quantity, related: [{ id: item.id, __type: "api::logistics.ipo-item" }], revalidateCallback: revalidateCallback })] }) }), jsx(Typography, { variant: "body2", children: "Released" }), jsx(AmountUpdater, { currentValue: released_quantity || 0, totalValue: ordered_quantity + received_bad_quantity + registered_bad_quantity, minNewValue: 0, maxNewValue: registered_quantity, color: "info", handleChange: (newValue) => {
|
|
38
38
|
handleUpdateQuantity(newValue, item.id, "released_quantity");
|
|
39
39
|
} })] })) }, index));
|
|
40
40
|
}
|
|
@@ -47,7 +47,7 @@ function ConfirmFormDialog({ open, handleClose, orderID, currentStatus, revalida
|
|
|
47
47
|
function ManageIPOForm({ data, sx, revalidateCallback, handleClose, role, }) {
|
|
48
48
|
const [formState, formAction] = useFormState((prevState, formData) => updateIpoAction(data.id, prevState, formData), INITIAL_STATE);
|
|
49
49
|
const { handleAddMessage } = useSnackbar();
|
|
50
|
-
const [items, setItems] = useState(data.items
|
|
50
|
+
const [items, setItems] = useState(data.items ? data.items : []);
|
|
51
51
|
const [confirmDialogOpen, setConfirmDialogOpen] = useState(false);
|
|
52
52
|
useEffect(() => {
|
|
53
53
|
if (formState?.message) {
|
|
@@ -87,12 +87,12 @@ function ManageIPOForm({ data, sx, revalidateCallback, handleClose, role, }) {
|
|
|
87
87
|
};
|
|
88
88
|
return (jsx(Box, { sx: [...(Array.isArray(sx) ? sx : [sx])], children: jsxs(Grid, { container: true, spacing: 2, children: [jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsxs(Stack, { direction: "row", spacing: 2, justifyContent: "space-between", children: [jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h3", component: "h1", children: "Manage Inbound Purchase Order" }), jsx(Typography, { variant: "body1", children: "Update the incoming purchase order details" })] }), jsx(NoteTakingComponent, { content: "", related: [{ id: data.id, __type: "api::logistics.ipo" }], revalidateCallback: revalidateCallback })] }), jsx(Divider, {})] }) }), jsx(Grid, { item: true, xs: 6, children: jsxs(Stack, { spacing: 1, children: [jsx(Typography, { variant: "h5", children: "Details" }), jsxs(Stack, { direction: "row", spacing: 2, children: [jsx(Typography, { variant: "body1", width: "250px", children: "Purchase Order Number" }), jsx(Typography, { variant: "body2", children: data.ipo_number })] }), jsxs(Stack, { direction: "row", spacing: 2, children: [jsx(Typography, { variant: "body1", width: "250px", children: "Custom reference" }), jsx(Typography, { variant: "body2", children: data.customer_reference })] }), jsxs(Stack, { direction: "row", spacing: 2, children: [jsx(Typography, { variant: "body1", width: "250px", children: "Order Date" }), jsx(Typography, { variant: "body2", children: data.order_date })] }), jsxs(Stack, { direction: "row", spacing: 2, children: [jsx(Typography, { variant: "body1", width: "250px", children: "Supplier" }), jsx(Typography, { variant: "body2", children: data.vendor_profile?.business_credentials?.company_name })] }), jsxs(Stack, { direction: "row", spacing: 2, children: [jsx(Typography, { variant: "body1", width: "250px", children: "Order Status" }), jsx(Typography, { variant: "body2", width: "250px", children: data.internal_status })] }), (data.internal_status === "placed" ||
|
|
89
89
|
data.internal_status === "released_on_stock") &&
|
|
90
|
-
role === "enduser" && (jsxs(Fragment, { children: [jsx(Button, { variant: "contained", color: "primary", onClick: () => setConfirmDialogOpen(true), children: "Confirm order" }), jsx(Alert, { severity: "warning", children: "Please confirm the order as soon as possible. Only upon confirmation will this order be available to the dispatcher." }), jsx(ConfirmFormDialog, { open: confirmDialogOpen, handleClose: () => setConfirmDialogOpen(false), orderID: data.
|
|
90
|
+
role === "enduser" && (jsxs(Fragment, { children: [jsx(Button, { variant: "contained", color: "primary", onClick: () => setConfirmDialogOpen(true), children: "Confirm order" }), jsx(Alert, { severity: "warning", children: "Please confirm the order as soon as possible. Only upon confirmation will this order be available to the dispatcher." }), jsx(ConfirmFormDialog, { open: confirmDialogOpen, handleClose: () => setConfirmDialogOpen(false), orderID: data.documentId, currentStatus: data.internal_status, revalidateCallback: revalidateCallback })] }))] }) }), jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h5", children: "Documents" }), jsx(Paper, { sx: { p: 2 }, children: jsxs(Stack, { spacing: 1, children: [role === "enduser" && (jsx(Fragment, { children: data.order_confirmation ? (jsxs(Stack, { spacing: 1, children: [jsx(Typography, { variant: "h6", children: "Order Confirmation" }), jsx(Typography, { children: data.order_confirmation?.name }), jsx(Button, { variant: "contained", onClick: () => {
|
|
91
91
|
downloadBase64File(`api/ipos/${data.id}`, "order_confirmation");
|
|
92
92
|
}, children: "Download" })] })) : (jsxs(Stack, { spacing: 1, children: [jsx(Typography, { variant: "h6", children: "Order Confirmation" }), jsx(Typography, { variant: "body1", children: "Upload the order confirmation for this order" }), jsx(UploadBase64MediaForm, { reference: "api::logistics.ipo", refID: data.id, field: "order_confirmation", multiple: false, accept: "text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document", path: "api/ipos", componentName: "order_confirmation", componentReference: "common.base64-encoded-media", revalidateCallback: revalidateCallback })] })) })), data.delivery_note ? (jsxs(Stack, { spacing: 1, children: [jsx(Typography, { variant: "h6", children: "Delivery Note" }), jsx(Typography, { children: data.delivery_note?.name }), jsx(Button, { variant: "contained", onClick: () => {
|
|
93
93
|
downloadBase64File(`api/ipos/${data.id}`, "delivery_note");
|
|
94
|
-
}, children: "Download" })] })) : (jsxs(Stack, { spacing: 1, children: [jsx(Typography, { variant: "h6", children: "Delivery Note" }), jsx(Typography, { variant: "body1", children: "Upload the delivery note for this order" }), jsx(UploadBase64MediaForm, { reference: "api::logistics.ipo", refID: data.id, field: "delivery_note", multiple: false, accept: "text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document", path: "api/ipos", componentName: "delivery_note", componentReference: "common.base64-encoded-media", revalidateCallback: revalidateCallback })] }))] }) })] }) }), data?.notes?.
|
|
95
|
-
data.items.
|
|
94
|
+
}, children: "Download" })] })) : (jsxs(Stack, { spacing: 1, children: [jsx(Typography, { variant: "h6", children: "Delivery Note" }), jsx(Typography, { variant: "body1", children: "Upload the delivery note for this order" }), jsx(UploadBase64MediaForm, { reference: "api::logistics.ipo", refID: data.id, field: "delivery_note", multiple: false, accept: "text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document", path: "api/ipos", componentName: "delivery_note", componentReference: "common.base64-encoded-media", revalidateCallback: revalidateCallback })] }))] }) })] }) }), data?.notes?.length > 0 && (jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h5", children: "Notes" }), jsx(NotesDisplay, { notes: data.notes }), jsx(Divider, {})] }) })), jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h5", children: "Items" }), data.internal_status === "placed" && (jsx(Alert, { severity: "warning", children: "Items cannot be updated before order confirmation" })), jsxs("form", { action: formAction, children: [jsx("input", { name: "id", type: "hidden", value: data.id }), jsx("input", { type: "hidden", name: "items", value: JSON.stringify(parseItems(items)) }), jsxs(Stack, { spacing: 2, children: [data?.items &&
|
|
95
|
+
data.items.map((item, index) => (jsx(Paper, { sx: { p: 2 }, children: data.internal_status === "placed" ? (jsx(ItemDisplay, { item: item, index: index, image: item?.product?.image })) : (jsx(ItemUpdater, { item: item, index: index, handleUpdateQuantity: handleUpdateQuantity, image: item?.product?.image,
|
|
96
96
|
// handleRemoveReportAtIndex={handleRemoveReportAtIndex}
|
|
97
97
|
revalidateCallback: revalidateCallback })) }, index))), data.internal_status !== "placed" && (jsx(Paper, { sx: { p: 2 }, children: jsxs(Stack, { direction: "row", justifyContent: "flex-end", spacing: 2, children: [handleClose && (jsx(Button, { onClick: handleClose, variant: "outlined", children: "Cancel" })), jsx(SubmitButton, { text: "Update Items", loadingText: "Updating...", variant: "contained" })] }) }))] })] })] }) })] }) }));
|
|
98
98
|
}
|