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