@feedmepos/mf-inventory-portal 0.0.22-dev.9 → 0.0.23-dev.1

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