@argusoft/medplat-product-management 1.0.2 → 1.0.4

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