@feedmepos/mf-inventory-portal 1.2.10-dev.1 → 1.2.10-dev.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.
Files changed (47) hide show
  1. package/dist/{App-Bg2M5RwP.js → App-D9otYMgh.js} +1 -1
  2. package/dist/{ApprovalView-C46UDXnc.js → ApprovalView-Bue46U6e.js} +2 -2
  3. package/dist/{BindingsDialog-CtJjpbw-.js → BindingsDialog-Xleskmvg.js} +2 -2
  4. package/dist/{BindingsPicker-B6Er5Lea.js → BindingsPicker-BeNF1NcZ.js} +1 -1
  5. package/dist/{BindingsTable-MPeTr_ip.js → BindingsTable-ecWz3SHk.js} +1 -1
  6. package/dist/{ClosingDraftView-BaD3MLeG.js → ClosingDraftView-DkxOW9Ns.js} +2 -2
  7. package/dist/{ClosingTemplateView-C4z3GXwd.js → ClosingTemplateView-BbnpVNYF.js} +3 -3
  8. package/dist/{DeliveryOrderPrintPreview-BfafKFMa.js → DeliveryOrderPrintPreview-CH-IzSM9.js} +1 -1
  9. package/dist/{FmAdminBadge-Dg5rl1fj.js → FmAdminBadge-D4rqYlKu.js} +1 -1
  10. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-BATVvC9u.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DOR_Iu0w.js} +3 -3
  11. package/dist/{FmMultiselectDialog-DJ-dIe8C.js → FmMultiselectDialog-DBgk0_mV.js} +1 -1
  12. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-BBWaPrlm.js → FmUnitInput.vue_vue_type_script_setup_true_lang-DdxSlJRz.js} +1 -1
  13. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-oaujHoaU.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-C22gncaQ.js} +1 -1
  14. package/dist/{IngredientGroupView-u4ubHtNF.js → IngredientGroupView-CrNLRll8.js} +2 -2
  15. package/dist/{IngredientsView-CXbJifY6.js → IngredientsView-DLK0Seww.js} +135 -129
  16. package/dist/{IntegrationView-XEypfcAW.js → IntegrationView-DRwnqCf9.js} +4 -4
  17. package/dist/{InventoryBindingForm-CETOb5Nj.js → InventoryBindingForm-DU6B0J0B.js} +1 -1
  18. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-DC52GJ2Y.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-CLCDb25h.js} +3 -3
  19. package/dist/{InventoryBindingSummary-DbyJW8z0.js → InventoryBindingSummary-BH2bWICt.js} +1 -1
  20. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BQWWQxaq.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BD2hneTA.js} +1 -1
  21. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-BruydtsG.js → PremiumBadge.vue_vue_type_script_setup_true_lang-GabOf_-7.js} +1 -1
  22. package/dist/{PublishView-Cl3IluMR.js → PublishView-B510iDYx.js} +1 -1
  23. package/dist/{PurchaseOrderPrintPreview-BG_uBL4o.js → PurchaseOrderPrintPreview-Cbsl8gcZ.js} +1 -1
  24. package/dist/{ReceiveRequestView-BvGlUVTp.js → ReceiveRequestView-rKyNjRbk.js} +8 -8
  25. package/dist/{RecipeView-C-7XU5F8.js → RecipeView-C9dw-1_E.js} +3 -3
  26. package/dist/StockView-scnHVHGB.js +2158 -0
  27. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-D0kASPO9.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-Dt1S8tTH.js} +1 -1
  28. package/dist/{SupplierView-BoGoqUS-.js → SupplierView-to6stKYV.js} +4 -4
  29. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-D53vhWDq.js → TransferDetails.vue_vue_type_script_setup_true_lang-laVp-HrL.js} +6 -6
  30. package/dist/{TransferTemplateView-DZIDXFp7.js → TransferTemplateView-VOgIhPGW.js} +7 -7
  31. package/dist/{UnitView-CvHIFkue.js → UnitView-sr5QkKex.js} +3 -3
  32. package/dist/{WarehouseView-Dh_WZz5L.js → WarehouseView-CB3luO1P.js} +1 -1
  33. package/dist/{app-BT34Yv61.js → app-BpyxIAaY.js} +6031 -6014
  34. package/dist/app.js +1 -1
  35. package/dist/{closing-template-JDCk0_lU.js → closing-template-CEJaVQKn.js} +1 -1
  36. package/dist/{decimal-BTgTm2JD.js → decimal-Dqff6QMJ.js} +1 -1
  37. package/dist/{format-unit-display-HHCA1rN3.js → format-unit-display-DcORb0K7.js} +3 -3
  38. package/dist/{index-CdamrmzX.js → index-CFfIlNHC.js} +1 -1
  39. package/dist/{index-Bz_lEYOD.js → index-rTyWq-0n.js} +1 -1
  40. package/dist/{purchase-order-template-DJiYiY6t.js → purchase-order-template-BFPrzfeR.js} +1 -1
  41. package/dist/{stock-C8afHO4C.js → stock-CkgmiPOr.js} +1 -1
  42. package/dist/{supplier-C8RMKqQX.js → supplier-Db_-hKgm.js} +1 -1
  43. package/dist/tsconfig.app.tsbuildinfo +1 -1
  44. package/dist/{use-ingredient-select-dialog-fLK9yq-0.js → use-ingredient-select-dialog-CEEFJa9x.js} +1 -1
  45. package/dist/{use-inventory-binding-dialog--7tzpXgV.js → use-inventory-binding-dialog-C6Ev4777.js} +1 -1
  46. package/package.json +2 -2
  47. package/dist/StockView-rYhlg4fr.js +0 -2104
@@ -0,0 +1,2158 @@
1
+ import { defineComponent as ce, ref as N, computed as H, resolveComponent as I, openBlock as F, createBlock as K, withCtx as j, createElementVNode as e, normalizeClass as he, toDisplayString as b, createVNode as g, createElementBlock as O, Fragment as Z, renderList as ie, unref as u, h as fe, watch as xe, isRef as Ue, createCommentVNode as te, reactive as ut, mergeModels as Ye, useModel as ct, onMounted as Ee, createTextVNode as ue, normalizeStyle as Ze, Teleport as dt, normalizeProps as Ae, mergeProps as Ve } from "vue";
2
+ import { u as pe, a1 as mt, f as He, h as pt, a as Pe, F as Ke, a2 as vt, w as je, k as me, Y as ft, t as Se, a0 as Fe, A as yt, M as _t, $ as ye, a3 as bt, a4 as ne, a5 as kt, a6 as Ge, o as gt, s as ht, a7 as xt, a8 as St, a9 as Ft, aa as Ce, ab as wt, ac as et, Z as X, ad as $t, z as tt, ae as ke, af as At, ag as Vt, q as Me, n as We, r as Ct, c as Mt, ah as Bt, ai as Dt, aj as It, ak as jt, al as Tt, b as Ut, N as Et, J as Ht, K as Pt, L as Rt, O as Ot, P as Nt, Q as qe } from "./app-BpyxIAaY.js";
3
+ import { u as Re, a as _e } from "./stock-CkgmiPOr.js";
4
+ import { g as we } from "./decimal-Dqff6QMJ.js";
5
+ import { e as Lt, u as nt, i as ot, _ as Xe } from "./PremiumBadge.vue_vue_type_script_setup_true_lang-GabOf_-7.js";
6
+ import { _ as Te, S as Be, g as st, a as zt } from "./SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-Dt1S8tTH.js";
7
+ import { _ as Yt } from "./PreviewBadge.vue_vue_type_script_setup_true_lang-CRZiQHjx.js";
8
+ import { useI18n as de, useCoreStore as at } from "@feedmepos/mf-common";
9
+ import { useSnackbar as be, useDialog as Oe, useProxiedModel as Ne, useBreakpoints as Kt } from "@feedmepos/ui-library";
10
+ import { defineStore as Gt } from "pinia";
11
+ import { u as Wt } from "./use-inventory-binding-dialog-C6Ev4777.js";
12
+ import { _ as qt } from "./NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BD2hneTA.js";
13
+ import { E as Xt } from "./empty-placeholder-wf6-BWE8.js";
14
+ import { F as lt } from "./FmAdminBadge-D4rqYlKu.js";
15
+ import "./array-Ca8T3f_G.js";
16
+ var ge = /* @__PURE__ */ ((k) => (k.History = "History", k.Convert = "Convert", k.Adjust = "Adjust", k))(ge || {});
17
+ const Jt = [
18
+ {
19
+ translationKey: "inventory.stock.action.history",
20
+ color: "text-neutral-700",
21
+ value: "History"
22
+ /* History */
23
+ }
24
+ ], Qt = [
25
+ {
26
+ translationKey: "inventory.stock.action.history",
27
+ color: "text-neutral-700",
28
+ value: "History"
29
+ /* History */
30
+ },
31
+ {
32
+ translationKey: "inventory.stock.action.convert",
33
+ color: "text-neutral-700",
34
+ value: "Convert"
35
+ /* Convert */
36
+ },
37
+ {
38
+ translationKey: "inventory.stock.action.adjust",
39
+ color: "text-neutral-700",
40
+ value: "Adjust"
41
+ /* Adjust */
42
+ }
43
+ ];
44
+ async function Zt(k) {
45
+ const c = `${(pe().currentLocation.name || "").replace(
46
+ / /g,
47
+ "_"
48
+ )}_${mt().format("DD_MM_YYYY_HHmm")}.xlsx`;
49
+ await Lt(
50
+ [
51
+ {
52
+ name: "stock",
53
+ data: k,
54
+ columns: [
55
+ {
56
+ name: "Code",
57
+ selector: "code"
58
+ },
59
+ {
60
+ name: "Name",
61
+ selector: "name"
62
+ },
63
+ {
64
+ name: "Balance",
65
+ selector: (s) => {
66
+ const $ = $e(s, s.unit);
67
+ return $.type === "unit" ? we(s.balance, s.unit, null, !1) : we(s.balance, s.unit, $.measurement, !1);
68
+ }
69
+ },
70
+ {
71
+ name: "Unit",
72
+ selector: (s) => {
73
+ var d;
74
+ const $ = $e(s, s.unit);
75
+ return $.type === "unit" ? s.unit.abbrev : ((d = s.unit.measurements.find((m) => m.id === $.measurement)) == null ? void 0 : d.abbrev) || "";
76
+ }
77
+ }
78
+ ]
79
+ }
80
+ ],
81
+ c
82
+ );
83
+ }
84
+ function $e(k, h) {
85
+ const c = localStorage.getItem(`uom:${k._id}`);
86
+ return c ? c === h._id ? {
87
+ type: "unit"
88
+ } : h.measurements.find((s) => s.id === c) ? {
89
+ type: "measurement",
90
+ measurement: c
91
+ } : {
92
+ type: "unit"
93
+ } : k.trackingMeasurement && h.measurements.find((s) => s.id === k.trackingMeasurement) ? {
94
+ type: "measurement",
95
+ measurement: k.trackingMeasurement
96
+ } : {
97
+ type: "unit"
98
+ };
99
+ }
100
+ const en = { class: "fm-typo-en-body-md-400 flex-grow" }, rt = /* @__PURE__ */ ce({
101
+ __name: "UnitDisplayControl",
102
+ props: {
103
+ unit: {},
104
+ sku: {},
105
+ amount: {},
106
+ defaultTrackingMeasurement: {}
107
+ },
108
+ setup(k) {
109
+ function h(B) {
110
+ return `uom:${B._id}`;
111
+ }
112
+ function c(B) {
113
+ const i = h(s.sku);
114
+ B ? localStorage.setItem(i, B) : localStorage.setItem(i, s.unit._id), $.value = $e(s.sku, s.unit);
115
+ }
116
+ const s = k, $ = N($e(s.sku, s.unit)), d = H(() => {
117
+ const { measurements: B } = s.unit;
118
+ return [
119
+ {
120
+ label: `${we(s.amount, s.unit)}`,
121
+ value: null
122
+ },
123
+ ...B.map(({ id: i }) => ({
124
+ label: `${we(s.amount, s.unit, i)}`,
125
+ value: i
126
+ }))
127
+ ];
128
+ });
129
+ function m({ value: B }) {
130
+ return u($).type === "unit" ? B === null : B === u($).measurement;
131
+ }
132
+ const v = H(
133
+ () => {
134
+ var B;
135
+ return ((B = d.value.find((i) => m(i))) == null ? void 0 : B.label) ?? "";
136
+ }
137
+ ), S = N(!1);
138
+ return (B, i) => {
139
+ const l = I("FmIcon"), y = I("FmMenuItem"), C = I("FmMenu");
140
+ return F(), K(C, {
141
+ "stop-click-propagation": "",
142
+ onMenuChanged: i[0] || (i[0] = (A) => S.value = A)
143
+ }, {
144
+ "menu-button": j(() => [
145
+ e("button", {
146
+ type: "button",
147
+ class: he([
148
+ "w-full text-left flex items-center gap-8 cursor-pointer fm-corner-radius-sm px-8 py-4 border bg-white",
149
+ S.value ? "border-fm-color-primary" : "border-fm-color-neutral-gray-100"
150
+ ])
151
+ }, [
152
+ e("div", en, b(v.value), 1),
153
+ g(l, {
154
+ class: "text-fm-color-neutral-gray-400",
155
+ name: "expand_more"
156
+ })
157
+ ], 2)
158
+ ]),
159
+ default: j(() => [
160
+ (F(!0), O(Z, null, ie(d.value, (A) => (F(), K(y, {
161
+ key: A.value ?? 0,
162
+ label: A.label,
163
+ "model-value": m(A),
164
+ onClick: (V) => c(A.value)
165
+ }, null, 8, ["label", "model-value", "onClick"]))), 128))
166
+ ]),
167
+ _: 1
168
+ });
169
+ };
170
+ }
171
+ }), tn = { class: "whitespace-nowrap" }, nn = /* @__PURE__ */ ce({
172
+ __name: "StockHeaderPreview",
173
+ setup(k) {
174
+ const { t: h } = de();
175
+ return (c, s) => (F(), K(Yt, null, {
176
+ default: j(() => [
177
+ e("div", tn, b(u(h)("inventory.stock.prediction.daysRemaining")), 1)
178
+ ]),
179
+ _: 1
180
+ }));
181
+ }
182
+ }), it = Gt("stockActions", () => {
183
+ const k = N(!1), h = pe(), c = Re(), s = nt(), $ = be(), d = Oe(), { t: m } = de();
184
+ async function v() {
185
+ if (h._currentLocation) {
186
+ k.value = !0;
187
+ try {
188
+ await c.readStockBalance(), await c.readProductBalance(), await s.readStockEstimateBalance();
189
+ } catch {
190
+ $.open({
191
+ title: m("inventory.stock.error.title"),
192
+ message: m("inventory.stock.error.message"),
193
+ type: "error"
194
+ });
195
+ } finally {
196
+ k.value = !1;
197
+ }
198
+ }
199
+ }
200
+ const S = N();
201
+ async function B(V) {
202
+ var M, D, E;
203
+ if (!!!((D = (M = V.convert) == null ? void 0 : M.inventoryBindings) != null && D.length)) {
204
+ d.open({
205
+ title: m("inventory.stock.error.convert.title"),
206
+ message: m("inventory.stock.error.convert.message")
207
+ });
208
+ return;
209
+ }
210
+ const w = {
211
+ maxCount: ((E = c.productBalance.find(({ id: P }) => P === V._id)) == null ? void 0 : E.count) || 0,
212
+ sku: V,
213
+ show: !0,
214
+ "onUpdate:show"(P) {
215
+ S.value.show = P;
216
+ },
217
+ onSubmitted() {
218
+ v();
219
+ }
220
+ };
221
+ S.value = w;
222
+ }
223
+ const i = N();
224
+ async function l(V) {
225
+ const n = {
226
+ stock: V,
227
+ show: !0,
228
+ "onUpdate:show"(r) {
229
+ i.value.show = r;
230
+ },
231
+ onSubmitted() {
232
+ v();
233
+ }
234
+ };
235
+ i.value = n;
236
+ }
237
+ const y = N();
238
+ async function C(V) {
239
+ const n = {
240
+ sku: V,
241
+ show: !0,
242
+ "onUpdate:show"(r) {
243
+ y.value.show = r;
244
+ }
245
+ };
246
+ y.value = n;
247
+ }
248
+ function A(V, n) {
249
+ const r = He(n);
250
+ switch (V) {
251
+ case ge.History:
252
+ C(r);
253
+ return;
254
+ case ge.Convert:
255
+ B(r);
256
+ return;
257
+ case ge.Adjust:
258
+ l(r);
259
+ return;
260
+ }
261
+ }
262
+ return {
263
+ fetchStockBalance: v,
264
+ onActionMenu: A,
265
+ stockHistoryProps: y,
266
+ showSkuHistory: C,
267
+ convertSkuDialogProps: S,
268
+ adjustSkuDialogProps: i
269
+ };
270
+ });
271
+ function on() {
272
+ const k = pe(), h = it(), { t: c } = de();
273
+ return {
274
+ columnDefs: [
275
+ {
276
+ accessorKey: "code",
277
+ header: () => c("inventory.stock.code"),
278
+ enableSorting: !0,
279
+ size: 300
280
+ },
281
+ {
282
+ accessorKey: "name",
283
+ header: () => c("inventory.stock.product"),
284
+ enableSorting: !0,
285
+ size: "auto"
286
+ },
287
+ {
288
+ id: "UOM",
289
+ header: () => c("inventory.stock.balance"),
290
+ cell($) {
291
+ const d = $.row.original, m = {
292
+ unit: d.unit,
293
+ sku: d,
294
+ amount: d.balance,
295
+ defaultTrackingMeasurement: d.trackingMeasurement ?? void 0
296
+ };
297
+ return fe(rt, m);
298
+ },
299
+ size: 180
300
+ },
301
+ {
302
+ accessorKey: "isInactive",
303
+ header: () => c("inventory.ingredient.status.title"),
304
+ cell($) {
305
+ const d = $.row.original.isInactive;
306
+ return fe(
307
+ "span",
308
+ {
309
+ class: [
310
+ "inline-block px-3 py-1 rounded-full text-xs font-semibold",
311
+ d ? "bg-red-100 text-red-700" : "bg-green-100 text-green-700"
312
+ ].join(" ")
313
+ },
314
+ c(d ? "inventory.ingredient.status.inactive" : "inventory.ingredient.status.active")
315
+ );
316
+ },
317
+ enableSorting: !0
318
+ },
319
+ {
320
+ accessorKey: "day",
321
+ id: "expireDate",
322
+ header: () => fe(nn),
323
+ enableSorting: !0,
324
+ sortUndefined: "last",
325
+ cell($) {
326
+ var i, l;
327
+ const d = $.row.original.day, m = (i = $.row.original.thresholds) == null ? void 0 : i.low, v = (l = $.row.original.thresholds) == null ? void 0 : l.mid;
328
+ if (typeof d != "number" || typeof m != "number" || typeof v != "number")
329
+ return fe(Te, {
330
+ days: d
331
+ });
332
+ const S = d <= m ? Be.low : d <= v ? Be.mid : Be.high;
333
+ return fe(Te, {
334
+ days: d,
335
+ level: S
336
+ });
337
+ },
338
+ size: 200
339
+ },
340
+ {
341
+ id: "action",
342
+ cell($) {
343
+ var d;
344
+ return pt(
345
+ ((d = k._currentLocation) == null ? void 0 : d.type) === "restaurant" ? Jt : Qt,
346
+ (m) => h.onActionMenu(m, $.row.original)
347
+ );
348
+ },
349
+ enableSorting: !1,
350
+ size: 40,
351
+ meta: {
352
+ cellClass: "",
353
+ headerClass: ""
354
+ }
355
+ }
356
+ ]
357
+ };
358
+ }
359
+ const sn = {
360
+ context: null,
361
+ error: null,
362
+ isRequired(k = "This field is required") {
363
+ return `${this.context ?? ""}`.length === 0 && (this.error = k), this;
364
+ },
365
+ isString(k = "Must be a valid string") {
366
+ return this.error ? this : (typeof this.context != "string" && (this.error ?? (this.error = k)), this);
367
+ },
368
+ toInt() {
369
+ return this.error ? this : (this.context = +this.context, this);
370
+ },
371
+ isInteger(k = "Must be an integer") {
372
+ return this.error ? this : (this.toInt(), isNaN(this.context) && (this.error = k), this);
373
+ },
374
+ min(k, h) {
375
+ if (this.error) return this;
376
+ try {
377
+ typeof this.context == "number" ? +this.context < k && (this.error = h ?? `Must be at least ${k}`) : Object.prototype.hasOwnProperty.call(this.context, "length") ? +this.context.length < k && (this.error = h ?? `Must be at least ${k}`) : this.error = "Length cannot be determined";
378
+ } catch {
379
+ this.error = "Length cannot be determined";
380
+ }
381
+ return this;
382
+ },
383
+ max(k, h) {
384
+ if (this.error) return this;
385
+ try {
386
+ typeof this.context == "number" ? +this.context > k && (this.error = h ?? `Must be at most ${k}`) : "length" in this.context ? +this.context.length > k && (this.error = h ?? `Must be at most ${k}`) : this.error = "Length cannot be determined";
387
+ } catch {
388
+ this.error = "Length cannot be determined";
389
+ }
390
+ return this;
391
+ }
392
+ };
393
+ function Je(k) {
394
+ return { ...sn, context: k };
395
+ }
396
+ const an = { class: "flex items-center" }, ln = { class: "fm-typo-en-title-md-800" }, rn = { class: "flex flex-col gap-24 w-full" }, un = { class: "flex flex-col gap-8" }, cn = { class: "fm-typo-en-body-lg-600" }, dn = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary flex-grow" }, mn = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-error" }, pn = { class: "flex flex-col p-16 gap-8" }, vn = { class: "flex flex-col gap-4" }, fn = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary bg-fm-color-neutral-gray-100 border-b py-12 px-16" }, yn = { class: "grid grid-cols-[auto_100px_100px_48px] xs:grid-cols-[auto_80px_120px_48px] gap-8 px-8 items-center" }, _n = { class: "xs:col-span-3" }, bn = { class: "flex gap-8" }, kn = /* @__PURE__ */ ce({
397
+ __name: "ConvertSkuDialog",
398
+ props: {
399
+ sku: {},
400
+ maxCount: {},
401
+ show: { type: Boolean }
402
+ },
403
+ emits: ["update:show", "submitted"],
404
+ setup(k, { expose: h, emit: c }) {
405
+ const s = k, $ = c, d = Wt(), m = Pe(), v = _e(), S = be(), { t: B } = de(), i = N(0), l = N(null), y = H(() => m.skus), C = H(
406
+ () => {
407
+ var _, t;
408
+ return (((t = (_ = s.sku) == null ? void 0 : _.convert) == null ? void 0 : t.inventoryBindings) ?? []).filter(
409
+ (o) => o.type === Ke.enum.SKU
410
+ );
411
+ }
412
+ ), A = H({
413
+ get() {
414
+ return !!l.value;
415
+ },
416
+ set(_) {
417
+ _ ? l.value = He(C.value) : (l.value = null, i.value = Math.min(i.value, s.maxCount ?? 0));
418
+ }
419
+ }), V = N(!1);
420
+ xe([() => s.show], ([_]) => {
421
+ _ && (i.value = 0);
422
+ });
423
+ function n() {
424
+ Q(s.sku, Se(i.value), l.value);
425
+ }
426
+ function r(_) {
427
+ if (l.value)
428
+ return !0;
429
+ const t = Je(_).isInteger().max(s.maxCount ?? 0).error ?? "";
430
+ return t || !0;
431
+ }
432
+ function w(_) {
433
+ var a;
434
+ const t = (a = s.sku.convert) != null && a.measurement ? s.sku.unit.measurements.find((x) => {
435
+ var U;
436
+ return x.id === ((U = s.sku.convert) == null ? void 0 : U.measurement);
437
+ }) ?? null : null, o = je(s.sku.unit, t), f = bt(+_);
438
+ return Je(f).isInteger().max(o).error ? "Precision cannot be more than " + o : !0;
439
+ }
440
+ const M = H(
441
+ () => {
442
+ var _, t;
443
+ return (_ = s.sku.convert) != null && _.measurement ? (t = s.sku.unit.measurements.find((o) => {
444
+ var f;
445
+ return o.id === ((f = s.sku.convert) == null ? void 0 : f.measurement);
446
+ })) == null ? void 0 : t.abbrev : s.sku.unit.abbrev;
447
+ }
448
+ ), D = H(() => {
449
+ var f, p;
450
+ const t = vt({
451
+ bindings: ((f = s.sku.convert) == null ? void 0 : f.inventoryBindings) ?? [],
452
+ skus: m.skus,
453
+ skuGroups: m.skuGroups,
454
+ recipes: m.recipes
455
+ }).inventoryBindings.filter((a) => "success" in a && a.success).map((a) => a).map((a) => a.binding);
456
+ return (p = l.value ?? t) == null ? void 0 : p.map((a) => {
457
+ var ae, re, q, ee, Le;
458
+ const x = m.skus.find((ve) => ve._id === a.id), U = ((ae = a.measurement) == null ? void 0 : ae.abbrev) ?? ((re = x == null ? void 0 : x.unit) == null ? void 0 : re.abbrev), z = (q = s.sku.convert) != null && q.measurement ? s.sku.unit.measurements.find((ve) => {
459
+ var ze;
460
+ return ve.id === ((ze = s.sku.convert) == null ? void 0 : ze.measurement);
461
+ }) ?? null : null, se = je(s.sku.unit, z), T = w(`${i.value}`) === !0 ? me(
462
+ ft(
463
+ a.amount,
464
+ Se(+i.value, se)
465
+ ),
466
+ !1
467
+ ) : "0", G = (Le = (ee = l.value) == null ? void 0 : ee.find((ve) => ve.id === (x == null ? void 0 : x._id))) == null ? void 0 : Le.amount, W = G ? me(G, !1) : null;
468
+ return {
469
+ sku: x,
470
+ convertAmount: W ?? T,
471
+ abbrev: U
472
+ };
473
+ });
474
+ }), E = N();
475
+ h({
476
+ validateInputs: () => {
477
+ var _, t;
478
+ (t = (_ = E.value) == null ? void 0 : _.validateInputs) == null || t.call(_);
479
+ },
480
+ resetInputsValidation: () => {
481
+ var _, t;
482
+ (t = (_ = E.value) == null ? void 0 : _.resetInputsValidation) == null || t.call(_);
483
+ },
484
+ resetInputs: () => {
485
+ var _, t;
486
+ (t = (_ = E.value) == null ? void 0 : _.resetInputs) == null || t.call(_);
487
+ }
488
+ });
489
+ const P = Ne(s, "show");
490
+ async function Q(_, t, o) {
491
+ V.value = !0;
492
+ try {
493
+ await v.convertSku({
494
+ conversions: [
495
+ {
496
+ doc: _,
497
+ amount: t,
498
+ overrides: o == null ? void 0 : o.map((f) => ({
499
+ ...f,
500
+ amount: {
501
+ ...f.amount,
502
+ amount: -1 * Math.abs(f.amount.amount)
503
+ // ensure truly negative
504
+ }
505
+ }))
506
+ }
507
+ ]
508
+ }), $("update:show", !1), $("submitted");
509
+ } catch (f) {
510
+ S.open({
511
+ title: "Something went wrong",
512
+ message: `Cannot convert ${_.name}. Please try again.`,
513
+ type: "error"
514
+ }), console.error("error at converting stock amount", _, t, f);
515
+ } finally {
516
+ V.value = !1;
517
+ }
518
+ }
519
+ function J(_, t, o) {
520
+ const f = +t;
521
+ let p = o;
522
+ t.length > 0 && isFinite(f) ? p = o.map((a) => (a.id !== _ || (a.amount = ye(f)), a)) : p = o.map((a) => (a.id !== _ || (a.amount = { amount: 0, precision: 0 }), a)), l.value = p;
523
+ }
524
+ function R(_) {
525
+ const t = y.value.find((o) => o._id === _);
526
+ return t ? st(t.unit, !0) : [];
527
+ }
528
+ function oe(_, t) {
529
+ const o = R(_), f = o.find((p) => p.value === t) ?? o.find((p) => p.value === null);
530
+ return f ? {
531
+ ...f,
532
+ label: f.abbrev
533
+ } : null;
534
+ }
535
+ function L(_, t, o) {
536
+ let f;
537
+ if (t === null)
538
+ f = o.map((p) => (p.id !== _ || (p.measurement = null), p)) ?? [];
539
+ else {
540
+ const p = y.value.find((a) => a._id === _);
541
+ f = o.map((a) => {
542
+ var x, U;
543
+ return a.id !== _ || (a.measurement = (U = (x = p == null ? void 0 : p.unit) == null ? void 0 : x.measurements) == null ? void 0 : U.find((z) => z.id === t)), a;
544
+ }) ?? [];
545
+ }
546
+ l.value = f;
547
+ }
548
+ function Y(_, t) {
549
+ const o = t.filter((f) => f.id !== _);
550
+ l.value = o;
551
+ }
552
+ function le() {
553
+ const _ = (l.value ?? []).map((t) => ({
554
+ ...t,
555
+ type: Ke.enum.SKU
556
+ }));
557
+ d.promptIngredientsBinding(
558
+ _,
559
+ (t) => l.value = t,
560
+ s.sku._id
561
+ );
562
+ }
563
+ return xe(
564
+ () => s.show,
565
+ (_) => {
566
+ _ || (l.value = null, i.value = 0);
567
+ }
568
+ ), (_, t) => {
569
+ const o = I("FmTextField"), f = I("FmForm"), p = I("FmCard"), a = I("FmSwitch"), x = I("FmFormGroup"), U = I("FmSelect"), z = I("FmButton"), se = I("FmSideSheet");
570
+ return F(), K(se, {
571
+ "dismiss-away": "",
572
+ modelValue: u(P),
573
+ "onUpdate:modelValue": t[3] || (t[3] = (T) => Ue(P) ? P.value = T : null),
574
+ "max-width": 500
575
+ }, {
576
+ "side-sheet-header": j(() => [
577
+ e("div", an, [
578
+ e("div", ln, b(u(B)("inventory.stock.convert.title", { name: _.sku.name })), 1)
579
+ ])
580
+ ]),
581
+ default: j(() => [
582
+ e("div", rn, [
583
+ g(f, {
584
+ ref_key: "formRef",
585
+ ref: E,
586
+ onValidationSuccess: n
587
+ }, {
588
+ default: j(() => [
589
+ g(o, {
590
+ disabled: V.value,
591
+ "model-value": i.value,
592
+ "onUpdate:modelValue": t[0] || (t[0] = (T) => i.value = T),
593
+ label: u(B)("inventory.stock.convert.amount"),
594
+ rules: [r, w, u(Fe)(0)],
595
+ "append-text": M.value,
596
+ "helper-text": l.value ? void 0 : `Max ${_.maxCount} ${M.value}`
597
+ }, null, 8, ["disabled", "model-value", "label", "rules", "append-text", "helper-text"])
598
+ ]),
599
+ _: 1
600
+ }, 512),
601
+ g(p, {
602
+ variant: "outlined",
603
+ class: "p-16"
604
+ }, {
605
+ default: j(() => [
606
+ e("div", un, [
607
+ e("div", cn, b(u(B)("inventory.stock.convert.deductionSummary")), 1),
608
+ (F(!0), O(Z, null, ie(D.value, (T) => {
609
+ var G, W;
610
+ return F(), O("div", {
611
+ key: (G = T.sku) == null ? void 0 : G._id,
612
+ class: "flex items-center"
613
+ }, [
614
+ e("div", dn, b((W = T.sku) == null ? void 0 : W.name), 1),
615
+ e("div", mn, " -" + b(T.convertAmount) + " " + b(T.abbrev), 1)
616
+ ]);
617
+ }), 128))
618
+ ])
619
+ ]),
620
+ _: 1
621
+ }),
622
+ g(p, { variant: "outlined" }, {
623
+ default: j(() => [
624
+ e("div", pn, [
625
+ g(a, {
626
+ value: "",
627
+ modelValue: A.value,
628
+ "onUpdate:modelValue": t[1] || (t[1] = (T) => A.value = T),
629
+ label: u(B)("inventory.stock.convert.overrideDeduction"),
630
+ "label-placement": "right"
631
+ }, null, 8, ["modelValue", "label"]),
632
+ A.value ? (F(), O(Z, { key: 0 }, [
633
+ g(x, {
634
+ modelValue: l.value,
635
+ rules: [u(yt)(1, "Must have at least one ingredient binding")]
636
+ }, null, 8, ["modelValue", "rules"]),
637
+ e("div", vn, [
638
+ e("div", fn, b(u(B)("inventory.stock.convert.ingredients")), 1),
639
+ (F(!0), O(Z, null, ie(l.value, (T) => (F(), K(x, {
640
+ key: T.id,
641
+ disabled: V.value,
642
+ modelValue: +u(me)(T.amount ?? { amount: 1, precision: 0 }),
643
+ rules: [
644
+ u(_t)(
645
+ y.value.find((G) => G._id === T.id).unit,
646
+ T.measurement
647
+ ),
648
+ u(Fe)(0)
649
+ ]
650
+ }, {
651
+ default: j(({ invalid: G }) => {
652
+ var W, ae, re;
653
+ return [
654
+ e("div", yn, [
655
+ e("div", _n, b((W = y.value.find((q) => q._id === T.id)) == null ? void 0 : W.name), 1),
656
+ g(o, {
657
+ class: "xs:col-span-2",
658
+ disabled: V.value,
659
+ modelValue: +u(me)(
660
+ T.amount ?? { amount: 1, precision: 0 }
661
+ ),
662
+ "onUpdate:modelValue": (q) => J(T.id, q, l.value ?? []),
663
+ invalid: G
664
+ }, null, 8, ["disabled", "modelValue", "onUpdate:modelValue", "invalid"]),
665
+ g(U, {
666
+ disabled: V.value,
667
+ class: "translate-y-[2px]",
668
+ items: R(T.id),
669
+ "model-value": (re = oe(T.id, (ae = T.measurement) == null ? void 0 : ae.id)) == null ? void 0 : re.value,
670
+ "onUpdate:modelValue": (q) => L(T.id, q, l.value ?? []),
671
+ invalid: G
672
+ }, {
673
+ "helper-text": j(() => t[4] || (t[4] = [])),
674
+ _: 2
675
+ }, 1032, ["disabled", "items", "model-value", "onUpdate:modelValue", "invalid"]),
676
+ g(z, {
677
+ disabled: V.value,
678
+ type: "button",
679
+ variant: "tertiary",
680
+ icon: "delete",
681
+ onClick: (q) => Y(T.id, l.value ?? [])
682
+ }, null, 8, ["disabled", "onClick"])
683
+ ])
684
+ ];
685
+ }),
686
+ _: 2
687
+ }, 1032, ["disabled", "modelValue", "rules"]))), 128))
688
+ ]),
689
+ e("div", null, [
690
+ g(z, {
691
+ icon: "link",
692
+ label: u(B)("inventory.stock.convert.linkIngredient"),
693
+ variant: "plain",
694
+ onClick: le
695
+ }, null, 8, ["label"])
696
+ ])
697
+ ], 64)) : te("", !0)
698
+ ])
699
+ ]),
700
+ _: 1
701
+ })
702
+ ])
703
+ ]),
704
+ "side-sheet-footer": j(() => [
705
+ e("div", bn, [
706
+ g(z, {
707
+ loading: V.value,
708
+ label: u(B)("inventory.stock.convert.convertButton"),
709
+ onClick: t[2] || (t[2] = (T) => {
710
+ var G, W;
711
+ return (W = (G = E.value) == null ? void 0 : G.validateInputs) == null ? void 0 : W.call(G);
712
+ })
713
+ }, null, 8, ["loading", "label"])
714
+ ])
715
+ ]),
716
+ _: 1
717
+ }, 8, ["modelValue"]);
718
+ };
719
+ }
720
+ });
721
+ function De(k, h) {
722
+ const c = Se(k, h);
723
+ return { ...c, amount: -c.amount };
724
+ }
725
+ function Qe(k, h) {
726
+ return Se(Math.abs(k), h);
727
+ }
728
+ const Ie = {
729
+ [ne.enum.DAMAGE]: {
730
+ label: "Waste",
731
+ toAdjustmentAmount: De
732
+ },
733
+ [ne.enum.THEFT]: {
734
+ label: "Theft",
735
+ toAdjustmentAmount: De
736
+ },
737
+ [ne.enum.LOSE]: {
738
+ label: "Lose",
739
+ toAdjustmentAmount: De
740
+ },
741
+ [ne.enum.EXTRA]: {
742
+ label: "Extra",
743
+ toAdjustmentAmount: Qe
744
+ },
745
+ [ne.enum.PURCHASE]: {
746
+ label: "Purchase",
747
+ toAdjustmentAmount: Qe
748
+ }
749
+ }, gn = { class: "col-span-2 flex" }, hn = { class: "fm-typo-en-body-lg-600 flex-1" }, xn = /* @__PURE__ */ ce({
750
+ __name: "AdjustedItemForm",
751
+ props: {
752
+ modelValue: {},
753
+ disabled: { type: Boolean }
754
+ },
755
+ emits: ["update:modelValue", "click:delete"],
756
+ setup(k, { emit: h }) {
757
+ const c = k, s = h, $ = H(
758
+ () => Object.keys(Ie).map((i) => ({
759
+ label: kt(i),
760
+ value: i
761
+ }))
762
+ ), d = H(() => st(c.modelValue.doc.unit, !0)), m = H({
763
+ get() {
764
+ return c.modelValue.type ?? ne.enum.PURCHASE;
765
+ },
766
+ set(i) {
767
+ const l = {
768
+ ...c.modelValue
769
+ };
770
+ l.type = i;
771
+ const y = Ge(c.modelValue.amount);
772
+ l.amount = Ie[l.type].toAdjustmentAmount(
773
+ +me(y),
774
+ y.precision
775
+ ), s("update:modelValue", l);
776
+ }
777
+ }), v = H({
778
+ get() {
779
+ const i = Ge(c.modelValue.amount);
780
+ return +me(i);
781
+ },
782
+ set(i) {
783
+ const l = {
784
+ ...c.modelValue
785
+ }, y = ye(i);
786
+ l.amount = Ie[m.value].toAdjustmentAmount(
787
+ i,
788
+ y.precision
789
+ ), s("update:modelValue", l);
790
+ }
791
+ }), S = H({
792
+ get() {
793
+ var i;
794
+ return ((i = c.modelValue.measurement) == null ? void 0 : i.id) ?? null;
795
+ },
796
+ set(i) {
797
+ var y, C;
798
+ const l = {
799
+ ...c.modelValue
800
+ };
801
+ l.measurement = ((C = (y = c.modelValue.doc.unit) == null ? void 0 : y.measurements) == null ? void 0 : C.find((A) => A.id === i)) ?? null, s("update:modelValue", l);
802
+ }
803
+ }), B = H({
804
+ get() {
805
+ return c.modelValue.remark ?? "";
806
+ },
807
+ set(i) {
808
+ const l = {
809
+ ...c.modelValue
810
+ };
811
+ l.remark = i, s("update:modelValue", l);
812
+ }
813
+ });
814
+ return (i, l) => {
815
+ const y = I("FmButton"), C = I("FmSelect"), A = I("FmTextarea"), V = I("FmCard");
816
+ return F(), K(V, {
817
+ variant: "outlined",
818
+ class: "grid grid-cols-2 gap-8 p-16"
819
+ }, {
820
+ default: j(() => [
821
+ e("div", gn, [
822
+ e("div", hn, b(i.modelValue.doc.name), 1),
823
+ g(y, {
824
+ variant: "tertiary",
825
+ "prepend-icon": "delete",
826
+ onClick: l[0] || (l[0] = (n) => s("click:delete"))
827
+ })
828
+ ]),
829
+ g(C, {
830
+ disabled: i.disabled,
831
+ class: "col-span-2",
832
+ label: "Type",
833
+ items: $.value,
834
+ modelValue: m.value,
835
+ "onUpdate:modelValue": l[1] || (l[1] = (n) => m.value = n),
836
+ rules: [u(gt)()],
837
+ "label-mark": "required"
838
+ }, null, 8, ["disabled", "items", "modelValue", "rules"]),
839
+ g(qt, {
840
+ disabled: i.disabled,
841
+ label: "Amount",
842
+ step: +u(me)({
843
+ amount: 1,
844
+ precision: u(je)(i.modelValue.doc.unit, i.modelValue.measurement)
845
+ }),
846
+ modelValue: v.value,
847
+ "onUpdate:modelValue": l[2] || (l[2] = (n) => v.value = n),
848
+ rules: [u(Fe)(0)]
849
+ }, null, 8, ["disabled", "step", "modelValue", "rules"]),
850
+ g(C, {
851
+ disabled: i.disabled,
852
+ label: "Unit",
853
+ items: d.value,
854
+ modelValue: S.value,
855
+ "onUpdate:modelValue": l[3] || (l[3] = (n) => S.value = n)
856
+ }, null, 8, ["disabled", "items", "modelValue"]),
857
+ g(A, {
858
+ class: "col-span-2",
859
+ disabled: i.disabled,
860
+ label: "Remark",
861
+ modelValue: B.value,
862
+ "onUpdate:modelValue": l[4] || (l[4] = (n) => B.value = n),
863
+ "label-mark": "optional"
864
+ }, null, 8, ["disabled", "modelValue"])
865
+ ]),
866
+ _: 1
867
+ });
868
+ };
869
+ }
870
+ }), Sn = { class: "flex items-center" }, Fn = { class: "fm-typo-en-title-md-800" }, wn = { class: "flex items-center" }, $n = { class: "fm-typo-en-title-sm-800 flex-1" }, An = { class: "flex gap-8" }, Vn = /* @__PURE__ */ ce({
871
+ __name: "AdjustSkuDialog",
872
+ props: {
873
+ stock: {},
874
+ show: { type: Boolean }
875
+ },
876
+ emits: ["update:show", "submitted"],
877
+ setup(k, { expose: h, emit: c }) {
878
+ const s = k, $ = c, d = Pe(), m = Oe(), v = _e(), S = be(), B = N(!1), { t: i } = de();
879
+ function l() {
880
+ V(He(A));
881
+ }
882
+ const y = N();
883
+ h({
884
+ validateInputs: () => {
885
+ var w, M;
886
+ (M = (w = y.value) == null ? void 0 : w.validateInputs) == null || M.call(w);
887
+ },
888
+ resetInputsValidation: () => {
889
+ var w, M;
890
+ (M = (w = y.value) == null ? void 0 : w.resetInputsValidation) == null || M.call(w);
891
+ },
892
+ resetInputs: () => {
893
+ var w, M;
894
+ (M = (w = y.value) == null ? void 0 : w.resetInputs) == null || M.call(w);
895
+ }
896
+ });
897
+ const C = Ne(s, "show"), A = ut({
898
+ remark: "",
899
+ adjustments: [
900
+ {
901
+ id: `sku_${(/* @__PURE__ */ new Date()).toISOString()}_${Math.random().toString(16).slice(2, 8)}`,
902
+ type: ne.enum.PURCHASE,
903
+ doc: s.stock,
904
+ measurement: null,
905
+ remark: "",
906
+ amount: ye(1)
907
+ }
908
+ ]
909
+ });
910
+ xe([() => s.show], ([w]) => {
911
+ w && (A.remark = "", A.adjustments = [
912
+ {
913
+ id: `sku_${(/* @__PURE__ */ new Date()).toISOString()}_${Math.random().toString(16).slice(2, 8)}`,
914
+ type: ne.enum.PURCHASE,
915
+ doc: s.stock,
916
+ measurement: null,
917
+ remark: "",
918
+ amount: ye(1)
919
+ }
920
+ ]);
921
+ });
922
+ async function V(w) {
923
+ B.value = !0;
924
+ try {
925
+ await v.adjustSku({
926
+ remark: w.remark,
927
+ adjustments: w.adjustments.map(({ doc: M, remark: D, type: E, amount: P, measurement: Q }) => ({
928
+ id: M._id,
929
+ amount: P,
930
+ measurement: Q,
931
+ remark: D,
932
+ doc: M,
933
+ type: E
934
+ }))
935
+ }), $("update:show", !1), $("submitted");
936
+ } catch (M) {
937
+ S.open({
938
+ title: i("inventory.stock.adjust.error.title"),
939
+ message: i("inventory.stock.adjust.error.message"),
940
+ type: "error"
941
+ }), console.log("error on adjust ingredients", w, M);
942
+ } finally {
943
+ B.value = !1;
944
+ }
945
+ }
946
+ function n() {
947
+ const w = d.skus.map((D) => ({
948
+ label: D.name,
949
+ sublabel: D.code,
950
+ value: D._id
951
+ })), M = w.filter((D) => A.adjustments.find((E) => E.doc._id === D.value)).map((D) => D.value);
952
+ m.open({
953
+ title: "Select ingredients",
954
+ contentComponent: ht,
955
+ contentComponentProps: {
956
+ items: w,
957
+ modelValue: M
958
+ },
959
+ overlay: !0,
960
+ closeButton: !0,
961
+ dismissAway: !0,
962
+ primaryActions: {
963
+ text: "Confirm",
964
+ close: !0
965
+ },
966
+ secondaryActions: {
967
+ text: "Close",
968
+ close: !0,
969
+ variant: "tertiary"
970
+ }
971
+ }).onPrimary((D) => {
972
+ A.adjustments = D.map(
973
+ (E) => A.adjustments.find((P) => P.doc._id === E) ?? {
974
+ id: `sku_${(/* @__PURE__ */ new Date()).toISOString()}_${Math.random().toString(16).slice(2, 8)}`,
975
+ type: ne.enum.PURCHASE,
976
+ doc: d.skus.find((P) => P._id === E),
977
+ measurement: null,
978
+ remark: "",
979
+ amount: ye(1)
980
+ }
981
+ );
982
+ });
983
+ }
984
+ function r(w) {
985
+ A.adjustments.splice(w, 1);
986
+ }
987
+ return (w, M) => {
988
+ const D = I("FmTextarea"), E = I("FmButton"), P = I("FmForm"), Q = I("FmSideSheet");
989
+ return F(), K(Q, {
990
+ modelValue: u(C),
991
+ "onUpdate:modelValue": M[2] || (M[2] = (J) => Ue(C) ? C.value = J : null),
992
+ "dismiss-away": "",
993
+ "max-width": 500
994
+ }, {
995
+ "side-sheet-header": j(() => [
996
+ e("div", Sn, [
997
+ e("div", Fn, b(u(i)("inventory.stock.adjust.title")), 1)
998
+ ])
999
+ ]),
1000
+ default: j(() => [
1001
+ g(P, {
1002
+ class: "w-full flex flex-col gap-12",
1003
+ ref_key: "formRef",
1004
+ ref: y,
1005
+ onValidationSuccess: l
1006
+ }, {
1007
+ default: j(() => [
1008
+ g(D, {
1009
+ label: u(i)("inventory.stock.adjust.remark"),
1010
+ modelValue: A.remark,
1011
+ "onUpdate:modelValue": M[0] || (M[0] = (J) => A.remark = J)
1012
+ }, null, 8, ["label", "modelValue"]),
1013
+ e("div", wn, [
1014
+ e("div", $n, b(u(i)("inventory.stock.adjust.adjustedItems")), 1),
1015
+ g(E, {
1016
+ "prepend-icon": "add",
1017
+ variant: "tertiary",
1018
+ size: "md",
1019
+ onClick: n
1020
+ })
1021
+ ]),
1022
+ (F(!0), O(Z, null, ie(A.adjustments, (J, R) => (F(), K(xn, {
1023
+ key: J.id,
1024
+ modelValue: A.adjustments[R],
1025
+ "onUpdate:modelValue": (oe) => A.adjustments[R] = oe,
1026
+ "onClick:delete": (oe) => r(R)
1027
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onClick:delete"]))), 128))
1028
+ ]),
1029
+ _: 1
1030
+ }, 512)
1031
+ ]),
1032
+ "side-sheet-footer": j(() => [
1033
+ e("div", An, [
1034
+ g(E, {
1035
+ label: u(i)("inventory.stock.adjust.adjustButton"),
1036
+ loading: B.value,
1037
+ onClick: M[1] || (M[1] = (J) => {
1038
+ var R, oe;
1039
+ return (oe = (R = y.value) == null ? void 0 : R.validateInputs) == null ? void 0 : oe.call(R);
1040
+ })
1041
+ }, null, 8, ["label", "loading"])
1042
+ ])
1043
+ ]),
1044
+ _: 1
1045
+ }, 8, ["modelValue"]);
1046
+ };
1047
+ }
1048
+ }), Cn = xt((k, h) => ({
1049
+ // TODO: remove once latest inventory backend has been push
1050
+ async findBillsByBusinessId(c, s, $) {
1051
+ const d = `${k.businessesBackendUrl}/${c}/reports/find-many`, m = {
1052
+ // type: TYPE.bill,
1053
+ type: "bill",
1054
+ restaurantIds: s,
1055
+ ids: $
1056
+ };
1057
+ return await h.post(d, m);
1058
+ },
1059
+ async findBillsById(c) {
1060
+ const $ = pe().currentLocationDBName, d = `${k.inventoryBackendUrl}/${$}/bill/search`, m = {
1061
+ ids: c
1062
+ };
1063
+ return await h.post(d, m);
1064
+ }
1065
+ })), Mn = {
1066
+ key: 0,
1067
+ class: "flex justify-center items-center h-32"
1068
+ }, Bn = { class: "mb-3" }, Dn = { class: "flex flex-col gap-8" }, In = { class: "flex flex-col text-fm-color-typo-primary mb-3 text-center" }, jn = { class: "text-fm-color-neutral-gray-400 fm-typo-en-body-sm-600" }, Tn = { class: "flex flex-col gap-4 text-fm-color-typo-primary mb-3" }, Un = { class: "flex flex-col gap-4 text-fm-color-typo-primary mb-3" }, En = { class: "flex flex-col gap-4 text-fm-color-typo-primary mb-3" }, Hn = { class: "flex flex-col w-full px-2" }, Pn = { class: "flex gap-2" }, Rn = /* @__PURE__ */ ce({
1069
+ __name: "AmendAdjustmentForm",
1070
+ props: /* @__PURE__ */ Ye({
1071
+ adjustmentId: {}
1072
+ }, {
1073
+ modelValue: {},
1074
+ modelModifiers: {}
1075
+ }),
1076
+ emits: /* @__PURE__ */ Ye(["refreshHistory"], ["update:modelValue"]),
1077
+ setup(k, { emit: h }) {
1078
+ const c = k, s = h, $ = _e(), d = ct(k, "modelValue"), m = N(!1), v = N(!1), S = N(!1), B = N({
1079
+ _id: `inventoryAdjustment_${(/* @__PURE__ */ new Date()).toISOString()}_XXXXX`,
1080
+ skus: []
1081
+ }), i = N();
1082
+ Ee(async () => {
1083
+ m.value = !0;
1084
+ const n = await $.readSingleAdjustment(c.adjustmentId);
1085
+ if (!n) throw new Error("Adjustment not found");
1086
+ B.value = n, m.value = !1;
1087
+ });
1088
+ async function l() {
1089
+ var r, w;
1090
+ if ((w = (r = i == null ? void 0 : i.value) == null ? void 0 : r.validateInputs) == null || w.call(r), !v.value) return;
1091
+ const n = {};
1092
+ Object.keys(d.value || {}).forEach((M) => {
1093
+ var D;
1094
+ Object.keys(((D = d.value) == null ? void 0 : D[M]) || {}).forEach((E) => {
1095
+ var Q, J;
1096
+ const P = (J = (Q = d.value) == null ? void 0 : Q[M]) == null ? void 0 : J[Number(E)];
1097
+ P && C(P.amount) > 0 && (n[M] || (n[M] = []), n[M].push(P));
1098
+ });
1099
+ }), await $.revertWastageAdjustment({
1100
+ targetWastageAdjustmentId: c.adjustmentId,
1101
+ amountsGoingToAdjust: n
1102
+ }), s("refreshHistory"), S.value = !1, d.value = {};
1103
+ }
1104
+ function y(n, r, w) {
1105
+ return H({
1106
+ get: () => {
1107
+ var D, E, P;
1108
+ const M = (P = (E = (D = d.value) == null ? void 0 : D[n]) == null ? void 0 : E[r]) == null ? void 0 : P.amount;
1109
+ return M ? C(M, !0) : 0;
1110
+ },
1111
+ set: (M) => {
1112
+ d.value || (d.value = {});
1113
+ const D = { ...d.value };
1114
+ D[n] || (D[n] = {}), D[n][r] = {
1115
+ amount: Ce.fromNumber(M),
1116
+ type: ne.Enum.WASTAGE,
1117
+ measurement: w
1118
+ }, d.value = D;
1119
+ }
1120
+ });
1121
+ }
1122
+ function C(n, r = !0) {
1123
+ const w = Number(Ce.toFormatString({ value: n }));
1124
+ return r ? Math.abs(w) : w;
1125
+ }
1126
+ function A(n, r) {
1127
+ return r.measurement ? r.measurement.abbrev : n.sku.unit.abbrev;
1128
+ }
1129
+ function V(n, r) {
1130
+ return r === 0 ? "N/A" : (n + r).toString();
1131
+ }
1132
+ return (n, r) => {
1133
+ const w = I("FmIcon"), M = I("FmStepperField"), D = I("FmCard"), E = I("FmForm"), P = I("FmSpacer"), Q = I("FmButton"), J = I("FmDialog");
1134
+ return F(), K(J, {
1135
+ modelValue: S.value,
1136
+ "onUpdate:modelValue": r[4] || (r[4] = (R) => S.value = R),
1137
+ overlay: !0
1138
+ }, {
1139
+ "dialog-button": j(() => [
1140
+ g(lt, null, {
1141
+ default: j(() => [
1142
+ e("button", {
1143
+ onClick: r[0] || (r[0] = (R) => S.value = !0),
1144
+ class: "rounded-md hover:bg-gray-100 transition-colors"
1145
+ }, [
1146
+ g(w, {
1147
+ name: "edit",
1148
+ size: "sm"
1149
+ })
1150
+ ])
1151
+ ]),
1152
+ _: 1
1153
+ })
1154
+ ]),
1155
+ "dialog-header": j(() => r[5] || (r[5] = [
1156
+ e("div", null, "Amend Adjustment", -1)
1157
+ ])),
1158
+ "dialog-footer": j(() => [
1159
+ e("div", Hn, [
1160
+ r[13] || (r[13] = e("span", { class: "text-fm-color-system-warning-400 fm-typo-en-body-sm-400" }, "1. New adjustment EXTRA will be created for each reversal", -1)),
1161
+ e("div", Pn, [
1162
+ g(P),
1163
+ g(Q, {
1164
+ class: "sm:w-full xs:w-full",
1165
+ label: "Close",
1166
+ size: "md",
1167
+ variant: "tertiary",
1168
+ onClick: r[3] || (r[3] = (R) => S.value = !1)
1169
+ }),
1170
+ g(Q, {
1171
+ class: "sm:w-full xs:w-full",
1172
+ label: "Submit",
1173
+ size: "md",
1174
+ variant: "primary",
1175
+ onClick: l
1176
+ })
1177
+ ])
1178
+ ])
1179
+ ]),
1180
+ default: j(() => [
1181
+ m.value ? (F(), O("div", Mn)) : (F(), K(E, {
1182
+ key: 1,
1183
+ ref_key: "formRef",
1184
+ ref: i,
1185
+ onValidationFailed: r[1] || (r[1] = () => {
1186
+ v.value = !1;
1187
+ }),
1188
+ onValidationSuccess: r[2] || (r[2] = () => {
1189
+ v.value = !0;
1190
+ }),
1191
+ blameFormChildOnValidationFailed: ""
1192
+ }, {
1193
+ default: j(() => [
1194
+ e("p", Bn, [
1195
+ r[6] || (r[6] = e("b", null, "Date:", -1)),
1196
+ r[7] || (r[7] = e("br", null, null, -1)),
1197
+ ue(" " + b(u(St)(u(Ft)(B.value._id))), 1)
1198
+ ]),
1199
+ e("div", Dn, [
1200
+ (F(!0), O(Z, null, ie(B.value.skus, (R, oe) => (F(), O(Z, { key: oe }, [
1201
+ (F(!0), O(Z, null, ie(R.amounts, (L, Y) => (F(), K(D, {
1202
+ key: Y,
1203
+ variant: "outlined",
1204
+ class: "p-2"
1205
+ }, {
1206
+ default: j(() => [
1207
+ e("div", In, [
1208
+ e("span", jn, b(R.sku.code), 1),
1209
+ e("span", null, b(R.sku.name), 1)
1210
+ ]),
1211
+ r[12] || (r[12] = e("hr", { class: "m-2" }, null, -1)),
1212
+ e("div", Tn, [
1213
+ r[8] || (r[8] = e("span", { class: "fm-typo-en-body-lg-600" }, "Adjustment type:", -1)),
1214
+ e("span", null, b(L.type), 1)
1215
+ ]),
1216
+ e("div", Un, [
1217
+ r[9] || (r[9] = e("span", { class: "fm-typo-en-body-lg-600" }, "Current amount:", -1)),
1218
+ e("span", null, b(u(Ce).toFormatString({ value: L.amount })) + " " + b(A(R, L)), 1)
1219
+ ]),
1220
+ g(M, {
1221
+ "model-value": y(R.sku._id, Y).value,
1222
+ "onUpdate:modelValue": (le) => y(R.sku._id, Y).value = le,
1223
+ class: "mb-3",
1224
+ label: "Adjust Amount (Leave 0 to skip)",
1225
+ "helper-text": `Max: ${C(L.amount)}`,
1226
+ "append-text": A(R, L),
1227
+ rules: [
1228
+ (le) => le <= C(L.amount) || `Cannot be more than ${C(L.amount)}`,
1229
+ u(Fe)(-1)
1230
+ ]
1231
+ }, null, 8, ["model-value", "onUpdate:modelValue", "helper-text", "append-text", "rules"]),
1232
+ e("div", En, [
1233
+ r[10] || (r[10] = e("span", { class: "fm-typo-en-body-lg-600" }, "Amount after amend:", -1)),
1234
+ r[11] || (r[11] = e("span", { class: "text-fm-color-system-warning-400 fm-typo-en-body-sm-400" }, "* It's an estimate for your reference, as it didn't include all the reversals related to this adjustment", -1)),
1235
+ ue(" " + b(V(
1236
+ C(L.amount, !1),
1237
+ y(R.sku._id, Y).value
1238
+ )) + " " + b(A(R, L)), 1)
1239
+ ])
1240
+ ]),
1241
+ _: 2
1242
+ }, 1024))), 128))
1243
+ ], 64))), 128))
1244
+ ])
1245
+ ]),
1246
+ _: 1
1247
+ }, 512))
1248
+ ]),
1249
+ _: 1
1250
+ }, 8, ["modelValue"]);
1251
+ };
1252
+ }
1253
+ }), On = { class: "p-16" }, Nn = { class: "fm-typo-en-body-md-600 flex-grow" }, Ln = { class: "flex-grow text-fm-color-typo-secondary" }, zn = {
1254
+ key: 0,
1255
+ class: "my-5"
1256
+ }, Yn = { class: "text-neutral-400" }, Kn = { class: "flex-grow" }, Gn = { class: "flex gap-1" }, Wn = { class: "flex flex-col gap-1" }, qn = {
1257
+ key: 1,
1258
+ class: "t-system text-fsecondary"
1259
+ }, Xn = {
1260
+ key: 2,
1261
+ class: "inline-flex items-center rounded-md bg-yellow-400/10 px-2 text-xs font-medium text-yellow-500 inset-ring inset-ring-yellow-400/20"
1262
+ }, Jn = {
1263
+ key: 1,
1264
+ class: "shrink-0 text-fm-color-typo-secondary"
1265
+ }, Qn = /* @__PURE__ */ ce({
1266
+ __name: "StockRecordCard",
1267
+ props: {
1268
+ record: {},
1269
+ sku: {},
1270
+ bills: { default: () => [] }
1271
+ },
1272
+ emits: ["refreshHistory"],
1273
+ setup(k, { emit: h }) {
1274
+ const c = k, s = N(!1);
1275
+ at();
1276
+ const $ = N(), d = N(null), m = H(() => d.value === null ? "unset" : s.value ? `${d.value}px` : "0px");
1277
+ Ee(() => {
1278
+ var i;
1279
+ d.value = ((i = $.value) == null ? void 0 : i.scrollHeight) || 0;
1280
+ });
1281
+ const v = H(() => {
1282
+ var V;
1283
+ const i = c.record.adjustments, l = c.sku, y = {}, A = i.flatMap((n) => {
1284
+ var r;
1285
+ return ((r = n.skus) == null ? void 0 : r.filter((w) => w.sku._id === l._id)) ?? [];
1286
+ }).flatMap((n) => n.amounts);
1287
+ for (const n of A) {
1288
+ const r = n.measurement ? wt(n.measurement.conversion, n.amount) : n.amount;
1289
+ y[V = n.type] ?? (y[V] = { amount: 0, precision: 0 }), y[n.type] = et(r, y[n.type]);
1290
+ }
1291
+ return Object.entries(y).reduce(
1292
+ (n, [r, w]) => (n[r] = /// comment, because without it formatter makes code uglier
1293
+ `${X.toFormatString({
1294
+ value: w,
1295
+ precision: 4
1296
+ })} ${l.unit.abbrev}`, n),
1297
+ {}
1298
+ );
1299
+ }), { t: S } = de(), B = H(() => c.record.adjustmentsByTime.map(({ date: i, adjustments: l }) => ({
1300
+ time: $t(new Date(i)),
1301
+ adjustments: l.flatMap(
1302
+ (y) => {
1303
+ var C, A;
1304
+ return ((A = (C = y.skus) == null ? void 0 : C.map) == null ? void 0 : A.call(C, (V) => {
1305
+ var n, r;
1306
+ return {
1307
+ ...V,
1308
+ ref: y.ref,
1309
+ backdateFrom: y.effectiveAt != null ? ot(y._id) : null,
1310
+ toBalance: (r = (n = y.skus) == null ? void 0 : n[0]) == null ? void 0 : r.toBalance,
1311
+ adjustmentId: y._id
1312
+ };
1313
+ })) ?? [];
1314
+ }
1315
+ ).flatMap((y) => {
1316
+ var V;
1317
+ const C = (V = c.bills.find((n) => n._id === y.ref)) == null ? void 0 : V.seqNumber, A = C ? S("inventory.stock.record.bill", [C]) : "";
1318
+ return y.amounts.map((n) => {
1319
+ var r;
1320
+ return {
1321
+ amount: `${X.toFormatString({ value: n.amount, precision: 4 })} ${((r = n.measurement) == null ? void 0 : r.abbrev) ?? y.sku.unit.abbrev}`,
1322
+ backdateFrom: y.backdateFrom,
1323
+ name: n.type,
1324
+ remark: n.remark || A || "",
1325
+ cost: n.cost,
1326
+ toBalance: X.toFormatString({
1327
+ value: y.toBalance ?? X.fromNumber(0),
1328
+ precision: 4
1329
+ }),
1330
+ baseUnit: y.sku.unit.abbrev,
1331
+ adjustmentId: y.adjustmentId
1332
+ };
1333
+ });
1334
+ })
1335
+ })));
1336
+ return (i, l) => {
1337
+ const y = I("FmIcon"), C = I("FmTooltip"), A = I("FmCard");
1338
+ return F(), K(A, { variant: "outlined" }, {
1339
+ default: j(() => [
1340
+ e("div", On, [
1341
+ e("div", {
1342
+ class: "flex items-center cursor-pointer mb-1",
1343
+ onClick: l[0] || (l[0] = (V) => s.value = !s.value)
1344
+ }, [
1345
+ e("div", Nn, b(i.record.date), 1),
1346
+ g(y, {
1347
+ name: s.value ? "expand_more" : "expand_less",
1348
+ color: "#777777",
1349
+ size: "md"
1350
+ }, null, 8, ["name"])
1351
+ ]),
1352
+ (F(!0), O(Z, null, ie(v.value, (V, n) => (F(), O("div", {
1353
+ key: n,
1354
+ class: "flex flex-row py-1",
1355
+ style: { "font-size": "0.8rem" }
1356
+ }, [
1357
+ e("div", Ln, b(u(S)(`inventory.inventoryAdjustment.type.${n}`)), 1),
1358
+ e("div", {
1359
+ class: he({
1360
+ "text-fm-color-typo-error": V.startsWith("-"),
1361
+ "text-fm-color-typo-success": !V.startsWith("-"),
1362
+ "ml-auto": !0
1363
+ })
1364
+ }, b(V), 3)
1365
+ ]))), 128)),
1366
+ e("div", {
1367
+ ref_key: "detailRef",
1368
+ ref: $,
1369
+ style: Ze({
1370
+ fontSize: "0.8rem",
1371
+ maxHeight: m.value,
1372
+ overflow: "hidden",
1373
+ transition: "max-height 0.2s ease-out"
1374
+ })
1375
+ }, [
1376
+ B.value.length ? (F(), O("hr", zn)) : te("", !0),
1377
+ (F(!0), O(Z, null, ie(B.value, (V) => (F(), O("div", {
1378
+ key: V.time,
1379
+ class: "flex gap-1 w-full"
1380
+ }, [
1381
+ e("div", Yn, b(V.time), 1),
1382
+ e("div", Kn, [
1383
+ (F(!0), O(Z, null, ie(V.adjustments, (n) => (F(), O("div", {
1384
+ key: n.name,
1385
+ class: "flex gap-1"
1386
+ }, [
1387
+ e("div", Gn, [
1388
+ ue(b(u(S)(`inventory.inventoryAdjustment.type.${n.name}`)) + " ", 1),
1389
+ n.backdateFrom ? (F(), K(C, {
1390
+ key: 0,
1391
+ variant: "plain",
1392
+ placement: "top",
1393
+ "z-index": 50
1394
+ }, {
1395
+ content: j(() => [
1396
+ e("div", Wn, b(u(S)("inventory.stock.record.backdate", [
1397
+ u(tt)(new Date(n.backdateFrom))
1398
+ ])), 1)
1399
+ ]),
1400
+ default: j(() => [
1401
+ g(y, {
1402
+ name: "info",
1403
+ size: "sm",
1404
+ color: "primary"
1405
+ })
1406
+ ]),
1407
+ _: 2
1408
+ }, 1024)) : te("", !0),
1409
+ n.remark ? (F(), O("span", qn, " # " + b(n.remark), 1)) : te("", !0),
1410
+ n.name === u(ne).Enum.CLOSING ? (F(), O("span", Xn, " Actual Balance: " + b(n.toBalance) + " " + b(n.baseUnit), 1)) : te("", !0)
1411
+ ]),
1412
+ e("div", {
1413
+ class: he({
1414
+ "text-fm-color-typo-error": n.amount.startsWith("-"),
1415
+ "text-fm-color-typo-success": !n.amount.startsWith("-"),
1416
+ "ml-auto": !0
1417
+ })
1418
+ }, b(n.amount), 3),
1419
+ n.name === u(ne).Enum.WASTAGE ? (F(), K(Rn, {
1420
+ key: 0,
1421
+ adjustmentId: n.adjustmentId,
1422
+ onRefreshHistory: l[1] || (l[1] = (r) => i.$emit("refreshHistory"))
1423
+ }, null, 8, ["adjustmentId"])) : te("", !0),
1424
+ n.cost ? (F(), O("div", Jn, " (" + b(u(ke)(n.cost, !1, n.cost.precision)) + ") ", 1)) : te("", !0)
1425
+ ]))), 128))
1426
+ ])
1427
+ ]))), 128))
1428
+ ], 4)
1429
+ ])
1430
+ ]),
1431
+ _: 1
1432
+ });
1433
+ };
1434
+ }
1435
+ });
1436
+ function Zn(k, h) {
1437
+ var d;
1438
+ const c = Object.keys(ne.enum).reduce(
1439
+ (m, v) => (m[v] = { amount: 0, precision: 0 }, m),
1440
+ {}
1441
+ );
1442
+ if (!h)
1443
+ return Object.entries(c).reduce(
1444
+ (m, [v]) => (m[v] = X.fromNumber(0), m),
1445
+ {}
1446
+ );
1447
+ const $ = k.flatMap((m) => {
1448
+ var v;
1449
+ return ((v = m.skus) == null ? void 0 : v.filter((S) => S.sku._id === h._id)) ?? [];
1450
+ }).flatMap((m) => m.amounts);
1451
+ for (const m of $) {
1452
+ const v = m.measurement ? X.multiply([m.measurement.conversion, m.amount]) : m.amount;
1453
+ c[d = m.type] ?? (c[d] = { amount: 0, precision: 0 }), c[m.type] = X.add([v, c[m.type]]);
1454
+ }
1455
+ return Object.entries(c).reduce(
1456
+ (m, [v, S]) => {
1457
+ const B = {
1458
+ ...S,
1459
+ amount: Math.abs(S.amount)
1460
+ };
1461
+ return m[v] = /// comment, because without it formatter makes code uglier
1462
+ `${X.toFormatString({
1463
+ value: B,
1464
+ precision: 4
1465
+ })} ${h.unit.abbrev}`, m;
1466
+ },
1467
+ {}
1468
+ );
1469
+ }
1470
+ function eo(k, h) {
1471
+ if (!h)
1472
+ return null;
1473
+ let c = null;
1474
+ const $ = k.flatMap((d) => {
1475
+ var m;
1476
+ return ((m = d.skus) == null ? void 0 : m.filter((v) => v.sku._id === h._id)) ?? [];
1477
+ }).flatMap((d) => {
1478
+ var m;
1479
+ return !d.history || ((m = d.history) == null ? void 0 : m.length) === 0 ? [] : d.history[0];
1480
+ });
1481
+ for (const d of $) {
1482
+ const m = d.amounts;
1483
+ for (const v of m) {
1484
+ if (v.type !== ne.Enum.SALES)
1485
+ continue;
1486
+ const S = v.measurement ? X.multiply([v.measurement.conversion, v.amount]) : v.amount;
1487
+ c ?? (c = X.fromNumber(0)), c = X.add([c, S]);
1488
+ }
1489
+ }
1490
+ return c != null ? (c.amount = Math.abs(c.amount), `${X.toFormatString({
1491
+ value: c,
1492
+ precision: 4
1493
+ })} ${h.unit.abbrev}`) : null;
1494
+ }
1495
+ const to = { class: "flex items-center w-full fm-typo-en-title-md-800" }, no = { class: "flex-1 line-clamp-2" }, oo = { class: "flex flex-col gap-32 w-full h-full" }, so = { class: "flex items-center relative gap-4" }, ao = { class: "flex-1" }, lo = {
1496
+ key: 0,
1497
+ class: "flex-1 flex flex-col items-center gap-16"
1498
+ }, ro = { class: "fm-typo-en-body-lg-400 translate-x-4" }, io = {
1499
+ key: 1,
1500
+ class: "flex flex-col gap-12"
1501
+ }, uo = { class: "pb-16" }, co = { class: "fm-typo-cn-body-lg-600" }, mo = {
1502
+ class: "grid gap-12 fm-typo-en-body-md-400",
1503
+ style: { "grid-template-columns": "auto auto auto", "grid-auto-rows": "1fr" }
1504
+ }, po = { class: "flex flex-col gap-1" }, vo = { class: "text-fm-color-typo-secondary" }, fo = { class: "font-bold" }, yo = { class: "flex flex-col gap-1" }, _o = { class: "text-fm-color-typo-secondary flex" }, bo = { class: "font-bold" }, ko = { class: "flex flex-col gap-1" }, go = { class: "text-fm-color-typo-secondary" }, ho = { class: "font-bold" }, xo = { class: "flex flex-col gap-1" }, So = { class: "text-fm-color-typo-secondary" }, Fo = { class: "font-bold" }, wo = { class: "flex flex-col gap-1" }, $o = { class: "text-fm-color-typo-secondary" }, Ao = { class: "font-bold" }, Vo = { class: "flex flex-col gap-1" }, Co = { class: "text-fm-color-typo-secondary" }, Mo = { class: "font-bold" }, Bo = { class: "flex flex-col gap-1" }, Do = { class: "text-fm-color-typo-secondary" }, Io = { class: "font-bold" }, jo = { class: "flex flex-col gap-1" }, To = { class: "text-fm-color-typo-secondary" }, Uo = { class: "font-bold" }, Eo = { class: "flex flex-col gap-1" }, Ho = { class: "text-fm-color-typo-secondary" }, Po = { class: "font-bold" }, Ro = {
1505
+ key: 0,
1506
+ class: "flex flex-col gap-8"
1507
+ }, Oo = { class: "flex" }, No = { class: "flex-1 flex flex-col gap-1" }, Lo = { class: "flex gap-1 items-center text-fm-color-typo-secondary" }, zo = { class: "font-bold" }, Yo = { class: "flex-1 flex flex-col gap-1" }, Ko = { class: "flex gap-1 items-center text-fm-color-typo-secondary" }, Go = { class: "flex flex-col gap-1" }, Wo = { class: "font-bold" }, qo = {
1508
+ key: 2,
1509
+ class: "flex-1 flex flex-col items-center gap-8"
1510
+ }, Xo = ["src"], Jo = { class: "font-bold text-lg" }, Qo = { class: "text-xs text-neutral-400 text-center" }, Zo = /* @__PURE__ */ ce({
1511
+ __name: "StockHistory",
1512
+ props: {
1513
+ sku: {},
1514
+ show: { type: Boolean }
1515
+ },
1516
+ emits: ["update:show"],
1517
+ setup(k) {
1518
+ const h = at(), c = Re(), s = _e(), $ = Cn(), d = pe(), m = Mt(), { t: v } = de(), S = k, B = N(!1), i = be(), l = N(At(0));
1519
+ async function y() {
1520
+ B.value = !0;
1521
+ try {
1522
+ await w(), await c.readStockBalance();
1523
+ } catch (t) {
1524
+ i.open({
1525
+ title: "Something went wrong",
1526
+ message: "Cannot fetch stock history. Please try again.",
1527
+ type: "error"
1528
+ }), console.log("failed at fetching item adjustment history", S.sku, l, t);
1529
+ } finally {
1530
+ B.value = !1;
1531
+ }
1532
+ }
1533
+ Ee(() => {
1534
+ y();
1535
+ }), xe([() => l.value, () => S.sku], () => {
1536
+ y();
1537
+ });
1538
+ const C = N([]), A = N([]), V = N(new Array());
1539
+ function n(t, o) {
1540
+ return o === "day" ? Tt(t) : tt(t);
1541
+ }
1542
+ function r(t, o) {
1543
+ const f = t.reduce(
1544
+ (p, a) => {
1545
+ const x = a.effectiveAt ?? ot(a._id);
1546
+ if (!x)
1547
+ return p;
1548
+ const U = n(new Date(x), o);
1549
+ return p[U] ?? (p[U] = []), p[U].push(a), p;
1550
+ },
1551
+ {}
1552
+ );
1553
+ return Object.keys(f).map((p) => ({
1554
+ date: p,
1555
+ adjustments: f[p]
1556
+ }));
1557
+ }
1558
+ async function w() {
1559
+ let t = await s.readStockAdjustment(
1560
+ S.sku._id,
1561
+ Bt(new Date(l.value.startDate)).toISOString(),
1562
+ Dt(new Date(l.value.endDate)).toISOString()
1563
+ );
1564
+ C.value = t;
1565
+ const o = t.filter(({ ref: f }) => f == null ? void 0 : f.startsWith("bill_")).map(({ ref: f }) => f);
1566
+ await M(o), A.value = r(t, "day").map(({ date: f, adjustments: p }) => ({
1567
+ date: f,
1568
+ adjustments: p,
1569
+ adjustmentsByTime: r(p, "minute")
1570
+ }));
1571
+ }
1572
+ async function M(t) {
1573
+ t.length && (V.value = await $.findBillsById(t).catch((o) => {
1574
+ var a;
1575
+ console.error("Error on using latest bill API, retrying using legacy api", o);
1576
+ const f = ((a = h.currentBusiness.value) == null ? void 0 : a._id) ?? "", p = d.currentLocation.doc._id;
1577
+ return $.findBillsByBusinessId(f, [p], t);
1578
+ }));
1579
+ }
1580
+ const D = H(() => {
1581
+ const t = C.value, o = S.sku;
1582
+ return Zn(t, o);
1583
+ }), E = H(() => {
1584
+ const t = C.value, o = S.sku;
1585
+ return eo(t, o);
1586
+ }), P = H(() => {
1587
+ const t = [...C.value].computeFirst((f) => {
1588
+ var a, x;
1589
+ const p = (x = (a = f.skus) == null ? void 0 : a.find) == null ? void 0 : x.call(a, (U) => U.sku._id === S.sku._id);
1590
+ return p == null ? void 0 : p.fromBalance;
1591
+ }) ?? {
1592
+ amount: 0,
1593
+ precision: 0
1594
+ }, o = S.sku;
1595
+ return o ? `${X.toFormatString({
1596
+ value: t,
1597
+ precision: 4
1598
+ })} ${o.unit.abbrev}` : "";
1599
+ }), Q = H(() => {
1600
+ const t = [...C.value].reverse().computeFirst((f) => {
1601
+ var a, x;
1602
+ const p = (x = (a = f.skus) == null ? void 0 : a.find) == null ? void 0 : x.call(a, (U) => U.sku._id === S.sku._id);
1603
+ return p == null ? void 0 : p.toBalance;
1604
+ }) ?? {
1605
+ amount: 0,
1606
+ precision: 0
1607
+ }, o = S.sku;
1608
+ return o ? `${X.toFormatString({ value: t, precision: 4 })} ${o.unit.abbrev}` : "";
1609
+ }), J = H(() => {
1610
+ var f;
1611
+ const o = C.value.flatMap((p) => {
1612
+ var a;
1613
+ return ((a = p.skus) == null ? void 0 : a.flatMap((x) => x.amounts)) ?? [];
1614
+ }).filter((p) => p.amount.amount < 0).reduce(
1615
+ (p, a) => {
1616
+ const x = a.cost;
1617
+ if (!x) return p;
1618
+ const U = {
1619
+ ...Vt(p, Math.max(p.precision, x.precision)),
1620
+ currency: x.currency
1621
+ };
1622
+ return {
1623
+ ...et(U, x),
1624
+ currency: p.currency
1625
+ };
1626
+ },
1627
+ {
1628
+ amount: 0,
1629
+ precision: 0,
1630
+ currency: Me((f = h.currentCountry) == null ? void 0 : f.value)
1631
+ }
1632
+ );
1633
+ return ke(o, !1, o.precision);
1634
+ });
1635
+ function R() {
1636
+ const { startDate: t, endDate: o } = It(l.value);
1637
+ t !== null && o !== null && (l.value = {
1638
+ startDate: t,
1639
+ endDate: o
1640
+ });
1641
+ }
1642
+ const oe = H(() => S.sku.valuation === We.Enum.FIFO ? v("inventory.ingredient.valuationMethod.FIFO") : v("inventory.ingredient.valuationMethod.WAVG")), L = H(() => {
1643
+ var U, z, se, T;
1644
+ const t = [...C.value].reverse().computeFirst((G) => {
1645
+ var W, ae;
1646
+ return (ae = (W = G.skus) == null ? void 0 : W.find) == null ? void 0 : ae.call(W, (re) => re.sku._id === S.sku._id);
1647
+ });
1648
+ if (!t) return "No data";
1649
+ const o = [...t.amounts].reverse()[0], f = {
1650
+ amount: ((U = o.cost) == null ? void 0 : U.amount) ?? 0,
1651
+ precision: ((z = o.cost) == null ? void 0 : z.precision) ?? 0
1652
+ }, p = o.amount, a = p.amount == 0 ? X.fromNumber(0) : X.divide([f, p]);
1653
+ return {
1654
+ ...X.multiply([a, p]),
1655
+ currency: ((se = o.cost) == null ? void 0 : se.currency) || Me(((T = h.currentCountry) == null ? void 0 : T.value) ?? Ct)
1656
+ };
1657
+ }), Y = H(() => {
1658
+ var f;
1659
+ const t = [...C.value].reverse().computeFirst((p) => {
1660
+ var x, U;
1661
+ const a = (U = (x = p.skus) == null ? void 0 : x.find) == null ? void 0 : U.call(x, (z) => z.sku._id === S.sku._id);
1662
+ return a == null ? void 0 : a.toCostBalances;
1663
+ });
1664
+ return t ? {
1665
+ ...t.reduce((p, a) => X.add([p, X.fromDinero(a.cost)]), {
1666
+ amount: 0,
1667
+ precision: 0
1668
+ }),
1669
+ currency: Me((f = h.currentCountry) == null ? void 0 : f.value)
1670
+ } : "No data";
1671
+ });
1672
+ function le() {
1673
+ const { startDate: t, endDate: o } = jt(l.value);
1674
+ t !== null && o !== null && (l.value = {
1675
+ startDate: t,
1676
+ endDate: o
1677
+ });
1678
+ }
1679
+ const _ = Ne(S, "show");
1680
+ return (t, o) => {
1681
+ const f = I("FmButton"), p = I("FmField"), a = I("FmDateRangePicker"), x = I("FmSpacer"), U = I("FmCircularProgress"), z = I("FmIcon"), se = I("FmTooltip"), T = I("FmMenuDivider"), G = I("FmChip"), W = I("FmCardSection"), ae = I("FmCard"), re = I("FmSideSheet");
1682
+ return F(), K(re, {
1683
+ "dismiss-away": "",
1684
+ modelValue: u(_),
1685
+ "onUpdate:modelValue": o[4] || (o[4] = (q) => Ue(_) ? _.value = q : null),
1686
+ "close-button": !1,
1687
+ "max-width": 560
1688
+ }, {
1689
+ "side-sheet-header": j(() => [
1690
+ e("div", to, [
1691
+ e("div", no, b(u(v)("inventory.stock.history.title", [t.sku.name])), 1),
1692
+ g(f, {
1693
+ variant: "tertiary",
1694
+ "prepend-icon": "close",
1695
+ onClick: o[0] || (o[0] = (q) => _.value = !1)
1696
+ })
1697
+ ])
1698
+ ]),
1699
+ default: j(() => {
1700
+ var q;
1701
+ return [
1702
+ e("div", oo, [
1703
+ e("div", so, [
1704
+ e("div", ao, [
1705
+ g(a, {
1706
+ modelValue: l.value,
1707
+ "onUpdate:modelValue": o[1] || (o[1] = (ee) => l.value = ee),
1708
+ "show-predefined-range": "",
1709
+ "start-label": "",
1710
+ "end-label": "",
1711
+ "z-index": 50
1712
+ }, {
1713
+ "trigger-button": j(({ opened: ee }) => [
1714
+ g(p, {
1715
+ "prepend-icon": "calendar_month",
1716
+ focused: ee
1717
+ }, {
1718
+ default: j(() => [
1719
+ ue(b(l.value.startDate) + " - " + b(l.value.endDate), 1)
1720
+ ]),
1721
+ _: 2
1722
+ }, 1032, ["focused"])
1723
+ ]),
1724
+ _: 1
1725
+ }, 8, ["modelValue"])
1726
+ ]),
1727
+ g(f, {
1728
+ variant: "tertiary",
1729
+ onClick: o[2] || (o[2] = (ee) => R()),
1730
+ "prepend-icon": "navigate_before"
1731
+ }),
1732
+ g(f, {
1733
+ variant: "tertiary",
1734
+ onClick: o[3] || (o[3] = (ee) => le()),
1735
+ "prepend-icon": "navigate_next"
1736
+ })
1737
+ ]),
1738
+ B.value ? (F(), O("div", lo, [
1739
+ g(x),
1740
+ g(U, { size: "xl" }),
1741
+ e("div", ro, b(u(v)("inventory.stock.history.loading")), 1),
1742
+ g(x),
1743
+ g(x)
1744
+ ])) : A.value && ((q = A.value) == null ? void 0 : q.length) > 0 ? (F(), O("div", io, [
1745
+ g(ae, { variant: "outlined" }, {
1746
+ default: j(() => [
1747
+ g(W, { class: "flex flex-col gap-4" }, {
1748
+ default: j(() => [
1749
+ e("div", uo, [
1750
+ e("div", co, b(u(v)("inventory.stock.history.summary.title")), 1)
1751
+ ]),
1752
+ e("div", mo, [
1753
+ e("div", po, [
1754
+ e("div", vo, b(u(v)("inventory.stock.history.summary.totalPurchase")), 1),
1755
+ e("div", fo, b(D.value.PURCHASE), 1)
1756
+ ]),
1757
+ e("div", yo, [
1758
+ e("div", _o, [
1759
+ ue(b(u(v)("inventory.stock.history.summary.totalSales")) + "  ", 1),
1760
+ E.value != null ? (F(), K(se, {
1761
+ key: 0,
1762
+ variant: "plain",
1763
+ placement: "top",
1764
+ content: `Before: ${E.value}`,
1765
+ "z-index": 50
1766
+ }, {
1767
+ default: j(() => [
1768
+ g(z, {
1769
+ name: "warning",
1770
+ size: "sm"
1771
+ })
1772
+ ]),
1773
+ _: 1
1774
+ }, 8, ["content"])) : te("", !0)
1775
+ ]),
1776
+ e("div", bo, b(D.value.SALES), 1)
1777
+ ]),
1778
+ e("div", ko, [
1779
+ e("div", go, b(u(v)("inventory.stock.history.summary.totalLose")), 1),
1780
+ e("div", ho, b(D.value.LOSE), 1)
1781
+ ]),
1782
+ e("div", xo, [
1783
+ e("div", So, b(u(v)("inventory.stock.history.summary.totalRequest")), 1),
1784
+ e("div", Fo, b(D.value.REQUEST), 1)
1785
+ ]),
1786
+ e("div", wo, [
1787
+ e("div", $o, b(u(v)("inventory.stock.history.summary.totalReceive")), 1),
1788
+ e("div", Ao, b(D.value.RECEIVE), 1)
1789
+ ]),
1790
+ e("div", Vo, [
1791
+ e("div", Co, b(u(v)("inventory.stock.history.summary.totalConvert")), 1),
1792
+ e("div", Mo, b(D.value.CONVERT), 1)
1793
+ ]),
1794
+ e("div", Bo, [
1795
+ e("div", Do, b(u(v)("inventory.stock.history.summary.totalDamage")), 1),
1796
+ e("div", Io, b(D.value.DAMAGE), 1)
1797
+ ]),
1798
+ e("div", jo, [
1799
+ e("div", To, b(u(v)("inventory.stock.history.summary.openingBalance")), 1),
1800
+ e("div", Uo, b(P.value), 1)
1801
+ ]),
1802
+ e("div", Eo, [
1803
+ e("div", Ho, b(u(v)("inventory.stock.history.summary.lastStockBalance")), 1),
1804
+ e("div", Po, b(Q.value), 1)
1805
+ ])
1806
+ ]),
1807
+ u(m).enableTotalCost ? (F(), O("div", Ro, [
1808
+ g(T, { class: "w-full" }),
1809
+ e("div", Oo, [
1810
+ e("div", No, [
1811
+ g(Xe, { "z-index": 50 }, {
1812
+ default: j(() => [
1813
+ e("div", Lo, [
1814
+ ue(b(u(v)("inventory.stock.history.estimatedValue")) + " ", 1),
1815
+ g(se, {
1816
+ variant: "plain",
1817
+ placement: "top",
1818
+ content: `[${oe.value}] ${u(v)("inventory.stock.history.estimatedValueTooltip")}`,
1819
+ "z-index": 50
1820
+ }, {
1821
+ default: j(() => [
1822
+ g(z, {
1823
+ name: "help",
1824
+ size: "sm"
1825
+ })
1826
+ ]),
1827
+ _: 1
1828
+ }, 8, ["content"])
1829
+ ])
1830
+ ]),
1831
+ _: 1
1832
+ }),
1833
+ e("div", zo, [
1834
+ t.sku.valuation === u(We).Enum.FIFO ? (F(), O(Z, { key: 0 }, [
1835
+ g(G, {
1836
+ label: "FIFO",
1837
+ compact: ""
1838
+ }),
1839
+ ue(" " + b(typeof Y.value != "string" ? u(ke)(
1840
+ Y.value,
1841
+ !1,
1842
+ Y.value.precision
1843
+ ) : Y.value), 1)
1844
+ ], 64)) : (F(), O(Z, { key: 1 }, [
1845
+ ue(b(typeof L.value != "string" ? u(ke)(
1846
+ L.value,
1847
+ !1,
1848
+ L.value.precision
1849
+ ) : L.value), 1)
1850
+ ], 64))
1851
+ ])
1852
+ ]),
1853
+ e("div", Yo, [
1854
+ g(Xe, { "z-index": 50 }, {
1855
+ default: j(() => [
1856
+ e("div", Ko, [
1857
+ ue(b(u(v)("inventory.stock.history.costSold")) + " ", 1),
1858
+ g(se, {
1859
+ variant: "plain",
1860
+ placement: "top",
1861
+ "z-index": 50
1862
+ }, {
1863
+ content: j(() => [
1864
+ e("div", Go, b(u(v)("inventory.stock.history.costSoldTooltip")), 1)
1865
+ ]),
1866
+ default: j(() => [
1867
+ g(z, {
1868
+ name: "help",
1869
+ size: "sm"
1870
+ })
1871
+ ]),
1872
+ _: 1
1873
+ })
1874
+ ])
1875
+ ]),
1876
+ _: 1
1877
+ }),
1878
+ e("div", Wo, b(J.value), 1)
1879
+ ])
1880
+ ])
1881
+ ])) : te("", !0)
1882
+ ]),
1883
+ _: 1
1884
+ })
1885
+ ]),
1886
+ _: 1
1887
+ }),
1888
+ o[5] || (o[5] = e("div", null, null, -1)),
1889
+ (F(!0), O(Z, null, ie(A.value, (ee) => (F(), O(Z, {
1890
+ key: ee.date
1891
+ }, [
1892
+ t.sku ? (F(), K(Qn, {
1893
+ key: 0,
1894
+ record: ee,
1895
+ sku: t.sku,
1896
+ bills: V.value,
1897
+ onRefreshHistory: y
1898
+ }, null, 8, ["record", "sku", "bills"])) : te("", !0)
1899
+ ], 64))), 128))
1900
+ ])) : (F(), O("div", qo, [
1901
+ g(x),
1902
+ e("div", null, [
1903
+ e("img", {
1904
+ src: u(Xt),
1905
+ alt: "List is empty"
1906
+ }, null, 8, Xo)
1907
+ ]),
1908
+ e("div", Jo, b(u(v)("inventory.stock.history.noRecords")), 1),
1909
+ e("div", Qo, b(u(v)("inventory.stock.history.changeDateRange")), 1),
1910
+ g(x),
1911
+ g(x)
1912
+ ]))
1913
+ ])
1914
+ ];
1915
+ }),
1916
+ _: 1
1917
+ }, 8, ["modelValue"]);
1918
+ };
1919
+ }
1920
+ }), es = {
1921
+ key: 0,
1922
+ class: "flex items-center gap-1"
1923
+ }, ts = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ns = { class: "flex flex-col gap-8" }, os = { class: "flex flex-col" }, ss = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, as = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary line-clamp-1" }, hs = /* @__PURE__ */ ce({
1924
+ __name: "StockView",
1925
+ setup(k) {
1926
+ const { t: h } = de(), c = Pe(), s = pe(), $ = Re(), d = it(), m = _e(), v = nt(), S = Ut(), { columnDefs: B } = on(), i = Oe(), l = be();
1927
+ s.watchLocation(V);
1928
+ const y = H(
1929
+ () => new Set(S.getAvailableItems(S.businessSubsidiaryId))
1930
+ ), C = N(!1);
1931
+ async function A() {
1932
+ i.open({
1933
+ title: h("inventory.stock.stock_balance.refreshBalance"),
1934
+ message: h("inventory.stock.stock_balance.refreshBalanceDescription"),
1935
+ closeButton: !0,
1936
+ primaryActions: {
1937
+ text: h("common.confirm"),
1938
+ close: !0
1939
+ },
1940
+ secondaryActions: {
1941
+ text: h("common.close"),
1942
+ close: !0,
1943
+ variant: "tertiary"
1944
+ }
1945
+ }).onPrimary(async () => {
1946
+ await m.recalculation.refreshCurrentBalances(), l.open({
1947
+ title: "Refresh Stock Balance",
1948
+ message: "Stock balance refresh has been queued. This may take a moment to complete.",
1949
+ type: "success"
1950
+ });
1951
+ });
1952
+ }
1953
+ async function V() {
1954
+ if (s._currentLocation) {
1955
+ C.value = !0;
1956
+ try {
1957
+ await $.readStockBalance(), await $.readProductBalance(), await v.readStockEstimateBalance();
1958
+ } catch (L) {
1959
+ l.open({
1960
+ title: h("inventory.stock.error.title"),
1961
+ message: h("inventory.stock.error.message"),
1962
+ type: "error"
1963
+ }), console.error("error on fetch stock balance", L);
1964
+ } finally {
1965
+ C.value = !1;
1966
+ }
1967
+ }
1968
+ }
1969
+ const n = H(() => [
1970
+ {
1971
+ type: "string",
1972
+ key: "status",
1973
+ entity: "sku",
1974
+ values: ["Active", "Inactive"]
1975
+ }
1976
+ ]), r = N({
1977
+ logic: "AND",
1978
+ rules: [
1979
+ {
1980
+ property: "status",
1981
+ operator: "$in",
1982
+ value: ["Active"],
1983
+ type: "string"
1984
+ }
1985
+ ]
1986
+ }), w = H(() => {
1987
+ var le, _, t;
1988
+ const L = r.value ? Et.build(r.value) : null, Y = [];
1989
+ for (const o of c.skus) {
1990
+ let f = !0;
1991
+ if (S.isEnabled && D.value && y.value && f && (f = y.value.has(o._id)), L && f && (f = Ht(
1992
+ {
1993
+ status: o.isInactive ? "Inactive" : "Active"
1994
+ },
1995
+ L
1996
+ )), f) {
1997
+ const p = o.trackingMeasurement;
1998
+ let a = (_ = (le = $.stockBalance.skus) == null ? void 0 : le.find(
1999
+ (z) => z.id === o._id
2000
+ )) == null ? void 0 : _.balance, x = v.inventoryForecast.skus.find(
2001
+ (z) => z.id === o._id
2002
+ );
2003
+ const U = {
2004
+ ...o,
2005
+ balance: a ?? {
2006
+ amount: 0,
2007
+ precision: 0
2008
+ },
2009
+ day: (x == null ? void 0 : x.depletionDays) ?? void 0,
2010
+ trackingUnitAbbrev: p ? ((t = o.unit.measurements.find((z) => z.id === p)) == null ? void 0 : t.abbrev) ?? "" : o.unit.abbrev
2011
+ };
2012
+ Y.push(U);
2013
+ }
2014
+ }
2015
+ return Y;
2016
+ }), M = N(""), D = N(!0), { breakpoints: E } = Kt(), P = H(() => E.value.xs || E.value.sm), Q = H(() => P.value ? 10 : 20), J = Pt(), R = H(() => [
2017
+ {
2018
+ label: h("inventory.stock.stock_balance.refreshBalance"),
2019
+ value: "refresh-balance",
2020
+ isPrimary: !0,
2021
+ prependIcon: "calculate"
2022
+ },
2023
+ {
2024
+ label: h("inventory.common.refresh"),
2025
+ value: "refresh"
2026
+ },
2027
+ {
2028
+ label: h("inventory.common.export"),
2029
+ value: "export"
2030
+ }
2031
+ ]);
2032
+ function oe(L) {
2033
+ switch (L) {
2034
+ case "refresh-balance":
2035
+ return A();
2036
+ case "refresh":
2037
+ return V();
2038
+ case "export":
2039
+ return Zt(w.value);
2040
+ }
2041
+ }
2042
+ return (L, Y) => {
2043
+ const le = I("FmSwitch"), _ = I("FmTable");
2044
+ return F(), K(Rt, {
2045
+ title: u(h)("inventory.stock.title"),
2046
+ actions: R.value,
2047
+ "onClick:action": oe
2048
+ }, {
2049
+ default: j(() => {
2050
+ var t, o, f, p;
2051
+ return [
2052
+ e("div", {
2053
+ class: he([
2054
+ "flex flex-col gap-8 max-h-full",
2055
+ {
2056
+ "p-0": P.value,
2057
+ "px-24 ": !P.value
2058
+ }
2059
+ ])
2060
+ }, [
2061
+ g(Ot, {
2062
+ searchable: "",
2063
+ "change-location": "",
2064
+ search: M.value,
2065
+ "onUpdate:search": Y[1] || (Y[1] = (a) => M.value = a),
2066
+ filterable: "",
2067
+ "filter-attributes": n.value,
2068
+ filter: r.value,
2069
+ "onUpdate:filter": Y[2] || (Y[2] = (a) => r.value = a)
2070
+ }, {
2071
+ default: j(() => [
2072
+ u(S).isEnabled ? (F(), O("div", es, [
2073
+ e("span", ts, b(u(h)("inventory.integration.netsuite.subsidiaryHierarchy.filtering")), 1),
2074
+ g(zt),
2075
+ g(lt, null, {
2076
+ default: j(() => [
2077
+ g(le, {
2078
+ modelValue: D.value,
2079
+ "onUpdate:modelValue": Y[0] || (Y[0] = (a) => D.value = a)
2080
+ }, null, 8, ["modelValue"])
2081
+ ]),
2082
+ _: 1
2083
+ })
2084
+ ])) : te("", !0)
2085
+ ]),
2086
+ _: 1
2087
+ }, 8, ["search", "filter-attributes", "filter"]),
2088
+ (F(), K(_, {
2089
+ style: Ze(u(J).tableHeight),
2090
+ "column-defs": u(B),
2091
+ "row-data": w.value,
2092
+ "search-value": M.value,
2093
+ loading: C.value || !u(s)._currentLocation,
2094
+ key: (t = u(s)._currentLocation) == null ? void 0 : t.dbName,
2095
+ onRowClick: Y[3] || (Y[3] = (a) => u(d).showSkuHistory(a.original)),
2096
+ "page-size": Q.value
2097
+ }, {
2098
+ "list-row": j((a) => [
2099
+ g(Nt, {
2100
+ row: a,
2101
+ onRowClick: u(d).showSkuHistory
2102
+ }, {
2103
+ default: j((x) => {
2104
+ var U, z, se, T, G, W, ae, re, q, ee;
2105
+ return [
2106
+ e("div", ns, [
2107
+ e("div", os, [
2108
+ e("div", ss, [
2109
+ g(u(qe), {
2110
+ render: (se = (z = (U = x.code) == null ? void 0 : U.column) == null ? void 0 : z.columnDef) == null ? void 0 : se.cell,
2111
+ props: (G = (T = x.code) == null ? void 0 : T.getContext) == null ? void 0 : G.call(T)
2112
+ }, null, 8, ["render", "props"])
2113
+ ]),
2114
+ e("div", as, [
2115
+ g(u(qe), {
2116
+ render: (re = (ae = (W = x.name) == null ? void 0 : W.column) == null ? void 0 : ae.columnDef) == null ? void 0 : re.cell,
2117
+ props: (ee = (q = x.name) == null ? void 0 : q.getContext) == null ? void 0 : ee.call(q)
2118
+ }, null, 8, ["render", "props"])
2119
+ ])
2120
+ ]),
2121
+ e("div", null, [
2122
+ g(Te, {
2123
+ days: a.original.day
2124
+ }, null, 8, ["days"])
2125
+ ]),
2126
+ e("div", null, [
2127
+ g(rt, {
2128
+ class: "xs:w-[160px]",
2129
+ unit: a.original.unit,
2130
+ sku: a.original,
2131
+ amount: a.original.balance,
2132
+ "default-tracking-measurement": a.original.trackingMeasurement ?? void 0
2133
+ }, null, 8, ["unit", "sku", "amount", "default-tracking-measurement"])
2134
+ ])
2135
+ ])
2136
+ ];
2137
+ }),
2138
+ _: 2
2139
+ }, 1032, ["row", "onRowClick"])
2140
+ ]),
2141
+ _: 1
2142
+ }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
2143
+ ], 2),
2144
+ (F(), K(dt, { to: "body" }, [
2145
+ (o = u(d).stockHistoryProps) != null && o.sku ? (F(), K(Zo, Ae(Ve({ key: 0 }, u(d).stockHistoryProps)), null, 16)) : te("", !0),
2146
+ (f = u(d).convertSkuDialogProps) != null && f.sku ? (F(), K(kn, Ae(Ve({ key: 1 }, u(d).convertSkuDialogProps)), null, 16)) : te("", !0),
2147
+ (p = u(d).adjustSkuDialogProps) != null && p.stock ? (F(), K(Vn, Ae(Ve({ key: 2 }, u(d).adjustSkuDialogProps)), null, 16)) : te("", !0)
2148
+ ]))
2149
+ ];
2150
+ }),
2151
+ _: 1
2152
+ }, 8, ["title", "actions"]);
2153
+ };
2154
+ }
2155
+ });
2156
+ export {
2157
+ hs as default
2158
+ };