@feedmepos/mf-inventory-portal 0.0.23-dev.18 → 0.0.23-dev.2

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