@feedmepos/mf-inventory-portal 1.5.12 → 1.6.0-dev.1
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-DBEmTaMX.js → App-HlUs-LF4.js} +4 -4
- package/dist/{ApprovalView-BvzIwH1r.js → ApprovalView-qmRODLFE.js} +7 -7
- package/dist/{BindingsDialog-DnqHoU0Y.js → BindingsDialog-DhSose8-.js} +2 -2
- package/dist/{BindingsPicker-Bjpj0zdJ.js → BindingsPicker-JnvHyWiF.js} +2 -2
- package/dist/{BindingsTable-S5Nqq4Qv.js → BindingsTable-B8BSFIJ8.js} +3 -3
- package/dist/ClosingDraftView-XGq-b6Sj.js +4318 -0
- package/dist/{ClosingHistoryView-B2ccrB2K.js → ClosingHistoryView-DAo8MIT2.js} +5 -5
- package/dist/ClosingTemplateView-DSFABll0.js +2221 -0
- package/dist/{DefaultView-DQhLe6LE.js → DefaultView-B-HflwRG.js} +2 -2
- package/dist/{DeliveryOrderPrintPreview-Cup9mzpO.js → DeliveryOrderPrintPreview-Drn8FFa7.js} +2 -2
- package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DuZFuSbw.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CK8RpMEu.js} +2 -2
- package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DoPyc0aE.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-P64wdK5z.js} +2 -2
- package/dist/{FmMultiselectDialog-Cwazmlw3.js → FmMultiselectDialog-CH126sIF.js} +2 -2
- package/dist/{FmMultiselectDialog-DnuUrW7h.js → FmMultiselectDialog-CRG145W_.js} +1 -1
- package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-BMzzUsa4.js → FmUnitInput.vue_vue_type_script_setup_true_lang-Dg0alt69.js} +5 -5
- package/dist/{ImportView-CXtrdABV.js → ImportView-Ca1QPSKV.js} +6 -6
- package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-Cfp95IvX.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-CoFavJB9.js} +1 -1
- package/dist/{IngredientGroupView-Bm-2yK8J.js → IngredientGroupView-BfBtqgnZ.js} +5 -5
- package/dist/{IngredientsView-Bo8w9LSr.js → IngredientsView-WzM4VxgZ.js} +15 -15
- package/dist/{IntegrationExplorerView-DUqQ64CE.js → IntegrationExplorerView-OwTTR-uV.js} +352 -352
- package/dist/{IntegrationView-CtkbKPzC.js → IntegrationView-DYAGDE0m.js} +13 -13
- package/dist/{InventoryBindingForm-DWJRCTf8.js → InventoryBindingForm-Cs-8ACDl.js} +1 -1
- package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-DH-xUQ5m.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-Dm9Nna0r.js} +5 -5
- package/dist/{InventoryBindingSummary-DSwCvTnu.js → InventoryBindingSummary-BbhIvkwv.js} +1 -1
- package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-KDWRZCxm.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-Ci0Wx2Gl.js} +1 -1
- package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-Wuv2teWn.js → PremiumBadge.vue_vue_type_script_setup_true_lang-BLOC3W1b.js} +1 -1
- package/dist/{PublishView-BSahQbqy.js → PublishView-CUNDP20R.js} +3 -3
- package/dist/{PurchaseOrderPrintPreview-C8umjCEU.js → PurchaseOrderPrintPreview-oUPrrGvK.js} +2 -2
- package/dist/{ReceiveRequestView-Bf5dAcun.js → ReceiveRequestView-CxcE8Azw.js} +26 -26
- package/dist/{RecipeView-wU9u23Zp.js → RecipeView-CdN4CJal.js} +1104 -1117
- package/dist/{SettingsView-C5Uc6h0A.js → SettingsView-B5QKC4i7.js} +4 -4
- package/dist/{StockView-QF68mXtU.js → StockView-By0MuX62.js} +19 -19
- package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-Cgw8EDXb.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-C7Elh3p_.js} +1 -1
- package/dist/{SupplierView-xBONJSsg.js → SupplierView-apsm42Mq.js} +12 -12
- package/dist/{SurchargeView-BK8aNKZl.js → SurchargeView-B-G77ghZ.js} +6 -6
- package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-tsuedeNl.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-DlhMQg5r.js} +2 -2
- package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-BXVa7pt5.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-CmYIHCe2.js} +1 -1
- package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-CVRD5iri.js → TransferDetails.vue_vue_type_script_setup_true_lang-24nRAago.js} +20 -20
- package/dist/TransferTemplateView-BBIIu12F.js +2327 -0
- package/dist/{UnitCostHistoryView-BS0nrbkD.js → UnitCostHistoryView-CG-6grmh.js} +4 -4
- package/dist/{UnitDisplayControl.vue_vue_type_script_setup_true_lang-CeD0qWRC.js → UnitDisplayControl.vue_vue_type_script_setup_true_lang-DtmY7fLw.js} +5 -5
- package/dist/{UnitView-DsKX7DM0.js → UnitView-CIrL8HXK.js} +7 -7
- package/dist/{WarehouseView-DRZaGu80.js → WarehouseView-Bvd72APe.js} +5 -5
- package/dist/{WastageTemplateView-CtMSWKFj.js → WastageTemplateView-DHej2xrY.js} +14 -14
- package/dist/api/closing-draft.d.ts +6 -0
- package/dist/{app-DYMYQwvV.js → app-BCF9ZpO-.js} +16381 -14374
- package/dist/app.d.ts +268 -0
- package/dist/app.js +1 -1
- package/dist/{closing-template-Cxsa4j_W.js → closing-template-CIuRAYD3.js} +1 -1
- package/dist/{date2-BdXL0GG5.js → date2-DJVh7XJh.js} +1 -1
- package/dist/{dayjs.min-LoBFKjU2.js → dayjs.min-HcfNNaXG.js} +1 -1
- package/dist/{decimal-BFFta-yv.js → decimal-BZ-WtkK6.js} +2 -2
- package/dist/{defineDeepModel-CCZ3fqXQ.js → defineDeepModel-D06G28ot.js} +1 -1
- package/dist/{duplicate-template-C2Qho2Ig.js → duplicate-template-y-uKyjAx.js} +1 -1
- package/dist/{feature-Dt5ZFkZR.js → feature-DW0OW8Zl.js} +2 -2
- package/dist/{format-time-from-id-LqoWbcB4.js → format-time-from-id-CrGnGtJV.js} +1 -1
- package/dist/format-unit-display-DVEnGOV-.js +1432 -0
- package/dist/{import-export.helper-DogBd6aS.js → import-export.helper-CPoS7Xw2.js} +6 -6
- package/dist/{index-D0xsiYLO.js → index-BAI_qEVG.js} +1 -1
- package/dist/{index-2DNXazDV.js → index-BF_ER6cD.js} +3 -3
- package/dist/{index-IMHyRNdu.js → index-BSLoykmu.js} +1 -1
- package/dist/{inventory-core-dart.default-BkcD7c_a.js → inventory-core-dart.default-B8GRBHwH.js} +1 -1
- package/dist/{lz-string-CgecKowu.js → lz-string-DllDsJgA.js} +1 -1
- package/dist/{netsuite-9qEVrdMv.js → netsuite-BdXvv_AI.js} +2 -2
- package/dist/{number-DSMFbPf0.js → number-fWsZU3Us.js} +3 -3
- package/dist/{predefined-templates-OZoiOUoA.js → predefined-templates-C-9FNSkn.js} +1 -1
- package/dist/{purchase-order-template-CUee1L_x.js → purchase-order-template-DDMRkK1M.js} +1 -1
- package/dist/{recalculationUtils-CPcCUHIm.js → recalculationUtils-17E1-6g0.js} +1 -1
- package/dist/{rules-CMNaUkUU.js → rules-clVHbjpg.js} +2 -2
- package/dist/{stock-BOaUT0Y3.js → stock-ZvR0DmAv.js} +1 -1
- package/dist/{supplier-BAbQZL7x.js → supplier-BnYLExem.js} +2 -2
- package/dist/{surcharge-C5tQ0vs0.js → surcharge-CYjKFXbG.js} +1 -1
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/dist/{uom-rules-CSmRb5Ds.js → uom-rules-C_eQhUkx.js} +1 -1
- package/dist/{use-ingredient-select-dialog-B9XYlxjA.js → use-ingredient-select-dialog-ClGmxwFU.js} +16 -16
- package/dist/{use-inventory-binding-dialog-BzIb4yxm.js → use-inventory-binding-dialog-CpKdIwMo.js} +2 -2
- package/dist/use-template-enabled-locations-deP7LXci.js +132 -0
- package/dist/{use-transfer-locations-Di5ozOgU.js → use-transfer-locations-D3nYdH_3.js} +2 -2
- package/dist/{useHrmPermission-N8GPw9P_.js → useHrmPermission-CMTlJ6AP.js} +1 -1
- package/dist/{useNavigationMenu-BLnGMLsm.js → useNavigationMenu-BxATo1IC.js} +2 -2
- package/dist/{useSseClient-BQtJfryY.js → useSseClient-CGJVJAXa.js} +3 -3
- package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftApprovalDialog.vue.d.ts +800 -0
- package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftDialog.vue.d.ts +40 -0
- package/dist/views/closing-draft/components/closing-draft-groups/ClosingGroupAction.vue.d.ts +21 -0
- package/dist/views/closing-draft/components/closing-draft-groups/ClosingGroupCard.vue.d.ts +20 -0
- package/dist/views/closing-draft/components/closing-draft-groups/ClosingGroupDetailSideSheet.vue.d.ts +823 -0
- package/dist/views/closing-draft/components/closing-draft-groups/ClosingGroupGrid.vue.d.ts +20 -0
- package/dist/views/closing-draft/composables/use-closing-draft-import.d.ts +10 -0
- package/dist/views/closing-draft/composables/use-closing-draft-table.d.ts +1400 -133
- package/dist/views/closing-draft/helpers/closing-draft-summary.helper.d.ts +11 -0
- package/dist/views/closing-draft/helpers/closing-group-detail.helper.d.ts +68 -0
- package/dist/views/closing-draft/helpers/closing-group-status.helper.d.ts +6 -0
- package/dist/views/closing-draft/helpers/closing-groups.helper.d.ts +28 -0
- package/dist/views/closing-draft/helpers/merge-closing-draft-items.helper.d.ts +9 -0
- package/dist/views/closing-template/components/closing-template-form/components/ClosingTemplateGroupsEditor.vue.d.ts +31 -0
- package/dist/views/closing-template/components/closing-template-form/components/ClosingTemplateItem.vue.d.ts +164 -7
- package/dist/views/closing-template/components/closing-template-form/composables/use-closing-template-items.d.ts +24 -88
- package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +108 -0
- package/dist/views/closing-template/composables/use-closing-template-table.d.ts +108 -0
- package/dist/views/ingredients/composables/use-ingredient-select-dialog.d.ts +3 -3
- package/dist/views/recipe/composables/use-recipe-bulk-editor.d.ts +3 -3
- package/dist/views/transfer-template/components/template-item-bulk-editor/TemplateItemBulkEditorDialog.vue.d.ts +2 -0
- package/dist/views/transfer-template/components/template-item-bulk-editor/TemplateItemBulkEditorStep1.vue.d.ts +2 -0
- package/dist/views/transfer-template/components/template-item-bulk-editor/TemplateItemBulkEditorStep2.vue.d.ts +8 -0
- package/dist/views/transfer-template/components/template-item-bulk-editor/TemplateItemBulkEditorStep3.vue.d.ts +2 -0
- package/dist/views/transfer-template/composables/use-template-item-bulk-editor.d.ts +3225 -0
- package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +4 -1
- package/dist/views/transfer-template/helpers/template-item-bulk-editor-export.d.ts +9 -0
- package/dist/{vue-i18n-DR8I1LQH.js → vue-i18n-DCgzd-Rs.js} +498 -498
- package/dist/{xlsx-D5-Cqx-l.js → xlsx-Cy0iFCJQ.js} +398 -398
- package/dist/{xlsx.util-DEdsfN6W.js → xlsx.util-D8wvUM2Y.js} +3 -3
- package/package.json +5 -5
- package/dist/ClosingDraftView-Y074sSoz.js +0 -3343
- package/dist/ClosingTemplateView-BcvKBWVJ.js +0 -2077
- package/dist/TransferTemplateView-Cm4evaK3.js +0 -1564
- package/dist/format-unit-display-CWqmpVa_.js +0 -1268
- package/dist/use-template-enabled-locations-V5iE0ywc.js +0 -146
|
@@ -1,1268 +0,0 @@
|
|
|
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-CUee1L_x.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-DYMYQwvV.js";
|
|
7
|
-
import { useRouter as Be } from "vue-router";
|
|
8
|
-
import { a as Qe } from "./FmMultiselectDialog-Cwazmlw3.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-LqoWbcB4.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-DEdsfN6W.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-DSMFbPf0.js";
|
|
16
|
-
import { f as ze } from "./date2-BdXL0GG5.js";
|
|
17
|
-
import { u as oe } from "./supplier-BAbQZL7x.js";
|
|
18
|
-
import { a as Ye, B as Ke } from "./rules-CMNaUkUU.js";
|
|
19
|
-
import { u as ae } from "./netsuite-9qEVrdMv.js";
|
|
20
|
-
import { u as We } from "./duplicate-template-C2Qho2Ig.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
|
-
};
|