@feedmepos/mf-inventory-portal 1.0.37-dev.3 → 1.0.38

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 (81) hide show
  1. package/dist/{App-Dmd2G8R5.js → App-Bh_jIWxm.js} +1 -1
  2. package/dist/{ApprovalView-Dp3k5vDw.js → ApprovalView-U-Jo7wyv.js} +19 -19
  3. package/dist/{BindingsDialog-D80Yhk4v.js → BindingsDialog-CC0wt6a_.js} +4 -4
  4. package/dist/{BindingsPicker-BYRH73Mx.js → BindingsPicker-WL_1lOdc.js} +1 -1
  5. package/dist/{BindingsTable-CvblcQnI.js → BindingsTable-DJf1WJou.js} +4 -4
  6. package/dist/{ClosingDraftView-DiUIrHnf.js → ClosingDraftView-BI19VIT_.js} +26 -26
  7. package/dist/ClosingTemplateView-B6p83fs1.js +1804 -0
  8. package/dist/{DeliveryOrderPrintPreview-7DmbPXg9.js → DeliveryOrderPrintPreview-LANZdQE7.js} +4 -4
  9. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-C_QmBqHi.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-Bhz1nVO6.js} +11 -11
  10. package/dist/{FmMultiselectDialog-m2Wih5ZC.js → FmMultiselectDialog-B16LNSaK.js} +1 -1
  11. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-C0Ky06__.js → FmUnitInput.vue_vue_type_script_setup_true_lang-pAmapm7v.js} +21 -21
  12. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-DLfxc861.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-D7wM9EQ2.js} +1 -1
  13. package/dist/{IngredientGroupView-Um-bP1SR.js → IngredientGroupView-Bi8657CZ.js} +2 -2
  14. package/dist/IngredientsView-CGEQ-GvW.js +1838 -0
  15. package/dist/{IntegrationView-DfBOpvo1.js → IntegrationView-mYS_UJlk.js} +76 -77
  16. package/dist/{InventoryBindingForm-sbgSzNep.js → InventoryBindingForm-D-Y-IDFl.js} +1 -1
  17. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-CYpXwzuu.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-ByFJ6s6U.js} +24 -24
  18. package/dist/{InventoryBindingSummary-BWdagbGS.js → InventoryBindingSummary-z6XljZ_R.js} +1 -1
  19. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BvdA5Qfu.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-ihrVnPMe.js} +1 -1
  20. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-CBH7oYpv.js → PremiumBadge.vue_vue_type_script_setup_true_lang-DhoXg0vX.js} +10 -10
  21. package/dist/{PublishView-CjX1ZmFe.js → PublishView-DB7j7FkK.js} +17 -17
  22. package/dist/{PurchaseOrderPrintPreview-M20PXH1Z.js → PurchaseOrderPrintPreview-CTQIzDKp.js} +12 -12
  23. package/dist/{ReceiveRequestView-CF9p1j-M.js → ReceiveRequestView-B2UDO9o9.js} +782 -797
  24. package/dist/{RecipeView-kVgJAZ9d.js → RecipeView-BIDDh0V9.js} +3 -3
  25. package/dist/{StockView-B9bSTjY4.js → StockView-BgzAJBdL.js} +6 -6
  26. package/dist/{SupplierView-uaW913cH.js → SupplierView-zS3HDy59.js} +3 -3
  27. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-Bwiv5v2m.js → TransferDetails.vue_vue_type_script_setup_true_lang-DhnPjxXG.js} +696 -691
  28. package/dist/{TransferTemplateView-BuHT8mNT.js → TransferTemplateView-DLS9QAGY.js} +83 -83
  29. package/dist/{UnitView-Db_ETZrB.js → UnitView-B8mfgqXO.js} +3 -3
  30. package/dist/{WarehouseView-2SJNm6XK.js → WarehouseView-D4yYBRSM.js} +1 -1
  31. package/dist/api/inventory.d.ts +0 -4
  32. package/dist/api/netsuite.d.ts +0 -7
  33. package/dist/{app-CoEB-VoH.js → app-BLo-E2P1.js} +61427 -61936
  34. package/dist/app.d.ts +0 -9
  35. package/dist/app.js +1 -1
  36. package/dist/components/inventory-binding/InventoryBinding.vue.d.ts +0 -1
  37. package/dist/components/row-action.enum.d.ts +1 -2
  38. package/dist/components/shell/inventory/binding-ui.vue.d.ts +0 -1
  39. package/dist/{decimal-B7itxUWP.js → decimal-u4mLA_2Z.js} +1 -1
  40. package/dist/format-unit-display-g_Tq_sk7.js +1230 -0
  41. package/dist/{index-YGLKr3WK.js → index-BbBtmjWx.js} +1 -1
  42. package/dist/{index-DfWaG7Tl.js → index-Bu2R1xRv.js} +1 -1
  43. package/dist/{stock-CCQ352Hu.js → stock-BxIuAFed.js} +1 -1
  44. package/dist/stores/integration/netsuite.d.ts +1 -7
  45. package/dist/stores/inventory.d.ts +0 -9
  46. package/dist/{supplier-BCwA2FHM.js → supplier-CQftkZPG.js} +1 -1
  47. package/dist/tsconfig.app.tsbuildinfo +1 -1
  48. package/dist/{use-ingredient-select-dialog-DOONV-IL.js → use-ingredient-select-dialog-C9I7bja9.js} +1 -1
  49. package/dist/{use-inventory-binding-dialog-BPM-7FrW.js → use-inventory-binding-dialog-s8nyBhfo.js} +1 -1
  50. package/dist/views/adjustment-template/wastage-template/actions.d.ts +1 -4
  51. package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftDialog.vue.d.ts +0 -8
  52. package/dist/views/closing-draft/composables/use-closing-draft-table.d.ts +0 -24
  53. package/dist/views/closing-template/components/closing-template-form/composables/use-closing-template-items.d.ts +0 -1
  54. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +1 -16
  55. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +0 -12
  56. package/dist/views/ingredients/components/ingredient-form/IngredientForm.vue.d.ts +0 -2
  57. package/dist/views/ingredients/composables/use-ingredient-table.d.ts +0 -1
  58. package/dist/views/integration/components/netsuite/InventoryTransferIngredientTable.vue.d.ts +0 -2
  59. package/dist/views/integration/components/netsuite/business/BusinessNetSuiteSideSheet.vue.d.ts +0 -4
  60. package/dist/views/receive-request/components/netsuite/NetSuiteLog.vue.d.ts +2 -2
  61. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +0 -17
  62. package/dist/views/receive-request/components/transfer-form/components/ForecastStock.vue.d.ts +0 -2
  63. package/dist/views/receive-request/components/transfer-form/components/TransferItemTable.vue.d.ts +0 -4
  64. package/dist/views/receive-request/components/transfer-form/composables/use-transfer-items.d.ts +0 -1
  65. package/dist/views/receive-request/composables/use-process-purchase-order.d.ts +0 -4
  66. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +0 -24
  67. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +0 -24
  68. package/dist/views/stock/components/dialog/AdjustedItemForm.vue.d.ts +0 -2
  69. package/dist/views/transfer-template/components/transfer-template-dialog/TransferTemplateDialog.vue.d.ts +0 -2
  70. package/dist/views/transfer-template/components/transfer-template-form/components/NetSuiteCustomCodeSelection.vue.d.ts +0 -2
  71. package/dist/views/transfer-template/components/transfer-template-form/components/TransferTemplateItemTable.vue.d.ts +0 -2
  72. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.d.ts +0 -1
  73. package/dist/views/transfer-template/composables/use-netsuite-custom-field.d.ts +0 -3
  74. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +1 -16
  75. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +0 -12
  76. package/dist/{vue-i18n-DZAYeut-.js → vue-i18n-C3CYm8Dg.js} +352 -352
  77. package/package.json +1 -1
  78. package/dist/ClosingTemplateView-BGyaxOv_.js +0 -1849
  79. package/dist/IngredientsView-BOYvD0VL.js +0 -1858
  80. package/dist/api/duplicate-template.d.ts +0 -5
  81. package/dist/format-unit-display-DswmXjqB.js +0 -1275
@@ -1,1275 +0,0 @@
1
- import { a3 as Ie, a as V, T as Ne, ag as M, s as De, ah as ye, v as he, u as G, j as B, w as Oe, aK as ie, x as ve, b as ee, t as W, Y as J, aJ as Pe, aB as Fe, a0 as Ue, y as Me, z as Be, ai as Le, e as le, f as te, R as ce, a2 as Qe, af as He, D as j, i as N, h as qe } from "./app-CoEB-VoH.js";
2
- import { useCoreStore as re, useI18n as ne } from "@feedmepos/mf-common";
3
- import { useDialogChild as Ve, useSnackbar as ge, useDialog as je, FmButtonVariant as z, components as me } from "@feedmepos/ui-library";
4
- import { defineStore as be } from "pinia";
5
- import { defineComponent as xe, resolveComponent as Q, openBlock as $, createElementBlock as k, createElementVNode as C, normalizeClass as H, createTextVNode as ze, toDisplayString as D, unref as A, createCommentVNode as q, createVNode as F, withCtx as X, Fragment as L, renderList as Y, ref as E, onMounted as Ke, computed as ue, watch as Ye, createSlots as We, createBlock as K, h as Z } from "vue";
6
- import { useRouter as Ge } from "vue-router";
7
- import { u as oe } from "./supplier-BCwA2FHM.js";
8
- const Se = Ie((e, t) => {
9
- function s() {
10
- var o;
11
- return `business_${((o = re().currentBusiness.value) == null ? void 0 : o._id) ?? ""}`;
12
- }
13
- return {
14
- async getTemplate(l) {
15
- const i = s(), o = `${e.inventoryBackendUrl}/${i}/purchase-order-template/${l}`;
16
- return t.get(o);
17
- },
18
- async readTemplates() {
19
- const l = s(), i = `${e.inventoryBackendUrl}/${l}/purchase-order-template`;
20
- return t.get(i);
21
- },
22
- async createTemplate(l) {
23
- const i = s(), o = `${e.inventoryBackendUrl}/${i}/purchase-order-template`;
24
- return t.post(o, l);
25
- },
26
- async updateTemplate(l) {
27
- const i = s(), o = `${e.inventoryBackendUrl}/${i}/purchase-order-template`;
28
- return t.put(o, l);
29
- },
30
- async deleteTemplate(l) {
31
- const i = s(), o = `${e.inventoryBackendUrl}/${i}/purchase-order-template`;
32
- return t.delete(o, { _id: l._id, _rev: l._rev });
33
- },
34
- async importTemplates(l) {
35
- const i = s(), o = `${e.inventoryBackendUrl}/${i}/purchase-order-template/import`;
36
- return t.post(o, l);
37
- }
38
- };
39
- });
40
- function Te(e) {
41
- const t = V(), s = e.sku, l = t.skuById[s._id];
42
- if (l.unit._id !== s.unit._id) return !0;
43
- const i = e.measurement;
44
- return i ? !t.unitById[l.unit._id].measurements.find((c) => c.id === i.id) : !1;
45
- }
46
- var R = /* @__PURE__ */ ((e) => (e.PURCHASE = "PURCHASE", e.TRANSFER = "TRANSFER", e))(R || {}), ae = /* @__PURE__ */ ((e) => (e.Source = "Source", e.Destination = "Destination", e.Ingredient = "Ingredient", e))(ae || {});
47
- const de = Ne(0);
48
- function _e(e) {
49
- var l;
50
- const t = e.sku;
51
- return {
52
- code: t.code,
53
- overrideCode: e.code,
54
- name: t.name,
55
- unit: ((l = t.unit.measurements.find((i) => i.id === t.trackingMeasurement)) == null ? void 0 : l.abbrev) ?? t.unit.abbrev,
56
- defaultQuantity: +B(e.quantity),
57
- minimumQuantity: +B(e.minimumQuantity ?? de),
58
- maximumQuantity: +B(e.maximumQuantity ?? de),
59
- quantityStep: +B(e.quantityStep)
60
- };
61
- }
62
- function $e() {
63
- return [
64
- {
65
- id: "code",
66
- name: "Code"
67
- },
68
- {
69
- id: "overrideCode",
70
- name: "Override Code (Optional)"
71
- },
72
- {
73
- id: "name",
74
- name: "Name"
75
- },
76
- {
77
- id: "unit",
78
- name: "Unit"
79
- },
80
- {
81
- id: "defaultQuantity",
82
- name: "Default Quantity"
83
- },
84
- {
85
- id: "minimumQuantity",
86
- name: "Minimum Quantity"
87
- },
88
- {
89
- id: "maximumQuantity",
90
- name: "Maximum Quantity (Optional)"
91
- },
92
- {
93
- id: "quantityStep",
94
- name: "Quantity Step"
95
- }
96
- ];
97
- }
98
- function Je(e) {
99
- var c;
100
- const s = re().currentBusiness.value, i = (c = e.map((a) => {
101
- var g;
102
- const m = a.purchaseOrder.items.map((r) => _e(r)), h = $e(), d = [
103
- ["Template ID", a._id],
104
- ["Template name", a.name],
105
- ["Business name", s == null ? void 0 : s.name],
106
- ["Business ID", s == null ? void 0 : s._id],
107
- ["Menu version", s == null ? void 0 : s.menuVersion],
108
- [
109
- "Purchase/Transfer",
110
- typeof a.purchaseOrder.supplier.internal == "string" ? R.TRANSFER : R.PURCHASE
111
- ],
112
- [
113
- "Transfer from",
114
- `${a.purchaseOrder.supplier.name} (${[
115
- a.purchaseOrder.supplier.internal,
116
- a.purchaseOrder.supplier._id
117
- ].filter((r) => r).join("_")})`
118
- ],
119
- [
120
- "Locations",
121
- ...(g = a.locations) != null && g.length ? a.locations.map((r) => `${r.name} (${r.dbName})`) : ["All"]
122
- ],
123
- ["Reference", a.purchaseOrder.ref ?? ""],
124
- ["Remark", a.purchaseOrder.remark ?? ""],
125
- [],
126
- h.map((r) => r.name),
127
- ...m.map((r) => h.map((x) => r[x.id]))
128
- ], u = h.map((r) => `system:${r.id}`), v = M(d, u);
129
- return { name: a.name, sheet: v };
130
- }).reduce(
131
- (a, m) => {
132
- var d;
133
- const h = m.name.slice(0, 12);
134
- return (d = a.sheetOccurence)[h] ?? (d[h] = 0), a.sheetOccurence[h] += 1, a.sheets[`${h} (${a.sheetOccurence[h]})`] = m.sheet, a;
135
- },
136
- {
137
- sheets: {},
138
- sheetOccurence: {}
139
- }
140
- )) == null ? void 0 : c.sheets, o = `${s == null ? void 0 : s.name} transfer templates (${De(/* @__PURE__ */ new Date())}).xlsx`, f = ye(i);
141
- return he(f, o), o;
142
- }
143
- function Ze() {
144
- const e = re(), t = oe(), s = G(), l = V(), i = e.currentBusiness.value, o = _e({
145
- sku: {
146
- unit: {
147
- _id: "",
148
- name: "Unit",
149
- abbrev: "Unit",
150
- precision: 0,
151
- measurements: []
152
- },
153
- code: "ING001",
154
- _id: "",
155
- name: "Sugar"
156
- },
157
- code: "ING001 (override optional)",
158
- name: "Sugar",
159
- quantity: {
160
- amount: 1,
161
- precision: 0
162
- },
163
- quantityStep: {
164
- amount: 1,
165
- precision: 0
166
- },
167
- minimumQuantity: {
168
- amount: 1,
169
- precision: 0
170
- },
171
- maximumQuantity: {
172
- amount: 1,
173
- precision: 0
174
- }
175
- }), f = $e(), c = [
176
- ["Template ID (leave empty to create new)"],
177
- ["Template Name", "New template"],
178
- ["Business name", i == null ? void 0 : i.name],
179
- ["Business ID", i == null ? void 0 : i._id],
180
- ["Menu version", i == null ? void 0 : i.menuVersion],
181
- ["Purchase/Transfer", "Purchase"],
182
- [
183
- "Transfer from",
184
- "Example supplier (supplier_xxx)",
185
- "Refer to sources list & copy whole cell."
186
- ],
187
- [
188
- "Location codes (leave empty to enable all)",
189
- "Example outlet (restaurant_xxx)",
190
- "Example outlet 2 (restaurant_xxx)"
191
- ],
192
- ["Reference"],
193
- ["Remark"],
194
- [],
195
- f.map((r) => r.name),
196
- f.map((r) => o[r.id])
197
- ], a = f.map((r) => `system:${r.id}`), m = M(c, a), h = M(
198
- [
199
- ...t.businessSuppliers.map((r) => [
200
- `${r.name} (${r._id})`,
201
- "Purchase",
202
- r.address.line1,
203
- r.address.line2,
204
- r.address.city,
205
- r.address.postcode,
206
- r.address.state,
207
- r.address.country
208
- ]),
209
- ...s.locations.map((r) => {
210
- var x, w, S, p, n, y;
211
- return [
212
- `${r.name} (${r.dbName})`,
213
- "Transfer",
214
- (x = r.doc.profile.address) == null ? void 0 : x.line1,
215
- (w = r.doc.profile.address) == null ? void 0 : w.line2,
216
- (S = r.doc.profile.address) == null ? void 0 : S.city,
217
- (p = r.doc.profile.address) == null ? void 0 : p.postcode,
218
- (n = r.doc.profile.address) == null ? void 0 : n.state,
219
- (y = r.doc.profile.address) == null ? void 0 : y.country
220
- ];
221
- })
222
- ],
223
- ["Name", "Type", "Line 1", "Line 2", "City", "Postal", "State", "Country"]
224
- ), d = M(
225
- s.locations.map((r) => {
226
- var x, w, S, p, n, y;
227
- return [
228
- `${r.name} (${r.dbName})`,
229
- (x = r.doc.profile.address) == null ? void 0 : x.line1,
230
- (w = r.doc.profile.address) == null ? void 0 : w.line2,
231
- (S = r.doc.profile.address) == null ? void 0 : S.city,
232
- (p = r.doc.profile.address) == null ? void 0 : p.postcode,
233
- (n = r.doc.profile.address) == null ? void 0 : n.state,
234
- (y = r.doc.profile.address) == null ? void 0 : y.country
235
- ];
236
- }),
237
- ["Name", "Line 1", "Line 2", "City", "Postal", "State", "Country"]
238
- ), u = M(
239
- l.skus.map((r) => [
240
- r.code,
241
- r.name,
242
- r.unit.abbrev,
243
- ...r.unit.measurements.map((x) => x.abbrev)
244
- ]),
245
- ["Code", "Name", "Base unit", "Measurements"]
246
- ), v = ye({
247
- Template: m,
248
- Source: h,
249
- Destination: d,
250
- Ingredient: u
251
- }), g = `${i == null ? void 0 : i.name} transfer templates import.xlsx`;
252
- return he(v, g), g;
253
- }
254
- function Xe(e, t) {
255
- const s = new Array(), l = /(.*) \(((supplier_|warehouse_|restaurant_).{24,})\)/, o = G().locationByDbName, c = oe().supplierById, a = e.trim(), m = l.exec(a);
256
- if (!m)
257
- return s.push(`Transfer from location value of ${a} cannot be read.`), {
258
- errors: s
259
- };
260
- const h = m[1], d = m[2];
261
- let u;
262
- if (d.startsWith("supplier"))
263
- u = c[d], t !== R.PURCHASE && s.push(`Expected transfer type Purchase but found ${t} instead.`);
264
- else {
265
- const v = o[d];
266
- if (!v)
267
- return s.push(`Location (${h}) of id ${d} is not found.`), {
268
- errors: s
269
- };
270
- h !== v.name && s.push(
271
- `Location id ${d} has non-matching name. Found ${h} but expected ${v.name}`
272
- ), u = {
273
- _id: v.doc._id,
274
- name: v.name,
275
- address: v.doc.profile.address ?? {
276
- line1: "",
277
- state: "",
278
- country: "",
279
- city: "",
280
- postcode: "",
281
- coordinates: [0, 0]
282
- },
283
- internal: d.split("_")[0] === "restaurant" ? ie.enum.restaurant : ie.enum.warehouse,
284
- phoneNumber: v.doc.profile.phoneNo ?? "",
285
- email: v.doc.profile.email ?? "",
286
- _rev: "",
287
- contactName: v.doc.profile.name ?? "",
288
- registrationNumber: v.doc.profile.regNo ?? ""
289
- };
290
- }
291
- return {
292
- from: u,
293
- errors: s
294
- };
295
- }
296
- function et(e) {
297
- if (!e.length || `${e[0]}`.toLocaleLowerCase() === "all")
298
- return [];
299
- const t = /(.*) \(((warehouse_|restaurant_).{24,})\)/, l = G().locationByDbName;
300
- return e.map((i) => {
301
- const o = new Array(), f = i.trim(), c = t.exec(f);
302
- if (!c)
303
- return o.push(`Enabled location value of ${f} cannot be read.`), {
304
- errors: o
305
- };
306
- const a = c[1], m = c[2], h = l[m];
307
- return h ? (a !== h.name && o.push(
308
- `Location id ${m} has non-matching name. Found ${a} but expected ${h.name}`
309
- ), {
310
- errors: o,
311
- location: h
312
- }) : (o.push(`Location (${a}) of id ${m} is not found.`), {
313
- errors: o
314
- });
315
- });
316
- }
317
- function tt(e) {
318
- const [
319
- t,
320
- s,
321
- l,
322
- i,
323
- o,
324
- f,
325
- c,
326
- a,
327
- m,
328
- h,
329
- d
330
- ] = ve(e);
331
- return {
332
- id: `${s[1] ?? ""}`.trim(),
333
- name: `${l[1] ?? ""}`.trim(),
334
- type: `${c[1] ?? ""}`.trim().toLocaleLowerCase() === "transfer" ? R.TRANSFER : R.PURCHASE,
335
- transferFrom: `${a[1] ?? ""}`.trim(),
336
- locations: m.slice(1).map((u) => `${u}`.trim()).filter((u) => u),
337
- reference: `${h[1] ?? ""}`.trim(),
338
- remark: `${d[1] ?? ""}`.trim()
339
- };
340
- }
341
- function rt(e) {
342
- const [
343
- t,
344
- s,
345
- l,
346
- i,
347
- o,
348
- f,
349
- c,
350
- a,
351
- m,
352
- h,
353
- d,
354
- u,
355
- v,
356
- ...g
357
- ] = ve(e);
358
- if (!t || !t.length || t.some((p) => p.length && !p.startsWith("system:")))
359
- throw new Error("Missing meta header. Excel file does not come from the template.");
360
- const r = t.map((p) => p.split(":")[1]), w = [
361
- "code",
362
- "name",
363
- "unit",
364
- "defaultQuantity",
365
- "minimumQuantity",
366
- "maximumQuantity",
367
- "quantityStep"
368
- ].filter((p) => !r.includes(p));
369
- if (w.length)
370
- throw new Error(
371
- `Missing meta headers (${w.join()}). Excel file does not come from the template.`
372
- );
373
- return g.map((p, n) => {
374
- const y = {};
375
- for (const T in r) {
376
- const _ = r[T];
377
- Object.assign(y, { [_]: p[T] });
378
- }
379
- return {
380
- index: n,
381
- data: y
382
- };
383
- });
384
- }
385
- function nt(e, t, s) {
386
- const l = e === "" ? null : W(e, s), i = t === "" ? null : W(t, s), o = l && i && l.amount > i.amount;
387
- return {
388
- min: l,
389
- max: i,
390
- compareError: o ? "Minimum amount must be less than or equal to maximum amount" : void 0
391
- };
392
- }
393
- function ot(e, t, s) {
394
- const l = V(), i = ee(), o = l.skuByCode[e.code], f = new Array();
395
- if (!o)
396
- return f.push(`Cannot find ingredient with code (${e.code}) ${e.name}.`), {
397
- index: t,
398
- errors: f
399
- };
400
- if (s.filter((p) => p.data.code === e.code).length > 1)
401
- return f.push(`Ingredient ${e.code} is defined twice.`), {
402
- index: t,
403
- errors: f
404
- };
405
- const c = o.unit, a = c == null ? void 0 : c.measurements.find((p) => p.abbrev === e.unit);
406
- if (c.abbrev !== e.unit && !a) {
407
- const p = `Cannot find unit measurement of symbol ${e.unit || "[empty]"} for ingredient (${e.code}) ${e.name}.`;
408
- f.push(p);
409
- const n = {
410
- sku: o,
411
- code: e.overrideCode || o.code,
412
- name: o.name,
413
- measurement: a,
414
- quantity: { amount: 0, precision: 0 },
415
- quantityStep: { amount: 0, precision: 0 },
416
- minimumQuantity: { amount: 0, precision: 0 },
417
- maximumQuantity: { amount: 0, precision: 0 }
418
- };
419
- if (i.isEnabled) {
420
- const y = i.getItemCustomCode(o);
421
- y && (n.code = y);
422
- }
423
- return {
424
- index: t,
425
- errors: f,
426
- templateItem: n
427
- };
428
- }
429
- const m = W(
430
- e.quantityStep,
431
- J(c, a)
432
- );
433
- (Number.isNaN(Number(e.quantityStep)) || Number(e.quantityStep) <= 0) && f.push("Amount step must be more than 0");
434
- const h = Pe(m), d = nt(
435
- e.minimumQuantity,
436
- e.maximumQuantity,
437
- J(c, a)
438
- ), u = d.min, v = d.max;
439
- d.compareError && f.push(d.compareError);
440
- const g = Fe(+e.minimumQuantity, +e.maximumQuantity), r = W(
441
- e.defaultQuantity,
442
- J(c, a)
443
- ), x = h(r);
444
- typeof x == "string" && f.push(`Default amount: ${x}`);
445
- const w = d.min && d.max ? g(`${e.defaultQuantity}`) : null;
446
- typeof w == "string" && f.push(`Default amount: ${w}`);
447
- const S = {
448
- sku: o,
449
- code: e.overrideCode || o.code,
450
- name: e.name || o.name,
451
- measurement: a,
452
- quantity: r,
453
- quantityStep: m,
454
- minimumQuantity: u,
455
- maximumQuantity: v
456
- };
457
- return {
458
- index: t,
459
- errors: f,
460
- templateItem: S
461
- };
462
- }
463
- function at(e) {
464
- const t = e.SheetNames.filter(
465
- (o) => !Object.values(ae).map(String).includes(o)
466
- ), l = Ce().templates, i = Oe(l, "_id");
467
- try {
468
- return t.reduce(
469
- (o, f) => {
470
- var p;
471
- const c = new Array(), a = e.Sheets[f], m = tt(a), h = Xe(m.transferFrom, m.type);
472
- c.push(...h.errors);
473
- const d = h.from, u = et(m.locations), v = u.filter((n) => n.location).map((n) => n.location);
474
- c.push(...u.flatMap((n) => n.errors));
475
- const g = rt(a).filter((n) => n.data.code), r = g.map(
476
- (n, y) => ot(n.data, y, g)
477
- );
478
- c.push(
479
- ...r.flatMap(
480
- (n) => n.errors.map((y) => `(Excel row ${n.index + 14}) ${y}`)
481
- )
482
- );
483
- const x = r.filter((n) => n.templateItem).map((n) => n.templateItem);
484
- if (m.id) {
485
- const n = i[m.id];
486
- if (!n) {
487
- const T = {
488
- _id: m.id,
489
- _rev: "",
490
- name: m.name || `(unnamed from sheet ${f || "<unnamed sheet>"})`,
491
- purchaseOrder: st()
492
- };
493
- return c.push(`Template ID ${m.id} is not found.`), o.importUpdateResult.push({
494
- type: "update",
495
- original: T,
496
- template: T,
497
- excelSheetName: f,
498
- errors: c
499
- }), o;
500
- }
501
- const y = {
502
- type: "update",
503
- original: n,
504
- template: {
505
- ...n,
506
- name: m.name,
507
- locations: v.length ? v : null,
508
- purchaseOrder: {
509
- ...n.purchaseOrder,
510
- supplier: d ?? ((p = n.purchaseOrder) == null ? void 0 : p.supplier),
511
- ref: m.reference,
512
- remark: m.remark,
513
- items: x
514
- }
515
- },
516
- excelSheetName: f,
517
- errors: c
518
- };
519
- return o.importUpdateResult.push(y), o;
520
- }
521
- const S = {
522
- type: "create",
523
- template: {
524
- name: m.name,
525
- locations: v.length ? v : null,
526
- purchaseOrder: {
527
- supplier: d ?? we(),
528
- ref: m.reference,
529
- remark: m.remark,
530
- items: x
531
- }
532
- },
533
- excelSheetName: f,
534
- errors: c
535
- };
536
- return o.importCreateResult.push(S), o;
537
- },
538
- {
539
- invalidExcel: !1,
540
- importCreateResult: new Array(),
541
- importUpdateResult: new Array()
542
- }
543
- );
544
- } catch (o) {
545
- return {
546
- invalidExcel: !0,
547
- invalidExcelMessage: (o == null ? void 0 : o.message) ?? "Invalid excel",
548
- importCreateResult: [],
549
- importUpdateResult: []
550
- };
551
- }
552
- }
553
- function we() {
554
- return {
555
- _id: "",
556
- name: "",
557
- address: {
558
- line2: void 0,
559
- line1: "",
560
- state: "",
561
- city: "",
562
- postcode: "",
563
- country: ""
564
- }
565
- };
566
- }
567
- function st() {
568
- return {
569
- remark: void 0,
570
- ref: void 0,
571
- items: [],
572
- supplier: we()
573
- };
574
- }
575
- const it = { class: "flex items-center gap-12 pl-8" }, lt = { class: "flex flex-col" }, ct = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary flex items-center gap-4" }, mt = { class: "text-fm-color-typo-secondary fm-typo-en-body-md-400" }, ut = {
576
- key: 0,
577
- class: "text-fm-color-typo-secondary fm-typo-en-body-sm-400"
578
- }, dt = { key: 0 }, pe = /* @__PURE__ */ xe({
579
- __name: "TransferTemplateImportItem",
580
- props: {
581
- type: {},
582
- name: {},
583
- transferType: {},
584
- locations: {},
585
- items: {},
586
- errors: {}
587
- },
588
- setup(e) {
589
- return (t, s) => {
590
- var o, f, c;
591
- const l = Q("FmIcon"), i = Q("FmTooltip");
592
- return $(), k("div", it, [
593
- s[0] || (s[0] = C("div", null, "•", -1)),
594
- C("div", lt, [
595
- C("div", ct, [
596
- C("div", {
597
- class: H({
598
- "text-fm-color-system-error-300": t.errors.length
599
- })
600
- }, [
601
- ze(D(t.name) + " ", 1),
602
- C("span", mt, " (" + D(A(Ue)(`${t.transferType}`)) + ") ", 1),
603
- t.type === "create" ? ($(), k("span", ut, "(new)")) : q("", !0)
604
- ], 2),
605
- t.errors.length ? ($(), k("div", dt, [
606
- F(i, { "z-index": 50 }, {
607
- content: X(() => [
608
- C("ol", null, [
609
- ($(!0), k(L, null, Y(t.errors, (a, m) => ($(), k("li", { key: m }, D(a), 1))), 128))
610
- ])
611
- ]),
612
- default: X(() => [
613
- F(l, {
614
- name: "error",
615
- size: "sm",
616
- color: "system-error-300"
617
- })
618
- ]),
619
- _: 1
620
- })
621
- ])) : q("", !0)
622
- ]),
623
- C("div", {
624
- class: H([
625
- "fm-typo-en-body-sm-400",
626
- {
627
- "text-fm-color-system-error-200": t.errors.length,
628
- "text-fm-color-typo-secondary": !t.errors.length
629
- }
630
- ])
631
- }, D((o = t.locations) != null && o.length ? `${(f = t.locations) == null ? void 0 : f.length} locations` : "All locations") + ", " + D(`${(c = t.items) == null ? void 0 : c.length} items`), 3)
632
- ])
633
- ]);
634
- };
635
- }
636
- }), pt = { class: "flex flex-col gap-24" }, ft = {
637
- key: 0,
638
- class: "flex items-center gap-8"
639
- }, yt = { class: "flex flex-col gap-8" }, ht = { class: "line-clamp-2 text-ellipsis break-all" }, vt = {
640
- key: 2,
641
- class: "shrink-0"
642
- }, gt = {
643
- key: 0,
644
- class: "flex flex-col"
645
- }, bt = { class: "text-fm-color-system-error-300 fm-typo-en-body-sm-400" }, xt = {
646
- key: 0,
647
- class: "max-h-[200px] overflow-y-auto flex flex-col gap-8"
648
- }, St = { class: "fm-typo-en-body-lg-600" }, Tt = /* @__PURE__ */ xe({
649
- __name: "TransferTemplateImport",
650
- setup(e) {
651
- const t = E(null), s = Ve(), l = ge(), i = E(!1), o = E(!1), f = oe();
652
- Ke(async () => {
653
- o.value = !0;
654
- try {
655
- await f.readSuppliers().delayed(1e3);
656
- } catch {
657
- l.open({
658
- title: "Something went wrong.",
659
- message: "Error at reading suppliers list. Please try again.",
660
- type: "error"
661
- });
662
- } finally {
663
- o.value = !1;
664
- }
665
- });
666
- const c = E(new Array()), a = E([]), m = E([]), h = ue(
667
- () => !!c.value.length || a.value.some((g) => g.errors.length) || m.value.some((g) => g.errors.length)
668
- ), d = ue(
669
- () => !!a.value.length || !!m.value.length
670
- ), { t: u } = ne();
671
- async function v(g) {
672
- c.value = [], a.value = [], m.value = [];
673
- try {
674
- i.value = !0;
675
- const [r] = await Promise.all([
676
- Be(g),
677
- // fake buffer
678
- new Promise((p) => setTimeout(p, 1e3))
679
- ]);
680
- if (!r.SheetNames.filter(
681
- (p) => !Object.values(ae).map(String).includes(p)
682
- ).find((p) => p)) {
683
- c.value.push(u("inventory.ingredient.import.fileError.noSheet"));
684
- return;
685
- }
686
- const S = at(r);
687
- if (S.invalidExcel) {
688
- c.value.push(
689
- S.invalidExcelMessage ?? u("inventory.ingredient.import.fileError.invalidExcel")
690
- );
691
- return;
692
- }
693
- if (a.value = S.importCreateResult, m.value = S.importUpdateResult, !a.value.length && !m.value.length) {
694
- c.value.push(u("inventory.ingredient.import.fileError.noData"));
695
- return;
696
- }
697
- s.emitData(S);
698
- } catch (r) {
699
- l.open({
700
- title: u("inventory.ingredient.import.fileError.unableToRead"),
701
- message: r == null ? void 0 : r.message,
702
- type: "error"
703
- }), console.error("Error in reading file", r);
704
- } finally {
705
- c.value.length && l.open({
706
- title: u("inventory.ingredient.import.fileError.invalidExcel"),
707
- type: "error"
708
- }), i.value = !1;
709
- }
710
- }
711
- return Ye(t, (g) => {
712
- g && v(g);
713
- }), (g, r) => {
714
- const x = Q("FmCircularProgress"), w = Q("FmIcon"), S = Q("FmButton");
715
- return $(), k("div", pt, [
716
- r[2] || (r[2] = C("div", { class: "fm-typo-en-body-md-400" }, "Import transfer templates from excel sheets.", -1)),
717
- o.value ? ($(), k("div", ft, [
718
- C("div", null, [
719
- F(x, {
720
- size: "md",
721
- color: "neutral-gray-200"
722
- })
723
- ]),
724
- r[1] || (r[1] = C("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "Loading...", -1))
725
- ])) : ($(), k(L, { key: 1 }, [
726
- F(Me, {
727
- class: H({
728
- "w-full": !0,
729
- "h-[200px]": !t.value
730
- }),
731
- accept: ".xlsx",
732
- onFileUpload: r[0] || (r[0] = (p) => t.value = p),
733
- label: A(u)("inventory.ingredient.import.uploadTemplate"),
734
- "button-label": A(u)("inventory.ingredient.import.selectFile")
735
- }, We({ _: 2 }, [
736
- t.value ? {
737
- name: "default",
738
- fn: X(({ openFileDialog: p }) => [
739
- C("div", yt, [
740
- C("div", {
741
- class: H([
742
- "fm-corner-radius-md p-16 flex items-center gap-16",
743
- {
744
- "border border-fm-color-neutral-gray-100": i.value,
745
- "border border-fm-color-neutral-gray-200": !i.value && !h.value,
746
- "border border-fm-color-system-error-200": h.value
747
- }
748
- ])
749
- }, [
750
- i.value ? ($(), K(x, {
751
- key: 0,
752
- size: "md",
753
- color: "neutral-gray-200"
754
- })) : ($(), K(w, {
755
- key: 1,
756
- name: h.value ? "error" : "attach_file",
757
- outline: "",
758
- color: h.value ? "system-error-300" : void 0
759
- }, null, 8, ["name", "color"])),
760
- C("div", {
761
- class: H([
762
- "fm-typo-en-body-md-400 flex-1 h-[36px] flex items-center",
763
- {
764
- "text-fm-color-typo-disabled": i.value,
765
- "text-fm-color-typo-primary": !i.value
766
- }
767
- ])
768
- }, [
769
- C("div", ht, D(t.value.name), 1)
770
- ], 2),
771
- i.value ? q("", !0) : ($(), k("div", vt, [
772
- F(S, {
773
- label: A(u)("inventory.ingredient.import.replaceFile"),
774
- variant: h.value ? "destructive" : "secondary",
775
- "prepend-icon": h.value ? void 0 : "autorenew",
776
- onClick: p
777
- }, null, 8, ["label", "variant", "prepend-icon", "onClick"])
778
- ]))
779
- ], 2),
780
- c.value.length ? ($(), k("div", gt, [
781
- ($(!0), k(L, null, Y(c.value, (n, y) => ($(), k("div", {
782
- key: y,
783
- class: "flex gap-8 items-center"
784
- }, [
785
- F(w, {
786
- name: "error",
787
- size: "sm",
788
- color: "system-error-300"
789
- }),
790
- C("div", bt, D(n), 1)
791
- ]))), 128))
792
- ])) : q("", !0)
793
- ])
794
- ]),
795
- key: "0"
796
- } : void 0
797
- ]), 1032, ["class", "label", "button-label"]),
798
- d.value ? ($(), k("div", xt, [
799
- C("div", St, D(A(u)("inventory.ingredient.import.summary")), 1),
800
- ($(!0), k(L, null, Y(a.value, (p, n) => ($(), K(pe, {
801
- key: n,
802
- name: p.template.name,
803
- "transfer-type": typeof p.template.purchaseOrder.supplier.internal == "string" ? A(R).TRANSFER : A(R).PURCHASE,
804
- locations: p.template.locations,
805
- items: p.template.purchaseOrder.items,
806
- errors: p.errors,
807
- type: "create"
808
- }, null, 8, ["name", "transfer-type", "locations", "items", "errors"]))), 128)),
809
- ($(!0), k(L, null, Y(m.value, (p) => ($(), K(pe, {
810
- key: p.template._id,
811
- name: p.template.name,
812
- "transfer-type": typeof p.template.purchaseOrder.supplier.internal == "string" ? A(R).TRANSFER : A(R).PURCHASE,
813
- locations: p.template.locations,
814
- items: p.template.purchaseOrder.items,
815
- errors: p.errors,
816
- type: "update"
817
- }, null, 8, ["name", "transfer-type", "locations", "items", "errors"]))), 128))
818
- ])) : q("", !0)
819
- ], 64))
820
- ]);
821
- };
822
- }
823
- });
824
- function _t(e) {
825
- var o, f;
826
- const t = ee();
827
- if (!t.isEnabled) return !0;
828
- if (!e.internal) {
829
- const c = t.getNetSuiteVendor(e._id), a = c == null ? void 0 : c.subsidiaryId, m = (o = t.currentVendorSubsidiary(e._id)) == null ? void 0 : o.id;
830
- return a && a == m;
831
- }
832
- const s = t.getNetSuiteLocation(`${e.internal}_${e._id}`), l = t.getLocationSubsidiary(s == null ? void 0 : s.netSuiteId).id, i = (f = t.currentLocationSubsidiary()) == null ? void 0 : f.id;
833
- return l && l == i;
834
- }
835
- const $t = be("transferTemplateActions", () => {
836
- const e = je(), t = ge(), s = G(), l = Ce(), i = Le(), o = Se(), f = ee(), c = Ge(), { t: a } = ne(), m = E({});
837
- function h() {
838
- m.value = {
839
- mode: le.CREATE,
840
- show: !0,
841
- "onUpdate:show"(n) {
842
- m.value.show = n;
843
- }
844
- };
845
- }
846
- function d(n) {
847
- m.value = {
848
- mode: le.UPDATE,
849
- modelValue: n,
850
- show: !0,
851
- "onUpdate:show"(y) {
852
- m.value.show = y;
853
- }
854
- };
855
- }
856
- function u(n, y, T) {
857
- e.open({
858
- title: `Confirm deleting template ${n.name}?`,
859
- message: "Deleted template can no longer be retrieved",
860
- primaryActions: {
861
- text: "Delete",
862
- variant: z.Destructive,
863
- close: !0
864
- },
865
- secondaryActions: {
866
- text: "Cancel",
867
- variant: z.Plain,
868
- close: !0
869
- }
870
- }).onPrimary(async () => {
871
- t.open({
872
- title: `Deleting ${n.name}`,
873
- type: "info"
874
- });
875
- try {
876
- y.value = !0;
877
- const [_] = await Promise.allSettled([
878
- o.deleteTemplate(n),
879
- new Promise((I) => setTimeout(I, 1e3))
880
- ]);
881
- if (_.status === "rejected") throw _.reason;
882
- t.open({
883
- title: `Deleted ${n.name}`,
884
- type: "success"
885
- });
886
- } catch (_) {
887
- t.open({
888
- title: `Unable to delete ${n.name}`,
889
- message: `See error from server: ${_}`,
890
- type: "error"
891
- }), console.error("error on deleting purchase order template", _);
892
- } finally {
893
- y.value = !1, T();
894
- }
895
- });
896
- }
897
- function v(n, y, T) {
898
- e.open({
899
- title: `Confirm duplicating template "${n.name}"?`,
900
- message: "Duplicated template can be edited and used independently",
901
- primaryActions: {
902
- text: "Duplicate",
903
- variant: z.Destructive,
904
- close: !0
905
- },
906
- secondaryActions: {
907
- text: "Cancel",
908
- variant: z.Plain,
909
- close: !0
910
- }
911
- }).onPrimary(async () => {
912
- t.open({
913
- title: `Duplicating ${n.name}`,
914
- type: "info"
915
- });
916
- try {
917
- y.value = !0;
918
- const [_] = await Promise.allSettled([
919
- i.duplicatePurchaseOrderTemplate(n._id),
920
- new Promise((I) => setTimeout(I, 1e3))
921
- ]);
922
- if (_.status === "rejected") throw _.reason;
923
- t.open({
924
- title: `Duplicated ${n.name}`,
925
- type: "success"
926
- });
927
- } catch (_) {
928
- t.open({
929
- title: `Unable to duplicate ${n.name}`,
930
- message: `See error from server: ${_}`,
931
- type: "error"
932
- }), console.error("error on duplicating purchase order template", _);
933
- } finally {
934
- y.value = !1, T();
935
- }
936
- });
937
- }
938
- const g = E({});
939
- function r(n) {
940
- g.value = {
941
- template: n,
942
- show: !0,
943
- "onUpdate:show"(y) {
944
- g.value.show = y;
945
- },
946
- "onAction:edit"() {
947
- g.value.show = !1, d(te(n));
948
- }
949
- };
950
- }
951
- function x() {
952
- const { promise: n, resolve: y } = Promise.withResolvers(), T = (b) => {
953
- y(b);
954
- }, _ = l.templates.filter((b) => {
955
- var O, P;
956
- return ((O = b.purchaseOrder.supplier) == null ? void 0 : O._id) === s.currentLocation.doc._id ? !1 : (P = b.locations) != null && P.length ? b.locations.find((U) => U.doc._id === s.currentLocation.doc._id) : !0;
957
- });
958
- if (!_.length)
959
- return e.open({
960
- title: "Select one template",
961
- message: "There is no available template in your business. Configure a new template?",
962
- primaryActions: {
963
- text: "Go to templates",
964
- close: !0
965
- },
966
- secondaryActions: {
967
- text: "Close",
968
- close: !0
969
- }
970
- }).onPrimary(() => {
971
- c.push({ name: ce.TRANSFER_TEMPLATE }), T(void 0);
972
- }).onSecondary(() => T(void 0)).onClose(() => T(void 0)), n;
973
- const I = _.map((b) => {
974
- var se;
975
- const O = !b.purchaseOrder.items.length || b.purchaseOrder.items.some(Te), P = !_t(b.purchaseOrder.supplier), U = b.purchaseOrder.supplier.internal ? f.getNetSuiteLocation(
976
- `${b.purchaseOrder.supplier.internal}_${b.purchaseOrder.supplier._id}`
977
- ) : f.getNetSuiteVendor(b.purchaseOrder.supplier._id), ke = P ? `The subsidiary of the request
978
- location is ${(se = f.getLocationSubsidiary(U == null ? void 0 : U.netSuiteId)) == null ? void 0 : se.fullName}.` : void 0, Ee = O || P, Re = O ? "This template is invalid. Update this template." : P ? ke : void 0, Ae = `${b.purchaseOrder.supplier.internal ? "Transfer" : "Purchase"} from ${b.purchaseOrder.supplier.name}`;
979
- return {
980
- label: b.name,
981
- value: b._id,
982
- disabled: Ee,
983
- sublabel: Re ?? Ae
984
- };
985
- });
986
- return I.sort((b, O) => +!!b.disabled - +!!O.disabled), e.open({
987
- title: "Select one template",
988
- contentComponent: Qe,
989
- contentComponentProps: {
990
- items: I,
991
- singleSelect: !0
992
- },
993
- primaryActions: {
994
- text: "Confirm",
995
- close: !0
996
- },
997
- secondaryActions: {
998
- text: "Close",
999
- close: !0
1000
- },
1001
- tertiaryActions: {
1002
- text: "Templates",
1003
- close: !0
1004
- }
1005
- }).onPrimary((b) => Array.isArray(b) ? T(b[0]) : null).onSecondary(() => T(void 0)).onTertiary(() => {
1006
- c.push({ name: ce.TRANSFER_TEMPLATE }), T(void 0);
1007
- }).onClose(() => T(void 0)), n;
1008
- }
1009
- function w() {
1010
- e.open({
1011
- title: a("inventory.ingredient.import.title"),
1012
- contentComponent: Tt,
1013
- overlay: !0,
1014
- closeButton: !0,
1015
- primaryActions: {
1016
- text: a("common.import"),
1017
- close: !1
1018
- },
1019
- secondaryActions: {
1020
- text: a("common.close"),
1021
- close: !0
1022
- },
1023
- tertiaryActions: {
1024
- text: a("inventory.ingredient.import.actions.downloadTemplate"),
1025
- close: !1,
1026
- variant: "plain"
1027
- }
1028
- }).onPrimary((n) => {
1029
- if (!n) {
1030
- t.open({
1031
- title: a("inventory.ingredient.import.error.noData"),
1032
- type: "error"
1033
- });
1034
- return;
1035
- }
1036
- if (!n.importCreateResult.length && !n.importUpdateResult.length) {
1037
- t.open({
1038
- title: a("inventory.ingredient.import.error.invalidContent"),
1039
- message: a("inventory.ingredient.import.error.noImportData"),
1040
- type: "error"
1041
- });
1042
- return;
1043
- }
1044
- if (n.importCreateResult.some((y) => y.errors.length) || n.importUpdateResult.some((y) => y.errors.length)) {
1045
- t.open({
1046
- title: a("inventory.ingredient.import.error.invalidContent"),
1047
- message: a("inventory.ingredient.import.error.hasErrors"),
1048
- type: "error"
1049
- });
1050
- return;
1051
- }
1052
- e.close(), S(n);
1053
- }).onTertiary(Ze);
1054
- }
1055
- async function S(n) {
1056
- try {
1057
- const y = [
1058
- ...n.importCreateResult.map(
1059
- (b) => b.template
1060
- ),
1061
- ...n.importUpdateResult.map(
1062
- (b) => b.template
1063
- )
1064
- ], T = 100;
1065
- let _ = 0;
1066
- const I = () => {
1067
- _ += T, t.open({
1068
- title: a("inventory.ingredient.import.progress", [
1069
- Math.min(_, y.length),
1070
- y.length
1071
- ])
1072
- });
1073
- };
1074
- for (const b of y.chunk(100))
1075
- I(), await o.importTemplates(b);
1076
- t.open({
1077
- title: a("inventory.ingredient.import.success"),
1078
- type: "success"
1079
- });
1080
- } catch (y) {
1081
- t.open({
1082
- title: a("inventory.ingredient.import.error.failed"),
1083
- message: a("inventory.ingredient.import.error.systemMessage", [y == null ? void 0 : y.message]),
1084
- type: "error"
1085
- }), console.error("Error in importing skus", n, y);
1086
- } finally {
1087
- l.fetchTemplates();
1088
- }
1089
- }
1090
- function p() {
1091
- const n = Je(l.templates);
1092
- t.open({
1093
- title: a("inventory.ingredient.export.success"),
1094
- message: a("inventory.ingredient.export.filename", [n]),
1095
- type: "success"
1096
- });
1097
- }
1098
- return {
1099
- createTemplate: h,
1100
- viewTemplate: r,
1101
- updateTemplate: d,
1102
- deleteTemplate: u,
1103
- duplicateTemplate: v,
1104
- getTemplateId: x,
1105
- importTemplates: w,
1106
- exportTemplates: p,
1107
- templateDialogProps: m,
1108
- templateDetailsProps: g
1109
- };
1110
- });
1111
- function fe(e) {
1112
- const { skuById: t } = V(), s = te(e);
1113
- return s.purchaseOrder.items = e.purchaseOrder.items.filter((l) => t[l.sku._id]), s;
1114
- }
1115
- const Ce = be(
1116
- "transferTemplateTable",
1117
- function() {
1118
- const { t } = ne(), s = $t(), l = E(!1), i = E(new Array()), o = Se(), f = V();
1119
- async function c() {
1120
- i.value = [], l.value = !0;
1121
- try {
1122
- const [d] = await Promise.all([
1123
- o.readTemplates(),
1124
- f.readInventory()
1125
- ]).delayed(1e3);
1126
- i.value = d.map(fe);
1127
- } catch (d) {
1128
- console.log("Something went wrong when fetching templates:", d);
1129
- } finally {
1130
- l.value = !1;
1131
- }
1132
- }
1133
- async function a(d) {
1134
- if (!i.value.find((u) => u._id)) {
1135
- l.value = !0;
1136
- try {
1137
- i.value = [
1138
- await o.getTemplate(d).then(fe).delayed(1e3)
1139
- ];
1140
- } catch (u) {
1141
- console.log("Something went wrong when fetching templates:", u);
1142
- } finally {
1143
- l.value = !1;
1144
- }
1145
- }
1146
- }
1147
- function m(d, u) {
1148
- switch (u = te(u), d) {
1149
- case N.Details:
1150
- return s.viewTemplate(u);
1151
- case N.Edit:
1152
- return s.updateTemplate(u);
1153
- case N.Delete:
1154
- return s.deleteTemplate(u, l, c);
1155
- case N.Duplicate:
1156
- return s.duplicateTemplate(u, l, c);
1157
- }
1158
- }
1159
- return {
1160
- columnDefs: [
1161
- {
1162
- id: "_id",
1163
- accessorKey: "_id",
1164
- header: () => t("inventory.transfer.table.createdAt"),
1165
- cell(d) {
1166
- return He(`${d.getValue()}`);
1167
- },
1168
- enableSorting: !0
1169
- },
1170
- {
1171
- id: "name",
1172
- accessorKey: "name",
1173
- header: () => t("inventory.transfer.table.name"),
1174
- enableSorting: !0,
1175
- size: 200
1176
- },
1177
- {
1178
- id: "supplier",
1179
- accessorKey: "purchaseOrder.supplier.name",
1180
- header: () => t("inventory.transfer.table.from"),
1181
- enableSorting: !0,
1182
- size: 200
1183
- },
1184
- {
1185
- id: "noOfItems",
1186
- accessorKey: "purchaseOrder.items.length",
1187
- header: () => t("inventory.transfer.table.noOfItems"),
1188
- enableSorting: !1,
1189
- meta: {
1190
- width: "10rem",
1191
- textAlign: "right"
1192
- },
1193
- cell(d) {
1194
- const u = Number(d.getValue()) || 0, v = d.row.original.purchaseOrder.items.some(Te);
1195
- return u === 0 || v ? Z("div", { class: "flex justify-end gap-4 items-center" }, [
1196
- Z(
1197
- me.FmTooltip,
1198
- {},
1199
- {
1200
- content() {
1201
- return v ? "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.";
1202
- },
1203
- default() {
1204
- return Z(me.FmIcon, {
1205
- name: "error",
1206
- color: "system-error-300",
1207
- size: "sm"
1208
- });
1209
- }
1210
- }
1211
- ),
1212
- u
1213
- ]) : u;
1214
- }
1215
- },
1216
- {
1217
- id: "enabledLocations",
1218
- accessorKey: "purchaseOrder.locations.length",
1219
- header: () => "Enabled outlets",
1220
- cell(d) {
1221
- var v;
1222
- const u = (v = d.row.original.locations) == null ? void 0 : v.length;
1223
- return u ? `${u}` : "All";
1224
- },
1225
- enableSorting: !1,
1226
- meta: {
1227
- width: "10rem",
1228
- textAlign: "right"
1229
- }
1230
- },
1231
- {
1232
- id: "ref",
1233
- accessorKey: "purchaseOrder.ref",
1234
- header: () => t("inventory.transfer.table.reference"),
1235
- enableSorting: !1,
1236
- size: "auto"
1237
- },
1238
- {
1239
- id: "action",
1240
- cell(d) {
1241
- const u = d.row.original, v = [
1242
- j[N.Details],
1243
- j[N.Edit],
1244
- j[N.Duplicate],
1245
- j[N.Delete]
1246
- ];
1247
- return qe(v, (g) => m(g, u));
1248
- },
1249
- enableSorting: !1,
1250
- size: 40,
1251
- meta: {
1252
- cellClass: "",
1253
- headerClass: ""
1254
- }
1255
- }
1256
- ],
1257
- templates: i,
1258
- loading: l,
1259
- fetchTemplates: c,
1260
- loadTemplate: a
1261
- };
1262
- }
1263
- );
1264
- function Dt(e, t, s) {
1265
- const l = (s == null ? void 0 : s.abbrev) ?? t.abbrev;
1266
- return `${B(e, !1)} ${l}`;
1267
- }
1268
- export {
1269
- R as P,
1270
- Se as a,
1271
- $t as b,
1272
- Dt as f,
1273
- Te as t,
1274
- Ce as u
1275
- };