@feedmepos/mf-inventory-portal 0.0.26-dev.7 → 1.0.0
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.
- package/dist/{App-CN1wDbBM.js → App-BXjfROFx.js} +1 -1
- package/dist/{ApprovalView-NvAfknRi.js → ApprovalView-MxDTxv1U.js} +2 -2
- package/dist/{BindingsDialog-BO7Qkm_c.js → BindingsDialog-CReY-EFB.js} +2 -2
- package/dist/{BindingsPicker-D1Ie4pZa.js → BindingsPicker-DrYKe07W.js} +1 -1
- package/dist/{BindingsTable-DU6fi4As.js → BindingsTable-D2CqKDUn.js} +1 -1
- package/dist/{ClosingDraftView-CDnutDbT.js → ClosingDraftView-BQ0VK-Ol.js} +2 -2
- package/dist/{ClosingTemplateView-CX_1xHo6.js → ClosingTemplateView-CWOCuMKw.js} +2 -2
- package/dist/DeliveryOrderPrintPreview-Co2BwN1m.js +206 -0
- package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-BXOnckzO.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-C5jCtYOY.js} +3 -3
- package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-BCx9ypzV.js → FmUnitInput.vue_vue_type_script_setup_true_lang-Bn11PZk4.js} +1 -1
- package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-C6PzUeeG.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-CS1CAuzh.js} +1 -1
- package/dist/{IngredientGroupView-D43MJCpm.js → IngredientGroupView-Cs3ozRSD.js} +1 -1
- package/dist/{IngredientsView-bupdTz_l.js → IngredientsView-DyBRETFi.js} +3 -3
- package/dist/{IntegrationView-C9HVvorY.js → IntegrationView-C2Nc8oFo.js} +2 -2
- package/dist/{InventoryBindingForm-CQWxQF3-.js → InventoryBindingForm-9dXXMr6Z.js} +1 -1
- package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-EJggR11S.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-B4NqOZo4.js} +3 -3
- package/dist/{InventoryBindingSummary-CcnVi7Os.js → InventoryBindingSummary-C5Tv7aR4.js} +24 -23
- package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BKNjM9HR.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DJZXrRPY.js} +1 -1
- package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-miu55qi6.js → PremiumBadge.vue_vue_type_script_setup_true_lang-CbnDa-Vf.js} +1 -1
- package/dist/{PublishView-C-lVtMQl.js → PublishView-8j5LWGWa.js} +2 -2
- package/dist/{PurchaseOrderPrintPreview-ZF_LBN3o.js → PurchaseOrderPrintPreview-CiKvUHxJ.js} +11 -11
- package/dist/{ReceiveRequestView-B5qWCj60.js → ReceiveRequestView-C6BCA6Pf.js} +8 -8
- package/dist/{RecipeView-keeueyyP.js → RecipeView-BVfU7_FV.js} +3 -3
- package/dist/{StockView-T-ABu4nY.js → StockView-D6_XAFbl.js} +6 -6
- package/dist/{SupplierView-CSWB0cdr.js → SupplierView-CR2gkPSN.js} +3 -3
- package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-PBWZaKZJ.js +1722 -0
- package/dist/{TransferTemplateView-_uOaT0PN.js → TransferTemplateView-D31h26QJ.js} +6 -6
- package/dist/{UnitView-DbrwJrRC.js → UnitView-BoPO9xT-.js} +3 -3
- package/dist/{WarehouseView-URBaB_mY.js → WarehouseView-BVQPr2GC.js} +1 -1
- package/dist/{app-DO4zFXhs.js → app-DpFKiToa.js} +15139 -15086
- package/dist/app.d.ts +2 -0
- package/dist/app.js +1 -1
- package/dist/{decimal-BATyV8Kj.js → decimal-Bk6qaQim.js} +1 -1
- package/dist/format-unit-display-DZLCFCVK.js +1223 -0
- package/dist/{index-DIWaRs7y.js → index-DkzC4npa.js} +1 -1
- package/dist/{index-D2Itwzq7.js → index-Gkcv16Cc.js} +1 -1
- package/dist/router/name.d.ts +2 -1
- package/dist/{stock-Cb9IlHZY.js → stock-cg67ntFi.js} +1 -1
- package/dist/stores/feature.d.ts +4 -1
- package/dist/style.css +1 -1
- package/dist/{supplier-ymeKljVS.js → supplier-Dy2QaZ9W.js} +1 -1
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/dist/{use-ingredient-select-dialog-DCuU2XV6.js → use-ingredient-select-dialog-BAJNQkHH.js} +1 -1
- package/dist/{use-inventory-binding-dialog-DsBKAuef.js → use-inventory-binding-dialog-BQEEeZpQ.js} +1 -1
- package/dist/views/receive-request/components/transfer-details/FulfillmentForm.vue.d.ts +15 -0
- package/dist/views/receive-request/helper/print-po.d.ts +2 -1
- package/dist/views/receive-request/print-preview/DeliveryOrderPrintPreview.vue.d.ts +51 -0
- package/dist/{vue-i18n-CZiAQszg.js → vue-i18n-C89e3sXt.js} +473 -473
- package/package.json +2 -2
- package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-B8EKBH4q.js +0 -1566
- package/dist/format-unit-display-CLyqfHfQ.js +0 -1217
|
@@ -1,1217 +0,0 @@
|
|
|
1
|
-
import { Y as Ee, a as H, L as Ie, ab as P, s as Ae, ac as pe, v as fe, u as K, j as U, w as Ne, aD as oe, x as ye, b as J, t as q, Q as V, aC as De, av as Oe, W as Fe, y as Pe, z as Ue, e as ae, f as Z, R as se, J as Be, aa as Me, D as W, i as D, h as Le } from "./app-DO4zFXhs.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 M, openBlock as T, createElementBlock as w, createElementVNode as $, normalizeClass as L, createTextVNode as qe, toDisplayString as I, unref as E, createCommentVNode as Q, createVNode as O, withCtx as G, Fragment as B, renderList as z, ref as C, onMounted as Ve, computed as ce, watch as je, createSlots as ze, createBlock as j, h as Y } from "vue";
|
|
6
|
-
import { useRouter as Ke } from "vue-router";
|
|
7
|
-
import { u as te } from "./supplier-ymeKljVS.js";
|
|
8
|
-
const be = Ee((e, t) => {
|
|
9
|
-
function i() {
|
|
10
|
-
var n;
|
|
11
|
-
return `business_${((n = X().currentBusiness.value) == null ? void 0 : n._id) ?? ""}`;
|
|
12
|
-
}
|
|
13
|
-
return {
|
|
14
|
-
async getTemplate(c) {
|
|
15
|
-
const a = i(), n = `${e.inventoryBackendUrl}/${a}/purchase-order-template/${c}`;
|
|
16
|
-
return t.get(n);
|
|
17
|
-
},
|
|
18
|
-
async readTemplates() {
|
|
19
|
-
const c = i(), a = `${e.inventoryBackendUrl}/${c}/purchase-order-template`;
|
|
20
|
-
return t.get(a);
|
|
21
|
-
},
|
|
22
|
-
async createTemplate(c) {
|
|
23
|
-
const a = i(), n = `${e.inventoryBackendUrl}/${a}/purchase-order-template`;
|
|
24
|
-
return t.post(n, c);
|
|
25
|
-
},
|
|
26
|
-
async updateTemplate(c) {
|
|
27
|
-
const a = i(), n = `${e.inventoryBackendUrl}/${a}/purchase-order-template`;
|
|
28
|
-
return t.put(n, c);
|
|
29
|
-
},
|
|
30
|
-
async deleteTemplate(c) {
|
|
31
|
-
const a = i(), n = `${e.inventoryBackendUrl}/${a}/purchase-order-template`;
|
|
32
|
-
return t.delete(n, { _id: c._id, _rev: c._rev });
|
|
33
|
-
},
|
|
34
|
-
async importTemplates(c) {
|
|
35
|
-
const a = i(), n = `${e.inventoryBackendUrl}/${a}/purchase-order-template/import`;
|
|
36
|
-
return t.post(n, c);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
});
|
|
40
|
-
function Se(e) {
|
|
41
|
-
const t = H(), i = e.sku, c = t.skuById[i._id];
|
|
42
|
-
if (c.unit._id !== i.unit._id) return !0;
|
|
43
|
-
const a = e.measurement;
|
|
44
|
-
return a ? !t.unitById[c.unit._id].measurements.find((o) => o.id === a.id) : !1;
|
|
45
|
-
}
|
|
46
|
-
var R = /* @__PURE__ */ ((e) => (e.PURCHASE = "PURCHASE", e.TRANSFER = "TRANSFER", e))(R || {}), re = /* @__PURE__ */ ((e) => (e.Source = "Source", e.Destination = "Destination", e.Ingredient = "Ingredient", e))(re || {});
|
|
47
|
-
const me = Ie(0);
|
|
48
|
-
function xe(e) {
|
|
49
|
-
var c;
|
|
50
|
-
const t = e.sku;
|
|
51
|
-
return {
|
|
52
|
-
code: t.code,
|
|
53
|
-
overrideCode: e.code,
|
|
54
|
-
name: t.name,
|
|
55
|
-
unit: ((c = t.unit.measurements.find((a) => a.id === t.trackingMeasurement)) == null ? void 0 : c.abbrev) ?? t.unit.abbrev,
|
|
56
|
-
defaultQuantity: +U(e.quantity),
|
|
57
|
-
minimumQuantity: +U(e.minimumQuantity ?? me),
|
|
58
|
-
maximumQuantity: +U(e.maximumQuantity ?? me),
|
|
59
|
-
quantityStep: +U(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 We(e) {
|
|
99
|
-
var o;
|
|
100
|
-
const i = X().currentBusiness.value, a = (o = e.map((l) => {
|
|
101
|
-
var b;
|
|
102
|
-
const d = l.purchaseOrder.items.map((r) => xe(r)), h = Te(), y = [
|
|
103
|
-
["Template ID", l._id],
|
|
104
|
-
["Template name", l.name],
|
|
105
|
-
["Business name", i == null ? void 0 : i.name],
|
|
106
|
-
["Business ID", i == null ? void 0 : i._id],
|
|
107
|
-
["Menu version", i == null ? void 0 : i.menuVersion],
|
|
108
|
-
[
|
|
109
|
-
"Purchase/Transfer",
|
|
110
|
-
typeof l.purchaseOrder.supplier.internal == "string" ? R.TRANSFER : R.PURCHASE
|
|
111
|
-
],
|
|
112
|
-
[
|
|
113
|
-
"Transfer from",
|
|
114
|
-
`${l.purchaseOrder.supplier.name} (${[
|
|
115
|
-
l.purchaseOrder.supplier.internal,
|
|
116
|
-
l.purchaseOrder.supplier._id
|
|
117
|
-
].filter((r) => r).join("_")})`
|
|
118
|
-
],
|
|
119
|
-
[
|
|
120
|
-
"Locations",
|
|
121
|
-
...(b = l.locations) != null && b.length ? l.locations.map((r) => `${r.name} (${r.dbName})`) : ["All"]
|
|
122
|
-
],
|
|
123
|
-
["Reference", l.purchaseOrder.ref ?? ""],
|
|
124
|
-
["Remark", l.purchaseOrder.remark ?? ""],
|
|
125
|
-
[],
|
|
126
|
-
h.map((r) => r.name),
|
|
127
|
-
...d.map((r) => h.map((x) => r[x.id]))
|
|
128
|
-
], m = h.map((r) => `system:${r.id}`), v = P(y, m);
|
|
129
|
-
return { name: l.name, sheet: v };
|
|
130
|
-
}).reduce(
|
|
131
|
-
(l, d) => {
|
|
132
|
-
var y;
|
|
133
|
-
const h = d.name.slice(0, 12);
|
|
134
|
-
return (y = l.sheetOccurence)[h] ?? (y[h] = 0), l.sheetOccurence[h] += 1, l.sheets[`${h} (${l.sheetOccurence[h]})`] = d.sheet, l;
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
sheets: {},
|
|
138
|
-
sheetOccurence: {}
|
|
139
|
-
}
|
|
140
|
-
)) == null ? void 0 : o.sheets, n = `${i == null ? void 0 : i.name} transfer templates (${Ae(/* @__PURE__ */ new Date())}).xlsx`, f = pe(a);
|
|
141
|
-
return fe(f, n), n;
|
|
142
|
-
}
|
|
143
|
-
function Ye() {
|
|
144
|
-
const e = X(), t = te(), i = K(), c = H(), a = e.currentBusiness.value, n = xe({
|
|
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 = Te(), o = [
|
|
176
|
-
["Template ID (leave empty to create new)"],
|
|
177
|
-
["Template Name", "New template"],
|
|
178
|
-
["Business name", a == null ? void 0 : a.name],
|
|
179
|
-
["Business ID", a == null ? void 0 : a._id],
|
|
180
|
-
["Menu version", a == null ? void 0 : a.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) => n[r.id])
|
|
197
|
-
], l = f.map((r) => `system:${r.id}`), d = P(o, l), 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
|
-
...i.locations.map((r) => {
|
|
210
|
-
var x, _, u, s, p, S;
|
|
211
|
-
return [
|
|
212
|
-
`${r.name} (${r.dbName})`,
|
|
213
|
-
"Transfer",
|
|
214
|
-
(x = r.doc.profile.address) == null ? void 0 : x.line1,
|
|
215
|
-
(_ = r.doc.profile.address) == null ? void 0 : _.line2,
|
|
216
|
-
(u = r.doc.profile.address) == null ? void 0 : u.city,
|
|
217
|
-
(s = r.doc.profile.address) == null ? void 0 : s.postcode,
|
|
218
|
-
(p = r.doc.profile.address) == null ? void 0 : p.state,
|
|
219
|
-
(S = r.doc.profile.address) == null ? void 0 : S.country
|
|
220
|
-
];
|
|
221
|
-
})
|
|
222
|
-
],
|
|
223
|
-
["Name", "Type", "Line 1", "Line 2", "City", "Postal", "State", "Country"]
|
|
224
|
-
), y = P(
|
|
225
|
-
i.locations.map((r) => {
|
|
226
|
-
var x, _, u, s, p, S;
|
|
227
|
-
return [
|
|
228
|
-
`${r.name} (${r.dbName})`,
|
|
229
|
-
(x = r.doc.profile.address) == null ? void 0 : x.line1,
|
|
230
|
-
(_ = r.doc.profile.address) == null ? void 0 : _.line2,
|
|
231
|
-
(u = r.doc.profile.address) == null ? void 0 : u.city,
|
|
232
|
-
(s = r.doc.profile.address) == null ? void 0 : s.postcode,
|
|
233
|
-
(p = r.doc.profile.address) == null ? void 0 : p.state,
|
|
234
|
-
(S = r.doc.profile.address) == null ? void 0 : S.country
|
|
235
|
-
];
|
|
236
|
-
}),
|
|
237
|
-
["Name", "Line 1", "Line 2", "City", "Postal", "State", "Country"]
|
|
238
|
-
), m = P(
|
|
239
|
-
c.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 = pe({
|
|
247
|
-
Template: d,
|
|
248
|
-
Source: h,
|
|
249
|
-
Destination: y,
|
|
250
|
-
Ingredient: m
|
|
251
|
-
}), b = `${a == null ? void 0 : a.name} transfer templates import.xlsx`;
|
|
252
|
-
return fe(v, b), b;
|
|
253
|
-
}
|
|
254
|
-
function Ge(e, t) {
|
|
255
|
-
const i = new Array(), c = /(.*) \(((supplier_|warehouse_|restaurant_).{24,})\)/, n = K().locationByDbName, o = te().supplierById, l = e.trim(), d = c.exec(l);
|
|
256
|
-
if (!d)
|
|
257
|
-
return i.push(`Transfer from location value of ${l} cannot be read.`), {
|
|
258
|
-
errors: i
|
|
259
|
-
};
|
|
260
|
-
const h = d[1], y = d[2];
|
|
261
|
-
let m;
|
|
262
|
-
if (y.startsWith("supplier"))
|
|
263
|
-
m = o[y], t !== R.PURCHASE && i.push(`Expected transfer type Purchase but found ${t} instead.`);
|
|
264
|
-
else {
|
|
265
|
-
const v = n[y];
|
|
266
|
-
if (!v)
|
|
267
|
-
return i.push(`Location (${h}) of id ${y} is not found.`), {
|
|
268
|
-
errors: i
|
|
269
|
-
};
|
|
270
|
-
h !== v.name && i.push(
|
|
271
|
-
`Location id ${y} 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: y.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: i
|
|
294
|
-
};
|
|
295
|
-
}
|
|
296
|
-
function Je(e) {
|
|
297
|
-
if (!e.length || `${e[0]}`.toLocaleLowerCase() === "all")
|
|
298
|
-
return [];
|
|
299
|
-
const t = /(.*) \(((warehouse_|restaurant_).{24,})\)/, c = K().locationByDbName;
|
|
300
|
-
return e.map((a) => {
|
|
301
|
-
const n = new Array(), f = a.trim(), o = t.exec(f);
|
|
302
|
-
if (!o)
|
|
303
|
-
return n.push(`Enabled location value of ${f} cannot be read.`), {
|
|
304
|
-
errors: n
|
|
305
|
-
};
|
|
306
|
-
const l = o[1], d = o[2], h = c[d];
|
|
307
|
-
return h ? (l !== h.name && n.push(
|
|
308
|
-
`Location id ${d} has non-matching name. Found ${l} but expected ${h.name}`
|
|
309
|
-
), {
|
|
310
|
-
errors: n,
|
|
311
|
-
location: h
|
|
312
|
-
}) : (n.push(`Location (${l}) of id ${d} is not found.`), {
|
|
313
|
-
errors: n
|
|
314
|
-
});
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
function Ze(e) {
|
|
318
|
-
const [
|
|
319
|
-
t,
|
|
320
|
-
i,
|
|
321
|
-
c,
|
|
322
|
-
a,
|
|
323
|
-
n,
|
|
324
|
-
f,
|
|
325
|
-
o,
|
|
326
|
-
l,
|
|
327
|
-
d,
|
|
328
|
-
h,
|
|
329
|
-
y
|
|
330
|
-
] = ye(e);
|
|
331
|
-
return {
|
|
332
|
-
id: `${i[1] ?? ""}`.trim(),
|
|
333
|
-
name: `${c[1] ?? ""}`.trim(),
|
|
334
|
-
type: `${o[1] ?? ""}`.trim().toLocaleLowerCase() === "transfer" ? R.TRANSFER : R.PURCHASE,
|
|
335
|
-
transferFrom: `${l[1] ?? ""}`.trim(),
|
|
336
|
-
locations: d.slice(1).map((m) => `${m}`.trim()).filter((m) => m),
|
|
337
|
-
reference: `${h[1] ?? ""}`.trim(),
|
|
338
|
-
remark: `${y[1] ?? ""}`.trim()
|
|
339
|
-
};
|
|
340
|
-
}
|
|
341
|
-
function Xe(e) {
|
|
342
|
-
const [
|
|
343
|
-
t,
|
|
344
|
-
i,
|
|
345
|
-
c,
|
|
346
|
-
a,
|
|
347
|
-
n,
|
|
348
|
-
f,
|
|
349
|
-
o,
|
|
350
|
-
l,
|
|
351
|
-
d,
|
|
352
|
-
h,
|
|
353
|
-
y,
|
|
354
|
-
m,
|
|
355
|
-
v,
|
|
356
|
-
...b
|
|
357
|
-
] = ye(e);
|
|
358
|
-
if (!t || !t.length || t.some((s) => s.length && !s.startsWith("system:")))
|
|
359
|
-
throw new Error("Missing meta header. Excel file does not come from the template.");
|
|
360
|
-
const r = t.map((s) => s.split(":")[1]), _ = [
|
|
361
|
-
"code",
|
|
362
|
-
"name",
|
|
363
|
-
"unit",
|
|
364
|
-
"defaultQuantity",
|
|
365
|
-
"minimumQuantity",
|
|
366
|
-
"maximumQuantity",
|
|
367
|
-
"quantityStep"
|
|
368
|
-
].filter((s) => !r.includes(s));
|
|
369
|
-
if (_.length)
|
|
370
|
-
throw new Error(
|
|
371
|
-
`Missing meta headers (${_.join()}). Excel file does not come from the template.`
|
|
372
|
-
);
|
|
373
|
-
return b.map((s, p) => {
|
|
374
|
-
const S = {};
|
|
375
|
-
for (const k in r) {
|
|
376
|
-
const g = r[k];
|
|
377
|
-
Object.assign(S, { [g]: s[k] });
|
|
378
|
-
}
|
|
379
|
-
return {
|
|
380
|
-
index: p,
|
|
381
|
-
data: S
|
|
382
|
-
};
|
|
383
|
-
});
|
|
384
|
-
}
|
|
385
|
-
function et(e, t, i) {
|
|
386
|
-
const c = H(), a = J(), n = c.skuByCode[e.code], f = new Array();
|
|
387
|
-
if (!n)
|
|
388
|
-
return f.push(`Cannot find ingredient with code (${e.code}) ${e.name}.`), {
|
|
389
|
-
index: t,
|
|
390
|
-
errors: f
|
|
391
|
-
};
|
|
392
|
-
if (i.filter((u) => u.data.code === e.code).length > 1)
|
|
393
|
-
return f.push(`Ingredient ${e.code} is defined twice.`), {
|
|
394
|
-
index: t,
|
|
395
|
-
errors: f
|
|
396
|
-
};
|
|
397
|
-
const o = n.unit, l = o == null ? void 0 : o.measurements.find((u) => u.abbrev === e.unit);
|
|
398
|
-
if (o.abbrev !== e.unit && !l) {
|
|
399
|
-
const u = `Cannot find unit measurement of symbol ${e.unit || "[empty]"} for ingredient (${e.code}) ${e.name}.`;
|
|
400
|
-
f.push(u);
|
|
401
|
-
const s = {
|
|
402
|
-
sku: n,
|
|
403
|
-
code: e.overrideCode || n.code,
|
|
404
|
-
name: n.name,
|
|
405
|
-
measurement: l,
|
|
406
|
-
quantity: { amount: 0, precision: 0 },
|
|
407
|
-
quantityStep: { amount: 0, precision: 0 },
|
|
408
|
-
minimumQuantity: { amount: 0, precision: 0 },
|
|
409
|
-
maximumQuantity: { amount: 0, precision: 0 }
|
|
410
|
-
};
|
|
411
|
-
if (a.isEnabled) {
|
|
412
|
-
const p = a.getItemPKTCode(n);
|
|
413
|
-
p && (s.code = p);
|
|
414
|
-
}
|
|
415
|
-
return {
|
|
416
|
-
index: t,
|
|
417
|
-
errors: f,
|
|
418
|
-
templateItem: s
|
|
419
|
-
};
|
|
420
|
-
}
|
|
421
|
-
const d = q(
|
|
422
|
-
e.quantityStep,
|
|
423
|
-
V(o, l)
|
|
424
|
-
);
|
|
425
|
-
(Number.isNaN(Number(e.quantityStep)) || Number(e.quantityStep) <= 0) && f.push("Amount step must be more than 0");
|
|
426
|
-
const h = De(d), y = q(
|
|
427
|
-
e.minimumQuantity,
|
|
428
|
-
V(o, l)
|
|
429
|
-
);
|
|
430
|
-
h(y);
|
|
431
|
-
const m = q(
|
|
432
|
-
e.maximumQuantity,
|
|
433
|
-
V(o, l)
|
|
434
|
-
);
|
|
435
|
-
h(m), +e.minimumQuantity > +e.maximumQuantity && f.push("Minimum amount must be less than or equal to maximum amount");
|
|
436
|
-
const v = Oe(+e.minimumQuantity, +e.maximumQuantity), b = q(
|
|
437
|
-
e.defaultQuantity,
|
|
438
|
-
V(o, l)
|
|
439
|
-
), r = h(b), x = v(`${e.defaultQuantity}`);
|
|
440
|
-
typeof r == "string" && f.push(`Default amount: ${r}`), typeof x == "string" && f.push(`Default amount: ${x}`);
|
|
441
|
-
const _ = {
|
|
442
|
-
sku: n,
|
|
443
|
-
code: e.overrideCode || n.code,
|
|
444
|
-
name: e.name || n.name,
|
|
445
|
-
measurement: l,
|
|
446
|
-
quantity: b,
|
|
447
|
-
quantityStep: d,
|
|
448
|
-
minimumQuantity: y,
|
|
449
|
-
maximumQuantity: m
|
|
450
|
-
};
|
|
451
|
-
return {
|
|
452
|
-
index: t,
|
|
453
|
-
errors: f,
|
|
454
|
-
templateItem: _
|
|
455
|
-
};
|
|
456
|
-
}
|
|
457
|
-
function tt(e) {
|
|
458
|
-
const t = e.SheetNames.filter(
|
|
459
|
-
(n) => !Object.values(re).map(String).includes(n)
|
|
460
|
-
), c = $e().templates, a = Ne(c, "_id");
|
|
461
|
-
try {
|
|
462
|
-
return t.reduce(
|
|
463
|
-
(n, f) => {
|
|
464
|
-
var s;
|
|
465
|
-
const o = new Array(), l = e.Sheets[f], d = Ze(l), h = Ge(d.transferFrom, d.type);
|
|
466
|
-
o.push(...h.errors);
|
|
467
|
-
const y = h.from, m = Je(d.locations), v = m.filter((p) => p.location).map((p) => p.location);
|
|
468
|
-
o.push(...m.flatMap((p) => p.errors));
|
|
469
|
-
const b = Xe(l).filter((p) => p.data.code), r = b.map(
|
|
470
|
-
(p, S) => et(p.data, S, b)
|
|
471
|
-
);
|
|
472
|
-
o.push(
|
|
473
|
-
...r.flatMap(
|
|
474
|
-
(p) => p.errors.map((S) => `(Excel row ${p.index + 14}) ${S}`)
|
|
475
|
-
)
|
|
476
|
-
);
|
|
477
|
-
const x = r.filter((p) => p.templateItem).map((p) => p.templateItem);
|
|
478
|
-
if (d.id) {
|
|
479
|
-
const p = a[d.id];
|
|
480
|
-
if (!p) {
|
|
481
|
-
const k = {
|
|
482
|
-
_id: d.id,
|
|
483
|
-
_rev: "",
|
|
484
|
-
name: d.name || `(unnamed from sheet ${f || "<unnamed sheet>"})`,
|
|
485
|
-
purchaseOrder: rt()
|
|
486
|
-
};
|
|
487
|
-
return o.push(`Template ID ${d.id} is not found.`), n.importUpdateResult.push({
|
|
488
|
-
type: "update",
|
|
489
|
-
original: k,
|
|
490
|
-
template: k,
|
|
491
|
-
excelSheetName: f,
|
|
492
|
-
errors: o
|
|
493
|
-
}), n;
|
|
494
|
-
}
|
|
495
|
-
const S = {
|
|
496
|
-
type: "update",
|
|
497
|
-
original: p,
|
|
498
|
-
template: {
|
|
499
|
-
...p,
|
|
500
|
-
name: d.name,
|
|
501
|
-
locations: v.length ? v : null,
|
|
502
|
-
purchaseOrder: {
|
|
503
|
-
...p.purchaseOrder,
|
|
504
|
-
supplier: y ?? ((s = p.purchaseOrder) == null ? void 0 : s.supplier),
|
|
505
|
-
ref: d.reference,
|
|
506
|
-
remark: d.remark,
|
|
507
|
-
items: x
|
|
508
|
-
}
|
|
509
|
-
},
|
|
510
|
-
excelSheetName: f,
|
|
511
|
-
errors: o
|
|
512
|
-
};
|
|
513
|
-
return n.importUpdateResult.push(S), n;
|
|
514
|
-
}
|
|
515
|
-
const u = {
|
|
516
|
-
type: "create",
|
|
517
|
-
template: {
|
|
518
|
-
name: d.name,
|
|
519
|
-
locations: v.length ? v : null,
|
|
520
|
-
purchaseOrder: {
|
|
521
|
-
supplier: y ?? _e(),
|
|
522
|
-
ref: d.reference,
|
|
523
|
-
remark: d.remark,
|
|
524
|
-
items: x
|
|
525
|
-
}
|
|
526
|
-
},
|
|
527
|
-
excelSheetName: f,
|
|
528
|
-
errors: o
|
|
529
|
-
};
|
|
530
|
-
return n.importCreateResult.push(u), n;
|
|
531
|
-
},
|
|
532
|
-
{
|
|
533
|
-
invalidExcel: !1,
|
|
534
|
-
importCreateResult: new Array(),
|
|
535
|
-
importUpdateResult: new Array()
|
|
536
|
-
}
|
|
537
|
-
);
|
|
538
|
-
} catch (n) {
|
|
539
|
-
return {
|
|
540
|
-
invalidExcel: !0,
|
|
541
|
-
invalidExcelMessage: (n == null ? void 0 : n.message) ?? "Invalid excel",
|
|
542
|
-
importCreateResult: [],
|
|
543
|
-
importUpdateResult: []
|
|
544
|
-
};
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
function _e() {
|
|
548
|
-
return {
|
|
549
|
-
_id: "",
|
|
550
|
-
name: "",
|
|
551
|
-
address: {
|
|
552
|
-
line2: void 0,
|
|
553
|
-
line1: "",
|
|
554
|
-
state: "",
|
|
555
|
-
city: "",
|
|
556
|
-
postcode: "",
|
|
557
|
-
country: ""
|
|
558
|
-
}
|
|
559
|
-
};
|
|
560
|
-
}
|
|
561
|
-
function rt() {
|
|
562
|
-
return {
|
|
563
|
-
remark: void 0,
|
|
564
|
-
ref: void 0,
|
|
565
|
-
items: [],
|
|
566
|
-
supplier: _e()
|
|
567
|
-
};
|
|
568
|
-
}
|
|
569
|
-
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 = {
|
|
570
|
-
key: 0,
|
|
571
|
-
class: "text-fm-color-typo-secondary fm-typo-en-body-sm-400"
|
|
572
|
-
}, lt = { key: 0 }, ue = /* @__PURE__ */ ge({
|
|
573
|
-
__name: "TransferTemplateImportItem",
|
|
574
|
-
props: {
|
|
575
|
-
type: {},
|
|
576
|
-
name: {},
|
|
577
|
-
transferType: {},
|
|
578
|
-
locations: {},
|
|
579
|
-
items: {},
|
|
580
|
-
errors: {}
|
|
581
|
-
},
|
|
582
|
-
setup(e) {
|
|
583
|
-
return (t, i) => {
|
|
584
|
-
var n, f, o;
|
|
585
|
-
const c = M("FmIcon"), a = M("FmTooltip");
|
|
586
|
-
return T(), w("div", nt, [
|
|
587
|
-
i[0] || (i[0] = $("div", null, "•", -1)),
|
|
588
|
-
$("div", ot, [
|
|
589
|
-
$("div", at, [
|
|
590
|
-
$("div", {
|
|
591
|
-
class: L({
|
|
592
|
-
"text-fm-color-system-error-300": t.errors.length
|
|
593
|
-
})
|
|
594
|
-
}, [
|
|
595
|
-
qe(I(t.name) + " ", 1),
|
|
596
|
-
$("span", st, " (" + I(E(Fe)(`${t.transferType}`)) + ") ", 1),
|
|
597
|
-
t.type === "create" ? (T(), w("span", it, "(new)")) : Q("", !0)
|
|
598
|
-
], 2),
|
|
599
|
-
t.errors.length ? (T(), w("div", lt, [
|
|
600
|
-
O(a, { "z-index": 50 }, {
|
|
601
|
-
content: G(() => [
|
|
602
|
-
$("ol", null, [
|
|
603
|
-
(T(!0), w(B, null, z(t.errors, (l, d) => (T(), w("li", { key: d }, I(l), 1))), 128))
|
|
604
|
-
])
|
|
605
|
-
]),
|
|
606
|
-
default: G(() => [
|
|
607
|
-
O(c, {
|
|
608
|
-
name: "error",
|
|
609
|
-
size: "sm",
|
|
610
|
-
color: "system-error-300"
|
|
611
|
-
})
|
|
612
|
-
]),
|
|
613
|
-
_: 1
|
|
614
|
-
})
|
|
615
|
-
])) : Q("", !0)
|
|
616
|
-
]),
|
|
617
|
-
$("div", {
|
|
618
|
-
class: L([
|
|
619
|
-
"fm-typo-en-body-sm-400",
|
|
620
|
-
{
|
|
621
|
-
"text-fm-color-system-error-200": t.errors.length,
|
|
622
|
-
"text-fm-color-typo-secondary": !t.errors.length
|
|
623
|
-
}
|
|
624
|
-
])
|
|
625
|
-
}, I((n = t.locations) != null && n.length ? `${(f = t.locations) == null ? void 0 : f.length} locations` : "All locations") + ", " + I(`${(o = t.items) == null ? void 0 : o.length} items`), 3)
|
|
626
|
-
])
|
|
627
|
-
]);
|
|
628
|
-
};
|
|
629
|
-
}
|
|
630
|
-
}), ct = { class: "flex flex-col gap-24" }, mt = {
|
|
631
|
-
key: 0,
|
|
632
|
-
class: "flex items-center gap-8"
|
|
633
|
-
}, ut = { class: "flex flex-col gap-8" }, dt = { class: "line-clamp-2 text-ellipsis break-all" }, pt = {
|
|
634
|
-
key: 2,
|
|
635
|
-
class: "shrink-0"
|
|
636
|
-
}, ft = {
|
|
637
|
-
key: 0,
|
|
638
|
-
class: "flex flex-col"
|
|
639
|
-
}, yt = { class: "text-fm-color-system-error-300 fm-typo-en-body-sm-400" }, ht = {
|
|
640
|
-
key: 0,
|
|
641
|
-
class: "max-h-[200px] overflow-y-auto flex flex-col gap-8"
|
|
642
|
-
}, vt = { class: "fm-typo-en-body-lg-600" }, gt = /* @__PURE__ */ ge({
|
|
643
|
-
__name: "TransferTemplateImport",
|
|
644
|
-
setup(e) {
|
|
645
|
-
const t = C(null), i = Qe(), c = he(), a = C(!1), n = C(!1), f = te();
|
|
646
|
-
Ve(async () => {
|
|
647
|
-
n.value = !0;
|
|
648
|
-
try {
|
|
649
|
-
await f.readSuppliers().delayed(1e3);
|
|
650
|
-
} catch {
|
|
651
|
-
c.open({
|
|
652
|
-
title: "Something went wrong.",
|
|
653
|
-
message: "Error at reading suppliers list. Please try again.",
|
|
654
|
-
type: "error"
|
|
655
|
-
});
|
|
656
|
-
} finally {
|
|
657
|
-
n.value = !1;
|
|
658
|
-
}
|
|
659
|
-
});
|
|
660
|
-
const o = C(new Array()), l = C([]), d = C([]), h = ce(
|
|
661
|
-
() => !!o.value.length || l.value.some((b) => b.errors.length) || d.value.some((b) => b.errors.length)
|
|
662
|
-
), y = ce(
|
|
663
|
-
() => !!l.value.length || !!d.value.length
|
|
664
|
-
), { t: m } = ee();
|
|
665
|
-
async function v(b) {
|
|
666
|
-
o.value = [], l.value = [], d.value = [];
|
|
667
|
-
try {
|
|
668
|
-
a.value = !0;
|
|
669
|
-
const [r] = await Promise.all([
|
|
670
|
-
Ue(b),
|
|
671
|
-
// fake buffer
|
|
672
|
-
new Promise((s) => setTimeout(s, 1e3))
|
|
673
|
-
]);
|
|
674
|
-
if (!r.SheetNames.filter(
|
|
675
|
-
(s) => !Object.values(re).map(String).includes(s)
|
|
676
|
-
).find((s) => s)) {
|
|
677
|
-
o.value.push(m("inventory.ingredient.import.fileError.noSheet"));
|
|
678
|
-
return;
|
|
679
|
-
}
|
|
680
|
-
const u = tt(r);
|
|
681
|
-
if (u.invalidExcel) {
|
|
682
|
-
o.value.push(
|
|
683
|
-
u.invalidExcelMessage ?? m("inventory.ingredient.import.fileError.invalidExcel")
|
|
684
|
-
);
|
|
685
|
-
return;
|
|
686
|
-
}
|
|
687
|
-
if (l.value = u.importCreateResult, d.value = u.importUpdateResult, !l.value.length && !d.value.length) {
|
|
688
|
-
o.value.push(m("inventory.ingredient.import.fileError.noData"));
|
|
689
|
-
return;
|
|
690
|
-
}
|
|
691
|
-
i.emitData(u);
|
|
692
|
-
} catch (r) {
|
|
693
|
-
c.open({
|
|
694
|
-
title: m("inventory.ingredient.import.fileError.unableToRead"),
|
|
695
|
-
message: r == null ? void 0 : r.message,
|
|
696
|
-
type: "error"
|
|
697
|
-
}), console.error("Error in reading file", r);
|
|
698
|
-
} finally {
|
|
699
|
-
o.value.length && c.open({
|
|
700
|
-
title: m("inventory.ingredient.import.fileError.invalidExcel"),
|
|
701
|
-
type: "error"
|
|
702
|
-
}), a.value = !1;
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
return je(t, (b) => {
|
|
706
|
-
b && v(b);
|
|
707
|
-
}), (b, r) => {
|
|
708
|
-
const x = M("FmCircularProgress"), _ = M("FmIcon"), u = M("FmButton");
|
|
709
|
-
return T(), w("div", ct, [
|
|
710
|
-
r[2] || (r[2] = $("div", { class: "fm-typo-en-body-md-400" }, "Import transfer templates from excel sheets.", -1)),
|
|
711
|
-
n.value ? (T(), w("div", mt, [
|
|
712
|
-
$("div", null, [
|
|
713
|
-
O(x, {
|
|
714
|
-
size: "md",
|
|
715
|
-
color: "neutral-gray-200"
|
|
716
|
-
})
|
|
717
|
-
]),
|
|
718
|
-
r[1] || (r[1] = $("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "Loading...", -1))
|
|
719
|
-
])) : (T(), w(B, { key: 1 }, [
|
|
720
|
-
O(Pe, {
|
|
721
|
-
class: L({
|
|
722
|
-
"w-full": !0,
|
|
723
|
-
"h-[200px]": !t.value
|
|
724
|
-
}),
|
|
725
|
-
accept: ".xlsx",
|
|
726
|
-
onFileUpload: r[0] || (r[0] = (s) => t.value = s),
|
|
727
|
-
label: E(m)("inventory.ingredient.import.uploadTemplate"),
|
|
728
|
-
"button-label": E(m)("inventory.ingredient.import.selectFile")
|
|
729
|
-
}, ze({ _: 2 }, [
|
|
730
|
-
t.value ? {
|
|
731
|
-
name: "default",
|
|
732
|
-
fn: G(({ openFileDialog: s }) => [
|
|
733
|
-
$("div", ut, [
|
|
734
|
-
$("div", {
|
|
735
|
-
class: L([
|
|
736
|
-
"fm-corner-radius-md p-16 flex items-center gap-16",
|
|
737
|
-
{
|
|
738
|
-
"border border-fm-color-neutral-gray-100": a.value,
|
|
739
|
-
"border border-fm-color-neutral-gray-200": !a.value && !h.value,
|
|
740
|
-
"border border-fm-color-system-error-200": h.value
|
|
741
|
-
}
|
|
742
|
-
])
|
|
743
|
-
}, [
|
|
744
|
-
a.value ? (T(), j(x, {
|
|
745
|
-
key: 0,
|
|
746
|
-
size: "md",
|
|
747
|
-
color: "neutral-gray-200"
|
|
748
|
-
})) : (T(), j(_, {
|
|
749
|
-
key: 1,
|
|
750
|
-
name: h.value ? "error" : "attach_file",
|
|
751
|
-
outline: "",
|
|
752
|
-
color: h.value ? "system-error-300" : void 0
|
|
753
|
-
}, null, 8, ["name", "color"])),
|
|
754
|
-
$("div", {
|
|
755
|
-
class: L([
|
|
756
|
-
"fm-typo-en-body-md-400 flex-1 h-[36px] flex items-center",
|
|
757
|
-
{
|
|
758
|
-
"text-fm-color-typo-disabled": a.value,
|
|
759
|
-
"text-fm-color-typo-primary": !a.value
|
|
760
|
-
}
|
|
761
|
-
])
|
|
762
|
-
}, [
|
|
763
|
-
$("div", dt, I(t.value.name), 1)
|
|
764
|
-
], 2),
|
|
765
|
-
a.value ? Q("", !0) : (T(), w("div", pt, [
|
|
766
|
-
O(u, {
|
|
767
|
-
label: E(m)("inventory.ingredient.import.replaceFile"),
|
|
768
|
-
variant: h.value ? "destructive" : "secondary",
|
|
769
|
-
"prepend-icon": h.value ? void 0 : "autorenew",
|
|
770
|
-
onClick: s
|
|
771
|
-
}, null, 8, ["label", "variant", "prepend-icon", "onClick"])
|
|
772
|
-
]))
|
|
773
|
-
], 2),
|
|
774
|
-
o.value.length ? (T(), w("div", ft, [
|
|
775
|
-
(T(!0), w(B, null, z(o.value, (p, S) => (T(), w("div", {
|
|
776
|
-
key: S,
|
|
777
|
-
class: "flex gap-8 items-center"
|
|
778
|
-
}, [
|
|
779
|
-
O(_, {
|
|
780
|
-
name: "error",
|
|
781
|
-
size: "sm",
|
|
782
|
-
color: "system-error-300"
|
|
783
|
-
}),
|
|
784
|
-
$("div", yt, I(p), 1)
|
|
785
|
-
]))), 128))
|
|
786
|
-
])) : Q("", !0)
|
|
787
|
-
])
|
|
788
|
-
]),
|
|
789
|
-
key: "0"
|
|
790
|
-
} : void 0
|
|
791
|
-
]), 1032, ["class", "label", "button-label"]),
|
|
792
|
-
y.value ? (T(), w("div", ht, [
|
|
793
|
-
$("div", vt, I(E(m)("inventory.ingredient.import.summary")), 1),
|
|
794
|
-
(T(!0), w(B, null, z(l.value, (s, p) => (T(), j(ue, {
|
|
795
|
-
key: p,
|
|
796
|
-
name: s.template.name,
|
|
797
|
-
"transfer-type": typeof s.template.purchaseOrder.supplier.internal == "string" ? E(R).TRANSFER : E(R).PURCHASE,
|
|
798
|
-
locations: s.template.locations,
|
|
799
|
-
items: s.template.purchaseOrder.items,
|
|
800
|
-
errors: s.errors,
|
|
801
|
-
type: "create"
|
|
802
|
-
}, null, 8, ["name", "transfer-type", "locations", "items", "errors"]))), 128)),
|
|
803
|
-
(T(!0), w(B, null, z(d.value, (s) => (T(), j(ue, {
|
|
804
|
-
key: s.template._id,
|
|
805
|
-
name: s.template.name,
|
|
806
|
-
"transfer-type": typeof s.template.purchaseOrder.supplier.internal == "string" ? E(R).TRANSFER : E(R).PURCHASE,
|
|
807
|
-
locations: s.template.locations,
|
|
808
|
-
items: s.template.purchaseOrder.items,
|
|
809
|
-
errors: s.errors,
|
|
810
|
-
type: "update"
|
|
811
|
-
}, null, 8, ["name", "transfer-type", "locations", "items", "errors"]))), 128))
|
|
812
|
-
])) : Q("", !0)
|
|
813
|
-
], 64))
|
|
814
|
-
]);
|
|
815
|
-
};
|
|
816
|
-
}
|
|
817
|
-
});
|
|
818
|
-
function bt(e) {
|
|
819
|
-
var n, f;
|
|
820
|
-
const t = J();
|
|
821
|
-
if (!t.isEnabled) return !0;
|
|
822
|
-
if (!e.internal) {
|
|
823
|
-
const o = t.getNetSuiteVendor(e._id), l = o == null ? void 0 : o.subsidiaryId, d = (n = t.currentVendorSubsidiary(e._id)) == null ? void 0 : n.id;
|
|
824
|
-
return l && l == d;
|
|
825
|
-
}
|
|
826
|
-
const i = t.getNetSuiteLocation(`${e.internal}_${e._id}`), c = t.getLocationSubsidiary(i == null ? void 0 : i.netSuiteId).id, a = (f = t.currentLocationSubsidiary()) == null ? void 0 : f.id;
|
|
827
|
-
return c && c == a;
|
|
828
|
-
}
|
|
829
|
-
const St = ve("transferTemplateActions", () => {
|
|
830
|
-
const e = He(), t = he(), i = K(), c = $e(), a = be(), n = J(), f = Ke(), { t: o } = ee(), l = C({});
|
|
831
|
-
function d() {
|
|
832
|
-
l.value = {
|
|
833
|
-
mode: ae.CREATE,
|
|
834
|
-
show: !0,
|
|
835
|
-
"onUpdate:show"(u) {
|
|
836
|
-
l.value.show = u;
|
|
837
|
-
}
|
|
838
|
-
};
|
|
839
|
-
}
|
|
840
|
-
function h(u) {
|
|
841
|
-
l.value = {
|
|
842
|
-
mode: ae.UPDATE,
|
|
843
|
-
modelValue: u,
|
|
844
|
-
show: !0,
|
|
845
|
-
"onUpdate:show"(s) {
|
|
846
|
-
l.value.show = s;
|
|
847
|
-
}
|
|
848
|
-
};
|
|
849
|
-
}
|
|
850
|
-
function y(u, s, p) {
|
|
851
|
-
e.open({
|
|
852
|
-
title: `Confirm deleting template ${u.name}?`,
|
|
853
|
-
message: "Deleted template can no longer be retrieved",
|
|
854
|
-
primaryActions: {
|
|
855
|
-
text: "Delete",
|
|
856
|
-
variant: ie.Destructive,
|
|
857
|
-
close: !0
|
|
858
|
-
},
|
|
859
|
-
secondaryActions: {
|
|
860
|
-
text: "Cancel",
|
|
861
|
-
variant: ie.Plain,
|
|
862
|
-
close: !0
|
|
863
|
-
}
|
|
864
|
-
}).onPrimary(async () => {
|
|
865
|
-
t.open({
|
|
866
|
-
title: `Deleting ${u.name}`,
|
|
867
|
-
type: "info"
|
|
868
|
-
});
|
|
869
|
-
try {
|
|
870
|
-
s.value = !0;
|
|
871
|
-
const [S] = await Promise.allSettled([
|
|
872
|
-
a.deleteTemplate(u),
|
|
873
|
-
new Promise((k) => setTimeout(k, 1e3))
|
|
874
|
-
]);
|
|
875
|
-
if (S.status === "rejected") throw S.reason;
|
|
876
|
-
t.open({
|
|
877
|
-
title: `Deleted ${u.name}`,
|
|
878
|
-
type: "success"
|
|
879
|
-
});
|
|
880
|
-
} catch (S) {
|
|
881
|
-
t.open({
|
|
882
|
-
title: `Unable to delete ${u.name}`,
|
|
883
|
-
message: `See error from server: ${S}`,
|
|
884
|
-
type: "error"
|
|
885
|
-
}), console.error("error on deleting purchase order template", S);
|
|
886
|
-
} finally {
|
|
887
|
-
s.value = !1, p();
|
|
888
|
-
}
|
|
889
|
-
});
|
|
890
|
-
}
|
|
891
|
-
const m = C({});
|
|
892
|
-
function v(u) {
|
|
893
|
-
m.value = {
|
|
894
|
-
template: u,
|
|
895
|
-
show: !0,
|
|
896
|
-
"onUpdate:show"(s) {
|
|
897
|
-
m.value.show = s;
|
|
898
|
-
},
|
|
899
|
-
"onAction:edit"() {
|
|
900
|
-
m.value.show = !1, h(Z(u));
|
|
901
|
-
}
|
|
902
|
-
};
|
|
903
|
-
}
|
|
904
|
-
function b() {
|
|
905
|
-
const { promise: u, resolve: s } = Promise.withResolvers(), p = (g) => {
|
|
906
|
-
s(g);
|
|
907
|
-
}, S = c.templates.filter((g) => {
|
|
908
|
-
var A, N;
|
|
909
|
-
return ((A = g.purchaseOrder.supplier) == null ? void 0 : A._id) === i.currentLocation.doc._id ? !1 : (N = g.locations) != null && N.length ? g.locations.find((F) => F.doc._id === i.currentLocation.doc._id) : !0;
|
|
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: "Go to templates",
|
|
917
|
-
close: !0
|
|
918
|
-
},
|
|
919
|
-
secondaryActions: {
|
|
920
|
-
text: "Close",
|
|
921
|
-
close: !0
|
|
922
|
-
}
|
|
923
|
-
}).onPrimary(() => {
|
|
924
|
-
f.push({ name: se.TRANSFER_TEMPLATE }), p(void 0);
|
|
925
|
-
}).onSecondary(() => p(void 0)).onClose(() => p(void 0)), u;
|
|
926
|
-
const k = S.map((g) => {
|
|
927
|
-
var ne;
|
|
928
|
-
const A = !g.purchaseOrder.items.length || g.purchaseOrder.items.some(Se), N = !bt(g.purchaseOrder.supplier), F = g.purchaseOrder.supplier.internal ? n.getNetSuiteLocation(
|
|
929
|
-
`${g.purchaseOrder.supplier.internal}_${g.purchaseOrder.supplier._id}`
|
|
930
|
-
) : n.getNetSuiteVendor(g.purchaseOrder.supplier._id), we = N ? `The subsidiary of the request
|
|
931
|
-
location is ${(ne = n.getLocationSubsidiary(F == null ? void 0 : F.netSuiteId)) == null ? void 0 : ne.fullName}.` : void 0, ke = A || N, Ce = A ? "This template is invalid. Update this template." : N ? we : void 0, Re = `${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: Ce ?? Re
|
|
937
|
-
};
|
|
938
|
-
});
|
|
939
|
-
return k.sort((g, A) => +!!g.disabled - +!!A.disabled), e.open({
|
|
940
|
-
title: "Select one template",
|
|
941
|
-
contentComponent: Be,
|
|
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) ? p(g[0]) : null).onSecondary(() => p(void 0)).onTertiary(() => {
|
|
959
|
-
f.push({ name: se.TRANSFER_TEMPLATE }), p(void 0);
|
|
960
|
-
}).onClose(() => p(void 0)), u;
|
|
961
|
-
}
|
|
962
|
-
function r() {
|
|
963
|
-
e.open({
|
|
964
|
-
title: o("inventory.ingredient.import.title"),
|
|
965
|
-
contentComponent: gt,
|
|
966
|
-
overlay: !0,
|
|
967
|
-
closeButton: !0,
|
|
968
|
-
primaryActions: {
|
|
969
|
-
text: o("common.import"),
|
|
970
|
-
close: !1
|
|
971
|
-
},
|
|
972
|
-
secondaryActions: {
|
|
973
|
-
text: o("common.close"),
|
|
974
|
-
close: !0
|
|
975
|
-
},
|
|
976
|
-
tertiaryActions: {
|
|
977
|
-
text: o("inventory.ingredient.import.actions.downloadTemplate"),
|
|
978
|
-
close: !1,
|
|
979
|
-
variant: "plain"
|
|
980
|
-
}
|
|
981
|
-
}).onPrimary((u) => {
|
|
982
|
-
if (!u) {
|
|
983
|
-
t.open({
|
|
984
|
-
title: o("inventory.ingredient.import.error.noData"),
|
|
985
|
-
type: "error"
|
|
986
|
-
});
|
|
987
|
-
return;
|
|
988
|
-
}
|
|
989
|
-
if (!u.importCreateResult.length && !u.importUpdateResult.length) {
|
|
990
|
-
t.open({
|
|
991
|
-
title: o("inventory.ingredient.import.error.invalidContent"),
|
|
992
|
-
message: o("inventory.ingredient.import.error.noImportData"),
|
|
993
|
-
type: "error"
|
|
994
|
-
});
|
|
995
|
-
return;
|
|
996
|
-
}
|
|
997
|
-
if (u.importCreateResult.some((s) => s.errors.length) || u.importUpdateResult.some((s) => s.errors.length)) {
|
|
998
|
-
t.open({
|
|
999
|
-
title: o("inventory.ingredient.import.error.invalidContent"),
|
|
1000
|
-
message: o("inventory.ingredient.import.error.hasErrors"),
|
|
1001
|
-
type: "error"
|
|
1002
|
-
});
|
|
1003
|
-
return;
|
|
1004
|
-
}
|
|
1005
|
-
e.close(), x(u);
|
|
1006
|
-
}).onTertiary(Ye);
|
|
1007
|
-
}
|
|
1008
|
-
async function x(u) {
|
|
1009
|
-
try {
|
|
1010
|
-
const s = [
|
|
1011
|
-
...u.importCreateResult.map(
|
|
1012
|
-
(g) => g.template
|
|
1013
|
-
),
|
|
1014
|
-
...u.importUpdateResult.map(
|
|
1015
|
-
(g) => g.template
|
|
1016
|
-
)
|
|
1017
|
-
], p = 100;
|
|
1018
|
-
let S = 0;
|
|
1019
|
-
const k = () => {
|
|
1020
|
-
S += p, t.open({
|
|
1021
|
-
title: o("inventory.ingredient.import.progress", [
|
|
1022
|
-
Math.min(S, s.length),
|
|
1023
|
-
s.length
|
|
1024
|
-
])
|
|
1025
|
-
});
|
|
1026
|
-
};
|
|
1027
|
-
for (const g of s.chunk(100))
|
|
1028
|
-
k(), await a.importTemplates(g);
|
|
1029
|
-
t.open({
|
|
1030
|
-
title: o("inventory.ingredient.import.success"),
|
|
1031
|
-
type: "success"
|
|
1032
|
-
});
|
|
1033
|
-
} catch (s) {
|
|
1034
|
-
t.open({
|
|
1035
|
-
title: o("inventory.ingredient.import.error.failed"),
|
|
1036
|
-
message: o("inventory.ingredient.import.error.systemMessage", [s == null ? void 0 : s.message]),
|
|
1037
|
-
type: "error"
|
|
1038
|
-
}), console.error("Error in importing skus", u, s);
|
|
1039
|
-
} finally {
|
|
1040
|
-
c.fetchTemplates();
|
|
1041
|
-
}
|
|
1042
|
-
}
|
|
1043
|
-
function _() {
|
|
1044
|
-
const u = We(c.templates);
|
|
1045
|
-
t.open({
|
|
1046
|
-
title: o("inventory.ingredient.export.success"),
|
|
1047
|
-
message: o("inventory.ingredient.export.filename", [u]),
|
|
1048
|
-
type: "success"
|
|
1049
|
-
});
|
|
1050
|
-
}
|
|
1051
|
-
return {
|
|
1052
|
-
createTemplate: d,
|
|
1053
|
-
viewTemplate: v,
|
|
1054
|
-
updateTemplate: h,
|
|
1055
|
-
deleteTemplate: y,
|
|
1056
|
-
getTemplateId: b,
|
|
1057
|
-
importTemplates: r,
|
|
1058
|
-
exportTemplates: _,
|
|
1059
|
-
templateDialogProps: l,
|
|
1060
|
-
templateDetailsProps: m
|
|
1061
|
-
};
|
|
1062
|
-
});
|
|
1063
|
-
function de(e) {
|
|
1064
|
-
const { skuById: t } = H(), i = Z(e);
|
|
1065
|
-
return i.purchaseOrder.items = e.purchaseOrder.items.filter((c) => t[c.sku._id]), i;
|
|
1066
|
-
}
|
|
1067
|
-
const $e = ve(
|
|
1068
|
-
"transferTemplateTable",
|
|
1069
|
-
function() {
|
|
1070
|
-
const { t } = ee(), i = St(), c = C(!1), a = C(new Array()), n = be(), f = H();
|
|
1071
|
-
async function o() {
|
|
1072
|
-
a.value = [], c.value = !0;
|
|
1073
|
-
try {
|
|
1074
|
-
const [y] = await Promise.all([
|
|
1075
|
-
n.readTemplates(),
|
|
1076
|
-
f.readInventory()
|
|
1077
|
-
]).delayed(1e3);
|
|
1078
|
-
a.value = y.map(de);
|
|
1079
|
-
} catch (y) {
|
|
1080
|
-
console.log("Something went wrong when fetching templates:", y);
|
|
1081
|
-
} finally {
|
|
1082
|
-
c.value = !1;
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
|
-
async function l(y) {
|
|
1086
|
-
if (!a.value.find((m) => m._id)) {
|
|
1087
|
-
c.value = !0;
|
|
1088
|
-
try {
|
|
1089
|
-
a.value = [
|
|
1090
|
-
await n.getTemplate(y).then(de).delayed(1e3)
|
|
1091
|
-
];
|
|
1092
|
-
} catch (m) {
|
|
1093
|
-
console.log("Something went wrong when fetching templates:", m);
|
|
1094
|
-
} finally {
|
|
1095
|
-
c.value = !1;
|
|
1096
|
-
}
|
|
1097
|
-
}
|
|
1098
|
-
}
|
|
1099
|
-
function d(y, m) {
|
|
1100
|
-
switch (m = Z(m), y) {
|
|
1101
|
-
case D.Details:
|
|
1102
|
-
return i.viewTemplate(m);
|
|
1103
|
-
case D.Edit:
|
|
1104
|
-
return i.updateTemplate(m);
|
|
1105
|
-
case D.Delete:
|
|
1106
|
-
return i.deleteTemplate(m, c, o);
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1109
|
-
return {
|
|
1110
|
-
columnDefs: [
|
|
1111
|
-
{
|
|
1112
|
-
id: "_id",
|
|
1113
|
-
accessorKey: "_id",
|
|
1114
|
-
header: () => t("inventory.transfer.table.createdAt"),
|
|
1115
|
-
cell(y) {
|
|
1116
|
-
return Me(`${y.getValue()}`);
|
|
1117
|
-
},
|
|
1118
|
-
enableSorting: !0
|
|
1119
|
-
},
|
|
1120
|
-
{
|
|
1121
|
-
id: "name",
|
|
1122
|
-
accessorKey: "name",
|
|
1123
|
-
header: () => t("inventory.transfer.table.name"),
|
|
1124
|
-
enableSorting: !0,
|
|
1125
|
-
size: 200
|
|
1126
|
-
},
|
|
1127
|
-
{
|
|
1128
|
-
id: "noOfItems",
|
|
1129
|
-
accessorKey: "purchaseOrder.items.length",
|
|
1130
|
-
header: () => t("inventory.transfer.table.noOfItems"),
|
|
1131
|
-
enableSorting: !1,
|
|
1132
|
-
meta: {
|
|
1133
|
-
width: "10rem",
|
|
1134
|
-
textAlign: "right"
|
|
1135
|
-
},
|
|
1136
|
-
cell(y) {
|
|
1137
|
-
const m = Number(y.getValue()) || 0, v = y.row.original.purchaseOrder.items.some(Se);
|
|
1138
|
-
return m === 0 || v ? Y("div", { class: "flex justify-end gap-4 items-center" }, [
|
|
1139
|
-
Y(
|
|
1140
|
-
le.FmTooltip,
|
|
1141
|
-
{},
|
|
1142
|
-
{
|
|
1143
|
-
content() {
|
|
1144
|
-
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.";
|
|
1145
|
-
},
|
|
1146
|
-
default() {
|
|
1147
|
-
return Y(le.FmIcon, {
|
|
1148
|
-
name: "error",
|
|
1149
|
-
color: "system-error-300",
|
|
1150
|
-
size: "sm"
|
|
1151
|
-
});
|
|
1152
|
-
}
|
|
1153
|
-
}
|
|
1154
|
-
),
|
|
1155
|
-
m
|
|
1156
|
-
]) : m;
|
|
1157
|
-
}
|
|
1158
|
-
},
|
|
1159
|
-
{
|
|
1160
|
-
id: "enabledLocations",
|
|
1161
|
-
accessorKey: "purchaseOrder.locations.length",
|
|
1162
|
-
header: () => "Enabled outlets",
|
|
1163
|
-
cell(y) {
|
|
1164
|
-
var v;
|
|
1165
|
-
const m = (v = y.row.original.locations) == null ? void 0 : v.length;
|
|
1166
|
-
return m ? `${m}` : "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: () => t("inventory.transfer.table.reference"),
|
|
1178
|
-
enableSorting: !1,
|
|
1179
|
-
size: "auto"
|
|
1180
|
-
},
|
|
1181
|
-
{
|
|
1182
|
-
id: "action",
|
|
1183
|
-
cell(y) {
|
|
1184
|
-
const m = y.row.original, v = [
|
|
1185
|
-
W[D.Details],
|
|
1186
|
-
W[D.Edit],
|
|
1187
|
-
W[D.Delete]
|
|
1188
|
-
];
|
|
1189
|
-
return Le(v, (b) => d(b, m));
|
|
1190
|
-
},
|
|
1191
|
-
enableSorting: !1,
|
|
1192
|
-
size: 40,
|
|
1193
|
-
meta: {
|
|
1194
|
-
cellClass: "",
|
|
1195
|
-
headerClass: ""
|
|
1196
|
-
}
|
|
1197
|
-
}
|
|
1198
|
-
],
|
|
1199
|
-
templates: a,
|
|
1200
|
-
loading: c,
|
|
1201
|
-
fetchTemplates: o,
|
|
1202
|
-
loadTemplate: l
|
|
1203
|
-
};
|
|
1204
|
-
}
|
|
1205
|
-
);
|
|
1206
|
-
function Et(e, t, i) {
|
|
1207
|
-
const c = (i == null ? void 0 : i.abbrev) ?? t.abbrev;
|
|
1208
|
-
return `${U(e, !1)} ${c}`;
|
|
1209
|
-
}
|
|
1210
|
-
export {
|
|
1211
|
-
R as P,
|
|
1212
|
-
be as a,
|
|
1213
|
-
St as b,
|
|
1214
|
-
Et as f,
|
|
1215
|
-
Se as t,
|
|
1216
|
-
$e as u
|
|
1217
|
-
};
|