@feedmepos/mf-inventory-portal 1.2.51 → 1.2.53-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{App-BJ_vKOR1.js → App-C8X881gs.js} +75 -70
- package/dist/{ApprovalView-B_prTTtl.js → ApprovalView-CnwwVO46.js} +34 -34
- package/dist/{BindingsDialog-BPuKgJIk.js → BindingsDialog-MM6wv-je.js} +2 -2
- package/dist/{BindingsPicker-Dv_cmEil.js → BindingsPicker-C_VV8t8e.js} +2 -2
- package/dist/{BindingsTable-BNSfYRfq.js → BindingsTable-CabKT98b.js} +4 -4
- package/dist/{ClosingDraftView-C78tcaJ3.js → ClosingDraftView-D3dwGHdG.js} +19 -18
- package/dist/{ClosingHistoryView-DY8liEk3.js → ClosingHistoryView-CBMIWL-O.js} +27 -27
- package/dist/{ClosingTemplateView-pJXEcrjO.js → ClosingTemplateView-FHCJY1Y1.js} +525 -511
- package/dist/{DeliveryOrderPrintPreview-Bu_l-kxu.js → DeliveryOrderPrintPreview-BB4HVWaM.js} +1 -1
- package/dist/FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-Dq2vcIMB.js +188 -0
- package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DHe5G3kX.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BSrjl8Vc.js} +12 -12
- package/dist/FmMultiselectDialog-D8E2bGwL.js +618 -0
- package/dist/{FmMultiselectDialog-C3iCMK5I.js → FmMultiselectDialog-HP5xQpLC.js} +1 -1
- package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-CefvebOx.js → FmUnitInput.vue_vue_type_script_setup_true_lang--yzPFTUH.js} +3 -3
- package/dist/{ImportView-JrenRgiI.js → ImportView-DQPKyc1T.js} +7 -7
- package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-CSdxodp6.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-DZAOa26T.js} +1 -1
- package/dist/{IngredientGroupView-aDFq_ZDh.js → IngredientGroupView-CiR31jQz.js} +108 -107
- package/dist/{IngredientsView-DSh3UqDg.js → IngredientsView-Csa1Lifk.js} +126 -125
- package/dist/{IntegrationView-KhZ78uxM.js → IntegrationView-DqGXjNPx.js} +80 -80
- package/dist/{InventoryBindingForm-DZu0CZYh.js → InventoryBindingForm-kZ6JIgK4.js} +1 -1
- package/dist/InventoryBindingForm.vue_vue_type_script_setup_true_lang-D-qjPLHS.js +403 -0
- package/dist/{InventoryBindingSummary-DZxLhZ_-.js → InventoryBindingSummary-Cn3y7cXX.js} +1 -1
- package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DAwpZY3n.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-5cpvf_ze.js} +1 -1
- package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-CPDxwz-V.js → PremiumBadge.vue_vue_type_script_setup_true_lang-DW_3XEAx.js} +2 -2
- package/dist/{PublishView-CLnQ7NBN.js → PublishView-tvxBQLp2.js} +3 -3
- package/dist/{PurchaseOrderPrintPreview-DiBztBma.js → PurchaseOrderPrintPreview-CqSijErx.js} +1 -1
- package/dist/ReceiveRequestView-Oq87gJ1d.js +2913 -0
- package/dist/{RecipeView-BPIMvoTw.js → RecipeView-c7SNUwhq.js} +83 -82
- package/dist/{StockView-CI8MUJay.js → StockView-B3ocNf5D.js} +113 -112
- package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-DEBHEMkh.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-Br3p4H5X.js} +1 -1
- package/dist/{SupplierView-COihDMNY.js → SupplierView-7UHgW64q.js} +28 -27
- package/dist/SurchargeView-CkBBz_W1.js +460 -0
- package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-D-c0Ayis.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-BxqwBD1A.js} +2 -2
- package/dist/TableActionableRow.vue_vue_type_script_setup_true_lang-Ca_eYa8-.js +84 -0
- package/dist/TemplatePublishDialog.vue_vue_type_script_setup_true_lang-DZxJDrcN.js +201 -0
- package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-BVuuw11z.js → TransferDetails.vue_vue_type_script_setup_true_lang-BP7PC5FE.js} +15 -15
- package/dist/{TransferTemplateView-B2NNfrEq.js → TransferTemplateView-gnib1NSD.js} +82 -81
- package/dist/{UnitView-ZsbM07hw.js → UnitView-gccTcBDm.js} +20 -19
- package/dist/{WarehouseView-Cd5RFu5v.js → WarehouseView-9Tzk2HFV.js} +21 -20
- package/dist/WastageTemplateView-bxDDb0it.js +2383 -0
- package/dist/api/adjustment-template.d.ts +1 -0
- package/dist/api/closing-template.d.ts +1 -0
- package/dist/api/netsuite.d.ts +8 -0
- package/dist/api/surcharge.d.ts +31 -0
- package/dist/app-DiX-EfV6.js +8167 -0
- package/dist/{app-CySQTQxj.js → app-S9HQBEDL.js} +4514 -4410
- package/dist/app.d.ts +53 -0
- package/dist/app.js +1 -1
- package/dist/closing-template-DSppbNBU.js +125 -0
- package/dist/component-DpCUABT3.js +82 -0
- package/dist/components/FmInventoryTableToolbar.vue.d.ts +8 -0
- package/dist/components/FmMultiselectDialogProps.d.ts +5 -0
- package/dist/components/TemplatePublishDialog.d.ts +2 -0
- package/dist/{date2-BWoUn1K_.js → date2-a0EDY-8z.js} +1 -1
- package/dist/{dayjs.min-cMW8olEu.js → dayjs.min-D3uqC-FM.js} +26 -26
- package/dist/{decimal-8BRzZQU6.js → decimal-iC0dKSbY.js} +2 -2
- package/dist/{defineDeepModel-AsUZ-DyW.js → defineDeepModel-sBbNFqqR.js} +1 -1
- package/dist/{duplicate-template-CyHfZR3S.js → duplicate-template-Dwe_h80w.js} +1 -1
- package/dist/{feature-Dm0FnWf9.js → feature-12j10xt_.js} +8956 -6221
- package/dist/{format-time-from-id-C9lmv5BP.js → format-time-from-id-Dyyvx-ha.js} +1 -1
- package/dist/{format-unit-display-BV8pJisO.js → format-unit-display-DstE3kKS.js} +11 -11
- package/dist/{import-export.helper-Djxw_H5S.js → import-export.helper-CR8rEBJV.js} +5 -5
- package/dist/{index-D6u3kywf.js → index-BbpxRM23.js} +1 -1
- package/dist/{index-8hCa5_Gb.js → index-Ca8nKTEy.js} +1 -1
- package/dist/{index-DidYtgNc.js → index-CvRrsISb.js} +3 -3
- package/dist/{lodash-CW_Ea6mA.js → lodash-BiCqhRt2.js} +1 -1
- package/dist/netsuite-B84CfGmT.js +5454 -0
- package/dist/{purchase-order-template-BTzjcgrO.js → purchase-order-template-ogVLqXnM.js} +1 -1
- package/dist/router/name.d.ts +1 -0
- package/dist/{rules-DkVWS5mF.js → rules-C0W8tBAK.js} +9 -9
- package/dist/{stock-CHw8pI8V.js → stock-BfY956rP.js} +3 -3
- package/dist/{stock-D8hLHgeN.js → stock-Dy08ISna.js} +1 -1
- package/dist/stores/feature.d.ts +4 -0
- package/dist/stores/integration/netsuite.d.ts +5 -0
- package/dist/stores/surcharge.d.ts +18 -0
- package/dist/style.css +1 -1
- package/dist/{supplier-Dv83IfQr.js → supplier-BGfg_Uzv.js} +2 -2
- package/dist/surcharge-DZkc9Zxa.js +71 -0
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/dist/{use-ingredient-select-dialog-CJjd4g-6.js → use-ingredient-select-dialog-fOf-xHgn.js} +2 -2
- package/dist/{use-inventory-binding-dialog-D4g79p5S.js → use-inventory-binding-dialog-CF6dmCop.js} +2 -2
- package/dist/{use-template-enabled-locations-2-Cg2iqQdq.js → use-template-enabled-locations-2-C9YTP8tP.js} +2 -2
- package/dist/views/adjustment-template/wastage-template/actions.d.ts +4 -1
- package/dist/views/receive-request/components/transfer-form/TransferFormWithController.vue.d.ts +714 -0
- package/dist/views/receive-request/components/transfer-form/composables/use-transfer-items.d.ts +8 -1
- package/dist/views/stock/components/StockRecordCard.vue.d.ts +1 -1
- package/dist/views/surcharge/SurchargeView.vue.d.ts +2 -0
- package/dist/{vue-i18n-kUcLfpvT.js → vue-i18n-CVvQI1xZ.js} +571 -571
- package/dist/{xlsx-BjeMbhDF.js → xlsx-C46Afq2T.js} +1 -1
- package/dist/{xlsx.util-9eMlJfd9.js → xlsx.util-iJmlHY2V.js} +1 -1
- package/package.json +2 -2
- package/dist/FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-Dgibb-Fh.js +0 -231
- package/dist/FmMultiselectDialog-CDONDKxE.js +0 -598
- package/dist/InventoryBindingForm.vue_vue_type_script_setup_true_lang-YuCn0irA.js +0 -375
- package/dist/ReceiveRequestView-_TOSnDGJ.js +0 -2913
- package/dist/TableActionableRow.vue_vue_type_script_setup_true_lang-cfFHDIwQ.js +0 -162
- package/dist/TemplatePublishDialog.vue_vue_type_script_setup_true_lang-D8vbPlie.js +0 -155
- package/dist/WastageTemplateView-DpikyyZW.js +0 -2327
- package/dist/app-uBuHtW8m.js +0 -8127
- package/dist/closing-template-DXGjC5AG.js +0 -117
- package/dist/cypress/component/receive-request/KDI-15-total-price-currency.cy.d.ts +0 -2
- package/dist/netsuite-BEto-z0v.js +0 -5131
- package/dist/views/ingredients/helper/calculate-default-cost.d.ts +0 -9
- package/dist/views/receive-request/components/transfer-form/TransferForm2.vue.d.ts +0 -22
|
@@ -0,0 +1,2383 @@
|
|
|
1
|
+
import { ref as M, h as P, defineComponent as G, resolveComponent as E, openBlock as I, createElementBlock as A, createElementVNode as y, normalizeClass as Y, createTextVNode as Z, toDisplayString as F, unref as x, createCommentVNode as z, createVNode as C, createBlock as O, Fragment as K, renderList as X, computed as U, watch as pe, createSlots as Ue, withCtx as j, isRef as Le, normalizeStyle as Qe, Teleport as Xe, normalizeProps as Ze, guardReactiveProps as et, mergeProps as je } from "vue";
|
|
2
|
+
import { u as tt, _ as nt } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-CWZkVCAj.js";
|
|
3
|
+
import { useI18n as J, useCoreStore as Ne } from "@feedmepos/mf-common";
|
|
4
|
+
import { D as ce, R as B } from "./row-action.enum-BcW_L_nE.js";
|
|
5
|
+
import { _ as st } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BSrjl8Vc.js";
|
|
6
|
+
import { useDialog as ee, useDialogChild as ot, useSnackbar as te, FmButtonVariant as Q, components as H, useProxiedModel as Be, useBreakpoints as at } from "@feedmepos/ui-library";
|
|
7
|
+
import { defineStore as ze, storeToRefs as Oe } from "pinia";
|
|
8
|
+
import { _ as lt, F as me } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-Ca_eYa8-.js";
|
|
9
|
+
import { u as he, c as We, a as ne, G as N, n as rt, D as fe } from "./app-S9HQBEDL.js";
|
|
10
|
+
import { F as q } from "./form-mode.enum-BKiNVH6A.js";
|
|
11
|
+
import { c as it } from "./component-DpCUABT3.js";
|
|
12
|
+
import { f as ut } from "./format-time-from-id-Dyyvx-ha.js";
|
|
13
|
+
import { u as se } from "./closing-template-DSppbNBU.js";
|
|
14
|
+
import { _ as ct } from "./TemplatePublishDialog.vue_vue_type_script_setup_true_lang-DZxJDrcN.js";
|
|
15
|
+
import { t as ve, a as He, d as Ke, s as Ye, r as mt } from "./xlsx.util-iJmlHY2V.js";
|
|
16
|
+
import { f as dt, a as de } from "./date2-a0EDY-8z.js";
|
|
17
|
+
import { u as pt } from "./netsuite-B84CfGmT.js";
|
|
18
|
+
import { F as ft } from "./FmDroppableField-J0xUsOTV.js";
|
|
19
|
+
import { u as vt } from "./duplicate-template-Dwe_h80w.js";
|
|
20
|
+
import { A as yt, R as Ge } from "./rules-C0W8tBAK.js";
|
|
21
|
+
import { d as ht } from "./defineDeepModel-sBbNFqqR.js";
|
|
22
|
+
import { u as gt } from "./use-template-enabled-locations-2-C9YTP8tP.js";
|
|
23
|
+
import { a as bt } from "./FmMultiselectDialog-D8E2bGwL.js";
|
|
24
|
+
import { _ as _t } from "./SystemTrailDialog.vue_vue_type_script_setup_true_lang-BxqwBD1A.js";
|
|
25
|
+
import { _ as xt } from "./_plugin-vue_export-helper-CHgC5LLL.js";
|
|
26
|
+
const oe = ze(
|
|
27
|
+
"wastageTable",
|
|
28
|
+
function() {
|
|
29
|
+
const { t: l } = J(), i = ee(), v = ye(), p = M({}), r = M(new Array()), m = M(!1), o = he(), t = se(), s = M({}), u = M();
|
|
30
|
+
async function b() {
|
|
31
|
+
if (o._currentLocation)
|
|
32
|
+
try {
|
|
33
|
+
u.value = await t.getReasons();
|
|
34
|
+
} catch (a) {
|
|
35
|
+
console.log("Something went wrong when fetching reasons:", a);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function g() {
|
|
39
|
+
var d;
|
|
40
|
+
if (!u.value) return !1;
|
|
41
|
+
const a = (d = p.value.publishedRevs) == null ? void 0 : d[u.value._id];
|
|
42
|
+
return u.value._rev === a;
|
|
43
|
+
}
|
|
44
|
+
function T(a) {
|
|
45
|
+
const d = {
|
|
46
|
+
title: a.name,
|
|
47
|
+
doc: a,
|
|
48
|
+
controller: {
|
|
49
|
+
publishAll: async (e) => {
|
|
50
|
+
const c = e || a.locations, R = await t.publishSingleDoc(
|
|
51
|
+
a._id,
|
|
52
|
+
c == null ? void 0 : c.map(($) => $.dbName)
|
|
53
|
+
);
|
|
54
|
+
return s.value = R.publishedRevByLocation || {}, s.value;
|
|
55
|
+
},
|
|
56
|
+
publishAtLocation: async (e) => {
|
|
57
|
+
const c = await t.publishSingleDoc(a._id, [
|
|
58
|
+
e.dbName
|
|
59
|
+
]);
|
|
60
|
+
return s.value = c.publishedRevByLocation || {}, s.value;
|
|
61
|
+
},
|
|
62
|
+
unpublishAll: async (e) => {
|
|
63
|
+
const c = e || a.locations, R = await t.unpublishSingleDoc(
|
|
64
|
+
a._id,
|
|
65
|
+
c == null ? void 0 : c.map(($) => $.dbName)
|
|
66
|
+
);
|
|
67
|
+
return s.value = R.publishedRevByLocation || {}, s.value;
|
|
68
|
+
},
|
|
69
|
+
unpublishAtLocation: async (e) => {
|
|
70
|
+
const c = await t.unpublishSingleDoc(a._id, [
|
|
71
|
+
e.dbName
|
|
72
|
+
]);
|
|
73
|
+
return s.value = c.publishedRevByLocation || {}, s.value;
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
initialPublishedRev: s.value,
|
|
77
|
+
locations: o.locations,
|
|
78
|
+
enabledLocations: a.locations
|
|
79
|
+
};
|
|
80
|
+
i.open({
|
|
81
|
+
title: "Publish template",
|
|
82
|
+
contentComponent: ct,
|
|
83
|
+
contentComponentProps: d,
|
|
84
|
+
closeButton: !0,
|
|
85
|
+
primaryActions: {
|
|
86
|
+
text: l("common.close"),
|
|
87
|
+
close: !0,
|
|
88
|
+
variant: "tertiary"
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
async function w() {
|
|
93
|
+
if (r.value = [], !!o._currentLocation) {
|
|
94
|
+
m.value = !0;
|
|
95
|
+
try {
|
|
96
|
+
const [a, d, e] = await Promise.all([
|
|
97
|
+
t.readTemplates(),
|
|
98
|
+
t.getRecentPublishingJob(),
|
|
99
|
+
t.getRecentPublishInfo()
|
|
100
|
+
]).delayed(1e3);
|
|
101
|
+
r.value = a, p.value = d, s.value = (e == null ? void 0 : e.publishedRevByLocation) || {}, await b();
|
|
102
|
+
} catch (a) {
|
|
103
|
+
console.log("Something went wrong when fetching templates:", a);
|
|
104
|
+
} finally {
|
|
105
|
+
m.value = !1;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
async function k(a) {
|
|
110
|
+
if (!r.value.find((d) => d._id) && o._currentLocation) {
|
|
111
|
+
m.value = !0;
|
|
112
|
+
try {
|
|
113
|
+
const [d] = await Promise.all([
|
|
114
|
+
t.getTemplate(a),
|
|
115
|
+
new Promise((e) => setTimeout(e, 1e3))
|
|
116
|
+
]);
|
|
117
|
+
r.value = [d];
|
|
118
|
+
} catch (d) {
|
|
119
|
+
console.log("Something went wrong when fetching templates:", d);
|
|
120
|
+
} finally {
|
|
121
|
+
m.value = !1;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function _(a, d) {
|
|
126
|
+
switch (d = We(d), a) {
|
|
127
|
+
case B.Details:
|
|
128
|
+
return v.viewTemplate(d);
|
|
129
|
+
case B.Edit:
|
|
130
|
+
return v.updateTemplate(d);
|
|
131
|
+
case B.Delete:
|
|
132
|
+
return v.deleteTemplate(d, m, w);
|
|
133
|
+
case B.Publish:
|
|
134
|
+
return T(d);
|
|
135
|
+
case B.Duplicate:
|
|
136
|
+
return v.duplicateTemplate(d, m, w);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
columnDefs: [
|
|
141
|
+
{
|
|
142
|
+
id: "_id",
|
|
143
|
+
accessorKey: "_id",
|
|
144
|
+
header: () => l("inventory.adjustment.template.table.createdAt"),
|
|
145
|
+
cell(a) {
|
|
146
|
+
return ut(`${a.getValue()}`);
|
|
147
|
+
},
|
|
148
|
+
enableSorting: !0
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
id: "name",
|
|
152
|
+
accessorKey: "name",
|
|
153
|
+
header: () => l("inventory.adjustment.template.table.name"),
|
|
154
|
+
enableSorting: !0,
|
|
155
|
+
size: 200
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
id: "noOfItems",
|
|
159
|
+
accessorKey: "items.length",
|
|
160
|
+
header: () => l("inventory.adjustment.template.table.noOfItems"),
|
|
161
|
+
enableSorting: !1,
|
|
162
|
+
meta: {
|
|
163
|
+
width: "10rem",
|
|
164
|
+
textAlign: "right"
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
id: "enabledLocations",
|
|
169
|
+
accessorKey: "locations.length",
|
|
170
|
+
header: () => l("inventory.adjustment.template.table.enabledOutlets"),
|
|
171
|
+
cell(a) {
|
|
172
|
+
var e;
|
|
173
|
+
const d = (e = a.row.original.locations) == null ? void 0 : e.length;
|
|
174
|
+
return d ? `${d}` : "All";
|
|
175
|
+
},
|
|
176
|
+
enableSorting: !1,
|
|
177
|
+
meta: {
|
|
178
|
+
width: "10rem",
|
|
179
|
+
textAlign: "right"
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
id: "status",
|
|
184
|
+
header: () => l("inventory.adjustment.template.table.status"),
|
|
185
|
+
enableSorting: !1,
|
|
186
|
+
cell(a) {
|
|
187
|
+
const d = a.row.original, e = d._rev, c = a.row.original.locations || o.locations, $ = c.filter((h) => !!(s.value[h.dbName] || []).find((D) => D._id === d._id && D._rev === e)).length === c.length;
|
|
188
|
+
return P(
|
|
189
|
+
"div",
|
|
190
|
+
{
|
|
191
|
+
class: "flex items-center gap-8"
|
|
192
|
+
},
|
|
193
|
+
P(
|
|
194
|
+
"div",
|
|
195
|
+
{
|
|
196
|
+
class: [
|
|
197
|
+
"fm-status-badge",
|
|
198
|
+
$ ? "fm-status-badge-success-secondary" : "fm-status-badge-info-secondary"
|
|
199
|
+
]
|
|
200
|
+
},
|
|
201
|
+
$ ? "Published" : "Unpublished"
|
|
202
|
+
)
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
id: "action",
|
|
208
|
+
cell(a) {
|
|
209
|
+
const d = a.row.original, e = [
|
|
210
|
+
ce[B.Edit],
|
|
211
|
+
ce[B.Duplicate],
|
|
212
|
+
ce[B.Delete],
|
|
213
|
+
ce[B.Publish]
|
|
214
|
+
];
|
|
215
|
+
return it(e, (c) => _(c, d));
|
|
216
|
+
},
|
|
217
|
+
enableSorting: !1,
|
|
218
|
+
size: 40,
|
|
219
|
+
meta: {
|
|
220
|
+
cellClass: "",
|
|
221
|
+
headerClass: ""
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
],
|
|
225
|
+
recentPublish: p,
|
|
226
|
+
templates: r,
|
|
227
|
+
reasons: u,
|
|
228
|
+
isReasonPublished: g,
|
|
229
|
+
loading: m,
|
|
230
|
+
fetchTemplates: w,
|
|
231
|
+
loadTemplate: k
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
);
|
|
235
|
+
var ge = /* @__PURE__ */ ((f) => (f.Ingredients = "Ingredients", f))(ge || {});
|
|
236
|
+
function Je(f, l, i) {
|
|
237
|
+
var p, r, m;
|
|
238
|
+
const v = [];
|
|
239
|
+
if (f.type == N.Enum.sku) {
|
|
240
|
+
const o = new Set(f.disabledMeasurements), t = (p = l.sku) == null ? void 0 : p.find((s) => s._id === f.id);
|
|
241
|
+
if (t) {
|
|
242
|
+
const s = {
|
|
243
|
+
type: f.type,
|
|
244
|
+
code: f.code,
|
|
245
|
+
name: f.name,
|
|
246
|
+
unit: t.unit.abbrev,
|
|
247
|
+
enabled: !o.has(t.unit._id)
|
|
248
|
+
};
|
|
249
|
+
v.push(
|
|
250
|
+
s,
|
|
251
|
+
...t.unit.measurements.map((u) => ({
|
|
252
|
+
unit: u.abbrev,
|
|
253
|
+
enabled: !o.has(u.id)
|
|
254
|
+
}))
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return f.type == N.Enum.recipe && ((r = l.recipe) != null && r.find((t) => t._id === f.id)) && v.push(f), f.type == N.Enum.menu && ((m = i == null ? void 0 : i.modules.item) != null && m.find((t) => t._id === f.id)) && v.push(f), v;
|
|
259
|
+
}
|
|
260
|
+
function qe() {
|
|
261
|
+
return [
|
|
262
|
+
{
|
|
263
|
+
id: "code",
|
|
264
|
+
name: "Code"
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
id: "type",
|
|
268
|
+
name: "Type"
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
id: "name",
|
|
272
|
+
name: "Name"
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
id: "unit",
|
|
276
|
+
name: "Unit"
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
id: "enabled",
|
|
280
|
+
name: "Enabled (Unit)"
|
|
281
|
+
}
|
|
282
|
+
];
|
|
283
|
+
}
|
|
284
|
+
function wt(f) {
|
|
285
|
+
var s;
|
|
286
|
+
const l = Ne(), i = ne(), v = i.menu.cache, p = l.currentBusiness.value, m = (s = f.map((u) => {
|
|
287
|
+
var _;
|
|
288
|
+
const b = u.items.flatMap(
|
|
289
|
+
(n) => Je(n, i.state.inventory, v)
|
|
290
|
+
), g = qe(), T = [
|
|
291
|
+
["Template ID", u._id],
|
|
292
|
+
["Template name", u.name],
|
|
293
|
+
["Business name", p == null ? void 0 : p.name],
|
|
294
|
+
["Business ID", p == null ? void 0 : p._id],
|
|
295
|
+
["Menu version", p == null ? void 0 : p.menuVersion],
|
|
296
|
+
[
|
|
297
|
+
"Locations",
|
|
298
|
+
...(_ = u.locations) != null && _.length ? u.locations.map((n) => `${n.name} (${n.dbName})`) : ["All"]
|
|
299
|
+
],
|
|
300
|
+
// ['Reference', template.ref ?? ''],
|
|
301
|
+
[],
|
|
302
|
+
g.map((n) => n.name),
|
|
303
|
+
...b.map((n) => g.map((a) => n[a.id]))
|
|
304
|
+
], w = g.map((n) => `system:${n.id}`), k = ve(T, w);
|
|
305
|
+
return { name: u.name, sheet: k };
|
|
306
|
+
}).reduce(
|
|
307
|
+
(u, b) => {
|
|
308
|
+
var T;
|
|
309
|
+
const g = b.name.slice(0, 12);
|
|
310
|
+
return (T = u.sheetOccurence)[g] ?? (T[g] = 0), u.sheetOccurence[g] += 1, u.sheets[`${g} (${u.sheetOccurence[g]})`] = b.sheet, u;
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
sheets: {},
|
|
314
|
+
sheetOccurence: {}
|
|
315
|
+
}
|
|
316
|
+
)) == null ? void 0 : s.sheets, o = `${p == null ? void 0 : p.name} adjustment templates (${dt(/* @__PURE__ */ new Date())}).xlsx`, t = He(m);
|
|
317
|
+
return Ke(t, o), o;
|
|
318
|
+
}
|
|
319
|
+
function Tt() {
|
|
320
|
+
var _;
|
|
321
|
+
const f = Ne(), l = ne(), i = pt(), v = (_ = l.state.inventory.sku) == null ? void 0 : _[0];
|
|
322
|
+
if (!v)
|
|
323
|
+
throw new Error("No inventory items");
|
|
324
|
+
const r = Je(
|
|
325
|
+
{
|
|
326
|
+
type: N.Enum.sku,
|
|
327
|
+
code: v.code,
|
|
328
|
+
id: v._id,
|
|
329
|
+
name: v.name
|
|
330
|
+
},
|
|
331
|
+
l.state.inventory,
|
|
332
|
+
l.menu.cache
|
|
333
|
+
)[0], m = f.currentBusiness.value, o = qe(), t = [
|
|
334
|
+
["Template ID (leave empty to create new)", ""],
|
|
335
|
+
["Template Name", "New template"],
|
|
336
|
+
["Business name", m == null ? void 0 : m.name],
|
|
337
|
+
["Business ID", m == null ? void 0 : m._id],
|
|
338
|
+
["Menu version", m == null ? void 0 : m.menuVersion],
|
|
339
|
+
[
|
|
340
|
+
"Location codes (leave empty to enable all)",
|
|
341
|
+
"Example outlet (restaurant_xxx)",
|
|
342
|
+
"Example outlet 2 (restaurant_xxx)"
|
|
343
|
+
],
|
|
344
|
+
// ['Reference:'],
|
|
345
|
+
[],
|
|
346
|
+
o.map((n) => n.name),
|
|
347
|
+
o.map((n) => r[n.id])
|
|
348
|
+
], s = o.map((n) => `system:${n.id}`), u = ve(t, s), b = i.isEnabled ? i.state.setting.childItems ?? [] : [], g = b.reduce(
|
|
349
|
+
(n, a) => {
|
|
350
|
+
var $, h;
|
|
351
|
+
const d = ($ = i.netSuiteItemIdToSkuId.get(a.parentNetSuiteId)) == null ? void 0 : $[0], e = (h = i.netSuiteMeasurementIdToMeasurementId.get(
|
|
352
|
+
a.unitOfMeasureId
|
|
353
|
+
)) == null ? void 0 : h[0];
|
|
354
|
+
if (!a.externalId)
|
|
355
|
+
return n;
|
|
356
|
+
if (!d)
|
|
357
|
+
return console.error(`Item ${a.externalId} cannot be mapped to parent FdoInventorySku.`, a), n;
|
|
358
|
+
const c = l.skuById[d], R = c.unit.measurements.find((S) => S.id === e);
|
|
359
|
+
return R ? (n[a.externalId] = {
|
|
360
|
+
sku: c,
|
|
361
|
+
measurement: R
|
|
362
|
+
}, n) : (console.error(
|
|
363
|
+
`Item ${a.externalId} found parent FdoInventorySku of ${c.code} ${c.name} but the measurement of netsuite id ${a.unitOfMeasureId} cannot be found.`,
|
|
364
|
+
a
|
|
365
|
+
), n);
|
|
366
|
+
},
|
|
367
|
+
{}
|
|
368
|
+
), T = ve(
|
|
369
|
+
[
|
|
370
|
+
...l.skus.flatMap((n) => [
|
|
371
|
+
[n.code, n.name, n.unit.abbrev, !0],
|
|
372
|
+
...n.unit.measurements.map((d) => [
|
|
373
|
+
"",
|
|
374
|
+
"",
|
|
375
|
+
d.abbrev,
|
|
376
|
+
!d.abbrev.toLocaleLowerCase("en-us").includes("inactive")
|
|
377
|
+
])
|
|
378
|
+
]),
|
|
379
|
+
...Object.entries(g).map(([n, { sku: a, measurement: d }]) => [
|
|
380
|
+
a.code,
|
|
381
|
+
a.name,
|
|
382
|
+
d.abbrev,
|
|
383
|
+
!d.abbrev.toLocaleLowerCase("en-us").includes("inactive"),
|
|
384
|
+
n
|
|
385
|
+
])
|
|
386
|
+
],
|
|
387
|
+
[
|
|
388
|
+
"Code",
|
|
389
|
+
"Type",
|
|
390
|
+
"Name",
|
|
391
|
+
"Units",
|
|
392
|
+
"Enabled (true/false)",
|
|
393
|
+
...b.length ? ["Netsuite Parent"] : []
|
|
394
|
+
]
|
|
395
|
+
), w = He({
|
|
396
|
+
Template: u,
|
|
397
|
+
Ingredients: T
|
|
398
|
+
}), k = `${m == null ? void 0 : m.name} transfer templates import.xlsx`;
|
|
399
|
+
return Ke(w, k), k;
|
|
400
|
+
}
|
|
401
|
+
function kt(f) {
|
|
402
|
+
if (!f.length || `${f[0]}`.toLocaleLowerCase() === "all")
|
|
403
|
+
return [];
|
|
404
|
+
const l = /(.*) \(((warehouse_|restaurant_).{24,})\)/, v = he().locationByDbName;
|
|
405
|
+
return f.map((p) => {
|
|
406
|
+
const r = new Array(), m = p.trim(), o = l.exec(m);
|
|
407
|
+
if (!o)
|
|
408
|
+
return r.push(`Enabled location value of ${m} cannot be read.`), {
|
|
409
|
+
errors: r
|
|
410
|
+
};
|
|
411
|
+
const t = o[1], s = o[2], u = v[s];
|
|
412
|
+
return u ? (t !== u.name && r.push(
|
|
413
|
+
`Location id ${s} has non-matching name. Found ${t} but expected ${u.name}`
|
|
414
|
+
), {
|
|
415
|
+
errors: r,
|
|
416
|
+
location: u
|
|
417
|
+
}) : (r.push(`Location (${t}) of id ${s} is not found.`), {
|
|
418
|
+
errors: r
|
|
419
|
+
});
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
function $t(f) {
|
|
423
|
+
const [
|
|
424
|
+
l,
|
|
425
|
+
i,
|
|
426
|
+
v,
|
|
427
|
+
p,
|
|
428
|
+
r,
|
|
429
|
+
m,
|
|
430
|
+
o,
|
|
431
|
+
t
|
|
432
|
+
] = Ye(f);
|
|
433
|
+
return {
|
|
434
|
+
id: `${i[1] ?? ""}`.trim(),
|
|
435
|
+
name: `${v[1] ?? ""}`.trim(),
|
|
436
|
+
locations: o.slice(1).map((s) => `${s}`.trim()).filter((s) => s),
|
|
437
|
+
reference: `${t[1] ?? ""}`.trim()
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
function St(f) {
|
|
441
|
+
const [
|
|
442
|
+
l,
|
|
443
|
+
i,
|
|
444
|
+
v,
|
|
445
|
+
p,
|
|
446
|
+
r,
|
|
447
|
+
m,
|
|
448
|
+
o,
|
|
449
|
+
t,
|
|
450
|
+
s,
|
|
451
|
+
...u
|
|
452
|
+
] = Ye(f);
|
|
453
|
+
if (!l || !l.length || l.some((k) => k.length && !k.startsWith("system:")))
|
|
454
|
+
throw new Error("Missing meta header. Excel file does not come from the template.");
|
|
455
|
+
const b = l.map((k) => k.split(":")[1]), T = [
|
|
456
|
+
"code",
|
|
457
|
+
"type",
|
|
458
|
+
"name",
|
|
459
|
+
"unit",
|
|
460
|
+
"enabled"
|
|
461
|
+
].filter((k) => !b.includes(k));
|
|
462
|
+
if (T.length)
|
|
463
|
+
throw new Error(
|
|
464
|
+
`Missing meta headers (${T.join()}). Excel file does not come from the template.`
|
|
465
|
+
);
|
|
466
|
+
return u.map((k, _) => {
|
|
467
|
+
const n = {};
|
|
468
|
+
for (const a in b) {
|
|
469
|
+
const d = b[a];
|
|
470
|
+
Object.assign(n, { [d]: k[a] });
|
|
471
|
+
}
|
|
472
|
+
return {
|
|
473
|
+
index: _,
|
|
474
|
+
data: n
|
|
475
|
+
};
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
function It(f) {
|
|
479
|
+
return f.reduce(
|
|
480
|
+
(l, i) => {
|
|
481
|
+
var r;
|
|
482
|
+
const v = i.data, p = i.index;
|
|
483
|
+
if (v.type == N.Enum.recipe)
|
|
484
|
+
l.result.push({ parent: i, children: [] });
|
|
485
|
+
else if (v.type == N.Enum.menu)
|
|
486
|
+
v.code ? l.result.push({ parent: i, children: [] }) : l.errors.push(`Menu item row ${p + 9} does not have a code.`);
|
|
487
|
+
else {
|
|
488
|
+
if (!v.unit) return l;
|
|
489
|
+
v.code ? l.result.push({ parent: i, children: [] }) : l.result.length ? (r = l.result.at(-1)) == null || r.children.push(i) : l.errors.push(`Cannot find parent for row ${p + 9}`);
|
|
490
|
+
}
|
|
491
|
+
return l;
|
|
492
|
+
},
|
|
493
|
+
{ result: new Array(), errors: new Array() }
|
|
494
|
+
);
|
|
495
|
+
}
|
|
496
|
+
function Ct(f) {
|
|
497
|
+
var t;
|
|
498
|
+
const l = f.parent.data, i = new Array(), v = ne();
|
|
499
|
+
if (f.parent.data.type == N.Enum.menu) {
|
|
500
|
+
const s = v.menu.cache, u = (t = s == null ? void 0 : s.modules.item) == null ? void 0 : t.find((g) => g.code === l.code);
|
|
501
|
+
if (!u)
|
|
502
|
+
return i.push(`Cannot find menu module of id ${l.code}`), { errors: i };
|
|
503
|
+
const b = {
|
|
504
|
+
type: N.Enum.menu,
|
|
505
|
+
code: u.code,
|
|
506
|
+
id: u._id,
|
|
507
|
+
name: u.name ?? ""
|
|
508
|
+
};
|
|
509
|
+
return { errors: i, templateItem: b };
|
|
510
|
+
}
|
|
511
|
+
if (f.parent.data.type == N.Enum.recipe) {
|
|
512
|
+
const u = v.recipes.find((g) => g.name === l.name);
|
|
513
|
+
if (!u)
|
|
514
|
+
return i.push(`Cannot find recipe module of id ${l.code}`), { errors: i };
|
|
515
|
+
const b = {
|
|
516
|
+
type: N.Enum.recipe,
|
|
517
|
+
id: u._id,
|
|
518
|
+
name: u.name ?? ""
|
|
519
|
+
};
|
|
520
|
+
return { errors: i, templateItem: b };
|
|
521
|
+
}
|
|
522
|
+
const p = v.skuByCode[l.code ?? ""];
|
|
523
|
+
if (!p)
|
|
524
|
+
return i.push(`Cannot find ingredient of code [${l.code}] [${l.name}]`), { errors: i };
|
|
525
|
+
const r = {
|
|
526
|
+
type: N.Enum.sku,
|
|
527
|
+
code: l.code,
|
|
528
|
+
id: p._id,
|
|
529
|
+
name: l.name ?? "",
|
|
530
|
+
disabledMeasurements: []
|
|
531
|
+
}, m = p.unit.measurements.find((s) => s.abbrev === l.unit);
|
|
532
|
+
l.unit !== p.unit.abbrev && !m ? i.push(
|
|
533
|
+
`Cannot find measurement unit of ${l.unit} for (${l.code}) ${l.name}.`
|
|
534
|
+
) : (!l.enabled || `${l.enabled}`.toLocaleLowerCase() === "false") && (r.disabledMeasurements ?? (r.disabledMeasurements = []), r.disabledMeasurements.push((m == null ? void 0 : m.id) ?? p.unit._id));
|
|
535
|
+
for (const s of f.children) {
|
|
536
|
+
const u = s.data, b = u.unit === p.unit.abbrev ? p.unit : void 0, g = p.unit.measurements.find((T) => T.abbrev === u.unit);
|
|
537
|
+
if (!g && !b) {
|
|
538
|
+
i.push(
|
|
539
|
+
`Cannot find measurement unit of ${u.unit} for (${l.code}) ${l.name}.`
|
|
540
|
+
);
|
|
541
|
+
continue;
|
|
542
|
+
}
|
|
543
|
+
(!u.enabled || `${u.enabled}`.toLocaleLowerCase() === "false") && (r.disabledMeasurements ?? (r.disabledMeasurements = []), r.disabledMeasurements.push((g == null ? void 0 : g.id) ?? (b == null ? void 0 : b._id) ?? ""));
|
|
544
|
+
}
|
|
545
|
+
const o = new Set(r.disabledMeasurements);
|
|
546
|
+
return o.has(p.unit._id) && p.unit.measurements.every((s) => o.has(s.id)) && i.push(`Ingredient ${p.code} - ${p.name} must have at least one unit enabled.`), { errors: i, templateItem: r };
|
|
547
|
+
}
|
|
548
|
+
function Ft(f) {
|
|
549
|
+
const l = f.SheetNames.filter(
|
|
550
|
+
(r) => !Object.values(ge).map(String).includes(r)
|
|
551
|
+
), v = oe().templates, p = rt(v, "_id");
|
|
552
|
+
try {
|
|
553
|
+
return l.reduce(
|
|
554
|
+
(m, o) => {
|
|
555
|
+
const t = new Array(), s = f.Sheets[o], u = $t(s), b = kt(u.locations), g = b.filter((d) => d.location).map((d) => d.location);
|
|
556
|
+
t.push(...b.flatMap((d) => d.errors));
|
|
557
|
+
const T = St(s).filter((d) => {
|
|
558
|
+
const e = d.data;
|
|
559
|
+
return e.type == N.Enum.menu ? e.code : e.type == N.Enum.recipe ? e.name : d.data.code || d.data.unit;
|
|
560
|
+
}), w = It(T);
|
|
561
|
+
t.push(...w.errors);
|
|
562
|
+
const k = w.result.map(
|
|
563
|
+
(d) => Ct(d)
|
|
564
|
+
);
|
|
565
|
+
t.push(...k.flatMap((d) => d.errors));
|
|
566
|
+
const _ = k.filter((d) => d.templateItem).map((d) => d.templateItem);
|
|
567
|
+
if (u.id) {
|
|
568
|
+
const d = p[u.id];
|
|
569
|
+
if (!d) {
|
|
570
|
+
const c = {
|
|
571
|
+
type: fe.Enum.WASTAGE,
|
|
572
|
+
_id: u.id,
|
|
573
|
+
_rev: "",
|
|
574
|
+
name: u.name || `(unnamed from sheet ${o || "<unnamed sheet>"})`,
|
|
575
|
+
items: []
|
|
576
|
+
};
|
|
577
|
+
return t.push(`Template ID ${u.id} is not found.`), m.importUpdateResult.push({
|
|
578
|
+
type: "update",
|
|
579
|
+
original: c,
|
|
580
|
+
template: c,
|
|
581
|
+
excelSheetName: o,
|
|
582
|
+
errors: t
|
|
583
|
+
}), m;
|
|
584
|
+
}
|
|
585
|
+
const e = {
|
|
586
|
+
type: "update",
|
|
587
|
+
original: d,
|
|
588
|
+
template: {
|
|
589
|
+
...d,
|
|
590
|
+
name: u.name,
|
|
591
|
+
locations: g.length ? g : null,
|
|
592
|
+
items: _
|
|
593
|
+
},
|
|
594
|
+
excelSheetName: o,
|
|
595
|
+
errors: t
|
|
596
|
+
};
|
|
597
|
+
return m.importUpdateResult.push(e), m;
|
|
598
|
+
}
|
|
599
|
+
const a = {
|
|
600
|
+
type: "create",
|
|
601
|
+
template: {
|
|
602
|
+
type: fe.Enum.WASTAGE,
|
|
603
|
+
name: u.name,
|
|
604
|
+
locations: g.length ? g : null,
|
|
605
|
+
items: _
|
|
606
|
+
},
|
|
607
|
+
excelSheetName: o,
|
|
608
|
+
errors: t
|
|
609
|
+
};
|
|
610
|
+
return m.importCreateResult.push(a), m;
|
|
611
|
+
},
|
|
612
|
+
{
|
|
613
|
+
invalidExcel: !1,
|
|
614
|
+
importCreateResult: new Array(),
|
|
615
|
+
importUpdateResult: new Array()
|
|
616
|
+
}
|
|
617
|
+
);
|
|
618
|
+
} catch (r) {
|
|
619
|
+
return {
|
|
620
|
+
invalidExcel: !0,
|
|
621
|
+
invalidExcelMessage: (r == null ? void 0 : r.message) ?? "Invalid excel",
|
|
622
|
+
importCreateResult: [],
|
|
623
|
+
importUpdateResult: []
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
const At = { class: "flex" }, Rt = { class: "flex flex-col flex-1" }, Dt = { class: "flex flex-col" }, Mt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary flex items-center gap-4" }, Et = {
|
|
628
|
+
key: 0,
|
|
629
|
+
class: "text-fm-color-typo-secondary fm-typo-en-body-sm-400"
|
|
630
|
+
}, Pt = { key: 0 }, jt = { class: "ml-auto" }, Vt = { key: 0 }, Ve = /* @__PURE__ */ G({
|
|
631
|
+
__name: "AdjustmentTemplateImportItem",
|
|
632
|
+
props: {
|
|
633
|
+
type: {},
|
|
634
|
+
name: {},
|
|
635
|
+
locations: {},
|
|
636
|
+
items: {},
|
|
637
|
+
errors: {}
|
|
638
|
+
},
|
|
639
|
+
setup(f) {
|
|
640
|
+
const l = f, { t: i } = J(), v = M(!1), p = () => {
|
|
641
|
+
l.errors.length && (v.value = !v.value);
|
|
642
|
+
};
|
|
643
|
+
return (r, m) => {
|
|
644
|
+
var t, s, u;
|
|
645
|
+
const o = E("FmIcon");
|
|
646
|
+
return I(), A("div", At, [
|
|
647
|
+
m[0] || (m[0] = y("div", null, "•", -1)),
|
|
648
|
+
y("div", Rt, [
|
|
649
|
+
y("div", {
|
|
650
|
+
class: Y(["flex items-center gap-12 pl-8", {
|
|
651
|
+
"cursor-pointer": r.errors.length
|
|
652
|
+
}]),
|
|
653
|
+
onClick: p
|
|
654
|
+
}, [
|
|
655
|
+
y("div", Dt, [
|
|
656
|
+
y("div", Mt, [
|
|
657
|
+
y("div", {
|
|
658
|
+
class: Y({
|
|
659
|
+
"text-fm-color-system-error-300": r.errors.length
|
|
660
|
+
})
|
|
661
|
+
}, [
|
|
662
|
+
Z(F(r.name) + " ", 1),
|
|
663
|
+
r.type === "create" ? (I(), A("span", Et, "(" + F(x(i)("inventory.closing.template.import.new")) + ")", 1)) : z("", !0)
|
|
664
|
+
], 2),
|
|
665
|
+
r.errors.length ? (I(), A("div", Pt, [
|
|
666
|
+
C(o, {
|
|
667
|
+
name: "error",
|
|
668
|
+
size: "sm",
|
|
669
|
+
color: "system-error-300"
|
|
670
|
+
})
|
|
671
|
+
])) : z("", !0)
|
|
672
|
+
]),
|
|
673
|
+
y("div", {
|
|
674
|
+
class: Y([
|
|
675
|
+
"fm-typo-en-body-sm-400",
|
|
676
|
+
{
|
|
677
|
+
"text-fm-color-system-error-200": r.errors.length,
|
|
678
|
+
"text-fm-color-typo-secondary": !r.errors.length
|
|
679
|
+
}
|
|
680
|
+
])
|
|
681
|
+
}, F((t = r.locations) != null && t.length ? x(i)("inventory.closing.template.import.nLocations", { count: (s = r.locations) == null ? void 0 : s.length }) : x(i)("inventory.closing.template.import.allLocations")) + ", " + F(x(i)("inventory.closing.template.import.nItems", { count: (u = r.items) == null ? void 0 : u.length })), 3)
|
|
682
|
+
]),
|
|
683
|
+
y("div", jt, [
|
|
684
|
+
r.errors.length ? (I(), O(o, {
|
|
685
|
+
key: 0,
|
|
686
|
+
name: v.value ? "keyboard_arrow_up" : "keyboard_arrow_down",
|
|
687
|
+
size: "md"
|
|
688
|
+
}, null, 8, ["name"])) : z("", !0)
|
|
689
|
+
])
|
|
690
|
+
], 2),
|
|
691
|
+
v.value ? (I(), A("div", {
|
|
692
|
+
key: 0,
|
|
693
|
+
class: Y(["flex flex-col gap-4 pl-8 fm-typo-en-body-sm-400", {
|
|
694
|
+
"text-fm-color-typo-secondary": !r.errors.length,
|
|
695
|
+
"text-fm-color-system-error-300": r.errors.length
|
|
696
|
+
}])
|
|
697
|
+
}, [
|
|
698
|
+
r.errors.length ? (I(), A("div", Vt, [
|
|
699
|
+
y("ol", null, [
|
|
700
|
+
(I(!0), A(K, null, X(r.errors, (b, g) => (I(), A("li", { key: g }, F(b), 1))), 128))
|
|
701
|
+
])
|
|
702
|
+
])) : z("", !0)
|
|
703
|
+
], 2)) : z("", !0)
|
|
704
|
+
])
|
|
705
|
+
]);
|
|
706
|
+
};
|
|
707
|
+
}
|
|
708
|
+
}), Ut = { class: "flex flex-col gap-24" }, Lt = { class: "fm-typo-en-body-md-400" }, Nt = {
|
|
709
|
+
key: 0,
|
|
710
|
+
class: "flex items-center gap-8"
|
|
711
|
+
}, Bt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, zt = { class: "flex flex-col gap-8" }, Ot = { class: "line-clamp-2 text-ellipsis break-all" }, Wt = {
|
|
712
|
+
key: 2,
|
|
713
|
+
class: "shrink-0"
|
|
714
|
+
}, Ht = {
|
|
715
|
+
key: 0,
|
|
716
|
+
class: "flex flex-col"
|
|
717
|
+
}, Kt = { class: "text-fm-color-system-error-300 fm-typo-en-body-sm-400" }, Yt = {
|
|
718
|
+
key: 0,
|
|
719
|
+
class: "max-h-[200px] overflow-y-auto flex flex-col gap-8"
|
|
720
|
+
}, Gt = { class: "fm-typo-en-body-lg-600" }, Jt = /* @__PURE__ */ G({
|
|
721
|
+
__name: "AdjustmentTemplateImport",
|
|
722
|
+
setup(f) {
|
|
723
|
+
const l = M(null), i = ot(), v = te(), p = M(!1), r = M(!1), m = M(new Array()), o = M([]), t = M([]), s = U(
|
|
724
|
+
() => !!m.value.length || o.value.some((T) => T.errors.length) || t.value.some((T) => T.errors.length)
|
|
725
|
+
), u = U(
|
|
726
|
+
() => !!o.value.length || !!t.value.length
|
|
727
|
+
), { t: b } = J();
|
|
728
|
+
async function g(T) {
|
|
729
|
+
m.value = [], o.value = [], t.value = [];
|
|
730
|
+
try {
|
|
731
|
+
p.value = !0;
|
|
732
|
+
const [w] = await Promise.all([
|
|
733
|
+
mt(T),
|
|
734
|
+
// fake buffer
|
|
735
|
+
new Promise((a) => setTimeout(a, 1e3))
|
|
736
|
+
]);
|
|
737
|
+
if (!w.SheetNames.filter(
|
|
738
|
+
(a) => !Object.values(ge).map(String).includes(a)
|
|
739
|
+
).find((a) => a)) {
|
|
740
|
+
m.value.push(b("inventory.ingredient.import.fileError.noSheet"));
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
const n = Ft(w);
|
|
744
|
+
if (n.invalidExcel) {
|
|
745
|
+
m.value.push(
|
|
746
|
+
n.invalidExcelMessage ?? b("inventory.ingredient.import.fileError.invalidExcel")
|
|
747
|
+
);
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
if (o.value = n.importCreateResult, t.value = n.importUpdateResult, !o.value.length && !t.value.length) {
|
|
751
|
+
m.value.push(b("inventory.ingredient.import.fileError.noData"));
|
|
752
|
+
return;
|
|
753
|
+
}
|
|
754
|
+
i.emitData(n);
|
|
755
|
+
} catch (w) {
|
|
756
|
+
v.open({
|
|
757
|
+
title: b("inventory.ingredient.import.fileError.unableToRead"),
|
|
758
|
+
message: w == null ? void 0 : w.message,
|
|
759
|
+
type: "error"
|
|
760
|
+
}), console.error("Error in reading file", w);
|
|
761
|
+
} finally {
|
|
762
|
+
m.value.length && v.open({
|
|
763
|
+
title: b("inventory.ingredient.import.fileError.invalidExcel"),
|
|
764
|
+
type: "error"
|
|
765
|
+
}), p.value = !1;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
return pe(l, (T) => {
|
|
769
|
+
T && g(T);
|
|
770
|
+
}), (T, w) => {
|
|
771
|
+
const k = E("FmCircularProgress"), _ = E("FmIcon"), n = E("FmButton");
|
|
772
|
+
return I(), A("div", Ut, [
|
|
773
|
+
y("div", Lt, F(x(b)("inventory.adjustment.template.import.message")), 1),
|
|
774
|
+
r.value ? (I(), A("div", Nt, [
|
|
775
|
+
y("div", null, [
|
|
776
|
+
C(k, {
|
|
777
|
+
size: "md",
|
|
778
|
+
color: "neutral-gray-200"
|
|
779
|
+
})
|
|
780
|
+
]),
|
|
781
|
+
y("div", Bt, F(x(b)("inventory.formField.loading")), 1)
|
|
782
|
+
])) : (I(), A(K, { key: 1 }, [
|
|
783
|
+
C(ft, {
|
|
784
|
+
class: Y({
|
|
785
|
+
"w-full": !0,
|
|
786
|
+
"h-[200px]": !l.value
|
|
787
|
+
}),
|
|
788
|
+
accept: ".xlsx",
|
|
789
|
+
onFileUpload: w[0] || (w[0] = (a) => l.value = a),
|
|
790
|
+
label: x(b)("inventory.ingredient.import.uploadTemplate"),
|
|
791
|
+
"button-label": x(b)("inventory.ingredient.import.selectFile")
|
|
792
|
+
}, Ue({ _: 2 }, [
|
|
793
|
+
l.value ? {
|
|
794
|
+
name: "default",
|
|
795
|
+
fn: j(({ openFileDialog: a }) => [
|
|
796
|
+
y("div", zt, [
|
|
797
|
+
y("div", {
|
|
798
|
+
class: Y([
|
|
799
|
+
"fm-corner-radius-md p-16 flex items-center gap-16",
|
|
800
|
+
{
|
|
801
|
+
"border border-fm-color-neutral-gray-100": p.value,
|
|
802
|
+
"border border-fm-color-neutral-gray-200": !p.value && !s.value,
|
|
803
|
+
"border border-fm-color-system-error-200": s.value
|
|
804
|
+
}
|
|
805
|
+
])
|
|
806
|
+
}, [
|
|
807
|
+
p.value ? (I(), O(k, {
|
|
808
|
+
key: 0,
|
|
809
|
+
size: "md",
|
|
810
|
+
color: "neutral-gray-200"
|
|
811
|
+
})) : (I(), O(_, {
|
|
812
|
+
key: 1,
|
|
813
|
+
name: s.value ? "error" : "attach_file",
|
|
814
|
+
outline: "",
|
|
815
|
+
color: s.value ? "system-error-300" : void 0
|
|
816
|
+
}, null, 8, ["name", "color"])),
|
|
817
|
+
y("div", {
|
|
818
|
+
class: Y([
|
|
819
|
+
"fm-typo-en-body-md-400 flex-1 h-[36px] flex items-center",
|
|
820
|
+
{
|
|
821
|
+
"text-fm-color-typo-disabled": p.value,
|
|
822
|
+
"text-fm-color-typo-primary": !p.value
|
|
823
|
+
}
|
|
824
|
+
])
|
|
825
|
+
}, [
|
|
826
|
+
y("div", Ot, F(l.value.name), 1)
|
|
827
|
+
], 2),
|
|
828
|
+
p.value ? z("", !0) : (I(), A("div", Wt, [
|
|
829
|
+
C(n, {
|
|
830
|
+
label: x(b)("inventory.ingredient.import.replaceFile"),
|
|
831
|
+
variant: s.value ? "destructive" : "secondary",
|
|
832
|
+
"prepend-icon": s.value ? void 0 : "autorenew",
|
|
833
|
+
onClick: a
|
|
834
|
+
}, null, 8, ["label", "variant", "prepend-icon", "onClick"])
|
|
835
|
+
]))
|
|
836
|
+
], 2),
|
|
837
|
+
m.value.length ? (I(), A("div", Ht, [
|
|
838
|
+
(I(!0), A(K, null, X(m.value, (d, e) => (I(), A("div", {
|
|
839
|
+
key: e,
|
|
840
|
+
class: "flex gap-8 items-center"
|
|
841
|
+
}, [
|
|
842
|
+
C(_, {
|
|
843
|
+
name: "error",
|
|
844
|
+
size: "sm",
|
|
845
|
+
color: "system-error-300"
|
|
846
|
+
}),
|
|
847
|
+
y("div", Kt, F(d), 1)
|
|
848
|
+
]))), 128))
|
|
849
|
+
])) : z("", !0)
|
|
850
|
+
])
|
|
851
|
+
]),
|
|
852
|
+
key: "0"
|
|
853
|
+
} : void 0
|
|
854
|
+
]), 1032, ["class", "label", "button-label"]),
|
|
855
|
+
u.value ? (I(), A("div", Yt, [
|
|
856
|
+
y("div", Gt, F(x(b)("inventory.ingredient.import.summary")), 1),
|
|
857
|
+
(I(!0), A(K, null, X(o.value, (a, d) => (I(), O(Ve, {
|
|
858
|
+
key: d,
|
|
859
|
+
name: a.template.name,
|
|
860
|
+
locations: a.template.locations,
|
|
861
|
+
items: a.template.items,
|
|
862
|
+
errors: a.errors,
|
|
863
|
+
type: "create"
|
|
864
|
+
}, null, 8, ["name", "locations", "items", "errors"]))), 128)),
|
|
865
|
+
(I(!0), A(K, null, X(t.value, (a) => (I(), O(Ve, {
|
|
866
|
+
key: a.template._id,
|
|
867
|
+
name: a.template.name,
|
|
868
|
+
locations: a.template.locations,
|
|
869
|
+
items: a.template.items,
|
|
870
|
+
errors: a.errors,
|
|
871
|
+
type: "update"
|
|
872
|
+
}, null, 8, ["name", "locations", "items", "errors"]))), 128))
|
|
873
|
+
])) : z("", !0)
|
|
874
|
+
], 64))
|
|
875
|
+
]);
|
|
876
|
+
};
|
|
877
|
+
}
|
|
878
|
+
}), ye = ze("wastageTemplateAction", () => {
|
|
879
|
+
const { t: f } = J(), l = ee(), i = te(), v = se(), p = vt(), r = oe(), { loading: m } = Oe(r), o = M({});
|
|
880
|
+
function t() {
|
|
881
|
+
o.value = {
|
|
882
|
+
mode: q.CREATE,
|
|
883
|
+
show: !0,
|
|
884
|
+
"onUpdate:show"(e) {
|
|
885
|
+
o.value.show = e;
|
|
886
|
+
}
|
|
887
|
+
};
|
|
888
|
+
}
|
|
889
|
+
function s(e) {
|
|
890
|
+
o.value = {
|
|
891
|
+
mode: q.UPDATE,
|
|
892
|
+
modelValue: e,
|
|
893
|
+
show: !0,
|
|
894
|
+
"onUpdate:show"(c) {
|
|
895
|
+
o.value.show = c;
|
|
896
|
+
}
|
|
897
|
+
};
|
|
898
|
+
}
|
|
899
|
+
function u(e, c, R) {
|
|
900
|
+
l.open({
|
|
901
|
+
title: `Confirm deleting template ${e.name}?`,
|
|
902
|
+
message: "Deleted template can no longer be retrieved",
|
|
903
|
+
primaryActions: {
|
|
904
|
+
text: "Delete",
|
|
905
|
+
variant: Q.Destructive,
|
|
906
|
+
close: !0
|
|
907
|
+
},
|
|
908
|
+
secondaryActions: {
|
|
909
|
+
text: "Cancel",
|
|
910
|
+
variant: Q.Plain,
|
|
911
|
+
close: !0
|
|
912
|
+
}
|
|
913
|
+
}).onPrimary(async () => {
|
|
914
|
+
i.open({
|
|
915
|
+
title: `Deleting ${e.name}`,
|
|
916
|
+
type: "info"
|
|
917
|
+
});
|
|
918
|
+
try {
|
|
919
|
+
c.value = !0;
|
|
920
|
+
const [$] = await Promise.allSettled([
|
|
921
|
+
v.deleteTemplate(e),
|
|
922
|
+
new Promise((h) => setTimeout(h, 1e3))
|
|
923
|
+
]);
|
|
924
|
+
if ($.status === "rejected") throw $.reason;
|
|
925
|
+
i.open({
|
|
926
|
+
title: `Deleted "${e.name}"`,
|
|
927
|
+
type: "success"
|
|
928
|
+
});
|
|
929
|
+
} catch ($) {
|
|
930
|
+
i.open({
|
|
931
|
+
title: `Unable to delete "${e.name}"`,
|
|
932
|
+
message: $.message,
|
|
933
|
+
type: "error"
|
|
934
|
+
});
|
|
935
|
+
} finally {
|
|
936
|
+
c.value = !1, R();
|
|
937
|
+
}
|
|
938
|
+
});
|
|
939
|
+
}
|
|
940
|
+
function b(e, c, R) {
|
|
941
|
+
l.open({
|
|
942
|
+
title: `Confirm unpublishing template "${e.name}"?`,
|
|
943
|
+
message: "Unpublished template will no longer be available at locations",
|
|
944
|
+
primaryActions: {
|
|
945
|
+
text: "Unpublish",
|
|
946
|
+
variant: Q.Destructive,
|
|
947
|
+
close: !0
|
|
948
|
+
},
|
|
949
|
+
secondaryActions: {
|
|
950
|
+
text: "Cancel",
|
|
951
|
+
variant: Q.Plain,
|
|
952
|
+
close: !0
|
|
953
|
+
}
|
|
954
|
+
}).onPrimary(async () => {
|
|
955
|
+
i.open({
|
|
956
|
+
title: `Unpublishing "${e.name}"`,
|
|
957
|
+
type: "info"
|
|
958
|
+
});
|
|
959
|
+
try {
|
|
960
|
+
c.value = !0;
|
|
961
|
+
const [$] = await Promise.allSettled([
|
|
962
|
+
v.unpublishSingleDoc(e._id),
|
|
963
|
+
new Promise((h) => setTimeout(h, 1e3))
|
|
964
|
+
]);
|
|
965
|
+
if ($.status === "rejected") throw $.reason;
|
|
966
|
+
i.open({
|
|
967
|
+
title: `Unpublished "${e.name}"`,
|
|
968
|
+
type: "success"
|
|
969
|
+
});
|
|
970
|
+
} catch ($) {
|
|
971
|
+
i.open({
|
|
972
|
+
title: `Unable to unpublish "${e.name}"`,
|
|
973
|
+
message: `See error from server: ${$}`,
|
|
974
|
+
type: "error"
|
|
975
|
+
}), console.error("error on unpublishing adjustment template", $);
|
|
976
|
+
} finally {
|
|
977
|
+
c.value = !1, R();
|
|
978
|
+
}
|
|
979
|
+
});
|
|
980
|
+
}
|
|
981
|
+
function g(e, c, R) {
|
|
982
|
+
let $;
|
|
983
|
+
l.open({
|
|
984
|
+
title: `Confirm duplicating template "${e.name}"?`,
|
|
985
|
+
message: "Duplicated template can be edited after creation",
|
|
986
|
+
primaryActions: {
|
|
987
|
+
text: "Duplicate",
|
|
988
|
+
variant: Q.Destructive,
|
|
989
|
+
close: !0
|
|
990
|
+
},
|
|
991
|
+
secondaryActions: {
|
|
992
|
+
text: "Cancel",
|
|
993
|
+
variant: Q.Plain,
|
|
994
|
+
close: !0
|
|
995
|
+
},
|
|
996
|
+
contentComponent: G({
|
|
997
|
+
props: ["modelValue"],
|
|
998
|
+
emits: ["update:modelValue"],
|
|
999
|
+
setup(h) {
|
|
1000
|
+
return () => P(H.FmTextField, {
|
|
1001
|
+
modelValue: h.modelValue,
|
|
1002
|
+
"onUpdate:modelValue": (S) => $ = S,
|
|
1003
|
+
label: "New Template Name",
|
|
1004
|
+
size: "md",
|
|
1005
|
+
variant: "primary"
|
|
1006
|
+
});
|
|
1007
|
+
}
|
|
1008
|
+
})
|
|
1009
|
+
}).onPrimary(async () => {
|
|
1010
|
+
i.open({
|
|
1011
|
+
title: `Duplicating "${e.name}"`,
|
|
1012
|
+
type: "info"
|
|
1013
|
+
});
|
|
1014
|
+
try {
|
|
1015
|
+
c.value = !0;
|
|
1016
|
+
const [h] = await Promise.allSettled([
|
|
1017
|
+
p.duplicateWastagetemplate(e._id, $),
|
|
1018
|
+
new Promise((S) => setTimeout(S, 1e3))
|
|
1019
|
+
]);
|
|
1020
|
+
if (h.status === "rejected") throw h.reason;
|
|
1021
|
+
i.open({
|
|
1022
|
+
title: `Duplicated "${e.name}"`,
|
|
1023
|
+
type: "success"
|
|
1024
|
+
});
|
|
1025
|
+
} catch (h) {
|
|
1026
|
+
i.open({
|
|
1027
|
+
title: `Unable to duplicate "${e.name}"`,
|
|
1028
|
+
message: `See error from server: ${h}`,
|
|
1029
|
+
type: "error"
|
|
1030
|
+
}), console.error("error on duplicating adjustment template", h);
|
|
1031
|
+
} finally {
|
|
1032
|
+
c.value = !1, R();
|
|
1033
|
+
}
|
|
1034
|
+
});
|
|
1035
|
+
}
|
|
1036
|
+
const T = M({});
|
|
1037
|
+
function w(e) {
|
|
1038
|
+
T.value = {
|
|
1039
|
+
template: e,
|
|
1040
|
+
show: !0,
|
|
1041
|
+
"onUpdate:show"(c) {
|
|
1042
|
+
T.value.show = c;
|
|
1043
|
+
},
|
|
1044
|
+
"onAction:edit"() {
|
|
1045
|
+
T.value.show = !1, s(We(e));
|
|
1046
|
+
}
|
|
1047
|
+
};
|
|
1048
|
+
}
|
|
1049
|
+
function k() {
|
|
1050
|
+
if (!r.templates.length) {
|
|
1051
|
+
i.open({
|
|
1052
|
+
title: "No data to export",
|
|
1053
|
+
type: "error"
|
|
1054
|
+
});
|
|
1055
|
+
return;
|
|
1056
|
+
}
|
|
1057
|
+
const e = wt(r.templates);
|
|
1058
|
+
i.open({
|
|
1059
|
+
title: f("inventory.ingredient.export.success"),
|
|
1060
|
+
message: f("inventory.ingredient.export.filename", [e]),
|
|
1061
|
+
type: "success"
|
|
1062
|
+
});
|
|
1063
|
+
}
|
|
1064
|
+
function _() {
|
|
1065
|
+
r.loading || l.open({
|
|
1066
|
+
title: f("inventory.adjustment.template.import.title"),
|
|
1067
|
+
contentComponent: Jt,
|
|
1068
|
+
overlay: !0,
|
|
1069
|
+
closeButton: !0,
|
|
1070
|
+
primaryActions: {
|
|
1071
|
+
text: f("common.import"),
|
|
1072
|
+
close: !1
|
|
1073
|
+
},
|
|
1074
|
+
secondaryActions: {
|
|
1075
|
+
text: f("common.close"),
|
|
1076
|
+
close: !0
|
|
1077
|
+
},
|
|
1078
|
+
tertiaryActions: {
|
|
1079
|
+
text: f("inventory.ingredient.import.actions.downloadTemplate"),
|
|
1080
|
+
close: !1,
|
|
1081
|
+
variant: "plain"
|
|
1082
|
+
}
|
|
1083
|
+
}).onPrimary((e) => {
|
|
1084
|
+
if (!e) {
|
|
1085
|
+
i.open({
|
|
1086
|
+
title: f("inventory.ingredient.import.error.noData"),
|
|
1087
|
+
type: "error"
|
|
1088
|
+
});
|
|
1089
|
+
return;
|
|
1090
|
+
}
|
|
1091
|
+
if (!e.importCreateResult.length && !e.importUpdateResult.length) {
|
|
1092
|
+
i.open({
|
|
1093
|
+
title: f("inventory.ingredient.import.error.invalidContent"),
|
|
1094
|
+
message: f("inventory.ingredient.import.error.noImportData"),
|
|
1095
|
+
type: "error"
|
|
1096
|
+
});
|
|
1097
|
+
return;
|
|
1098
|
+
}
|
|
1099
|
+
if (e.importCreateResult.some((c) => c.errors.length) || e.importUpdateResult.some((c) => c.errors.length)) {
|
|
1100
|
+
i.open({
|
|
1101
|
+
title: f("inventory.ingredient.import.error.invalidContent"),
|
|
1102
|
+
message: f("inventory.ingredient.import.error.hasErrors"),
|
|
1103
|
+
type: "error"
|
|
1104
|
+
});
|
|
1105
|
+
return;
|
|
1106
|
+
}
|
|
1107
|
+
l.close(), n(e);
|
|
1108
|
+
}).onTertiary(Tt);
|
|
1109
|
+
}
|
|
1110
|
+
async function n(e) {
|
|
1111
|
+
m.value = !0;
|
|
1112
|
+
try {
|
|
1113
|
+
const c = [
|
|
1114
|
+
...e.importCreateResult.map(
|
|
1115
|
+
(S) => S.template
|
|
1116
|
+
),
|
|
1117
|
+
...e.importUpdateResult.map(
|
|
1118
|
+
(S) => S.template
|
|
1119
|
+
)
|
|
1120
|
+
], R = 100;
|
|
1121
|
+
let $ = 0;
|
|
1122
|
+
const h = () => {
|
|
1123
|
+
$ += R, i.open({
|
|
1124
|
+
title: f("inventory.ingredient.import.progress", [
|
|
1125
|
+
Math.min($, c.length),
|
|
1126
|
+
c.length
|
|
1127
|
+
])
|
|
1128
|
+
});
|
|
1129
|
+
};
|
|
1130
|
+
for (const S of c.chunk(100))
|
|
1131
|
+
h(), await v.importTemplates(S);
|
|
1132
|
+
i.open({
|
|
1133
|
+
title: f("inventory.ingredient.import.success"),
|
|
1134
|
+
type: "success"
|
|
1135
|
+
});
|
|
1136
|
+
} catch (c) {
|
|
1137
|
+
i.open({
|
|
1138
|
+
title: f("inventory.ingredient.import.error.failed"),
|
|
1139
|
+
message: f("inventory.ingredient.import.error.systemMessage", [c == null ? void 0 : c.message]),
|
|
1140
|
+
type: "error"
|
|
1141
|
+
}), console.error("Error in importing skus", e, c);
|
|
1142
|
+
} finally {
|
|
1143
|
+
m.value = !1, r.fetchTemplates();
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
const a = M({});
|
|
1147
|
+
function d() {
|
|
1148
|
+
a.value = {
|
|
1149
|
+
show: !0,
|
|
1150
|
+
"onUpdate:show"(e) {
|
|
1151
|
+
a.value.show = e;
|
|
1152
|
+
}
|
|
1153
|
+
};
|
|
1154
|
+
}
|
|
1155
|
+
return {
|
|
1156
|
+
createTemplate: t,
|
|
1157
|
+
viewTemplate: w,
|
|
1158
|
+
updateTemplate: s,
|
|
1159
|
+
deleteTemplate: u,
|
|
1160
|
+
unpublishTemplate: b,
|
|
1161
|
+
duplicateTemplate: g,
|
|
1162
|
+
exportTemplates: k,
|
|
1163
|
+
importTemplates: _,
|
|
1164
|
+
viewReason: d,
|
|
1165
|
+
templateDialogProps: o,
|
|
1166
|
+
templateDetailsProps: T,
|
|
1167
|
+
templateReasonProps: a
|
|
1168
|
+
};
|
|
1169
|
+
});
|
|
1170
|
+
function qt(f) {
|
|
1171
|
+
const l = ne(), i = U(() => {
|
|
1172
|
+
const r = /* @__PURE__ */ new Map();
|
|
1173
|
+
for (const m of l.skus)
|
|
1174
|
+
r.set(m._id, m);
|
|
1175
|
+
return r;
|
|
1176
|
+
}), v = U(() => {
|
|
1177
|
+
const r = [];
|
|
1178
|
+
for (const m of f.items)
|
|
1179
|
+
m.type === "sku" && (i.value.get(m.id) || r.push(m));
|
|
1180
|
+
return r;
|
|
1181
|
+
});
|
|
1182
|
+
return {
|
|
1183
|
+
columnDefs: U(() => {
|
|
1184
|
+
const r = f.items.map((o) => {
|
|
1185
|
+
if (o.type !== "sku") return 0;
|
|
1186
|
+
const t = i.value.get(o.id);
|
|
1187
|
+
return t ? t.unit.measurements.length : 0;
|
|
1188
|
+
}).reduce((o, t) => Math.max(o, t), 0);
|
|
1189
|
+
return [
|
|
1190
|
+
{
|
|
1191
|
+
id: "Delete",
|
|
1192
|
+
header: "",
|
|
1193
|
+
cell(o) {
|
|
1194
|
+
const t = o.row.original;
|
|
1195
|
+
return P(
|
|
1196
|
+
"div",
|
|
1197
|
+
{ class: "w-full flex justify-end" },
|
|
1198
|
+
P(H.FmButton, {
|
|
1199
|
+
class: "delete-button",
|
|
1200
|
+
key: t.id,
|
|
1201
|
+
type: "button",
|
|
1202
|
+
icon: "delete",
|
|
1203
|
+
variant: "tertiary",
|
|
1204
|
+
size: "md",
|
|
1205
|
+
disabled: f.disabled,
|
|
1206
|
+
onClick: () => {
|
|
1207
|
+
f.deleteItem(t);
|
|
1208
|
+
}
|
|
1209
|
+
})
|
|
1210
|
+
);
|
|
1211
|
+
},
|
|
1212
|
+
enableSorting: !1,
|
|
1213
|
+
size: 40,
|
|
1214
|
+
meta: {
|
|
1215
|
+
cellClass: "",
|
|
1216
|
+
headerClass: ""
|
|
1217
|
+
}
|
|
1218
|
+
},
|
|
1219
|
+
{
|
|
1220
|
+
id: "Name",
|
|
1221
|
+
header: () => "Name",
|
|
1222
|
+
enableSorting: !1,
|
|
1223
|
+
size: 400,
|
|
1224
|
+
minSize: 400,
|
|
1225
|
+
accessorFn: (o) => `${o.name} ${o.code}`,
|
|
1226
|
+
cell(o) {
|
|
1227
|
+
const t = o.row.original;
|
|
1228
|
+
return P("div", { class: "flex", style: { minWidth: "400px" } }, [
|
|
1229
|
+
P(
|
|
1230
|
+
"div",
|
|
1231
|
+
{
|
|
1232
|
+
class: "flex flex-col grow"
|
|
1233
|
+
},
|
|
1234
|
+
[
|
|
1235
|
+
P(
|
|
1236
|
+
H.FmTooltip,
|
|
1237
|
+
{
|
|
1238
|
+
content: t.name,
|
|
1239
|
+
placement: "top",
|
|
1240
|
+
variant: "plain",
|
|
1241
|
+
zIndex: 50
|
|
1242
|
+
},
|
|
1243
|
+
P(
|
|
1244
|
+
"span",
|
|
1245
|
+
{
|
|
1246
|
+
class: "flex-auto fm-typo-en-body-lg-400 text-fm-color-typo-primary line-clamp-1"
|
|
1247
|
+
},
|
|
1248
|
+
t.name
|
|
1249
|
+
)
|
|
1250
|
+
),
|
|
1251
|
+
P(
|
|
1252
|
+
"span",
|
|
1253
|
+
{ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary line-clamp-1" },
|
|
1254
|
+
t.code ?? ""
|
|
1255
|
+
)
|
|
1256
|
+
]
|
|
1257
|
+
),
|
|
1258
|
+
P(
|
|
1259
|
+
"div",
|
|
1260
|
+
{
|
|
1261
|
+
class: "flex flex-col justify-center"
|
|
1262
|
+
},
|
|
1263
|
+
[
|
|
1264
|
+
P(
|
|
1265
|
+
H.FmChip,
|
|
1266
|
+
{
|
|
1267
|
+
compact: !0
|
|
1268
|
+
},
|
|
1269
|
+
t.type === "sku" ? "Ingredient" : t.type === "recipe" ? "Recipe" : "Menu"
|
|
1270
|
+
)
|
|
1271
|
+
]
|
|
1272
|
+
)
|
|
1273
|
+
]);
|
|
1274
|
+
}
|
|
1275
|
+
},
|
|
1276
|
+
{
|
|
1277
|
+
id: "Unit",
|
|
1278
|
+
header: () => "Enable unit",
|
|
1279
|
+
enableSorting: !1,
|
|
1280
|
+
minSize: 200,
|
|
1281
|
+
maxSize: 400,
|
|
1282
|
+
cell(o) {
|
|
1283
|
+
var u, b, g;
|
|
1284
|
+
const t = o.row.original;
|
|
1285
|
+
if (t.type !== "sku") return P("span", "N/A");
|
|
1286
|
+
const s = i.value.get(t.id);
|
|
1287
|
+
return P("div", { class: "flex items-center gap-32" }, [
|
|
1288
|
+
P(
|
|
1289
|
+
H.FmFormGroup,
|
|
1290
|
+
{
|
|
1291
|
+
value: s.unit._id,
|
|
1292
|
+
modelValue: !((u = t.disabledMeasurements) != null && u.includes(s.unit._id))
|
|
1293
|
+
},
|
|
1294
|
+
P(
|
|
1295
|
+
"div",
|
|
1296
|
+
{
|
|
1297
|
+
class: "flex items-center gap-4",
|
|
1298
|
+
style: { width: "120px" }
|
|
1299
|
+
},
|
|
1300
|
+
[
|
|
1301
|
+
P(H.FmCheckbox, {
|
|
1302
|
+
value: s.unit._id,
|
|
1303
|
+
modelValue: !((b = t.disabledMeasurements) != null && b.includes(s.unit._id)),
|
|
1304
|
+
disabled: f.disabled || !((g = t.disabledMeasurements) != null && g.includes(s.unit._id)) && s.unit.measurements.every(
|
|
1305
|
+
(T) => {
|
|
1306
|
+
var w;
|
|
1307
|
+
return (w = t.disabledMeasurements) == null ? void 0 : w.includes(T.id);
|
|
1308
|
+
}
|
|
1309
|
+
),
|
|
1310
|
+
"onUpdate:modelValue"(T) {
|
|
1311
|
+
var w;
|
|
1312
|
+
if (console.log("active", T), T)
|
|
1313
|
+
f.updateItem({
|
|
1314
|
+
...t,
|
|
1315
|
+
disabledMeasurements: (w = t.disabledMeasurements) == null ? void 0 : w.filter(
|
|
1316
|
+
(k) => k !== s.unit._id
|
|
1317
|
+
)
|
|
1318
|
+
});
|
|
1319
|
+
else {
|
|
1320
|
+
const k = t.disabledMeasurements ?? [];
|
|
1321
|
+
f.updateItem({
|
|
1322
|
+
...t,
|
|
1323
|
+
disabledMeasurements: [...k, s.unit._id]
|
|
1324
|
+
});
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
}),
|
|
1328
|
+
P(
|
|
1329
|
+
H.FmTooltip,
|
|
1330
|
+
{ zIndex: 51 },
|
|
1331
|
+
{
|
|
1332
|
+
content() {
|
|
1333
|
+
return i.value.get(t.id).unit.abbrev;
|
|
1334
|
+
},
|
|
1335
|
+
default() {
|
|
1336
|
+
const T = i.value.get(t.id);
|
|
1337
|
+
return P(
|
|
1338
|
+
"div",
|
|
1339
|
+
{ class: "line-clamp-2 fm-typo-en-body-lg-400" },
|
|
1340
|
+
T.unit.abbrev
|
|
1341
|
+
);
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
)
|
|
1345
|
+
]
|
|
1346
|
+
)
|
|
1347
|
+
),
|
|
1348
|
+
...Array.from({ length: Math.max(r, 0) }).map((T, w) => {
|
|
1349
|
+
var a, d, e, c;
|
|
1350
|
+
const k = o.row.original, _ = i.value.get(k.id), n = _.unit.measurements[w];
|
|
1351
|
+
return n ? P(
|
|
1352
|
+
H.FmFormGroup,
|
|
1353
|
+
{
|
|
1354
|
+
modelValue: !((a = k.disabledMeasurements) != null && a.includes(n.id)),
|
|
1355
|
+
value: n.id
|
|
1356
|
+
},
|
|
1357
|
+
P(
|
|
1358
|
+
"div",
|
|
1359
|
+
{
|
|
1360
|
+
class: "flex items-center gap-4",
|
|
1361
|
+
style: { width: "120px" }
|
|
1362
|
+
},
|
|
1363
|
+
[
|
|
1364
|
+
P(H.FmCheckbox, {
|
|
1365
|
+
value: n.id,
|
|
1366
|
+
modelValue: !((d = k.disabledMeasurements) != null && d.includes(n.id)),
|
|
1367
|
+
disabled: f.disabled || !((e = k.disabledMeasurements) != null && e.includes(n.id)) && ((c = k.disabledMeasurements) == null ? void 0 : c.includes(_.unit._id)) && _.unit.measurements.filter((R) => R.id != n.id).every((R) => {
|
|
1368
|
+
var $;
|
|
1369
|
+
return ($ = k.disabledMeasurements) == null ? void 0 : $.includes(R.id);
|
|
1370
|
+
}),
|
|
1371
|
+
"onUpdate:modelValue"(R) {
|
|
1372
|
+
var $;
|
|
1373
|
+
if (console.log("active", R), R)
|
|
1374
|
+
f.updateItem({
|
|
1375
|
+
...k,
|
|
1376
|
+
disabledMeasurements: ($ = k.disabledMeasurements) == null ? void 0 : $.filter(
|
|
1377
|
+
(h) => h !== n.id
|
|
1378
|
+
)
|
|
1379
|
+
});
|
|
1380
|
+
else {
|
|
1381
|
+
const h = k.disabledMeasurements ?? [];
|
|
1382
|
+
f.updateItem({
|
|
1383
|
+
...k,
|
|
1384
|
+
disabledMeasurements: [...h, n.id]
|
|
1385
|
+
});
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
}),
|
|
1389
|
+
P(
|
|
1390
|
+
H.FmTooltip,
|
|
1391
|
+
{ zIndex: 51 },
|
|
1392
|
+
{
|
|
1393
|
+
content() {
|
|
1394
|
+
return n.abbrev;
|
|
1395
|
+
},
|
|
1396
|
+
default() {
|
|
1397
|
+
return P(
|
|
1398
|
+
"div",
|
|
1399
|
+
{ class: "line-clamp-2 fm-typo-en-body-lg-400" },
|
|
1400
|
+
n.abbrev
|
|
1401
|
+
);
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
)
|
|
1405
|
+
]
|
|
1406
|
+
)
|
|
1407
|
+
) : null;
|
|
1408
|
+
})
|
|
1409
|
+
]);
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
];
|
|
1413
|
+
}),
|
|
1414
|
+
missingSKUs: v
|
|
1415
|
+
};
|
|
1416
|
+
}
|
|
1417
|
+
const Qt = { class: "flex flex-col gap-16" }, Xt = { class: "flex items-center" }, Zt = { class: "flex-1 gap-8 fm-typo-en-title-sm-600" }, en = {
|
|
1418
|
+
key: 0,
|
|
1419
|
+
class: "flex flex-col gap-8 p-16 bg-fm-color-system-warning-100 border border-fm-color-system-warning-400 rounded-lg"
|
|
1420
|
+
}, tn = { class: "fm-typo-en-title-xs-600 text-fm-color-system-warning-400 flex items-center gap-8" }, nn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary" }, sn = { class: "list-disc pl-20 mt-8" }, on = /* @__PURE__ */ G({
|
|
1421
|
+
__name: "WastageTemplateItemTable",
|
|
1422
|
+
props: {
|
|
1423
|
+
modelValue: {},
|
|
1424
|
+
disabled: { type: Boolean }
|
|
1425
|
+
},
|
|
1426
|
+
emits: ["update:modelValue"],
|
|
1427
|
+
setup(f, { expose: l, emit: i }) {
|
|
1428
|
+
const v = f, p = M(v.modelValue), { t: r } = J(), m = i, o = ne(), t = ee(), s = M(), u = M("");
|
|
1429
|
+
l({
|
|
1430
|
+
validateInputs: () => {
|
|
1431
|
+
var _, n;
|
|
1432
|
+
(n = (_ = s.value) == null ? void 0 : _.validateInputs) == null || n.call(_);
|
|
1433
|
+
},
|
|
1434
|
+
resetInputsValidation: () => {
|
|
1435
|
+
var _, n;
|
|
1436
|
+
(n = (_ = s.value) == null ? void 0 : _.resetInputsValidation) == null || n.call(_);
|
|
1437
|
+
},
|
|
1438
|
+
resetInputs: () => {
|
|
1439
|
+
var _, n;
|
|
1440
|
+
(n = (_ = s.value) == null ? void 0 : _.resetInputs) == null || n.call(_);
|
|
1441
|
+
}
|
|
1442
|
+
});
|
|
1443
|
+
const b = qt({
|
|
1444
|
+
updateItem: (_) => {
|
|
1445
|
+
p.value = p.value.map((n) => n.id !== _.id ? n : _), m("update:modelValue", w.value);
|
|
1446
|
+
},
|
|
1447
|
+
deleteItem: (_) => {
|
|
1448
|
+
p.value = p.value.filter((n) => n.id !== _.id), m("update:modelValue", w.value);
|
|
1449
|
+
},
|
|
1450
|
+
get items() {
|
|
1451
|
+
return p.value;
|
|
1452
|
+
},
|
|
1453
|
+
get disabled() {
|
|
1454
|
+
return v.disabled;
|
|
1455
|
+
}
|
|
1456
|
+
}), g = U(() => b.columnDefs.value), T = U(() => b.missingSKUs.value), w = U(() => {
|
|
1457
|
+
const _ = new Set(T.value.map((n) => n.id));
|
|
1458
|
+
return p.value.filter((n) => !_.has(n.id));
|
|
1459
|
+
});
|
|
1460
|
+
pe(
|
|
1461
|
+
() => w.value,
|
|
1462
|
+
(_, n) => {
|
|
1463
|
+
T.value.length > 0 && JSON.stringify(_) !== JSON.stringify(n) && m("update:modelValue", _);
|
|
1464
|
+
},
|
|
1465
|
+
{ immediate: !0 }
|
|
1466
|
+
);
|
|
1467
|
+
function k() {
|
|
1468
|
+
var $;
|
|
1469
|
+
const _ = o.skus.map((h) => {
|
|
1470
|
+
var S, D;
|
|
1471
|
+
return {
|
|
1472
|
+
type: "sku",
|
|
1473
|
+
name: h.name,
|
|
1474
|
+
description: h.code,
|
|
1475
|
+
data: h,
|
|
1476
|
+
searchKeys: (S = h.customAttributes) != null && S.tag ? [(D = h.customAttributes) == null ? void 0 : D.tag] : void 0
|
|
1477
|
+
};
|
|
1478
|
+
}), n = o.recipes.map((h) => {
|
|
1479
|
+
var S, D;
|
|
1480
|
+
return {
|
|
1481
|
+
type: "recipe",
|
|
1482
|
+
name: h.name,
|
|
1483
|
+
description: "",
|
|
1484
|
+
data: h,
|
|
1485
|
+
searchKeys: (S = h.customAttributes) != null && S.tag ? [(D = h.customAttributes) == null ? void 0 : D.tag] : void 0
|
|
1486
|
+
};
|
|
1487
|
+
}), a = (($ = o.menu.cache) == null ? void 0 : $.modules.item.map((h) => ({
|
|
1488
|
+
type: "menu",
|
|
1489
|
+
name: h.name,
|
|
1490
|
+
description: `${h.code}`,
|
|
1491
|
+
data: h
|
|
1492
|
+
}))) ?? [], d = [..._, ...n, ...a].map((h) => {
|
|
1493
|
+
var D;
|
|
1494
|
+
const S = [h.type == "sku" ? "Ingredient" : h.type == "recipe" ? "Recipe" : "Menu"];
|
|
1495
|
+
if (h.type == "sku" || h.type == "recipe") {
|
|
1496
|
+
const V = (D = h.data.customAttributes) == null ? void 0 : D.tag;
|
|
1497
|
+
V && S.push(V);
|
|
1498
|
+
}
|
|
1499
|
+
return {
|
|
1500
|
+
label: h.name,
|
|
1501
|
+
sublabel: h.description,
|
|
1502
|
+
value: h,
|
|
1503
|
+
tags: S,
|
|
1504
|
+
searchKeys: h.searchKeys
|
|
1505
|
+
};
|
|
1506
|
+
}), e = /* @__PURE__ */ new Set();
|
|
1507
|
+
d.forEach((h) => {
|
|
1508
|
+
h.tags && h.tags.forEach((S) => {
|
|
1509
|
+
e.add(S);
|
|
1510
|
+
});
|
|
1511
|
+
});
|
|
1512
|
+
const c = e.size > 0 ? [
|
|
1513
|
+
{
|
|
1514
|
+
type: "string",
|
|
1515
|
+
key: "tags",
|
|
1516
|
+
entity: "item",
|
|
1517
|
+
values: Array.from(e)
|
|
1518
|
+
}
|
|
1519
|
+
] : [], R = d.filter((h) => p.value.find((S) => S.id === h.value.data._id)).map((h) => h.value);
|
|
1520
|
+
t.open({
|
|
1521
|
+
title: r("inventory.closing.form.items.selectItem"),
|
|
1522
|
+
closeButton: !0,
|
|
1523
|
+
contentComponent: bt,
|
|
1524
|
+
contentComponentProps: {
|
|
1525
|
+
modelValue: R,
|
|
1526
|
+
items: d,
|
|
1527
|
+
virtualScroll: !0,
|
|
1528
|
+
filterAttributes: c
|
|
1529
|
+
},
|
|
1530
|
+
primaryActions: {
|
|
1531
|
+
text: r("common.confirm"),
|
|
1532
|
+
close: !0
|
|
1533
|
+
},
|
|
1534
|
+
secondaryActions: {
|
|
1535
|
+
text: r("common.close"),
|
|
1536
|
+
close: !0,
|
|
1537
|
+
variant: "tertiary"
|
|
1538
|
+
}
|
|
1539
|
+
}).onPrimary((h) => {
|
|
1540
|
+
const S = p.value ?? [], D = h.map((L) => {
|
|
1541
|
+
const V = S.find((ae) => ae.id === L.data._id);
|
|
1542
|
+
return V ? {
|
|
1543
|
+
...V
|
|
1544
|
+
} : {
|
|
1545
|
+
id: L.data._id,
|
|
1546
|
+
name: L.name,
|
|
1547
|
+
code: L.description,
|
|
1548
|
+
type: L.type,
|
|
1549
|
+
disabledMeasurements: []
|
|
1550
|
+
};
|
|
1551
|
+
});
|
|
1552
|
+
D.sort((L, V) => L.name.localeCompare(V.name)), console.log(p.value), p.value = D, m("update:modelValue", w.value);
|
|
1553
|
+
});
|
|
1554
|
+
}
|
|
1555
|
+
return (_, n) => {
|
|
1556
|
+
const a = E("FmButton"), d = E("FmIcon"), e = E("FmTextField"), c = E("FmTable"), R = E("FmFormGroup");
|
|
1557
|
+
return I(), A("div", Qt, [
|
|
1558
|
+
y("div", Xt, [
|
|
1559
|
+
y("div", Zt, F(x(r)("inventory.closing.form.items.title")), 1),
|
|
1560
|
+
C(a, {
|
|
1561
|
+
disabled: _.disabled,
|
|
1562
|
+
label: x(r)("inventory.closing.form.items.addItem"),
|
|
1563
|
+
"prepend-icon": "add",
|
|
1564
|
+
variant: "plain",
|
|
1565
|
+
class: "border-2 rounded-lg border-fm-color-primary",
|
|
1566
|
+
onClick: n[0] || (n[0] = ($) => k()),
|
|
1567
|
+
size: "md"
|
|
1568
|
+
}, null, 8, ["disabled", "label"])
|
|
1569
|
+
]),
|
|
1570
|
+
T.value.length > 0 ? (I(), A("div", en, [
|
|
1571
|
+
y("div", tn, [
|
|
1572
|
+
C(d, {
|
|
1573
|
+
name: "warning",
|
|
1574
|
+
size: "sm"
|
|
1575
|
+
}),
|
|
1576
|
+
n[3] || (n[3] = y("span", null, "Invalid items", -1))
|
|
1577
|
+
]),
|
|
1578
|
+
y("div", nn, [
|
|
1579
|
+
Z(" The following " + F(T.value.length) + " item(s) no longer exist in the system and have been excluded: ", 1),
|
|
1580
|
+
y("ul", sn, [
|
|
1581
|
+
(I(!0), A(K, null, X(T.value, ($) => (I(), A("li", {
|
|
1582
|
+
key: $.id
|
|
1583
|
+
}, "(" + F($.code) + ") " + F($.name), 1))), 128))
|
|
1584
|
+
])
|
|
1585
|
+
])
|
|
1586
|
+
])) : z("", !0),
|
|
1587
|
+
C(e, {
|
|
1588
|
+
placeholder: "Filter items",
|
|
1589
|
+
modelValue: u.value,
|
|
1590
|
+
"onUpdate:modelValue": n[2] || (n[2] = ($) => u.value = $)
|
|
1591
|
+
}, Ue({ _: 2 }, [
|
|
1592
|
+
u.value ? {
|
|
1593
|
+
name: "append",
|
|
1594
|
+
fn: j(() => [
|
|
1595
|
+
C(d, {
|
|
1596
|
+
name: "close",
|
|
1597
|
+
onClick: n[1] || (n[1] = ($) => u.value = ""),
|
|
1598
|
+
class: "cursor-pointer"
|
|
1599
|
+
})
|
|
1600
|
+
]),
|
|
1601
|
+
key: "0"
|
|
1602
|
+
} : void 0
|
|
1603
|
+
]), 1032, ["modelValue"]),
|
|
1604
|
+
(I(), O(c, {
|
|
1605
|
+
"search-value": u.value,
|
|
1606
|
+
"column-defs": g.value,
|
|
1607
|
+
"row-data": w.value,
|
|
1608
|
+
key: w.value.map(($) => $.id).join("."),
|
|
1609
|
+
"hide-footer": w.value.length <= 10,
|
|
1610
|
+
"page-size": Math.min(10, w.value.length)
|
|
1611
|
+
}, null, 8, ["search-value", "column-defs", "row-data", "hide-footer", "page-size"])),
|
|
1612
|
+
C(R, {
|
|
1613
|
+
"model-value": w.value.length,
|
|
1614
|
+
rules: [x(yt)(1)]
|
|
1615
|
+
}, null, 8, ["model-value", "rules"])
|
|
1616
|
+
]);
|
|
1617
|
+
};
|
|
1618
|
+
}
|
|
1619
|
+
}), an = { class: "flex flex-col gap-16" }, ln = { class: "flex flex-col gap-24" }, rn = { class: "flex flex-col gap-16" }, un = { class: "flex items-center" }, cn = { class: "flex-1 fm-typo-en-title-sm-600" }, mn = /* @__PURE__ */ G({
|
|
1620
|
+
__name: "WastageTemplateForm",
|
|
1621
|
+
props: {
|
|
1622
|
+
modelValue: {},
|
|
1623
|
+
disabled: { type: Boolean }
|
|
1624
|
+
},
|
|
1625
|
+
setup(f, { expose: l }) {
|
|
1626
|
+
const i = ht(), { t: v } = J(), {
|
|
1627
|
+
promptSelectLocations: p,
|
|
1628
|
+
columnDefs: r,
|
|
1629
|
+
rowData: m
|
|
1630
|
+
} = gt({
|
|
1631
|
+
getLocations() {
|
|
1632
|
+
return i.locations;
|
|
1633
|
+
},
|
|
1634
|
+
setLocations(t) {
|
|
1635
|
+
i.locations = t;
|
|
1636
|
+
}
|
|
1637
|
+
}), o = M();
|
|
1638
|
+
return l({
|
|
1639
|
+
validateInputs: () => {
|
|
1640
|
+
var t, s;
|
|
1641
|
+
(s = (t = o.value) == null ? void 0 : t.validateInputs) == null || s.call(t);
|
|
1642
|
+
},
|
|
1643
|
+
resetInputsValidation: () => {
|
|
1644
|
+
var t, s;
|
|
1645
|
+
(s = (t = o.value) == null ? void 0 : t.resetInputsValidation) == null || s.call(t);
|
|
1646
|
+
},
|
|
1647
|
+
resetInputs: () => {
|
|
1648
|
+
var t, s;
|
|
1649
|
+
(s = (t = o.value) == null ? void 0 : t.resetInputs) == null || s.call(t);
|
|
1650
|
+
}
|
|
1651
|
+
}), (t, s) => {
|
|
1652
|
+
const u = E("FmTextField"), b = E("FmButton"), g = E("FmTable"), T = E("FmForm");
|
|
1653
|
+
return I(), O(T, {
|
|
1654
|
+
ref_key: "formRef",
|
|
1655
|
+
ref: o,
|
|
1656
|
+
class: "flex flex-col gap-32",
|
|
1657
|
+
disabled: t.disabled
|
|
1658
|
+
}, {
|
|
1659
|
+
default: j(() => [
|
|
1660
|
+
y("div", an, [
|
|
1661
|
+
y("div", ln, [
|
|
1662
|
+
C(u, {
|
|
1663
|
+
label: x(v)("inventory.closing.form.name"),
|
|
1664
|
+
"label-mark": "required",
|
|
1665
|
+
modelValue: x(i).name,
|
|
1666
|
+
"onUpdate:modelValue": s[0] || (s[0] = (w) => x(i).name = w),
|
|
1667
|
+
rules: [x(Ge)()]
|
|
1668
|
+
}, null, 8, ["label", "modelValue", "rules"])
|
|
1669
|
+
])
|
|
1670
|
+
]),
|
|
1671
|
+
y("div", rn, [
|
|
1672
|
+
y("div", un, [
|
|
1673
|
+
y("div", cn, F(x(v)("inventory.closing.form.locations")), 1),
|
|
1674
|
+
C(b, {
|
|
1675
|
+
disabled: t.disabled,
|
|
1676
|
+
label: x(v)("inventory.closing.form.selectLocation"),
|
|
1677
|
+
"prepend-icon": "add",
|
|
1678
|
+
variant: "plain",
|
|
1679
|
+
class: "border-2 rounded-lg border-fm-color-primary",
|
|
1680
|
+
onClick: x(p)
|
|
1681
|
+
}, null, 8, ["disabled", "label", "onClick"])
|
|
1682
|
+
]),
|
|
1683
|
+
C(g, {
|
|
1684
|
+
"column-defs": x(r),
|
|
1685
|
+
"row-data": x(m),
|
|
1686
|
+
"shrink-at": 9999,
|
|
1687
|
+
onRowClick: x(p),
|
|
1688
|
+
"hide-footer": ""
|
|
1689
|
+
}, null, 8, ["column-defs", "row-data", "onRowClick"])
|
|
1690
|
+
]),
|
|
1691
|
+
C(on, {
|
|
1692
|
+
"model-value": x(i).items,
|
|
1693
|
+
"onUpdate:modelValue": s[1] || (s[1] = (w) => x(i).items = w)
|
|
1694
|
+
}, null, 8, ["model-value"])
|
|
1695
|
+
]),
|
|
1696
|
+
_: 1
|
|
1697
|
+
}, 8, ["disabled"]);
|
|
1698
|
+
};
|
|
1699
|
+
}
|
|
1700
|
+
}), dn = { class: "flex items-center" }, pn = { class: "fm-typo-en-title-md-600" }, fn = { class: "flex justify-between" }, vn = { class: "fm-typo-en-body-lg-600" }, yn = { class: "flex flex-col gap-8" }, hn = { class: "flex flex-col gap-4" }, gn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, bn = { class: "flex items-center gap-8" }, _n = { class: "fm-typo-en-body-lg-600" }, xn = { class: "flex gap-4" }, wn = /* @__PURE__ */ G({
|
|
1701
|
+
__name: "WastageTemplateDialog",
|
|
1702
|
+
props: {
|
|
1703
|
+
mode: {},
|
|
1704
|
+
modelValue: {},
|
|
1705
|
+
show: { type: Boolean }
|
|
1706
|
+
},
|
|
1707
|
+
emits: ["update:show", "submitted"],
|
|
1708
|
+
setup(f, { expose: l, emit: i }) {
|
|
1709
|
+
var d;
|
|
1710
|
+
const v = f, p = i, r = se(), m = te(), { t: o } = J(), t = Be(v, "show");
|
|
1711
|
+
function s() {
|
|
1712
|
+
return {
|
|
1713
|
+
_id: "",
|
|
1714
|
+
name: "",
|
|
1715
|
+
type: fe.Enum.WASTAGE,
|
|
1716
|
+
items: []
|
|
1717
|
+
};
|
|
1718
|
+
}
|
|
1719
|
+
const u = M(v.modelValue ?? s()), b = M(((d = v.modelValue) == null ? void 0 : d._id) ?? `${Math.random()}`);
|
|
1720
|
+
pe(
|
|
1721
|
+
() => v.show,
|
|
1722
|
+
(e) => {
|
|
1723
|
+
var c;
|
|
1724
|
+
e && (u.value = v.modelValue ?? s(), b.value = ((c = v.modelValue) == null ? void 0 : c._id) ?? `${Math.random()}`);
|
|
1725
|
+
}
|
|
1726
|
+
);
|
|
1727
|
+
const g = M(!1), T = U(() => {
|
|
1728
|
+
switch (v.mode) {
|
|
1729
|
+
case q.READ:
|
|
1730
|
+
return "";
|
|
1731
|
+
case q.CREATE:
|
|
1732
|
+
return o("inventory.adjustment.template.create.title");
|
|
1733
|
+
case q.UPDATE:
|
|
1734
|
+
return o("inventory.adjustment.template.update.title");
|
|
1735
|
+
}
|
|
1736
|
+
return "";
|
|
1737
|
+
}), w = M();
|
|
1738
|
+
l({
|
|
1739
|
+
validateInputs: () => {
|
|
1740
|
+
var e, c;
|
|
1741
|
+
(c = (e = w.value) == null ? void 0 : e.validateInputs) == null || c.call(e);
|
|
1742
|
+
},
|
|
1743
|
+
resetInputsValidation: () => {
|
|
1744
|
+
var e, c;
|
|
1745
|
+
(c = (e = w.value) == null ? void 0 : e.resetInputsValidation) == null || c.call(e);
|
|
1746
|
+
},
|
|
1747
|
+
resetInputs: () => {
|
|
1748
|
+
var e, c;
|
|
1749
|
+
(c = (e = w.value) == null ? void 0 : e.resetInputs) == null || c.call(e);
|
|
1750
|
+
}
|
|
1751
|
+
});
|
|
1752
|
+
async function k() {
|
|
1753
|
+
const e = u.value;
|
|
1754
|
+
if (e) {
|
|
1755
|
+
g.value = !0;
|
|
1756
|
+
try {
|
|
1757
|
+
await r.createTemplate(e), await new Promise((c) => setTimeout(c, 1e3)), m.open({
|
|
1758
|
+
title: o("inventory.adjustment.template.create.success"),
|
|
1759
|
+
message: o("inventory.adjustment.template.create.successMessage"),
|
|
1760
|
+
type: "success"
|
|
1761
|
+
}), p("update:show", !1), p("submitted");
|
|
1762
|
+
} catch (c) {
|
|
1763
|
+
m.open({
|
|
1764
|
+
title: o("inventory.adjustment.template.create.error"),
|
|
1765
|
+
message: o("inventory.adjustment.template.create.errorMessage"),
|
|
1766
|
+
type: "error"
|
|
1767
|
+
}), console.error("Error in creating adjustment template", c);
|
|
1768
|
+
} finally {
|
|
1769
|
+
g.value = !1;
|
|
1770
|
+
}
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
async function _() {
|
|
1774
|
+
const e = u.value;
|
|
1775
|
+
if (e) {
|
|
1776
|
+
g.value = !0;
|
|
1777
|
+
try {
|
|
1778
|
+
await r.updateTemplate({
|
|
1779
|
+
...e,
|
|
1780
|
+
_rev: e._rev ?? ""
|
|
1781
|
+
}), await new Promise((c) => setTimeout(c, 1e3)), m.open({
|
|
1782
|
+
title: o("inventory.adjustment.template.update.success"),
|
|
1783
|
+
message: o("inventory.adjustment.template.update.successMessage"),
|
|
1784
|
+
type: "success"
|
|
1785
|
+
}), p("update:show", !1), p("submitted");
|
|
1786
|
+
} catch (c) {
|
|
1787
|
+
m.open({
|
|
1788
|
+
title: o("inventory.adjustment.template.update.error"),
|
|
1789
|
+
message: o("inventory.adjustment.template.update.errorMessage"),
|
|
1790
|
+
type: "error"
|
|
1791
|
+
}), console.error("Error in updating adjustment template", c);
|
|
1792
|
+
} finally {
|
|
1793
|
+
g.value = !1;
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
}
|
|
1797
|
+
function n() {
|
|
1798
|
+
switch (v.mode) {
|
|
1799
|
+
case q.CREATE:
|
|
1800
|
+
return k();
|
|
1801
|
+
case q.UPDATE:
|
|
1802
|
+
return _();
|
|
1803
|
+
}
|
|
1804
|
+
}
|
|
1805
|
+
function a() {
|
|
1806
|
+
var e, c;
|
|
1807
|
+
(c = (e = w.value) == null ? void 0 : e.validateInputs) == null || c.call(e);
|
|
1808
|
+
}
|
|
1809
|
+
return (e, c) => {
|
|
1810
|
+
const R = E("FmMenuDivider"), $ = E("FmCard"), h = E("FmButton"), S = E("FmSideSheet");
|
|
1811
|
+
return I(), O(S, {
|
|
1812
|
+
modelValue: x(t),
|
|
1813
|
+
"onUpdate:modelValue": c[2] || (c[2] = (D) => Le(t) ? t.value = D : null),
|
|
1814
|
+
"dismiss-away": "",
|
|
1815
|
+
"close-button": "",
|
|
1816
|
+
"max-width": 800
|
|
1817
|
+
}, {
|
|
1818
|
+
"side-sheet-header": j(() => [
|
|
1819
|
+
y("div", dn, [
|
|
1820
|
+
y("div", pn, F(T.value), 1)
|
|
1821
|
+
])
|
|
1822
|
+
]),
|
|
1823
|
+
default: j(() => [
|
|
1824
|
+
u.value.updatedAt ? (I(), A(K, { key: 0 }, [
|
|
1825
|
+
u.value.updatedAt ? (I(), O($, {
|
|
1826
|
+
key: 0,
|
|
1827
|
+
variant: "outlined",
|
|
1828
|
+
class: "flex flex-col gap-8 px-12 py-16 mb-16"
|
|
1829
|
+
}, {
|
|
1830
|
+
default: j(() => {
|
|
1831
|
+
var D;
|
|
1832
|
+
return [
|
|
1833
|
+
y("div", fn, [
|
|
1834
|
+
y("div", vn, F(x(o)("inventory.transfer.template.details.templateSummary")), 1)
|
|
1835
|
+
]),
|
|
1836
|
+
C(R),
|
|
1837
|
+
y("div", yn, [
|
|
1838
|
+
y("div", hn, [
|
|
1839
|
+
y("div", gn, F(x(o)("inventory.transfer.receiveRequest.details.updatedAt")), 1),
|
|
1840
|
+
y("div", bn, [
|
|
1841
|
+
y("div", _n, [
|
|
1842
|
+
Z(F(x(de)(u.value.updatedAt)) + " ", 1),
|
|
1843
|
+
(D = u.value.updatedBy) != null && D.name ? (I(), A(K, { key: 0 }, [
|
|
1844
|
+
Z(" (" + F(u.value.updatedBy.name) + ") ", 1)
|
|
1845
|
+
], 64)) : z("", !0)
|
|
1846
|
+
]),
|
|
1847
|
+
C(_t, {
|
|
1848
|
+
"adjustment-id": u.value._id
|
|
1849
|
+
}, null, 8, ["adjustment-id"])
|
|
1850
|
+
])
|
|
1851
|
+
])
|
|
1852
|
+
])
|
|
1853
|
+
];
|
|
1854
|
+
}),
|
|
1855
|
+
_: 1
|
|
1856
|
+
})) : z("", !0)
|
|
1857
|
+
], 64)) : z("", !0),
|
|
1858
|
+
(I(), O(mn, {
|
|
1859
|
+
class: "w-full",
|
|
1860
|
+
ref_key: "formRef",
|
|
1861
|
+
ref: w,
|
|
1862
|
+
onValidationSuccess: n,
|
|
1863
|
+
"model-value": u.value,
|
|
1864
|
+
"onUpdate:modelValue": c[0] || (c[0] = (D) => u.value = D),
|
|
1865
|
+
disabled: g.value,
|
|
1866
|
+
key: b.value
|
|
1867
|
+
}, null, 8, ["model-value", "disabled"]))
|
|
1868
|
+
]),
|
|
1869
|
+
"side-sheet-footer": j(() => [
|
|
1870
|
+
y("div", xn, [
|
|
1871
|
+
C(h, {
|
|
1872
|
+
loading: g.value,
|
|
1873
|
+
label: x(o)("common.save"),
|
|
1874
|
+
onClick: a
|
|
1875
|
+
}, null, 8, ["loading", "label"]),
|
|
1876
|
+
C(h, {
|
|
1877
|
+
disabled: g.value,
|
|
1878
|
+
variant: "tertiary",
|
|
1879
|
+
label: x(o)("common.close"),
|
|
1880
|
+
onClick: c[1] || (c[1] = (D) => p("update:show", !1))
|
|
1881
|
+
}, null, 8, ["disabled", "label"])
|
|
1882
|
+
])
|
|
1883
|
+
]),
|
|
1884
|
+
_: 1
|
|
1885
|
+
}, 8, ["modelValue"]);
|
|
1886
|
+
};
|
|
1887
|
+
}
|
|
1888
|
+
}), Tn = {};
|
|
1889
|
+
function kn(f, l) {
|
|
1890
|
+
return I(), A("div");
|
|
1891
|
+
}
|
|
1892
|
+
const $n = /* @__PURE__ */ xt(Tn, [["render", kn]]), Sn = { class: "flex flex-col gap-40" }, In = { key: 0 }, Cn = {
|
|
1893
|
+
key: 1,
|
|
1894
|
+
class: "flex gap-8 items-center"
|
|
1895
|
+
}, Fn = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary" }, An = {
|
|
1896
|
+
key: 2,
|
|
1897
|
+
class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary"
|
|
1898
|
+
}, Rn = {
|
|
1899
|
+
key: 3,
|
|
1900
|
+
class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary flex flex-col gap-12"
|
|
1901
|
+
}, Dn = { class: "fm-typo-en-body-md-600" }, Mn = { class: "fm-typo-en-body-md-600" }, En = { key: 4 }, Pn = { class: "fm-typo-en-body-md-600" }, jn = { class: "fm-typo-en-body-md-600" }, Vn = { class: "flex sm:flex-col xs:flex-col justify-end gap-8 w-full mb-16" }, Un = /* @__PURE__ */ G({
|
|
1902
|
+
__name: "WastageTemplatePublish",
|
|
1903
|
+
emits: ["close"],
|
|
1904
|
+
setup(f, { emit: l }) {
|
|
1905
|
+
const i = M(!1), v = te(), p = se(), r = oe(), { t: m } = J(), o = l;
|
|
1906
|
+
async function t() {
|
|
1907
|
+
i.value = !0;
|
|
1908
|
+
try {
|
|
1909
|
+
await p.startNewPublish().delayed(1e3), v.open({
|
|
1910
|
+
title: "Success",
|
|
1911
|
+
message: "You may refresh after a while to review publish status",
|
|
1912
|
+
type: "success"
|
|
1913
|
+
}), b();
|
|
1914
|
+
} catch (g) {
|
|
1915
|
+
v.open({
|
|
1916
|
+
title: "Something went wrong",
|
|
1917
|
+
message: "Please try again",
|
|
1918
|
+
type: "error"
|
|
1919
|
+
}), console.error("error on creating publish task", g);
|
|
1920
|
+
} finally {
|
|
1921
|
+
i.value = !1;
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1924
|
+
const s = U(() => r.recentPublish.recentJob), u = U(
|
|
1925
|
+
() => r.templates.length && (!s.value || s.value.outlets.length === s.value.completed.length)
|
|
1926
|
+
);
|
|
1927
|
+
function b() {
|
|
1928
|
+
o("close");
|
|
1929
|
+
}
|
|
1930
|
+
return (g, T) => {
|
|
1931
|
+
const w = E("FmCircularProgress"), k = E("i18n-t"), _ = E("FmButton");
|
|
1932
|
+
return I(), A("div", Sn, [
|
|
1933
|
+
x(r).templates.length ? i.value ? (I(), A("div", Cn, [
|
|
1934
|
+
y("div", null, [
|
|
1935
|
+
C(w, {
|
|
1936
|
+
size: "md",
|
|
1937
|
+
color: "neutral-gray-300"
|
|
1938
|
+
})
|
|
1939
|
+
]),
|
|
1940
|
+
y("div", Fn, [
|
|
1941
|
+
y("span", null, F(x(m)("inventory.adjustment.template.publish.publishing")), 1)
|
|
1942
|
+
])
|
|
1943
|
+
])) : s.value ? s.value.outlets.length === s.value.completed.length ? (I(), A("div", Rn, [
|
|
1944
|
+
C(k, {
|
|
1945
|
+
keypath: "inventory.adjustment.template.publish.recentlyPublishedAt",
|
|
1946
|
+
tag: "p"
|
|
1947
|
+
}, {
|
|
1948
|
+
started: j(() => [
|
|
1949
|
+
y("span", Dn, F(x(de)(new Date(s.value.createdAt))), 1)
|
|
1950
|
+
]),
|
|
1951
|
+
finished: j(() => [
|
|
1952
|
+
y("span", Mn, F(x(de)(new Date(s.value.updatedAt))), 1)
|
|
1953
|
+
]),
|
|
1954
|
+
_: 1
|
|
1955
|
+
}),
|
|
1956
|
+
y("p", null, F(x(m)("inventory.adjustment.template.publish.message")), 1)
|
|
1957
|
+
])) : (I(), A("div", En, [
|
|
1958
|
+
C(k, {
|
|
1959
|
+
keypath: "inventory.adjustment.template.publish.stillPublishing",
|
|
1960
|
+
tag: "p"
|
|
1961
|
+
}, {
|
|
1962
|
+
started: j(() => [
|
|
1963
|
+
y("span", Pn, F(x(de)(new Date(s.value.createdAt))), 1)
|
|
1964
|
+
]),
|
|
1965
|
+
progress: j(() => [
|
|
1966
|
+
y("span", jn, " (" + F(s.value.completed.length) + "/" + F(s.value.outlets.length) + " completed) ", 1)
|
|
1967
|
+
]),
|
|
1968
|
+
_: 1
|
|
1969
|
+
}),
|
|
1970
|
+
Z(" Your recent publishing task is still pending (" + F(s.value.completed.length) + " / " + F(s.value.outlets.length) + "). Please wait until all publishing task has completed. ", 1)
|
|
1971
|
+
])) : (I(), A("div", An, [
|
|
1972
|
+
y("p", null, F(x(m)("inventory.adjustment.template.publish.noRecentActivity")), 1),
|
|
1973
|
+
y("p", null, F(x(m)("inventory.adjustment.template.publish.message")), 1)
|
|
1974
|
+
])) : (I(), A("div", In, [
|
|
1975
|
+
y("p", null, F(x(m)("inventory.adjustment.template.publish.nothingToPublish")), 1)
|
|
1976
|
+
])),
|
|
1977
|
+
y("div", Vn, [
|
|
1978
|
+
C(_, {
|
|
1979
|
+
disabled: !u.value,
|
|
1980
|
+
loading: i.value,
|
|
1981
|
+
label: "Publish to all outlets",
|
|
1982
|
+
onClick: t
|
|
1983
|
+
}, null, 8, ["disabled", "loading"]),
|
|
1984
|
+
C(_, {
|
|
1985
|
+
variant: "tertiary",
|
|
1986
|
+
label: "Close",
|
|
1987
|
+
onClick: b
|
|
1988
|
+
})
|
|
1989
|
+
])
|
|
1990
|
+
]);
|
|
1991
|
+
};
|
|
1992
|
+
}
|
|
1993
|
+
}), Ln = { class: "flex flex-col gap-16" }, Nn = { class: "flex" }, Bn = { class: "flex gap-24" }, zn = { class: "flex" }, On = { class: "flex-1" }, Wn = { class: "flex" }, Hn = { class: "flex gap-8 items-center justify-start" }, Kn = /* @__PURE__ */ G({
|
|
1994
|
+
__name: "WastageTemplateReason",
|
|
1995
|
+
props: {
|
|
1996
|
+
show: { type: Boolean }
|
|
1997
|
+
},
|
|
1998
|
+
emits: ["update:show", "submitted"],
|
|
1999
|
+
setup(f, { emit: l }) {
|
|
2000
|
+
const i = f, v = Be(i, "show"), p = M(""), r = te(), m = ee(), o = M([]), t = l, s = oe(), u = se(), b = M(!1);
|
|
2001
|
+
pe(
|
|
2002
|
+
() => i.show,
|
|
2003
|
+
(n) => {
|
|
2004
|
+
var a;
|
|
2005
|
+
n && (o.value = ((a = s.reasons) == null ? void 0 : a.value) ?? []);
|
|
2006
|
+
}
|
|
2007
|
+
);
|
|
2008
|
+
const g = (n) => {
|
|
2009
|
+
if (o.value.indexOf(o.value[n]) === -1)
|
|
2010
|
+
return;
|
|
2011
|
+
const a = o.value[n];
|
|
2012
|
+
if (a.trim() === "") {
|
|
2013
|
+
o.value.splice(n, 1);
|
|
2014
|
+
return;
|
|
2015
|
+
}
|
|
2016
|
+
m.open({
|
|
2017
|
+
title: "Delete reason",
|
|
2018
|
+
message: `Are you sure you want to delete this reason? "${a}"`,
|
|
2019
|
+
primaryActions: {
|
|
2020
|
+
text: "Delete",
|
|
2021
|
+
close: !0,
|
|
2022
|
+
variant: "destructive"
|
|
2023
|
+
},
|
|
2024
|
+
secondaryActions: {
|
|
2025
|
+
text: "Cancel",
|
|
2026
|
+
close: !0,
|
|
2027
|
+
variant: "secondary"
|
|
2028
|
+
}
|
|
2029
|
+
}).onPrimary(() => {
|
|
2030
|
+
o.value.splice(n, 1);
|
|
2031
|
+
});
|
|
2032
|
+
}, T = () => {
|
|
2033
|
+
o.value.push("");
|
|
2034
|
+
const n = p.value.trim();
|
|
2035
|
+
if (n) {
|
|
2036
|
+
if (o.value.some((a) => a === n)) {
|
|
2037
|
+
r.open({
|
|
2038
|
+
title: "Reason already exists",
|
|
2039
|
+
message: "Please enter a different reason",
|
|
2040
|
+
type: "error"
|
|
2041
|
+
});
|
|
2042
|
+
return;
|
|
2043
|
+
}
|
|
2044
|
+
p.value = "";
|
|
2045
|
+
}
|
|
2046
|
+
}, w = async () => {
|
|
2047
|
+
const n = o.value.map((a) => a.trim()).filter((a) => a);
|
|
2048
|
+
if (s.reasons) {
|
|
2049
|
+
b.value = !0;
|
|
2050
|
+
try {
|
|
2051
|
+
await u.update({
|
|
2052
|
+
_id: s.reasons._id,
|
|
2053
|
+
_rev: s.reasons._rev,
|
|
2054
|
+
value: n
|
|
2055
|
+
}), r.open({
|
|
2056
|
+
title: "Reasons updated",
|
|
2057
|
+
message: "Reasons have been updated successfully",
|
|
2058
|
+
type: "success"
|
|
2059
|
+
}), t("update:show", !1), t("submitted");
|
|
2060
|
+
} catch {
|
|
2061
|
+
r.open({
|
|
2062
|
+
title: "Error updating reasons",
|
|
2063
|
+
message: "There was an error updating reasons",
|
|
2064
|
+
type: "error"
|
|
2065
|
+
});
|
|
2066
|
+
} finally {
|
|
2067
|
+
b.value = !1;
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2070
|
+
}, k = M(), _ = () => {
|
|
2071
|
+
var n, a;
|
|
2072
|
+
(a = (n = k.value) == null ? void 0 : n.validateInputs) == null || a.call(n);
|
|
2073
|
+
};
|
|
2074
|
+
return (n, a) => {
|
|
2075
|
+
const d = E("FmButton"), e = E("FmAvatar"), c = E("FmTextField"), R = E("FmList"), $ = E("FmForm"), h = E("FmSideSheet");
|
|
2076
|
+
return I(), O(h, {
|
|
2077
|
+
modelValue: x(v),
|
|
2078
|
+
"onUpdate:modelValue": a[0] || (a[0] = (S) => Le(v) ? v.value = S : null),
|
|
2079
|
+
header: "Reason for wastage",
|
|
2080
|
+
"close-button": "",
|
|
2081
|
+
"dismiss-away": !b.value,
|
|
2082
|
+
"max-width": 500
|
|
2083
|
+
}, {
|
|
2084
|
+
default: j(() => [
|
|
2085
|
+
C($, {
|
|
2086
|
+
ref_key: "formRef",
|
|
2087
|
+
ref: k,
|
|
2088
|
+
class: "flex flex-col gap-32",
|
|
2089
|
+
blameFormChildOnValidationFailed: "",
|
|
2090
|
+
onValidationSuccess: w
|
|
2091
|
+
}, {
|
|
2092
|
+
default: j(() => [
|
|
2093
|
+
y("div", Ln, [
|
|
2094
|
+
y("div", Nn, [
|
|
2095
|
+
C(d, {
|
|
2096
|
+
class: "ml-auto px-5",
|
|
2097
|
+
variant: "primary",
|
|
2098
|
+
label: "Add new reason",
|
|
2099
|
+
size: "md",
|
|
2100
|
+
onClick: T
|
|
2101
|
+
})
|
|
2102
|
+
])
|
|
2103
|
+
]),
|
|
2104
|
+
y("div", Bn, [
|
|
2105
|
+
C(R, {
|
|
2106
|
+
class: "w-full",
|
|
2107
|
+
separator: ""
|
|
2108
|
+
}, {
|
|
2109
|
+
default: j(() => [
|
|
2110
|
+
(I(!0), A(K, null, X(o.value, (S, D) => (I(), A("div", {
|
|
2111
|
+
key: D,
|
|
2112
|
+
class: "flex items-center gap-8 px-1 py-2"
|
|
2113
|
+
}, [
|
|
2114
|
+
y("div", zn, [
|
|
2115
|
+
C(e, {
|
|
2116
|
+
initials: String(D + 1),
|
|
2117
|
+
size: "sm"
|
|
2118
|
+
}, null, 8, ["initials"])
|
|
2119
|
+
]),
|
|
2120
|
+
y("div", On, [
|
|
2121
|
+
C(c, {
|
|
2122
|
+
class: "cursor-pointer text-fm-color-typo-tertiary",
|
|
2123
|
+
modelValue: o.value[D],
|
|
2124
|
+
"onUpdate:modelValue": (L) => o.value[D] = L,
|
|
2125
|
+
maxLength: 500,
|
|
2126
|
+
rules: [x(Ge)()]
|
|
2127
|
+
}, null, 8, ["modelValue", "onUpdate:modelValue", "rules"])
|
|
2128
|
+
]),
|
|
2129
|
+
y("div", Wn, [
|
|
2130
|
+
C(d, {
|
|
2131
|
+
variant: "tertiary",
|
|
2132
|
+
size: "md",
|
|
2133
|
+
"prepend-icon": "delete",
|
|
2134
|
+
onClick: (L) => g(D)
|
|
2135
|
+
}, null, 8, ["onClick"])
|
|
2136
|
+
])
|
|
2137
|
+
]))), 128))
|
|
2138
|
+
]),
|
|
2139
|
+
_: 1
|
|
2140
|
+
})
|
|
2141
|
+
])
|
|
2142
|
+
]),
|
|
2143
|
+
_: 1
|
|
2144
|
+
}, 512)
|
|
2145
|
+
]),
|
|
2146
|
+
"side-sheet-footer": j(() => [
|
|
2147
|
+
y("div", Hn, [
|
|
2148
|
+
C(d, {
|
|
2149
|
+
variant: "primary",
|
|
2150
|
+
label: "Save",
|
|
2151
|
+
size: "lg",
|
|
2152
|
+
onClick: _,
|
|
2153
|
+
disabled: b.value,
|
|
2154
|
+
loading: b.value
|
|
2155
|
+
}, null, 8, ["disabled", "loading"]),
|
|
2156
|
+
C(d, {
|
|
2157
|
+
variant: "secondary",
|
|
2158
|
+
label: "Close",
|
|
2159
|
+
size: "lg"
|
|
2160
|
+
})
|
|
2161
|
+
])
|
|
2162
|
+
]),
|
|
2163
|
+
_: 1
|
|
2164
|
+
}, 8, ["modelValue", "dismiss-away"]);
|
|
2165
|
+
};
|
|
2166
|
+
}
|
|
2167
|
+
}), Yn = { class: "flex items-center gap-5" }, Gn = { class: "flex items-center gap-2" }, Jn = { class: "flex-1 flex flex-col gap-8" }, qn = { class: "flex flex-col" }, Qn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Xn = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Zn = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, $s = /* @__PURE__ */ G({
|
|
2168
|
+
__name: "WastageTemplateView",
|
|
2169
|
+
setup(f) {
|
|
2170
|
+
const { t: l } = J(), { createTemplate: i, updateTemplate: v, exportTemplates: p, importTemplates: r, viewReason: m } = ye(), { templateDialogProps: o, templateDetailsProps: t, templateReasonProps: s } = Oe(
|
|
2171
|
+
ye()
|
|
2172
|
+
), u = he(), b = ee(), g = oe(), T = tt(), { breakpoints: w } = at();
|
|
2173
|
+
u.watchLocation(g.fetchTemplates);
|
|
2174
|
+
const k = U(() => g.loading), _ = M(""), n = U(() => w.value.xs || w.value.sm), a = U(() => n.value ? 10 : 20);
|
|
2175
|
+
function d(h) {
|
|
2176
|
+
switch (h) {
|
|
2177
|
+
case B.Add:
|
|
2178
|
+
return i();
|
|
2179
|
+
case "publish":
|
|
2180
|
+
return e();
|
|
2181
|
+
case "import":
|
|
2182
|
+
return r();
|
|
2183
|
+
case "export":
|
|
2184
|
+
return p();
|
|
2185
|
+
case "refresh":
|
|
2186
|
+
return g.fetchTemplates();
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
function e() {
|
|
2190
|
+
b.open({
|
|
2191
|
+
title: "Publish wastage templates",
|
|
2192
|
+
contentComponent: Un,
|
|
2193
|
+
contentComponentProps: {
|
|
2194
|
+
onClose() {
|
|
2195
|
+
b.close();
|
|
2196
|
+
}
|
|
2197
|
+
}
|
|
2198
|
+
});
|
|
2199
|
+
}
|
|
2200
|
+
function c(h) {
|
|
2201
|
+
return h;
|
|
2202
|
+
}
|
|
2203
|
+
const R = U(() => n.value ? [
|
|
2204
|
+
{
|
|
2205
|
+
label: l("inventory.adjustment.template.create.title"),
|
|
2206
|
+
value: B.Add,
|
|
2207
|
+
isPrimary: !0,
|
|
2208
|
+
prependIcon: "add"
|
|
2209
|
+
},
|
|
2210
|
+
{
|
|
2211
|
+
label: l("inventory.common.refresh"),
|
|
2212
|
+
value: "refresh",
|
|
2213
|
+
isPrimary: !1
|
|
2214
|
+
},
|
|
2215
|
+
{
|
|
2216
|
+
label: l("inventory.common.publish"),
|
|
2217
|
+
value: "publish",
|
|
2218
|
+
isPrimary: !1
|
|
2219
|
+
},
|
|
2220
|
+
{
|
|
2221
|
+
label: l("inventory.common.import"),
|
|
2222
|
+
value: "import",
|
|
2223
|
+
isPrimary: !1
|
|
2224
|
+
},
|
|
2225
|
+
{
|
|
2226
|
+
label: l("inventory.common.export"),
|
|
2227
|
+
value: "export",
|
|
2228
|
+
isPrimary: !1
|
|
2229
|
+
}
|
|
2230
|
+
] : [
|
|
2231
|
+
{
|
|
2232
|
+
label: l("inventory.adjustment.template.create.title"),
|
|
2233
|
+
value: B.Add,
|
|
2234
|
+
isPrimary: !0,
|
|
2235
|
+
prependIcon: "add"
|
|
2236
|
+
},
|
|
2237
|
+
{
|
|
2238
|
+
label: l("inventory.common.publish"),
|
|
2239
|
+
value: "publish",
|
|
2240
|
+
isPrimary: !1
|
|
2241
|
+
},
|
|
2242
|
+
{
|
|
2243
|
+
label: l("inventory.common.import"),
|
|
2244
|
+
value: "import",
|
|
2245
|
+
isPrimary: !1
|
|
2246
|
+
},
|
|
2247
|
+
{
|
|
2248
|
+
label: l("inventory.common.refresh"),
|
|
2249
|
+
value: "refresh",
|
|
2250
|
+
isPrimary: !1
|
|
2251
|
+
},
|
|
2252
|
+
{
|
|
2253
|
+
label: l("inventory.common.export"),
|
|
2254
|
+
value: "export",
|
|
2255
|
+
isPrimary: !1
|
|
2256
|
+
}
|
|
2257
|
+
]), $ = () => {
|
|
2258
|
+
m();
|
|
2259
|
+
};
|
|
2260
|
+
return (h, S) => {
|
|
2261
|
+
const D = E("FmButton"), L = E("FmTable");
|
|
2262
|
+
return I(), A(K, null, [
|
|
2263
|
+
C(nt, {
|
|
2264
|
+
title: x(l)("inventory.adjustment.template.wastage.title"),
|
|
2265
|
+
actions: R.value,
|
|
2266
|
+
"onClick:action": d
|
|
2267
|
+
}, {
|
|
2268
|
+
default: j(() => [
|
|
2269
|
+
y("div", {
|
|
2270
|
+
class: Y([
|
|
2271
|
+
"flex flex-col gap-8 max-h-full",
|
|
2272
|
+
{
|
|
2273
|
+
"p-0": n.value,
|
|
2274
|
+
"px-24 ": !n.value
|
|
2275
|
+
}
|
|
2276
|
+
])
|
|
2277
|
+
}, [
|
|
2278
|
+
y("div", Yn, [
|
|
2279
|
+
C(D, {
|
|
2280
|
+
class: "ml-auto",
|
|
2281
|
+
"prepend-icon": "edit",
|
|
2282
|
+
key: "Reason for wastage",
|
|
2283
|
+
label: "Default label",
|
|
2284
|
+
"bg-color": "neutral-gray-100",
|
|
2285
|
+
"text-color": "neutral-gray-400",
|
|
2286
|
+
onClick: $
|
|
2287
|
+
}, {
|
|
2288
|
+
default: j(() => [
|
|
2289
|
+
y("div", Gn, [
|
|
2290
|
+
S[4] || (S[4] = y("span", null, "Reasons", -1)),
|
|
2291
|
+
y("div", {
|
|
2292
|
+
class: Y([
|
|
2293
|
+
"fm-status-badge",
|
|
2294
|
+
x(g).isReasonPublished() ? "fm-status-badge-success-secondary" : "fm-status-badge-info-secondary"
|
|
2295
|
+
])
|
|
2296
|
+
}, F(x(g).isReasonPublished() ? "Published" : "Unpublished"), 3)
|
|
2297
|
+
])
|
|
2298
|
+
]),
|
|
2299
|
+
_: 1
|
|
2300
|
+
}),
|
|
2301
|
+
C(st, {
|
|
2302
|
+
class: "flex-1",
|
|
2303
|
+
searchable: "",
|
|
2304
|
+
search: _.value,
|
|
2305
|
+
"onUpdate:search": S[0] || (S[0] = (V) => _.value = V)
|
|
2306
|
+
}, null, 8, ["search"])
|
|
2307
|
+
]),
|
|
2308
|
+
C(L, {
|
|
2309
|
+
style: Qe(x(T).tableHeight),
|
|
2310
|
+
"column-defs": x(g).columnDefs,
|
|
2311
|
+
"row-data": x(g).templates,
|
|
2312
|
+
"search-value": _.value,
|
|
2313
|
+
loading: k.value,
|
|
2314
|
+
onRowClick: S[1] || (S[1] = (V) => x(v)(V.original)),
|
|
2315
|
+
"page-size": a.value
|
|
2316
|
+
}, {
|
|
2317
|
+
"list-row": j((V) => [
|
|
2318
|
+
C(lt, {
|
|
2319
|
+
row: V,
|
|
2320
|
+
onRowClick: (W) => x(v)(W)
|
|
2321
|
+
}, {
|
|
2322
|
+
default: j((W) => {
|
|
2323
|
+
var ae, be, _e, le, xe, we, Te, ke, re, $e, Se, Ie, Ce, Fe, Ae, ie, Re, De, Me, Ee, ue, Pe;
|
|
2324
|
+
return [
|
|
2325
|
+
y("div", Jn, [
|
|
2326
|
+
y("div", qn, [
|
|
2327
|
+
y("div", Qn, [
|
|
2328
|
+
C(x(me), {
|
|
2329
|
+
render: (_e = (be = (ae = W._id) == null ? void 0 : ae.column) == null ? void 0 : be.columnDef) == null ? void 0 : _e.cell,
|
|
2330
|
+
props: (xe = (le = W._id) == null ? void 0 : le.getContext) == null ? void 0 : xe.call(le)
|
|
2331
|
+
}, null, 8, ["render", "props"])
|
|
2332
|
+
]),
|
|
2333
|
+
y("div", Xn, [
|
|
2334
|
+
C(x(me), {
|
|
2335
|
+
render: (ke = (Te = (we = W.name) == null ? void 0 : we.column) == null ? void 0 : Te.columnDef) == null ? void 0 : ke.cell,
|
|
2336
|
+
props: ($e = (re = W.name) == null ? void 0 : re.getContext) == null ? void 0 : $e.call(re)
|
|
2337
|
+
}, null, 8, ["render", "props"])
|
|
2338
|
+
]),
|
|
2339
|
+
y("div", null, F((Se = V.original.locations) != null && Se.length ? x(l)("inventory.adjustment.template.table.enabledForN", {
|
|
2340
|
+
count: ((Ie = V.original.locations) == null ? void 0 : Ie.length) ?? 0
|
|
2341
|
+
}) : x(l)("inventory.adjustment.template.table.enabledForAll")), 1),
|
|
2342
|
+
S[5] || (S[5] = y("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-2" }, null, -1)),
|
|
2343
|
+
y("div", Zn, [
|
|
2344
|
+
C(x(me), {
|
|
2345
|
+
render: (Ae = (Fe = (Ce = W.ref) == null ? void 0 : Ce.column) == null ? void 0 : Fe.columnDef) == null ? void 0 : Ae.cell,
|
|
2346
|
+
props: (Re = (ie = W.ref) == null ? void 0 : ie.getContext) == null ? void 0 : Re.call(ie)
|
|
2347
|
+
}, null, 8, ["render", "props"])
|
|
2348
|
+
])
|
|
2349
|
+
]),
|
|
2350
|
+
y("div", null, [
|
|
2351
|
+
C(x(me), {
|
|
2352
|
+
render: (Ee = (Me = (De = W.status) == null ? void 0 : De.column) == null ? void 0 : Me.columnDef) == null ? void 0 : Ee.cell,
|
|
2353
|
+
props: (Pe = (ue = W.status) == null ? void 0 : ue.getContext) == null ? void 0 : Pe.call(ue)
|
|
2354
|
+
}, null, 8, ["render", "props"])
|
|
2355
|
+
])
|
|
2356
|
+
])
|
|
2357
|
+
];
|
|
2358
|
+
}),
|
|
2359
|
+
_: 2
|
|
2360
|
+
}, 1032, ["row", "onRowClick"])
|
|
2361
|
+
]),
|
|
2362
|
+
_: 1
|
|
2363
|
+
}, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"])
|
|
2364
|
+
], 2)
|
|
2365
|
+
]),
|
|
2366
|
+
_: 1
|
|
2367
|
+
}, 8, ["title", "actions"]),
|
|
2368
|
+
(I(), O(Xe, { to: "body" }, [
|
|
2369
|
+
C($n, Ze(et(x(t))), null, 16),
|
|
2370
|
+
C(wn, je(x(o), {
|
|
2371
|
+
onSubmitted: S[2] || (S[2] = (V) => x(g).fetchTemplates())
|
|
2372
|
+
}), null, 16),
|
|
2373
|
+
C(Kn, je(x(s), {
|
|
2374
|
+
onSubmitted: S[3] || (S[3] = (V) => x(g).fetchTemplates())
|
|
2375
|
+
}), null, 16)
|
|
2376
|
+
]))
|
|
2377
|
+
], 64);
|
|
2378
|
+
};
|
|
2379
|
+
}
|
|
2380
|
+
});
|
|
2381
|
+
export {
|
|
2382
|
+
$s as default
|
|
2383
|
+
};
|