@feedmepos/mf-inventory-portal 1.0.36 → 1.0.37-dev.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dist/{App-BM-ivBnF.js → App-_SMozUEj.js} +1 -1
  2. package/dist/{ApprovalView-C4hE43Zp.js → ApprovalView-D55iBGg5.js} +19 -19
  3. package/dist/{BindingsDialog-BqjiXxGY.js → BindingsDialog-Di_xTPkA.js} +4 -4
  4. package/dist/{BindingsPicker-DqCR7P5k.js → BindingsPicker-BwIKt9Il.js} +1 -1
  5. package/dist/{BindingsTable-DD_mVBtS.js → BindingsTable-CMFvNSAH.js} +4 -4
  6. package/dist/{ClosingDraftView-CL09Xu9q.js → ClosingDraftView-DXoi5cw9.js} +26 -26
  7. package/dist/ClosingTemplateView-DaPOj50P.js +1849 -0
  8. package/dist/{DeliveryOrderPrintPreview-CNPUHnpX.js → DeliveryOrderPrintPreview-CkIPZo14.js} +4 -4
  9. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DB6m8oSF.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-BSzt53-l.js} +11 -11
  10. package/dist/{FmMultiselectDialog-DJ5cyN7G.js → FmMultiselectDialog-EpV0X6CI.js} +1 -1
  11. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-CPAnSCWa.js → FmUnitInput.vue_vue_type_script_setup_true_lang-Cn3qOqJr.js} +21 -21
  12. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-CauBVtK9.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-BUQQL5kL.js} +1 -1
  13. package/dist/{IngredientGroupView-D0U1ivRz.js → IngredientGroupView-DvxOGAuo.js} +2 -2
  14. package/dist/IngredientsView-BhFDYfnd.js +1851 -0
  15. package/dist/{IntegrationView-hERgFYsT.js → IntegrationView-B_EmS2-x.js} +69 -69
  16. package/dist/{InventoryBindingForm-vO00BnZP.js → InventoryBindingForm-B79lRAe6.js} +1 -1
  17. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-Bku7tdc-.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-DBsD7abQ.js} +24 -24
  18. package/dist/{InventoryBindingSummary-DWOniuG6.js → InventoryBindingSummary-CmnSXYAW.js} +1 -1
  19. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-C4_atZsW.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CDRN_Nrk.js} +1 -1
  20. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-DUdI1WOL.js → PremiumBadge.vue_vue_type_script_setup_true_lang-BknocD4_.js} +10 -10
  21. package/dist/{PublishView-enVS6QHQ.js → PublishView-DNkUYpMh.js} +17 -17
  22. package/dist/{PurchaseOrderPrintPreview-Z769Yvkh.js → PurchaseOrderPrintPreview-D0UhIY8z.js} +12 -12
  23. package/dist/{ReceiveRequestView-BYYWrgNX.js → ReceiveRequestView-DsBpjA9P.js} +797 -782
  24. package/dist/{RecipeView-CU9pkFiv.js → RecipeView-lpMLqWM8.js} +3 -3
  25. package/dist/{StockView-iqR-h1Mg.js → StockView-CIgg_FTJ.js} +6 -6
  26. package/dist/{SupplierView-DFzgQ53O.js → SupplierView-fwzviqqM.js} +3 -3
  27. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-BEVlutvf.js → TransferDetails.vue_vue_type_script_setup_true_lang-TYNgMCEs.js} +604 -602
  28. package/dist/{TransferTemplateView-EZ_z14kY.js → TransferTemplateView-CSy8pydr.js} +83 -83
  29. package/dist/{UnitView-gYD75UdW.js → UnitView-CMOz7RLY.js} +3 -3
  30. package/dist/{WarehouseView-COLgYw-j.js → WarehouseView-B-1c6rRg.js} +1 -1
  31. package/dist/api/duplicate-template.d.ts +5 -0
  32. package/dist/api/inventory.d.ts +4 -0
  33. package/dist/api/netsuite.d.ts +7 -0
  34. package/dist/{app-DMbkakEB.js → app-CFm28RQ_.js} +53154 -52645
  35. package/dist/app.d.ts +9 -0
  36. package/dist/app.js +1 -1
  37. package/dist/components/inventory-binding/InventoryBinding.vue.d.ts +1 -0
  38. package/dist/components/row-action.enum.d.ts +2 -1
  39. package/dist/components/shell/inventory/binding-ui.vue.d.ts +1 -0
  40. package/dist/{decimal-BLjZMddB.js → decimal-UyI93Y1E.js} +1 -1
  41. package/dist/format-unit-display-CNki_g8Q.js +1275 -0
  42. package/dist/{index-C5rv3Yu2.js → index-BWYshfa3.js} +1 -1
  43. package/dist/{index-Bj0hlHvy.js → index-DliBh-3z.js} +1 -1
  44. package/dist/{stock-DjOpPBxG.js → stock-A60nU_aj.js} +1 -1
  45. package/dist/stores/integration/netsuite.d.ts +7 -1
  46. package/dist/stores/inventory.d.ts +9 -0
  47. package/dist/{supplier-BRKfl2V3.js → supplier-lcKFLaW5.js} +1 -1
  48. package/dist/tsconfig.app.tsbuildinfo +1 -1
  49. package/dist/{use-ingredient-select-dialog-DRIWNN3P.js → use-ingredient-select-dialog-B17VDJ0o.js} +1 -1
  50. package/dist/{use-inventory-binding-dialog-DLnKkFpe.js → use-inventory-binding-dialog-sj5lERBj.js} +1 -1
  51. package/dist/views/adjustment-template/wastage-template/actions.d.ts +4 -1
  52. package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftDialog.vue.d.ts +8 -0
  53. package/dist/views/closing-draft/composables/use-closing-draft-table.d.ts +24 -0
  54. package/dist/views/closing-template/components/closing-template-form/composables/use-closing-template-items.d.ts +1 -0
  55. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +16 -1
  56. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +12 -0
  57. package/dist/views/ingredients/components/ingredient-form/IngredientForm.vue.d.ts +2 -0
  58. package/dist/views/ingredients/composables/use-ingredient-table.d.ts +1 -0
  59. package/dist/views/integration/components/netsuite/InventoryTransferIngredientTable.vue.d.ts +2 -0
  60. package/dist/views/integration/components/netsuite/business/BusinessNetSuiteSideSheet.vue.d.ts +4 -0
  61. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +17 -0
  62. package/dist/views/receive-request/components/transfer-form/components/ForecastStock.vue.d.ts +2 -0
  63. package/dist/views/receive-request/components/transfer-form/components/TransferItemTable.vue.d.ts +4 -0
  64. package/dist/views/receive-request/components/transfer-form/composables/use-transfer-items.d.ts +1 -0
  65. package/dist/views/receive-request/composables/use-process-purchase-order.d.ts +4 -0
  66. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +24 -0
  67. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +24 -0
  68. package/dist/views/stock/components/dialog/AdjustedItemForm.vue.d.ts +2 -0
  69. package/dist/views/transfer-template/components/transfer-template-dialog/TransferTemplateDialog.vue.d.ts +2 -0
  70. package/dist/views/transfer-template/components/transfer-template-form/components/NetSuiteCustomCodeSelection.vue.d.ts +2 -0
  71. package/dist/views/transfer-template/components/transfer-template-form/components/TransferTemplateItemTable.vue.d.ts +2 -0
  72. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.d.ts +1 -0
  73. package/dist/views/transfer-template/composables/use-netsuite-custom-field.d.ts +3 -0
  74. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +16 -1
  75. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +12 -0
  76. package/dist/{vue-i18n-x8-PdKzv.js → vue-i18n-CZSieSF0.js} +487 -487
  77. package/package.json +4 -4
  78. package/dist/ClosingTemplateView-CDWMdZOk.js +0 -1804
  79. package/dist/IngredientsView-pgJWthql.js +0 -1838
  80. package/dist/format-unit-display-BkXJg2Ux.js +0 -1230
@@ -0,0 +1,1849 @@
1
+ import { ref as M, h as P, defineComponent as j, resolveComponent as R, openBlock as T, createElementBlock as I, createElementVNode as x, normalizeClass as Y, createTextVNode as Fe, toDisplayString as C, unref as h, createCommentVNode as G, createVNode as $, withCtx as A, Fragment as H, renderList as J, computed as E, watch as Pe, createSlots as Re, createBlock as N, isRef as Oe, normalizeStyle as Ye, Teleport as Ke, normalizeProps as Ge, guardReactiveProps as Je, mergeProps as We } from "vue";
2
+ import { a3 as qe, u as re, af as Qe, D as oe, i as V, h as Xe, f as Ae, ag as le, s as Ze, ah as Ee, v as Ue, a as ie, b as et, w as tt, x as Ve, y as nt, z as ot, ai as st, e as z, G as O, K as lt, aj as at, m as rt, E as Ne, A as it, ak as ct, al as se, B as mt, _ as ut, C as dt } from "./app-CFm28RQ_.js";
3
+ import { useCoreStore as ce, useI18n as B } from "@feedmepos/mf-common";
4
+ import { useDialogChild as pt, useSnackbar as ee, useDialog as me, FmButtonVariant as Z, components as L, useProxiedModel as ft, useBreakpoints as vt } from "@feedmepos/ui-library";
5
+ import { defineStore as Be, storeToRefs as Le } from "pinia";
6
+ import { u as gt } from "./use-ingredient-select-dialog-B17VDJ0o.js";
7
+ const te = qe((r, o) => {
8
+ function n() {
9
+ var e;
10
+ return `business_${((e = ce().currentBusiness.value) == null ? void 0 : e._id) ?? ""}`;
11
+ }
12
+ return {
13
+ async getRecentPublishingJob() {
14
+ const l = n(), t = `${r.inventoryBackendUrl}/${l}/closing-template/publish/recent`;
15
+ return o.get(t);
16
+ },
17
+ async startNewPublish() {
18
+ const l = n(), t = `${r.inventoryBackendUrl}/${l}/closing-template/publish`;
19
+ return o.post(t);
20
+ },
21
+ async getTemplate(l) {
22
+ const t = n(), e = `${r.inventoryBackendUrl}/${t}/closing-template/${l}`;
23
+ return o.get(e);
24
+ },
25
+ async readTemplates() {
26
+ const l = n(), t = `${r.inventoryBackendUrl}/${l}/closing-template`;
27
+ return o.get(t);
28
+ },
29
+ async createTemplate(l) {
30
+ const t = n(), e = `${r.inventoryBackendUrl}/${t}/closing-template`;
31
+ return o.post(e, l);
32
+ },
33
+ async updateTemplate(l) {
34
+ const t = n(), e = `${r.inventoryBackendUrl}/${t}/closing-template`;
35
+ return o.put(e, l);
36
+ },
37
+ async deleteTemplate(l) {
38
+ const t = n(), e = `${r.inventoryBackendUrl}/${t}/closing-template`;
39
+ return o.delete(e, { _id: l._id, _rev: l._rev });
40
+ },
41
+ async importTemplates(l) {
42
+ const t = n(), e = `${r.inventoryBackendUrl}/${t}/closing-template/import`;
43
+ return o.post(e, l);
44
+ }
45
+ };
46
+ }), ne = Be(
47
+ "closingTemplateTable",
48
+ function() {
49
+ const { t: o } = B(), n = ae(), l = M({}), t = M(new Array()), e = M(!1), b = re(), u = te();
50
+ async function v() {
51
+ if (t.value = [], !!b._currentLocation) {
52
+ e.value = !0;
53
+ try {
54
+ const [g, _] = await Promise.all([
55
+ u.readTemplates(),
56
+ u.getRecentPublishingJob()
57
+ ]).delayed(1e3);
58
+ t.value = g, l.value = _;
59
+ } catch (g) {
60
+ console.log("Something went wrong when fetching templates:", g);
61
+ } finally {
62
+ e.value = !1;
63
+ }
64
+ }
65
+ }
66
+ async function a(g) {
67
+ if (!t.value.find((_) => _._id) && b._currentLocation) {
68
+ e.value = !0;
69
+ try {
70
+ const [_] = await Promise.all([
71
+ u.getTemplate(g),
72
+ new Promise((c) => setTimeout(c, 1e3))
73
+ ]);
74
+ t.value = [_];
75
+ } catch (_) {
76
+ console.log("Something went wrong when fetching templates:", _);
77
+ } finally {
78
+ e.value = !1;
79
+ }
80
+ }
81
+ }
82
+ function d(g, _) {
83
+ switch (_ = Ae(_), g) {
84
+ case V.Details:
85
+ return n.viewTemplate(_);
86
+ case V.Edit:
87
+ return n.updateTemplate(_);
88
+ case V.Delete:
89
+ return n.deleteTemplate(_, e, v);
90
+ case V.Duplicate:
91
+ return n.duplicateTemplate(_, e, v);
92
+ }
93
+ }
94
+ return {
95
+ columnDefs: [
96
+ {
97
+ id: "_id",
98
+ accessorKey: "_id",
99
+ header: () => o("inventory.closing.table.createdAt"),
100
+ cell(g) {
101
+ return Qe(`${g.getValue()}`);
102
+ },
103
+ enableSorting: !0
104
+ },
105
+ {
106
+ id: "name",
107
+ accessorKey: "name",
108
+ header: () => o("inventory.closing.table.name"),
109
+ enableSorting: !0,
110
+ size: 200
111
+ },
112
+ {
113
+ id: "noOfItems",
114
+ accessorKey: "items.length",
115
+ header: () => o("inventory.closing.table.noOfItems"),
116
+ enableSorting: !1,
117
+ meta: {
118
+ width: "10rem",
119
+ textAlign: "right"
120
+ }
121
+ },
122
+ {
123
+ id: "enabledLocations",
124
+ accessorKey: "locations.length",
125
+ header: () => o("inventory.closing.table.enabledOutlets"),
126
+ cell(g) {
127
+ var c;
128
+ const _ = (c = g.row.original.locations) == null ? void 0 : c.length;
129
+ return _ ? `${_}` : "All";
130
+ },
131
+ enableSorting: !1,
132
+ meta: {
133
+ width: "10rem",
134
+ textAlign: "right"
135
+ }
136
+ },
137
+ {
138
+ id: "ref",
139
+ accessorKey: "ref",
140
+ header: () => o("inventory.closing.table.reference"),
141
+ enableSorting: !1,
142
+ size: "auto"
143
+ },
144
+ {
145
+ id: "status",
146
+ header: () => o("inventory.closing.table.status"),
147
+ enableSorting: !1,
148
+ cell(g) {
149
+ var y;
150
+ const _ = g.row.original, c = _._rev, i = (y = l.value.publishedRevs) == null ? void 0 : y[_._id], f = c === i;
151
+ return P(
152
+ "div",
153
+ {
154
+ class: "flex"
155
+ },
156
+ P(
157
+ "div",
158
+ {
159
+ class: [
160
+ "fm-status-badge",
161
+ f ? "fm-status-badge-success-secondary" : "fm-status-badge-info-secondary"
162
+ ]
163
+ },
164
+ f ? "Published" : "Unpublished"
165
+ )
166
+ );
167
+ }
168
+ },
169
+ {
170
+ id: "action",
171
+ cell(g) {
172
+ const _ = g.row.original, c = [
173
+ oe[V.Edit],
174
+ oe[V.Duplicate],
175
+ oe[V.Delete]
176
+ ];
177
+ return Xe(c, (i) => d(i, _));
178
+ },
179
+ enableSorting: !1,
180
+ size: 40,
181
+ meta: {
182
+ cellClass: "",
183
+ headerClass: ""
184
+ }
185
+ }
186
+ ],
187
+ recentPublish: l,
188
+ templates: t,
189
+ loading: e,
190
+ fetchTemplates: v,
191
+ loadTemplate: a
192
+ };
193
+ }
194
+ );
195
+ var ue = /* @__PURE__ */ ((r) => (r.Ingredients = "Ingredients", r))(ue || {});
196
+ function ze(r) {
197
+ const o = r.sku, n = new Set(r.disabledMeasurements);
198
+ return [
199
+ {
200
+ code: o.code,
201
+ name: o.name,
202
+ unit: o.unit.abbrev,
203
+ enabled: !n.has(o.unit._id)
204
+ },
205
+ ...o.unit.measurements.map((e) => ({
206
+ unit: e.abbrev,
207
+ enabled: !n.has(e.id)
208
+ }))
209
+ ];
210
+ }
211
+ function He() {
212
+ return [
213
+ {
214
+ id: "code",
215
+ name: "Code"
216
+ },
217
+ {
218
+ id: "name",
219
+ name: "Name"
220
+ },
221
+ {
222
+ id: "unit",
223
+ name: "Unit"
224
+ },
225
+ {
226
+ id: "enabled",
227
+ name: "Enabled"
228
+ }
229
+ ];
230
+ }
231
+ function yt(r) {
232
+ var u;
233
+ const n = ce().currentBusiness.value, t = (u = r.map((v) => {
234
+ var c;
235
+ const a = v.items.flatMap(ze), d = He(), p = [
236
+ ["Template ID", v._id],
237
+ ["Template name", v.name],
238
+ ["Business name", n == null ? void 0 : n.name],
239
+ ["Business ID", n == null ? void 0 : n._id],
240
+ ["Menu version", n == null ? void 0 : n.menuVersion],
241
+ [
242
+ "Locations",
243
+ ...(c = v.locations) != null && c.length ? v.locations.map((i) => `${i.name} (${i.dbName})`) : ["All"]
244
+ ],
245
+ ["Reference", v.ref ?? ""],
246
+ [],
247
+ d.map((i) => i.name),
248
+ ...a.map((i) => d.map((f) => i[f.id]))
249
+ ], g = d.map((i) => `system:${i.id}`), _ = le(p, g);
250
+ return { name: v.name, sheet: _ };
251
+ }).reduce(
252
+ (v, a) => {
253
+ var p;
254
+ const d = a.name.slice(0, 12);
255
+ return (p = v.sheetOccurence)[d] ?? (p[d] = 0), v.sheetOccurence[d] += 1, v.sheets[`${d} (${v.sheetOccurence[d]})`] = a.sheet, v;
256
+ },
257
+ {
258
+ sheets: {},
259
+ sheetOccurence: {}
260
+ }
261
+ )) == null ? void 0 : u.sheets, e = `${n == null ? void 0 : n.name} closing templates (${Ze(/* @__PURE__ */ new Date())}).xlsx`, b = Ee(t);
262
+ return Ue(b, e), e;
263
+ }
264
+ function ht() {
265
+ const r = ce(), o = ie(), n = et(), l = ze({
266
+ sku: {
267
+ unit: {
268
+ _id: "",
269
+ name: "Unit",
270
+ abbrev: "Unit",
271
+ precision: 0,
272
+ measurements: []
273
+ },
274
+ code: "ING001",
275
+ _id: "",
276
+ name: "Sugar"
277
+ }
278
+ })[0], t = r.currentBusiness.value, e = He(), b = [
279
+ ["Template ID (leave empty to create new)", ""],
280
+ ["Template Name", "New template"],
281
+ ["Business name", t == null ? void 0 : t.name],
282
+ ["Business ID", t == null ? void 0 : t._id],
283
+ ["Menu version", t == null ? void 0 : t.menuVersion],
284
+ [
285
+ "Location codes (leave empty to enable all)",
286
+ "Example outlet (restaurant_xxx)",
287
+ "Example outlet 2 (restaurant_xxx)"
288
+ ],
289
+ ["Reference:"],
290
+ [],
291
+ e.map((c) => c.name),
292
+ e.map((c) => l[c.id])
293
+ ], u = e.map((c) => `system:${c.id}`), v = le(b, u), a = n.isEnabled ? n.state.setting.childItems ?? [] : [], d = a.reduce(
294
+ (c, i) => {
295
+ var m, w;
296
+ const f = (m = n.netSuiteItemIdToSkuId.get(i.parentNetSuiteId)) == null ? void 0 : m[0], y = (w = n.netSuiteMeasurementIdToMeasurementId.get(
297
+ i.unitOfMeasureId
298
+ )) == null ? void 0 : w[0];
299
+ if (!i.externalId)
300
+ return c;
301
+ if (!f)
302
+ return console.error(`Item ${i.externalId} cannot be mapped to parent FdoInventorySku.`, i), c;
303
+ const s = o.skuById[f], k = s.unit.measurements.find((S) => S.id === y);
304
+ return k ? (c[i.externalId] = {
305
+ sku: s,
306
+ measurement: k
307
+ }, c) : (console.error(
308
+ `Item ${i.externalId} found parent FdoInventorySku of ${s.code} ${s.name} but the measurement of netsuite id ${i.unitOfMeasureId} cannot be found.`,
309
+ i
310
+ ), c);
311
+ },
312
+ {}
313
+ ), p = le(
314
+ [
315
+ ...o.skus.flatMap((c) => [
316
+ [c.code, c.name, c.unit.abbrev, !0],
317
+ ...c.unit.measurements.map((f) => [
318
+ "",
319
+ "",
320
+ f.abbrev,
321
+ !f.abbrev.toLocaleLowerCase("en-us").includes("inactive")
322
+ ])
323
+ ]),
324
+ ...Object.entries(d).map(([c, { sku: i, measurement: f }]) => [
325
+ i.code,
326
+ i.name,
327
+ f.abbrev,
328
+ !f.abbrev.toLocaleLowerCase("en-us").includes("inactive"),
329
+ c
330
+ ])
331
+ ],
332
+ [
333
+ "Code",
334
+ "Name",
335
+ "Units",
336
+ "Enabled (true/false)",
337
+ ...a.length ? ["Netsuite Parent"] : []
338
+ ]
339
+ ), g = Ee({
340
+ Template: v,
341
+ Ingredients: p
342
+ }), _ = `${t == null ? void 0 : t.name} transfer templates import.xlsx`;
343
+ return Ue(g, _), _;
344
+ }
345
+ function bt(r) {
346
+ if (!r.length || `${r[0]}`.toLocaleLowerCase() === "all")
347
+ return [];
348
+ const o = /(.*) \(((warehouse_|restaurant_).{24,})\)/, l = re().locationByDbName;
349
+ return r.map((t) => {
350
+ const e = new Array(), b = t.trim(), u = o.exec(b);
351
+ if (!u)
352
+ return e.push(`Enabled location value of ${b} cannot be read.`), {
353
+ errors: e
354
+ };
355
+ const v = u[1], a = u[2], d = l[a];
356
+ return d ? (v !== d.name && e.push(
357
+ `Location id ${a} has non-matching name. Found ${v} but expected ${d.name}`
358
+ ), {
359
+ errors: e,
360
+ location: d
361
+ }) : (e.push(`Location (${v}) of id ${a} is not found.`), {
362
+ errors: e
363
+ });
364
+ });
365
+ }
366
+ function _t(r) {
367
+ const [
368
+ o,
369
+ n,
370
+ l,
371
+ t,
372
+ e,
373
+ b,
374
+ u,
375
+ v
376
+ ] = Ve(r);
377
+ return {
378
+ id: `${n[1] ?? ""}`.trim(),
379
+ name: `${l[1] ?? ""}`.trim(),
380
+ locations: u.slice(1).map((a) => `${a}`.trim()).filter((a) => a),
381
+ reference: `${v[1] ?? ""}`.trim()
382
+ };
383
+ }
384
+ function xt(r) {
385
+ const [
386
+ o,
387
+ n,
388
+ l,
389
+ t,
390
+ e,
391
+ b,
392
+ u,
393
+ v,
394
+ a,
395
+ d,
396
+ ...p
397
+ ] = Ve(r);
398
+ if (!o || !o.length || o.some((f) => f.length && !f.startsWith("system:")))
399
+ throw new Error("Missing meta header. Excel file does not come from the template.");
400
+ const g = o.map((f) => f.split(":")[1]), c = ["code", "name", "unit", "enabled"].filter((f) => !g.includes(f));
401
+ if (c.length)
402
+ throw new Error(
403
+ `Missing meta headers (${c.join()}). Excel file does not come from the template.`
404
+ );
405
+ return p.map((f, y) => {
406
+ const s = {};
407
+ for (const k in g) {
408
+ const m = g[k];
409
+ Object.assign(s, { [m]: f[k] });
410
+ }
411
+ return {
412
+ index: y,
413
+ data: s
414
+ };
415
+ });
416
+ }
417
+ function wt(r) {
418
+ return r.reduce(
419
+ (o, n) => {
420
+ var e;
421
+ const l = n.data, t = n.index;
422
+ return l.unit && (l.code ? o.result.push({ parent: n, children: [] }) : o.result.length ? (e = o.result.at(-1)) == null || e.children.push(n) : o.errors.push(`Cannot find parent for row ${t + 9}`)), o;
423
+ },
424
+ { result: new Array(), errors: new Array() }
425
+ );
426
+ }
427
+ function kt(r) {
428
+ const o = r.parent.data, n = new Array(), t = ie().skuByCode[o.code ?? ""];
429
+ if (!t)
430
+ return n.push(`Cannot find ingredient of code ${o.code} ${o.name}`), { errors: n };
431
+ const e = {
432
+ sku: t
433
+ }, b = /* @__PURE__ */ new Set([t.unit._id, ...t.unit.measurements.map((v) => v.id)]), u = t.unit.measurements.find((v) => v.abbrev === o.unit);
434
+ o.unit !== t.unit.abbrev && !u ? n.push(
435
+ `Cannot find measurement unit of ${o.unit} for (${o.code}) ${o.name}.`
436
+ ) : (o.enabled === !0 || `${o.enabled}`.toLocaleLowerCase() === "true") && b.delete(t.unit._id);
437
+ for (const v of r.children) {
438
+ const a = v.data, d = a.unit === t.unit.abbrev ? t.unit : void 0, p = t.unit.measurements.find((g) => g.abbrev === a.unit);
439
+ if (!p && !d) {
440
+ n.push(
441
+ `Cannot find measurement unit of ${a.unit} for (${o.code}) ${o.name}.`
442
+ );
443
+ continue;
444
+ }
445
+ (a.enabled === !0 || `${a.enabled}`.toLocaleLowerCase() === "true") && b.delete((p == null ? void 0 : p.id) ?? (d == null ? void 0 : d._id) ?? "");
446
+ }
447
+ return b.has(t.unit._id) && e.sku.unit.measurements.every((v) => b.has(v.id)) && n.push(`Ingredient ${t.code} - ${t.name} must have at least one unit enabled.`), e.disabledMeasurements = [...b], { errors: n, templateItem: e };
448
+ }
449
+ function Tt(r) {
450
+ const o = r.SheetNames.filter(
451
+ (e) => !Object.values(ue).map(String).includes(e)
452
+ ), l = ne().templates, t = tt(l, "_id");
453
+ try {
454
+ return o.reduce(
455
+ (e, b) => {
456
+ const u = new Array(), v = r.Sheets[b], a = _t(v), d = bt(a.locations), p = d.filter((s) => s.location).map((s) => s.location);
457
+ u.push(...d.flatMap((s) => s.errors));
458
+ const g = xt(v).filter(
459
+ (s) => s.data.code || s.data.unit
460
+ ), _ = wt(g);
461
+ u.push(..._.errors);
462
+ const c = _.result.map(
463
+ (s) => kt(s)
464
+ );
465
+ u.push(...c.flatMap((s) => s.errors));
466
+ const i = c.filter((s) => s.templateItem).map((s) => s.templateItem);
467
+ if (a.id) {
468
+ const s = t[a.id];
469
+ if (!s) {
470
+ const m = {
471
+ _id: a.id,
472
+ _rev: "",
473
+ name: a.name || `(unnamed from sheet ${b || "<unnamed sheet>"})`,
474
+ items: []
475
+ };
476
+ return u.push(`Template ID ${a.id} is not found.`), e.importUpdateResult.push({
477
+ type: "update",
478
+ original: m,
479
+ template: m,
480
+ excelSheetName: b,
481
+ errors: u
482
+ }), e;
483
+ }
484
+ const k = {
485
+ type: "update",
486
+ original: s,
487
+ template: {
488
+ ...s,
489
+ name: a.name,
490
+ locations: p.length ? p : null,
491
+ ref: a.reference,
492
+ items: i
493
+ },
494
+ excelSheetName: b,
495
+ errors: u
496
+ };
497
+ return e.importUpdateResult.push(k), e;
498
+ }
499
+ const y = {
500
+ type: "create",
501
+ template: {
502
+ name: a.name,
503
+ locations: p.length ? p : null,
504
+ ref: a.reference,
505
+ items: i
506
+ },
507
+ excelSheetName: b,
508
+ errors: u
509
+ };
510
+ return e.importCreateResult.push(y), e;
511
+ },
512
+ {
513
+ invalidExcel: !1,
514
+ importCreateResult: new Array(),
515
+ importUpdateResult: new Array()
516
+ }
517
+ );
518
+ } catch (e) {
519
+ return {
520
+ invalidExcel: !0,
521
+ invalidExcelMessage: (e == null ? void 0 : e.message) ?? "Invalid excel",
522
+ importCreateResult: [],
523
+ importUpdateResult: []
524
+ };
525
+ }
526
+ }
527
+ const $t = { class: "flex items-center gap-12 pl-8" }, Ct = { class: "flex flex-col" }, It = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary flex items-center gap-4" }, St = {
528
+ key: 0,
529
+ class: "text-fm-color-typo-secondary fm-typo-en-body-sm-400"
530
+ }, Dt = { key: 0 }, Me = /* @__PURE__ */ j({
531
+ __name: "ClosingTemplateImportItem",
532
+ props: {
533
+ type: {},
534
+ name: {},
535
+ locations: {},
536
+ items: {},
537
+ errors: {}
538
+ },
539
+ setup(r) {
540
+ const { t: o } = B();
541
+ return (n, l) => {
542
+ var b, u, v;
543
+ const t = R("FmIcon"), e = R("FmTooltip");
544
+ return T(), I("div", $t, [
545
+ l[0] || (l[0] = x("div", null, "•", -1)),
546
+ x("div", Ct, [
547
+ x("div", It, [
548
+ x("div", {
549
+ class: Y({
550
+ "text-fm-color-system-error-300": n.errors.length
551
+ })
552
+ }, [
553
+ Fe(C(n.name) + " ", 1),
554
+ n.type === "create" ? (T(), I("span", St, "(" + C(h(o)("inventory.closing.template.import.new")) + ")", 1)) : G("", !0)
555
+ ], 2),
556
+ n.errors.length ? (T(), I("div", Dt, [
557
+ $(e, { "z-index": 50 }, {
558
+ content: A(() => [
559
+ x("ol", null, [
560
+ (T(!0), I(H, null, J(n.errors, (a, d) => (T(), I("li", { key: d }, C(a), 1))), 128))
561
+ ])
562
+ ]),
563
+ default: A(() => [
564
+ $(t, {
565
+ name: "error",
566
+ size: "sm",
567
+ color: "system-error-300"
568
+ })
569
+ ]),
570
+ _: 1
571
+ })
572
+ ])) : G("", !0)
573
+ ]),
574
+ x("div", {
575
+ class: Y([
576
+ "fm-typo-en-body-sm-400",
577
+ {
578
+ "text-fm-color-system-error-200": n.errors.length,
579
+ "text-fm-color-typo-secondary": !n.errors.length
580
+ }
581
+ ])
582
+ }, C((b = n.locations) != null && b.length ? h(o)("inventory.closing.template.import.nLocations", { count: (u = n.locations) == null ? void 0 : u.length }) : h(o)("inventory.closing.template.import.allLocations")) + ", " + C(h(o)("inventory.closing.template.import.nItems", { count: (v = n.items) == null ? void 0 : v.length })), 3)
583
+ ])
584
+ ]);
585
+ };
586
+ }
587
+ }), Mt = { class: "flex flex-col gap-24" }, Ft = { class: "fm-typo-en-body-md-400" }, Pt = {
588
+ key: 0,
589
+ class: "flex items-center gap-8"
590
+ }, Rt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, At = { class: "flex flex-col gap-8" }, Et = { class: "line-clamp-2 text-ellipsis break-all" }, Ut = {
591
+ key: 2,
592
+ class: "shrink-0"
593
+ }, Vt = {
594
+ key: 0,
595
+ class: "flex flex-col"
596
+ }, Nt = { class: "text-fm-color-system-error-300 fm-typo-en-body-sm-400" }, Bt = {
597
+ key: 0,
598
+ class: "max-h-[200px] overflow-y-auto flex flex-col gap-8"
599
+ }, Lt = { class: "fm-typo-en-body-lg-600" }, zt = /* @__PURE__ */ j({
600
+ __name: "ClosingTemplateImport",
601
+ setup(r) {
602
+ const o = M(null), n = pt(), l = ee(), t = M(!1), e = M(!1), b = M(new Array()), u = M([]), v = M([]), a = E(
603
+ () => !!b.value.length || u.value.some((_) => _.errors.length) || v.value.some((_) => _.errors.length)
604
+ ), d = E(
605
+ () => !!u.value.length || !!v.value.length
606
+ ), { t: p } = B();
607
+ async function g(_) {
608
+ b.value = [], u.value = [], v.value = [];
609
+ try {
610
+ t.value = !0;
611
+ const [c] = await Promise.all([
612
+ ot(_),
613
+ // fake buffer
614
+ new Promise((s) => setTimeout(s, 1e3))
615
+ ]);
616
+ if (!c.SheetNames.filter(
617
+ (s) => !Object.values(ue).map(String).includes(s)
618
+ ).find((s) => s)) {
619
+ b.value.push(p("inventory.ingredient.import.fileError.noSheet"));
620
+ return;
621
+ }
622
+ const y = Tt(c);
623
+ if (y.invalidExcel) {
624
+ b.value.push(
625
+ y.invalidExcelMessage ?? p("inventory.ingredient.import.fileError.invalidExcel")
626
+ );
627
+ return;
628
+ }
629
+ if (u.value = y.importCreateResult, v.value = y.importUpdateResult, !u.value.length && !v.value.length) {
630
+ b.value.push(p("inventory.ingredient.import.fileError.noData"));
631
+ return;
632
+ }
633
+ n.emitData(y);
634
+ } catch (c) {
635
+ l.open({
636
+ title: p("inventory.ingredient.import.fileError.unableToRead"),
637
+ message: c == null ? void 0 : c.message,
638
+ type: "error"
639
+ }), console.error("Error in reading file", c);
640
+ } finally {
641
+ b.value.length && l.open({
642
+ title: p("inventory.ingredient.import.fileError.invalidExcel"),
643
+ type: "error"
644
+ }), t.value = !1;
645
+ }
646
+ }
647
+ return Pe(o, (_) => {
648
+ _ && g(_);
649
+ }), (_, c) => {
650
+ const i = R("FmCircularProgress"), f = R("FmIcon"), y = R("FmButton");
651
+ return T(), I("div", Mt, [
652
+ x("div", Ft, C(h(p)("inventory.closing.template.import.message")), 1),
653
+ e.value ? (T(), I("div", Pt, [
654
+ x("div", null, [
655
+ $(i, {
656
+ size: "md",
657
+ color: "neutral-gray-200"
658
+ })
659
+ ]),
660
+ x("div", Rt, C(h(p)("inventory.formField.loading")), 1)
661
+ ])) : (T(), I(H, { key: 1 }, [
662
+ $(nt, {
663
+ class: Y({
664
+ "w-full": !0,
665
+ "h-[200px]": !o.value
666
+ }),
667
+ accept: ".xlsx",
668
+ onFileUpload: c[0] || (c[0] = (s) => o.value = s),
669
+ label: h(p)("inventory.ingredient.import.uploadTemplate"),
670
+ "button-label": h(p)("inventory.ingredient.import.selectFile")
671
+ }, Re({ _: 2 }, [
672
+ o.value ? {
673
+ name: "default",
674
+ fn: A(({ openFileDialog: s }) => [
675
+ x("div", At, [
676
+ x("div", {
677
+ class: Y([
678
+ "fm-corner-radius-md p-16 flex items-center gap-16",
679
+ {
680
+ "border border-fm-color-neutral-gray-100": t.value,
681
+ "border border-fm-color-neutral-gray-200": !t.value && !a.value,
682
+ "border border-fm-color-system-error-200": a.value
683
+ }
684
+ ])
685
+ }, [
686
+ t.value ? (T(), N(i, {
687
+ key: 0,
688
+ size: "md",
689
+ color: "neutral-gray-200"
690
+ })) : (T(), N(f, {
691
+ key: 1,
692
+ name: a.value ? "error" : "attach_file",
693
+ outline: "",
694
+ color: a.value ? "system-error-300" : void 0
695
+ }, null, 8, ["name", "color"])),
696
+ x("div", {
697
+ class: Y([
698
+ "fm-typo-en-body-md-400 flex-1 h-[36px] flex items-center",
699
+ {
700
+ "text-fm-color-typo-disabled": t.value,
701
+ "text-fm-color-typo-primary": !t.value
702
+ }
703
+ ])
704
+ }, [
705
+ x("div", Et, C(o.value.name), 1)
706
+ ], 2),
707
+ t.value ? G("", !0) : (T(), I("div", Ut, [
708
+ $(y, {
709
+ label: h(p)("inventory.ingredient.import.replaceFile"),
710
+ variant: a.value ? "destructive" : "secondary",
711
+ "prepend-icon": a.value ? void 0 : "autorenew",
712
+ onClick: s
713
+ }, null, 8, ["label", "variant", "prepend-icon", "onClick"])
714
+ ]))
715
+ ], 2),
716
+ b.value.length ? (T(), I("div", Vt, [
717
+ (T(!0), I(H, null, J(b.value, (k, m) => (T(), I("div", {
718
+ key: m,
719
+ class: "flex gap-8 items-center"
720
+ }, [
721
+ $(f, {
722
+ name: "error",
723
+ size: "sm",
724
+ color: "system-error-300"
725
+ }),
726
+ x("div", Nt, C(k), 1)
727
+ ]))), 128))
728
+ ])) : G("", !0)
729
+ ])
730
+ ]),
731
+ key: "0"
732
+ } : void 0
733
+ ]), 1032, ["class", "label", "button-label"]),
734
+ d.value ? (T(), I("div", Bt, [
735
+ x("div", Lt, C(h(p)("inventory.ingredient.import.summary")), 1),
736
+ (T(!0), I(H, null, J(u.value, (s, k) => (T(), N(Me, {
737
+ key: k,
738
+ name: s.template.name,
739
+ locations: s.template.locations,
740
+ items: s.template.items,
741
+ errors: s.errors,
742
+ type: "create"
743
+ }, null, 8, ["name", "locations", "items", "errors"]))), 128)),
744
+ (T(!0), I(H, null, J(v.value, (s) => (T(), N(Me, {
745
+ key: s.template._id,
746
+ name: s.template.name,
747
+ locations: s.template.locations,
748
+ items: s.template.items,
749
+ errors: s.errors,
750
+ type: "update"
751
+ }, null, 8, ["name", "locations", "items", "errors"]))), 128))
752
+ ])) : G("", !0)
753
+ ], 64))
754
+ ]);
755
+ };
756
+ }
757
+ }), ae = Be("closingTemplateActions", () => {
758
+ const { t: r } = B(), o = me(), n = ee(), l = te(), t = st(), e = ne(), { loading: b } = Le(e), u = M({});
759
+ function v() {
760
+ u.value = {
761
+ mode: z.CREATE,
762
+ show: !0,
763
+ "onUpdate:show"(y) {
764
+ u.value.show = y;
765
+ }
766
+ };
767
+ }
768
+ function a(y) {
769
+ u.value = {
770
+ mode: z.UPDATE,
771
+ modelValue: y,
772
+ show: !0,
773
+ "onUpdate:show"(s) {
774
+ u.value.show = s;
775
+ }
776
+ };
777
+ }
778
+ function d(y, s, k) {
779
+ o.open({
780
+ title: `Confirm deleting template ${y.name}?`,
781
+ message: "Deleted template can no longer be retrieved",
782
+ primaryActions: {
783
+ text: "Delete",
784
+ variant: Z.Destructive,
785
+ close: !0
786
+ },
787
+ secondaryActions: {
788
+ text: "Cancel",
789
+ variant: Z.Plain,
790
+ close: !0
791
+ }
792
+ }).onPrimary(async () => {
793
+ n.open({
794
+ title: `Deleting ${y.name}`,
795
+ type: "info"
796
+ });
797
+ try {
798
+ s.value = !0;
799
+ const [m] = await Promise.allSettled([
800
+ l.deleteTemplate(y),
801
+ new Promise((w) => setTimeout(w, 1e3))
802
+ ]);
803
+ if (m.status === "rejected") throw m.reason;
804
+ n.open({
805
+ title: `Deleted ${y.name}`,
806
+ type: "success"
807
+ });
808
+ } catch (m) {
809
+ n.open({
810
+ title: `Unable to delete ${y.name}`,
811
+ message: `See error from server: ${m}`,
812
+ type: "error"
813
+ }), console.error("error on deleting closing template", m);
814
+ } finally {
815
+ s.value = !1, k();
816
+ }
817
+ });
818
+ }
819
+ function p(y, s, k) {
820
+ o.open({
821
+ title: `Confirm duplicating template "${y.name}"?`,
822
+ message: "Duplicated template can be edited after creation",
823
+ primaryActions: {
824
+ text: "Duplicate",
825
+ variant: Z.Destructive,
826
+ close: !0
827
+ },
828
+ secondaryActions: {
829
+ text: "Cancel",
830
+ variant: Z.Plain,
831
+ close: !0
832
+ }
833
+ }).onPrimary(async () => {
834
+ n.open({
835
+ title: `Duplicating "${y.name}"`,
836
+ type: "info"
837
+ });
838
+ try {
839
+ s.value = !0;
840
+ const [m] = await Promise.allSettled([
841
+ t.duplicateClosingTemplate(y._id),
842
+ new Promise((w) => setTimeout(w, 1e3))
843
+ ]);
844
+ if (m.status === "rejected") throw m.reason;
845
+ n.open({
846
+ title: `Duplicated "${y.name}"`,
847
+ type: "success"
848
+ });
849
+ } catch (m) {
850
+ n.open({
851
+ title: `Unable to duplicate "${y.name}"`,
852
+ message: `See error from server: ${m}`,
853
+ type: "error"
854
+ }), console.error("error on duplicating closing template", m);
855
+ } finally {
856
+ s.value = !1, k();
857
+ }
858
+ });
859
+ }
860
+ const g = M({});
861
+ function _(y) {
862
+ g.value = {
863
+ template: y,
864
+ show: !0,
865
+ "onUpdate:show"(s) {
866
+ g.value.show = s;
867
+ },
868
+ "onAction:edit"() {
869
+ g.value.show = !1, a(Ae(y));
870
+ }
871
+ };
872
+ }
873
+ function c() {
874
+ if (!e.templates.length) {
875
+ n.open({
876
+ title: "No data to export",
877
+ type: "error"
878
+ });
879
+ return;
880
+ }
881
+ const y = yt(e.templates);
882
+ n.open({
883
+ title: r("inventory.ingredient.export.success"),
884
+ message: r("inventory.ingredient.export.filename", [y]),
885
+ type: "success"
886
+ });
887
+ }
888
+ function i() {
889
+ e.loading || o.open({
890
+ title: r("inventory.ingredient.import.title"),
891
+ contentComponent: zt,
892
+ overlay: !0,
893
+ closeButton: !0,
894
+ primaryActions: {
895
+ text: r("common.import"),
896
+ close: !1
897
+ },
898
+ secondaryActions: {
899
+ text: r("common.close"),
900
+ close: !0
901
+ },
902
+ tertiaryActions: {
903
+ text: r("inventory.ingredient.import.actions.downloadTemplate"),
904
+ close: !1,
905
+ variant: "plain"
906
+ }
907
+ }).onPrimary((y) => {
908
+ if (!y) {
909
+ n.open({
910
+ title: r("inventory.ingredient.import.error.noData"),
911
+ type: "error"
912
+ });
913
+ return;
914
+ }
915
+ if (!y.importCreateResult.length && !y.importUpdateResult.length) {
916
+ n.open({
917
+ title: r("inventory.ingredient.import.error.invalidContent"),
918
+ message: r("inventory.ingredient.import.error.noImportData"),
919
+ type: "error"
920
+ });
921
+ return;
922
+ }
923
+ if (y.importCreateResult.some((s) => s.errors.length) || y.importUpdateResult.some((s) => s.errors.length)) {
924
+ n.open({
925
+ title: r("inventory.ingredient.import.error.invalidContent"),
926
+ message: r("inventory.ingredient.import.error.hasErrors"),
927
+ type: "error"
928
+ });
929
+ return;
930
+ }
931
+ o.close(), f(y);
932
+ }).onTertiary(ht);
933
+ }
934
+ async function f(y) {
935
+ b.value = !0;
936
+ try {
937
+ const s = [
938
+ ...y.importCreateResult.map(
939
+ (S) => S.template
940
+ ),
941
+ ...y.importUpdateResult.map(
942
+ (S) => S.template
943
+ )
944
+ ], k = 100;
945
+ let m = 0;
946
+ const w = () => {
947
+ m += k, n.open({
948
+ title: r("inventory.ingredient.import.progress", [
949
+ Math.min(m, s.length),
950
+ s.length
951
+ ])
952
+ });
953
+ };
954
+ for (const S of s.chunk(100))
955
+ w(), await l.importTemplates(S);
956
+ n.open({
957
+ title: r("inventory.ingredient.import.success"),
958
+ type: "success"
959
+ });
960
+ } catch (s) {
961
+ n.open({
962
+ title: r("inventory.ingredient.import.error.failed"),
963
+ message: r("inventory.ingredient.import.error.systemMessage", [s == null ? void 0 : s.message]),
964
+ type: "error"
965
+ }), console.error("Error in importing skus", y, s);
966
+ } finally {
967
+ b.value = !1, e.fetchTemplates();
968
+ }
969
+ }
970
+ return {
971
+ createTemplate: v,
972
+ viewTemplate: _,
973
+ updateTemplate: a,
974
+ deleteTemplate: d,
975
+ duplicateTemplate: p,
976
+ exportTemplates: c,
977
+ importTemplates: i,
978
+ templateDialogProps: u,
979
+ templateDetailsProps: g
980
+ };
981
+ });
982
+ var K = /* @__PURE__ */ ((r) => (r.Name = "Name", r.Unit = "Unit", r.Delete = "Delete", r))(K || {});
983
+ function Ht(r) {
984
+ return {
985
+ columnDefs: E(() => {
986
+ const n = r.items.map((t) => t.sku.unit.measurements.length).reduce((t, e) => Math.max(t, e), 0);
987
+ return [
988
+ {
989
+ id: "Name",
990
+ header: () => "Name",
991
+ enableSorting: !1,
992
+ size: 400,
993
+ minSize: 400,
994
+ accessorFn: (t) => `${t.sku.name} ${t.sku.code}`,
995
+ cell(t) {
996
+ const e = t.row.original;
997
+ return P(
998
+ "div",
999
+ {
1000
+ class: "flex flex-col",
1001
+ style: { minWidth: "400px" }
1002
+ },
1003
+ [
1004
+ P(
1005
+ "span",
1006
+ { class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary line-clamp-1" },
1007
+ e.sku.name
1008
+ ),
1009
+ P(
1010
+ "span",
1011
+ { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary line-clamp-1" },
1012
+ e.sku.code
1013
+ )
1014
+ ]
1015
+ );
1016
+ }
1017
+ },
1018
+ {
1019
+ id: "Unit",
1020
+ header: () => "Enable unit",
1021
+ enableSorting: !1,
1022
+ minSize: 200,
1023
+ maxSize: 400,
1024
+ cell(t) {
1025
+ var b, u, v;
1026
+ const e = t.row.original;
1027
+ return P("div", { class: "flex items-center gap-32" }, [
1028
+ P(
1029
+ L.FmFormGroup,
1030
+ {
1031
+ value: e.sku.unit._id,
1032
+ modelValue: !((b = e.disabledMeasurements) != null && b.includes(e.sku.unit._id))
1033
+ },
1034
+ P(
1035
+ "div",
1036
+ {
1037
+ class: "flex items-center gap-4",
1038
+ style: { width: "120px" }
1039
+ },
1040
+ [
1041
+ P(L.FmCheckbox, {
1042
+ value: e.sku.unit._id,
1043
+ modelValue: !((u = e.disabledMeasurements) != null && u.includes(e.sku.unit._id)),
1044
+ disabled: r.disabled || !((v = e.disabledMeasurements) != null && v.includes(e.sku.unit._id)) && e.sku.unit.measurements.every(
1045
+ (a) => {
1046
+ var d;
1047
+ return (d = e.disabledMeasurements) == null ? void 0 : d.includes(a.id);
1048
+ }
1049
+ ),
1050
+ "onUpdate:modelValue"(a) {
1051
+ var d;
1052
+ if (a)
1053
+ r.updateItem({
1054
+ ...e,
1055
+ disabledMeasurements: (d = e.disabledMeasurements) == null ? void 0 : d.filter(
1056
+ (p) => p !== e.sku.unit._id
1057
+ )
1058
+ });
1059
+ else {
1060
+ const p = e.disabledMeasurements ?? [];
1061
+ r.updateItem({
1062
+ ...e,
1063
+ disabledMeasurements: [...p, e.sku.unit._id]
1064
+ });
1065
+ }
1066
+ }
1067
+ }),
1068
+ P(
1069
+ L.FmTooltip,
1070
+ { zIndex: 51 },
1071
+ {
1072
+ content() {
1073
+ return e.sku.unit.abbrev;
1074
+ },
1075
+ default() {
1076
+ return P(
1077
+ "div",
1078
+ { class: "line-clamp-2 fm-typo-en-body-lg-400" },
1079
+ e.sku.unit.abbrev
1080
+ );
1081
+ }
1082
+ }
1083
+ )
1084
+ ]
1085
+ )
1086
+ ),
1087
+ ...Array.from({ length: Math.max(n, 0) }).map((a, d) => {
1088
+ var _, c, i, f;
1089
+ const p = t.row.original, g = p.sku.unit.measurements[d];
1090
+ return g ? P(
1091
+ L.FmFormGroup,
1092
+ {
1093
+ modelValue: !((_ = p.disabledMeasurements) != null && _.includes(g.id)),
1094
+ value: g.id
1095
+ },
1096
+ P(
1097
+ "div",
1098
+ {
1099
+ class: "flex items-center gap-4",
1100
+ style: { width: "120px" }
1101
+ },
1102
+ [
1103
+ P(L.FmCheckbox, {
1104
+ value: g.id,
1105
+ modelValue: !((c = p.disabledMeasurements) != null && c.includes(g.id)),
1106
+ disabled: r.disabled || !((i = p.disabledMeasurements) != null && i.includes(g.id)) && ((f = p.disabledMeasurements) == null ? void 0 : f.includes(p.sku.unit._id)) && p.sku.unit.measurements.filter((y) => y.id != g.id).every((y) => {
1107
+ var s;
1108
+ return (s = p.disabledMeasurements) == null ? void 0 : s.includes(y.id);
1109
+ }),
1110
+ "onUpdate:modelValue"(y) {
1111
+ var s;
1112
+ if (y)
1113
+ r.updateItem({
1114
+ ...p,
1115
+ disabledMeasurements: (s = p.disabledMeasurements) == null ? void 0 : s.filter(
1116
+ (k) => k !== g.id
1117
+ )
1118
+ });
1119
+ else {
1120
+ const k = p.disabledMeasurements ?? [];
1121
+ r.updateItem({
1122
+ ...p,
1123
+ disabledMeasurements: [...k, g.id]
1124
+ });
1125
+ }
1126
+ }
1127
+ }),
1128
+ P(
1129
+ L.FmTooltip,
1130
+ { zIndex: 51 },
1131
+ {
1132
+ content() {
1133
+ return g.abbrev;
1134
+ },
1135
+ default() {
1136
+ return P(
1137
+ "div",
1138
+ { class: "line-clamp-2 fm-typo-en-body-lg-400" },
1139
+ g.abbrev
1140
+ );
1141
+ }
1142
+ }
1143
+ )
1144
+ ]
1145
+ )
1146
+ ) : null;
1147
+ })
1148
+ ]);
1149
+ }
1150
+ },
1151
+ {
1152
+ id: "Delete",
1153
+ header: "",
1154
+ cell(t) {
1155
+ const e = t.row.original;
1156
+ return P(
1157
+ "div",
1158
+ { class: "w-full flex justify-end" },
1159
+ P(L.FmButton, {
1160
+ class: "delete-button",
1161
+ key: e.sku._id,
1162
+ type: "button",
1163
+ icon: "delete",
1164
+ variant: "tertiary",
1165
+ size: "md",
1166
+ disabled: r.disabled,
1167
+ onClick: () => {
1168
+ r.deleteItem(e);
1169
+ }
1170
+ })
1171
+ );
1172
+ },
1173
+ enableSorting: !1,
1174
+ size: 40,
1175
+ meta: {
1176
+ cellClass: "",
1177
+ headerClass: ""
1178
+ }
1179
+ }
1180
+ ];
1181
+ })
1182
+ };
1183
+ }
1184
+ const jt = { class: "flex flex-col gap-16 py-12" }, Ot = { class: "flex" }, Yt = { class: "flex-1 flex flex-col" }, Kt = { class: "fm-typo-en-title-sm-600 text-fm-color-typo-primary" }, Gt = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Jt = { class: "flex flex-col gap-4" }, Wt = /* @__PURE__ */ j({
1185
+ __name: "ClosingTemplateItem",
1186
+ props: {
1187
+ cellByColId: {},
1188
+ row: {}
1189
+ },
1190
+ setup(r) {
1191
+ const o = r, n = E(() => o.row), l = E(
1192
+ () => n.value.getVisibleCells().filter((t) => t.column.id !== K.Name && t.column.id !== K.Delete)
1193
+ );
1194
+ return (t, e) => {
1195
+ var b, u, v, a, d;
1196
+ return T(), I("div", jt, [
1197
+ x("div", Ot, [
1198
+ x("div", Yt, [
1199
+ x("div", Kt, C(n.value.original.sku.name), 1),
1200
+ x("div", Gt, C(n.value.original.sku.code), 1)
1201
+ ]),
1202
+ x("div", null, [
1203
+ $(h(O), {
1204
+ render: (v = (u = (b = t.cellByColId[h(K).Delete]) == null ? void 0 : b.column) == null ? void 0 : u.columnDef) == null ? void 0 : v.cell,
1205
+ props: (d = (a = t.cellByColId[h(K).Delete]) == null ? void 0 : a.getContext) == null ? void 0 : d.call(a)
1206
+ }, null, 8, ["render", "props"])
1207
+ ])
1208
+ ]),
1209
+ x("div", Jt, [
1210
+ e[0] || (e[0] = x("div", { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, null, -1)),
1211
+ (T(!0), I(H, null, J(l.value, (p) => {
1212
+ var g, _, c;
1213
+ return T(), I("div", {
1214
+ key: p.id
1215
+ }, [
1216
+ $(h(O), {
1217
+ render: (_ = (g = p.column) == null ? void 0 : g.columnDef) == null ? void 0 : _.cell,
1218
+ props: (c = p.getContext) == null ? void 0 : c.call(p)
1219
+ }, null, 8, ["render", "props"])
1220
+ ]);
1221
+ }), 128))
1222
+ ])
1223
+ ]);
1224
+ };
1225
+ }
1226
+ }), qt = { class: "flex flex-col gap-16" }, Qt = { class: "flex flex-col gap-24" }, Xt = { class: "flex flex-col gap-16" }, Zt = { class: "flex items-center" }, en = { class: "flex-1 fm-typo-en-title-sm-600" }, tn = { class: "flex flex-col gap-16" }, nn = { class: "flex items-center" }, on = { class: "flex-1 gap-8 fm-typo-en-title-sm-600" }, sn = /* @__PURE__ */ j({
1227
+ __name: "ClosingTemplateForm",
1228
+ props: {
1229
+ modelValue: {},
1230
+ disabled: { type: Boolean }
1231
+ },
1232
+ setup(r, { expose: o }) {
1233
+ const n = r, l = lt(), { t } = B(), e = ie();
1234
+ me();
1235
+ const {
1236
+ promptSelectLocations: b,
1237
+ columnDefs: u,
1238
+ rowData: v
1239
+ } = at({
1240
+ getLocations() {
1241
+ return l.locations;
1242
+ },
1243
+ setLocations(i) {
1244
+ l.locations = i;
1245
+ }
1246
+ }), a = M(), d = M("");
1247
+ o({
1248
+ validateInputs: () => {
1249
+ var i, f;
1250
+ (f = (i = a.value) == null ? void 0 : i.validateInputs) == null || f.call(i);
1251
+ },
1252
+ resetInputsValidation: () => {
1253
+ var i, f;
1254
+ (f = (i = a.value) == null ? void 0 : i.resetInputsValidation) == null || f.call(i);
1255
+ },
1256
+ resetInputs: () => {
1257
+ var i, f;
1258
+ (f = (i = a.value) == null ? void 0 : i.resetInputs) == null || f.call(i);
1259
+ }
1260
+ });
1261
+ const p = Ht({
1262
+ updateItem: (i) => {
1263
+ l.items = l.items.map((f) => f.sku._id !== i.sku._id ? f : i);
1264
+ },
1265
+ deleteItem: (i) => {
1266
+ l.items = l.items.filter((f) => f.sku._id !== i.sku._id);
1267
+ },
1268
+ get items() {
1269
+ return l.items;
1270
+ },
1271
+ get disabled() {
1272
+ return n.disabled;
1273
+ }
1274
+ }), g = E(() => p.columnDefs.value), { promptSelectIngredients: _ } = gt();
1275
+ async function c() {
1276
+ const f = e.skus.map((k) => ({
1277
+ label: k.name,
1278
+ sublabel: k.code,
1279
+ value: k
1280
+ })).filter((k) => {
1281
+ var m;
1282
+ return (m = l.items) == null ? void 0 : m.find((w) => w.sku._id === k.value._id);
1283
+ }).map((k) => k.value), y = l.items ?? [], s = await _(
1284
+ f.map((k) => k._id),
1285
+ (k) => {
1286
+ const m = e.skuById[k], w = y.find((F) => F.sku._id === m._id);
1287
+ return w || {
1288
+ sku: m
1289
+ };
1290
+ }
1291
+ );
1292
+ s && (s.sort((k, m) => k.sku.code.localeCompare(m.sku.code)), l.items = s);
1293
+ }
1294
+ return (i, f) => {
1295
+ const y = R("FmTextField"), s = R("FmButton"), k = R("FmTable"), m = R("FmIcon"), w = R("FmFormGroup"), S = R("FmForm");
1296
+ return T(), N(S, {
1297
+ ref_key: "formRef",
1298
+ ref: a,
1299
+ class: "flex flex-col gap-32",
1300
+ disabled: i.disabled
1301
+ }, {
1302
+ default: A(() => [
1303
+ x("div", qt, [
1304
+ x("div", Qt, [
1305
+ $(y, {
1306
+ label: h(t)("inventory.closing.form.name"),
1307
+ "label-mark": "required",
1308
+ modelValue: h(l).name,
1309
+ "onUpdate:modelValue": f[0] || (f[0] = (F) => h(l).name = F),
1310
+ rules: [h(rt)()]
1311
+ }, null, 8, ["label", "modelValue", "rules"]),
1312
+ $(y, {
1313
+ label: h(t)("inventory.closing.form.reference"),
1314
+ "label-mark": "optional",
1315
+ modelValue: h(l).ref,
1316
+ "onUpdate:modelValue": f[1] || (f[1] = (F) => h(l).ref = F)
1317
+ }, null, 8, ["label", "modelValue"])
1318
+ ])
1319
+ ]),
1320
+ x("div", Xt, [
1321
+ x("div", Zt, [
1322
+ x("div", en, C(h(t)("inventory.closing.form.locations")), 1),
1323
+ $(s, {
1324
+ disabled: i.disabled,
1325
+ label: h(t)("inventory.closing.form.selectLocation"),
1326
+ "prepend-icon": "add",
1327
+ variant: "plain",
1328
+ class: "border-2 rounded-lg border-fm-color-primary",
1329
+ onClick: h(b)
1330
+ }, null, 8, ["disabled", "label", "onClick"])
1331
+ ]),
1332
+ $(k, {
1333
+ "column-defs": h(u),
1334
+ "row-data": h(v),
1335
+ "shrink-at": 9999,
1336
+ onRowClick: h(b),
1337
+ "hide-footer": ""
1338
+ }, null, 8, ["column-defs", "row-data", "onRowClick"])
1339
+ ]),
1340
+ x("div", tn, [
1341
+ x("div", nn, [
1342
+ x("div", on, C(h(t)("inventory.closing.form.items.title")), 1),
1343
+ $(s, {
1344
+ disabled: i.disabled,
1345
+ label: h(t)("inventory.closing.form.items.addItem"),
1346
+ "prepend-icon": "add",
1347
+ variant: "plain",
1348
+ class: "border-2 rounded-lg border-fm-color-primary",
1349
+ onClick: f[2] || (f[2] = (F) => c()),
1350
+ size: "md"
1351
+ }, null, 8, ["disabled", "label"])
1352
+ ]),
1353
+ $(y, {
1354
+ placeholder: "Filter items",
1355
+ modelValue: d.value,
1356
+ "onUpdate:modelValue": f[4] || (f[4] = (F) => d.value = F)
1357
+ }, Re({ _: 2 }, [
1358
+ d.value ? {
1359
+ name: "append",
1360
+ fn: A(() => [
1361
+ $(m, {
1362
+ name: "close",
1363
+ onClick: f[3] || (f[3] = (F) => d.value = ""),
1364
+ class: "cursor-pointer"
1365
+ })
1366
+ ]),
1367
+ key: "0"
1368
+ } : void 0
1369
+ ]), 1032, ["modelValue"]),
1370
+ (T(), N(k, {
1371
+ "search-value": d.value,
1372
+ "column-defs": g.value,
1373
+ "row-data": h(l).items,
1374
+ key: h(l).items.map((F) => F.sku._id).join("."),
1375
+ "hide-footer": h(l).items.length <= 10,
1376
+ "page-size": Math.min(10, h(l).items.length)
1377
+ }, {
1378
+ "list-row": A((F) => [
1379
+ (T(), N(Ne, {
1380
+ row: F,
1381
+ key: h(l).items.map((D) => D.sku._id).join(".")
1382
+ }, {
1383
+ default: A((D) => [
1384
+ $(Wt, {
1385
+ row: F,
1386
+ "cell-by-col-id": D
1387
+ }, null, 8, ["row", "cell-by-col-id"])
1388
+ ]),
1389
+ _: 2
1390
+ }, 1032, ["row"]))
1391
+ ]),
1392
+ _: 1
1393
+ }, 8, ["search-value", "column-defs", "row-data", "hide-footer", "page-size"])),
1394
+ $(w, {
1395
+ "model-value": h(l).items.length,
1396
+ rules: [h(it)(1)]
1397
+ }, null, 8, ["model-value", "rules"])
1398
+ ])
1399
+ ]),
1400
+ _: 1
1401
+ }, 8, ["disabled"]);
1402
+ };
1403
+ }
1404
+ }), ln = { class: "flex items-center" }, an = { class: "fm-typo-en-title-md-600" }, rn = { class: "flex gap-4" }, cn = /* @__PURE__ */ j({
1405
+ __name: "ClosingTemplateDialog",
1406
+ props: {
1407
+ mode: {},
1408
+ modelValue: {},
1409
+ show: { type: Boolean }
1410
+ },
1411
+ emits: ["update:show", "submitted"],
1412
+ setup(r, { expose: o, emit: n }) {
1413
+ var k;
1414
+ const l = r, t = n, e = te(), b = ee(), { t: u } = B(), v = ft(l, "show");
1415
+ function a() {
1416
+ return {
1417
+ _id: "",
1418
+ name: "",
1419
+ items: []
1420
+ };
1421
+ }
1422
+ const d = M(l.modelValue ?? a()), p = M(((k = l.modelValue) == null ? void 0 : k._id) ?? `${Math.random()}`);
1423
+ Pe(
1424
+ () => l.show,
1425
+ (m) => {
1426
+ var w;
1427
+ m && (d.value = l.modelValue ?? a(), p.value = ((w = l.modelValue) == null ? void 0 : w._id) ?? `${Math.random()}`);
1428
+ }
1429
+ );
1430
+ const g = M(!1), _ = E(() => {
1431
+ switch (l.mode) {
1432
+ case z.READ:
1433
+ return "";
1434
+ case z.CREATE:
1435
+ return u("inventory.closing.template.create.title");
1436
+ case z.UPDATE:
1437
+ return u("inventory.closing.template.update.title");
1438
+ }
1439
+ return "";
1440
+ }), c = M();
1441
+ o({
1442
+ validateInputs: () => {
1443
+ var m, w;
1444
+ (w = (m = c.value) == null ? void 0 : m.validateInputs) == null || w.call(m);
1445
+ },
1446
+ resetInputsValidation: () => {
1447
+ var m, w;
1448
+ (w = (m = c.value) == null ? void 0 : m.resetInputsValidation) == null || w.call(m);
1449
+ },
1450
+ resetInputs: () => {
1451
+ var m, w;
1452
+ (w = (m = c.value) == null ? void 0 : m.resetInputs) == null || w.call(m);
1453
+ }
1454
+ });
1455
+ async function i() {
1456
+ const m = d.value;
1457
+ if (m) {
1458
+ g.value = !0;
1459
+ try {
1460
+ await e.createTemplate(m), await new Promise((w) => setTimeout(w, 1e3)), b.open({
1461
+ title: u("inventory.closing.template.create.success"),
1462
+ message: u("inventory.closing.template.create.successMessage"),
1463
+ type: "success"
1464
+ }), t("update:show", !1), t("submitted");
1465
+ } catch (w) {
1466
+ b.open({
1467
+ title: u("inventory.closing.template.create.error"),
1468
+ message: u("inventory.closing.template.create.errorMessage"),
1469
+ type: "error"
1470
+ }), console.error("Error in creating closing template", w);
1471
+ } finally {
1472
+ g.value = !1;
1473
+ }
1474
+ }
1475
+ }
1476
+ async function f() {
1477
+ const m = d.value;
1478
+ if (m) {
1479
+ g.value = !0;
1480
+ try {
1481
+ await e.updateTemplate({
1482
+ ...m,
1483
+ _rev: m._rev ?? ""
1484
+ }), await new Promise((w) => setTimeout(w, 1e3)), b.open({
1485
+ title: u("inventory.closing.template.update.success"),
1486
+ message: u("inventory.closing.template.update.successMessage"),
1487
+ type: "success"
1488
+ }), t("update:show", !1), t("submitted");
1489
+ } catch (w) {
1490
+ b.open({
1491
+ title: u("inventory.closing.template.update.error"),
1492
+ message: u("inventory.closing.template.update.errorMessage"),
1493
+ type: "error"
1494
+ }), console.error("Error in updating closing template", w);
1495
+ } finally {
1496
+ g.value = !1;
1497
+ }
1498
+ }
1499
+ }
1500
+ function y() {
1501
+ switch (l.mode) {
1502
+ case z.CREATE:
1503
+ return i();
1504
+ case z.UPDATE:
1505
+ return f();
1506
+ }
1507
+ }
1508
+ function s() {
1509
+ var m, w;
1510
+ (w = (m = c.value) == null ? void 0 : m.validateInputs) == null || w.call(m);
1511
+ }
1512
+ return (m, w) => {
1513
+ const S = R("FmButton"), F = R("FmSideSheet");
1514
+ return T(), N(F, {
1515
+ modelValue: h(v),
1516
+ "onUpdate:modelValue": w[2] || (w[2] = (D) => Oe(v) ? v.value = D : null),
1517
+ "dismiss-away": "",
1518
+ "close-button": "",
1519
+ "max-width": 800
1520
+ }, {
1521
+ "side-sheet-header": A(() => [
1522
+ x("div", ln, [
1523
+ x("div", an, C(_.value), 1)
1524
+ ])
1525
+ ]),
1526
+ default: A(() => [
1527
+ (T(), N(sn, {
1528
+ class: "w-full",
1529
+ ref_key: "formRef",
1530
+ ref: c,
1531
+ onValidationSuccess: y,
1532
+ "model-value": d.value,
1533
+ "onUpdate:modelValue": w[0] || (w[0] = (D) => d.value = D),
1534
+ disabled: g.value,
1535
+ key: p.value
1536
+ }, null, 8, ["model-value", "disabled"]))
1537
+ ]),
1538
+ "side-sheet-footer": A(() => [
1539
+ x("div", rn, [
1540
+ $(S, {
1541
+ loading: g.value,
1542
+ label: h(u)("common.save"),
1543
+ onClick: s
1544
+ }, null, 8, ["loading", "label"]),
1545
+ $(S, {
1546
+ disabled: g.value,
1547
+ variant: "tertiary",
1548
+ label: h(u)("common.close"),
1549
+ onClick: w[1] || (w[1] = (D) => t("update:show", !1))
1550
+ }, null, 8, ["disabled", "label"])
1551
+ ])
1552
+ ]),
1553
+ _: 1
1554
+ }, 8, ["modelValue"]);
1555
+ };
1556
+ }
1557
+ }), mn = {};
1558
+ function un(r, o) {
1559
+ return T(), I("div");
1560
+ }
1561
+ const dn = /* @__PURE__ */ ct(mn, [["render", un]]), pn = { class: "flex flex-col gap-40" }, fn = { key: 0 }, vn = {
1562
+ key: 1,
1563
+ class: "flex gap-8 items-center"
1564
+ }, gn = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary" }, yn = {
1565
+ key: 2,
1566
+ class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary"
1567
+ }, hn = {
1568
+ key: 3,
1569
+ class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary flex flex-col gap-12"
1570
+ }, bn = { class: "fm-typo-en-body-md-600" }, _n = { class: "fm-typo-en-body-md-600" }, xn = { key: 4 }, wn = { class: "fm-typo-en-body-md-600" }, kn = { class: "fm-typo-en-body-md-600" }, Tn = { class: "flex sm:flex-col xs:flex-col justify-end gap-8 w-full mb-16" }, $n = /* @__PURE__ */ j({
1571
+ __name: "ClosingTemplatePublish",
1572
+ emits: ["close"],
1573
+ setup(r, { emit: o }) {
1574
+ const n = M(!1), l = ee(), t = te(), e = ne(), { t: b } = B(), u = o;
1575
+ async function v() {
1576
+ n.value = !0;
1577
+ try {
1578
+ await t.startNewPublish().delayed(1e3), l.open({
1579
+ title: "Success",
1580
+ message: "You may refresh after a while to review publish status",
1581
+ type: "success"
1582
+ }), p();
1583
+ } catch (g) {
1584
+ l.open({
1585
+ title: "Something went wrong",
1586
+ message: "Please try again",
1587
+ type: "error"
1588
+ }), console.error("error on creating publish task", g);
1589
+ } finally {
1590
+ n.value = !1;
1591
+ }
1592
+ }
1593
+ const a = E(() => e.recentPublish.recentJob), d = E(
1594
+ () => e.templates.length && (!a.value || a.value.outlets.length === a.value.completed.length)
1595
+ );
1596
+ function p() {
1597
+ u("close");
1598
+ }
1599
+ return (g, _) => {
1600
+ const c = R("FmCircularProgress"), i = R("i18n-t"), f = R("FmButton");
1601
+ return T(), I("div", pn, [
1602
+ h(e).templates.length ? n.value ? (T(), I("div", vn, [
1603
+ x("div", null, [
1604
+ $(c, {
1605
+ size: "md",
1606
+ color: "neutral-gray-300"
1607
+ })
1608
+ ]),
1609
+ x("div", gn, [
1610
+ x("span", null, C(h(b)("inventory.closing.template.publish.publishing")), 1)
1611
+ ])
1612
+ ])) : a.value ? a.value.outlets.length === a.value.completed.length ? (T(), I("div", hn, [
1613
+ $(i, {
1614
+ keypath: "inventory.closing.template.publish.recentlyPublishedAt",
1615
+ tag: "p"
1616
+ }, {
1617
+ started: A(() => [
1618
+ x("span", bn, C(h(se)(new Date(a.value.createdAt))), 1)
1619
+ ]),
1620
+ finished: A(() => [
1621
+ x("span", _n, C(h(se)(new Date(a.value.updatedAt))), 1)
1622
+ ]),
1623
+ _: 1
1624
+ }),
1625
+ x("p", null, C(h(b)("inventory.closing.template.publish.message")), 1)
1626
+ ])) : (T(), I("div", xn, [
1627
+ $(i, {
1628
+ keypath: "inventory.closing.template.publish.stillPublishing",
1629
+ tag: "p"
1630
+ }, {
1631
+ started: A(() => [
1632
+ x("span", wn, C(h(se)(new Date(a.value.createdAt))), 1)
1633
+ ]),
1634
+ progress: A(() => [
1635
+ x("span", kn, " (" + C(a.value.completed.length) + "/" + C(a.value.outlets.length) + " completed) ", 1)
1636
+ ]),
1637
+ _: 1
1638
+ }),
1639
+ Fe(" Your recent publishing task is still pending (" + C(a.value.completed.length) + " / " + C(a.value.outlets.length) + "). Please wait until all publishing task has completed. ", 1)
1640
+ ])) : (T(), I("div", yn, [
1641
+ x("p", null, C(h(b)("inventory.closing.template.publish.noRecentActivity")), 1),
1642
+ x("p", null, C(h(b)("inventory.closing.template.publish.message")), 1)
1643
+ ])) : (T(), I("div", fn, [
1644
+ x("p", null, C(h(b)("inventory.closing.template.publish.nothingToPublish")), 1)
1645
+ ])),
1646
+ x("div", Tn, [
1647
+ $(f, {
1648
+ disabled: !d.value,
1649
+ loading: n.value,
1650
+ label: "Publish to all outlets",
1651
+ onClick: v
1652
+ }, null, 8, ["disabled", "loading"]),
1653
+ $(f, {
1654
+ variant: "tertiary",
1655
+ label: "Close",
1656
+ onClick: p
1657
+ })
1658
+ ])
1659
+ ]);
1660
+ };
1661
+ }
1662
+ }), Cn = { class: "flex-1 flex flex-col gap-8" }, In = { class: "flex flex-col" }, Sn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Dn = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Mn = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-2" }, Fn = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, Nn = /* @__PURE__ */ j({
1663
+ __name: "ClosingTemplateView",
1664
+ setup(r) {
1665
+ const { t: o } = B(), { createTemplate: n, updateTemplate: l, exportTemplates: t, importTemplates: e } = ae(), { templateDialogProps: b, templateDetailsProps: u } = Le(ae()), v = re(), a = me(), d = ne(), p = mt(), { breakpoints: g } = vt();
1666
+ v.watchLocation(d.fetchTemplates);
1667
+ const _ = E(() => d.loading), c = M(""), i = E(() => g.value.xs || g.value.sm), f = E(() => i.value ? 10 : 20);
1668
+ function y(w) {
1669
+ switch (w) {
1670
+ case V.Add:
1671
+ return n();
1672
+ case "publish":
1673
+ return s();
1674
+ case "import":
1675
+ return e();
1676
+ case "export":
1677
+ return t();
1678
+ case "refresh":
1679
+ return d.fetchTemplates();
1680
+ }
1681
+ }
1682
+ function s() {
1683
+ a.open({
1684
+ title: "Publish closing templates",
1685
+ contentComponent: $n,
1686
+ contentComponentProps: {
1687
+ onClose() {
1688
+ a.close();
1689
+ }
1690
+ }
1691
+ });
1692
+ }
1693
+ function k(w) {
1694
+ return w;
1695
+ }
1696
+ const m = E(() => i.value ? [
1697
+ {
1698
+ label: o("inventory.closing.template.create.title"),
1699
+ value: V.Add,
1700
+ isPrimary: !0,
1701
+ prependIcon: "add"
1702
+ },
1703
+ {
1704
+ label: o("inventory.common.refresh"),
1705
+ value: "refresh",
1706
+ isPrimary: !1
1707
+ },
1708
+ {
1709
+ label: o("inventory.common.publish"),
1710
+ value: "publish",
1711
+ isPrimary: !1
1712
+ },
1713
+ {
1714
+ label: o("inventory.common.import"),
1715
+ value: "import",
1716
+ isPrimary: !1
1717
+ },
1718
+ {
1719
+ label: o("inventory.common.export"),
1720
+ value: "export",
1721
+ isPrimary: !1
1722
+ }
1723
+ ] : [
1724
+ {
1725
+ label: o("inventory.closing.template.create.title"),
1726
+ value: V.Add,
1727
+ isPrimary: !0,
1728
+ prependIcon: "add"
1729
+ },
1730
+ {
1731
+ label: o("inventory.common.publish"),
1732
+ value: "publish",
1733
+ isPrimary: !1
1734
+ },
1735
+ {
1736
+ label: o("inventory.common.import"),
1737
+ value: "import",
1738
+ isPrimary: !1
1739
+ },
1740
+ {
1741
+ label: o("inventory.common.refresh"),
1742
+ value: "refresh",
1743
+ isPrimary: !1
1744
+ },
1745
+ {
1746
+ label: o("inventory.common.export"),
1747
+ value: "export",
1748
+ isPrimary: !1
1749
+ }
1750
+ ]);
1751
+ return (w, S) => {
1752
+ const F = R("FmTable");
1753
+ return T(), I(H, null, [
1754
+ $(ut, {
1755
+ title: h(o)("inventory.closing.template.title"),
1756
+ actions: m.value,
1757
+ "onClick:action": y
1758
+ }, {
1759
+ default: A(() => [
1760
+ x("div", {
1761
+ class: Y([
1762
+ "flex flex-col gap-8 max-h-full",
1763
+ {
1764
+ "p-0": i.value,
1765
+ "px-24 ": !i.value
1766
+ }
1767
+ ])
1768
+ }, [
1769
+ $(dt, {
1770
+ searchable: "",
1771
+ search: c.value,
1772
+ "onUpdate:search": S[0] || (S[0] = (D) => c.value = D)
1773
+ }, null, 8, ["search"]),
1774
+ $(F, {
1775
+ style: Ye(h(p).tableHeight),
1776
+ "column-defs": h(d).columnDefs,
1777
+ "row-data": h(d).templates,
1778
+ "search-value": c.value,
1779
+ loading: _.value,
1780
+ onRowClick: S[1] || (S[1] = (D) => h(l)(D.original)),
1781
+ "page-size": f.value
1782
+ }, {
1783
+ "list-row": A((D) => [
1784
+ $(Ne, {
1785
+ row: D,
1786
+ onRowClick: (U) => h(l)(U)
1787
+ }, {
1788
+ default: A((U) => {
1789
+ var de, pe, fe, W, ve, ge, ye, he, q, be, _e, xe, we, ke, Te, Q, $e, Ce, Ie, Se, X, De;
1790
+ return [
1791
+ x("div", Cn, [
1792
+ x("div", In, [
1793
+ x("div", Sn, [
1794
+ $(h(O), {
1795
+ render: (fe = (pe = (de = U._id) == null ? void 0 : de.column) == null ? void 0 : pe.columnDef) == null ? void 0 : fe.cell,
1796
+ props: (ve = (W = U._id) == null ? void 0 : W.getContext) == null ? void 0 : ve.call(W)
1797
+ }, null, 8, ["render", "props"])
1798
+ ]),
1799
+ x("div", Dn, [
1800
+ $(h(O), {
1801
+ render: (he = (ye = (ge = U.name) == null ? void 0 : ge.column) == null ? void 0 : ye.columnDef) == null ? void 0 : he.cell,
1802
+ props: (be = (q = U.name) == null ? void 0 : q.getContext) == null ? void 0 : be.call(q)
1803
+ }, null, 8, ["render", "props"])
1804
+ ]),
1805
+ x("div", null, C((_e = D.original.locations) != null && _e.length ? h(o)("inventory.closing.table.enabledForN", {
1806
+ count: ((xe = D.original.locations) == null ? void 0 : xe.length) ?? 0
1807
+ }) : h(o)("inventory.closing.table.enabledForAll")), 1),
1808
+ x("div", Mn, C([
1809
+ ...D.original.items.slice(0, 3).map((je) => je.sku.name),
1810
+ ...D.original.items.length >= 3 ? [`and ${D.original.items.length - 3} more items`] : []
1811
+ ].join(", ")), 1),
1812
+ x("div", Fn, [
1813
+ $(h(O), {
1814
+ render: (Te = (ke = (we = U.ref) == null ? void 0 : we.column) == null ? void 0 : ke.columnDef) == null ? void 0 : Te.cell,
1815
+ props: ($e = (Q = U.ref) == null ? void 0 : Q.getContext) == null ? void 0 : $e.call(Q)
1816
+ }, null, 8, ["render", "props"])
1817
+ ])
1818
+ ]),
1819
+ x("div", null, [
1820
+ $(h(O), {
1821
+ render: (Se = (Ie = (Ce = U.status) == null ? void 0 : Ce.column) == null ? void 0 : Ie.columnDef) == null ? void 0 : Se.cell,
1822
+ props: (De = (X = U.status) == null ? void 0 : X.getContext) == null ? void 0 : De.call(X)
1823
+ }, null, 8, ["render", "props"])
1824
+ ])
1825
+ ])
1826
+ ];
1827
+ }),
1828
+ _: 2
1829
+ }, 1032, ["row", "onRowClick"])
1830
+ ]),
1831
+ _: 1
1832
+ }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"])
1833
+ ], 2)
1834
+ ]),
1835
+ _: 1
1836
+ }, 8, ["title", "actions"]),
1837
+ (T(), N(Ke, { to: "body" }, [
1838
+ $(dn, Ge(Je(h(u))), null, 16),
1839
+ $(cn, We(h(b), {
1840
+ onSubmitted: S[2] || (S[2] = (D) => h(d).fetchTemplates())
1841
+ }), null, 16)
1842
+ ]))
1843
+ ], 64);
1844
+ };
1845
+ }
1846
+ });
1847
+ export {
1848
+ Nn as default
1849
+ };