@feedmepos/mf-inventory-portal 1.2.7 → 1.2.8

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