@argusoft/medplat-product-management 1.0.1 → 1.0.2

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.
@@ -9,21 +9,21 @@ import { useEffect as he, useMemo as u, useState as d } from "react";
9
9
  import { Fragment as ge, jsx as f, jsxs as p } from "react/jsx-runtime";
10
10
  import { v4 as m } from "uuid";
11
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";
12
+ import we from "@mui/icons-material/AddRounded";
13
+ import { showToast as A } from "@/common/toaster/toaster";
14
+ import { useNavigate as Te } from "react-router-dom";
15
+ import Ee from "@mui/icons-material/Inventory2Rounded";
16
+ import De from "@mui/icons-material/SaveRounded";
17
+ import Oe from "@mui/icons-material/DeleteOutlineRounded";
18
18
  //#region src/views/PurchaseCreatePage.jsx
19
- var M = [{
19
+ var j = [{
20
20
  value: "USER",
21
21
  label: "Personal Use"
22
22
  }, {
23
23
  value: "FACILITY",
24
24
  label: "Facility Use"
25
25
  }];
26
- function N() {
26
+ function M() {
27
27
  return {
28
28
  key: m(),
29
29
  batchId: m(),
@@ -36,23 +36,23 @@ function N() {
36
36
  storageUnitId: ""
37
37
  };
38
38
  }
39
- function P() {
40
- let P = we(), F = a(), 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({
39
+ function N() {
40
+ let N = Te(), P = a(), F = P?.managePurchaseAmounts !== !1, I = P?.allowPersonalPurchase !== !1, L = P?.requirePurchaseConfirmation === !0, ke = u(() => I ? j : j.filter((e) => e.value !== "USER"), [I]), [R, Ae] = d([]), [z, je] = d([]), [B, Me] = d([]), [V, H] = d(""), U = se(), W = (/* @__PURE__ */ new Date()).toISOString().substring(0, 10), [G, K] = d({
41
41
  id: m(),
42
- ownerType: L ? "USER" : "FACILITY",
42
+ ownerType: I ? "USER" : "FACILITY",
43
43
  ownerId: "",
44
- purchaseDate: G,
44
+ purchaseDate: W,
45
45
  paymentMode: "CASH",
46
46
  notes: "",
47
- items: [N()]
47
+ items: [M()]
48
48
  });
49
49
  he(() => {
50
- !L && K.ownerType === "USER" && q((e) => ({
50
+ !I && G.ownerType === "USER" && K((e) => ({
51
51
  ...e,
52
52
  ownerType: "FACILITY",
53
53
  ownerId: ""
54
54
  }));
55
- }, [L, K.ownerType]), n("update.manage.productManagement.purchase", () => {
55
+ }, [I, G.ownerType]), n("update.manage.productManagement.purchase", () => {
56
56
  async function n() {
57
57
  try {
58
58
  let [n, r, a] = await Promise.all([
@@ -60,24 +60,24 @@ function P() {
60
60
  t({ activeOnly: !0 }),
61
61
  e().catch(() => [])
62
62
  ]);
63
- ke(n), Ae(r), je(a);
63
+ Ae(n), je(r), Me(a);
64
64
  } catch (e) {
65
- U(e?.response?.data?.message ?? e?.message ?? "Failed to load reference data");
65
+ H(e?.response?.data?.message ?? e?.message ?? "Failed to load reference data");
66
66
  }
67
67
  }
68
68
  n();
69
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), [
70
+ let q = u(() => G.ownerType === "USER" ? B.filter((e) => e.ownerType === "USER" && Number(e.qtyRemaining ?? 0) > 0 && e.status !== "EXPIRED" && e.status !== "EXHAUSTED") : G.ownerType === "FACILITY" && G.ownerId ? B.filter((e) => e.ownerType === "FACILITY" && e.ownerId === G.ownerId && Number(e.qtyRemaining ?? 0) > 0 && e.status !== "EXPIRED" && e.status !== "EXHAUSTED") : [], [
75
71
  B,
76
- K.ownerType,
77
- K.ownerId
72
+ G.ownerType,
73
+ G.ownerId
74
+ ]), Ne = u(() => G.ownerType !== "FACILITY" || !G.ownerId ? [] : z.filter((e) => e.ownerId === G.ownerId), [
75
+ z,
76
+ G.ownerType,
77
+ G.ownerId
78
78
  ]);
79
- function Y(e, t, n) {
80
- q((r) => {
79
+ function J(e, t, n) {
80
+ K((r) => {
81
81
  let i = r.items.slice();
82
82
  return i[e] = {
83
83
  ...i[e],
@@ -88,36 +88,36 @@ function P() {
88
88
  };
89
89
  });
90
90
  }
91
- function Ne(e) {
92
- q((t) => ({
91
+ function Pe(e) {
92
+ K((t) => ({
93
93
  ...t,
94
94
  items: t.items.filter((t, n) => n !== e)
95
95
  }));
96
96
  }
97
- function Pe() {
98
- q((e) => ({
97
+ function Y() {
98
+ K((e) => ({
99
99
  ...e,
100
- items: [...e.items, N()]
100
+ items: [...e.items, M()]
101
101
  }));
102
102
  }
103
103
  let X = u(() => {
104
104
  let e = !1;
105
105
  return {
106
- sum: K.items.reduce((t, n) => {
106
+ sum: G.items.reduce((t, n) => {
107
107
  if (n.buyPrice === "" || n.quantity === "" || n.quantity == null) return t;
108
108
  let r = Number(n.quantity), i = Number(n.buyPrice);
109
109
  return Number.isNaN(r) || Number.isNaN(i) ? t : (e = !0, t + r * i);
110
110
  }, 0),
111
111
  priced: e
112
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") : "";
113
+ }, [G.items]), Z = {
114
+ ownerType: c(G.ownerType, "Purchase type"),
115
+ ownerId: G.ownerType === "FACILITY" ? c(G.ownerId, "Facility") : "",
116
+ purchaseDate: c(G.purchaseDate, "Purchase date")
117
+ }, Q = G.items.map((e) => {
118
+ let t = R.find((t) => t.id === e.productId), n = t?.hasExpiry === !0, r = t?.needsStorageUnit === !0 && G.ownerType === "FACILITY" ? c(e.storageUnitId, "Storage unit") : "";
119
119
  if (!r && e.storageUnitId && t?.vaccineConfig) {
120
- let n = t.vaccineConfig, i = B.find((t) => t.id === e.storageUnitId);
120
+ let n = t.vaccineConfig, i = z.find((t) => t.id === e.storageUnitId);
121
121
  if (n.storageTempMinCelsius != null && n.storageTempMaxCelsius != null && i) {
122
122
  let e = i.operatingTempMinCelsius, t = i.operatingTempMaxCelsius;
123
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.`);
@@ -126,30 +126,30 @@ function P() {
126
126
  return {
127
127
  productId: c(e.productId, "Product"),
128
128
  quantity: ae(e.quantity),
129
- buyPrice: s(e.buyPrice),
130
- expiryDate: R ? "" : n && c(e.expiryDate, "Expiry date") || ie(e.expiryDate, { label: "Expiry" }),
129
+ buyPrice: F ? c(e.buyPrice, "Buy price") || s(e.buyPrice) || (Number(e.buyPrice) > 0 ? "" : "Buy price must be greater than 0.") : s(e.buyPrice),
130
+ expiryDate: L ? "" : n && c(e.expiryDate, "Expiry date") || ie(e.expiryDate, { label: "Expiry" }),
131
131
  manufactureDate: oe(e.manufactureDate, { label: "Manufacture date" }),
132
132
  storageUnitId: r
133
133
  };
134
- }), $ = l(Z) && Q.every(l) && K.items.length > 0;
134
+ }), $ = l(Z) && Q.every(l) && G.items.length > 0;
135
135
  async function Fe() {
136
136
  if (!$) {
137
- W.markAllTouched(), U("Please fix the highlighted fields and try again.");
137
+ U.markAllTouched(), H("Please fix the highlighted fields and try again.");
138
138
  return;
139
139
  }
140
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) => ({
141
+ id: G.id,
142
+ ownerType: G.ownerType,
143
+ ownerId: G.ownerType === "FACILITY" ? G.ownerId : null,
144
+ purchaseDate: G.purchaseDate,
145
+ paymentMode: F && G.paymentMode || null,
146
+ totalAmount: F && X.priced ? Number(X.sum.toFixed(2)) : null,
147
+ notes: G.notes || null,
148
+ items: G.items.map((e) => ({
149
149
  batchId: e.batchId,
150
150
  productId: e.productId,
151
151
  quantity: Number(e.quantity),
152
- buyPrice: I && e.buyPrice !== "" ? Number(e.buyPrice) : null,
152
+ buyPrice: F && e.buyPrice !== "" ? Number(e.buyPrice) : null,
153
153
  expiryDate: e.expiryDate || null,
154
154
  lotNumber: e.lotNumber || null,
155
155
  manufactureDate: e.manufactureDate || null,
@@ -157,46 +157,46 @@ function P() {
157
157
  }))
158
158
  };
159
159
  try {
160
- if (R) {
160
+ if (L) {
161
161
  let t = await r(e);
162
- j({
162
+ A({
163
163
  message: "Purchase request submitted for approval.",
164
164
  type: "success"
165
- }), P(`/ui/medplat/manage/pm/purchase-requests/${t?.id ?? K.id}`);
166
- } else await re(e), j({
165
+ }), N(`/ui/medplat/manage/pm/purchase-requests/${t?.id ?? G.id}`);
166
+ } else await re(e), A({
167
167
  message: "Purchase recorded.",
168
168
  type: "success"
169
- }), P("/ui/medplat/manage/pm/purchases");
169
+ }), N("/ui/medplat/manage/pm/purchases");
170
170
  } catch (e) {
171
- U(e?.response?.data?.message ?? e?.message ?? (R ? "Failed to submit purchase request" : "Failed to record purchase"));
171
+ H(e?.response?.data?.message ?? e?.message ?? (L ? "Failed to submit purchase request" : "Failed to record purchase"));
172
172
  }
173
173
  }
174
174
  return /* @__PURE__ */ p(ve, { children: [/* @__PURE__ */ f(ne, {}), /* @__PURE__ */ f(ee, {
175
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",
176
+ title: L ? "You don’t have permission to submit purchase requests" : "You don’t have permission to record purchases",
177
177
  children: /* @__PURE__ */ p(te, {
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.",
178
+ title: L ? "Submit Purchase Request" : "Record Purchase",
179
+ subtitle: L ? "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
180
  actions: /* @__PURE__ */ p(T, {
181
181
  direction: "row",
182
182
  spacing: 1,
183
183
  children: [/* @__PURE__ */ f(h, {
184
184
  variant: "outlined",
185
- onClick: () => P(R ? "/ui/medplat/manage/pm/purchase-requests" : "/ui/medplat/manage/pm/purchases"),
185
+ onClick: () => N(L ? "/ui/medplat/manage/pm/purchase-requests" : "/ui/medplat/manage/pm/purchases"),
186
186
  children: "Cancel"
187
187
  }), /* @__PURE__ */ f(h, {
188
188
  variant: "contained",
189
- startIcon: /* @__PURE__ */ f(Ee, {}),
189
+ startIcon: /* @__PURE__ */ f(De, {}),
190
190
  disabled: !$,
191
191
  onClick: () => void Fe(),
192
- children: R ? "Submit Request" : "Save"
192
+ children: L ? "Submit Request" : "Save"
193
193
  })]
194
194
  }),
195
195
  children: [
196
- H ? /* @__PURE__ */ f(_e, {
196
+ V ? /* @__PURE__ */ f(_e, {
197
197
  severity: "error",
198
198
  sx: { mb: 2 },
199
- children: H
199
+ children: V
200
200
  }) : null,
201
201
  /* @__PURE__ */ f(g, {
202
202
  sx: {
@@ -224,46 +224,46 @@ function P() {
224
224
  required: !0,
225
225
  fullWidth: !0,
226
226
  size: "small",
227
- error: W.show("ownerType") && !!Z.ownerType,
227
+ error: U.show("ownerType") && !!Z.ownerType,
228
228
  children: [
229
229
  /* @__PURE__ */ f(S, { children: "Purchase Type" }),
230
230
  /* @__PURE__ */ f(w, {
231
231
  label: "Purchase Type",
232
- value: K.ownerType,
233
- onChange: (e) => q({
234
- ...K,
232
+ value: G.ownerType,
233
+ onChange: (e) => K({
234
+ ...G,
235
235
  ownerType: e.target.value,
236
236
  ownerId: ""
237
237
  }),
238
- onBlur: W.onBlur("ownerType"),
239
- children: Oe.map((e) => /* @__PURE__ */ f(C, {
238
+ onBlur: U.onBlur("ownerType"),
239
+ children: ke.map((e) => /* @__PURE__ */ f(C, {
240
240
  value: e.value,
241
241
  children: e.label
242
242
  }, e.value))
243
243
  }),
244
- /* @__PURE__ */ f(b, { children: W.show("ownerType") && Z.ownerType ? Z.ownerType : "Personal stock vs. facility stock" })
244
+ /* @__PURE__ */ f(b, { children: U.show("ownerType") && Z.ownerType ? Z.ownerType : "Personal stock vs. facility stock" })
245
245
  ]
246
246
  })
247
- }), K.ownerType === "FACILITY" ? /* @__PURE__ */ f(x, {
247
+ }), G.ownerType === "FACILITY" ? /* @__PURE__ */ f(x, {
248
248
  item: !0,
249
249
  xs: 12,
250
250
  md: 4,
251
251
  children: /* @__PURE__ */ f(me, {
252
252
  required: !0,
253
- value: K.ownerId,
254
- onChange: (e) => q({
255
- ...K,
253
+ value: G.ownerId,
254
+ onChange: (e) => K({
255
+ ...G,
256
256
  ownerId: e
257
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."
258
+ onBlur: U.onBlur("ownerId"),
259
+ error: U.show("ownerId") && !!Z.ownerId,
260
+ helperText: U.show("ownerId") && Z.ownerId ? Z.ownerId : "Search for the facility."
261
261
  })
262
262
  }) : null]
263
263
  })]
264
264
  })
265
265
  }),
266
- K.ownerType === "USER" || K.ownerType === "FACILITY" && K.ownerId ? /* @__PURE__ */ f(g, {
266
+ G.ownerType === "USER" || G.ownerType === "FACILITY" && G.ownerId ? /* @__PURE__ */ f(g, {
267
267
  sx: {
268
268
  borderRadius: 4,
269
269
  mb: 2,
@@ -276,9 +276,9 @@ function P() {
276
276
  children: [/* @__PURE__ */ f(o, {
277
277
  eyebrow: "Context",
278
278
  title: "Existing inventory",
279
- hint: K.ownerType === "USER" ? "Your current stock." : "What this facility already has, including where it is stored.",
279
+ hint: G.ownerType === "USER" ? "Your current stock." : "What this facility already has, including where it is stored.",
280
280
  sx: { mb: 1.5 }
281
- }), J.length === 0 ? /* @__PURE__ */ p(T, {
281
+ }), q.length === 0 ? /* @__PURE__ */ p(T, {
282
282
  direction: "row",
283
283
  spacing: 1.25,
284
284
  alignItems: "center",
@@ -286,7 +286,7 @@ function P() {
286
286
  py: 1.5,
287
287
  color: "text.secondary"
288
288
  },
289
- children: [/* @__PURE__ */ f(Te, { fontSize: "small" }), /* @__PURE__ */ f(k, {
289
+ children: [/* @__PURE__ */ f(Ee, { fontSize: "small" }), /* @__PURE__ */ f(k, {
290
290
  variant: "body2",
291
291
  children: "No active stock yet for this owner."
292
292
  })]
@@ -300,9 +300,9 @@ function P() {
300
300
  children: "Remaining"
301
301
  }),
302
302
  /* @__PURE__ */ f(E, { children: "Expiry" }),
303
- K.ownerType === "FACILITY" ? /* @__PURE__ */ f(E, { children: "Storage" }) : null,
303
+ G.ownerType === "FACILITY" ? /* @__PURE__ */ f(E, { children: "Storage" }) : null,
304
304
  /* @__PURE__ */ f(E, { children: "Status" })
305
- ] }) }), /* @__PURE__ */ f(Se, { children: J.map((e) => /* @__PURE__ */ p(D, { children: [
305
+ ] }) }), /* @__PURE__ */ f(Se, { children: q.map((e) => /* @__PURE__ */ p(D, { children: [
306
306
  /* @__PURE__ */ f(E, {
307
307
  sx: { fontWeight: 700 },
308
308
  children: e.productName
@@ -323,7 +323,7 @@ function P() {
323
323
  children: e.qtyRemaining
324
324
  }),
325
325
  /* @__PURE__ */ f(E, { children: e.expiryDate ? ue(e.expiryDate) : "—" }),
326
- K.ownerType === "FACILITY" ? /* @__PURE__ */ f(E, { children: e.storageUnitName || "—" }) : null,
326
+ G.ownerType === "FACILITY" ? /* @__PURE__ */ f(E, { children: e.storageUnitName || "—" }) : null,
327
327
  /* @__PURE__ */ f(E, { children: /* @__PURE__ */ f(ye, {
328
328
  size: "small",
329
329
  label: fe(pe, e.status),
@@ -355,16 +355,16 @@ function P() {
355
355
  hint: "Each item creates one batch in your inventory and a receipt record."
356
356
  }), /* @__PURE__ */ f(h, {
357
357
  variant: "outlined",
358
- startIcon: /* @__PURE__ */ f(A, {}),
359
- onClick: Pe,
358
+ startIcon: /* @__PURE__ */ f(we, {}),
359
+ onClick: Y,
360
360
  children: "Add Line"
361
361
  })]
362
362
  }),
363
363
  /* @__PURE__ */ f(v, { sx: { mb: 2 } }),
364
364
  /* @__PURE__ */ f(T, {
365
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";
366
+ children: G.items.map((e, t) => {
367
+ let n = Q[t] || {}, r = R.find((t) => t.id === e.productId), i = r?.hasExpiry === !0, a = r?.needsStorageUnit === !0 && G.ownerType === "FACILITY";
368
368
  return /* @__PURE__ */ f(g, {
369
369
  variant: "outlined",
370
370
  sx: {
@@ -383,20 +383,20 @@ function P() {
383
383
  required: !0,
384
384
  fullWidth: !0,
385
385
  size: "small",
386
- error: W.show(`items.${t}.productId`) && !!n.productId,
386
+ error: U.show(`items.${t}.productId`) && !!n.productId,
387
387
  children: [
388
388
  /* @__PURE__ */ f(S, { children: "Product" }),
389
389
  /* @__PURE__ */ f(w, {
390
390
  label: "Product",
391
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, {
392
+ onChange: (e) => J(t, "productId", e.target.value),
393
+ onBlur: U.onBlur(`items.${t}.productId`),
394
+ children: R.map((e) => /* @__PURE__ */ f(C, {
395
395
  value: e.id,
396
396
  children: e.name
397
397
  }, e.id))
398
398
  }),
399
- W.show(`items.${t}.productId`) && n.productId ? /* @__PURE__ */ f(b, { children: n.productId }) : null
399
+ U.show(`items.${t}.productId`) && n.productId ? /* @__PURE__ */ f(b, { children: n.productId }) : null
400
400
  ]
401
401
  })
402
402
  }),
@@ -412,17 +412,18 @@ function P() {
412
412
  label: "Qty",
413
413
  inputProps: { min: 1 },
414
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 : ""
415
+ onChange: (e) => J(t, "quantity", e.target.value),
416
+ onBlur: U.onBlur(`items.${t}.quantity`),
417
+ error: U.show(`items.${t}.quantity`) && !!n.quantity,
418
+ helperText: U.show(`items.${t}.quantity`) ? n.quantity : ""
419
419
  })
420
420
  }),
421
- I ? /* @__PURE__ */ f(x, {
421
+ F ? /* @__PURE__ */ f(x, {
422
422
  item: !0,
423
423
  xs: 6,
424
424
  md: 2,
425
425
  children: /* @__PURE__ */ f(O, {
426
+ required: !0,
426
427
  fullWidth: !0,
427
428
  size: "small",
428
429
  type: "number",
@@ -432,13 +433,13 @@ function P() {
432
433
  },
433
434
  label: "Buy Price",
434
435
  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 : ""
436
+ onChange: (e) => J(t, "buyPrice", e.target.value),
437
+ onBlur: U.onBlur(`items.${t}.buyPrice`),
438
+ error: U.show(`items.${t}.buyPrice`) && !!n.buyPrice,
439
+ helperText: U.show(`items.${t}.buyPrice`) ? n.buyPrice : ""
439
440
  })
440
441
  }) : null,
441
- R ? null : /* @__PURE__ */ f(x, {
442
+ L ? null : /* @__PURE__ */ f(x, {
442
443
  item: !0,
443
444
  xs: 6,
444
445
  md: 2,
@@ -449,15 +450,15 @@ function P() {
449
450
  type: "date",
450
451
  label: "Expiry",
451
452
  InputLabelProps: { shrink: !0 },
452
- inputProps: { min: G },
453
+ inputProps: { min: W },
453
454
  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" : ""
455
+ onChange: (e) => J(t, "expiryDate", e.target.value),
456
+ onBlur: U.onBlur(`items.${t}.expiryDate`),
457
+ error: U.show(`items.${t}.expiryDate`) && !!n.expiryDate,
458
+ helperText: U.show(`items.${t}.expiryDate`) && n.expiryDate ? n.expiryDate : i ? "Required for this product" : ""
458
459
  })
459
460
  }),
460
- R ? null : /* @__PURE__ */ f(x, {
461
+ L ? null : /* @__PURE__ */ f(x, {
461
462
  item: !0,
462
463
  xs: 6,
463
464
  md: 2,
@@ -466,7 +467,7 @@ function P() {
466
467
  size: "small",
467
468
  label: "Lot #",
468
469
  value: e.lotNumber,
469
- onChange: (e) => Y(t, "lotNumber", e.target.value)
470
+ onChange: (e) => J(t, "lotNumber", e.target.value)
470
471
  })
471
472
  }),
472
473
  /* @__PURE__ */ f(x, {
@@ -477,24 +478,24 @@ function P() {
477
478
  fullWidth: !0,
478
479
  size: "small",
479
480
  required: a,
480
- disabled: K.ownerType !== "FACILITY" || !K.ownerId,
481
- error: W.show(`items.${t}.storageUnitId`) && !!n.storageUnitId,
481
+ disabled: G.ownerType !== "FACILITY" || !G.ownerId,
482
+ error: U.show(`items.${t}.storageUnitId`) && !!n.storageUnitId,
482
483
  children: [
483
484
  /* @__PURE__ */ f(S, { children: "Storage" }),
484
485
  /* @__PURE__ */ p(w, {
485
486
  label: "Storage",
486
487
  value: e.storageUnitId || "",
487
- onChange: (e) => Y(t, "storageUnitId", e.target.value),
488
- onBlur: W.onBlur(`items.${t}.storageUnitId`),
488
+ onChange: (e) => J(t, "storageUnitId", e.target.value),
489
+ onBlur: U.onBlur(`items.${t}.storageUnitId`),
489
490
  children: [/* @__PURE__ */ f(C, {
490
491
  value: "",
491
492
  children: /* @__PURE__ */ f("em", { children: "—" })
492
- }), Me.map((e) => /* @__PURE__ */ f(C, {
493
+ }), Ne.map((e) => /* @__PURE__ */ f(C, {
493
494
  value: e.id,
494
495
  children: e.unitName
495
496
  }, e.id))]
496
497
  }),
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
+ U.show(`items.${t}.storageUnitId`) && n.storageUnitId ? /* @__PURE__ */ f(b, { children: n.storageUnitId }) : a ? /* @__PURE__ */ f(b, { children: "Required for this product" }) : null
498
499
  ]
499
500
  })
500
501
  }),
@@ -505,9 +506,9 @@ function P() {
505
506
  sx: { textAlign: "right" },
506
507
  children: /* @__PURE__ */ f(be, {
507
508
  color: "error",
508
- onClick: () => Ne(t),
509
- disabled: K.items.length === 1,
510
- children: /* @__PURE__ */ f(De, {})
509
+ onClick: () => Pe(t),
510
+ disabled: G.items.length === 1,
511
+ children: /* @__PURE__ */ f(Oe, {})
511
512
  })
512
513
  })
513
514
  ]
@@ -531,14 +532,14 @@ function P() {
531
532
  children: [
532
533
  /* @__PURE__ */ f(o, {
533
534
  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.",
535
+ title: F ? "Bill summary" : "Receipt details",
536
+ hint: F ? "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
537
  sx: { mb: 2 }
537
538
  }),
538
539
  /* @__PURE__ */ p(x, {
539
540
  container: !0,
540
541
  spacing: 2,
541
- children: [I ? /* @__PURE__ */ f(x, {
542
+ children: [F ? /* @__PURE__ */ f(x, {
542
543
  item: !0,
543
544
  xs: 12,
544
545
  md: 6,
@@ -547,9 +548,9 @@ function P() {
547
548
  size: "small",
548
549
  children: [/* @__PURE__ */ f(S, { children: "Payment Mode" }), /* @__PURE__ */ p(w, {
549
550
  label: "Payment Mode",
550
- value: K.paymentMode || "",
551
- onChange: (e) => q({
552
- ...K,
551
+ value: G.paymentMode || "",
552
+ onChange: (e) => K({
553
+ ...G,
553
554
  paymentMode: e.target.value
554
555
  }),
555
556
  children: [/* @__PURE__ */ f(C, {
@@ -564,20 +565,20 @@ function P() {
564
565
  }) : null, /* @__PURE__ */ f(x, {
565
566
  item: !0,
566
567
  xs: 12,
567
- md: I ? 6 : 12,
568
+ md: F ? 6 : 12,
568
569
  children: /* @__PURE__ */ f(O, {
569
570
  fullWidth: !0,
570
571
  size: "small",
571
572
  label: "Notes",
572
- value: K.notes,
573
- onChange: (e) => q({
574
- ...K,
573
+ value: G.notes,
574
+ onChange: (e) => K({
575
+ ...G,
575
576
  notes: e.target.value
576
577
  })
577
578
  })
578
579
  })]
579
580
  }),
580
- I ? /* @__PURE__ */ p(ge, { children: [
581
+ F ? /* @__PURE__ */ p(ge, { children: [
581
582
  /* @__PURE__ */ f(v, { sx: { my: 2 } }),
582
583
  /* @__PURE__ */ p(T, {
583
584
  direction: "row",
@@ -589,9 +590,9 @@ function P() {
589
590
  color: "text.secondary",
590
591
  children: [
591
592
  "Total (",
592
- K.items.length,
593
+ G.items.length,
593
594
  " ",
594
- K.items.length === 1 ? "line" : "lines",
595
+ G.items.length === 1 ? "line" : "lines",
595
596
  ")"
596
597
  ]
597
598
  }), /* @__PURE__ */ f(k, {
@@ -621,6 +622,6 @@ function P() {
621
622
  })] });
622
623
  }
623
624
  //#endregion
624
- export { P as default };
625
+ export { N as default };
625
626
 
626
- //# sourceMappingURL=PurchaseCreatePage-Dcsg4uoB.js.map
627
+ //# sourceMappingURL=PurchaseCreatePage-CDfNDcKG.js.map