@feedmepos/mf-inventory-portal 1.2.46 → 1.2.47

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