@feedmepos/mf-inventory-portal 1.0.37 → 1.0.39

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-PCcAF8Xv.js → App-Bt0e2n-m.js} +1 -1
  2. package/dist/{ApprovalView-CAF8rKoi.js → ApprovalView-BYd63yvj.js} +19 -19
  3. package/dist/{BindingsDialog-DwqG0Hsz.js → BindingsDialog-9D6UOcDp.js} +4 -4
  4. package/dist/{BindingsPicker-Q-I3VeNS.js → BindingsPicker--Vm4weI3.js} +1 -1
  5. package/dist/{BindingsTable-Dg9eIaTK.js → BindingsTable-DGHN8lRO.js} +4 -4
  6. package/dist/{ClosingDraftView-wGfktZWC.js → ClosingDraftView-CH8j-LTL.js} +26 -26
  7. package/dist/ClosingTemplateView-IKON-MRo.js +1849 -0
  8. package/dist/{DeliveryOrderPrintPreview-B0XUNKJb.js → DeliveryOrderPrintPreview-Ck-nrZ3U.js} +4 -4
  9. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-Bgof7EWF.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-Csnq6SpA.js} +11 -11
  10. package/dist/{FmMultiselectDialog-CzkgAIGY.js → FmMultiselectDialog-x_pPeeUw.js} +1 -1
  11. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-CgU3fI7R.js → FmUnitInput.vue_vue_type_script_setup_true_lang-B88hbpoh.js} +21 -21
  12. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-BJ0tegHR.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-DMs8hdak.js} +1 -1
  13. package/dist/{IngredientGroupView-BcTQ0KqW.js → IngredientGroupView-D1qKwLux.js} +2 -2
  14. package/dist/IngredientsView-BeBN6cke.js +1858 -0
  15. package/dist/{IntegrationView-JI6kjKNB.js → IntegrationView-By8g31e5.js} +77 -76
  16. package/dist/{InventoryBindingForm-DeEj_xzq.js → InventoryBindingForm-CU0pvHRP.js} +1 -1
  17. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-BaNc5eeK.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-NxZjLjCh.js} +24 -24
  18. package/dist/{InventoryBindingSummary-Bipyw3xO.js → InventoryBindingSummary-B_y6WR3o.js} +1 -1
  19. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BQBjpBNL.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CPGZh3TN.js} +1 -1
  20. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-DPwHQy_S.js → PremiumBadge.vue_vue_type_script_setup_true_lang-g2XDRfkl.js} +10 -10
  21. package/dist/{PublishView-7XkvtNnX.js → PublishView-B_c-fWDu.js} +17 -17
  22. package/dist/{PurchaseOrderPrintPreview-eSOFS1g6.js → PurchaseOrderPrintPreview-BCRL75HR.js} +12 -12
  23. package/dist/{ReceiveRequestView-BuOj9nZG.js → ReceiveRequestView-BrwJpnEe.js} +797 -782
  24. package/dist/{RecipeView-Bmgrlys8.js → RecipeView-Cn6NY1IO.js} +3 -3
  25. package/dist/{StockView-By7lUolG.js → StockView-DEx5DPM9.js} +6 -6
  26. package/dist/{SupplierView-BP4FxIE9.js → SupplierView-BFNNKC01.js} +3 -3
  27. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-D7k3PiMo.js → TransferDetails.vue_vue_type_script_setup_true_lang-UN-fDAMb.js} +614 -605
  28. package/dist/{TransferTemplateView-C6AXtV1p.js → TransferTemplateView-CS8mbtcf.js} +83 -83
  29. package/dist/{UnitView-CpJT9nbZ.js → UnitView-UKnui3HV.js} +3 -3
  30. package/dist/{WarehouseView-bD9WOJAb.js → WarehouseView-K4AyxptS.js} +1 -1
  31. package/dist/api/duplicate-template.d.ts +5 -0
  32. package/dist/api/inventory.d.ts +4 -0
  33. package/dist/api/netsuite.d.ts +7 -0
  34. package/dist/{app-8I_gNY_C.js → app-DqUjChxa.js} +53154 -52645
  35. package/dist/app.d.ts +9 -0
  36. package/dist/app.js +1 -1
  37. package/dist/components/inventory-binding/InventoryBinding.vue.d.ts +1 -0
  38. package/dist/components/row-action.enum.d.ts +2 -1
  39. package/dist/components/shell/inventory/binding-ui.vue.d.ts +1 -0
  40. package/dist/{decimal-XS-oUZ58.js → decimal-LA_Bg4TZ.js} +1 -1
  41. package/dist/format-unit-display-Btqn8Vdi.js +1275 -0
  42. package/dist/{index-CxWZtTgh.js → index-DlXAEnHf.js} +1 -1
  43. package/dist/{index-ByjAx-mG.js → index-iifMSNu9.js} +1 -1
  44. package/dist/{stock-Di0sHyh2.js → stock-CuKsIhl3.js} +1 -1
  45. package/dist/stores/integration/netsuite.d.ts +7 -1
  46. package/dist/stores/inventory.d.ts +9 -0
  47. package/dist/{supplier-BOti7LMg.js → supplier-C4vIJUP1.js} +1 -1
  48. package/dist/tsconfig.app.tsbuildinfo +1 -1
  49. package/dist/{use-ingredient-select-dialog-DHNa-mhW.js → use-ingredient-select-dialog-Rax2O0HM.js} +1 -1
  50. package/dist/{use-inventory-binding-dialog-CvyHpZHX.js → use-inventory-binding-dialog-DdggFLK-.js} +1 -1
  51. package/dist/views/adjustment-template/wastage-template/actions.d.ts +4 -1
  52. package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftDialog.vue.d.ts +8 -0
  53. package/dist/views/closing-draft/composables/use-closing-draft-table.d.ts +24 -0
  54. package/dist/views/closing-template/components/closing-template-form/composables/use-closing-template-items.d.ts +1 -0
  55. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +16 -1
  56. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +12 -0
  57. package/dist/views/ingredients/components/ingredient-form/IngredientForm.vue.d.ts +2 -0
  58. package/dist/views/ingredients/composables/use-ingredient-table.d.ts +1 -0
  59. package/dist/views/integration/components/netsuite/InventoryTransferIngredientTable.vue.d.ts +2 -0
  60. package/dist/views/integration/components/netsuite/business/BusinessNetSuiteSideSheet.vue.d.ts +4 -0
  61. package/dist/views/receive-request/components/netsuite/NetSuiteLog.vue.d.ts +2 -2
  62. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +17 -0
  63. package/dist/views/receive-request/components/transfer-form/components/ForecastStock.vue.d.ts +2 -0
  64. package/dist/views/receive-request/components/transfer-form/components/TransferItemTable.vue.d.ts +4 -0
  65. package/dist/views/receive-request/components/transfer-form/composables/use-transfer-items.d.ts +1 -0
  66. package/dist/views/receive-request/composables/use-process-purchase-order.d.ts +4 -0
  67. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +24 -0
  68. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +24 -0
  69. package/dist/views/stock/components/dialog/AdjustedItemForm.vue.d.ts +2 -0
  70. package/dist/views/transfer-template/components/transfer-template-dialog/TransferTemplateDialog.vue.d.ts +2 -0
  71. package/dist/views/transfer-template/components/transfer-template-form/components/NetSuiteCustomCodeSelection.vue.d.ts +2 -0
  72. package/dist/views/transfer-template/components/transfer-template-form/components/TransferTemplateItemTable.vue.d.ts +2 -0
  73. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.d.ts +1 -0
  74. package/dist/views/transfer-template/composables/use-netsuite-custom-field.d.ts +3 -0
  75. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +16 -1
  76. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +12 -0
  77. package/dist/{vue-i18n-y6eJldrX.js → vue-i18n-CkkKCDtp.js} +320 -320
  78. package/package.json +3 -3
  79. package/dist/ClosingTemplateView-NRHvagkV.js +0 -1804
  80. package/dist/IngredientsView-Yj3W5zHy.js +0 -1838
  81. package/dist/format-unit-display-Bqbyy60P.js +0 -1230
@@ -1,1230 +0,0 @@
1
- import { a3 as Re, a as H, T as Ie, ag as P, s as Ne, ah as pe, v as fe, u as z, j as M, w as Ae, aI as oe, x as ye, b as Z, t as j, Y as K, aH as Oe, aA as De, a0 as Fe, y as Pe, z as Me, e as ae, f as J, R as se, a2 as Ue, af as Be, D as Y, i as O, h as Le } from "./app-8I_gNY_C.js";
2
- import { useCoreStore as X, useI18n as ee } from "@feedmepos/mf-common";
3
- import { useDialogChild as Qe, useSnackbar as he, useDialog as He, FmButtonVariant as ie, components as le } from "@feedmepos/ui-library";
4
- import { defineStore as ve } from "pinia";
5
- import { defineComponent as ge, resolveComponent as B, openBlock as T, createElementBlock as w, createElementVNode as $, normalizeClass as L, createTextVNode as qe, toDisplayString as I, unref as R, createCommentVNode as Q, createVNode as D, withCtx as G, Fragment as U, renderList as V, ref as C, onMounted as Ve, computed as ce, watch as je, createSlots as ze, createBlock as q, h as W } from "vue";
6
- import { useRouter as Ke } from "vue-router";
7
- import { u as te } from "./supplier-BOti7LMg.js";
8
- const be = Re((e, t) => {
9
- function s() {
10
- var n;
11
- return `business_${((n = X().currentBusiness.value) == null ? void 0 : n._id) ?? ""}`;
12
- }
13
- return {
14
- async getTemplate(l) {
15
- const o = s(), n = `${e.inventoryBackendUrl}/${o}/purchase-order-template/${l}`;
16
- return t.get(n);
17
- },
18
- async readTemplates() {
19
- const l = s(), o = `${e.inventoryBackendUrl}/${l}/purchase-order-template`;
20
- return t.get(o);
21
- },
22
- async createTemplate(l) {
23
- const o = s(), n = `${e.inventoryBackendUrl}/${o}/purchase-order-template`;
24
- return t.post(n, l);
25
- },
26
- async updateTemplate(l) {
27
- const o = s(), n = `${e.inventoryBackendUrl}/${o}/purchase-order-template`;
28
- return t.put(n, l);
29
- },
30
- async deleteTemplate(l) {
31
- const o = s(), n = `${e.inventoryBackendUrl}/${o}/purchase-order-template`;
32
- return t.delete(n, { _id: l._id, _rev: l._rev });
33
- },
34
- async importTemplates(l) {
35
- const o = s(), n = `${e.inventoryBackendUrl}/${o}/purchase-order-template/import`;
36
- return t.post(n, l);
37
- }
38
- };
39
- });
40
- function xe(e) {
41
- const t = H(), s = e.sku, l = t.skuById[s._id];
42
- if (l.unit._id !== s.unit._id) return !0;
43
- const o = e.measurement;
44
- return o ? !t.unitById[l.unit._id].measurements.find((i) => i.id === o.id) : !1;
45
- }
46
- var E = /* @__PURE__ */ ((e) => (e.PURCHASE = "PURCHASE", e.TRANSFER = "TRANSFER", e))(E || {}), re = /* @__PURE__ */ ((e) => (e.Source = "Source", e.Destination = "Destination", e.Ingredient = "Ingredient", e))(re || {});
47
- const me = Ie(0);
48
- function Se(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((o) => o.id === t.trackingMeasurement)) == null ? void 0 : l.abbrev) ?? t.unit.abbrev,
56
- defaultQuantity: +M(e.quantity),
57
- minimumQuantity: +M(e.minimumQuantity ?? me),
58
- maximumQuantity: +M(e.maximumQuantity ?? me),
59
- quantityStep: +M(e.quantityStep)
60
- };
61
- }
62
- function Te() {
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 Ye(e) {
99
- var i;
100
- const s = X().currentBusiness.value, o = (i = e.map((c) => {
101
- var x;
102
- const u = c.purchaseOrder.items.map((r) => Se(r)), h = Te(), p = [
103
- ["Template ID", c._id],
104
- ["Template name", c.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 c.purchaseOrder.supplier.internal == "string" ? E.TRANSFER : E.PURCHASE
111
- ],
112
- [
113
- "Transfer from",
114
- `${c.purchaseOrder.supplier.name} (${[
115
- c.purchaseOrder.supplier.internal,
116
- c.purchaseOrder.supplier._id
117
- ].filter((r) => r).join("_")})`
118
- ],
119
- [
120
- "Locations",
121
- ...(x = c.locations) != null && x.length ? c.locations.map((r) => `${r.name} (${r.dbName})`) : ["All"]
122
- ],
123
- ["Reference", c.purchaseOrder.ref ?? ""],
124
- ["Remark", c.purchaseOrder.remark ?? ""],
125
- [],
126
- h.map((r) => r.name),
127
- ...u.map((r) => h.map((S) => r[S.id]))
128
- ], m = h.map((r) => `system:${r.id}`), v = P(p, m);
129
- return { name: c.name, sheet: v };
130
- }).reduce(
131
- (c, u) => {
132
- var p;
133
- const h = u.name.slice(0, 12);
134
- return (p = c.sheetOccurence)[h] ?? (p[h] = 0), c.sheetOccurence[h] += 1, c.sheets[`${h} (${c.sheetOccurence[h]})`] = u.sheet, c;
135
- },
136
- {
137
- sheets: {},
138
- sheetOccurence: {}
139
- }
140
- )) == null ? void 0 : i.sheets, n = `${s == null ? void 0 : s.name} transfer templates (${Ne(/* @__PURE__ */ new Date())}).xlsx`, y = pe(o);
141
- return fe(y, n), n;
142
- }
143
- function We() {
144
- const e = X(), t = te(), s = z(), l = H(), o = e.currentBusiness.value, n = Se({
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
- }), y = Te(), i = [
176
- ["Template ID (leave empty to create new)"],
177
- ["Template Name", "New template"],
178
- ["Business name", o == null ? void 0 : o.name],
179
- ["Business ID", o == null ? void 0 : o._id],
180
- ["Menu version", o == null ? void 0 : o.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
- y.map((r) => r.name),
196
- y.map((r) => n[r.id])
197
- ], c = y.map((r) => `system:${r.id}`), u = P(i, c), h = P(
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 S, _, f, a, d, g;
211
- return [
212
- `${r.name} (${r.dbName})`,
213
- "Transfer",
214
- (S = r.doc.profile.address) == null ? void 0 : S.line1,
215
- (_ = r.doc.profile.address) == null ? void 0 : _.line2,
216
- (f = r.doc.profile.address) == null ? void 0 : f.city,
217
- (a = r.doc.profile.address) == null ? void 0 : a.postcode,
218
- (d = r.doc.profile.address) == null ? void 0 : d.state,
219
- (g = r.doc.profile.address) == null ? void 0 : g.country
220
- ];
221
- })
222
- ],
223
- ["Name", "Type", "Line 1", "Line 2", "City", "Postal", "State", "Country"]
224
- ), p = P(
225
- s.locations.map((r) => {
226
- var S, _, f, a, d, g;
227
- return [
228
- `${r.name} (${r.dbName})`,
229
- (S = r.doc.profile.address) == null ? void 0 : S.line1,
230
- (_ = r.doc.profile.address) == null ? void 0 : _.line2,
231
- (f = r.doc.profile.address) == null ? void 0 : f.city,
232
- (a = r.doc.profile.address) == null ? void 0 : a.postcode,
233
- (d = r.doc.profile.address) == null ? void 0 : d.state,
234
- (g = r.doc.profile.address) == null ? void 0 : g.country
235
- ];
236
- }),
237
- ["Name", "Line 1", "Line 2", "City", "Postal", "State", "Country"]
238
- ), m = P(
239
- l.skus.map((r) => [
240
- r.code,
241
- r.name,
242
- r.unit.abbrev,
243
- ...r.unit.measurements.map((S) => S.abbrev)
244
- ]),
245
- ["Code", "Name", "Base unit", "Measurements"]
246
- ), v = pe({
247
- Template: u,
248
- Source: h,
249
- Destination: p,
250
- Ingredient: m
251
- }), x = `${o == null ? void 0 : o.name} transfer templates import.xlsx`;
252
- return fe(v, x), x;
253
- }
254
- function Ge(e, t) {
255
- const s = new Array(), l = /(.*) \(((supplier_|warehouse_|restaurant_).{24,})\)/, n = z().locationByDbName, i = te().supplierById, c = e.trim(), u = l.exec(c);
256
- if (!u)
257
- return s.push(`Transfer from location value of ${c} cannot be read.`), {
258
- errors: s
259
- };
260
- const h = u[1], p = u[2];
261
- let m;
262
- if (p.startsWith("supplier"))
263
- m = i[p], t !== E.PURCHASE && s.push(`Expected transfer type Purchase but found ${t} instead.`);
264
- else {
265
- const v = n[p];
266
- if (!v)
267
- return s.push(`Location (${h}) of id ${p} is not found.`), {
268
- errors: s
269
- };
270
- h !== v.name && s.push(
271
- `Location id ${p} has non-matching name. Found ${h} but expected ${v.name}`
272
- ), m = {
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: p.split("_")[0] === "restaurant" ? oe.enum.restaurant : oe.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: m,
293
- errors: s
294
- };
295
- }
296
- function Ze(e) {
297
- if (!e.length || `${e[0]}`.toLocaleLowerCase() === "all")
298
- return [];
299
- const t = /(.*) \(((warehouse_|restaurant_).{24,})\)/, l = z().locationByDbName;
300
- return e.map((o) => {
301
- const n = new Array(), y = o.trim(), i = t.exec(y);
302
- if (!i)
303
- return n.push(`Enabled location value of ${y} cannot be read.`), {
304
- errors: n
305
- };
306
- const c = i[1], u = i[2], h = l[u];
307
- return h ? (c !== h.name && n.push(
308
- `Location id ${u} has non-matching name. Found ${c} but expected ${h.name}`
309
- ), {
310
- errors: n,
311
- location: h
312
- }) : (n.push(`Location (${c}) of id ${u} is not found.`), {
313
- errors: n
314
- });
315
- });
316
- }
317
- function Je(e) {
318
- const [
319
- t,
320
- s,
321
- l,
322
- o,
323
- n,
324
- y,
325
- i,
326
- c,
327
- u,
328
- h,
329
- p
330
- ] = ye(e);
331
- return {
332
- id: `${s[1] ?? ""}`.trim(),
333
- name: `${l[1] ?? ""}`.trim(),
334
- type: `${i[1] ?? ""}`.trim().toLocaleLowerCase() === "transfer" ? E.TRANSFER : E.PURCHASE,
335
- transferFrom: `${c[1] ?? ""}`.trim(),
336
- locations: u.slice(1).map((m) => `${m}`.trim()).filter((m) => m),
337
- reference: `${h[1] ?? ""}`.trim(),
338
- remark: `${p[1] ?? ""}`.trim()
339
- };
340
- }
341
- function Xe(e) {
342
- const [
343
- t,
344
- s,
345
- l,
346
- o,
347
- n,
348
- y,
349
- i,
350
- c,
351
- u,
352
- h,
353
- p,
354
- m,
355
- v,
356
- ...x
357
- ] = ye(e);
358
- if (!t || !t.length || t.some((a) => a.length && !a.startsWith("system:")))
359
- throw new Error("Missing meta header. Excel file does not come from the template.");
360
- const r = t.map((a) => a.split(":")[1]), _ = [
361
- "code",
362
- "name",
363
- "unit",
364
- "defaultQuantity",
365
- "minimumQuantity",
366
- "maximumQuantity",
367
- "quantityStep"
368
- ].filter((a) => !r.includes(a));
369
- if (_.length)
370
- throw new Error(
371
- `Missing meta headers (${_.join()}). Excel file does not come from the template.`
372
- );
373
- return x.map((a, d) => {
374
- const g = {};
375
- for (const k in r) {
376
- const b = r[k];
377
- Object.assign(g, { [b]: a[k] });
378
- }
379
- return {
380
- index: d,
381
- data: g
382
- };
383
- });
384
- }
385
- function et(e, t, s) {
386
- const l = e === "" ? null : j(e, s), o = t === "" ? null : j(t, s), n = l && o && l.amount > o.amount;
387
- return {
388
- min: l,
389
- max: o,
390
- compareError: n ? "Minimum amount must be less than or equal to maximum amount" : void 0
391
- };
392
- }
393
- function tt(e, t, s) {
394
- const l = H(), o = Z(), n = l.skuByCode[e.code], y = new Array();
395
- if (!n)
396
- return y.push(`Cannot find ingredient with code (${e.code}) ${e.name}.`), {
397
- index: t,
398
- errors: y
399
- };
400
- if (s.filter((a) => a.data.code === e.code).length > 1)
401
- return y.push(`Ingredient ${e.code} is defined twice.`), {
402
- index: t,
403
- errors: y
404
- };
405
- const i = n.unit, c = i == null ? void 0 : i.measurements.find((a) => a.abbrev === e.unit);
406
- if (i.abbrev !== e.unit && !c) {
407
- const a = `Cannot find unit measurement of symbol ${e.unit || "[empty]"} for ingredient (${e.code}) ${e.name}.`;
408
- y.push(a);
409
- const d = {
410
- sku: n,
411
- code: e.overrideCode || n.code,
412
- name: n.name,
413
- measurement: c,
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 (o.isEnabled) {
420
- const g = o.getItemPKTCode(n);
421
- g && (d.code = g);
422
- }
423
- return {
424
- index: t,
425
- errors: y,
426
- templateItem: d
427
- };
428
- }
429
- const u = j(
430
- e.quantityStep,
431
- K(i, c)
432
- );
433
- (Number.isNaN(Number(e.quantityStep)) || Number(e.quantityStep) <= 0) && y.push("Amount step must be more than 0");
434
- const h = Oe(u), p = et(
435
- e.minimumQuantity,
436
- e.maximumQuantity,
437
- K(i, c)
438
- ), m = p.min, v = p.max;
439
- p.compareError && y.push(p.compareError);
440
- const x = De(+e.minimumQuantity, +e.maximumQuantity), r = j(
441
- e.defaultQuantity,
442
- K(i, c)
443
- ), S = h(r);
444
- typeof S == "string" && y.push(`Default amount: ${S}`);
445
- const _ = p.min && p.max ? x(`${e.defaultQuantity}`) : null;
446
- typeof _ == "string" && y.push(`Default amount: ${_}`);
447
- const f = {
448
- sku: n,
449
- code: e.overrideCode || n.code,
450
- name: e.name || n.name,
451
- measurement: c,
452
- quantity: r,
453
- quantityStep: u,
454
- minimumQuantity: m,
455
- maximumQuantity: v
456
- };
457
- return {
458
- index: t,
459
- errors: y,
460
- templateItem: f
461
- };
462
- }
463
- function rt(e) {
464
- const t = e.SheetNames.filter(
465
- (n) => !Object.values(re).map(String).includes(n)
466
- ), l = $e().templates, o = Ae(l, "_id");
467
- try {
468
- return t.reduce(
469
- (n, y) => {
470
- var a;
471
- const i = new Array(), c = e.Sheets[y], u = Je(c), h = Ge(u.transferFrom, u.type);
472
- i.push(...h.errors);
473
- const p = h.from, m = Ze(u.locations), v = m.filter((d) => d.location).map((d) => d.location);
474
- i.push(...m.flatMap((d) => d.errors));
475
- const x = Xe(c).filter((d) => d.data.code), r = x.map(
476
- (d, g) => tt(d.data, g, x)
477
- );
478
- i.push(
479
- ...r.flatMap(
480
- (d) => d.errors.map((g) => `(Excel row ${d.index + 14}) ${g}`)
481
- )
482
- );
483
- const S = r.filter((d) => d.templateItem).map((d) => d.templateItem);
484
- if (u.id) {
485
- const d = o[u.id];
486
- if (!d) {
487
- const k = {
488
- _id: u.id,
489
- _rev: "",
490
- name: u.name || `(unnamed from sheet ${y || "<unnamed sheet>"})`,
491
- purchaseOrder: nt()
492
- };
493
- return i.push(`Template ID ${u.id} is not found.`), n.importUpdateResult.push({
494
- type: "update",
495
- original: k,
496
- template: k,
497
- excelSheetName: y,
498
- errors: i
499
- }), n;
500
- }
501
- const g = {
502
- type: "update",
503
- original: d,
504
- template: {
505
- ...d,
506
- name: u.name,
507
- locations: v.length ? v : null,
508
- purchaseOrder: {
509
- ...d.purchaseOrder,
510
- supplier: p ?? ((a = d.purchaseOrder) == null ? void 0 : a.supplier),
511
- ref: u.reference,
512
- remark: u.remark,
513
- items: S
514
- }
515
- },
516
- excelSheetName: y,
517
- errors: i
518
- };
519
- return n.importUpdateResult.push(g), n;
520
- }
521
- const f = {
522
- type: "create",
523
- template: {
524
- name: u.name,
525
- locations: v.length ? v : null,
526
- purchaseOrder: {
527
- supplier: p ?? _e(),
528
- ref: u.reference,
529
- remark: u.remark,
530
- items: S
531
- }
532
- },
533
- excelSheetName: y,
534
- errors: i
535
- };
536
- return n.importCreateResult.push(f), n;
537
- },
538
- {
539
- invalidExcel: !1,
540
- importCreateResult: new Array(),
541
- importUpdateResult: new Array()
542
- }
543
- );
544
- } catch (n) {
545
- return {
546
- invalidExcel: !0,
547
- invalidExcelMessage: (n == null ? void 0 : n.message) ?? "Invalid excel",
548
- importCreateResult: [],
549
- importUpdateResult: []
550
- };
551
- }
552
- }
553
- function _e() {
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 nt() {
568
- return {
569
- remark: void 0,
570
- ref: void 0,
571
- items: [],
572
- supplier: _e()
573
- };
574
- }
575
- const ot = { class: "flex items-center gap-12 pl-8" }, at = { class: "flex flex-col" }, st = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary flex items-center gap-4" }, it = { class: "text-fm-color-typo-secondary fm-typo-en-body-md-400" }, lt = {
576
- key: 0,
577
- class: "text-fm-color-typo-secondary fm-typo-en-body-sm-400"
578
- }, ct = { key: 0 }, ue = /* @__PURE__ */ ge({
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 n, y, i;
591
- const l = B("FmIcon"), o = B("FmTooltip");
592
- return T(), w("div", ot, [
593
- s[0] || (s[0] = $("div", null, "•", -1)),
594
- $("div", at, [
595
- $("div", st, [
596
- $("div", {
597
- class: L({
598
- "text-fm-color-system-error-300": t.errors.length
599
- })
600
- }, [
601
- qe(I(t.name) + " ", 1),
602
- $("span", it, " (" + I(R(Fe)(`${t.transferType}`)) + ") ", 1),
603
- t.type === "create" ? (T(), w("span", lt, "(new)")) : Q("", !0)
604
- ], 2),
605
- t.errors.length ? (T(), w("div", ct, [
606
- D(o, { "z-index": 50 }, {
607
- content: G(() => [
608
- $("ol", null, [
609
- (T(!0), w(U, null, V(t.errors, (c, u) => (T(), w("li", { key: u }, I(c), 1))), 128))
610
- ])
611
- ]),
612
- default: G(() => [
613
- D(l, {
614
- name: "error",
615
- size: "sm",
616
- color: "system-error-300"
617
- })
618
- ]),
619
- _: 1
620
- })
621
- ])) : Q("", !0)
622
- ]),
623
- $("div", {
624
- class: L([
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
- }, I((n = t.locations) != null && n.length ? `${(y = t.locations) == null ? void 0 : y.length} locations` : "All locations") + ", " + I(`${(i = t.items) == null ? void 0 : i.length} items`), 3)
632
- ])
633
- ]);
634
- };
635
- }
636
- }), mt = { class: "flex flex-col gap-24" }, ut = {
637
- key: 0,
638
- class: "flex items-center gap-8"
639
- }, dt = { class: "flex flex-col gap-8" }, pt = { class: "line-clamp-2 text-ellipsis break-all" }, ft = {
640
- key: 2,
641
- class: "shrink-0"
642
- }, yt = {
643
- key: 0,
644
- class: "flex flex-col"
645
- }, ht = { class: "text-fm-color-system-error-300 fm-typo-en-body-sm-400" }, vt = {
646
- key: 0,
647
- class: "max-h-[200px] overflow-y-auto flex flex-col gap-8"
648
- }, gt = { class: "fm-typo-en-body-lg-600" }, bt = /* @__PURE__ */ ge({
649
- __name: "TransferTemplateImport",
650
- setup(e) {
651
- const t = C(null), s = Qe(), l = he(), o = C(!1), n = C(!1), y = te();
652
- Ve(async () => {
653
- n.value = !0;
654
- try {
655
- await y.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
- n.value = !1;
664
- }
665
- });
666
- const i = C(new Array()), c = C([]), u = C([]), h = ce(
667
- () => !!i.value.length || c.value.some((x) => x.errors.length) || u.value.some((x) => x.errors.length)
668
- ), p = ce(
669
- () => !!c.value.length || !!u.value.length
670
- ), { t: m } = ee();
671
- async function v(x) {
672
- i.value = [], c.value = [], u.value = [];
673
- try {
674
- o.value = !0;
675
- const [r] = await Promise.all([
676
- Me(x),
677
- // fake buffer
678
- new Promise((a) => setTimeout(a, 1e3))
679
- ]);
680
- if (!r.SheetNames.filter(
681
- (a) => !Object.values(re).map(String).includes(a)
682
- ).find((a) => a)) {
683
- i.value.push(m("inventory.ingredient.import.fileError.noSheet"));
684
- return;
685
- }
686
- const f = rt(r);
687
- if (f.invalidExcel) {
688
- i.value.push(
689
- f.invalidExcelMessage ?? m("inventory.ingredient.import.fileError.invalidExcel")
690
- );
691
- return;
692
- }
693
- if (c.value = f.importCreateResult, u.value = f.importUpdateResult, !c.value.length && !u.value.length) {
694
- i.value.push(m("inventory.ingredient.import.fileError.noData"));
695
- return;
696
- }
697
- s.emitData(f);
698
- } catch (r) {
699
- l.open({
700
- title: m("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
- i.value.length && l.open({
706
- title: m("inventory.ingredient.import.fileError.invalidExcel"),
707
- type: "error"
708
- }), o.value = !1;
709
- }
710
- }
711
- return je(t, (x) => {
712
- x && v(x);
713
- }), (x, r) => {
714
- const S = B("FmCircularProgress"), _ = B("FmIcon"), f = B("FmButton");
715
- return T(), w("div", mt, [
716
- r[2] || (r[2] = $("div", { class: "fm-typo-en-body-md-400" }, "Import transfer templates from excel sheets.", -1)),
717
- n.value ? (T(), w("div", ut, [
718
- $("div", null, [
719
- D(S, {
720
- size: "md",
721
- color: "neutral-gray-200"
722
- })
723
- ]),
724
- r[1] || (r[1] = $("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "Loading...", -1))
725
- ])) : (T(), w(U, { key: 1 }, [
726
- D(Pe, {
727
- class: L({
728
- "w-full": !0,
729
- "h-[200px]": !t.value
730
- }),
731
- accept: ".xlsx",
732
- onFileUpload: r[0] || (r[0] = (a) => t.value = a),
733
- label: R(m)("inventory.ingredient.import.uploadTemplate"),
734
- "button-label": R(m)("inventory.ingredient.import.selectFile")
735
- }, ze({ _: 2 }, [
736
- t.value ? {
737
- name: "default",
738
- fn: G(({ openFileDialog: a }) => [
739
- $("div", dt, [
740
- $("div", {
741
- class: L([
742
- "fm-corner-radius-md p-16 flex items-center gap-16",
743
- {
744
- "border border-fm-color-neutral-gray-100": o.value,
745
- "border border-fm-color-neutral-gray-200": !o.value && !h.value,
746
- "border border-fm-color-system-error-200": h.value
747
- }
748
- ])
749
- }, [
750
- o.value ? (T(), q(S, {
751
- key: 0,
752
- size: "md",
753
- color: "neutral-gray-200"
754
- })) : (T(), q(_, {
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
- $("div", {
761
- class: L([
762
- "fm-typo-en-body-md-400 flex-1 h-[36px] flex items-center",
763
- {
764
- "text-fm-color-typo-disabled": o.value,
765
- "text-fm-color-typo-primary": !o.value
766
- }
767
- ])
768
- }, [
769
- $("div", pt, I(t.value.name), 1)
770
- ], 2),
771
- o.value ? Q("", !0) : (T(), w("div", ft, [
772
- D(f, {
773
- label: R(m)("inventory.ingredient.import.replaceFile"),
774
- variant: h.value ? "destructive" : "secondary",
775
- "prepend-icon": h.value ? void 0 : "autorenew",
776
- onClick: a
777
- }, null, 8, ["label", "variant", "prepend-icon", "onClick"])
778
- ]))
779
- ], 2),
780
- i.value.length ? (T(), w("div", yt, [
781
- (T(!0), w(U, null, V(i.value, (d, g) => (T(), w("div", {
782
- key: g,
783
- class: "flex gap-8 items-center"
784
- }, [
785
- D(_, {
786
- name: "error",
787
- size: "sm",
788
- color: "system-error-300"
789
- }),
790
- $("div", ht, I(d), 1)
791
- ]))), 128))
792
- ])) : Q("", !0)
793
- ])
794
- ]),
795
- key: "0"
796
- } : void 0
797
- ]), 1032, ["class", "label", "button-label"]),
798
- p.value ? (T(), w("div", vt, [
799
- $("div", gt, I(R(m)("inventory.ingredient.import.summary")), 1),
800
- (T(!0), w(U, null, V(c.value, (a, d) => (T(), q(ue, {
801
- key: d,
802
- name: a.template.name,
803
- "transfer-type": typeof a.template.purchaseOrder.supplier.internal == "string" ? R(E).TRANSFER : R(E).PURCHASE,
804
- locations: a.template.locations,
805
- items: a.template.purchaseOrder.items,
806
- errors: a.errors,
807
- type: "create"
808
- }, null, 8, ["name", "transfer-type", "locations", "items", "errors"]))), 128)),
809
- (T(!0), w(U, null, V(u.value, (a) => (T(), q(ue, {
810
- key: a.template._id,
811
- name: a.template.name,
812
- "transfer-type": typeof a.template.purchaseOrder.supplier.internal == "string" ? R(E).TRANSFER : R(E).PURCHASE,
813
- locations: a.template.locations,
814
- items: a.template.purchaseOrder.items,
815
- errors: a.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 xt(e) {
825
- var n, y;
826
- const t = Z();
827
- if (!t.isEnabled) return !0;
828
- if (!e.internal) {
829
- const i = t.getNetSuiteVendor(e._id), c = i == null ? void 0 : i.subsidiaryId, u = (n = t.currentVendorSubsidiary(e._id)) == null ? void 0 : n.id;
830
- return c && c == u;
831
- }
832
- const s = t.getNetSuiteLocation(`${e.internal}_${e._id}`), l = t.getLocationSubsidiary(s == null ? void 0 : s.netSuiteId).id, o = (y = t.currentLocationSubsidiary()) == null ? void 0 : y.id;
833
- return l && l == o;
834
- }
835
- const St = ve("transferTemplateActions", () => {
836
- const e = He(), t = he(), s = z(), l = $e(), o = be(), n = Z(), y = Ke(), { t: i } = ee(), c = C({});
837
- function u() {
838
- c.value = {
839
- mode: ae.CREATE,
840
- show: !0,
841
- "onUpdate:show"(f) {
842
- c.value.show = f;
843
- }
844
- };
845
- }
846
- function h(f) {
847
- c.value = {
848
- mode: ae.UPDATE,
849
- modelValue: f,
850
- show: !0,
851
- "onUpdate:show"(a) {
852
- c.value.show = a;
853
- }
854
- };
855
- }
856
- function p(f, a, d) {
857
- e.open({
858
- title: `Confirm deleting template ${f.name}?`,
859
- message: "Deleted template can no longer be retrieved",
860
- primaryActions: {
861
- text: "Delete",
862
- variant: ie.Destructive,
863
- close: !0
864
- },
865
- secondaryActions: {
866
- text: "Cancel",
867
- variant: ie.Plain,
868
- close: !0
869
- }
870
- }).onPrimary(async () => {
871
- t.open({
872
- title: `Deleting ${f.name}`,
873
- type: "info"
874
- });
875
- try {
876
- a.value = !0;
877
- const [g] = await Promise.allSettled([
878
- o.deleteTemplate(f),
879
- new Promise((k) => setTimeout(k, 1e3))
880
- ]);
881
- if (g.status === "rejected") throw g.reason;
882
- t.open({
883
- title: `Deleted ${f.name}`,
884
- type: "success"
885
- });
886
- } catch (g) {
887
- t.open({
888
- title: `Unable to delete ${f.name}`,
889
- message: `See error from server: ${g}`,
890
- type: "error"
891
- }), console.error("error on deleting purchase order template", g);
892
- } finally {
893
- a.value = !1, d();
894
- }
895
- });
896
- }
897
- const m = C({});
898
- function v(f) {
899
- m.value = {
900
- template: f,
901
- show: !0,
902
- "onUpdate:show"(a) {
903
- m.value.show = a;
904
- },
905
- "onAction:edit"() {
906
- m.value.show = !1, h(J(f));
907
- }
908
- };
909
- }
910
- function x() {
911
- const { promise: f, resolve: a } = Promise.withResolvers(), d = (b) => {
912
- a(b);
913
- }, g = l.templates.filter((b) => {
914
- var N, A;
915
- return ((N = b.purchaseOrder.supplier) == null ? void 0 : N._id) === s.currentLocation.doc._id ? !1 : (A = b.locations) != null && A.length ? b.locations.find((F) => F.doc._id === s.currentLocation.doc._id) : !0;
916
- });
917
- if (!g.length)
918
- return e.open({
919
- title: "Select one template",
920
- message: "There is no available template in your business. Configure a new template?",
921
- primaryActions: {
922
- text: "Go to templates",
923
- close: !0
924
- },
925
- secondaryActions: {
926
- text: "Close",
927
- close: !0
928
- }
929
- }).onPrimary(() => {
930
- y.push({ name: se.TRANSFER_TEMPLATE }), d(void 0);
931
- }).onSecondary(() => d(void 0)).onClose(() => d(void 0)), f;
932
- const k = g.map((b) => {
933
- var ne;
934
- const N = !b.purchaseOrder.items.length || b.purchaseOrder.items.some(xe), A = !xt(b.purchaseOrder.supplier), F = b.purchaseOrder.supplier.internal ? n.getNetSuiteLocation(
935
- `${b.purchaseOrder.supplier.internal}_${b.purchaseOrder.supplier._id}`
936
- ) : n.getNetSuiteVendor(b.purchaseOrder.supplier._id), we = A ? `The subsidiary of the request
937
- location is ${(ne = n.getLocationSubsidiary(F == null ? void 0 : F.netSuiteId)) == null ? void 0 : ne.fullName}.` : void 0, ke = N || A, Ce = N ? "This template is invalid. Update this template." : A ? we : void 0, Ee = `${b.purchaseOrder.supplier.internal ? "Transfer" : "Purchase"} from ${b.purchaseOrder.supplier.name}`;
938
- return {
939
- label: b.name,
940
- value: b._id,
941
- disabled: ke,
942
- sublabel: Ce ?? Ee
943
- };
944
- });
945
- return k.sort((b, N) => +!!b.disabled - +!!N.disabled), e.open({
946
- title: "Select one template",
947
- contentComponent: Ue,
948
- contentComponentProps: {
949
- items: k,
950
- singleSelect: !0
951
- },
952
- primaryActions: {
953
- text: "Confirm",
954
- close: !0
955
- },
956
- secondaryActions: {
957
- text: "Close",
958
- close: !0
959
- },
960
- tertiaryActions: {
961
- text: "Templates",
962
- close: !0
963
- }
964
- }).onPrimary((b) => Array.isArray(b) ? d(b[0]) : null).onSecondary(() => d(void 0)).onTertiary(() => {
965
- y.push({ name: se.TRANSFER_TEMPLATE }), d(void 0);
966
- }).onClose(() => d(void 0)), f;
967
- }
968
- function r() {
969
- e.open({
970
- title: i("inventory.ingredient.import.title"),
971
- contentComponent: bt,
972
- overlay: !0,
973
- closeButton: !0,
974
- primaryActions: {
975
- text: i("common.import"),
976
- close: !1
977
- },
978
- secondaryActions: {
979
- text: i("common.close"),
980
- close: !0
981
- },
982
- tertiaryActions: {
983
- text: i("inventory.ingredient.import.actions.downloadTemplate"),
984
- close: !1,
985
- variant: "plain"
986
- }
987
- }).onPrimary((f) => {
988
- if (!f) {
989
- t.open({
990
- title: i("inventory.ingredient.import.error.noData"),
991
- type: "error"
992
- });
993
- return;
994
- }
995
- if (!f.importCreateResult.length && !f.importUpdateResult.length) {
996
- t.open({
997
- title: i("inventory.ingredient.import.error.invalidContent"),
998
- message: i("inventory.ingredient.import.error.noImportData"),
999
- type: "error"
1000
- });
1001
- return;
1002
- }
1003
- if (f.importCreateResult.some((a) => a.errors.length) || f.importUpdateResult.some((a) => a.errors.length)) {
1004
- t.open({
1005
- title: i("inventory.ingredient.import.error.invalidContent"),
1006
- message: i("inventory.ingredient.import.error.hasErrors"),
1007
- type: "error"
1008
- });
1009
- return;
1010
- }
1011
- e.close(), S(f);
1012
- }).onTertiary(We);
1013
- }
1014
- async function S(f) {
1015
- try {
1016
- const a = [
1017
- ...f.importCreateResult.map(
1018
- (b) => b.template
1019
- ),
1020
- ...f.importUpdateResult.map(
1021
- (b) => b.template
1022
- )
1023
- ], d = 100;
1024
- let g = 0;
1025
- const k = () => {
1026
- g += d, t.open({
1027
- title: i("inventory.ingredient.import.progress", [
1028
- Math.min(g, a.length),
1029
- a.length
1030
- ])
1031
- });
1032
- };
1033
- for (const b of a.chunk(100))
1034
- k(), await o.importTemplates(b);
1035
- t.open({
1036
- title: i("inventory.ingredient.import.success"),
1037
- type: "success"
1038
- });
1039
- } catch (a) {
1040
- t.open({
1041
- title: i("inventory.ingredient.import.error.failed"),
1042
- message: i("inventory.ingredient.import.error.systemMessage", [a == null ? void 0 : a.message]),
1043
- type: "error"
1044
- }), console.error("Error in importing skus", f, a);
1045
- } finally {
1046
- l.fetchTemplates();
1047
- }
1048
- }
1049
- function _() {
1050
- const f = Ye(l.templates);
1051
- t.open({
1052
- title: i("inventory.ingredient.export.success"),
1053
- message: i("inventory.ingredient.export.filename", [f]),
1054
- type: "success"
1055
- });
1056
- }
1057
- return {
1058
- createTemplate: u,
1059
- viewTemplate: v,
1060
- updateTemplate: h,
1061
- deleteTemplate: p,
1062
- getTemplateId: x,
1063
- importTemplates: r,
1064
- exportTemplates: _,
1065
- templateDialogProps: c,
1066
- templateDetailsProps: m
1067
- };
1068
- });
1069
- function de(e) {
1070
- const { skuById: t } = H(), s = J(e);
1071
- return s.purchaseOrder.items = e.purchaseOrder.items.filter((l) => t[l.sku._id]), s;
1072
- }
1073
- const $e = ve(
1074
- "transferTemplateTable",
1075
- function() {
1076
- const { t } = ee(), s = St(), l = C(!1), o = C(new Array()), n = be(), y = H();
1077
- async function i() {
1078
- o.value = [], l.value = !0;
1079
- try {
1080
- const [p] = await Promise.all([
1081
- n.readTemplates(),
1082
- y.readInventory()
1083
- ]).delayed(1e3);
1084
- o.value = p.map(de);
1085
- } catch (p) {
1086
- console.log("Something went wrong when fetching templates:", p);
1087
- } finally {
1088
- l.value = !1;
1089
- }
1090
- }
1091
- async function c(p) {
1092
- if (!o.value.find((m) => m._id)) {
1093
- l.value = !0;
1094
- try {
1095
- o.value = [
1096
- await n.getTemplate(p).then(de).delayed(1e3)
1097
- ];
1098
- } catch (m) {
1099
- console.log("Something went wrong when fetching templates:", m);
1100
- } finally {
1101
- l.value = !1;
1102
- }
1103
- }
1104
- }
1105
- function u(p, m) {
1106
- switch (m = J(m), p) {
1107
- case O.Details:
1108
- return s.viewTemplate(m);
1109
- case O.Edit:
1110
- return s.updateTemplate(m);
1111
- case O.Delete:
1112
- return s.deleteTemplate(m, l, i);
1113
- }
1114
- }
1115
- return {
1116
- columnDefs: [
1117
- {
1118
- id: "_id",
1119
- accessorKey: "_id",
1120
- header: () => t("inventory.transfer.table.createdAt"),
1121
- cell(p) {
1122
- return Be(`${p.getValue()}`);
1123
- },
1124
- enableSorting: !0
1125
- },
1126
- {
1127
- id: "name",
1128
- accessorKey: "name",
1129
- header: () => t("inventory.transfer.table.name"),
1130
- enableSorting: !0,
1131
- size: 200
1132
- },
1133
- {
1134
- id: "supplier",
1135
- accessorKey: "purchaseOrder.supplier.name",
1136
- header: () => t("inventory.transfer.table.from"),
1137
- enableSorting: !0,
1138
- size: 200
1139
- },
1140
- {
1141
- id: "noOfItems",
1142
- accessorKey: "purchaseOrder.items.length",
1143
- header: () => t("inventory.transfer.table.noOfItems"),
1144
- enableSorting: !1,
1145
- meta: {
1146
- width: "10rem",
1147
- textAlign: "right"
1148
- },
1149
- cell(p) {
1150
- const m = Number(p.getValue()) || 0, v = p.row.original.purchaseOrder.items.some(xe);
1151
- return m === 0 || v ? W("div", { class: "flex justify-end gap-4 items-center" }, [
1152
- W(
1153
- le.FmTooltip,
1154
- {},
1155
- {
1156
- content() {
1157
- 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.";
1158
- },
1159
- default() {
1160
- return W(le.FmIcon, {
1161
- name: "error",
1162
- color: "system-error-300",
1163
- size: "sm"
1164
- });
1165
- }
1166
- }
1167
- ),
1168
- m
1169
- ]) : m;
1170
- }
1171
- },
1172
- {
1173
- id: "enabledLocations",
1174
- accessorKey: "purchaseOrder.locations.length",
1175
- header: () => "Enabled outlets",
1176
- cell(p) {
1177
- var v;
1178
- const m = (v = p.row.original.locations) == null ? void 0 : v.length;
1179
- return m ? `${m}` : "All";
1180
- },
1181
- enableSorting: !1,
1182
- meta: {
1183
- width: "10rem",
1184
- textAlign: "right"
1185
- }
1186
- },
1187
- {
1188
- id: "ref",
1189
- accessorKey: "purchaseOrder.ref",
1190
- header: () => t("inventory.transfer.table.reference"),
1191
- enableSorting: !1,
1192
- size: "auto"
1193
- },
1194
- {
1195
- id: "action",
1196
- cell(p) {
1197
- const m = p.row.original, v = [
1198
- Y[O.Details],
1199
- Y[O.Edit],
1200
- Y[O.Delete]
1201
- ];
1202
- return Le(v, (x) => u(x, m));
1203
- },
1204
- enableSorting: !1,
1205
- size: 40,
1206
- meta: {
1207
- cellClass: "",
1208
- headerClass: ""
1209
- }
1210
- }
1211
- ],
1212
- templates: o,
1213
- loading: l,
1214
- fetchTemplates: i,
1215
- loadTemplate: c
1216
- };
1217
- }
1218
- );
1219
- function It(e, t, s) {
1220
- const l = (s == null ? void 0 : s.abbrev) ?? t.abbrev;
1221
- return `${M(e, !1)} ${l}`;
1222
- }
1223
- export {
1224
- E as P,
1225
- be as a,
1226
- St as b,
1227
- It as f,
1228
- xe as t,
1229
- $e as u
1230
- };