@feedmepos/mf-inventory-portal 0.0.23-dev.23 → 0.0.23-dev.25
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-BvEB-iR6.js → App-CNgj7enS.js} +49 -45
- package/dist/{ApprovalView-BmPYoGNQ.js → ApprovalView-CaVxfwVZ.js} +15 -15
- package/dist/{BindingsDialog-BqKMRdvl.js → BindingsDialog-jRZXoJFn.js} +9 -9
- package/dist/{BindingsPicker-BaEdafvS.js → BindingsPicker-B1HSa3PR.js} +5 -5
- package/dist/{BindingsTable--d-nM2Gv.js → BindingsTable-OF56C-md.js} +8 -8
- package/dist/ClosingDraftView-B6okKype.js +1134 -0
- package/dist/{ClosingTemplateView-BdUGSMOi.js → ClosingTemplateView-iX4shLcv.js} +251 -255
- package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CIk6CwoD.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-Bj2M9OAD.js} +13 -13
- package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-Bt1hyXul.js → FmUnitInput.vue_vue_type_script_setup_true_lang-CnPZaNTp.js} +46 -46
- package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-wYnVSXtH.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-CGpmbbpm.js} +7 -7
- package/dist/{IngredientGroupView-0-nzZJcl.js → IngredientGroupView-BeW-0hWb.js} +40 -40
- package/dist/{IngredientsView-ClRyZ-cb.js → IngredientsView-CuVBlnOu.js} +207 -210
- package/dist/{IntegrationView-CgmsV7oX.js → IntegrationView-lDfeScNo.js} +89 -90
- package/dist/{InventoryBindingForm-DnnGejy0.js → InventoryBindingForm-D6EuWIkE.js} +1 -1
- package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-CapSS-KQ.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-CUpKKG4l.js} +27 -27
- package/dist/{InventoryBindingSummary-Dz-F2ofe.js → InventoryBindingSummary-CD60iCr_.js} +1 -1
- package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-glXw963h.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-7jkFhj27.js} +1 -1
- package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-DpIyyZL-.js → PremiumBadge.vue_vue_type_script_setup_true_lang-DDXsfGVf.js} +17 -18
- package/dist/{PurchaseOrderPrintPreview--hGI0aFU.js → PurchaseOrderPrintPreview-eJxn76Ir.js} +1 -1
- package/dist/{ReceiveRequestView-cPIOC0rj.js → ReceiveRequestView-D6Cdkd36.js} +26 -27
- package/dist/{RecipeView-BK74973y.js → RecipeView-BWy56DhW.js} +47 -48
- package/dist/{StockView-D6TYfv5x.js → StockView-BEXAvBjP.js} +7 -7
- package/dist/{SupplierView-BFwzHw7l.js → SupplierView-C4vwkzdX.js} +203 -206
- package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-ChwtBdsS.js → TransferDetails.vue_vue_type_script_setup_true_lang-CIcj9NWg.js} +61 -62
- package/dist/{TransferTemplateView-De5sG12Q.js → TransferTemplateView-27Ng_EgG.js} +144 -145
- package/dist/{UnitView-CQoB6Uq_.js → UnitView-CXvkO_fh.js} +3 -3
- package/dist/{WarehouseView-Di4mLjoS.js → WarehouseView-Cl6HN1EW.js} +52 -52
- package/dist/app-Dt6Yd1pM.js +84133 -0
- package/dist/app.js +1 -1
- package/dist/{decimal-D2WMzK1d.js → decimal-D1M8NkLV.js} +1 -1
- package/dist/{feature-SYqA_m5m.js → feature-CqDcAtUy.js} +1 -1
- package/dist/{format-unit-display-D0G-LaQY.js → format-unit-display-BI9EVHb3.js} +50 -53
- package/dist/{index-Bj8PDCww.js → index-7V6E004u.js} +1 -1
- package/dist/{stock-CEexJdO3.js → stock-wjdjOqbM.js} +1 -1
- package/dist/style.css +1 -1
- package/dist/{supplier-BdB47EjI.js → supplier-D3-7dgm5.js} +1 -1
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/dist/{use-inventory-binding-dialog-n3khDS2D.js → use-inventory-binding-dialog-BLHffZgi.js} +1 -1
- package/dist/views/adjustment-template/import/AdjustmentTemplateImport.vue.d.ts +2 -0
- package/dist/views/adjustment-template/import/AdjustmentTemplateImportItem.vue.d.ts +18 -0
- package/dist/views/adjustment-template/import/export.d.ts +60 -0
- package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftDialog.vue.d.ts +178 -8
- package/dist/views/closing-draft/composables/use-closing-draft-table.d.ts +1498 -478
- package/package.json +3 -3
- package/dist/ClosingDraftView-Clh7bujC.js +0 -1116
- package/dist/FmDroppableField-DHhcKcJf.js +0 -154
- package/dist/app-DpJictvi.js +0 -58871
- package/dist/netsuite-TWj-9PDj.js +0 -251
- package/dist/xlsx-Cbd5szA2.js +0 -24004
- package/dist/xlsx.util-hCH_XTAD.js +0 -78
|
@@ -0,0 +1,1134 @@
|
|
|
1
|
+
import { defineComponent as fe, ref as z, resolveComponent as U, openBlock as w, createBlock as ne, withCtx as W, createElementVNode as o, createTextVNode as ye, toDisplayString as I, unref as b, createVNode as _, h as N, computed as M, onMounted as Ue, watch as He, isRef as xe, createCommentVNode as te, createElementBlock as F, Fragment as J, normalizeClass as ae, renderList as ce, normalizeStyle as De, Teleport as Ie, mergeProps as ze } from "vue";
|
|
2
|
+
import { W as Ee, u as pe, ah as O, l as Le, J as ve, i as S, t as Ne, K as se, o as Oe, p as Ke, q as Ve, ai as Ae, aj as _e, a6 as we, ak as ke, al as oe, ac as Ye, ag as q, T as Ce, D as be, h as ie, f as Ge, e as qe, a as We, x as Ze, y as Je, z as Qe, B as Xe, E as ue } from "./app-Dt6Yd1pM.js";
|
|
3
|
+
import { useCoreStore as et, useI18n as je } from "@feedmepos/mf-common";
|
|
4
|
+
import { useSnackbar as ge, useDialog as tt, useProxiedModel as at, components as de, useBreakpoints as nt } from "@feedmepos/ui-library";
|
|
5
|
+
import { defineStore as Se, storeToRefs as ot } from "pinia";
|
|
6
|
+
import { u as Be } from "./stock-wjdjOqbM.js";
|
|
7
|
+
import { E as st } from "./empty-placeholder-wf6-BWE8.js";
|
|
8
|
+
const Fe = Ee((a, l) => {
|
|
9
|
+
function e() {
|
|
10
|
+
return pe().currentLocation.dbName;
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
async getDraft(c) {
|
|
14
|
+
const d = e(), v = `${a.inventoryBackendUrl}/${d}/closing-draft/${c}`;
|
|
15
|
+
return l.get(v);
|
|
16
|
+
},
|
|
17
|
+
async readDrafts() {
|
|
18
|
+
const c = e(), d = `${a.inventoryBackendUrl}/${c}/closing-draft`;
|
|
19
|
+
return l.get(d);
|
|
20
|
+
},
|
|
21
|
+
async runOperation(c) {
|
|
22
|
+
const d = e(), v = `${a.inventoryBackendUrl}/${d}/closing-draft/run-operation`;
|
|
23
|
+
return l.post(v, c);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}), rt = { class: "fm-typo-en-body-lg-400" }, lt = { class: "fm-typo-en-body-lg-600" }, ct = { class: "flex gap-12 py-8 justify-end w-full" }, he = /* @__PURE__ */ fe({
|
|
27
|
+
__name: "ClosingDraftAction",
|
|
28
|
+
props: {
|
|
29
|
+
draft: {},
|
|
30
|
+
action: {},
|
|
31
|
+
onCancel: { type: Function },
|
|
32
|
+
onFinished: { type: Function }
|
|
33
|
+
},
|
|
34
|
+
setup(a) {
|
|
35
|
+
const l = a, e = z(), c = Fe(), d = ge(), v = z(!1);
|
|
36
|
+
async function i() {
|
|
37
|
+
v.value = !0;
|
|
38
|
+
try {
|
|
39
|
+
await c.runOperation({
|
|
40
|
+
_id: l.draft._id,
|
|
41
|
+
_rev: l.draft._rev ?? "",
|
|
42
|
+
action: l.action,
|
|
43
|
+
data: {
|
|
44
|
+
remark: e.value
|
|
45
|
+
}
|
|
46
|
+
}).delayed(500), d.open({
|
|
47
|
+
title: "Success",
|
|
48
|
+
message: "Action submitted",
|
|
49
|
+
type: "success"
|
|
50
|
+
}), l.onFinished();
|
|
51
|
+
} catch (f) {
|
|
52
|
+
d.open({
|
|
53
|
+
title: "Something went wrong",
|
|
54
|
+
message: "Unable to submit actino. Please try again",
|
|
55
|
+
type: "error"
|
|
56
|
+
}), console.error("error on submit closing draft aciont", f);
|
|
57
|
+
} finally {
|
|
58
|
+
v.value = !1;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return (f, y) => {
|
|
62
|
+
const B = U("FmTextField"), R = U("FmButton"), $ = U("FmForm");
|
|
63
|
+
return w(), ne($, {
|
|
64
|
+
onValidationSuccess: i,
|
|
65
|
+
class: "flex flex-col gap-32",
|
|
66
|
+
disabled: v.value
|
|
67
|
+
}, {
|
|
68
|
+
default: W(() => [
|
|
69
|
+
o("div", rt, [
|
|
70
|
+
y[2] || (y[2] = ye(" You are about to ")),
|
|
71
|
+
o("span", lt, I(f.action == b(O).enum.approveDraft ? "approve" : "reject"), 1),
|
|
72
|
+
y[3] || (y[3] = ye(" this draft. Please provider a remark to justify this action. "))
|
|
73
|
+
]),
|
|
74
|
+
_(B, {
|
|
75
|
+
modelValue: e.value,
|
|
76
|
+
"onUpdate:modelValue": y[0] || (y[0] = (r) => e.value = r),
|
|
77
|
+
label: "Remark",
|
|
78
|
+
"label-mark": "required",
|
|
79
|
+
rules: [b(Le)()]
|
|
80
|
+
}, null, 8, ["modelValue", "rules"]),
|
|
81
|
+
o("div", ct, [
|
|
82
|
+
_(R, {
|
|
83
|
+
label: "Cancel",
|
|
84
|
+
variant: "tertiary",
|
|
85
|
+
onClick: y[1] || (y[1] = (r) => f.onCancel())
|
|
86
|
+
}),
|
|
87
|
+
_(R, {
|
|
88
|
+
label: f.action == b(O).enum.approveDraft ? "Approve" : "Reject",
|
|
89
|
+
type: "submit",
|
|
90
|
+
variant: f.action == b(O).enum.approveDraft ? "primary" : "destructive",
|
|
91
|
+
loading: v.value
|
|
92
|
+
}, null, 8, ["label", "variant", "loading"])
|
|
93
|
+
])
|
|
94
|
+
]),
|
|
95
|
+
_: 1
|
|
96
|
+
}, 8, ["disabled"]);
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}), it = se(0);
|
|
100
|
+
function $e(a) {
|
|
101
|
+
const l = a.measurementsAmounts.groupBy((c) => c.measurement.id), e = a.sku.unit.measurements.reduce((c, d) => {
|
|
102
|
+
var f, y;
|
|
103
|
+
const v = ((y = (f = l.get(d.id)) == null ? void 0 : f[0]) == null ? void 0 : y.amount) ?? it, i = ve(d.conversion, v);
|
|
104
|
+
return c + +S(i);
|
|
105
|
+
}, +S(a.baseAmount));
|
|
106
|
+
return Ne(e, a.baseAmount.precision);
|
|
107
|
+
}
|
|
108
|
+
const ut = se(0), dt = se(100);
|
|
109
|
+
function mt(a, l) {
|
|
110
|
+
const e = $e(a), c = Ae(e, l), d = l.amount === 0 ? null : _e(c, l), v = d ? ve(d, dt) : null;
|
|
111
|
+
return {
|
|
112
|
+
code: a.sku.code,
|
|
113
|
+
name: a.sku.name,
|
|
114
|
+
baseUnit: a.sku.unit.abbrev,
|
|
115
|
+
baseUnitAmount: +S(a.baseAmount),
|
|
116
|
+
...a.measurementsAmounts.filter((f) => Re(f.measurement)).reduce(
|
|
117
|
+
(f, y, B) => (f[`measurementAbbrev${B}`] = `(${y.measurement.abbrev}) × ${S(y.measurement.conversion)}`, f[`measurementAmount${B}`] = +S(y.amount), f),
|
|
118
|
+
{}
|
|
119
|
+
),
|
|
120
|
+
systemBalance: +S(l),
|
|
121
|
+
physicalBalance: +S(e),
|
|
122
|
+
adjustedAmount: +S(c),
|
|
123
|
+
adjustedDiffPercentage: v ? +S(we(v, 2)) : null
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function Re(a) {
|
|
127
|
+
return !a.abbrev.toLocaleLowerCase().includes("inactive");
|
|
128
|
+
}
|
|
129
|
+
function ft(a) {
|
|
130
|
+
return a.reduce((l, e) => l + e.sku.unit.measurements.filter(Re).length, 0);
|
|
131
|
+
}
|
|
132
|
+
function pt(a) {
|
|
133
|
+
return [
|
|
134
|
+
{
|
|
135
|
+
id: "code",
|
|
136
|
+
name: "Code"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
id: "name",
|
|
140
|
+
name: "Name"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
id: "unit",
|
|
144
|
+
name: "Base unit amount"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
id: "baseUnit",
|
|
148
|
+
name: "Base unit"
|
|
149
|
+
},
|
|
150
|
+
...Array.from({ length: a }).flatMap((e, c) => [
|
|
151
|
+
{
|
|
152
|
+
id: `measurementAmount${c}`,
|
|
153
|
+
name: `UOM amount ${c + 1}`
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
id: `measurementAbbrev${c}`,
|
|
157
|
+
name: `UOM ${c + 1}`
|
|
158
|
+
}
|
|
159
|
+
]),
|
|
160
|
+
{
|
|
161
|
+
id: "physicalBalance",
|
|
162
|
+
name: "Total balance"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
id: "systemBalance",
|
|
166
|
+
name: "System balance"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
id: "adjustedAmount",
|
|
170
|
+
name: "Adjusted amount"
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
id: "adjustedDiffPercentage",
|
|
174
|
+
name: "Diff (%)"
|
|
175
|
+
}
|
|
176
|
+
];
|
|
177
|
+
}
|
|
178
|
+
function vt(a, l) {
|
|
179
|
+
var r, s, p, H, T, j, Q;
|
|
180
|
+
const e = l.groupBy(
|
|
181
|
+
(h) => h.id,
|
|
182
|
+
(h) => h.balance
|
|
183
|
+
), c = a.items.map((h) => {
|
|
184
|
+
var K;
|
|
185
|
+
const k = ((K = e.get(h.sku._id)) == null ? void 0 : K[0]) ?? ut;
|
|
186
|
+
return mt(h, k);
|
|
187
|
+
}), d = ft(a.items), i = et().currentBusiness.value, f = pt(d), y = [
|
|
188
|
+
["Business name:", i == null ? void 0 : i.name],
|
|
189
|
+
["Business ID:", i == null ? void 0 : i._id],
|
|
190
|
+
["Menu version", i == null ? void 0 : i.menuVersion],
|
|
191
|
+
["Created at", new Date(a.createdAt)],
|
|
192
|
+
["Created by", (r = a.createdBy) == null ? void 0 : r.name],
|
|
193
|
+
["Updated at", new Date(a.updatedAt)],
|
|
194
|
+
["Updated by", (s = a.updatedBy) == null ? void 0 : s.name],
|
|
195
|
+
["Recent action", a.approvedAt ? "Approve" : a.rejectionHistory ? "Reject" : ""],
|
|
196
|
+
[
|
|
197
|
+
"Action by",
|
|
198
|
+
a.approvedAt ? (p = a.approvedBy) == null ? void 0 : p.name : a.rejectionHistory ? (T = (H = a.rejectionHistory[0]) == null ? void 0 : H.rejectedBy) == null ? void 0 : T.name : ""
|
|
199
|
+
],
|
|
200
|
+
[
|
|
201
|
+
"Action at",
|
|
202
|
+
a.approvedAt ? new Date(a.approvedAt) : a.rejectionHistory ? new Date((j = a.rejectionHistory[0]) == null ? void 0 : j.rejectedAt) : ""
|
|
203
|
+
],
|
|
204
|
+
[
|
|
205
|
+
"Action remark",
|
|
206
|
+
a.approvedAt ? a.approveRemark : a.rejectionHistory ? new Date((Q = a.rejectionHistory[0]) == null ? void 0 : Q.rejectRemark) : ""
|
|
207
|
+
],
|
|
208
|
+
[],
|
|
209
|
+
f.map((h) => h.name),
|
|
210
|
+
...c.map((h) => f.map((k) => h[k.id]))
|
|
211
|
+
], B = f.map((h) => `system:${h.id}`), R = Oe(y, B), $ = `[${i == null ? void 0 : i.name}] closing draft (${Ke(new Date(a.updatedAt))}).xlsx`;
|
|
212
|
+
return Ve(R, $), $;
|
|
213
|
+
}
|
|
214
|
+
const me = Se(
|
|
215
|
+
"closingDraftActions",
|
|
216
|
+
function() {
|
|
217
|
+
const l = tt(), e = ge(), c = ke(), d = Be(), v = z(!1), i = z();
|
|
218
|
+
function f(s) {
|
|
219
|
+
const p = {
|
|
220
|
+
draft: s
|
|
221
|
+
};
|
|
222
|
+
i.value = p, v.value = !0;
|
|
223
|
+
}
|
|
224
|
+
async function y(s) {
|
|
225
|
+
var H;
|
|
226
|
+
if (s.status === oe.enum.COMPLETED) {
|
|
227
|
+
const T = s.closingId;
|
|
228
|
+
if (!T)
|
|
229
|
+
return e.open({
|
|
230
|
+
title: "Something went wrong",
|
|
231
|
+
message: "Closing draft is completed but closing document cannot be found.",
|
|
232
|
+
type: "error"
|
|
233
|
+
}), console.error("Closing draft is completed but closing document cannot be found.", {
|
|
234
|
+
draftId: s == null ? void 0 : s._id
|
|
235
|
+
}), [];
|
|
236
|
+
const j = await c.getClosingById(T);
|
|
237
|
+
return (j == null ? void 0 : j.skus) ?? [];
|
|
238
|
+
} else
|
|
239
|
+
return await d.readStockBalance(), ((H = d.stockBalance) == null ? void 0 : H.skus) ?? [];
|
|
240
|
+
}
|
|
241
|
+
async function B(s, p) {
|
|
242
|
+
p || (e.open({
|
|
243
|
+
title: "Exporting",
|
|
244
|
+
message: "Fetching data..."
|
|
245
|
+
}), p = await y(s)), vt(s, p);
|
|
246
|
+
}
|
|
247
|
+
function R(s, p) {
|
|
248
|
+
l.open({
|
|
249
|
+
title: "Approve draft",
|
|
250
|
+
contentComponent: he,
|
|
251
|
+
contentComponentProps: {
|
|
252
|
+
draft: s,
|
|
253
|
+
action: O.enum.approveDraft,
|
|
254
|
+
onFinished: () => {
|
|
255
|
+
l.close(), p == null || p();
|
|
256
|
+
},
|
|
257
|
+
onCancel: () => l.close()
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
function $(s, p) {
|
|
262
|
+
l.open({
|
|
263
|
+
title: "Reject draft",
|
|
264
|
+
contentComponent: he,
|
|
265
|
+
contentComponentProps: {
|
|
266
|
+
draft: s,
|
|
267
|
+
action: O.enum.rejectDraft,
|
|
268
|
+
onFinished: () => {
|
|
269
|
+
l.close(), p == null || p();
|
|
270
|
+
},
|
|
271
|
+
onCancel: () => l.close()
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
function r() {
|
|
276
|
+
v.value = !1;
|
|
277
|
+
}
|
|
278
|
+
return {
|
|
279
|
+
viewDraft: f,
|
|
280
|
+
closeDraftDialog: r,
|
|
281
|
+
approveDraft: R,
|
|
282
|
+
rejectDraft: $,
|
|
283
|
+
exportDraft: B,
|
|
284
|
+
viewClosingDraftShow: v,
|
|
285
|
+
viewClosingDraftProps: i
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
);
|
|
289
|
+
function Te(a) {
|
|
290
|
+
switch (a) {
|
|
291
|
+
case "DRAFT":
|
|
292
|
+
return "fm-status-badge-draft";
|
|
293
|
+
case "PROCESSING":
|
|
294
|
+
return "fm-status-badge-processing";
|
|
295
|
+
case "FAILED":
|
|
296
|
+
return "fm-status-badge-cancel";
|
|
297
|
+
case "COMPLETED":
|
|
298
|
+
return "fm-status-badge-complete";
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
const gt = Se("closingTable", function() {
|
|
302
|
+
const { t: l } = je(), e = me(), c = z(new Array()), d = z(!1), v = pe(), i = Fe();
|
|
303
|
+
async function f() {
|
|
304
|
+
if (c.value = [], !!v._currentLocation) {
|
|
305
|
+
d.value = !0;
|
|
306
|
+
try {
|
|
307
|
+
const [r] = await Promise.all([i.readDrafts()]).delayed(1e3);
|
|
308
|
+
c.value = r.reverse();
|
|
309
|
+
} catch (r) {
|
|
310
|
+
console.log("Something went wrong when fetching drafts:", r);
|
|
311
|
+
} finally {
|
|
312
|
+
d.value = !1;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
async function y(r) {
|
|
317
|
+
if (!c.value.find((s) => s._id) && v._currentLocation) {
|
|
318
|
+
d.value = !0;
|
|
319
|
+
try {
|
|
320
|
+
const [s] = await Promise.all([
|
|
321
|
+
i.getDraft(r),
|
|
322
|
+
new Promise((p) => setTimeout(p, 1e3))
|
|
323
|
+
]);
|
|
324
|
+
c.value = [s];
|
|
325
|
+
} catch (s) {
|
|
326
|
+
console.log("Something went wrong when fetching drafts:", s);
|
|
327
|
+
} finally {
|
|
328
|
+
d.value = !1;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
function B() {
|
|
333
|
+
e.closeDraftDialog(), f();
|
|
334
|
+
}
|
|
335
|
+
function R(r, s) {
|
|
336
|
+
switch (s = qe(s), r) {
|
|
337
|
+
case ie.Details:
|
|
338
|
+
return e.viewDraft(s);
|
|
339
|
+
case ie.Export:
|
|
340
|
+
return e.exportDraft(s);
|
|
341
|
+
case O.enum.approveDraft:
|
|
342
|
+
return e.approveDraft(s, B);
|
|
343
|
+
case O.enum.rejectDraft:
|
|
344
|
+
return e.rejectDraft(s, B);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
return {
|
|
348
|
+
columnDefs: [
|
|
349
|
+
{
|
|
350
|
+
id: "_id",
|
|
351
|
+
accessorKey: "_id",
|
|
352
|
+
header: () => l("inventory.closing.table.createdAt"),
|
|
353
|
+
cell(r) {
|
|
354
|
+
return Ye(`${r.getValue()}`);
|
|
355
|
+
},
|
|
356
|
+
enableSorting: !0
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
id: "updatedAt",
|
|
360
|
+
accessorFn: (r) => q(r.updatedAt),
|
|
361
|
+
header: () => "Updated at",
|
|
362
|
+
enableSorting: !0,
|
|
363
|
+
size: 200
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
id: "updatedBy",
|
|
367
|
+
accessorKey: "updatedBy.name",
|
|
368
|
+
header: () => "Last update by",
|
|
369
|
+
enableSorting: !0,
|
|
370
|
+
size: 200
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
id: "noOfItems",
|
|
374
|
+
accessorFn: (r) => {
|
|
375
|
+
var s;
|
|
376
|
+
return r.items.length + (((s = r.negativeStockItems) == null ? void 0 : s.length) ?? 0);
|
|
377
|
+
},
|
|
378
|
+
header: () => l("inventory.closing.table.noOfItems"),
|
|
379
|
+
enableSorting: !1,
|
|
380
|
+
meta: {
|
|
381
|
+
width: "10rem",
|
|
382
|
+
textAlign: "right"
|
|
383
|
+
}
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
id: "recentRemark",
|
|
387
|
+
accessorFn: (r) => {
|
|
388
|
+
var s;
|
|
389
|
+
return (r == null ? void 0 : r.approveRemark) ?? ((s = r == null ? void 0 : r.rejectionHistory) == null ? void 0 : s.computeFirst((p) => p.rejectRemark));
|
|
390
|
+
},
|
|
391
|
+
header: () => "Recent remark"
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
id: "status",
|
|
395
|
+
accessorFn: (r) => r.status,
|
|
396
|
+
header: () => l("inventory.closing.table.status"),
|
|
397
|
+
enableSorting: !1,
|
|
398
|
+
cell(r) {
|
|
399
|
+
const p = r.row.original.status;
|
|
400
|
+
return N(
|
|
401
|
+
"div",
|
|
402
|
+
{
|
|
403
|
+
class: "flex"
|
|
404
|
+
},
|
|
405
|
+
N(
|
|
406
|
+
"div",
|
|
407
|
+
{
|
|
408
|
+
class: ["fm-status-badge", Te(p)]
|
|
409
|
+
},
|
|
410
|
+
Ce(p)
|
|
411
|
+
)
|
|
412
|
+
);
|
|
413
|
+
}
|
|
414
|
+
},
|
|
415
|
+
{
|
|
416
|
+
id: "action",
|
|
417
|
+
cell(r) {
|
|
418
|
+
const s = r.row.original, p = [
|
|
419
|
+
be[ie.Details],
|
|
420
|
+
be[ie.Export]
|
|
421
|
+
], H = [
|
|
422
|
+
{
|
|
423
|
+
translationKey: "inventory.closing.draft.approveDraft",
|
|
424
|
+
color: "text-fm-color-typo-primary",
|
|
425
|
+
value: O.enum.approveDraft
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
translationKey: "inventory.closing.draft.rejectDraft",
|
|
429
|
+
color: "text-fm-color-typo-error",
|
|
430
|
+
value: O.enum.rejectDraft
|
|
431
|
+
}
|
|
432
|
+
];
|
|
433
|
+
return Ge(
|
|
434
|
+
[...p, ...s.status === oe.enum.DRAFT ? H : []],
|
|
435
|
+
(T) => R(T, s)
|
|
436
|
+
);
|
|
437
|
+
},
|
|
438
|
+
enableSorting: !1,
|
|
439
|
+
size: 40,
|
|
440
|
+
meta: {
|
|
441
|
+
cellClass: "",
|
|
442
|
+
headerClass: ""
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
],
|
|
446
|
+
drafts: c,
|
|
447
|
+
loading: d,
|
|
448
|
+
fetchDrafts: f,
|
|
449
|
+
loadDraft: y
|
|
450
|
+
};
|
|
451
|
+
}), yt = { class: "w-full flex flex-col gap-32" }, bt = { class: "flex justify-between" }, ht = { class: "flex" }, xt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Dt = { class: "flex gap-1" }, At = { class: "fm-typo-en-body-lg-600" }, _t = { class: "flex flex-col gap-16" }, wt = { class: "flex" }, kt = { key: 0 }, Ct = {
|
|
452
|
+
key: 0,
|
|
453
|
+
class: "w-full flex flex-col items-center"
|
|
454
|
+
}, jt = { class: "flex items-center gap-8" }, St = {
|
|
455
|
+
key: 1,
|
|
456
|
+
class: "overflow-x-auto"
|
|
457
|
+
}, Bt = {
|
|
458
|
+
key: 1,
|
|
459
|
+
class: "flex-1 xs:w-screen xs:max-w-full"
|
|
460
|
+
}, Ft = {
|
|
461
|
+
key: 0,
|
|
462
|
+
class: "flex flex-col items-center gap-8 h-full"
|
|
463
|
+
}, $t = ["src"], Rt = {
|
|
464
|
+
key: 1,
|
|
465
|
+
class: "px-4 flex flex-col"
|
|
466
|
+
}, Tt = { class: "flex gap-12 content-stretch" }, Mt = {
|
|
467
|
+
class: "flex flex-col w-24",
|
|
468
|
+
name: "circles"
|
|
469
|
+
}, Pt = { class: "flex-1 flex flex-col items-center" }, Ut = { class: "flex-1 flex flex-col items-center" }, Ht = {
|
|
470
|
+
class: "py-12 flex flex-col gap-4",
|
|
471
|
+
name: "received-at header"
|
|
472
|
+
}, It = { class: "fm-typo-en-body-lg-400" }, zt = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Et = { class: "flex gap-12 content-stretch" }, Lt = {
|
|
473
|
+
class: "flex flex-col w-24",
|
|
474
|
+
name: "circles"
|
|
475
|
+
}, Nt = { class: "flex-1 flex flex-col items-center" }, Ot = {
|
|
476
|
+
class: "py-12 flex flex-col gap-4 flex-1",
|
|
477
|
+
name: "delivery details"
|
|
478
|
+
}, Kt = { class: "flex flex-col gap-8" }, Vt = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Yt = { class: "flex flex-col gap-4" }, Gt = { class: "flex gap-8" }, qt = /* @__PURE__ */ fe({
|
|
479
|
+
__name: "ClosingDraftDialog",
|
|
480
|
+
props: {
|
|
481
|
+
show: { type: Boolean },
|
|
482
|
+
draft: {}
|
|
483
|
+
},
|
|
484
|
+
emits: ["submitted"],
|
|
485
|
+
setup(a, { emit: l }) {
|
|
486
|
+
const e = a, c = Be(), d = me(), v = at(e, "show"), i = z(!1), f = z(new Array()), y = ke(), B = ge(), R = We(), $ = l, r = M(() => {
|
|
487
|
+
var n, t;
|
|
488
|
+
return [
|
|
489
|
+
...((n = e.draft) == null ? void 0 : n.items) ?? [],
|
|
490
|
+
...((t = e.draft) == null ? void 0 : t.negativeStockItems) ?? []
|
|
491
|
+
];
|
|
492
|
+
}), s = M(() => {
|
|
493
|
+
const n = r.value.map((t) => t.sku);
|
|
494
|
+
return n.sort((t, m) => t.code.localeCompare(m.code)), n;
|
|
495
|
+
}), p = M(() => r.value.groupBy(
|
|
496
|
+
(t) => t.sku._id,
|
|
497
|
+
(t) => t.measurementsAmounts.filter((m) => !m.measurement.abbrev.toLocaleLowerCase().includes("inactive")).map((m) => m.measurement.id)
|
|
498
|
+
));
|
|
499
|
+
Ue(j), He(
|
|
500
|
+
() => e.show,
|
|
501
|
+
(n) => {
|
|
502
|
+
n && (V.value = ee[0], j());
|
|
503
|
+
}
|
|
504
|
+
);
|
|
505
|
+
const H = se(0), T = se(100);
|
|
506
|
+
async function j() {
|
|
507
|
+
var t, m, u;
|
|
508
|
+
i.value = !0;
|
|
509
|
+
const n = ((t = e.draft) == null ? void 0 : t.status) === oe.enum.COMPLETED;
|
|
510
|
+
try {
|
|
511
|
+
if (await R.init(), n) {
|
|
512
|
+
const x = e.draft.closingId;
|
|
513
|
+
if (!x) {
|
|
514
|
+
B.open({
|
|
515
|
+
title: "Something went wrong",
|
|
516
|
+
message: "Closing draft is completed but closing document cannot be found.",
|
|
517
|
+
type: "error"
|
|
518
|
+
}), console.error("Closing draft is completed but closing document cannot be found.", {
|
|
519
|
+
draftId: (m = e.draft) == null ? void 0 : m._id
|
|
520
|
+
});
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
const g = await y.getClosingById(x);
|
|
524
|
+
f.value = (g == null ? void 0 : g.skus) ?? [];
|
|
525
|
+
} else
|
|
526
|
+
await c.readStockBalance(), f.value = ((u = c.stockBalance) == null ? void 0 : u.skus) ?? [];
|
|
527
|
+
} catch (x) {
|
|
528
|
+
B.open({
|
|
529
|
+
title: "Something went wrong",
|
|
530
|
+
message: "Something went wrong when fetching info. Please try again.",
|
|
531
|
+
type: "error"
|
|
532
|
+
}), console.error("error on fetch stock balances", x);
|
|
533
|
+
} finally {
|
|
534
|
+
i.value = !1;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
const Q = M(
|
|
538
|
+
() => f.value.groupBy(
|
|
539
|
+
(n) => n.id,
|
|
540
|
+
(n) => n.balance
|
|
541
|
+
)
|
|
542
|
+
), h = M(() => r.value.groupBy((n) => n.sku._id));
|
|
543
|
+
function k(n) {
|
|
544
|
+
return N(
|
|
545
|
+
de.FmTooltip,
|
|
546
|
+
{ zIndex: 51, placement: "left", class: "w-full flex justify-end" },
|
|
547
|
+
{
|
|
548
|
+
default() {
|
|
549
|
+
return n;
|
|
550
|
+
},
|
|
551
|
+
content() {
|
|
552
|
+
return "Differences are calculated using this formula: (Adjusted / System) × 100%";
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
);
|
|
556
|
+
}
|
|
557
|
+
const K = M(() => {
|
|
558
|
+
const n = s.value.reduce((m, u) => {
|
|
559
|
+
var x, g, P, Y;
|
|
560
|
+
return console.log(
|
|
561
|
+
"Measurement counts",
|
|
562
|
+
u.unit.name,
|
|
563
|
+
u.unit.abbrev,
|
|
564
|
+
(g = (x = p.value) == null ? void 0 : x.get(u._id)) == null ? void 0 : g[0].length
|
|
565
|
+
), Math.max(m, ((Y = (P = p.value) == null ? void 0 : P.get(u._id)) == null ? void 0 : Y[0].length) ?? 0);
|
|
566
|
+
}, 0);
|
|
567
|
+
return [
|
|
568
|
+
{
|
|
569
|
+
id: "code",
|
|
570
|
+
accessorKey: "code",
|
|
571
|
+
header: () => "Code",
|
|
572
|
+
size: 200
|
|
573
|
+
},
|
|
574
|
+
{
|
|
575
|
+
id: "name",
|
|
576
|
+
accessorKey: "name",
|
|
577
|
+
header: () => "Name",
|
|
578
|
+
size: 300
|
|
579
|
+
},
|
|
580
|
+
{
|
|
581
|
+
id: "baseUnitAmount",
|
|
582
|
+
accessorKey: "baseUnitAmount",
|
|
583
|
+
header: () => k("Base unit amount"),
|
|
584
|
+
size: 200,
|
|
585
|
+
meta: {
|
|
586
|
+
textAlign: "right"
|
|
587
|
+
}
|
|
588
|
+
},
|
|
589
|
+
{
|
|
590
|
+
id: "baseUnit",
|
|
591
|
+
accessorKey: "baseUnit",
|
|
592
|
+
header: () => "Base unit",
|
|
593
|
+
size: 200
|
|
594
|
+
},
|
|
595
|
+
...Array.from({ length: n }).flatMap((m, u) => {
|
|
596
|
+
const x = `measurementAbbrev${u}`, g = `measurementAmount${u}`;
|
|
597
|
+
return [
|
|
598
|
+
{
|
|
599
|
+
id: g,
|
|
600
|
+
accessorKey: g,
|
|
601
|
+
header: () => k(`UOM amount ${u + 1}`),
|
|
602
|
+
size: 200,
|
|
603
|
+
meta: {
|
|
604
|
+
textAlign: "right"
|
|
605
|
+
}
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
id: x,
|
|
609
|
+
accessorKey: x,
|
|
610
|
+
header: () => `UOM ${u + 1}`,
|
|
611
|
+
size: 200
|
|
612
|
+
}
|
|
613
|
+
];
|
|
614
|
+
}),
|
|
615
|
+
{
|
|
616
|
+
id: "physicalBalance",
|
|
617
|
+
accessorKey: "physicalBalance",
|
|
618
|
+
header: () => k("Total balance"),
|
|
619
|
+
size: 200,
|
|
620
|
+
meta: {
|
|
621
|
+
textAlign: "right"
|
|
622
|
+
}
|
|
623
|
+
},
|
|
624
|
+
{
|
|
625
|
+
id: "systemBalance",
|
|
626
|
+
accessorKey: "systemBalance",
|
|
627
|
+
header: () => k("System balance"),
|
|
628
|
+
size: 200,
|
|
629
|
+
meta: {
|
|
630
|
+
textAlign: "right"
|
|
631
|
+
}
|
|
632
|
+
},
|
|
633
|
+
{
|
|
634
|
+
id: "adjustedAmount",
|
|
635
|
+
accessorKey: "adjustedAmount",
|
|
636
|
+
header: () => k("Adjusted amount"),
|
|
637
|
+
size: 200,
|
|
638
|
+
meta: {
|
|
639
|
+
textAlign: "right"
|
|
640
|
+
}
|
|
641
|
+
},
|
|
642
|
+
{
|
|
643
|
+
id: "adjustedDiffPercentage",
|
|
644
|
+
accessorKey: "adjustedDiffPercentage",
|
|
645
|
+
header: () => N(
|
|
646
|
+
de.FmTooltip,
|
|
647
|
+
{ zIndex: 51, placement: "left", class: "w-full flex justify-end" },
|
|
648
|
+
{
|
|
649
|
+
default() {
|
|
650
|
+
return N("div", { class: "flex items-center gap-4" }, [
|
|
651
|
+
"Diff (%)",
|
|
652
|
+
N(de.FmIcon, { name: "info", color: "neutral-gray-400", size: "sm" })
|
|
653
|
+
]);
|
|
654
|
+
},
|
|
655
|
+
content() {
|
|
656
|
+
return "Differences are calculated using this formula: (Adjusted / System) × 100%";
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
),
|
|
660
|
+
size: 200,
|
|
661
|
+
cell(m) {
|
|
662
|
+
const u = m.row.original.adjustedDiffPercentage;
|
|
663
|
+
if (!u) return "N/A";
|
|
664
|
+
const x = u.toFixed(2);
|
|
665
|
+
if (x === "0.00")
|
|
666
|
+
return N("div", { class: "flex items-center gap-4 justify-end" }, ["0.00"]);
|
|
667
|
+
const g = u > 0;
|
|
668
|
+
return N("div", { class: "flex items-center gap-4 justify-end" }, [
|
|
669
|
+
N(de.FmIcon, {
|
|
670
|
+
name: g ? "arrow_drop_up" : "arrow_drop_down",
|
|
671
|
+
color: g ? "system-success-300" : "system-error-300",
|
|
672
|
+
size: "md"
|
|
673
|
+
}),
|
|
674
|
+
x
|
|
675
|
+
]);
|
|
676
|
+
},
|
|
677
|
+
meta: {
|
|
678
|
+
textAlign: "right"
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
];
|
|
682
|
+
}), re = M(() => K.value.map((n) => n.size ?? 0).reduce((n, t) => n + t)), le = M(() => s.value.map((n) => {
|
|
683
|
+
var L, Z;
|
|
684
|
+
const t = (L = h.value.get(n._id)) == null ? void 0 : L[0], m = ((Z = Q.value.get(n._id)) == null ? void 0 : Z[0]) ?? H;
|
|
685
|
+
if (!t)
|
|
686
|
+
return {
|
|
687
|
+
code: n.code,
|
|
688
|
+
name: n.name,
|
|
689
|
+
baseUnit: n.unit.abbrev,
|
|
690
|
+
baseUnitAmount: 0,
|
|
691
|
+
systemBalance: +S(m),
|
|
692
|
+
physicalBalance: 0,
|
|
693
|
+
adjustedAmount: -+S(m),
|
|
694
|
+
adjustedDiffPercentage: -100
|
|
695
|
+
};
|
|
696
|
+
const u = $e(t), x = Ae(u, m), g = m.amount === 0 ? null : _e(x, {
|
|
697
|
+
...m,
|
|
698
|
+
amount: Math.abs(m.amount)
|
|
699
|
+
}), P = g ? ve(g, T) : null;
|
|
700
|
+
return {
|
|
701
|
+
code: n.code,
|
|
702
|
+
name: n.name,
|
|
703
|
+
baseUnit: n.unit.abbrev,
|
|
704
|
+
baseUnitAmount: +S(t.baseAmount),
|
|
705
|
+
...t.measurementsAmounts.filter((A) => {
|
|
706
|
+
var D, C, G;
|
|
707
|
+
return (G = (C = (D = p.value) == null ? void 0 : D.get(n._id)) == null ? void 0 : C[0]) == null ? void 0 : G.includes(A.measurement.id);
|
|
708
|
+
}).reduce((A, D, C) => (A[`measurementAbbrev${C}`] = `(${D.measurement.abbrev}) × ${S(D.measurement.conversion)}`, A[`measurementAmount${C}`] = +S(D.amount), A), {}),
|
|
709
|
+
systemBalance: +S(m),
|
|
710
|
+
physicalBalance: +S(u),
|
|
711
|
+
adjustedAmount: +S(x),
|
|
712
|
+
adjustedDiffPercentage: P ? +S(we(P, 2)) : null
|
|
713
|
+
};
|
|
714
|
+
})), X = M(() => {
|
|
715
|
+
var t, m;
|
|
716
|
+
if (!e.draft) return [];
|
|
717
|
+
const n = e.draft.approvedAt ? {
|
|
718
|
+
action: `Approve at ${q(e.draft.approvedAt)}`,
|
|
719
|
+
// actionAt: props.draft.approvedAt,
|
|
720
|
+
actionBy: e.draft.approvedBy,
|
|
721
|
+
remark: e.draft.approveRemark
|
|
722
|
+
} : (t = e.draft.rejectionHistory) == null ? void 0 : t.computeFirst((u) => ({
|
|
723
|
+
action: `Reject at ${q(u.rejectedAt)}`,
|
|
724
|
+
// actionAt: e.rejectedAt,
|
|
725
|
+
actionBy: u.rejectedBy,
|
|
726
|
+
remark: u.rejectRemark
|
|
727
|
+
}));
|
|
728
|
+
return [
|
|
729
|
+
{
|
|
730
|
+
label: "Created at",
|
|
731
|
+
value: q(e.draft.createdAt)
|
|
732
|
+
},
|
|
733
|
+
{
|
|
734
|
+
label: "Created by",
|
|
735
|
+
value: e.draft.createdBy.name
|
|
736
|
+
},
|
|
737
|
+
{
|
|
738
|
+
label: "Updated at",
|
|
739
|
+
value: q(e.draft.updatedAt)
|
|
740
|
+
},
|
|
741
|
+
{
|
|
742
|
+
label: "Updated by",
|
|
743
|
+
value: e.draft.updatedBy.name
|
|
744
|
+
},
|
|
745
|
+
{
|
|
746
|
+
label: "Effective at",
|
|
747
|
+
value: q(e.draft.effectiveAt ?? e.draft.updatedAt)
|
|
748
|
+
},
|
|
749
|
+
n ? {
|
|
750
|
+
label: "Last action",
|
|
751
|
+
value: n.action
|
|
752
|
+
} : null,
|
|
753
|
+
n && n.actionBy ? {
|
|
754
|
+
label: "Last action by",
|
|
755
|
+
value: (m = n.actionBy) == null ? void 0 : m.name
|
|
756
|
+
} : null,
|
|
757
|
+
n && n.remark ? {
|
|
758
|
+
label: "Action remark",
|
|
759
|
+
value: n.remark
|
|
760
|
+
} : null
|
|
761
|
+
].filter((u) => u).map((u) => u);
|
|
762
|
+
}), ee = [
|
|
763
|
+
{
|
|
764
|
+
label: "Overview",
|
|
765
|
+
value: "overview"
|
|
766
|
+
},
|
|
767
|
+
{
|
|
768
|
+
label: "Action history",
|
|
769
|
+
value: "history"
|
|
770
|
+
}
|
|
771
|
+
], V = z(ee[0]), E = M(() => {
|
|
772
|
+
var t, m, u, x;
|
|
773
|
+
return [
|
|
774
|
+
...(((t = e.draft) == null ? void 0 : t.rejectionHistory) ?? []).map(
|
|
775
|
+
(g) => ({
|
|
776
|
+
header: "Reject",
|
|
777
|
+
date: q(g.rejectedAt),
|
|
778
|
+
info: [
|
|
779
|
+
{
|
|
780
|
+
label: "Rejected by",
|
|
781
|
+
values: [g.rejectedBy.name]
|
|
782
|
+
},
|
|
783
|
+
{
|
|
784
|
+
label: "Rejection remark",
|
|
785
|
+
values: [g.rejectRemark]
|
|
786
|
+
}
|
|
787
|
+
]
|
|
788
|
+
})
|
|
789
|
+
),
|
|
790
|
+
...(m = e.draft) != null && m.approvedBy ? [
|
|
791
|
+
{
|
|
792
|
+
header: "Approve",
|
|
793
|
+
date: e.draft.approvedAt ? q(e.draft.approvedAt) : "",
|
|
794
|
+
info: [
|
|
795
|
+
{
|
|
796
|
+
label: "Approved by",
|
|
797
|
+
values: [(u = e.draft) == null ? void 0 : u.approvedBy.name]
|
|
798
|
+
},
|
|
799
|
+
{
|
|
800
|
+
label: "Approval remark",
|
|
801
|
+
values: [((x = e.draft) == null ? void 0 : x.approveRemark) ?? ""]
|
|
802
|
+
}
|
|
803
|
+
]
|
|
804
|
+
}
|
|
805
|
+
] : []
|
|
806
|
+
];
|
|
807
|
+
});
|
|
808
|
+
return (n, t) => {
|
|
809
|
+
const m = U("FmButtonGroup"), u = U("FmMenuDivider"), x = U("FmCard"), g = U("FmButton"), P = U("FmCircularProgress"), Y = U("FmTable"), L = U("FmSpacer"), Z = U("FmSideSheet");
|
|
810
|
+
return w(), ne(Z, {
|
|
811
|
+
"dismiss-away": "",
|
|
812
|
+
"max-width": 900,
|
|
813
|
+
"model-value": b(v),
|
|
814
|
+
"onUpdate:modelValue": t[5] || (t[5] = (A) => xe(v) ? v.value = A : null),
|
|
815
|
+
header: "Closing details"
|
|
816
|
+
}, {
|
|
817
|
+
"side-sheet-footer": W(() => {
|
|
818
|
+
var A, D;
|
|
819
|
+
return [
|
|
820
|
+
o("div", Gt, [
|
|
821
|
+
((A = e.draft) == null ? void 0 : A.status) === b(oe).enum.DRAFT ? (w(), ne(g, {
|
|
822
|
+
key: 0,
|
|
823
|
+
label: "Approve",
|
|
824
|
+
onClick: t[2] || (t[2] = () => e.draft && b(d).approveDraft(e.draft, () => $("submitted")))
|
|
825
|
+
})) : te("", !0),
|
|
826
|
+
((D = e.draft) == null ? void 0 : D.status) === b(oe).enum.DRAFT ? (w(), ne(g, {
|
|
827
|
+
key: 1,
|
|
828
|
+
label: "Reject",
|
|
829
|
+
variant: "destructive",
|
|
830
|
+
onClick: t[3] || (t[3] = () => e.draft && b(d).rejectDraft(e.draft, () => $("submitted")))
|
|
831
|
+
})) : te("", !0),
|
|
832
|
+
_(g, {
|
|
833
|
+
label: "Close",
|
|
834
|
+
variant: "tertiary",
|
|
835
|
+
onClick: t[4] || (t[4] = (C) => v.value = !1)
|
|
836
|
+
})
|
|
837
|
+
])
|
|
838
|
+
];
|
|
839
|
+
}),
|
|
840
|
+
default: W(() => [
|
|
841
|
+
o("div", yt, [
|
|
842
|
+
o("div", null, [
|
|
843
|
+
_(m, {
|
|
844
|
+
items: ee,
|
|
845
|
+
modelValue: V.value,
|
|
846
|
+
"onUpdate:modelValue": t[0] || (t[0] = (A) => V.value = A)
|
|
847
|
+
}, null, 8, ["modelValue"])
|
|
848
|
+
]),
|
|
849
|
+
V.value.value === "overview" ? (w(), F(J, { key: 0 }, [
|
|
850
|
+
_(x, {
|
|
851
|
+
variant: "outlined",
|
|
852
|
+
class: "flex flex-col gap-8 px-12 py-16"
|
|
853
|
+
}, {
|
|
854
|
+
default: W(() => {
|
|
855
|
+
var A, D;
|
|
856
|
+
return [
|
|
857
|
+
o("div", bt, [
|
|
858
|
+
t[6] || (t[6] = o("div", { class: "fm-typo-en-body-lg-600" }, "Closing summary", -1)),
|
|
859
|
+
o("div", ht, [
|
|
860
|
+
o("div", {
|
|
861
|
+
class: ae(["fm-status-badge", b(Te)(((A = n.draft) == null ? void 0 : A.status) ?? "DRAFT")])
|
|
862
|
+
}, I(b(Ce)(((D = n.draft) == null ? void 0 : D.status) ?? "")), 3)
|
|
863
|
+
])
|
|
864
|
+
]),
|
|
865
|
+
_(u),
|
|
866
|
+
(w(!0), F(J, null, ce(X.value, (C, G) => (w(), F("div", {
|
|
867
|
+
class: "flex flex-col gap-4",
|
|
868
|
+
key: G
|
|
869
|
+
}, [
|
|
870
|
+
o("div", xt, [
|
|
871
|
+
o("div", Dt, I(C.label), 1)
|
|
872
|
+
]),
|
|
873
|
+
o("div", At, I(C.value), 1)
|
|
874
|
+
]))), 128))
|
|
875
|
+
];
|
|
876
|
+
}),
|
|
877
|
+
_: 1
|
|
878
|
+
}),
|
|
879
|
+
o("div", _t, [
|
|
880
|
+
o("div", wt, [
|
|
881
|
+
t[7] || (t[7] = o("div", { class: "flex-1 fm-typo-en-title-sm-600 text-fm-color-typo-primary" }, " Closing items ", -1)),
|
|
882
|
+
i.value ? te("", !0) : (w(), F("div", kt, [
|
|
883
|
+
_(g, {
|
|
884
|
+
label: "Export data",
|
|
885
|
+
"prepend-icon": "download",
|
|
886
|
+
variant: "secondary",
|
|
887
|
+
"text-color": "primary",
|
|
888
|
+
"bg-color": "transparent",
|
|
889
|
+
"border-color": "primary",
|
|
890
|
+
onClick: t[1] || (t[1] = (A) => n.draft ? b(d).exportDraft(n.draft, f.value) : null)
|
|
891
|
+
})
|
|
892
|
+
]))
|
|
893
|
+
]),
|
|
894
|
+
i.value ? (w(), F("div", Ct, [
|
|
895
|
+
t[9] || (t[9] = o("div", { class: "h-80" }, null, -1)),
|
|
896
|
+
o("div", jt, [
|
|
897
|
+
o("div", null, [
|
|
898
|
+
_(P, { size: "md" })
|
|
899
|
+
]),
|
|
900
|
+
t[8] || (t[8] = o("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Fetching info... ", -1))
|
|
901
|
+
]),
|
|
902
|
+
t[10] || (t[10] = o("div", { class: "h-80" }, null, -1))
|
|
903
|
+
])) : (w(), F("div", St, [
|
|
904
|
+
o("div", {
|
|
905
|
+
style: De({ width: `${re.value}px` })
|
|
906
|
+
}, [
|
|
907
|
+
_(Y, {
|
|
908
|
+
"column-defs": K.value,
|
|
909
|
+
"row-data": le.value
|
|
910
|
+
}, null, 8, ["column-defs", "row-data"])
|
|
911
|
+
], 4)
|
|
912
|
+
]))
|
|
913
|
+
])
|
|
914
|
+
], 64)) : te("", !0),
|
|
915
|
+
V.value.value === "history" ? (w(), F("div", Bt, [
|
|
916
|
+
E.value.length ? (w(), F("div", Rt, [
|
|
917
|
+
(w(!0), F(J, null, ce(E.value, (A, D) => (w(), F(J, { key: D }, [
|
|
918
|
+
o("div", Tt, [
|
|
919
|
+
o("div", Mt, [
|
|
920
|
+
o("div", Pt, [
|
|
921
|
+
o("div", {
|
|
922
|
+
class: ae([
|
|
923
|
+
{
|
|
924
|
+
"bg-fm-color-primary": D !== 0,
|
|
925
|
+
"bg-white": D === 0
|
|
926
|
+
},
|
|
927
|
+
"w-[2px] h-full"
|
|
928
|
+
])
|
|
929
|
+
}, null, 2)
|
|
930
|
+
]),
|
|
931
|
+
t[13] || (t[13] = o("div", { class: "h-24 w-24 bg-fm-color-primary rounded-full" }, null, -1)),
|
|
932
|
+
o("div", Ut, [
|
|
933
|
+
o("div", {
|
|
934
|
+
class: ae([
|
|
935
|
+
{
|
|
936
|
+
"bg-fm-color-primary": D < E.value.length - 1,
|
|
937
|
+
"bg-white": D >= E.value.length - 1
|
|
938
|
+
},
|
|
939
|
+
"w-[2px] h-full"
|
|
940
|
+
])
|
|
941
|
+
}, null, 2)
|
|
942
|
+
])
|
|
943
|
+
]),
|
|
944
|
+
o("div", Ht, [
|
|
945
|
+
o("div", It, I(A.header), 1),
|
|
946
|
+
o("div", zt, I(A.date), 1)
|
|
947
|
+
])
|
|
948
|
+
]),
|
|
949
|
+
o("div", Et, [
|
|
950
|
+
o("div", Lt, [
|
|
951
|
+
o("div", Nt, [
|
|
952
|
+
o("div", {
|
|
953
|
+
class: ae([
|
|
954
|
+
{
|
|
955
|
+
"bg-fm-color-primary": D < E.value.length - 1,
|
|
956
|
+
"bg-white": D >= E.value.length - 1
|
|
957
|
+
},
|
|
958
|
+
"w-[2px] h-full"
|
|
959
|
+
])
|
|
960
|
+
}, null, 2)
|
|
961
|
+
])
|
|
962
|
+
]),
|
|
963
|
+
o("div", Ot, [
|
|
964
|
+
_(x, {
|
|
965
|
+
variant: "outlined",
|
|
966
|
+
class: "py-12 px-16"
|
|
967
|
+
}, {
|
|
968
|
+
default: W(() => [
|
|
969
|
+
o("div", Kt, [
|
|
970
|
+
(w(!0), F(J, null, ce(A.info, (C, G) => (w(), F("div", {
|
|
971
|
+
key: G,
|
|
972
|
+
class: "flex flex-col gap-4"
|
|
973
|
+
}, [
|
|
974
|
+
o("div", Vt, I(C == null ? void 0 : C.label), 1),
|
|
975
|
+
o("div", Yt, [
|
|
976
|
+
(w(!0), F(J, null, ce(C == null ? void 0 : C.values, (Me, Pe) => (w(), F("div", {
|
|
977
|
+
key: Pe,
|
|
978
|
+
class: "fm-typo-en-body-lg-600"
|
|
979
|
+
}, I(Me), 1))), 128))
|
|
980
|
+
])
|
|
981
|
+
]))), 128))
|
|
982
|
+
])
|
|
983
|
+
]),
|
|
984
|
+
_: 2
|
|
985
|
+
}, 1024)
|
|
986
|
+
])
|
|
987
|
+
])
|
|
988
|
+
], 64))), 128))
|
|
989
|
+
])) : (w(), F("div", Ft, [
|
|
990
|
+
_(L),
|
|
991
|
+
o("div", null, [
|
|
992
|
+
o("img", {
|
|
993
|
+
src: b(st),
|
|
994
|
+
alt: "List is empty"
|
|
995
|
+
}, null, 8, $t)
|
|
996
|
+
]),
|
|
997
|
+
t[11] || (t[11] = o("div", { class: "fm-typo-en-body-lg-600" }, I("No records found"), -1)),
|
|
998
|
+
t[12] || (t[12] = o("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary px-16" }, I("You can track approval and rejection history here"), -1)),
|
|
999
|
+
_(L),
|
|
1000
|
+
_(L)
|
|
1001
|
+
]))
|
|
1002
|
+
])) : te("", !0)
|
|
1003
|
+
])
|
|
1004
|
+
]),
|
|
1005
|
+
_: 1
|
|
1006
|
+
}, 8, ["model-value"]);
|
|
1007
|
+
};
|
|
1008
|
+
}
|
|
1009
|
+
}), Wt = { class: "flex-1 flex flex-col gap-8" }, Zt = { class: "flex flex-col" }, Jt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Qt = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Xt = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-2" }, ea = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, ca = /* @__PURE__ */ fe({
|
|
1010
|
+
__name: "ClosingDraftView",
|
|
1011
|
+
setup(a) {
|
|
1012
|
+
const { t: l } = je(), { viewDraft: e } = me(), { viewClosingDraftProps: c, viewClosingDraftShow: d } = ot(me()), v = pe(), i = gt(), f = Ze(), { breakpoints: y } = nt();
|
|
1013
|
+
v.watchLocation(i.fetchDrafts);
|
|
1014
|
+
const B = M(() => i.loading), R = z(""), $ = M(() => y.value.xs || y.value.sm), r = M(() => $.value ? 10 : 20);
|
|
1015
|
+
function s(T) {
|
|
1016
|
+
switch (T) {
|
|
1017
|
+
case "refresh":
|
|
1018
|
+
return i.fetchDrafts();
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
function p(T) {
|
|
1022
|
+
return T;
|
|
1023
|
+
}
|
|
1024
|
+
const H = M(() => $.value ? [
|
|
1025
|
+
{
|
|
1026
|
+
label: "Refresh",
|
|
1027
|
+
value: "refresh",
|
|
1028
|
+
isPrimary: !1
|
|
1029
|
+
}
|
|
1030
|
+
] : [
|
|
1031
|
+
{
|
|
1032
|
+
label: "Refresh",
|
|
1033
|
+
value: "refresh",
|
|
1034
|
+
isPrimary: !1
|
|
1035
|
+
}
|
|
1036
|
+
]);
|
|
1037
|
+
return (T, j) => {
|
|
1038
|
+
const Q = U("FmTable");
|
|
1039
|
+
return w(), F(J, null, [
|
|
1040
|
+
_(Je, {
|
|
1041
|
+
title: b(l)("inventory.closing.draft.title"),
|
|
1042
|
+
actions: H.value,
|
|
1043
|
+
"onClick:action": s
|
|
1044
|
+
}, {
|
|
1045
|
+
default: W(() => [
|
|
1046
|
+
o("div", {
|
|
1047
|
+
class: ae([
|
|
1048
|
+
"flex flex-col gap-8 max-h-full",
|
|
1049
|
+
{
|
|
1050
|
+
"p-0": $.value,
|
|
1051
|
+
"px-24 ": !$.value
|
|
1052
|
+
}
|
|
1053
|
+
])
|
|
1054
|
+
}, [
|
|
1055
|
+
_(Qe, {
|
|
1056
|
+
"change-location": "",
|
|
1057
|
+
searchable: "",
|
|
1058
|
+
search: R.value,
|
|
1059
|
+
"onUpdate:search": j[0] || (j[0] = (h) => R.value = h)
|
|
1060
|
+
}, null, 8, ["search"]),
|
|
1061
|
+
_(Q, {
|
|
1062
|
+
style: De(b(f).tableHeight),
|
|
1063
|
+
"column-defs": b(i).columnDefs,
|
|
1064
|
+
"row-data": b(i).drafts,
|
|
1065
|
+
"search-value": R.value,
|
|
1066
|
+
loading: B.value,
|
|
1067
|
+
onRowClick: j[1] || (j[1] = (h) => b(e)(h.original)),
|
|
1068
|
+
"page-size": r.value
|
|
1069
|
+
}, {
|
|
1070
|
+
"list-row": W((h) => [
|
|
1071
|
+
_(Xe, {
|
|
1072
|
+
row: h,
|
|
1073
|
+
onRowClick: (k) => b(e)(k)
|
|
1074
|
+
}, {
|
|
1075
|
+
default: W((k) => {
|
|
1076
|
+
var K, re, le, X, ee, V, E, n, t, m, u, x, g, P, Y, L, Z, A, D, C;
|
|
1077
|
+
return [
|
|
1078
|
+
o("div", Wt, [
|
|
1079
|
+
o("div", Zt, [
|
|
1080
|
+
o("div", Jt, [
|
|
1081
|
+
_(b(ue), {
|
|
1082
|
+
render: (le = (re = (K = k._id) == null ? void 0 : K.column) == null ? void 0 : re.columnDef) == null ? void 0 : le.cell,
|
|
1083
|
+
props: (ee = (X = k._id) == null ? void 0 : X.getContext) == null ? void 0 : ee.call(X)
|
|
1084
|
+
}, null, 8, ["render", "props"])
|
|
1085
|
+
]),
|
|
1086
|
+
o("div", Qt, [
|
|
1087
|
+
_(b(ue), {
|
|
1088
|
+
render: (n = (E = (V = k.name) == null ? void 0 : V.column) == null ? void 0 : E.columnDef) == null ? void 0 : n.cell,
|
|
1089
|
+
props: (m = (t = k.name) == null ? void 0 : t.getContext) == null ? void 0 : m.call(t)
|
|
1090
|
+
}, null, 8, ["render", "props"])
|
|
1091
|
+
]),
|
|
1092
|
+
o("div", Xt, I([
|
|
1093
|
+
...h.original.items.slice(0, 3).map((G) => G.sku.name),
|
|
1094
|
+
...h.original.items.length >= 3 ? [`and ${h.original.items.length - 3} more items`] : []
|
|
1095
|
+
].join(", ")), 1),
|
|
1096
|
+
o("div", ea, [
|
|
1097
|
+
_(b(ue), {
|
|
1098
|
+
render: (g = (x = (u = k.ref) == null ? void 0 : u.column) == null ? void 0 : x.columnDef) == null ? void 0 : g.cell,
|
|
1099
|
+
props: (Y = (P = k.ref) == null ? void 0 : P.getContext) == null ? void 0 : Y.call(P)
|
|
1100
|
+
}, null, 8, ["render", "props"])
|
|
1101
|
+
])
|
|
1102
|
+
]),
|
|
1103
|
+
o("div", null, [
|
|
1104
|
+
_(b(ue), {
|
|
1105
|
+
render: (A = (Z = (L = k.status) == null ? void 0 : L.column) == null ? void 0 : Z.columnDef) == null ? void 0 : A.cell,
|
|
1106
|
+
props: (C = (D = k.status) == null ? void 0 : D.getContext) == null ? void 0 : C.call(D)
|
|
1107
|
+
}, null, 8, ["render", "props"])
|
|
1108
|
+
])
|
|
1109
|
+
])
|
|
1110
|
+
];
|
|
1111
|
+
}),
|
|
1112
|
+
_: 2
|
|
1113
|
+
}, 1032, ["row", "onRowClick"])
|
|
1114
|
+
]),
|
|
1115
|
+
_: 1
|
|
1116
|
+
}, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"])
|
|
1117
|
+
], 2)
|
|
1118
|
+
]),
|
|
1119
|
+
_: 1
|
|
1120
|
+
}, 8, ["title", "actions"]),
|
|
1121
|
+
(w(), ne(Ie, { to: "body" }, [
|
|
1122
|
+
_(qt, ze(b(c), {
|
|
1123
|
+
show: b(d),
|
|
1124
|
+
"onUpdate:show": j[2] || (j[2] = (h) => xe(d) ? d.value = h : null),
|
|
1125
|
+
onSubmitted: j[3] || (j[3] = () => (d.value = !1, b(i).fetchDrafts()))
|
|
1126
|
+
}), null, 16, ["show"])
|
|
1127
|
+
]))
|
|
1128
|
+
], 64);
|
|
1129
|
+
};
|
|
1130
|
+
}
|
|
1131
|
+
});
|
|
1132
|
+
export {
|
|
1133
|
+
ca as default
|
|
1134
|
+
};
|