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