@argusoft/medplat-product-management 1.0.0
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/BrandsPage-DCMCVvDY.js +334 -0
- package/dist/BrandsPage-DCMCVvDY.js.map +1 -0
- package/dist/CategoriesPage-BpRhwfrc.js +284 -0
- package/dist/CategoriesPage-BpRhwfrc.js.map +1 -0
- package/dist/DashboardPage-BNKUQj46.js +436 -0
- package/dist/DashboardPage-BNKUQj46.js.map +1 -0
- package/dist/FacilityPicker-Coi8I3yE.js +79 -0
- package/dist/FacilityPicker-Coi8I3yE.js.map +1 -0
- package/dist/InventoryPage-BR6jOzg2.js +517 -0
- package/dist/InventoryPage-BR6jOzg2.js.map +1 -0
- package/dist/MemberProfileCard-DbHZCS5n.js +272 -0
- package/dist/MemberProfileCard-DbHZCS5n.js.map +1 -0
- package/dist/PaymentCreatePage-Ci3ERnby.js +487 -0
- package/dist/PaymentCreatePage-Ci3ERnby.js.map +1 -0
- package/dist/PaymentsPage-sdg902zX.js +157 -0
- package/dist/PaymentsPage-sdg902zX.js.map +1 -0
- package/dist/PickupCreatePage-CieMsgWV.js +310 -0
- package/dist/PickupCreatePage-CieMsgWV.js.map +1 -0
- package/dist/PickupsPage-Ci2Ll0Kn.js +566 -0
- package/dist/PickupsPage-Ci2Ll0Kn.js.map +1 -0
- package/dist/PmGuard-CjJBisaN.js +1195 -0
- package/dist/PmGuard-CjJBisaN.js.map +1 -0
- package/dist/PmTable-BuXZQZCU.js +302 -0
- package/dist/PmTable-BuXZQZCU.js.map +1 -0
- package/dist/ProductEditPage-DL8gy85Y.js +666 -0
- package/dist/ProductEditPage-DL8gy85Y.js.map +1 -0
- package/dist/ProductsPage-BANTKxLb.js +221 -0
- package/dist/ProductsPage-BANTKxLb.js.map +1 -0
- package/dist/PurchaseCreatePage-C3KMfBxJ.js +626 -0
- package/dist/PurchaseCreatePage-C3KMfBxJ.js.map +1 -0
- package/dist/PurchaseRequestDetailPage-C0GYFJDl.js +586 -0
- package/dist/PurchaseRequestDetailPage-C0GYFJDl.js.map +1 -0
- package/dist/PurchaseRequestsPage-DvFH_tWe.js +265 -0
- package/dist/PurchaseRequestsPage-DvFH_tWe.js.map +1 -0
- package/dist/PurchasesPage-BCvLvSp4.js +295 -0
- package/dist/PurchasesPage-BCvLvSp4.js.map +1 -0
- package/dist/SaleCreatePage-DpkQMoTq.js +548 -0
- package/dist/SaleCreatePage-DpkQMoTq.js.map +1 -0
- package/dist/SalesPage-DUwgkEO-.js +315 -0
- package/dist/SalesPage-DUwgkEO-.js.map +1 -0
- package/dist/SettingsPage-CusC0jqJ.js +710 -0
- package/dist/SettingsPage-CusC0jqJ.js.map +1 -0
- package/dist/StorageUnitsPage-BlC2AgrJ.js +469 -0
- package/dist/StorageUnitsPage-BlC2AgrJ.js.map +1 -0
- package/dist/TransactionsPage-DDaK4VyY.js +714 -0
- package/dist/TransactionsPage-DDaK4VyY.js.map +1 -0
- package/dist/TransferCreatePage-BxudLfhS.js +363 -0
- package/dist/TransferCreatePage-BxudLfhS.js.map +1 -0
- package/dist/TransfersPage-zgmt7teZ.js +480 -0
- package/dist/TransfersPage-zgmt7teZ.js.map +1 -0
- package/dist/VialsPage-CjqPfgpV.js +855 -0
- package/dist/VialsPage-CjqPfgpV.js.map +1 -0
- package/dist/constants-BrA_hfAI.js +254 -0
- package/dist/constants-BrA_hfAI.js.map +1 -0
- package/dist/currency-BDDCDgeE.js +169 -0
- package/dist/currency-BDDCDgeE.js.map +1 -0
- package/dist/format-UOyOu75i.js +52 -0
- package/dist/format-UOyOu75i.js.map +1 -0
- package/dist/index.js +45 -0
- package/dist/index.js.map +1 -0
- package/dist/useFieldErrors-hDG8ox_x.js +29 -0
- package/dist/useFieldErrors-hDG8ox_x.js.map +1 -0
- package/dist/validation-Ba7puFIO.js +109 -0
- package/dist/validation-Ba7puFIO.js.map +1 -0
- package/package.json +36 -0
|
@@ -0,0 +1,626 @@
|
|
|
1
|
+
import { A as e, N as t, P as n, a as r, c as i, n as a, r as ee, rt as te, t as ne, v as re } from "./PmGuard-CjJBisaN.js";
|
|
2
|
+
import { n as o } from "./PmTable-BuXZQZCU.js";
|
|
3
|
+
import { a as ie, d as s, f as ae, l as oe, m as c, t as l } from "./validation-Ba7puFIO.js";
|
|
4
|
+
import { t as se } from "./useFieldErrors-hDG8ox_x.js";
|
|
5
|
+
import { a as ce, r as le, t as ue } from "./format-UOyOu75i.js";
|
|
6
|
+
import { n as de, p as fe, t as pe } from "./constants-BrA_hfAI.js";
|
|
7
|
+
import { t as me } from "./FacilityPicker-Coi8I3yE.js";
|
|
8
|
+
import { useEffect as he, useMemo as u, useState as d } from "react";
|
|
9
|
+
import { Fragment as ge, jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
10
|
+
import { v4 as m } from "uuid";
|
|
11
|
+
import { Alert as _e, Box as ve, Button as h, Card as g, CardContent as _, Chip as ye, Divider as v, FormControl as y, FormHelperText as b, Grid as x, IconButton as be, InputLabel as S, MenuItem as C, Select as w, Stack as T, Table as xe, TableBody as Se, TableCell as E, TableHead as Ce, TableRow as D, TextField as O, Typography as k } from "@mui/material";
|
|
12
|
+
import A from "@mui/icons-material/AddRounded";
|
|
13
|
+
import { showToast as j } from "@/common/toaster/toaster";
|
|
14
|
+
import { useNavigate as we } from "react-router-dom";
|
|
15
|
+
import Te from "@mui/icons-material/Inventory2Rounded";
|
|
16
|
+
import Ee from "@mui/icons-material/SaveRounded";
|
|
17
|
+
import De from "@mui/icons-material/DeleteOutlineRounded";
|
|
18
|
+
//#region src/views/PurchaseCreatePage.jsx
|
|
19
|
+
var M = [{
|
|
20
|
+
value: "USER",
|
|
21
|
+
label: "Personal Use"
|
|
22
|
+
}, {
|
|
23
|
+
value: "FACILITY",
|
|
24
|
+
label: "Facility Use"
|
|
25
|
+
}];
|
|
26
|
+
function N() {
|
|
27
|
+
return {
|
|
28
|
+
key: m(),
|
|
29
|
+
batchId: m(),
|
|
30
|
+
productId: "",
|
|
31
|
+
quantity: 1,
|
|
32
|
+
buyPrice: "",
|
|
33
|
+
expiryDate: "",
|
|
34
|
+
lotNumber: "",
|
|
35
|
+
manufactureDate: "",
|
|
36
|
+
storageUnitId: ""
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function P() {
|
|
40
|
+
let P = we(), F = i(), I = F?.managePurchaseAmounts !== !1, L = F?.allowPersonalPurchase !== !1, R = F?.requirePurchaseConfirmation === !0, Oe = u(() => L ? M : M.filter((e) => e.value !== "USER"), [L]), [z, ke] = d([]), [B, Ae] = d([]), [V, je] = d([]), [H, U] = d(""), W = se(), G = (/* @__PURE__ */ new Date()).toISOString().substring(0, 10), [K, q] = d({
|
|
41
|
+
id: m(),
|
|
42
|
+
ownerType: L ? "USER" : "FACILITY",
|
|
43
|
+
ownerId: "",
|
|
44
|
+
purchaseDate: G,
|
|
45
|
+
paymentMode: "CASH",
|
|
46
|
+
notes: "",
|
|
47
|
+
items: [N()]
|
|
48
|
+
});
|
|
49
|
+
he(() => {
|
|
50
|
+
!L && K.ownerType === "USER" && q((e) => ({
|
|
51
|
+
...e,
|
|
52
|
+
ownerType: "FACILITY",
|
|
53
|
+
ownerId: ""
|
|
54
|
+
}));
|
|
55
|
+
}, [L, K.ownerType]), ee("update.manage.productManagement.purchase", () => {
|
|
56
|
+
async function r() {
|
|
57
|
+
try {
|
|
58
|
+
let [r, i, a] = await Promise.all([
|
|
59
|
+
e(),
|
|
60
|
+
t({ activeOnly: !0 }),
|
|
61
|
+
n().catch(() => [])
|
|
62
|
+
]);
|
|
63
|
+
ke(r), Ae(i), je(a);
|
|
64
|
+
} catch (e) {
|
|
65
|
+
U(e?.response?.data?.message ?? e?.message ?? "Failed to load reference data");
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
r();
|
|
69
|
+
}, []);
|
|
70
|
+
let J = u(() => K.ownerType === "USER" ? V.filter((e) => e.ownerType === "USER" && Number(e.qtyRemaining ?? 0) > 0 && e.status !== "EXPIRED" && e.status !== "EXHAUSTED") : K.ownerType === "FACILITY" && K.ownerId ? V.filter((e) => e.ownerType === "FACILITY" && e.ownerId === K.ownerId && Number(e.qtyRemaining ?? 0) > 0 && e.status !== "EXPIRED" && e.status !== "EXHAUSTED") : [], [
|
|
71
|
+
V,
|
|
72
|
+
K.ownerType,
|
|
73
|
+
K.ownerId
|
|
74
|
+
]), Me = u(() => K.ownerType !== "FACILITY" || !K.ownerId ? [] : B.filter((e) => e.ownerId === K.ownerId), [
|
|
75
|
+
B,
|
|
76
|
+
K.ownerType,
|
|
77
|
+
K.ownerId
|
|
78
|
+
]);
|
|
79
|
+
function Y(e, t, n) {
|
|
80
|
+
q((r) => {
|
|
81
|
+
let i = r.items.slice();
|
|
82
|
+
return i[e] = {
|
|
83
|
+
...i[e],
|
|
84
|
+
[t]: n
|
|
85
|
+
}, {
|
|
86
|
+
...r,
|
|
87
|
+
items: i
|
|
88
|
+
};
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function Ne(e) {
|
|
92
|
+
q((t) => ({
|
|
93
|
+
...t,
|
|
94
|
+
items: t.items.filter((t, n) => n !== e)
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
function Pe() {
|
|
98
|
+
q((e) => ({
|
|
99
|
+
...e,
|
|
100
|
+
items: [...e.items, N()]
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
let X = u(() => {
|
|
104
|
+
let e = !1;
|
|
105
|
+
return {
|
|
106
|
+
sum: K.items.reduce((t, n) => {
|
|
107
|
+
if (n.buyPrice === "" || n.quantity === "" || n.quantity == null) return t;
|
|
108
|
+
let r = Number(n.quantity), i = Number(n.buyPrice);
|
|
109
|
+
return Number.isNaN(r) || Number.isNaN(i) ? t : (e = !0, t + r * i);
|
|
110
|
+
}, 0),
|
|
111
|
+
priced: e
|
|
112
|
+
};
|
|
113
|
+
}, [K.items]), Z = {
|
|
114
|
+
ownerType: c(K.ownerType, "Purchase type"),
|
|
115
|
+
ownerId: K.ownerType === "FACILITY" ? c(K.ownerId, "Facility") : "",
|
|
116
|
+
purchaseDate: c(K.purchaseDate, "Purchase date")
|
|
117
|
+
}, Q = K.items.map((e) => {
|
|
118
|
+
let t = z.find((t) => t.id === e.productId), n = t?.hasExpiry === !0, r = t?.needsStorageUnit === !0 && K.ownerType === "FACILITY" ? c(e.storageUnitId, "Storage unit") : "";
|
|
119
|
+
if (!r && e.storageUnitId && t?.vaccineConfig) {
|
|
120
|
+
let n = t.vaccineConfig, i = B.find((t) => t.id === e.storageUnitId);
|
|
121
|
+
if (n.storageTempMinCelsius != null && n.storageTempMaxCelsius != null && i) {
|
|
122
|
+
let e = i.operatingTempMinCelsius, t = i.operatingTempMaxCelsius;
|
|
123
|
+
(e == null || t == null || Number(e) > Number(n.storageTempMinCelsius) || Number(t) < Number(n.storageTempMaxCelsius)) && (r = `Unit operates ${e ?? "?"}°C → ${t ?? "?"}°C, which cannot cover this product's required ${n.storageTempMinCelsius}°C → ${n.storageTempMaxCelsius}°C.`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
productId: c(e.productId, "Product"),
|
|
128
|
+
quantity: ae(e.quantity),
|
|
129
|
+
buyPrice: s(e.buyPrice),
|
|
130
|
+
expiryDate: R ? "" : n && c(e.expiryDate, "Expiry date") || ie(e.expiryDate, { label: "Expiry" }),
|
|
131
|
+
manufactureDate: oe(e.manufactureDate, { label: "Manufacture date" }),
|
|
132
|
+
storageUnitId: r
|
|
133
|
+
};
|
|
134
|
+
}), $ = l(Z) && Q.every(l) && K.items.length > 0;
|
|
135
|
+
async function Fe() {
|
|
136
|
+
if (!$) {
|
|
137
|
+
W.markAllTouched(), U("Please fix the highlighted fields and try again.");
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
let e = {
|
|
141
|
+
id: K.id,
|
|
142
|
+
ownerType: K.ownerType,
|
|
143
|
+
ownerId: K.ownerType === "FACILITY" ? K.ownerId : null,
|
|
144
|
+
purchaseDate: K.purchaseDate,
|
|
145
|
+
paymentMode: I && K.paymentMode || null,
|
|
146
|
+
totalAmount: I && X.priced ? Number(X.sum.toFixed(2)) : null,
|
|
147
|
+
notes: K.notes || null,
|
|
148
|
+
items: K.items.map((e) => ({
|
|
149
|
+
batchId: e.batchId,
|
|
150
|
+
productId: e.productId,
|
|
151
|
+
quantity: Number(e.quantity),
|
|
152
|
+
buyPrice: I && e.buyPrice !== "" ? Number(e.buyPrice) : null,
|
|
153
|
+
expiryDate: e.expiryDate || null,
|
|
154
|
+
lotNumber: e.lotNumber || null,
|
|
155
|
+
manufactureDate: e.manufactureDate || null,
|
|
156
|
+
storageUnitId: e.storageUnitId || null
|
|
157
|
+
}))
|
|
158
|
+
};
|
|
159
|
+
try {
|
|
160
|
+
if (R) {
|
|
161
|
+
let t = await te(e);
|
|
162
|
+
j({
|
|
163
|
+
message: "Purchase request submitted for approval.",
|
|
164
|
+
type: "success"
|
|
165
|
+
}), P(`/ui/medplat/manage/pm/purchase-requests/${t?.id ?? K.id}`);
|
|
166
|
+
} else await re(e), j({
|
|
167
|
+
message: "Purchase recorded.",
|
|
168
|
+
type: "success"
|
|
169
|
+
}), P("/ui/medplat/manage/pm/purchases");
|
|
170
|
+
} catch (e) {
|
|
171
|
+
U(e?.response?.data?.message ?? e?.message ?? (R ? "Failed to submit purchase request" : "Failed to record purchase"));
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return /* @__PURE__ */ p(ve, { children: [/* @__PURE__ */ f(a, {}), /* @__PURE__ */ f(ne, {
|
|
175
|
+
perm: "update.manage.productManagement.purchase",
|
|
176
|
+
title: R ? "You don’t have permission to submit purchase requests" : "You don’t have permission to record purchases",
|
|
177
|
+
children: /* @__PURE__ */ p(r, {
|
|
178
|
+
title: R ? "Submit Purchase Request" : "Record Purchase",
|
|
179
|
+
subtitle: R ? "Purchases need approval before stock is added. Submit the request and wait for a manager to confirm." : "Each item creates a batch that you can track and a record in your ledger.",
|
|
180
|
+
actions: /* @__PURE__ */ p(T, {
|
|
181
|
+
direction: "row",
|
|
182
|
+
spacing: 1,
|
|
183
|
+
children: [/* @__PURE__ */ f(h, {
|
|
184
|
+
variant: "outlined",
|
|
185
|
+
onClick: () => P(R ? "/ui/medplat/manage/pm/purchase-requests" : "/ui/medplat/manage/pm/purchases"),
|
|
186
|
+
children: "Cancel"
|
|
187
|
+
}), /* @__PURE__ */ f(h, {
|
|
188
|
+
variant: "contained",
|
|
189
|
+
startIcon: /* @__PURE__ */ f(Ee, {}),
|
|
190
|
+
disabled: !$,
|
|
191
|
+
onClick: () => void Fe(),
|
|
192
|
+
children: R ? "Submit Request" : "Save"
|
|
193
|
+
})]
|
|
194
|
+
}),
|
|
195
|
+
children: [
|
|
196
|
+
H ? /* @__PURE__ */ f(_e, {
|
|
197
|
+
severity: "error",
|
|
198
|
+
sx: { mb: 2 },
|
|
199
|
+
children: H
|
|
200
|
+
}) : null,
|
|
201
|
+
/* @__PURE__ */ f(g, {
|
|
202
|
+
sx: {
|
|
203
|
+
borderRadius: 4,
|
|
204
|
+
mb: 2,
|
|
205
|
+
border: "1px solid",
|
|
206
|
+
borderColor: "divider",
|
|
207
|
+
boxShadow: "0 12px 32px rgba(15, 23, 42, 0.045)"
|
|
208
|
+
},
|
|
209
|
+
children: /* @__PURE__ */ p(_, {
|
|
210
|
+
sx: { p: 2.5 },
|
|
211
|
+
children: [/* @__PURE__ */ f(o, {
|
|
212
|
+
eyebrow: "Step 1",
|
|
213
|
+
title: "Purchase for",
|
|
214
|
+
hint: "Choose who will own this stock: yourself or a facility.",
|
|
215
|
+
sx: { mb: 2 }
|
|
216
|
+
}), /* @__PURE__ */ p(x, {
|
|
217
|
+
container: !0,
|
|
218
|
+
spacing: 2,
|
|
219
|
+
children: [/* @__PURE__ */ f(x, {
|
|
220
|
+
item: !0,
|
|
221
|
+
xs: 12,
|
|
222
|
+
md: 4,
|
|
223
|
+
children: /* @__PURE__ */ p(y, {
|
|
224
|
+
required: !0,
|
|
225
|
+
fullWidth: !0,
|
|
226
|
+
size: "small",
|
|
227
|
+
error: W.show("ownerType") && !!Z.ownerType,
|
|
228
|
+
children: [
|
|
229
|
+
/* @__PURE__ */ f(S, { children: "Purchase Type" }),
|
|
230
|
+
/* @__PURE__ */ f(w, {
|
|
231
|
+
label: "Purchase Type",
|
|
232
|
+
value: K.ownerType,
|
|
233
|
+
onChange: (e) => q({
|
|
234
|
+
...K,
|
|
235
|
+
ownerType: e.target.value,
|
|
236
|
+
ownerId: ""
|
|
237
|
+
}),
|
|
238
|
+
onBlur: W.onBlur("ownerType"),
|
|
239
|
+
children: Oe.map((e) => /* @__PURE__ */ f(C, {
|
|
240
|
+
value: e.value,
|
|
241
|
+
children: e.label
|
|
242
|
+
}, e.value))
|
|
243
|
+
}),
|
|
244
|
+
/* @__PURE__ */ f(b, { children: W.show("ownerType") && Z.ownerType ? Z.ownerType : "Personal stock vs. facility stock" })
|
|
245
|
+
]
|
|
246
|
+
})
|
|
247
|
+
}), K.ownerType === "FACILITY" ? /* @__PURE__ */ f(x, {
|
|
248
|
+
item: !0,
|
|
249
|
+
xs: 12,
|
|
250
|
+
md: 4,
|
|
251
|
+
children: /* @__PURE__ */ f(me, {
|
|
252
|
+
required: !0,
|
|
253
|
+
value: K.ownerId,
|
|
254
|
+
onChange: (e) => q({
|
|
255
|
+
...K,
|
|
256
|
+
ownerId: e
|
|
257
|
+
}),
|
|
258
|
+
onBlur: W.onBlur("ownerId"),
|
|
259
|
+
error: W.show("ownerId") && !!Z.ownerId,
|
|
260
|
+
helperText: W.show("ownerId") && Z.ownerId ? Z.ownerId : "Search for the facility."
|
|
261
|
+
})
|
|
262
|
+
}) : null]
|
|
263
|
+
})]
|
|
264
|
+
})
|
|
265
|
+
}),
|
|
266
|
+
K.ownerType === "USER" || K.ownerType === "FACILITY" && K.ownerId ? /* @__PURE__ */ f(g, {
|
|
267
|
+
sx: {
|
|
268
|
+
borderRadius: 4,
|
|
269
|
+
mb: 2,
|
|
270
|
+
border: "1px solid",
|
|
271
|
+
borderColor: "divider",
|
|
272
|
+
boxShadow: "0 12px 32px rgba(15, 23, 42, 0.045)"
|
|
273
|
+
},
|
|
274
|
+
children: /* @__PURE__ */ p(_, {
|
|
275
|
+
sx: { p: 2.5 },
|
|
276
|
+
children: [/* @__PURE__ */ f(o, {
|
|
277
|
+
eyebrow: "Context",
|
|
278
|
+
title: "Existing inventory",
|
|
279
|
+
hint: K.ownerType === "USER" ? "Your current stock." : "What this facility already has, including where it is stored.",
|
|
280
|
+
sx: { mb: 1.5 }
|
|
281
|
+
}), J.length === 0 ? /* @__PURE__ */ p(T, {
|
|
282
|
+
direction: "row",
|
|
283
|
+
spacing: 1.25,
|
|
284
|
+
alignItems: "center",
|
|
285
|
+
sx: {
|
|
286
|
+
py: 1.5,
|
|
287
|
+
color: "text.secondary"
|
|
288
|
+
},
|
|
289
|
+
children: [/* @__PURE__ */ f(Te, { fontSize: "small" }), /* @__PURE__ */ f(k, {
|
|
290
|
+
variant: "body2",
|
|
291
|
+
children: "No active stock yet for this owner."
|
|
292
|
+
})]
|
|
293
|
+
}) : /* @__PURE__ */ p(xe, {
|
|
294
|
+
size: "small",
|
|
295
|
+
children: [/* @__PURE__ */ f(Ce, { children: /* @__PURE__ */ p(D, { children: [
|
|
296
|
+
/* @__PURE__ */ f(E, { children: "Product" }),
|
|
297
|
+
/* @__PURE__ */ f(E, { children: "Lot" }),
|
|
298
|
+
/* @__PURE__ */ f(E, {
|
|
299
|
+
align: "right",
|
|
300
|
+
children: "Remaining"
|
|
301
|
+
}),
|
|
302
|
+
/* @__PURE__ */ f(E, { children: "Expiry" }),
|
|
303
|
+
K.ownerType === "FACILITY" ? /* @__PURE__ */ f(E, { children: "Storage" }) : null,
|
|
304
|
+
/* @__PURE__ */ f(E, { children: "Status" })
|
|
305
|
+
] }) }), /* @__PURE__ */ f(Se, { children: J.map((e) => /* @__PURE__ */ p(D, { children: [
|
|
306
|
+
/* @__PURE__ */ f(E, {
|
|
307
|
+
sx: { fontWeight: 700 },
|
|
308
|
+
children: e.productName
|
|
309
|
+
}),
|
|
310
|
+
/* @__PURE__ */ f(E, {
|
|
311
|
+
sx: {
|
|
312
|
+
fontFamily: "monospace",
|
|
313
|
+
fontSize: "0.78rem"
|
|
314
|
+
},
|
|
315
|
+
children: e.lotNumber || "—"
|
|
316
|
+
}),
|
|
317
|
+
/* @__PURE__ */ f(E, {
|
|
318
|
+
align: "right",
|
|
319
|
+
sx: {
|
|
320
|
+
fontVariantNumeric: "tabular-nums",
|
|
321
|
+
fontWeight: 700
|
|
322
|
+
},
|
|
323
|
+
children: e.qtyRemaining
|
|
324
|
+
}),
|
|
325
|
+
/* @__PURE__ */ f(E, { children: e.expiryDate ? ue(e.expiryDate) : "—" }),
|
|
326
|
+
K.ownerType === "FACILITY" ? /* @__PURE__ */ f(E, { children: e.storageUnitName || "—" }) : null,
|
|
327
|
+
/* @__PURE__ */ f(E, { children: /* @__PURE__ */ f(ye, {
|
|
328
|
+
size: "small",
|
|
329
|
+
label: fe(pe, e.status),
|
|
330
|
+
color: ce(e.status)
|
|
331
|
+
}) })
|
|
332
|
+
] }, e.id)) })]
|
|
333
|
+
})]
|
|
334
|
+
})
|
|
335
|
+
}) : null,
|
|
336
|
+
/* @__PURE__ */ f(g, {
|
|
337
|
+
sx: {
|
|
338
|
+
borderRadius: 4,
|
|
339
|
+
mb: 2,
|
|
340
|
+
border: "1px solid",
|
|
341
|
+
borderColor: "divider",
|
|
342
|
+
boxShadow: "0 12px 32px rgba(15, 23, 42, 0.045)"
|
|
343
|
+
},
|
|
344
|
+
children: /* @__PURE__ */ p(_, {
|
|
345
|
+
sx: { p: 2.5 },
|
|
346
|
+
children: [
|
|
347
|
+
/* @__PURE__ */ p(T, {
|
|
348
|
+
direction: "row",
|
|
349
|
+
justifyContent: "space-between",
|
|
350
|
+
alignItems: "flex-start",
|
|
351
|
+
sx: { mb: 2 },
|
|
352
|
+
children: [/* @__PURE__ */ f(o, {
|
|
353
|
+
eyebrow: "Step 2",
|
|
354
|
+
title: "Line items",
|
|
355
|
+
hint: "Each item creates one batch in your inventory and a receipt record."
|
|
356
|
+
}), /* @__PURE__ */ f(h, {
|
|
357
|
+
variant: "outlined",
|
|
358
|
+
startIcon: /* @__PURE__ */ f(A, {}),
|
|
359
|
+
onClick: Pe,
|
|
360
|
+
children: "Add Line"
|
|
361
|
+
})]
|
|
362
|
+
}),
|
|
363
|
+
/* @__PURE__ */ f(v, { sx: { mb: 2 } }),
|
|
364
|
+
/* @__PURE__ */ f(T, {
|
|
365
|
+
spacing: 2,
|
|
366
|
+
children: K.items.map((e, t) => {
|
|
367
|
+
let n = Q[t] || {}, r = z.find((t) => t.id === e.productId), i = r?.hasExpiry === !0, a = r?.needsStorageUnit === !0 && K.ownerType === "FACILITY";
|
|
368
|
+
return /* @__PURE__ */ f(g, {
|
|
369
|
+
variant: "outlined",
|
|
370
|
+
sx: {
|
|
371
|
+
p: 2,
|
|
372
|
+
borderRadius: 3
|
|
373
|
+
},
|
|
374
|
+
children: /* @__PURE__ */ p(x, {
|
|
375
|
+
container: !0,
|
|
376
|
+
spacing: 2,
|
|
377
|
+
children: [
|
|
378
|
+
/* @__PURE__ */ f(x, {
|
|
379
|
+
item: !0,
|
|
380
|
+
xs: 12,
|
|
381
|
+
md: 3,
|
|
382
|
+
children: /* @__PURE__ */ p(y, {
|
|
383
|
+
required: !0,
|
|
384
|
+
fullWidth: !0,
|
|
385
|
+
size: "small",
|
|
386
|
+
error: W.show(`items.${t}.productId`) && !!n.productId,
|
|
387
|
+
children: [
|
|
388
|
+
/* @__PURE__ */ f(S, { children: "Product" }),
|
|
389
|
+
/* @__PURE__ */ f(w, {
|
|
390
|
+
label: "Product",
|
|
391
|
+
value: e.productId,
|
|
392
|
+
onChange: (e) => Y(t, "productId", e.target.value),
|
|
393
|
+
onBlur: W.onBlur(`items.${t}.productId`),
|
|
394
|
+
children: z.map((e) => /* @__PURE__ */ f(C, {
|
|
395
|
+
value: e.id,
|
|
396
|
+
children: e.name
|
|
397
|
+
}, e.id))
|
|
398
|
+
}),
|
|
399
|
+
W.show(`items.${t}.productId`) && n.productId ? /* @__PURE__ */ f(b, { children: n.productId }) : null
|
|
400
|
+
]
|
|
401
|
+
})
|
|
402
|
+
}),
|
|
403
|
+
/* @__PURE__ */ f(x, {
|
|
404
|
+
item: !0,
|
|
405
|
+
xs: 6,
|
|
406
|
+
md: 1,
|
|
407
|
+
children: /* @__PURE__ */ f(O, {
|
|
408
|
+
required: !0,
|
|
409
|
+
fullWidth: !0,
|
|
410
|
+
size: "small",
|
|
411
|
+
type: "number",
|
|
412
|
+
label: "Qty",
|
|
413
|
+
inputProps: { min: 1 },
|
|
414
|
+
value: e.quantity,
|
|
415
|
+
onChange: (e) => Y(t, "quantity", e.target.value),
|
|
416
|
+
onBlur: W.onBlur(`items.${t}.quantity`),
|
|
417
|
+
error: W.show(`items.${t}.quantity`) && !!n.quantity,
|
|
418
|
+
helperText: W.show(`items.${t}.quantity`) ? n.quantity : ""
|
|
419
|
+
})
|
|
420
|
+
}),
|
|
421
|
+
I ? /* @__PURE__ */ f(x, {
|
|
422
|
+
item: !0,
|
|
423
|
+
xs: 6,
|
|
424
|
+
md: 2,
|
|
425
|
+
children: /* @__PURE__ */ f(O, {
|
|
426
|
+
fullWidth: !0,
|
|
427
|
+
size: "small",
|
|
428
|
+
type: "number",
|
|
429
|
+
inputProps: {
|
|
430
|
+
step: "0.01",
|
|
431
|
+
min: 0
|
|
432
|
+
},
|
|
433
|
+
label: "Buy Price",
|
|
434
|
+
value: e.buyPrice,
|
|
435
|
+
onChange: (e) => Y(t, "buyPrice", e.target.value),
|
|
436
|
+
onBlur: W.onBlur(`items.${t}.buyPrice`),
|
|
437
|
+
error: W.show(`items.${t}.buyPrice`) && !!n.buyPrice,
|
|
438
|
+
helperText: W.show(`items.${t}.buyPrice`) ? n.buyPrice : ""
|
|
439
|
+
})
|
|
440
|
+
}) : null,
|
|
441
|
+
R ? null : /* @__PURE__ */ f(x, {
|
|
442
|
+
item: !0,
|
|
443
|
+
xs: 6,
|
|
444
|
+
md: 2,
|
|
445
|
+
children: /* @__PURE__ */ f(O, {
|
|
446
|
+
required: i,
|
|
447
|
+
fullWidth: !0,
|
|
448
|
+
size: "small",
|
|
449
|
+
type: "date",
|
|
450
|
+
label: "Expiry",
|
|
451
|
+
InputLabelProps: { shrink: !0 },
|
|
452
|
+
inputProps: { min: G },
|
|
453
|
+
value: e.expiryDate,
|
|
454
|
+
onChange: (e) => Y(t, "expiryDate", e.target.value),
|
|
455
|
+
onBlur: W.onBlur(`items.${t}.expiryDate`),
|
|
456
|
+
error: W.show(`items.${t}.expiryDate`) && !!n.expiryDate,
|
|
457
|
+
helperText: W.show(`items.${t}.expiryDate`) && n.expiryDate ? n.expiryDate : i ? "Required for this product" : ""
|
|
458
|
+
})
|
|
459
|
+
}),
|
|
460
|
+
R ? null : /* @__PURE__ */ f(x, {
|
|
461
|
+
item: !0,
|
|
462
|
+
xs: 6,
|
|
463
|
+
md: 2,
|
|
464
|
+
children: /* @__PURE__ */ f(O, {
|
|
465
|
+
fullWidth: !0,
|
|
466
|
+
size: "small",
|
|
467
|
+
label: "Lot #",
|
|
468
|
+
value: e.lotNumber,
|
|
469
|
+
onChange: (e) => Y(t, "lotNumber", e.target.value)
|
|
470
|
+
})
|
|
471
|
+
}),
|
|
472
|
+
/* @__PURE__ */ f(x, {
|
|
473
|
+
item: !0,
|
|
474
|
+
xs: 10,
|
|
475
|
+
md: 1,
|
|
476
|
+
children: /* @__PURE__ */ p(y, {
|
|
477
|
+
fullWidth: !0,
|
|
478
|
+
size: "small",
|
|
479
|
+
required: a,
|
|
480
|
+
disabled: K.ownerType !== "FACILITY" || !K.ownerId,
|
|
481
|
+
error: W.show(`items.${t}.storageUnitId`) && !!n.storageUnitId,
|
|
482
|
+
children: [
|
|
483
|
+
/* @__PURE__ */ f(S, { children: "Storage" }),
|
|
484
|
+
/* @__PURE__ */ p(w, {
|
|
485
|
+
label: "Storage",
|
|
486
|
+
value: e.storageUnitId || "",
|
|
487
|
+
onChange: (e) => Y(t, "storageUnitId", e.target.value),
|
|
488
|
+
onBlur: W.onBlur(`items.${t}.storageUnitId`),
|
|
489
|
+
children: [/* @__PURE__ */ f(C, {
|
|
490
|
+
value: "",
|
|
491
|
+
children: /* @__PURE__ */ f("em", { children: "—" })
|
|
492
|
+
}), Me.map((e) => /* @__PURE__ */ f(C, {
|
|
493
|
+
value: e.id,
|
|
494
|
+
children: e.unitName
|
|
495
|
+
}, e.id))]
|
|
496
|
+
}),
|
|
497
|
+
W.show(`items.${t}.storageUnitId`) && n.storageUnitId ? /* @__PURE__ */ f(b, { children: n.storageUnitId }) : a ? /* @__PURE__ */ f(b, { children: "Required for this product" }) : null
|
|
498
|
+
]
|
|
499
|
+
})
|
|
500
|
+
}),
|
|
501
|
+
/* @__PURE__ */ f(x, {
|
|
502
|
+
item: !0,
|
|
503
|
+
xs: 2,
|
|
504
|
+
md: 1,
|
|
505
|
+
sx: { textAlign: "right" },
|
|
506
|
+
children: /* @__PURE__ */ f(be, {
|
|
507
|
+
color: "error",
|
|
508
|
+
onClick: () => Ne(t),
|
|
509
|
+
disabled: K.items.length === 1,
|
|
510
|
+
children: /* @__PURE__ */ f(De, {})
|
|
511
|
+
})
|
|
512
|
+
})
|
|
513
|
+
]
|
|
514
|
+
})
|
|
515
|
+
}, e.key);
|
|
516
|
+
})
|
|
517
|
+
})
|
|
518
|
+
]
|
|
519
|
+
})
|
|
520
|
+
}),
|
|
521
|
+
/* @__PURE__ */ f(g, {
|
|
522
|
+
sx: {
|
|
523
|
+
borderRadius: 4,
|
|
524
|
+
bgcolor: "grey.50",
|
|
525
|
+
border: "1px solid",
|
|
526
|
+
borderColor: "divider",
|
|
527
|
+
boxShadow: "0 12px 32px rgba(15, 23, 42, 0.045)"
|
|
528
|
+
},
|
|
529
|
+
children: /* @__PURE__ */ p(_, {
|
|
530
|
+
sx: { p: 2.5 },
|
|
531
|
+
children: [
|
|
532
|
+
/* @__PURE__ */ f(o, {
|
|
533
|
+
eyebrow: "Step 3",
|
|
534
|
+
title: I ? "Bill summary" : "Receipt details",
|
|
535
|
+
hint: I ? "The total is calculated from items. Add payment mode and notes. The date is set automatically." : "Add notes about this receipt. The date is set automatically.",
|
|
536
|
+
sx: { mb: 2 }
|
|
537
|
+
}),
|
|
538
|
+
/* @__PURE__ */ p(x, {
|
|
539
|
+
container: !0,
|
|
540
|
+
spacing: 2,
|
|
541
|
+
children: [I ? /* @__PURE__ */ f(x, {
|
|
542
|
+
item: !0,
|
|
543
|
+
xs: 12,
|
|
544
|
+
md: 6,
|
|
545
|
+
children: /* @__PURE__ */ p(y, {
|
|
546
|
+
fullWidth: !0,
|
|
547
|
+
size: "small",
|
|
548
|
+
children: [/* @__PURE__ */ f(S, { children: "Payment Mode" }), /* @__PURE__ */ p(w, {
|
|
549
|
+
label: "Payment Mode",
|
|
550
|
+
value: K.paymentMode || "",
|
|
551
|
+
onChange: (e) => q({
|
|
552
|
+
...K,
|
|
553
|
+
paymentMode: e.target.value
|
|
554
|
+
}),
|
|
555
|
+
children: [/* @__PURE__ */ f(C, {
|
|
556
|
+
value: "",
|
|
557
|
+
children: /* @__PURE__ */ f("em", { children: "—" })
|
|
558
|
+
}), de.map((e) => /* @__PURE__ */ f(C, {
|
|
559
|
+
value: e.value,
|
|
560
|
+
children: e.label
|
|
561
|
+
}, e.value))]
|
|
562
|
+
})]
|
|
563
|
+
})
|
|
564
|
+
}) : null, /* @__PURE__ */ f(x, {
|
|
565
|
+
item: !0,
|
|
566
|
+
xs: 12,
|
|
567
|
+
md: I ? 6 : 12,
|
|
568
|
+
children: /* @__PURE__ */ f(O, {
|
|
569
|
+
fullWidth: !0,
|
|
570
|
+
size: "small",
|
|
571
|
+
label: "Notes",
|
|
572
|
+
value: K.notes,
|
|
573
|
+
onChange: (e) => q({
|
|
574
|
+
...K,
|
|
575
|
+
notes: e.target.value
|
|
576
|
+
})
|
|
577
|
+
})
|
|
578
|
+
})]
|
|
579
|
+
}),
|
|
580
|
+
I ? /* @__PURE__ */ p(ge, { children: [
|
|
581
|
+
/* @__PURE__ */ f(v, { sx: { my: 2 } }),
|
|
582
|
+
/* @__PURE__ */ p(T, {
|
|
583
|
+
direction: "row",
|
|
584
|
+
justifyContent: "flex-end",
|
|
585
|
+
alignItems: "baseline",
|
|
586
|
+
spacing: 2,
|
|
587
|
+
children: [/* @__PURE__ */ p(k, {
|
|
588
|
+
variant: "body2",
|
|
589
|
+
color: "text.secondary",
|
|
590
|
+
children: [
|
|
591
|
+
"Total (",
|
|
592
|
+
K.items.length,
|
|
593
|
+
" ",
|
|
594
|
+
K.items.length === 1 ? "line" : "lines",
|
|
595
|
+
")"
|
|
596
|
+
]
|
|
597
|
+
}), /* @__PURE__ */ f(k, {
|
|
598
|
+
variant: "h4",
|
|
599
|
+
sx: {
|
|
600
|
+
fontWeight: 800,
|
|
601
|
+
fontVariantNumeric: "tabular-nums"
|
|
602
|
+
},
|
|
603
|
+
children: X.priced ? le(X.sum) : "—"
|
|
604
|
+
})]
|
|
605
|
+
}),
|
|
606
|
+
X.priced ? null : /* @__PURE__ */ f(k, {
|
|
607
|
+
variant: "caption",
|
|
608
|
+
color: "text.secondary",
|
|
609
|
+
sx: {
|
|
610
|
+
display: "block",
|
|
611
|
+
textAlign: "right"
|
|
612
|
+
},
|
|
613
|
+
children: "Add a Buy Price on at least one line to compute the total."
|
|
614
|
+
})
|
|
615
|
+
] }) : null
|
|
616
|
+
]
|
|
617
|
+
})
|
|
618
|
+
})
|
|
619
|
+
]
|
|
620
|
+
})
|
|
621
|
+
})] });
|
|
622
|
+
}
|
|
623
|
+
//#endregion
|
|
624
|
+
export { P as default };
|
|
625
|
+
|
|
626
|
+
//# sourceMappingURL=PurchaseCreatePage-C3KMfBxJ.js.map
|