@feedmepos/mf-inventory-portal 1.5.12-dev.0 → 1.5.13

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 (111) hide show
  1. package/dist/{App-ym7zoIt4.js → App-DqGcS6Gm.js} +4 -4
  2. package/dist/{ApprovalView-DS1cgEM3.js → ApprovalView-BpLssvwC.js} +7 -7
  3. package/dist/{BindingsDialog-pA-lQ0Qx.js → BindingsDialog-Bjca56rZ.js} +2 -2
  4. package/dist/{BindingsPicker-D-lS8rtE.js → BindingsPicker-D3bSjNn3.js} +2 -2
  5. package/dist/{BindingsTable-CCG83TCM.js → BindingsTable-b8uwBXvE.js} +3 -3
  6. package/dist/{ClosingDraftView-BI6RvZMJ.js → ClosingDraftView-DufSupv2.js} +15 -15
  7. package/dist/{ClosingHistoryView-CzSQ7tNH.js → ClosingHistoryView-C3V5brh9.js} +86 -85
  8. package/dist/{ClosingTemplateView-By2oAuyO.js → ClosingTemplateView-B6hpp5B8.js} +14 -14
  9. package/dist/{DefaultView-eHfv7jOS.js → DefaultView-DeN96J1z.js} +2 -2
  10. package/dist/{DeliveryOrderPrintPreview-59gPCEN9.js → DeliveryOrderPrintPreview-EnFKjxtA.js} +2 -2
  11. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DJnbYUPk.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-6M_CG9Xi.js} +2 -2
  12. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BmoeRycM.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-RH37--FG.js} +2 -2
  13. package/dist/{FmMultiselectDialog-y6iFhI-b.js → FmMultiselectDialog-6mShWQom.js} +1 -1
  14. package/dist/{FmMultiselectDialog-BQct_7_1.js → FmMultiselectDialog-CfjwOjv0.js} +2 -2
  15. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-5FB2Q2M7.js → FmUnitInput.vue_vue_type_script_setup_true_lang-ILexyjQI.js} +5 -5
  16. package/dist/{ImportView-CFhTlC6A.js → ImportView-Aksgpj3u.js} +6 -6
  17. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang--lvhU0IL.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-BVa8U4y-.js} +1 -1
  18. package/dist/{IngredientGroupView-98vFl0cv.js → IngredientGroupView-BbJFosjR.js} +5 -5
  19. package/dist/{IngredientsView-DOyC-80n.js → IngredientsView-CN933oCR.js} +15 -15
  20. package/dist/{IntegrationExplorerView-yqqhYVKa.js → IntegrationExplorerView-CAjxn-PC.js} +352 -352
  21. package/dist/IntegrationView-w4fp4oT4.js +4586 -0
  22. package/dist/{InventoryBindingForm-TOMIZzTV.js → InventoryBindingForm-EBJ3QGaU.js} +1 -1
  23. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-CCwsG2nZ.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-CoUtIP_H.js} +5 -5
  24. package/dist/{InventoryBindingSummary-Kq71Npw5.js → InventoryBindingSummary-DqplMp3W.js} +1 -1
  25. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BpqRkOKa.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DtBoicPG.js} +1 -1
  26. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-BXQXxebS.js → PremiumBadge.vue_vue_type_script_setup_true_lang-DsYsq73l.js} +1 -1
  27. package/dist/{PublishView-B3iAIUeC.js → PublishView-BJIsXl8d.js} +3 -3
  28. package/dist/{PurchaseOrderPrintPreview-C7BYCDq4.js → PurchaseOrderPrintPreview-C7HgcwTx.js} +2 -2
  29. package/dist/{ReceiveRequestView-C0RZHVVz.js → ReceiveRequestView-BKfE6CFa.js} +26 -26
  30. package/dist/{RecipeView-CGMCm-6C.js → RecipeView-CIcat7Oq.js} +1117 -1104
  31. package/dist/{SettingsView-Dy36ihuC.js → SettingsView-DAg0_Cxw.js} +4 -4
  32. package/dist/{StockView-DG8gGcR6.js → StockView-DkkBhXdb.js} +19 -19
  33. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-7jJ-_TKD.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-B_7-SpUx.js} +1 -1
  34. package/dist/{SupplierView-DkXdKVSS.js → SupplierView-DdBM6_mn.js} +12 -12
  35. package/dist/{SurchargeView-CnQFI8Np.js → SurchargeView-DO7ccJw4.js} +6 -6
  36. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-CjxxSwOw.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-CnmxlHSe.js} +2 -2
  37. package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-CgxcV8uB.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-CsxPLRxW.js} +1 -1
  38. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-P4wynSco.js → TransferDetails.vue_vue_type_script_setup_true_lang-UAe7BwyU.js} +20 -20
  39. package/dist/TransferTemplateView-DwNMWpQG.js +1564 -0
  40. package/dist/{UnitCostHistoryView-lq-q2AHS.js → UnitCostHistoryView-BR_DzquD.js} +4 -4
  41. package/dist/{UnitDisplayControl.vue_vue_type_script_setup_true_lang-DSlyQqSb.js → UnitDisplayControl.vue_vue_type_script_setup_true_lang-1frVLUSk.js} +5 -5
  42. package/dist/{UnitView-d_Imf603.js → UnitView-DHhs6eAM.js} +7 -7
  43. package/dist/{WarehouseView-61nx-AdI.js → WarehouseView-BncF3L-E.js} +5 -5
  44. package/dist/{WastageTemplateView-CjFGIKQo.js → WastageTemplateView-e3ixwHt1.js} +14 -14
  45. package/dist/api/inventory.d.ts +0 -1
  46. package/dist/api/netsuite.d.ts +4 -5
  47. package/dist/api/surcharge.d.ts +0 -1
  48. package/dist/{app-vpgIgmf7.js → app-BM6mngFA.js} +4141 -4438
  49. package/dist/app.d.ts +0 -268
  50. package/dist/app.js +1 -1
  51. package/dist/{closing-template-Dq6tC4Zx.js → closing-template-BD6V7qLl.js} +1 -1
  52. package/dist/{date2-Bdr9V2CH.js → date2-DDlrt2dw.js} +1 -1
  53. package/dist/{dayjs.min-DyMZZmIx.js → dayjs.min-CRtl6lAo.js} +1 -1
  54. package/dist/{decimal-naJvMnG2.js → decimal-C05Zbycy.js} +2 -2
  55. package/dist/{defineDeepModel-33cmeIFu.js → defineDeepModel-B0S3YXv1.js} +1 -1
  56. package/dist/{duplicate-template-DSu6924D.js → duplicate-template-DLoKowb8.js} +1 -1
  57. package/dist/{feature-yi8Tnb7H.js → feature-Hkq4qHGO.js} +2 -2
  58. package/dist/{format-time-from-id-Dq0qIwbK.js → format-time-from-id-BsGskcws.js} +1 -1
  59. package/dist/format-unit-display-Dbb2764O.js +1268 -0
  60. package/dist/{import-export.helper-DDiyb9cx.js → import-export.helper-CwHS2Pr0.js} +6 -6
  61. package/dist/{index-B4vbL-WN.js → index-BosCKut7.js} +1 -1
  62. package/dist/index-C-Z_O_57.js +164 -0
  63. package/dist/{index-Dmrgz0N_.js → index-DOZ0kYer.js} +1 -1
  64. package/dist/{inventory-core-dart.default-DzEwllSu.js → inventory-core-dart.default-DsrlA0VP.js} +1 -1
  65. package/dist/{lz-string-DECQ92Sb.js → lz-string-jug66pQ2.js} +1 -1
  66. package/dist/modules/print-template/api/print-template.d.ts +0 -1
  67. package/dist/{netsuite-CKOqNFIz.js → netsuite-CM1xsb3Q.js} +2 -2
  68. package/dist/{number-CwVsldWr.js → number-B1kR4U7C.js} +3 -3
  69. package/dist/{predefined-templates-7P8LQiMs.js → predefined-templates-B3VXqLxq.js} +1 -1
  70. package/dist/{purchase-order-template-CFGG5iZS.js → purchase-order-template-BZ7ubNPM.js} +1 -1
  71. package/dist/{recalculationUtils-CxUnAgYt.js → recalculationUtils-DT_K_oBV.js} +1 -1
  72. package/dist/{rules-C-5mKwH6.js → rules-DXN5yNM9.js} +2 -2
  73. package/dist/{stock-B_XDv328.js → stock-Cwp99-w7.js} +1 -1
  74. package/dist/stores/api.d.ts +0 -1
  75. package/dist/stores/helper/generate-backend-urls.d.ts +0 -1
  76. package/dist/stores/integration/index.d.ts +1 -4
  77. package/dist/{supplier-BDDyN8pD.js → supplier-CNblYzcC.js} +2 -2
  78. package/dist/{surcharge-9qVO99TB.js → surcharge-DiXkOxK8.js} +1 -1
  79. package/dist/tsconfig.app.tsbuildinfo +1 -1
  80. package/dist/{uom-rules-2xdoSjfc.js → uom-rules-B0cj4nFH.js} +1 -1
  81. package/dist/{use-ingredient-select-dialog-BHgTuz0K.js → use-ingredient-select-dialog-CHqjDEzy.js} +2 -2
  82. package/dist/{use-inventory-binding-dialog-CVpVEZ-n.js → use-inventory-binding-dialog-CqKj6_hT.js} +2 -2
  83. package/dist/use-template-enabled-locations-CZf0oezR.js +146 -0
  84. package/dist/{use-transfer-locations-CMPfQCpO.js → use-transfer-locations-BTRfRrp8.js} +2 -2
  85. package/dist/{useHrmPermission-BfjsEgXe.js → useHrmPermission-CYeY_uQ0.js} +1 -1
  86. package/dist/{useNavigationMenu-DQV4rPXu.js → useNavigationMenu-D2DBZszb.js} +2 -2
  87. package/dist/{useSseClient-DyY87MX7.js → useSseClient-DNe-54JD.js} +3 -3
  88. package/dist/views/recipe/composables/use-recipe-bulk-editor.d.ts +3 -3
  89. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +1 -4
  90. package/dist/{vue-i18n-WjLZbUYJ.js → vue-i18n-CRix8f2i.js} +419 -419
  91. package/dist/{xlsx-BoG4Nhqx.js → xlsx-4npyDw84.js} +398 -398
  92. package/dist/{xlsx.util-BSJ5fdz4.js → xlsx.util-C-DEH9b0.js} +3 -3
  93. package/package.json +4 -4
  94. package/dist/IntegrationView-BR7yLMpk.js +0 -5100
  95. package/dist/TransferTemplateView-D6dO4-GT.js +0 -2327
  96. package/dist/api/codemax.d.ts +0 -11
  97. package/dist/format-unit-display-dtvjecol.js +0 -1432
  98. package/dist/index-B4O6YlPQ.js +0 -257
  99. package/dist/stores/integration/codemax.d.ts +0 -432
  100. package/dist/use-template-enabled-locations-esKf16CY.js +0 -132
  101. package/dist/views/integration/Codemax.vue.d.ts +0 -2
  102. package/dist/views/integration/components/ApplyProductCodemax.vue.d.ts +0 -341
  103. package/dist/views/integration/components/ApplyProductDialogCodemax.vue.d.ts +0 -298
  104. package/dist/views/integration/components/ApplyProductDialogPropsCodemax.d.ts +0 -17
  105. package/dist/views/integration/components/CodemaxDialog.vue.d.ts +0 -519
  106. package/dist/views/transfer-template/components/template-item-bulk-editor/TemplateItemBulkEditorDialog.vue.d.ts +0 -2
  107. package/dist/views/transfer-template/components/template-item-bulk-editor/TemplateItemBulkEditorStep1.vue.d.ts +0 -2
  108. package/dist/views/transfer-template/components/template-item-bulk-editor/TemplateItemBulkEditorStep2.vue.d.ts +0 -8
  109. package/dist/views/transfer-template/components/template-item-bulk-editor/TemplateItemBulkEditorStep3.vue.d.ts +0 -2
  110. package/dist/views/transfer-template/composables/use-template-item-bulk-editor.d.ts +0 -3225
  111. package/dist/views/transfer-template/helpers/template-item-bulk-editor-export.d.ts +0 -9
@@ -1,1432 +0,0 @@
1
- import { components as ce, useDialogChild as Pe, useSnackbar as de, useDialog as Me, FmButtonVariant as te } from "@feedmepos/ui-library";
2
- import { defineStore as pe } from "pinia";
3
- import { F as xe } from "./form-mode.enum-BKiNVH6A.js";
4
- import { u as fe } from "./purchase-order-template-CFGG5iZS.js";
5
- import { ref as I, h as oe, defineComponent as ye, resolveComponent as W, openBlock as O, createElementBlock as F, createElementVNode as N, normalizeClass as J, createTextVNode as Be, toDisplayString as q, unref as B, createCommentVNode as Z, createVNode as j, withCtx as me, Fragment as Y, renderList as ae, onMounted as Le, computed as H, watch as Qe, createSlots as Ue, createBlock as re } from "vue";
6
- import { a as X, c as ve, r as L, u as ie, l as qe, j as _e, s as Ve, R as we } from "./app-vpgIgmf7.js";
7
- import { useRouter as He } from "vue-router";
8
- import { a as je } from "./FmMultiselectDialog-BQct_7_1.js";
9
- import { D as ne, R as U } from "./row-action.enum-DQ9bJ_uv.js";
10
- import { c as ze } from "./component-kqxARxvM.js";
11
- import { f as Ye } from "./format-time-from-id-Dq0qIwbK.js";
12
- import { useI18n as he, useCoreStore as Ie } from "@feedmepos/mf-common";
13
- import { t as K, a as Ce, d as Oe, s as Ae, r as Ke } from "./xlsx.util-BSJ5fdz4.js";
14
- import { F as Ge } from "./FmDroppableField-J0xUsOTV.js";
15
- import { c as We, a as G, t as se, g as ue } from "./number-CwVsldWr.js";
16
- import { f as Je } from "./date2-Bdr9V2CH.js";
17
- import { u as ge } from "./supplier-BDDyN8pD.js";
18
- import { a as Ze, B as Xe } from "./rules-C-5mKwH6.js";
19
- import { u as Te } from "./netsuite-CKOqNFIz.js";
20
- import { u as et } from "./duplicate-template-DSu6924D.js";
21
- import { u as tt } from "./vue-i18n-WjLZbUYJ.js";
22
- function De(n) {
23
- const e = X(), o = n.sku, d = e.skuById[o._id];
24
- if (d.unit._id !== o.unit._id) return !0;
25
- const u = n.measurement;
26
- return u ? !e.unitById[d.unit._id].measurements.find((a) => a.id === u.id) : !1;
27
- }
28
- function ke(n) {
29
- const { skuById: e } = X(), o = ve(n);
30
- return o.purchaseOrder.items = n.purchaseOrder.items.filter((d) => e[d.sku._id]), o;
31
- }
32
- const be = pe(
33
- "transferTemplateTable",
34
- function() {
35
- const { t: e } = he(), o = At(), d = I(!1), u = I(new Array()), s = fe(), m = X();
36
- async function a() {
37
- u.value = [], d.value = !0;
38
- try {
39
- m.isInventoryLoaded || await m.readInventory();
40
- const [l] = await Promise.all([s.readTemplates()]).delayed(
41
- 1e3
42
- );
43
- u.value = l.map(ke);
44
- } catch (l) {
45
- console.log("Something went wrong when fetching templates:", l);
46
- } finally {
47
- d.value = !1;
48
- }
49
- }
50
- async function r(l) {
51
- if (!u.value.find((c) => c._id)) {
52
- d.value = !0;
53
- try {
54
- u.value = [
55
- await s.getTemplate(l).then(ke).delayed(1e3)
56
- ];
57
- } catch (c) {
58
- console.log("Something went wrong when fetching templates:", c);
59
- } finally {
60
- d.value = !1;
61
- }
62
- }
63
- }
64
- function i(l, c) {
65
- switch (c = ve(c), l) {
66
- case U.Details:
67
- return o.viewTemplate(c);
68
- case U.Edit:
69
- return o.updateTemplate(c);
70
- case U.Delete:
71
- return o.deleteTemplate(c, d, a);
72
- case U.Duplicate:
73
- return o.duplicateTemplate(c, d, a);
74
- }
75
- }
76
- return {
77
- columnDefs: [
78
- {
79
- id: "_id",
80
- accessorKey: "_id",
81
- header: () => e("inventory.transfer.table.createdAt"),
82
- cell(l) {
83
- return Ye(`${l.getValue()}`);
84
- },
85
- enableSorting: !0
86
- },
87
- {
88
- id: "name",
89
- accessorKey: "name",
90
- header: () => e("inventory.transfer.table.name"),
91
- enableSorting: !0,
92
- size: 200
93
- },
94
- {
95
- id: "supplier",
96
- accessorKey: "purchaseOrder.supplier.name",
97
- header: () => e("inventory.transfer.table.from"),
98
- enableSorting: !0,
99
- size: 200
100
- },
101
- {
102
- id: "noOfItems",
103
- accessorKey: "purchaseOrder.items.length",
104
- header: () => e("inventory.transfer.table.noOfItems"),
105
- enableSorting: !1,
106
- meta: {
107
- width: "10rem",
108
- textAlign: "right"
109
- },
110
- cell(l) {
111
- const c = Number(l.getValue()) || 0, h = l.row.original.purchaseOrder.items.some(De);
112
- return c === 0 || h ? oe("div", { class: "flex justify-end gap-4 items-center" }, [
113
- oe(
114
- ce.FmTooltip,
115
- {},
116
- {
117
- content() {
118
- return h ? "The template is invalid due to invalid unit on some of the items. Please update this template." : "The template is invalid due to deleted ingredients. Please update this template.";
119
- },
120
- default() {
121
- return oe(ce.FmIcon, {
122
- name: "error",
123
- color: "system-error-300",
124
- size: "sm"
125
- });
126
- }
127
- }
128
- ),
129
- c
130
- ]) : c;
131
- }
132
- },
133
- {
134
- id: "enabledLocations",
135
- accessorKey: "purchaseOrder.locations.length",
136
- header: () => "Enabled outlets",
137
- cell(l) {
138
- var h;
139
- const c = (h = l.row.original.locations) == null ? void 0 : h.length;
140
- return c ? `${c}` : "All";
141
- },
142
- enableSorting: !1,
143
- meta: {
144
- width: "10rem",
145
- textAlign: "right"
146
- }
147
- },
148
- {
149
- id: "ref",
150
- accessorKey: "purchaseOrder.ref",
151
- header: () => e("inventory.transfer.table.reference"),
152
- enableSorting: !1,
153
- size: "auto"
154
- },
155
- {
156
- id: "action",
157
- cell(l) {
158
- const c = l.row.original, h = [
159
- ne[U.Details],
160
- ne[U.Edit],
161
- ne[U.Duplicate],
162
- ne[U.Delete]
163
- ];
164
- return ze(h, (b) => i(b, c));
165
- },
166
- enableSorting: !1,
167
- size: 40,
168
- meta: {
169
- cellClass: "",
170
- headerClass: ""
171
- }
172
- }
173
- ],
174
- templates: u,
175
- loading: d,
176
- fetchTemplates: a,
177
- loadTemplate: r
178
- };
179
- }
180
- );
181
- var Se = /* @__PURE__ */ ((n) => (n.Source = "Source", n.Destination = "Destination", n.Ingredient = "Ingredient", n))(Se || {});
182
- const Ee = We(0);
183
- function Ne(n) {
184
- var d;
185
- const e = n.sku;
186
- return {
187
- code: e.code,
188
- overrideCode: n.code,
189
- name: e.name,
190
- unit: ((d = e.unit.measurements.find((u) => u.id === e.trackingMeasurement)) == null ? void 0 : d.abbrev) ?? e.unit.abbrev,
191
- defaultQuantity: +G(n.quantity),
192
- minimumQuantity: +G(n.minimumQuantity ?? Ee),
193
- maximumQuantity: +G(n.maximumQuantity ?? Ee),
194
- quantityStep: +G(n.quantityStep)
195
- };
196
- }
197
- function Re() {
198
- return [
199
- {
200
- id: "code",
201
- name: "Code"
202
- },
203
- {
204
- id: "overrideCode",
205
- name: "Override Code (Optional)"
206
- },
207
- {
208
- id: "name",
209
- name: "Name"
210
- },
211
- {
212
- id: "unit",
213
- name: "Unit"
214
- },
215
- {
216
- id: "defaultQuantity",
217
- name: "Default Quantity"
218
- },
219
- {
220
- id: "minimumQuantity",
221
- name: "Minimum Quantity"
222
- },
223
- {
224
- id: "maximumQuantity",
225
- name: "Maximum Quantity (Optional)"
226
- },
227
- {
228
- id: "quantityStep",
229
- name: "Quantity Step"
230
- }
231
- ];
232
- }
233
- function rt(n) {
234
- var a;
235
- const o = Ie().currentBusiness.value, u = (a = n.map((r) => {
236
- var b;
237
- const i = r.purchaseOrder.items.map((t) => Ne(t)), p = Re(), l = [
238
- ["Template ID", r._id],
239
- ["Template name", r.name],
240
- ["Business name", o == null ? void 0 : o.name],
241
- ["Business ID", o == null ? void 0 : o._id],
242
- ["Menu version", o == null ? void 0 : o.menuVersion],
243
- [
244
- "Purchase/Transfer",
245
- typeof r.purchaseOrder.supplier.internal == "string" ? L.enum.transfer : L.enum.purchase
246
- ],
247
- [
248
- "Transfer from",
249
- `${r.purchaseOrder.supplier.name} (${[
250
- r.purchaseOrder.supplier.internal,
251
- r.purchaseOrder.supplier._id
252
- ].filter((t) => t).join("_")})`
253
- ],
254
- [
255
- "Locations",
256
- ...(b = r.locations) != null && b.length ? r.locations.map((t) => `${t.name} (${t.dbName})`) : ["All"]
257
- ],
258
- ["Reference", r.purchaseOrder.ref ?? ""],
259
- ["Remark", r.purchaseOrder.remark ?? ""],
260
- [],
261
- p.map((t) => t.name),
262
- ...i.map((t) => p.map((S) => t[S.id]))
263
- ], c = p.map((t) => `system:${t.id}`), h = K(l, c);
264
- return { name: r.name, sheet: h };
265
- }).reduce(
266
- (r, i) => {
267
- var l;
268
- const p = i.name.slice(0, 12);
269
- return (l = r.sheetOccurence)[p] ?? (l[p] = 0), r.sheetOccurence[p] += 1, r.sheets[`${p} (${r.sheetOccurence[p]})`] = i.sheet, r;
270
- },
271
- {
272
- sheets: {},
273
- sheetOccurence: {}
274
- }
275
- )) == null ? void 0 : a.sheets, s = `${o == null ? void 0 : o.name} transfer templates (${Je(/* @__PURE__ */ new Date())}).xlsx`, m = Ce(u);
276
- return Oe(m, s), s;
277
- }
278
- function nt() {
279
- const n = Ie(), e = ge(), o = ie(), d = X(), u = n.currentBusiness.value, s = Ne({
280
- sku: {
281
- unit: {
282
- _id: "",
283
- name: "Unit",
284
- abbrev: "Unit",
285
- precision: 0,
286
- measurements: []
287
- },
288
- code: "ING001",
289
- _id: "",
290
- name: "Sugar"
291
- },
292
- code: "ING001 (override optional)",
293
- name: "Sugar",
294
- quantity: {
295
- amount: 1,
296
- precision: 0
297
- },
298
- quantityStep: {
299
- amount: 1,
300
- precision: 0
301
- },
302
- minimumQuantity: {
303
- amount: 1,
304
- precision: 0
305
- },
306
- maximumQuantity: {
307
- amount: 1,
308
- precision: 0
309
- }
310
- }), m = Re(), a = [
311
- ["Template ID (leave empty to create new)"],
312
- ["Template Name", "New template"],
313
- ["Business name", u == null ? void 0 : u.name],
314
- ["Business ID", u == null ? void 0 : u._id],
315
- ["Menu version", u == null ? void 0 : u.menuVersion],
316
- ["Purchase/Transfer", "Purchase"],
317
- [
318
- "Transfer from",
319
- "Example supplier (supplier_xxx)",
320
- "Refer to sources list & copy whole cell."
321
- ],
322
- [
323
- "Location codes (leave empty to enable all)",
324
- "Example outlet (restaurant_xxx)",
325
- "Example outlet 2 (restaurant_xxx)"
326
- ],
327
- ["Reference"],
328
- ["Remark"],
329
- [],
330
- m.map((t) => t.name),
331
- m.map((t) => s[t.id])
332
- ], r = m.map((t) => `system:${t.id}`), i = K(a, r), p = K(
333
- [
334
- ...e.businessSuppliers.map((t) => [
335
- `${t.name} (${t._id})`,
336
- "Purchase",
337
- t.address.line1,
338
- t.address.line2,
339
- t.address.city,
340
- t.address.postcode,
341
- t.address.state,
342
- t.address.country
343
- ]),
344
- ...o.locations.map((t) => {
345
- var S, E, w, f, v, _;
346
- return [
347
- `${t.name} (${t.dbName})`,
348
- "Transfer",
349
- (S = t.doc.profile.address) == null ? void 0 : S.line1,
350
- (E = t.doc.profile.address) == null ? void 0 : E.line2,
351
- (w = t.doc.profile.address) == null ? void 0 : w.city,
352
- (f = t.doc.profile.address) == null ? void 0 : f.postcode,
353
- (v = t.doc.profile.address) == null ? void 0 : v.state,
354
- (_ = t.doc.profile.address) == null ? void 0 : _.country
355
- ];
356
- })
357
- ],
358
- ["Name", "Type", "Line 1", "Line 2", "City", "Postal", "State", "Country"]
359
- ), l = K(
360
- o.locations.map((t) => {
361
- var S, E, w, f, v, _;
362
- return [
363
- `${t.name} (${t.dbName})`,
364
- (S = t.doc.profile.address) == null ? void 0 : S.line1,
365
- (E = t.doc.profile.address) == null ? void 0 : E.line2,
366
- (w = t.doc.profile.address) == null ? void 0 : w.city,
367
- (f = t.doc.profile.address) == null ? void 0 : f.postcode,
368
- (v = t.doc.profile.address) == null ? void 0 : v.state,
369
- (_ = t.doc.profile.address) == null ? void 0 : _.country
370
- ];
371
- }),
372
- ["Name", "Line 1", "Line 2", "City", "Postal", "State", "Country"]
373
- ), c = K(
374
- d.skus.map((t) => [
375
- t.code,
376
- t.name,
377
- t.unit.abbrev,
378
- ...t.unit.measurements.map((S) => S.abbrev)
379
- ]),
380
- ["Code", "Name", "Base unit", "Measurements"]
381
- ), h = Ce({
382
- Template: i,
383
- Source: p,
384
- Destination: l,
385
- Ingredient: c
386
- }), b = `${u == null ? void 0 : u.name} transfer templates import.xlsx`;
387
- return Oe(h, b), b;
388
- }
389
- function ot(n, e) {
390
- const o = new Array(), d = /(.*) \(((supplier_|warehouse_|restaurant_).{24,})\)/, s = ie().locationByDbName, a = ge().supplierById, r = n.trim(), i = d.exec(r);
391
- if (!i)
392
- return o.push(`Transfer from location value of ${r} cannot be read.`), {
393
- errors: o
394
- };
395
- const p = i[1], l = i[2];
396
- let c;
397
- if (l.startsWith("supplier"))
398
- c = a[l], e !== L.enum.purchase && o.push(`Expected transfer type Purchase but found ${e} instead.`);
399
- else {
400
- const h = s[l];
401
- if (!h)
402
- return o.push(`Location (${p}) of id ${l} is not found.`), {
403
- errors: o
404
- };
405
- p !== h.name && o.push(
406
- `Location id ${l} has non-matching name. Found ${p} but expected ${h.name}`
407
- ), c = {
408
- _id: h.doc._id,
409
- name: h.name,
410
- address: h.doc.profile.address ?? {
411
- line1: "",
412
- state: "",
413
- country: "",
414
- city: "",
415
- postcode: "",
416
- coordinates: [0, 0]
417
- },
418
- internal: l.split("_")[0] === "restaurant" ? _e.enum.restaurant : _e.enum.warehouse,
419
- phoneNumber: h.doc.profile.phoneNo ?? "",
420
- email: h.doc.profile.email ?? "",
421
- _rev: "",
422
- contactName: h.doc.profile.name ?? "",
423
- registrationNumber: h.doc.profile.regNo ?? ""
424
- };
425
- }
426
- return {
427
- from: c,
428
- errors: o
429
- };
430
- }
431
- function at(n) {
432
- if (!n.length || `${n[0]}`.toLocaleLowerCase() === "all")
433
- return [];
434
- const e = /(.*) \(((warehouse_|restaurant_).{24,})\)/, d = ie().locationByDbName;
435
- return n.map((u) => {
436
- const s = new Array(), m = u.trim(), a = e.exec(m);
437
- if (!a)
438
- return s.push(`Enabled location value of ${m} cannot be read.`), {
439
- errors: s
440
- };
441
- const r = a[1], i = a[2], p = d[i];
442
- return p ? (r !== p.name && s.push(
443
- `Location id ${i} has non-matching name. Found ${r} but expected ${p.name}`
444
- ), {
445
- errors: s,
446
- location: p
447
- }) : (s.push(`Location (${r}) of id ${i} is not found.`), {
448
- errors: s
449
- });
450
- });
451
- }
452
- function st(n) {
453
- const [
454
- e,
455
- o,
456
- d,
457
- u,
458
- s,
459
- m,
460
- a,
461
- r,
462
- i,
463
- p,
464
- l
465
- ] = Ae(n);
466
- return {
467
- id: `${o[1] ?? ""}`.trim(),
468
- name: `${d[1] ?? ""}`.trim(),
469
- type: `${a[1] ?? ""}`.trim().toLocaleLowerCase() === "transfer" ? L.enum.transfer : L.enum.purchase,
470
- transferFrom: `${r[1] ?? ""}`.trim(),
471
- locations: i.slice(1).map((c) => `${c}`.trim()).filter((c) => c),
472
- reference: `${p[1] ?? ""}`.trim(),
473
- remark: `${l[1] ?? ""}`.trim()
474
- };
475
- }
476
- function it(n) {
477
- const [
478
- e,
479
- o,
480
- d,
481
- u,
482
- s,
483
- m,
484
- a,
485
- r,
486
- i,
487
- p,
488
- l,
489
- c,
490
- h,
491
- ...b
492
- ] = Ae(n);
493
- if (!e || !e.length || e.some((f) => f.length && !f.startsWith("system:")))
494
- throw new Error("Missing meta header. Excel file does not come from the template.");
495
- const t = e.map((f) => f.split(":")[1]), E = [
496
- "code",
497
- "name",
498
- "unit",
499
- "defaultQuantity",
500
- "minimumQuantity",
501
- "maximumQuantity",
502
- "quantityStep"
503
- ].filter((f) => !t.includes(f));
504
- if (E.length)
505
- throw new Error(
506
- `Missing meta headers (${E.join()}). Excel file does not come from the template.`
507
- );
508
- return b.map((f, v) => {
509
- const _ = {};
510
- for (const y in t) {
511
- const x = t[y];
512
- Object.assign(_, { [x]: f[y] });
513
- }
514
- return {
515
- index: v,
516
- data: _
517
- };
518
- });
519
- }
520
- function lt(n, e, o) {
521
- const d = n === "" ? null : se(n, o), u = e === "" ? null : se(e, o), s = d && u && d.amount > u.amount;
522
- return {
523
- min: d,
524
- max: u,
525
- compareError: s ? "Minimum amount must be less than or equal to maximum amount" : void 0
526
- };
527
- }
528
- function ut(n, e, o) {
529
- const d = X(), u = Te(), s = d.skuByCode[n.code], m = new Array();
530
- if (!s)
531
- return m.push(`Cannot find ingredient with code (${n.code}) ${n.name}.`), {
532
- index: e,
533
- errors: m
534
- };
535
- if (o.filter((f) => f.data.code === n.code).length > 1)
536
- return m.push(`Ingredient ${n.code} is defined twice.`), {
537
- index: e,
538
- errors: m
539
- };
540
- const a = s.unit, r = a == null ? void 0 : a.measurements.find((f) => f.abbrev === n.unit);
541
- if (a.abbrev !== n.unit && !r) {
542
- const f = `Cannot find unit measurement of symbol ${n.unit || "[empty]"} for ingredient (${n.code}) ${n.name}.`;
543
- m.push(f);
544
- const v = {
545
- sku: s,
546
- code: n.overrideCode || s.code,
547
- name: s.name,
548
- measurement: r,
549
- quantity: { amount: 0, precision: 0 },
550
- quantityStep: { amount: 0, precision: 0 },
551
- minimumQuantity: { amount: 0, precision: 0 },
552
- maximumQuantity: { amount: 0, precision: 0 }
553
- };
554
- if (u.isEnabled) {
555
- const _ = u.getItemCustomCode(s);
556
- _ && (v.code = _);
557
- }
558
- return {
559
- index: e,
560
- errors: m,
561
- templateItem: v
562
- };
563
- }
564
- const i = se(
565
- n.quantityStep,
566
- ue(a, r)
567
- );
568
- (Number.isNaN(Number(n.quantityStep)) || Number(n.quantityStep) <= 0) && m.push("Amount step must be more than 0");
569
- const p = Ze(i), l = lt(
570
- n.minimumQuantity,
571
- n.maximumQuantity,
572
- ue(a, r)
573
- ), c = l.min, h = l.max;
574
- l.compareError && m.push(l.compareError);
575
- const b = Xe(+n.minimumQuantity, +n.maximumQuantity), t = se(
576
- n.defaultQuantity,
577
- ue(a, r)
578
- ), S = p(t);
579
- typeof S == "string" && m.push(`Default amount: ${S}`);
580
- const E = l.min && l.max ? b(`${n.defaultQuantity}`) : null;
581
- typeof E == "string" && m.push(`Default amount: ${E}`);
582
- const w = {
583
- sku: s,
584
- code: n.overrideCode || s.code,
585
- name: n.name || s.name,
586
- measurement: r,
587
- quantity: t,
588
- quantityStep: i,
589
- minimumQuantity: c,
590
- maximumQuantity: h
591
- };
592
- return {
593
- index: e,
594
- errors: m,
595
- templateItem: w
596
- };
597
- }
598
- function ct(n) {
599
- const e = n.SheetNames.filter(
600
- (s) => !Object.values(Se).map(String).includes(s)
601
- ), d = be().templates, u = qe(d, "_id");
602
- try {
603
- return e.reduce(
604
- (s, m) => {
605
- var f;
606
- const a = new Array(), r = n.Sheets[m], i = st(r), p = ot(i.transferFrom, i.type);
607
- a.push(...p.errors);
608
- const l = p.from, c = at(i.locations), h = c.filter((v) => v.location).map((v) => v.location);
609
- a.push(...c.flatMap((v) => v.errors));
610
- const b = it(r).filter((v) => v.data.code), t = b.map(
611
- (v, _) => ut(v.data, _, b)
612
- );
613
- a.push(
614
- ...t.flatMap(
615
- (v) => v.errors.map((_) => `(Excel row ${v.index + 14}) ${_}`)
616
- )
617
- );
618
- const S = t.filter((v) => v.templateItem).map((v) => v.templateItem);
619
- if (i.id) {
620
- const v = u[i.id];
621
- if (!v) {
622
- const y = {
623
- _id: i.id,
624
- _rev: "",
625
- name: i.name || `(unnamed from sheet ${m || "<unnamed sheet>"})`,
626
- purchaseOrder: mt()
627
- };
628
- return a.push(`Template ID ${i.id} is not found.`), s.importUpdateResult.push({
629
- type: "update",
630
- original: y,
631
- template: y,
632
- excelSheetName: m,
633
- errors: a
634
- }), s;
635
- }
636
- const _ = {
637
- type: "update",
638
- original: v,
639
- template: {
640
- ...v,
641
- name: i.name,
642
- locations: h.length ? h : null,
643
- purchaseOrder: {
644
- ...v.purchaseOrder,
645
- supplier: l ?? ((f = v.purchaseOrder) == null ? void 0 : f.supplier),
646
- ref: i.reference,
647
- remark: i.remark,
648
- items: S
649
- }
650
- },
651
- excelSheetName: m,
652
- errors: a
653
- };
654
- return s.importUpdateResult.push(_), s;
655
- }
656
- const w = {
657
- type: "create",
658
- template: {
659
- name: i.name,
660
- locations: h.length ? h : null,
661
- purchaseOrder: {
662
- supplier: l ?? Fe(),
663
- ref: i.reference,
664
- remark: i.remark,
665
- items: S
666
- }
667
- },
668
- excelSheetName: m,
669
- errors: a
670
- };
671
- return s.importCreateResult.push(w), s;
672
- },
673
- {
674
- invalidExcel: !1,
675
- importCreateResult: new Array(),
676
- importUpdateResult: new Array()
677
- }
678
- );
679
- } catch (s) {
680
- return {
681
- invalidExcel: !0,
682
- invalidExcelMessage: (s == null ? void 0 : s.message) ?? "Invalid excel",
683
- importCreateResult: [],
684
- importUpdateResult: []
685
- };
686
- }
687
- }
688
- function Fe() {
689
- return {
690
- _id: "",
691
- name: "",
692
- address: {
693
- line2: void 0,
694
- line1: "",
695
- state: "",
696
- city: "",
697
- postcode: "",
698
- country: ""
699
- }
700
- };
701
- }
702
- function mt() {
703
- return {
704
- remark: void 0,
705
- ref: void 0,
706
- items: [],
707
- supplier: Fe()
708
- };
709
- }
710
- const dt = { class: "flex items-center gap-12 pl-8" }, pt = { class: "flex flex-col" }, ft = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary flex items-center gap-4" }, yt = { class: "text-fm-color-typo-secondary fm-typo-en-body-md-400" }, vt = {
711
- key: 0,
712
- class: "text-fm-color-typo-secondary fm-typo-en-body-sm-400"
713
- }, ht = { key: 0 }, $e = /* @__PURE__ */ ye({
714
- __name: "TransferTemplateImportItem",
715
- props: {
716
- type: {},
717
- name: {},
718
- transferType: {},
719
- locations: {},
720
- items: {},
721
- errors: {}
722
- },
723
- setup(n) {
724
- return (e, o) => {
725
- var s, m, a;
726
- const d = W("FmIcon"), u = W("FmTooltip");
727
- return O(), F("div", dt, [
728
- o[0] || (o[0] = N("div", null, "•", -1)),
729
- N("div", pt, [
730
- N("div", ft, [
731
- N("div", {
732
- class: J({
733
- "text-fm-color-system-error-300": e.errors.length
734
- })
735
- }, [
736
- Be(q(e.name) + " ", 1),
737
- N("span", yt, " (" + q(B(Ve)(`${e.transferType}`)) + ") ", 1),
738
- e.type === "create" ? (O(), F("span", vt, "(new)")) : Z("", !0)
739
- ], 2),
740
- e.errors.length ? (O(), F("div", ht, [
741
- j(u, { "z-index": 50 }, {
742
- content: me(() => [
743
- N("ol", null, [
744
- (O(!0), F(Y, null, ae(e.errors, (r, i) => (O(), F("li", { key: i }, q(r), 1))), 128))
745
- ])
746
- ]),
747
- default: me(() => [
748
- j(d, {
749
- name: "error",
750
- size: "sm",
751
- color: "system-error-300"
752
- })
753
- ]),
754
- _: 1
755
- })
756
- ])) : Z("", !0)
757
- ]),
758
- N("div", {
759
- class: J([
760
- "fm-typo-en-body-sm-400",
761
- {
762
- "text-fm-color-system-error-200": e.errors.length,
763
- "text-fm-color-typo-secondary": !e.errors.length
764
- }
765
- ])
766
- }, q((s = e.locations) != null && s.length ? `${(m = e.locations) == null ? void 0 : m.length} locations` : "All locations") + ", " + q(`${(a = e.items) == null ? void 0 : a.length} items`), 3)
767
- ])
768
- ]);
769
- };
770
- }
771
- }), gt = { class: "flex flex-col gap-24" }, Tt = {
772
- key: 0,
773
- class: "flex items-center gap-8"
774
- }, bt = { class: "flex flex-col gap-8" }, St = { class: "line-clamp-2 text-ellipsis break-all" }, xt = {
775
- key: 2,
776
- class: "shrink-0"
777
- }, _t = {
778
- key: 0,
779
- class: "flex flex-col"
780
- }, wt = { class: "text-fm-color-system-error-300 fm-typo-en-body-sm-400" }, kt = {
781
- key: 0,
782
- class: "max-h-[200px] overflow-y-auto flex flex-col gap-8"
783
- }, Et = { class: "fm-typo-en-body-lg-600" }, $t = /* @__PURE__ */ ye({
784
- __name: "TransferTemplateImport",
785
- setup(n) {
786
- const e = I(null), o = Pe(), d = de(), u = I(!1), s = I(!1), m = ge();
787
- Le(async () => {
788
- s.value = !0;
789
- try {
790
- await m.readSuppliers().delayed(1e3);
791
- } catch {
792
- d.open({
793
- title: "Something went wrong.",
794
- message: "Error at reading suppliers list. Please try again.",
795
- type: "error"
796
- });
797
- } finally {
798
- s.value = !1;
799
- }
800
- });
801
- const a = I(new Array()), r = I([]), i = I([]), p = H(
802
- () => !!a.value.length || r.value.some((b) => b.errors.length) || i.value.some((b) => b.errors.length)
803
- ), l = H(
804
- () => !!r.value.length || !!i.value.length
805
- ), { t: c } = he();
806
- async function h(b) {
807
- a.value = [], r.value = [], i.value = [];
808
- try {
809
- u.value = !0;
810
- const [t] = await Promise.all([
811
- Ke(b),
812
- // fake buffer
813
- new Promise((f) => setTimeout(f, 1e3))
814
- ]);
815
- if (!t.SheetNames.filter(
816
- (f) => !Object.values(Se).map(String).includes(f)
817
- ).find((f) => f)) {
818
- a.value.push(c("inventory.ingredient.import.fileError.noSheet"));
819
- return;
820
- }
821
- const w = ct(t);
822
- if (w.invalidExcel) {
823
- a.value.push(
824
- w.invalidExcelMessage ?? c("inventory.ingredient.import.fileError.invalidExcel")
825
- );
826
- return;
827
- }
828
- if (r.value = w.importCreateResult, i.value = w.importUpdateResult, !r.value.length && !i.value.length) {
829
- a.value.push(c("inventory.ingredient.import.fileError.noData"));
830
- return;
831
- }
832
- o.emitData(w);
833
- } catch (t) {
834
- d.open({
835
- title: c("inventory.ingredient.import.fileError.unableToRead"),
836
- message: t == null ? void 0 : t.message,
837
- type: "error"
838
- }), console.error("Error in reading file", t);
839
- } finally {
840
- a.value.length && d.open({
841
- title: c("inventory.ingredient.import.fileError.invalidExcel"),
842
- type: "error"
843
- }), u.value = !1;
844
- }
845
- }
846
- return Qe(e, (b) => {
847
- b && h(b);
848
- }), (b, t) => {
849
- const S = W("FmCircularProgress"), E = W("FmIcon"), w = W("FmButton");
850
- return O(), F("div", gt, [
851
- t[2] || (t[2] = N("div", { class: "fm-typo-en-body-md-400" }, "Import transfer templates from excel sheets.", -1)),
852
- s.value ? (O(), F("div", Tt, [
853
- N("div", null, [
854
- j(S, {
855
- size: "md",
856
- color: "neutral-gray-200"
857
- })
858
- ]),
859
- t[1] || (t[1] = N("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "Loading...", -1))
860
- ])) : (O(), F(Y, { key: 1 }, [
861
- j(Ge, {
862
- class: J({
863
- "w-full": !0,
864
- "h-[200px]": !e.value
865
- }),
866
- accept: ".xlsx",
867
- onFileUpload: t[0] || (t[0] = (f) => e.value = f),
868
- label: B(c)("inventory.ingredient.import.uploadTemplate"),
869
- "button-label": B(c)("inventory.ingredient.import.selectFile")
870
- }, Ue({ _: 2 }, [
871
- e.value ? {
872
- name: "default",
873
- fn: me(({ openFileDialog: f }) => [
874
- N("div", bt, [
875
- N("div", {
876
- class: J([
877
- "fm-corner-radius-md p-16 flex items-center gap-16",
878
- {
879
- "border border-fm-color-neutral-gray-100": u.value,
880
- "border border-fm-color-neutral-gray-200": !u.value && !p.value,
881
- "border border-fm-color-system-error-200": p.value
882
- }
883
- ])
884
- }, [
885
- u.value ? (O(), re(S, {
886
- key: 0,
887
- size: "md",
888
- color: "neutral-gray-200"
889
- })) : (O(), re(E, {
890
- key: 1,
891
- name: p.value ? "error" : "attach_file",
892
- outline: "",
893
- color: p.value ? "system-error-300" : void 0
894
- }, null, 8, ["name", "color"])),
895
- N("div", {
896
- class: J([
897
- "fm-typo-en-body-md-400 flex-1 h-[36px] flex items-center",
898
- {
899
- "text-fm-color-typo-disabled": u.value,
900
- "text-fm-color-typo-primary": !u.value
901
- }
902
- ])
903
- }, [
904
- N("div", St, q(e.value.name), 1)
905
- ], 2),
906
- u.value ? Z("", !0) : (O(), F("div", xt, [
907
- j(w, {
908
- label: B(c)("inventory.ingredient.import.replaceFile"),
909
- variant: p.value ? "destructive" : "secondary",
910
- "prepend-icon": p.value ? void 0 : "autorenew",
911
- onClick: f
912
- }, null, 8, ["label", "variant", "prepend-icon", "onClick"])
913
- ]))
914
- ], 2),
915
- a.value.length ? (O(), F("div", _t, [
916
- (O(!0), F(Y, null, ae(a.value, (v, _) => (O(), F("div", {
917
- key: _,
918
- class: "flex gap-8 items-center"
919
- }, [
920
- j(E, {
921
- name: "error",
922
- size: "sm",
923
- color: "system-error-300"
924
- }),
925
- N("div", wt, q(v), 1)
926
- ]))), 128))
927
- ])) : Z("", !0)
928
- ])
929
- ]),
930
- key: "0"
931
- } : void 0
932
- ]), 1032, ["class", "label", "button-label"]),
933
- l.value ? (O(), F("div", kt, [
934
- N("div", Et, q(B(c)("inventory.ingredient.import.summary")), 1),
935
- (O(!0), F(Y, null, ae(r.value, (f, v) => (O(), re($e, {
936
- key: v,
937
- name: f.template.name,
938
- "transfer-type": typeof f.template.purchaseOrder.supplier.internal == "string" ? B(L).enum.transfer : B(L).enum.purchase,
939
- locations: f.template.locations,
940
- items: f.template.purchaseOrder.items,
941
- errors: f.errors,
942
- type: "create"
943
- }, null, 8, ["name", "transfer-type", "locations", "items", "errors"]))), 128)),
944
- (O(!0), F(Y, null, ae(i.value, (f) => (O(), re($e, {
945
- key: f.template._id,
946
- name: f.template.name,
947
- "transfer-type": typeof f.template.purchaseOrder.supplier.internal == "string" ? B(L).enum.transfer : B(L).enum.purchase,
948
- locations: f.template.locations,
949
- items: f.template.purchaseOrder.items,
950
- errors: f.errors,
951
- type: "update"
952
- }, null, 8, ["name", "transfer-type", "locations", "items", "errors"]))), 128))
953
- ])) : Z("", !0)
954
- ], 64))
955
- ]);
956
- };
957
- }
958
- });
959
- function It(n) {
960
- var s, m;
961
- const e = Te();
962
- if (!e.isEnabled) return !0;
963
- if (!n.internal) {
964
- const a = e.getNetSuiteVendor(n._id), r = a == null ? void 0 : a.subsidiaryId, i = (s = e.currentVendorSubsidiary(n._id)) == null ? void 0 : s.id;
965
- return r && r == i;
966
- }
967
- const o = e.getNetSuiteLocation(`${n.internal}_${n._id}`), d = e.getLocationSubsidiary(o == null ? void 0 : o.netSuiteId).id, u = (m = e.currentLocationSubsidiary()) == null ? void 0 : m.id;
968
- return d && d == u;
969
- }
970
- const Ct = {
971
- code: ["code"],
972
- name: ["name"],
973
- defaultAmount: ["quantity", "measurement"],
974
- step: ["quantityStep"],
975
- limit: ["minimumQuantity", "maximumQuantity"]
976
- }, Ot = pe(
977
- "templateItemBulkEditor",
978
- function() {
979
- const { t: e } = tt(), o = de(), d = be(), u = fe(), s = I(!1), m = I(1), a = I(null), r = I([]), i = I({}), p = I(/* @__PURE__ */ new Set()), l = I([]), c = I(!1), h = I(/* @__PURE__ */ new Map()), b = I(/* @__PURE__ */ new Set()), t = H(() => {
980
- if (!a.value) return [];
981
- const T = a.value._id;
982
- return d.templates.filter(
983
- (C) => C.purchaseOrder.items.some(($) => $.sku._id === T)
984
- );
985
- }), S = H(
986
- () => t.value.filter((T) => r.value.includes(T._id))
987
- ), E = H(
988
- () => a.value !== null && t.value.length > 0 && r.value.length > 0
989
- ), w = H(() => {
990
- if (p.value.size === 0) return !1;
991
- const T = i.value;
992
- return !(p.value.has("code") && (!T.code || T.code.trim().length === 0) || p.value.has("name") && (!T.name || T.name.trim().length === 0) || p.value.has("defaultAmount") && T.quantity == null || p.value.has("step") && T.quantityStep == null);
993
- }), f = H(() => {
994
- if (!a.value) return [];
995
- const T = a.value._id;
996
- return S.value.map((C) => {
997
- const $ = JSON.parse(JSON.stringify(C));
998
- return $.purchaseOrder.items = $.purchaseOrder.items.map((k) => {
999
- if (k.sku._id !== T) return k;
1000
- const P = {};
1001
- for (const z of p.value)
1002
- for (const ee of Ct[z])
1003
- P[ee] = i.value[ee];
1004
- return { ...k, ...P };
1005
- }), $;
1006
- });
1007
- });
1008
- function v() {
1009
- y(), s.value = !0;
1010
- }
1011
- function _() {
1012
- s.value = !1;
1013
- }
1014
- function y() {
1015
- m.value = 1, a.value = null, r.value = [], i.value = {}, p.value = /* @__PURE__ */ new Set(), l.value = [], c.value = !1, h.value = /* @__PURE__ */ new Map(), b.value = /* @__PURE__ */ new Set();
1016
- }
1017
- function x() {
1018
- if (!a.value) return;
1019
- const T = a.value._id, C = S.value[0] ?? t.value[0];
1020
- if (C) {
1021
- const $ = C.purchaseOrder.items.find((k) => k.sku._id === T);
1022
- $ && (i.value = { ...$ });
1023
- }
1024
- m.value = 2;
1025
- }
1026
- function R() {
1027
- l.value = JSON.parse(JSON.stringify(f.value)), m.value = 3;
1028
- }
1029
- function A() {
1030
- m.value === 3 ? (l.value = [], m.value = 2) : m.value === 2 && (m.value = 1);
1031
- }
1032
- async function D() {
1033
- if (!c.value) {
1034
- c.value = !0, h.value = /* @__PURE__ */ new Map();
1035
- try {
1036
- const T = l.value.filter(
1037
- (k) => !b.value.has(k._id)
1038
- ), C = await Promise.allSettled(
1039
- T.map((k) => u.updateTemplate(k))
1040
- ), $ = /* @__PURE__ */ new Map();
1041
- C.forEach((k, P) => {
1042
- if (k.status === "rejected") {
1043
- const z = T[P], ee = k.reason instanceof Error ? k.reason.message : String(k.reason ?? "Unknown error");
1044
- $.set(z._id, ee);
1045
- } else
1046
- b.value = /* @__PURE__ */ new Set([...b.value, T[P]._id]);
1047
- }), $.size > 0 ? (h.value = $, await d.fetchTemplates(), l.value = l.value.map((k) => {
1048
- if (!$.has(k._id)) return k;
1049
- const P = d.templates.find((z) => z._id === k._id);
1050
- return P ? { ...k, _rev: P._rev } : k;
1051
- }), o.open({
1052
- title: e("inventory.transfer.template.bulkEditor.save.partialErrorTitle"),
1053
- message: e("inventory.transfer.template.bulkEditor.save.partialErrorMessage", {
1054
- failed: $.size,
1055
- total: l.value.length
1056
- }),
1057
- type: "warning"
1058
- })) : (o.open({
1059
- title: e("inventory.transfer.template.bulkEditor.save.successTitle"),
1060
- message: e("inventory.transfer.template.bulkEditor.save.successMessage", {
1061
- count: l.value.length
1062
- }, l.value.length),
1063
- type: "success"
1064
- }), s.value = !1, y(), await d.fetchTemplates());
1065
- } catch (T) {
1066
- o.open({
1067
- title: e("inventory.transfer.template.bulkEditor.save.errorTitle"),
1068
- message: e("inventory.transfer.template.bulkEditor.save.errorMessage"),
1069
- type: "error"
1070
- }), console.error("templateItemBulkEditor.confirmAndApply failed", T);
1071
- } finally {
1072
- c.value = !1;
1073
- }
1074
- }
1075
- }
1076
- function g(T) {
1077
- const C = new Set(p.value);
1078
- C.has(T) ? C.delete(T) : C.add(T), p.value = C;
1079
- }
1080
- function M(T) {
1081
- const C = new Set(p.value);
1082
- for (const $ of T) C.add($);
1083
- p.value = C;
1084
- }
1085
- function Q(T) {
1086
- r.value.indexOf(T) === -1 ? r.value = [...r.value, T] : r.value = r.value.filter(($) => $ !== T);
1087
- }
1088
- function V() {
1089
- r.value = t.value.map((T) => T._id);
1090
- }
1091
- function le() {
1092
- r.value = [];
1093
- }
1094
- return {
1095
- // state
1096
- show: s,
1097
- currentStep: m,
1098
- selectedSku: a,
1099
- selectedTemplateIds: r,
1100
- editedItem: i,
1101
- selectedFields: p,
1102
- reviewPayloads: l,
1103
- isSaving: c,
1104
- applyErrors: h,
1105
- succeededIds: b,
1106
- // computed
1107
- candidateTemplates: t,
1108
- selectedTemplates: S,
1109
- canGoToStep2: E,
1110
- canGoToStep3: w,
1111
- previewPayloads: f,
1112
- // actions
1113
- openDialog: v,
1114
- closeDialog: _,
1115
- reset: y,
1116
- goToStep2: x,
1117
- goToStep3: R,
1118
- back: A,
1119
- confirmAndApply: D,
1120
- toggleField: g,
1121
- autoSelectFields: M,
1122
- toggleTemplate: Q,
1123
- selectAllTemplates: V,
1124
- deselectAllTemplates: le
1125
- };
1126
- }
1127
- ), At = pe("transferTemplateActions", () => {
1128
- const n = Me(), e = de(), o = ie(), d = be(), u = et(), s = fe(), m = Te(), a = He(), { t: r } = he(), i = I({}), p = Ot();
1129
- function l() {
1130
- p.openDialog();
1131
- }
1132
- function c() {
1133
- i.value = {
1134
- mode: xe.CREATE,
1135
- show: !0,
1136
- "onUpdate:show"(y) {
1137
- i.value.show = y;
1138
- }
1139
- };
1140
- }
1141
- function h(y) {
1142
- i.value = {
1143
- mode: xe.UPDATE,
1144
- modelValue: y,
1145
- show: !0,
1146
- "onUpdate:show"(x) {
1147
- i.value.show = x;
1148
- }
1149
- };
1150
- }
1151
- function b(y, x, R) {
1152
- n.open({
1153
- title: `Confirm deleting template ${y.name}?`,
1154
- message: "Deleted template can no longer be retrieved",
1155
- primaryActions: {
1156
- text: "Delete",
1157
- variant: te.Destructive,
1158
- close: !0
1159
- },
1160
- secondaryActions: {
1161
- text: "Cancel",
1162
- variant: te.Plain,
1163
- close: !0
1164
- }
1165
- }).onPrimary(async () => {
1166
- e.open({
1167
- title: `Deleting ${y.name}`,
1168
- type: "info"
1169
- });
1170
- try {
1171
- x.value = !0;
1172
- const [A] = await Promise.allSettled([
1173
- s.deleteTemplate(y),
1174
- new Promise((D) => setTimeout(D, 1e3))
1175
- ]);
1176
- if (A.status === "rejected") throw A.reason;
1177
- e.open({
1178
- title: `Deleted ${y.name}`,
1179
- type: "success"
1180
- });
1181
- } catch (A) {
1182
- e.open({
1183
- title: `Unable to delete ${y.name}`,
1184
- message: `See error from server: ${A}`,
1185
- type: "error"
1186
- }), console.error("error on deleting purchase order template", A);
1187
- } finally {
1188
- x.value = !1, R();
1189
- }
1190
- });
1191
- }
1192
- function t(y, x, R) {
1193
- let A;
1194
- n.open({
1195
- title: `Confirm duplicating template "${y.name}"?`,
1196
- message: "Duplicated template can be edited and used independently",
1197
- primaryActions: {
1198
- text: "Duplicate",
1199
- variant: te.Destructive,
1200
- close: !0
1201
- },
1202
- secondaryActions: {
1203
- text: "Cancel",
1204
- variant: te.Plain,
1205
- close: !0
1206
- },
1207
- contentComponent: ye({
1208
- props: ["modelValue"],
1209
- emits: ["update:modelValue"],
1210
- setup(D) {
1211
- return () => oe(ce.FmTextField, {
1212
- modelValue: D.modelValue,
1213
- "onUpdate:modelValue": (g) => A = g,
1214
- label: "New Template Name",
1215
- size: "md",
1216
- variant: "primary"
1217
- });
1218
- }
1219
- })
1220
- }).onPrimary(async () => {
1221
- e.open({
1222
- title: `Duplicating ${y.name}`,
1223
- type: "info"
1224
- });
1225
- try {
1226
- x.value = !0;
1227
- const [D] = await Promise.allSettled([
1228
- u.duplicatePurchaseOrderTemplate(y._id, A),
1229
- new Promise((g) => setTimeout(g, 1e3))
1230
- ]);
1231
- if (D.status === "rejected") throw D.reason;
1232
- e.open({
1233
- title: `Duplicated ${y.name}`,
1234
- type: "success"
1235
- });
1236
- } catch (D) {
1237
- e.open({
1238
- title: `Unable to duplicate ${y.name}`,
1239
- message: `See error from server: ${D}`,
1240
- type: "error"
1241
- }), console.error("error on duplicating purchase order template", D);
1242
- } finally {
1243
- x.value = !1, R();
1244
- }
1245
- });
1246
- }
1247
- const S = I({});
1248
- function E(y) {
1249
- S.value = {
1250
- template: y,
1251
- show: !0,
1252
- "onUpdate:show"(x) {
1253
- S.value.show = x;
1254
- },
1255
- "onAction:edit"() {
1256
- S.value.show = !1, h(ve(y));
1257
- }
1258
- };
1259
- }
1260
- function w() {
1261
- const { promise: y, resolve: x } = Promise.withResolvers(), R = (g) => {
1262
- x(g);
1263
- }, A = d.templates.filter((g) => {
1264
- var M, Q;
1265
- return ((M = g.purchaseOrder.supplier) == null ? void 0 : M._id) === o.currentLocation.doc._id ? !1 : (Q = g.locations) != null && Q.length ? g.locations.find((V) => V.doc._id === o.currentLocation.doc._id) : !0;
1266
- });
1267
- if (!A.length)
1268
- return n.open({
1269
- title: "Select one template",
1270
- message: "There is no available template in your business. Configure a new template?",
1271
- primaryActions: {
1272
- text: "Go to templates",
1273
- close: !0
1274
- },
1275
- secondaryActions: {
1276
- text: "Close",
1277
- close: !0
1278
- }
1279
- }).onPrimary(() => {
1280
- a.push({ name: we.TRANSFER_TEMPLATE }), R(void 0);
1281
- }).onSecondary(() => R(void 0)).onClose(() => R(void 0)), y;
1282
- const D = A.map((g) => {
1283
- var P;
1284
- const M = !g.purchaseOrder.items.length || g.purchaseOrder.items.some(De), Q = !It(g.purchaseOrder.supplier), V = g.purchaseOrder.supplier.internal ? m.getNetSuiteLocation(
1285
- `${g.purchaseOrder.supplier.internal}_${g.purchaseOrder.supplier._id}`
1286
- ) : m.getNetSuiteVendor(g.purchaseOrder.supplier._id), le = Q ? `The subsidiary of the request
1287
- location is ${(P = m.getLocationSubsidiary(V == null ? void 0 : V.netSuiteId)) == null ? void 0 : P.fullName}.` : void 0, T = M || Q, C = M ? "This template is invalid. Update this template." : Q ? le : void 0, $ = `${g.purchaseOrder.supplier.internal ? "Transfer" : "Purchase"} from ${g.purchaseOrder.supplier.name}`;
1288
- return {
1289
- label: g.name,
1290
- value: g._id,
1291
- disabled: T,
1292
- sublabel: C ?? $
1293
- };
1294
- });
1295
- return D.sort((g, M) => +!!g.disabled - +!!M.disabled), n.open({
1296
- title: "Select one template",
1297
- contentComponent: je,
1298
- contentComponentProps: {
1299
- items: D,
1300
- singleSelect: !0
1301
- },
1302
- primaryActions: {
1303
- text: "Confirm",
1304
- close: !0
1305
- },
1306
- secondaryActions: {
1307
- text: "Close",
1308
- close: !0
1309
- },
1310
- tertiaryActions: {
1311
- text: "Templates",
1312
- close: !0
1313
- }
1314
- }).onPrimary((g) => Array.isArray(g) ? R(g[0]) : null).onSecondary(() => R(void 0)).onTertiary(() => {
1315
- a.push({ name: we.TRANSFER_TEMPLATE }), R(void 0);
1316
- }).onClose(() => R(void 0)), y;
1317
- }
1318
- function f() {
1319
- n.open({
1320
- title: r("inventory.ingredient.import.title"),
1321
- contentComponent: $t,
1322
- overlay: !0,
1323
- closeButton: !0,
1324
- primaryActions: {
1325
- text: r("common.import"),
1326
- close: !1
1327
- },
1328
- secondaryActions: {
1329
- text: r("common.close"),
1330
- close: !0
1331
- },
1332
- tertiaryActions: {
1333
- text: r("inventory.ingredient.import.actions.downloadTemplate"),
1334
- close: !1,
1335
- variant: "plain"
1336
- }
1337
- }).onPrimary((y) => {
1338
- if (!y) {
1339
- e.open({
1340
- title: r("inventory.ingredient.import.error.noData"),
1341
- type: "error"
1342
- });
1343
- return;
1344
- }
1345
- if (!y.importCreateResult.length && !y.importUpdateResult.length) {
1346
- e.open({
1347
- title: r("inventory.ingredient.import.error.invalidContent"),
1348
- message: r("inventory.ingredient.import.error.noImportData"),
1349
- type: "error"
1350
- });
1351
- return;
1352
- }
1353
- if (y.importCreateResult.some((x) => x.errors.length) || y.importUpdateResult.some((x) => x.errors.length)) {
1354
- e.open({
1355
- title: r("inventory.ingredient.import.error.invalidContent"),
1356
- message: r("inventory.ingredient.import.error.hasErrors"),
1357
- type: "error"
1358
- });
1359
- return;
1360
- }
1361
- n.close(), v(y);
1362
- }).onTertiary(nt);
1363
- }
1364
- async function v(y) {
1365
- try {
1366
- const x = [
1367
- ...y.importCreateResult.map(
1368
- (g) => g.template
1369
- ),
1370
- ...y.importUpdateResult.map(
1371
- (g) => g.template
1372
- )
1373
- ], R = 100;
1374
- let A = 0;
1375
- const D = () => {
1376
- A += R, e.open({
1377
- title: r("inventory.ingredient.import.progress", [
1378
- Math.min(A, x.length),
1379
- x.length
1380
- ])
1381
- });
1382
- };
1383
- for (const g of x.chunk(100))
1384
- D(), await s.importTemplates(g);
1385
- e.open({
1386
- title: r("inventory.ingredient.import.success"),
1387
- type: "success"
1388
- });
1389
- } catch (x) {
1390
- e.open({
1391
- title: r("inventory.ingredient.import.error.failed"),
1392
- message: r("inventory.ingredient.import.error.systemMessage", [x == null ? void 0 : x.message]),
1393
- type: "error"
1394
- }), console.error("Error in importing skus", y, x);
1395
- } finally {
1396
- d.fetchTemplates();
1397
- }
1398
- }
1399
- function _() {
1400
- const y = rt(d.templates);
1401
- e.open({
1402
- title: r("inventory.ingredient.export.success"),
1403
- message: r("inventory.ingredient.export.filename", [y]),
1404
- type: "success"
1405
- });
1406
- }
1407
- return {
1408
- createTemplate: c,
1409
- viewTemplate: E,
1410
- updateTemplate: h,
1411
- deleteTemplate: b,
1412
- duplicateTemplate: t,
1413
- getTemplateId: w,
1414
- importTemplates: f,
1415
- exportTemplates: _,
1416
- openBulkItemEditor: l,
1417
- templateDialogProps: i,
1418
- templateDetailsProps: S
1419
- };
1420
- });
1421
- function Xt(n, e, o) {
1422
- const d = (o == null ? void 0 : o.abbrev) ?? e.abbrev;
1423
- return `${G(n, !1)} ${d}`;
1424
- }
1425
- export {
1426
- At as a,
1427
- be as b,
1428
- Xt as f,
1429
- Re as g,
1430
- De as t,
1431
- Ot as u
1432
- };