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