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