@feedmepos/mf-inventory-portal 1.2.46-dev.4 → 1.2.46-dev.5
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-EK7lJDXt.js → App-DsW9zwH-.js} +3 -3
- package/dist/{ApprovalView-5wa67Pp2.js → ApprovalView-Dvyp3wel.js} +5 -5
- package/dist/{BindingsDialog-DNvqgfca.js → BindingsDialog-YBp__WSV.js} +2 -2
- package/dist/{BindingsPicker-B0In-fby.js → BindingsPicker-DlBjt-Ba.js} +2 -2
- package/dist/{BindingsTable-Dnj3lmqy.js → BindingsTable-CTRzUUB-.js} +3 -3
- package/dist/ClosingDraftView-6c7X_KiP.js +2410 -0
- package/dist/{ClosingHistoryView-CIzyFAlH.js → ClosingHistoryView-bOwlkF4Q.js} +3 -3
- package/dist/{ClosingTemplateView-6HX9oUcC.js → ClosingTemplateView-CA-f8FAh.js} +14 -14
- package/dist/{DeliveryOrderPrintPreview-MWn3Ar1T.js → DeliveryOrderPrintPreview-DmjK4cj3.js} +1 -1
- package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-C7YYLOYE.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-B813CRxg.js} +4 -4
- package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-CQiU_sGW.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-lgr6bbOW.js} +2 -2
- package/dist/{FmMultiselectDialog-BkjI4JGz.js → FmMultiselectDialog-26pdE-k-.js} +1 -1
- package/dist/{FmMultiselectDialog-CtiU1Dtg.js → FmMultiselectDialog-72g5JwZ9.js} +2 -2
- package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-LyzPCbxS.js → FmUnitInput.vue_vue_type_script_setup_true_lang-CQAnQxH8.js} +3 -3
- package/dist/{ImportView-7iS_eKvv.js → ImportView-4mjAMfeB.js} +6 -6
- package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-BgY8Q64y.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-CDodN-Rh.js} +1 -1
- package/dist/{IngredientGroupView-_U4bC7ki.js → IngredientGroupView-DmcHEj63.js} +5 -5
- package/dist/{IngredientsView-vNdlqPpT.js → IngredientsView-BDPANb85.js} +14 -14
- package/dist/{IntegrationView-cWl5050X.js → IntegrationView-pyqYL2jb.js} +12 -12
- package/dist/{InventoryBindingForm-Bze5ZhbJ.js → InventoryBindingForm-DSbRfb3F.js} +1 -1
- package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-CouXpFs-.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-KfPb4N5d.js} +4 -4
- package/dist/{InventoryBindingSummary-4bU5QfqT.js → InventoryBindingSummary-BcGBSNvn.js} +1 -1
- package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BpELQhv-.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-Dgauy-iB.js} +1 -1
- package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-CG5hkfB7.js → PremiumBadge.vue_vue_type_script_setup_true_lang-B53Hy6EY.js} +2 -2
- package/dist/{PublishView-Dl2oTfzU.js → PublishView-CJBqs89f.js} +3 -3
- package/dist/{PurchaseOrderPrintPreview-GQjxju0E.js → PurchaseOrderPrintPreview-BKvf3c7F.js} +1 -1
- package/dist/{ReceiveRequestView-B9aW_X5r.js → ReceiveRequestView-DwclAVDm.js} +18 -18
- package/dist/{RecipeView-BRtYb-YG.js → RecipeView-CYIOyih-.js} +8 -8
- package/dist/{StockView-BA2ZFlTp.js → StockView-loAHU_aR.js} +15 -15
- package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-g4FkX2mO.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-CNIpGt9s.js} +1 -1
- package/dist/{SupplierView-CmvDHCn1.js → SupplierView-D0h-AaRw.js} +11 -11
- package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-COP5SYtT.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-D1UE7aKR.js} +2 -2
- package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-Cs93Vtov.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-DhqGYaf-.js} +1 -1
- package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-De-0zviY.js → TransferDetails.vue_vue_type_script_setup_true_lang-D-g6cXC3.js} +14 -14
- package/dist/{TransferTemplateView-CJnlocMY.js → TransferTemplateView-dvekbFPc.js} +412 -412
- package/dist/{UnitView-BL9YToD9.js → UnitView-BJPDHJ1t.js} +6 -6
- package/dist/{WarehouseView-C83stFZt.js → WarehouseView-DfBC9bn5.js} +5 -5
- package/dist/{WastageTemplateView-BBZH-mKL.js → WastageTemplateView-D7txOfrr.js} +14 -14
- package/dist/{app-C41vbTKc.js → app-DZ9CIN-l.js} +22 -22
- package/dist/app.js +1 -1
- package/dist/{closing-template-Cgnip54N.js → closing-template-Bhuuo6RL.js} +1 -1
- package/dist/{date2-CMZo42ry.js → date2-D0I4_co0.js} +1 -1
- package/dist/{dayjs.min-VxvOpK4l.js → dayjs.min-DyYDX3Ns.js} +1 -1
- package/dist/{decimal-Bny34Eba.js → decimal-CpLUQcWa.js} +2 -2
- package/dist/{defineDeepModel-BAFlxgb7.js → defineDeepModel-CBc_F4eu.js} +1 -1
- package/dist/{duplicate-template-BtuFXv7t.js → duplicate-template-BIMQgrkD.js} +1 -1
- package/dist/{feature-DLwvVno7.js → feature-CjK6Ds77.js} +2 -2
- package/dist/{format-time-from-id-CZXW775p.js → format-time-from-id-9kP1kaTe.js} +1 -1
- package/dist/{format-unit-display-DuO3ios0.js → format-unit-display-De_mv7m7.js} +10 -10
- package/dist/{import-export.helper-C_pu3Vto.js → import-export.helper-BcEjyb3B.js} +5 -5
- package/dist/{index-B0PBI5Di.js → index-B1bw59a2.js} +1 -1
- package/dist/{index-GSUBHLP8.js → index-BcRb-JAY.js} +3 -3
- package/dist/{index-BprWbUJy.js → index-CJRR1JAe.js} +1 -1
- package/dist/{lodash-hzb22w2h.js → lodash-AfG_nKQX.js} +1 -1
- package/dist/{netsuite-yK572svg.js → netsuite-d7P730Bm.js} +3 -3
- package/dist/{purchase-order-template-CAmTt86P.js → purchase-order-template-J9nWMrS2.js} +1 -1
- package/dist/{rules-D2ifX1qj.js → rules-9v8VtDWl.js} +3 -3
- package/dist/{stock-BS7XBKNg.js → stock-C2_qYIxU.js} +1 -1
- package/dist/{stock-S6w8LDdV.js → stock-Cjj5e8_a.js} +3 -3
- package/dist/{supplier-CAFKaGyu.js → supplier-Ds2vZ4qg.js} +2 -2
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/dist/{use-ingredient-select-dialog-DuNV0Qev.js → use-ingredient-select-dialog-CAKpgkQ9.js} +2 -2
- package/dist/{use-inventory-binding-dialog-CXnHmvy1.js → use-inventory-binding-dialog-D98L2Cuv.js} +2 -2
- package/dist/{use-template-enabled-locations-2-gzV64awF.js → use-template-enabled-locations-2-DrUrir8n.js} +2 -2
- package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftApprovalDialog.vue.d.ts +2 -10
- package/dist/{vue-i18n-ChDJFBbd.js → vue-i18n-CNwuZJlQ.js} +258 -258
- package/dist/{xlsx-RW9YZaa8.js → xlsx-BfWdatQl.js} +1 -1
- package/dist/{xlsx.util-D-mF9Cdj.js → xlsx.util-sMO_ulne.js} +1 -1
- package/package.json +3 -3
- package/dist/ClosingDraftView-DMeJEGFR.js +0 -2372
|
@@ -1,2372 +0,0 @@
|
|
|
1
|
-
import { defineComponent as Re, ref as Y, computed as M, onMounted as et, resolveComponent as K, openBlock as F, createElementBlock as P, Fragment as oe, createTextVNode as re, createBlock as ce, withCtx as O, createElementVNode as s, toDisplayString as Z, unref as g, createVNode as k, createCommentVNode as J, h as B, watch as ze, renderList as $e, reactive as Mt, isRef as bt, normalizeClass as Be, normalizeStyle as ht, Teleport as Lt, mergeProps as Nt } from "vue";
|
|
2
|
-
import { F as Je, u as Et, _ as zt } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-CWZkVCAj.js";
|
|
3
|
-
import { useCoreStore as kt, useI18n as _t } from "@feedmepos/mf-common";
|
|
4
|
-
import { useSnackbar as tt, useDialog as Ht, components as ge, useProxiedModel as Ot, useBreakpoints as Kt } from "@feedmepos/ui-library";
|
|
5
|
-
import { o as Yt, u as qe, I as Q, s as E, J as Dt, K as be, A as He, v as Oe, c as Qt, a as qt } from "./app-C41vbTKc.js";
|
|
6
|
-
import { defineStore as xt, storeToRefs as Gt } from "pinia";
|
|
7
|
-
import { d as Ye, e as At, f as Wt, a as ye } from "./date2-CMZo42ry.js";
|
|
8
|
-
import { R as Zt, f as at, a as Xe, t as Jt, d as Ue, o as St, p as wt, m as Ft, l as Xt } from "./rules-D2ifX1qj.js";
|
|
9
|
-
import { b as ea, d as ta } from "./xlsx.util-D-mF9Cdj.js";
|
|
10
|
-
import { u as Ct } from "./stock-S6w8LDdV.js";
|
|
11
|
-
import { u as nt } from "./stock-BS7XBKNg.js";
|
|
12
|
-
import { D as yt, R as Ce } from "./row-action.enum-BcW_L_nE.js";
|
|
13
|
-
import { c as aa, _ as na, F as Ee } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-cfFHDIwQ.js";
|
|
14
|
-
import { f as oa } from "./format-time-from-id-CZXW775p.js";
|
|
15
|
-
import { _ as sa } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-CQiU_sGW.js";
|
|
16
|
-
import { E as ra } from "./empty-placeholder-wf6-BWE8.js";
|
|
17
|
-
import { u as la } from "./vue-i18n-ChDJFBbd.js";
|
|
18
|
-
const Ge = Yt((i, r) => {
|
|
19
|
-
function e() {
|
|
20
|
-
return qe().currentLocation.dbName;
|
|
21
|
-
}
|
|
22
|
-
return {
|
|
23
|
-
async getDraft(d) {
|
|
24
|
-
const _ = e(), y = `${i.inventoryBackendUrl}/${_}/closing-draft/${d}`;
|
|
25
|
-
return r.get(y);
|
|
26
|
-
},
|
|
27
|
-
async readDrafts() {
|
|
28
|
-
const d = e(), _ = `${i.inventoryBackendUrl}/${d}/closing-draft`;
|
|
29
|
-
return r.get(_);
|
|
30
|
-
},
|
|
31
|
-
async runOperation(d) {
|
|
32
|
-
const _ = e(), y = `${i.inventoryBackendUrl}/${_}/closing-draft/run-operation`;
|
|
33
|
-
return r.post(y, d);
|
|
34
|
-
},
|
|
35
|
-
async runOperationV1(d) {
|
|
36
|
-
const _ = e(), y = `${i.inventoryBackendUrl}/${_}/closing-draft/v1/run-operation`;
|
|
37
|
-
return r.post(y, d);
|
|
38
|
-
},
|
|
39
|
-
async sync(d) {
|
|
40
|
-
const _ = e(), y = `${i.inventoryBackendUrl}/${_}/closing-draft/sync`;
|
|
41
|
-
return r.post(y, d);
|
|
42
|
-
},
|
|
43
|
-
async cloneDraft(d) {
|
|
44
|
-
const _ = e(), y = `${i.inventoryBackendUrl}/${_}/closing-draft/${d}/clone`;
|
|
45
|
-
return r.post(y, {});
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
}), ia = { class: "fm-typo-en-body-lg-400" }, ca = { class: "fm-typo-en-body-lg-600" }, ua = {
|
|
49
|
-
key: 0,
|
|
50
|
-
class: "flex flex-col"
|
|
51
|
-
}, da = {
|
|
52
|
-
key: 0,
|
|
53
|
-
class: "fm-typo-en-body-sm-400 text-fm-color-typo-error mt-4"
|
|
54
|
-
}, ma = { class: "flex gap-12 py-8 justify-end w-full" }, Ze = /* @__PURE__ */ Re({
|
|
55
|
-
__name: "ClosingDraftAction",
|
|
56
|
-
props: {
|
|
57
|
-
draft: {},
|
|
58
|
-
action: {},
|
|
59
|
-
onCancel: { type: Function },
|
|
60
|
-
onFinished: { type: Function }
|
|
61
|
-
},
|
|
62
|
-
setup(i) {
|
|
63
|
-
const r = i, e = Y(), d = Ge(), _ = tt(), y = Y(!1), f = Y(null), j = Y(!1), V = M(() => {
|
|
64
|
-
switch (r.action) {
|
|
65
|
-
case Q.enum.approveDraft:
|
|
66
|
-
return "Approve";
|
|
67
|
-
case Q.enum.rejectDraft:
|
|
68
|
-
return "Reject";
|
|
69
|
-
case Q.enum.markAsFailed:
|
|
70
|
-
return "Mark as Failed";
|
|
71
|
-
}
|
|
72
|
-
throw new Error(`Unknown action: ${r.action}`);
|
|
73
|
-
}), T = M(() => {
|
|
74
|
-
switch (r.action) {
|
|
75
|
-
case Q.enum.approveDraft:
|
|
76
|
-
return "primary";
|
|
77
|
-
case Q.enum.rejectDraft:
|
|
78
|
-
return "destructive";
|
|
79
|
-
case Q.enum.markAsFailed:
|
|
80
|
-
return "destructive";
|
|
81
|
-
}
|
|
82
|
-
throw new Error(`Unknown action: ${r.action}`);
|
|
83
|
-
});
|
|
84
|
-
et(() => {
|
|
85
|
-
if (r.draft.effectiveAt)
|
|
86
|
-
f.value = new Date(r.draft.effectiveAt);
|
|
87
|
-
else {
|
|
88
|
-
const m = new Date(r.draft.createdAt);
|
|
89
|
-
m.setHours(23, 59, 59, 999), f.value = m;
|
|
90
|
-
}
|
|
91
|
-
j.value = !0;
|
|
92
|
-
});
|
|
93
|
-
const x = M({
|
|
94
|
-
get() {
|
|
95
|
-
return f.value === null ? "" : Ye(f.value);
|
|
96
|
-
},
|
|
97
|
-
set(m) {
|
|
98
|
-
if (m) {
|
|
99
|
-
const t = /* @__PURE__ */ new Date(`${m} ${D.value}`);
|
|
100
|
-
t.setSeconds(59, 999), f.value = t;
|
|
101
|
-
} else
|
|
102
|
-
f.value = null;
|
|
103
|
-
}
|
|
104
|
-
}), D = M({
|
|
105
|
-
get() {
|
|
106
|
-
return f.value === null ? "" : At(f.value);
|
|
107
|
-
},
|
|
108
|
-
set(m) {
|
|
109
|
-
if (m) {
|
|
110
|
-
const t = /* @__PURE__ */ new Date(`${x.value} ${m}`);
|
|
111
|
-
t.setSeconds(59, 999), f.value = t;
|
|
112
|
-
} else
|
|
113
|
-
f.value = null;
|
|
114
|
-
}
|
|
115
|
-
}), I = M(() => f.value ? f.value.getTime() > (/* @__PURE__ */ new Date()).getTime() : !1);
|
|
116
|
-
async function W(m) {
|
|
117
|
-
y.value = !0;
|
|
118
|
-
try {
|
|
119
|
-
m ? await d.runOperationV1({
|
|
120
|
-
_id: r.draft._id,
|
|
121
|
-
_rev: r.draft._rev ?? "",
|
|
122
|
-
action: r.action,
|
|
123
|
-
data: {
|
|
124
|
-
effectiveAt: f.value ? f.value.toISOString() : null,
|
|
125
|
-
remark: e.value
|
|
126
|
-
}
|
|
127
|
-
}).delayed(500) : await d.runOperation({
|
|
128
|
-
_id: r.draft._id,
|
|
129
|
-
_rev: r.draft._rev ?? "",
|
|
130
|
-
action: r.action,
|
|
131
|
-
data: {
|
|
132
|
-
effectiveAt: f.value ? f.value.toISOString() : null,
|
|
133
|
-
remark: e.value
|
|
134
|
-
}
|
|
135
|
-
}).delayed(500), _.open({
|
|
136
|
-
title: "Success",
|
|
137
|
-
message: "Action submitted",
|
|
138
|
-
type: "success"
|
|
139
|
-
}), r.onFinished();
|
|
140
|
-
} catch (t) {
|
|
141
|
-
_.open({
|
|
142
|
-
title: "Something went wrong",
|
|
143
|
-
message: (t == null ? void 0 : t.message) ?? "Unable to submit action. Please try again",
|
|
144
|
-
type: "error"
|
|
145
|
-
}), console.error("error on submit closing draft action", t);
|
|
146
|
-
} finally {
|
|
147
|
-
y.value = !1;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
return (m, t) => {
|
|
151
|
-
const S = K("FmLabel"), R = K("FmDatePicker"), z = K("FmTimePicker"), h = K("FmTextField"), p = K("FmButton"), w = K("FmForm");
|
|
152
|
-
return j.value ? (F(), ce(w, {
|
|
153
|
-
key: 1,
|
|
154
|
-
onValidationSuccess: W,
|
|
155
|
-
class: "flex flex-col gap-32",
|
|
156
|
-
disabled: y.value
|
|
157
|
-
}, {
|
|
158
|
-
default: O(() => [
|
|
159
|
-
s("div", ia, [
|
|
160
|
-
t[5] || (t[5] = re(" You are about to ")),
|
|
161
|
-
s("span", ca, Z(V.value), 1),
|
|
162
|
-
t[6] || (t[6] = re(" this draft. Please provide a remark to justify this action. "))
|
|
163
|
-
]),
|
|
164
|
-
m.action === g(Q).enum.approveDraft ? (F(), P("div", ua, [
|
|
165
|
-
k(S, { class: "fm-typo-en-body-lg-600" }, {
|
|
166
|
-
default: O(() => t[7] || (t[7] = [
|
|
167
|
-
re("Closing Date")
|
|
168
|
-
])),
|
|
169
|
-
_: 1
|
|
170
|
-
}),
|
|
171
|
-
k(R, {
|
|
172
|
-
modelValue: x.value,
|
|
173
|
-
"onUpdate:modelValue": t[0] || (t[0] = (H) => x.value = H),
|
|
174
|
-
max: g(Ye)(/* @__PURE__ */ new Date())
|
|
175
|
-
}, null, 8, ["modelValue", "max"]),
|
|
176
|
-
k(S, { class: "fm-typo-en-body-lg-600" }, {
|
|
177
|
-
default: O(() => t[8] || (t[8] = [
|
|
178
|
-
re("Closing Time")
|
|
179
|
-
])),
|
|
180
|
-
_: 1
|
|
181
|
-
}),
|
|
182
|
-
k(z, {
|
|
183
|
-
modelValue: D.value,
|
|
184
|
-
"onUpdate:modelValue": t[1] || (t[1] = (H) => D.value = H)
|
|
185
|
-
}, null, 8, ["modelValue"]),
|
|
186
|
-
I.value ? (F(), P("div", da, " Cannot select future date ")) : J("", !0)
|
|
187
|
-
])) : J("", !0),
|
|
188
|
-
k(h, {
|
|
189
|
-
modelValue: e.value,
|
|
190
|
-
"onUpdate:modelValue": t[2] || (t[2] = (H) => e.value = H),
|
|
191
|
-
label: "Remark",
|
|
192
|
-
"label-mark": "required",
|
|
193
|
-
rules: [g(Zt)()]
|
|
194
|
-
}, null, 8, ["modelValue", "rules"]),
|
|
195
|
-
s("div", ma, [
|
|
196
|
-
k(p, {
|
|
197
|
-
label: "Cancel",
|
|
198
|
-
variant: "tertiary",
|
|
199
|
-
onClick: t[3] || (t[3] = (H) => m.onCancel())
|
|
200
|
-
}),
|
|
201
|
-
m.action === g(Q).enum.approveDraft ? (F(), ce(Je, { key: 0 }, {
|
|
202
|
-
default: O(() => [
|
|
203
|
-
k(p, {
|
|
204
|
-
label: "Approve (Legacy)",
|
|
205
|
-
type: "button",
|
|
206
|
-
onClick: t[4] || (t[4] = (H) => W(!0)),
|
|
207
|
-
variant: T.value,
|
|
208
|
-
loading: y.value,
|
|
209
|
-
disabled: I.value
|
|
210
|
-
}, null, 8, ["variant", "loading", "disabled"])
|
|
211
|
-
]),
|
|
212
|
-
_: 1
|
|
213
|
-
})) : J("", !0),
|
|
214
|
-
k(p, {
|
|
215
|
-
label: V.value,
|
|
216
|
-
type: "submit",
|
|
217
|
-
variant: T.value,
|
|
218
|
-
loading: y.value
|
|
219
|
-
}, null, 8, ["label", "variant", "loading"])
|
|
220
|
-
])
|
|
221
|
-
]),
|
|
222
|
-
_: 1
|
|
223
|
-
}, 8, ["disabled"])) : (F(), P(oe, { key: 0 }, [
|
|
224
|
-
re("Loading")
|
|
225
|
-
], 64));
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
}), fa = Ue(0);
|
|
229
|
-
function $t(i) {
|
|
230
|
-
const r = i.measurementsAmounts.groupBy((d) => d.measurement.id), e = i.sku.unit.measurements.reduce((d, _) => {
|
|
231
|
-
var j, V;
|
|
232
|
-
const y = ((V = (j = r.get(_.id)) == null ? void 0 : j[0]) == null ? void 0 : V.amount) ?? fa, f = at(_.conversion, y);
|
|
233
|
-
return d + +Xe(f);
|
|
234
|
-
}, +Xe(i.baseAmount));
|
|
235
|
-
return Jt(e, i.baseAmount.precision);
|
|
236
|
-
}
|
|
237
|
-
const pa = Ue(0), va = Ue(100), Bt = "N/A";
|
|
238
|
-
function ga(i, r, e, d, _, y) {
|
|
239
|
-
var q, C, b, G, ne;
|
|
240
|
-
const f = $t(i), j = d ?? f, V = St(j, r), T = r.amount === 0 ? null : wt(V, {
|
|
241
|
-
...r,
|
|
242
|
-
amount: Math.abs(r.amount)
|
|
243
|
-
}), x = T ? at(T, va) : null, D = ((q = i.sku.defaultCost) == null ? void 0 : q.costPerUnit) ?? { amount: 0, precision: 0 }, I = Number(E.toFormatString({ value: D })), W = ((b = (C = i.sku.defaultCost) == null ? void 0 : C.measurement) == null ? void 0 : b.conversion) ?? {
|
|
244
|
-
amount: 1,
|
|
245
|
-
precision: 0
|
|
246
|
-
}, m = Number(
|
|
247
|
-
E.toFormatString({ value: W })
|
|
248
|
-
), t = _ ? Number(E.toFormatString({ value: _ })) : 0, S = Number(E.toFormatString({ value: r })), R = Number(E.toFormatString({ value: j })), z = S - R, h = z * I / m, p = R * I / m, w = S * I / m;
|
|
249
|
-
return {
|
|
250
|
-
code: i.sku.code,
|
|
251
|
-
name: i.sku.name,
|
|
252
|
-
baseUnit: i.sku.unit.abbrev,
|
|
253
|
-
costUnit: ((ne = (G = i.sku.defaultCost) == null ? void 0 : G.measurement) == null ? void 0 : ne.abbrev) ?? null,
|
|
254
|
-
baseUnitAmount: Number(E.toFormatString({ value: i.baseAmount })),
|
|
255
|
-
...i.measurementsAmounts.filter(
|
|
256
|
-
(se) => ya(se.measurement) && e.includes(se.measurement.id)
|
|
257
|
-
).reduce(
|
|
258
|
-
(se, le, me) => (se[`measurementAbbrev${me}`] = `(${le.measurement.abbrev}) × ${E.toFormatString({ value: le.measurement.conversion })}`, se[`measurementAmount${me}`] = Number(E.toFormatString({ value: le.amount })), se),
|
|
259
|
-
{}
|
|
260
|
-
),
|
|
261
|
-
systemBalance: S,
|
|
262
|
-
physicalBalance: R,
|
|
263
|
-
adjustedAmount: Number(E.toFormatString({ value: V })),
|
|
264
|
-
adjustedDiffPercentage: x ? Number(
|
|
265
|
-
E.toFormatString({
|
|
266
|
-
value: Ft(x, 2)
|
|
267
|
-
})
|
|
268
|
-
) : null,
|
|
269
|
-
costPerUnit: I,
|
|
270
|
-
opening: t,
|
|
271
|
-
adjustmentTypes: y ?? Bt,
|
|
272
|
-
varianceQty: z,
|
|
273
|
-
varianceInCost: h,
|
|
274
|
-
stockTakeValue: p,
|
|
275
|
-
systemValue: w
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
function ya(i) {
|
|
279
|
-
return !i.abbrev.toLocaleLowerCase().includes("inactive");
|
|
280
|
-
}
|
|
281
|
-
function ba(i) {
|
|
282
|
-
const r = Tt(i);
|
|
283
|
-
return i.reduce(
|
|
284
|
-
(e, d) => {
|
|
285
|
-
var _;
|
|
286
|
-
return Math.max(e, ((_ = r == null ? void 0 : r.get(d.sku._id)) == null ? void 0 : _[0].length) ?? 0);
|
|
287
|
-
},
|
|
288
|
-
0
|
|
289
|
-
);
|
|
290
|
-
}
|
|
291
|
-
function Tt(i) {
|
|
292
|
-
return i.groupBy(
|
|
293
|
-
(r) => r.sku._id,
|
|
294
|
-
(r) => r.measurementsAmounts.filter((e) => !e.measurement.abbrev.toLocaleLowerCase().includes("inactive")).map((e) => e.measurement.id)
|
|
295
|
-
);
|
|
296
|
-
}
|
|
297
|
-
function ha(i) {
|
|
298
|
-
const r = Dt(), e = r === "MYR" ? "RM" : r;
|
|
299
|
-
return [
|
|
300
|
-
{
|
|
301
|
-
id: "code",
|
|
302
|
-
name: "Code"
|
|
303
|
-
},
|
|
304
|
-
{
|
|
305
|
-
id: "name",
|
|
306
|
-
name: "Name"
|
|
307
|
-
},
|
|
308
|
-
{
|
|
309
|
-
id: "baseUnit",
|
|
310
|
-
name: "Base unit"
|
|
311
|
-
},
|
|
312
|
-
{
|
|
313
|
-
id: "costPerUnit",
|
|
314
|
-
name: "Cost per unit"
|
|
315
|
-
},
|
|
316
|
-
{
|
|
317
|
-
id: "costUnit",
|
|
318
|
-
name: "UOM"
|
|
319
|
-
},
|
|
320
|
-
{
|
|
321
|
-
id: "opening",
|
|
322
|
-
name: "Opening (B/F)"
|
|
323
|
-
},
|
|
324
|
-
{
|
|
325
|
-
id: "adjustmentTypes",
|
|
326
|
-
name: "Type"
|
|
327
|
-
},
|
|
328
|
-
{
|
|
329
|
-
id: "varianceQty",
|
|
330
|
-
name: "Variance (Qty)"
|
|
331
|
-
},
|
|
332
|
-
{
|
|
333
|
-
id: "varianceInCost",
|
|
334
|
-
name: `Variance (${e})`
|
|
335
|
-
},
|
|
336
|
-
{
|
|
337
|
-
id: "physicalBalance",
|
|
338
|
-
name: "Stock take (Qty)"
|
|
339
|
-
},
|
|
340
|
-
{
|
|
341
|
-
id: "systemBalance",
|
|
342
|
-
name: "System balance (Qty)"
|
|
343
|
-
},
|
|
344
|
-
{
|
|
345
|
-
id: "stockTakeValue",
|
|
346
|
-
name: `Stock take value (${e})`
|
|
347
|
-
},
|
|
348
|
-
{
|
|
349
|
-
id: "systemValue",
|
|
350
|
-
name: `System value (${e})`
|
|
351
|
-
},
|
|
352
|
-
{
|
|
353
|
-
id: "adjustedAmount",
|
|
354
|
-
name: "Adjusted balance"
|
|
355
|
-
},
|
|
356
|
-
{
|
|
357
|
-
id: "adjustedDiffPercentage",
|
|
358
|
-
name: "Diff (%)"
|
|
359
|
-
},
|
|
360
|
-
{
|
|
361
|
-
id: "baseUnitAmount",
|
|
362
|
-
name: "Base unit amount"
|
|
363
|
-
},
|
|
364
|
-
...Array.from({ length: i }).flatMap((_, y) => [
|
|
365
|
-
{
|
|
366
|
-
id: `measurementAmount${y}`,
|
|
367
|
-
name: `UOM amount ${y + 1}`
|
|
368
|
-
},
|
|
369
|
-
{
|
|
370
|
-
id: `measurementAbbrev${y}`,
|
|
371
|
-
name: `UOM ${y + 1}`
|
|
372
|
-
}
|
|
373
|
-
])
|
|
374
|
-
];
|
|
375
|
-
}
|
|
376
|
-
function ka(i, r, e) {
|
|
377
|
-
var z, h, p, w, H, q, C;
|
|
378
|
-
const d = r.groupBy(
|
|
379
|
-
(b) => b.id,
|
|
380
|
-
(b) => b.balance
|
|
381
|
-
), _ = e.groupBy(
|
|
382
|
-
(b) => b.id,
|
|
383
|
-
(b) => b.balance
|
|
384
|
-
), y = /* @__PURE__ */ new Map();
|
|
385
|
-
if (i.opening)
|
|
386
|
-
for (const b of i.opening)
|
|
387
|
-
y.set(b.skuId, b.balance);
|
|
388
|
-
const f = /* @__PURE__ */ new Map();
|
|
389
|
-
if (i.adjustmentSnapshot)
|
|
390
|
-
for (const b of i.adjustmentSnapshot) {
|
|
391
|
-
const G = Object.keys(b.adjustmentsByType).join(", ");
|
|
392
|
-
f.set(b.skuId, G || Bt);
|
|
393
|
-
}
|
|
394
|
-
const j = [...i.items, ...i.negativeStockItems ?? []], V = Tt(j), T = j.map((b) => {
|
|
395
|
-
var me, he, ke;
|
|
396
|
-
const G = ((me = d.get(b.sku._id)) == null ? void 0 : me[0]) ?? pa, ne = ((he = V == null ? void 0 : V.get(b.sku._id)) == null ? void 0 : he[0]) ?? [], se = y.get(b.sku._id), le = f.get(b.sku._id);
|
|
397
|
-
return ga(
|
|
398
|
-
b,
|
|
399
|
-
G,
|
|
400
|
-
ne,
|
|
401
|
-
(ke = _.get(b.sku._id)) == null ? void 0 : ke[0],
|
|
402
|
-
se,
|
|
403
|
-
le
|
|
404
|
-
);
|
|
405
|
-
}), x = ba(j), I = kt().currentBusiness.value, W = ha(x), m = [
|
|
406
|
-
["Business name:", I == null ? void 0 : I.name],
|
|
407
|
-
["Business ID:", I == null ? void 0 : I._id],
|
|
408
|
-
["Menu version", I == null ? void 0 : I.menuVersion],
|
|
409
|
-
["Created at", new Date(i.createdAt)],
|
|
410
|
-
["Created by", (z = i.createdBy) == null ? void 0 : z.name],
|
|
411
|
-
["Updated at", new Date(i.updatedAt)],
|
|
412
|
-
["Updated by", (h = i.updatedBy) == null ? void 0 : h.name],
|
|
413
|
-
["Recent action", i.approvedAt ? "Approve" : i.rejectionHistory ? "Reject" : ""],
|
|
414
|
-
[
|
|
415
|
-
"Action by",
|
|
416
|
-
i.approvedAt ? (p = i.approvedBy) == null ? void 0 : p.name : i.rejectionHistory ? (H = (w = i.rejectionHistory[0]) == null ? void 0 : w.rejectedBy) == null ? void 0 : H.name : ""
|
|
417
|
-
],
|
|
418
|
-
[
|
|
419
|
-
"Action at",
|
|
420
|
-
i.approvedAt ? new Date(i.approvedAt) : i.rejectionHistory ? new Date((q = i.rejectionHistory[0]) == null ? void 0 : q.rejectedAt) : ""
|
|
421
|
-
],
|
|
422
|
-
[
|
|
423
|
-
"Action remark",
|
|
424
|
-
i.approvedAt ? i.approveRemark : i.rejectionHistory ? new Date((C = i.rejectionHistory[0]) == null ? void 0 : C.rejectRemark) : ""
|
|
425
|
-
],
|
|
426
|
-
[],
|
|
427
|
-
W.map((b) => b.name),
|
|
428
|
-
...T.map((b) => W.map((G) => b[G.id]))
|
|
429
|
-
], t = W.map((b) => `system:${b.id}`), S = ea(m, t), R = `[${I == null ? void 0 : I.name}] closing draft (${Wt(new Date(i.updatedAt))}).xlsx`;
|
|
430
|
-
return ta(S, R), R;
|
|
431
|
-
}
|
|
432
|
-
const _a = { class: "flex flex-col" }, Da = {
|
|
433
|
-
key: 0,
|
|
434
|
-
class: "fm-typo-en-body-sm-400 text-fm-color-typo-error mt-4"
|
|
435
|
-
}, xa = { class: "flex gap-12 py-8 justify-end w-full" }, Aa = /* @__PURE__ */ Re({
|
|
436
|
-
__name: "RefreshBalanceAction",
|
|
437
|
-
props: {
|
|
438
|
-
draft: {},
|
|
439
|
-
onCancel: { type: Function },
|
|
440
|
-
onFinished: { type: Function }
|
|
441
|
-
},
|
|
442
|
-
setup(i) {
|
|
443
|
-
const r = i;
|
|
444
|
-
nt();
|
|
445
|
-
const e = Y(!1), d = Y(null), _ = Y(!1);
|
|
446
|
-
et(() => {
|
|
447
|
-
if (r.draft.effectiveAt)
|
|
448
|
-
d.value = new Date(r.draft.effectiveAt);
|
|
449
|
-
else {
|
|
450
|
-
const T = new Date(r.draft.createdAt);
|
|
451
|
-
T.setHours(23, 59, 59, 999), d.value = T;
|
|
452
|
-
}
|
|
453
|
-
_.value = !0;
|
|
454
|
-
});
|
|
455
|
-
const y = M({
|
|
456
|
-
get() {
|
|
457
|
-
return d.value === null ? "" : Ye(d.value);
|
|
458
|
-
},
|
|
459
|
-
set(T) {
|
|
460
|
-
if (T) {
|
|
461
|
-
const x = /* @__PURE__ */ new Date(`${T} ${f.value}`);
|
|
462
|
-
x.setSeconds(59, 999), d.value = x;
|
|
463
|
-
} else
|
|
464
|
-
d.value = null;
|
|
465
|
-
}
|
|
466
|
-
}), f = M({
|
|
467
|
-
get() {
|
|
468
|
-
return d.value === null ? "" : At(d.value);
|
|
469
|
-
},
|
|
470
|
-
set(T) {
|
|
471
|
-
if (T) {
|
|
472
|
-
const x = /* @__PURE__ */ new Date(`${y.value} ${T}`);
|
|
473
|
-
x.setSeconds(59, 999), d.value = x;
|
|
474
|
-
} else
|
|
475
|
-
d.value = null;
|
|
476
|
-
}
|
|
477
|
-
}), j = M(() => d.value ? d.value.getTime() > (/* @__PURE__ */ new Date()).getTime() : !1);
|
|
478
|
-
async function V() {
|
|
479
|
-
e.value = !0, r.onFinished(d.value.toISOString());
|
|
480
|
-
}
|
|
481
|
-
return (T, x) => {
|
|
482
|
-
const D = K("FmLabel"), I = K("FmDatePicker"), W = K("FmTimePicker"), m = K("FmButton"), t = K("FmForm");
|
|
483
|
-
return _.value ? (F(), ce(t, {
|
|
484
|
-
key: 1,
|
|
485
|
-
onValidationSuccess: V,
|
|
486
|
-
class: "flex flex-col gap-32",
|
|
487
|
-
disabled: e.value
|
|
488
|
-
}, {
|
|
489
|
-
default: O(() => [
|
|
490
|
-
x[5] || (x[5] = s("div", { class: "fm-typo-en-body-lg-400" }, [
|
|
491
|
-
s("p", null, [
|
|
492
|
-
re(" Performing "),
|
|
493
|
-
s("span", { class: "fm-typo-en-body-lg-600" }, '"Refresh Balance"'),
|
|
494
|
-
re(" until closing effective date and time. ")
|
|
495
|
-
]),
|
|
496
|
-
s("p", { class: "mt-2" }, [
|
|
497
|
-
re(" Please note that this action will "),
|
|
498
|
-
s("b", null, "update"),
|
|
499
|
-
re(" the effective date and time. ")
|
|
500
|
-
])
|
|
501
|
-
], -1)),
|
|
502
|
-
s("div", _a, [
|
|
503
|
-
k(D, { class: "fm-typo-en-body-lg-600" }, {
|
|
504
|
-
default: O(() => x[3] || (x[3] = [
|
|
505
|
-
re("Closing Date")
|
|
506
|
-
])),
|
|
507
|
-
_: 1
|
|
508
|
-
}),
|
|
509
|
-
k(I, {
|
|
510
|
-
modelValue: y.value,
|
|
511
|
-
"onUpdate:modelValue": x[0] || (x[0] = (S) => y.value = S),
|
|
512
|
-
max: g(Ye)(/* @__PURE__ */ new Date())
|
|
513
|
-
}, null, 8, ["modelValue", "max"]),
|
|
514
|
-
k(D, { class: "fm-typo-en-body-lg-600" }, {
|
|
515
|
-
default: O(() => x[4] || (x[4] = [
|
|
516
|
-
re("Closing Time")
|
|
517
|
-
])),
|
|
518
|
-
_: 1
|
|
519
|
-
}),
|
|
520
|
-
k(W, {
|
|
521
|
-
modelValue: f.value,
|
|
522
|
-
"onUpdate:modelValue": x[1] || (x[1] = (S) => f.value = S)
|
|
523
|
-
}, null, 8, ["modelValue"]),
|
|
524
|
-
j.value ? (F(), P("div", Da, " Cannot select future date ")) : J("", !0)
|
|
525
|
-
]),
|
|
526
|
-
s("div", xa, [
|
|
527
|
-
k(m, {
|
|
528
|
-
label: "Cancel",
|
|
529
|
-
variant: "tertiary",
|
|
530
|
-
onClick: x[2] || (x[2] = (S) => T.onCancel())
|
|
531
|
-
}),
|
|
532
|
-
k(m, {
|
|
533
|
-
label: "Refresh balance",
|
|
534
|
-
type: "submit",
|
|
535
|
-
variant: "primary",
|
|
536
|
-
loading: e.value,
|
|
537
|
-
disabled: j.value
|
|
538
|
-
}, null, 8, ["loading", "disabled"])
|
|
539
|
-
])
|
|
540
|
-
]),
|
|
541
|
-
_: 1
|
|
542
|
-
}, 8, ["disabled"])) : (F(), P(oe, { key: 0 }, [
|
|
543
|
-
re("Loading")
|
|
544
|
-
], 64));
|
|
545
|
-
};
|
|
546
|
-
}
|
|
547
|
-
}), Qe = xt(
|
|
548
|
-
"closingDraftActions",
|
|
549
|
-
function() {
|
|
550
|
-
const r = Ht(), e = tt(), d = nt(), _ = Ge(), y = Ct(), f = Y(!1), j = Y();
|
|
551
|
-
function V(h) {
|
|
552
|
-
const p = {
|
|
553
|
-
draft: h
|
|
554
|
-
};
|
|
555
|
-
j.value = p, f.value = !0;
|
|
556
|
-
}
|
|
557
|
-
async function T(h) {
|
|
558
|
-
var w;
|
|
559
|
-
if (h.status === be.enum.COMPLETED) {
|
|
560
|
-
const H = h.closingAdjustmentId;
|
|
561
|
-
if (!H)
|
|
562
|
-
return e.open({
|
|
563
|
-
title: "Something went wrong",
|
|
564
|
-
message: "Closing draft is completed but closing document cannot be found.",
|
|
565
|
-
type: "error"
|
|
566
|
-
}), console.error("Closing draft is completed but closing document cannot be found.", {
|
|
567
|
-
draftId: h._id
|
|
568
|
-
}), [];
|
|
569
|
-
const q = await d.readAdjustmentById(H);
|
|
570
|
-
return ((q == null ? void 0 : q.skus) ?? []).map((b) => ({
|
|
571
|
-
id: b.sku._id,
|
|
572
|
-
balance: b.fromBalance,
|
|
573
|
-
costs: b.fromCostBalances
|
|
574
|
-
}));
|
|
575
|
-
} else
|
|
576
|
-
return await y.readStockBalance(), ((w = y.stockBalance) == null ? void 0 : w.skus) ?? [];
|
|
577
|
-
}
|
|
578
|
-
async function x(h, p, w) {
|
|
579
|
-
p || (e.open({
|
|
580
|
-
title: "Exporting",
|
|
581
|
-
message: "Fetching data..."
|
|
582
|
-
}), p = await T(h)), ka(h, p, w ?? []);
|
|
583
|
-
}
|
|
584
|
-
function D(h, p, w) {
|
|
585
|
-
r.open({
|
|
586
|
-
title: "Approve draft",
|
|
587
|
-
contentComponent: Ze,
|
|
588
|
-
contentComponentProps: {
|
|
589
|
-
draft: h,
|
|
590
|
-
action: Q.enum.approveDraft,
|
|
591
|
-
onFinished: () => {
|
|
592
|
-
r.close(), p == null || p();
|
|
593
|
-
},
|
|
594
|
-
onCancel: () => {
|
|
595
|
-
r.close();
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
}).onClose(() => {
|
|
599
|
-
w == null || w();
|
|
600
|
-
});
|
|
601
|
-
}
|
|
602
|
-
function I(h, p) {
|
|
603
|
-
r.open({
|
|
604
|
-
title: "Reject draft",
|
|
605
|
-
contentComponent: Ze,
|
|
606
|
-
contentComponentProps: {
|
|
607
|
-
draft: h,
|
|
608
|
-
action: Q.enum.rejectDraft,
|
|
609
|
-
onFinished: () => {
|
|
610
|
-
r.close(), p == null || p();
|
|
611
|
-
},
|
|
612
|
-
onCancel: () => r.close()
|
|
613
|
-
}
|
|
614
|
-
});
|
|
615
|
-
}
|
|
616
|
-
function W(h, p) {
|
|
617
|
-
r.open({
|
|
618
|
-
title: "Mark draft as failed",
|
|
619
|
-
contentComponent: Ze,
|
|
620
|
-
contentComponentProps: {
|
|
621
|
-
draft: h,
|
|
622
|
-
action: Q.enum.markAsFailed,
|
|
623
|
-
onFinished: () => {
|
|
624
|
-
r.close(), p == null || p();
|
|
625
|
-
},
|
|
626
|
-
onCancel: () => r.close()
|
|
627
|
-
}
|
|
628
|
-
});
|
|
629
|
-
}
|
|
630
|
-
async function m(h, p) {
|
|
631
|
-
await _.sync({
|
|
632
|
-
_id: h._id,
|
|
633
|
-
_rev: h._rev ?? "",
|
|
634
|
-
action: Q.enum.approveDraft,
|
|
635
|
-
data: {
|
|
636
|
-
remark: h.remark ?? ""
|
|
637
|
-
}
|
|
638
|
-
}).delayed(500), e.open({
|
|
639
|
-
title: "Success",
|
|
640
|
-
message: "Sync requested",
|
|
641
|
-
type: "success"
|
|
642
|
-
}), p == null || p();
|
|
643
|
-
}
|
|
644
|
-
function t() {
|
|
645
|
-
f.value = !1;
|
|
646
|
-
}
|
|
647
|
-
async function S(h, p, w) {
|
|
648
|
-
await r.open({
|
|
649
|
-
title: "Refresh balance",
|
|
650
|
-
contentComponent: Aa,
|
|
651
|
-
contentComponentProps: {
|
|
652
|
-
draft: h,
|
|
653
|
-
onFinished: (H) => {
|
|
654
|
-
r.close(), w == null || w(H);
|
|
655
|
-
},
|
|
656
|
-
onCancel: async () => {
|
|
657
|
-
r.close(), p == null || p();
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
});
|
|
661
|
-
}
|
|
662
|
-
async function R(h) {
|
|
663
|
-
await r.open({
|
|
664
|
-
title: "Invalidate closing draft cache",
|
|
665
|
-
message: "It will invalidate opening and stock movement cache for this draft.",
|
|
666
|
-
primaryActions: { text: "Proceed", close: !0 },
|
|
667
|
-
secondaryActions: { text: "Cancel", close: !0 }
|
|
668
|
-
}).onPrimary(async () => {
|
|
669
|
-
await d.recalculation.scheduleInvalidateClosingDraftCache([h._id]), e.open({
|
|
670
|
-
title: "Success",
|
|
671
|
-
message: "Invalidate cache requested",
|
|
672
|
-
type: "success"
|
|
673
|
-
});
|
|
674
|
-
});
|
|
675
|
-
}
|
|
676
|
-
async function z(h, p) {
|
|
677
|
-
try {
|
|
678
|
-
e.open({
|
|
679
|
-
title: "Cloning",
|
|
680
|
-
message: "Creating a copy of the draft..."
|
|
681
|
-
}), await _.cloneDraft(h._id), e.open({
|
|
682
|
-
title: "Success",
|
|
683
|
-
message: "Draft cloned successfully",
|
|
684
|
-
type: "success"
|
|
685
|
-
}), p == null || p();
|
|
686
|
-
} catch (w) {
|
|
687
|
-
e.open({
|
|
688
|
-
title: "Error",
|
|
689
|
-
message: (w == null ? void 0 : w.message) || "Failed to clone draft",
|
|
690
|
-
type: "error"
|
|
691
|
-
});
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
return {
|
|
695
|
-
viewDraft: V,
|
|
696
|
-
closeDraftDialog: t,
|
|
697
|
-
approveDraft: D,
|
|
698
|
-
rejectDraft: I,
|
|
699
|
-
markAsFailed: W,
|
|
700
|
-
syncDraft: m,
|
|
701
|
-
exportDraft: x,
|
|
702
|
-
refreshBalance: S,
|
|
703
|
-
cloneDraft: z,
|
|
704
|
-
viewClosingDraftShow: f,
|
|
705
|
-
viewClosingDraftProps: j,
|
|
706
|
-
invalidateDraftCache: R
|
|
707
|
-
};
|
|
708
|
-
}
|
|
709
|
-
);
|
|
710
|
-
function Ke(i) {
|
|
711
|
-
switch (i) {
|
|
712
|
-
case "DRAFT":
|
|
713
|
-
return "fm-status-badge-draft";
|
|
714
|
-
case "PROCESSING":
|
|
715
|
-
return "fm-status-badge-processing";
|
|
716
|
-
case "FAILED":
|
|
717
|
-
return "fm-status-badge-cancel";
|
|
718
|
-
case "COMPLETED":
|
|
719
|
-
return "fm-status-badge-complete";
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
const Sa = xt(
|
|
723
|
-
"closingDraftTable",
|
|
724
|
-
function() {
|
|
725
|
-
const { t: r } = _t(), e = kt(), d = Qe(), _ = Y(new Array()), y = Y(!1), f = qe(), j = Ge();
|
|
726
|
-
async function V() {
|
|
727
|
-
if (_.value = [], !!f._currentLocation) {
|
|
728
|
-
y.value = !0;
|
|
729
|
-
try {
|
|
730
|
-
const [m] = await Promise.all([j.readDrafts()]).delayed(1e3);
|
|
731
|
-
_.value = m.reverse();
|
|
732
|
-
} catch (m) {
|
|
733
|
-
console.log("Something went wrong when fetching drafts:", m);
|
|
734
|
-
} finally {
|
|
735
|
-
y.value = !1;
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
}
|
|
739
|
-
async function T(m) {
|
|
740
|
-
if (!_.value.find((t) => t._id) && f._currentLocation) {
|
|
741
|
-
y.value = !0;
|
|
742
|
-
try {
|
|
743
|
-
const [t] = await Promise.all([
|
|
744
|
-
j.getDraft(m),
|
|
745
|
-
new Promise((S) => setTimeout(S, 1e3))
|
|
746
|
-
]);
|
|
747
|
-
_.value = [t];
|
|
748
|
-
} catch (t) {
|
|
749
|
-
console.log("Something went wrong when fetching drafts:", t);
|
|
750
|
-
} finally {
|
|
751
|
-
y.value = !1;
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
function x(m) {
|
|
756
|
-
_.value = _.value.map((t) => t._id === m._id ? {
|
|
757
|
-
...m,
|
|
758
|
-
_rev: t._rev
|
|
759
|
-
} : t);
|
|
760
|
-
}
|
|
761
|
-
function D() {
|
|
762
|
-
d.closeDraftDialog(), V();
|
|
763
|
-
}
|
|
764
|
-
function I(m, t) {
|
|
765
|
-
switch (t = Qt(t), m) {
|
|
766
|
-
case Ce.Details:
|
|
767
|
-
return d.viewDraft(t);
|
|
768
|
-
case Ce.Export:
|
|
769
|
-
return d.exportDraft(t);
|
|
770
|
-
case Q.enum.approveDraft:
|
|
771
|
-
return d.approveDraft(t, D);
|
|
772
|
-
case Q.enum.rejectDraft:
|
|
773
|
-
return d.rejectDraft(t, D);
|
|
774
|
-
case Q.enum.markAsFailed:
|
|
775
|
-
return d.markAsFailed(t, D);
|
|
776
|
-
case Ce.Duplicate:
|
|
777
|
-
return d.cloneDraft(t, D);
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
return {
|
|
781
|
-
columnDefs: [
|
|
782
|
-
{
|
|
783
|
-
id: "_id",
|
|
784
|
-
accessorKey: "_id",
|
|
785
|
-
header: () => r("inventory.closing.table.createdAt"),
|
|
786
|
-
cell(m) {
|
|
787
|
-
return oa(`${m.getValue()}`);
|
|
788
|
-
},
|
|
789
|
-
enableSorting: !0
|
|
790
|
-
},
|
|
791
|
-
{
|
|
792
|
-
accessorKey: "effectiveAt",
|
|
793
|
-
header: () => "Effective at",
|
|
794
|
-
cell(m) {
|
|
795
|
-
const t = m.row.original;
|
|
796
|
-
let S = m.getValue();
|
|
797
|
-
return S || (S = He(t._id)), ye(S);
|
|
798
|
-
},
|
|
799
|
-
enableSorting: !0,
|
|
800
|
-
size: 200
|
|
801
|
-
},
|
|
802
|
-
{
|
|
803
|
-
id: "updatedAt",
|
|
804
|
-
accessorFn: (m) => ye(m.updatedAt),
|
|
805
|
-
header: () => "Updated at",
|
|
806
|
-
enableSorting: !0,
|
|
807
|
-
size: 200
|
|
808
|
-
},
|
|
809
|
-
{
|
|
810
|
-
id: "updatedBy",
|
|
811
|
-
accessorKey: "updatedBy.name",
|
|
812
|
-
header: () => "Last update by",
|
|
813
|
-
enableSorting: !0,
|
|
814
|
-
size: 200
|
|
815
|
-
},
|
|
816
|
-
{
|
|
817
|
-
id: "noOfItems",
|
|
818
|
-
accessorFn: (m) => {
|
|
819
|
-
var t;
|
|
820
|
-
return m.items.length + (((t = m.negativeStockItems) == null ? void 0 : t.length) ?? 0);
|
|
821
|
-
},
|
|
822
|
-
header: () => r("inventory.closing.table.noOfItems"),
|
|
823
|
-
enableSorting: !1,
|
|
824
|
-
meta: {
|
|
825
|
-
width: "10rem",
|
|
826
|
-
textAlign: "right"
|
|
827
|
-
}
|
|
828
|
-
},
|
|
829
|
-
{
|
|
830
|
-
id: "recentRemark",
|
|
831
|
-
accessorFn: (m) => {
|
|
832
|
-
var t;
|
|
833
|
-
return (m == null ? void 0 : m.approveRemark) ?? ((t = m == null ? void 0 : m.rejectionHistory) == null ? void 0 : t.computeFirst((S) => S.rejectRemark)) ?? m.remark;
|
|
834
|
-
},
|
|
835
|
-
header: () => "Recent remark"
|
|
836
|
-
},
|
|
837
|
-
{
|
|
838
|
-
id: "status",
|
|
839
|
-
accessorFn: (m) => m.status,
|
|
840
|
-
header: () => r("inventory.closing.table.status"),
|
|
841
|
-
enableSorting: !1,
|
|
842
|
-
cell(m) {
|
|
843
|
-
var p;
|
|
844
|
-
const t = m.row.original, S = t.status, R = new Date(t.updatedAt), z = (p = t == null ? void 0 : t.rejectionHistory) == null ? void 0 : p.computeFirst((w) => w.rejectedAt), h = z ? new Date(z) : null;
|
|
845
|
-
return S === "DRAFT" && h ? h.getTime() > R.getTime() ? B(
|
|
846
|
-
"div",
|
|
847
|
-
{
|
|
848
|
-
class: "flex"
|
|
849
|
-
},
|
|
850
|
-
B(
|
|
851
|
-
"div",
|
|
852
|
-
{
|
|
853
|
-
class: ["fm-status-badge", Ke("FAILED")]
|
|
854
|
-
},
|
|
855
|
-
"Rejected"
|
|
856
|
-
)
|
|
857
|
-
) : B(
|
|
858
|
-
"div",
|
|
859
|
-
{
|
|
860
|
-
class: "flex"
|
|
861
|
-
},
|
|
862
|
-
B(
|
|
863
|
-
"div",
|
|
864
|
-
{
|
|
865
|
-
class: ["fm-status-badge", Ke("PROCESSING")]
|
|
866
|
-
},
|
|
867
|
-
"Updated"
|
|
868
|
-
)
|
|
869
|
-
) : B(
|
|
870
|
-
"div",
|
|
871
|
-
{
|
|
872
|
-
class: "flex"
|
|
873
|
-
},
|
|
874
|
-
B(
|
|
875
|
-
"div",
|
|
876
|
-
{
|
|
877
|
-
class: ["fm-status-badge", Ke(S)]
|
|
878
|
-
},
|
|
879
|
-
Oe(S)
|
|
880
|
-
)
|
|
881
|
-
);
|
|
882
|
-
}
|
|
883
|
-
},
|
|
884
|
-
{
|
|
885
|
-
id: "action",
|
|
886
|
-
cell(m) {
|
|
887
|
-
var p;
|
|
888
|
-
const t = m.row.original, S = ((p = e.sessionUser.value) == null ? void 0 : p.role.isAdmin) ?? !1, R = [
|
|
889
|
-
yt[Ce.Details],
|
|
890
|
-
yt[Ce.Export]
|
|
891
|
-
], z = [
|
|
892
|
-
{
|
|
893
|
-
translationKey: "inventory.closing.draft.approveDraft",
|
|
894
|
-
color: "text-fm-color-typo-primary",
|
|
895
|
-
value: Q.enum.approveDraft
|
|
896
|
-
},
|
|
897
|
-
{
|
|
898
|
-
translationKey: "inventory.closing.draft.rejectDraft",
|
|
899
|
-
color: "text-fm-color-typo-error",
|
|
900
|
-
value: Q.enum.rejectDraft
|
|
901
|
-
},
|
|
902
|
-
{
|
|
903
|
-
translationKey: "inventory.closing.draft.markAsFailed",
|
|
904
|
-
color: "text-fm-color-typo-error",
|
|
905
|
-
value: Q.enum.markAsFailed
|
|
906
|
-
}
|
|
907
|
-
], h = S && t.status !== be.enum.DRAFT ? [
|
|
908
|
-
{
|
|
909
|
-
translationKey: "inventory.closing.draft.cloneDraft",
|
|
910
|
-
color: "text-fm-color-typo-primary",
|
|
911
|
-
value: Ce.Duplicate
|
|
912
|
-
}
|
|
913
|
-
] : [];
|
|
914
|
-
return aa(
|
|
915
|
-
[
|
|
916
|
-
...R,
|
|
917
|
-
...t.status === be.enum.DRAFT ? z : []
|
|
918
|
-
],
|
|
919
|
-
(w) => I(w, t),
|
|
920
|
-
h
|
|
921
|
-
);
|
|
922
|
-
},
|
|
923
|
-
enableSorting: !1,
|
|
924
|
-
size: 40,
|
|
925
|
-
meta: {
|
|
926
|
-
cellClass: "",
|
|
927
|
-
headerClass: ""
|
|
928
|
-
}
|
|
929
|
-
}
|
|
930
|
-
],
|
|
931
|
-
drafts: _,
|
|
932
|
-
loading: y,
|
|
933
|
-
fetchDrafts: V,
|
|
934
|
-
loadDraft: T,
|
|
935
|
-
updateDraftRef: x
|
|
936
|
-
};
|
|
937
|
-
}
|
|
938
|
-
), wa = { class: "fm-typo-en-heading-lg-600" }, Fa = { class: "py-4" }, Ca = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary mb-4" }, $a = { key: 0 }, Ba = { class: "mt-4 flex gap-4" }, Ta = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary mb-4" }, ja = { key: 0 }, Ia = {
|
|
939
|
-
key: 0,
|
|
940
|
-
class: "mb-4"
|
|
941
|
-
}, Ua = { class: "flex flex-col gap-1 max-h-200 overflow-auto pr-4" }, Ra = { class: "fm-typo-en-body-md-400" }, Va = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Pa = { class: "mt-4 flex gap-4" }, Ma = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary mb-4" }, La = {
|
|
942
|
-
key: 0,
|
|
943
|
-
class: "flex gap-4"
|
|
944
|
-
}, Na = /* @__PURE__ */ Re({
|
|
945
|
-
__name: "ClosingDraftApprovalDialog",
|
|
946
|
-
props: {
|
|
947
|
-
show: { type: Boolean },
|
|
948
|
-
refreshing: { type: Boolean },
|
|
949
|
-
approving: { type: Boolean },
|
|
950
|
-
hasStockSnapshot: { type: Boolean },
|
|
951
|
-
negativeItems: {}
|
|
952
|
-
},
|
|
953
|
-
emits: ["update:show", "refresh", "approve"],
|
|
954
|
-
setup(i, { emit: r }) {
|
|
955
|
-
const { FmStepper: e, FmStep: d, FmDialog: _, FmButton: y } = ge, { t: f } = la(), j = i, V = r, T = M(() => {
|
|
956
|
-
var C;
|
|
957
|
-
return (((C = j.negativeItems) == null ? void 0 : C.length) ?? 0) > 0;
|
|
958
|
-
}), x = M({
|
|
959
|
-
get: () => j.show,
|
|
960
|
-
set: (C) => V("update:show", C)
|
|
961
|
-
}), D = Y(1), I = () => D.value > 1, W = () => D.value > 2, m = () => !1;
|
|
962
|
-
function t(C) {
|
|
963
|
-
return C === 1 ? j.hasStockSnapshot : C === 2 ? !T.value : !1;
|
|
964
|
-
}
|
|
965
|
-
const S = M(() => !j.hasStockSnapshot || T.value);
|
|
966
|
-
function R(C) {
|
|
967
|
-
let b = C + 1;
|
|
968
|
-
for (; b <= 3 && t(b); ) b++;
|
|
969
|
-
return b > 3 ? 3 : b;
|
|
970
|
-
}
|
|
971
|
-
function z(C) {
|
|
972
|
-
let b = C - 1;
|
|
973
|
-
for (; b >= 1 && t(b); ) b--;
|
|
974
|
-
return b < 1 ? 1 : b;
|
|
975
|
-
}
|
|
976
|
-
function h() {
|
|
977
|
-
return j.hasStockSnapshot ? T.value ? 2 : 3 : 1;
|
|
978
|
-
}
|
|
979
|
-
ze(
|
|
980
|
-
() => j.show,
|
|
981
|
-
(C) => {
|
|
982
|
-
C && (D.value = h());
|
|
983
|
-
}
|
|
984
|
-
), ze(
|
|
985
|
-
() => j.hasStockSnapshot,
|
|
986
|
-
(C) => {
|
|
987
|
-
C && D.value === 1 && (D.value = R(1));
|
|
988
|
-
}
|
|
989
|
-
), ze(
|
|
990
|
-
() => T.value,
|
|
991
|
-
(C) => {
|
|
992
|
-
!C && D.value === 2 && (D.value = R(2));
|
|
993
|
-
}
|
|
994
|
-
);
|
|
995
|
-
function p() {
|
|
996
|
-
V("refresh");
|
|
997
|
-
}
|
|
998
|
-
function w() {
|
|
999
|
-
D.value < 3 && (D.value = R(D.value));
|
|
1000
|
-
}
|
|
1001
|
-
function H() {
|
|
1002
|
-
D.value > 1 && (D.value = z(D.value));
|
|
1003
|
-
}
|
|
1004
|
-
function q() {
|
|
1005
|
-
V("approve");
|
|
1006
|
-
}
|
|
1007
|
-
return (C, b) => (F(), ce(g(_), {
|
|
1008
|
-
modelValue: x.value,
|
|
1009
|
-
"onUpdate:modelValue": b[1] || (b[1] = (G) => x.value = G),
|
|
1010
|
-
"max-width": 600
|
|
1011
|
-
}, {
|
|
1012
|
-
"dialog-header": O(() => [
|
|
1013
|
-
s("div", wa, Z(g(f)("inventory.closing.approval.title")), 1)
|
|
1014
|
-
]),
|
|
1015
|
-
default: O(() => [
|
|
1016
|
-
s("div", Fa, [
|
|
1017
|
-
k(g(e), {
|
|
1018
|
-
modelValue: D.value,
|
|
1019
|
-
"onUpdate:modelValue": b[0] || (b[0] = (G) => D.value = G),
|
|
1020
|
-
orientation: "vertical"
|
|
1021
|
-
}, {
|
|
1022
|
-
default: O(() => [
|
|
1023
|
-
k(g(d), {
|
|
1024
|
-
value: 1,
|
|
1025
|
-
title: g(f)("inventory.closing.approval.step.generateReport.title"),
|
|
1026
|
-
complete: I
|
|
1027
|
-
}, {
|
|
1028
|
-
default: O(() => [
|
|
1029
|
-
s("div", Ca, Z(g(f)("inventory.closing.approval.step.generateReport.description")), 1),
|
|
1030
|
-
D.value === 1 ? (F(), P("div", $a, [
|
|
1031
|
-
k(g(y), {
|
|
1032
|
-
label: g(f)("inventory.stock.stock_balance.refreshBalance"),
|
|
1033
|
-
"prepend-icon": "refresh",
|
|
1034
|
-
variant: "secondary",
|
|
1035
|
-
loading: C.refreshing,
|
|
1036
|
-
onClick: p
|
|
1037
|
-
}, null, 8, ["label", "loading"]),
|
|
1038
|
-
s("div", Ba, [
|
|
1039
|
-
k(g(y), {
|
|
1040
|
-
label: g(f)("inventory.common.continue"),
|
|
1041
|
-
disabled: !C.hasStockSnapshot,
|
|
1042
|
-
onClick: w
|
|
1043
|
-
}, null, 8, ["label", "disabled"])
|
|
1044
|
-
])
|
|
1045
|
-
])) : J("", !0)
|
|
1046
|
-
]),
|
|
1047
|
-
_: 1
|
|
1048
|
-
}, 8, ["title"]),
|
|
1049
|
-
k(g(d), {
|
|
1050
|
-
value: 2,
|
|
1051
|
-
title: g(f)("inventory.closing.approval.step.negativeItems.title"),
|
|
1052
|
-
disabled: () => !C.hasStockSnapshot,
|
|
1053
|
-
complete: W
|
|
1054
|
-
}, {
|
|
1055
|
-
default: O(() => {
|
|
1056
|
-
var G;
|
|
1057
|
-
return [
|
|
1058
|
-
s("div", Ta, Z(T.value ? g(f)("inventory.closing.approval.step.negativeItems.resolveMessage") : g(f)("inventory.closing.approval.step.negativeItems.noItemsMessage")), 1),
|
|
1059
|
-
D.value === 2 ? (F(), P("div", ja, [
|
|
1060
|
-
T.value && (((G = C.negativeItems) == null ? void 0 : G.length) ?? 0) > 0 ? (F(), P("div", Ia, [
|
|
1061
|
-
s("div", Ua, [
|
|
1062
|
-
(F(!0), P(oe, null, $e(C.negativeItems, (ne) => (F(), P("div", {
|
|
1063
|
-
key: ne.code,
|
|
1064
|
-
class: "flex justify-between gap-8"
|
|
1065
|
-
}, [
|
|
1066
|
-
s("div", Ra, Z(ne.name), 1),
|
|
1067
|
-
s("div", Va, Z(ne.code), 1)
|
|
1068
|
-
]))), 128))
|
|
1069
|
-
])
|
|
1070
|
-
])) : J("", !0),
|
|
1071
|
-
s("div", Pa, [
|
|
1072
|
-
k(g(y), {
|
|
1073
|
-
label: g(f)("inventory.common.back"),
|
|
1074
|
-
variant: "secondary",
|
|
1075
|
-
onClick: H
|
|
1076
|
-
}, null, 8, ["label"]),
|
|
1077
|
-
k(g(y), {
|
|
1078
|
-
label: g(f)("inventory.common.continue"),
|
|
1079
|
-
disabled: T.value,
|
|
1080
|
-
onClick: w
|
|
1081
|
-
}, null, 8, ["label", "disabled"])
|
|
1082
|
-
])
|
|
1083
|
-
])) : J("", !0)
|
|
1084
|
-
];
|
|
1085
|
-
}),
|
|
1086
|
-
_: 1
|
|
1087
|
-
}, 8, ["title", "disabled"]),
|
|
1088
|
-
k(g(d), {
|
|
1089
|
-
value: 3,
|
|
1090
|
-
title: g(f)("inventory.closing.approval.step.approval.title"),
|
|
1091
|
-
disabled: () => !C.hasStockSnapshot || T.value,
|
|
1092
|
-
complete: m
|
|
1093
|
-
}, {
|
|
1094
|
-
default: O(() => [
|
|
1095
|
-
s("div", Ma, Z(g(f)("inventory.closing.approval.step.approval.warning")), 1),
|
|
1096
|
-
D.value === 3 ? (F(), P("div", La, [
|
|
1097
|
-
k(g(y), {
|
|
1098
|
-
label: g(f)("inventory.common.back"),
|
|
1099
|
-
variant: "secondary",
|
|
1100
|
-
onClick: H
|
|
1101
|
-
}, null, 8, ["label"]),
|
|
1102
|
-
k(g(y), {
|
|
1103
|
-
label: g(f)("inventory.common.approve"),
|
|
1104
|
-
variant: "destructive",
|
|
1105
|
-
disabled: S.value,
|
|
1106
|
-
loading: C.approving,
|
|
1107
|
-
onClick: q
|
|
1108
|
-
}, null, 8, ["label", "disabled", "loading"])
|
|
1109
|
-
])) : J("", !0)
|
|
1110
|
-
]),
|
|
1111
|
-
_: 1
|
|
1112
|
-
}, 8, ["title", "disabled"])
|
|
1113
|
-
]),
|
|
1114
|
-
_: 1
|
|
1115
|
-
}, 8, ["modelValue"])
|
|
1116
|
-
])
|
|
1117
|
-
]),
|
|
1118
|
-
_: 1
|
|
1119
|
-
}, 8, ["modelValue"]));
|
|
1120
|
-
}
|
|
1121
|
-
}), Ea = { class: "w-full flex flex-col gap-32" }, za = { class: "flex justify-between" }, Ha = { class: "flex" }, Oa = { class: "grid grid-cols-[repeat(4,1fr)] xs:flex xs:flex-col sm:flex sm:flex-col gap-8" }, Ka = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ya = { class: "flex gap-1" }, Qa = { class: "fm-typo-en-body-lg-600" }, qa = { class: "flex flex-col gap-16" }, Ga = { class: "flex items-center" }, Wa = {
|
|
1122
|
-
key: 0,
|
|
1123
|
-
class: "flex gap-8"
|
|
1124
|
-
}, Za = {
|
|
1125
|
-
key: 0,
|
|
1126
|
-
class: "w-full flex flex-col items-center"
|
|
1127
|
-
}, Ja = { class: "flex items-center gap-8" }, Xa = { class: "flex flex-col gap-8" }, en = { class: "flex gap-8" }, tn = {
|
|
1128
|
-
key: 0,
|
|
1129
|
-
class: "flex gap-8"
|
|
1130
|
-
}, an = { class: "overflow-x-auto" }, nn = {
|
|
1131
|
-
key: 1,
|
|
1132
|
-
class: "flex-1 xs:w-screen xs:max-w-full"
|
|
1133
|
-
}, on = {
|
|
1134
|
-
key: 0,
|
|
1135
|
-
class: "flex flex-col items-center gap-8 h-full"
|
|
1136
|
-
}, sn = ["src"], rn = {
|
|
1137
|
-
key: 1,
|
|
1138
|
-
class: "px-4 flex flex-col"
|
|
1139
|
-
}, ln = { class: "flex gap-12 content-stretch" }, cn = {
|
|
1140
|
-
class: "flex flex-col w-24",
|
|
1141
|
-
name: "circles"
|
|
1142
|
-
}, un = { class: "flex-1 flex flex-col items-center" }, dn = { class: "flex-1 flex flex-col items-center" }, mn = {
|
|
1143
|
-
class: "py-12 flex flex-col gap-4",
|
|
1144
|
-
name: "received-at header"
|
|
1145
|
-
}, fn = { class: "fm-typo-en-body-lg-400" }, pn = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, vn = { class: "flex gap-12 content-stretch" }, gn = {
|
|
1146
|
-
class: "flex flex-col w-24",
|
|
1147
|
-
name: "circles"
|
|
1148
|
-
}, yn = { class: "flex-1 flex flex-col items-center" }, bn = {
|
|
1149
|
-
class: "py-12 flex flex-col gap-4 flex-1",
|
|
1150
|
-
name: "delivery details"
|
|
1151
|
-
}, hn = { class: "flex flex-col gap-8" }, kn = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _n = { class: "flex flex-col gap-4" }, Dn = { class: "flex gap-8" }, xn = "N/A", An = /* @__PURE__ */ Re({
|
|
1152
|
-
__name: "ClosingDraftDialog",
|
|
1153
|
-
props: {
|
|
1154
|
-
show: { type: Boolean },
|
|
1155
|
-
draft: {}
|
|
1156
|
-
},
|
|
1157
|
-
emits: ["submitted", "refresh"],
|
|
1158
|
-
setup(i, { emit: r }) {
|
|
1159
|
-
const e = i, d = M(() => {
|
|
1160
|
-
const c = Dt();
|
|
1161
|
-
return c === "MYR" ? "RM" : c;
|
|
1162
|
-
}), _ = Ct(), y = Qe(), f = Ot(e, "show"), j = Y(!1), V = Y(!1), T = Y(!1), x = Y(new Array()), D = Y(new Array()), I = Y([]), W = nt(), m = Ge(), t = tt(), S = qt(), R = qe(), z = Mt({}), h = M(() => new Set(
|
|
1163
|
-
S.skus.filter((c) => {
|
|
1164
|
-
var a;
|
|
1165
|
-
return z[(a = c.customAttributes) == null ? void 0 : a.tag];
|
|
1166
|
-
}).map((c) => c._id)
|
|
1167
|
-
)), p = r, w = Y({
|
|
1168
|
-
templateItem: !0,
|
|
1169
|
-
nonTemplateItem: !0
|
|
1170
|
-
}), H = M(() => {
|
|
1171
|
-
var a, v;
|
|
1172
|
-
const c = [...((a = e.draft) == null ? void 0 : a.items) ?? [], ...((v = e.draft) == null ? void 0 : v.negativeStockItems) ?? []];
|
|
1173
|
-
return h.value.size ? c.filter((n) => h.value.has(n.sku._id)) : c;
|
|
1174
|
-
}), q = M(() => {
|
|
1175
|
-
const c = H.value.map((a) => a.sku);
|
|
1176
|
-
return c.sort((a, v) => a.code.localeCompare(v.code)), c;
|
|
1177
|
-
}), C = M(() => H.value.groupBy(
|
|
1178
|
-
(a) => a.sku._id,
|
|
1179
|
-
(a) => a.measurementsAmounts.filter((v) => !v.measurement.abbrev.toLocaleLowerCase().includes("inactive")).map((v) => v.measurement.id)
|
|
1180
|
-
));
|
|
1181
|
-
et(ne), ze(
|
|
1182
|
-
() => e.show,
|
|
1183
|
-
(c) => {
|
|
1184
|
-
c && (_e.value = Se[0], ne(), w.value = {
|
|
1185
|
-
templateItem: !0,
|
|
1186
|
-
nonTemplateItem: !0
|
|
1187
|
-
});
|
|
1188
|
-
}
|
|
1189
|
-
);
|
|
1190
|
-
const b = Ue(0), G = Ue(100);
|
|
1191
|
-
async function ne() {
|
|
1192
|
-
var a, v, n, o;
|
|
1193
|
-
if (!R._currentLocation) return;
|
|
1194
|
-
j.value = !0;
|
|
1195
|
-
const c = ((a = e.draft) == null ? void 0 : a.status) === be.enum.COMPLETED;
|
|
1196
|
-
D.value = [];
|
|
1197
|
-
try {
|
|
1198
|
-
if (await S.init(), c) {
|
|
1199
|
-
const L = e.draft.closingAdjustmentId;
|
|
1200
|
-
if (!L) {
|
|
1201
|
-
t.open({
|
|
1202
|
-
title: "Something went wrong",
|
|
1203
|
-
message: "Closing draft is completed but closing document cannot be found.",
|
|
1204
|
-
type: "error"
|
|
1205
|
-
}), console.error("Closing draft is completed but closing document cannot be found.", {
|
|
1206
|
-
draftId: (v = e.draft) == null ? void 0 : v._id
|
|
1207
|
-
});
|
|
1208
|
-
return;
|
|
1209
|
-
}
|
|
1210
|
-
const N = await W.readAdjustmentById(L), ie = (N == null ? void 0 : N.skus) ?? [];
|
|
1211
|
-
for (const ue of ie) {
|
|
1212
|
-
const De = {
|
|
1213
|
-
id: ue.sku._id,
|
|
1214
|
-
balance: ue.fromBalance,
|
|
1215
|
-
costs: ue.fromCostBalances
|
|
1216
|
-
}, pe = {
|
|
1217
|
-
id: ue.sku._id,
|
|
1218
|
-
balance: ue.toBalance,
|
|
1219
|
-
costs: ue.toCostBalances
|
|
1220
|
-
};
|
|
1221
|
-
x.value.push(De), D.value.push(pe);
|
|
1222
|
-
}
|
|
1223
|
-
} else
|
|
1224
|
-
x.value = ((n = e.draft) == null ? void 0 : n.stockSnapshot) ?? [];
|
|
1225
|
-
const u = /* @__PURE__ */ new Set();
|
|
1226
|
-
if ((o = e.draft) != null && o.adjustmentSnapshot)
|
|
1227
|
-
for (const L of e.draft.adjustmentSnapshot)
|
|
1228
|
-
L.adjustmentsByType && Object.keys(L.adjustmentsByType).forEach((N) => u.add(N));
|
|
1229
|
-
const l = ["receive", "sales", "wastage"], $ = [];
|
|
1230
|
-
l.forEach((L) => {
|
|
1231
|
-
u.has(L) && ($.push(L), u.delete(L));
|
|
1232
|
-
});
|
|
1233
|
-
const A = Array.from(u).sort();
|
|
1234
|
-
I.value = [...$, ...A];
|
|
1235
|
-
} catch (u) {
|
|
1236
|
-
t.open({
|
|
1237
|
-
title: "Something went wrong",
|
|
1238
|
-
message: "Something went wrong when fetching info. Please try again.",
|
|
1239
|
-
type: "error"
|
|
1240
|
-
}), console.error("error on fetch stock balances", u);
|
|
1241
|
-
} finally {
|
|
1242
|
-
j.value = !1;
|
|
1243
|
-
}
|
|
1244
|
-
}
|
|
1245
|
-
async function se() {
|
|
1246
|
-
var a, v;
|
|
1247
|
-
if (!(((a = e.draft) == null ? void 0 : a.effectiveAt) ?? (e.draft ? He((v = e.draft) == null ? void 0 : v._id) : null))) {
|
|
1248
|
-
t.open({
|
|
1249
|
-
title: "Cannot refresh",
|
|
1250
|
-
message: "Effective date is not available for this draft.",
|
|
1251
|
-
type: "error"
|
|
1252
|
-
});
|
|
1253
|
-
return;
|
|
1254
|
-
}
|
|
1255
|
-
await y.refreshBalance(
|
|
1256
|
-
e.draft,
|
|
1257
|
-
() => {
|
|
1258
|
-
},
|
|
1259
|
-
async (n) => {
|
|
1260
|
-
var $;
|
|
1261
|
-
V.value = !0;
|
|
1262
|
-
const o = ($ = e.draft) == null ? void 0 : $._rev, u = 30, l = 2e3;
|
|
1263
|
-
try {
|
|
1264
|
-
await W.recalculation.scheduleCalculateStockSnapshotAtDate(n, e.draft._id);
|
|
1265
|
-
let A = null;
|
|
1266
|
-
for (let L = 0; L < u && (A = await m.getDraft(e.draft._id).delayed(l), A._rev === o); L++)
|
|
1267
|
-
;
|
|
1268
|
-
if (!A || A._rev === o) {
|
|
1269
|
-
t.open({
|
|
1270
|
-
title: "Refresh failed",
|
|
1271
|
-
message: "Failed to refresh stock balance. Please try again.",
|
|
1272
|
-
type: "error"
|
|
1273
|
-
}), console.error("error refreshing stock balances: there is no change in _rev");
|
|
1274
|
-
return;
|
|
1275
|
-
}
|
|
1276
|
-
p("refresh", A), x.value = A.stockSnapshot ?? [], t.open({
|
|
1277
|
-
title: "Balance refreshed",
|
|
1278
|
-
message: "Stock balance has been recalculated.",
|
|
1279
|
-
type: "success"
|
|
1280
|
-
}), f.value = !1;
|
|
1281
|
-
} catch (A) {
|
|
1282
|
-
t.open({
|
|
1283
|
-
title: "Refresh failed",
|
|
1284
|
-
message: "Failed to refresh stock balance. Please try again.",
|
|
1285
|
-
type: "error"
|
|
1286
|
-
}), console.error("error refreshing stock balances", A);
|
|
1287
|
-
} finally {
|
|
1288
|
-
V.value = !1;
|
|
1289
|
-
}
|
|
1290
|
-
}
|
|
1291
|
-
);
|
|
1292
|
-
}
|
|
1293
|
-
async function le() {
|
|
1294
|
-
var a, v;
|
|
1295
|
-
if (!(((a = e.draft) == null ? void 0 : a.effectiveAt) ?? (e.draft ? He((v = e.draft) == null ? void 0 : v._id) : null))) {
|
|
1296
|
-
t.open({
|
|
1297
|
-
title: "Cannot refresh",
|
|
1298
|
-
message: "Effective date is not available for this draft.",
|
|
1299
|
-
type: "error"
|
|
1300
|
-
});
|
|
1301
|
-
return;
|
|
1302
|
-
}
|
|
1303
|
-
await y.invalidateDraftCache(e.draft);
|
|
1304
|
-
}
|
|
1305
|
-
const me = M(
|
|
1306
|
-
() => x.value.groupBy(
|
|
1307
|
-
(c) => c.id,
|
|
1308
|
-
(c) => c.balance
|
|
1309
|
-
)
|
|
1310
|
-
), he = M(() => H.value.groupBy((c) => c.sku._id)), ke = M(() => {
|
|
1311
|
-
var c;
|
|
1312
|
-
return (c = e.draft) != null && c.adjustmentSnapshot ? new Map(e.draft.adjustmentSnapshot.map((a) => [a.skuId, a.adjustmentsByType])) : /* @__PURE__ */ new Map();
|
|
1313
|
-
}), Ve = M(() => {
|
|
1314
|
-
var c;
|
|
1315
|
-
return (c = e.draft) != null && c.opening ? new Map(e.draft.opening.map((a) => [a.skuId, a.balance])) : /* @__PURE__ */ new Map();
|
|
1316
|
-
});
|
|
1317
|
-
function te(c, a) {
|
|
1318
|
-
return B(
|
|
1319
|
-
ge.FmTooltip,
|
|
1320
|
-
{ zIndex: 51, placement: "left", class: "w-full flex justify-end" },
|
|
1321
|
-
{
|
|
1322
|
-
default() {
|
|
1323
|
-
return c;
|
|
1324
|
-
},
|
|
1325
|
-
content() {
|
|
1326
|
-
return a || c;
|
|
1327
|
-
}
|
|
1328
|
-
}
|
|
1329
|
-
);
|
|
1330
|
-
}
|
|
1331
|
-
const Te = M(() => {
|
|
1332
|
-
const c = q.value.reduce((v, n) => {
|
|
1333
|
-
var o, u;
|
|
1334
|
-
return Math.max(v, ((u = (o = C.value) == null ? void 0 : o.get(n._id)) == null ? void 0 : u[0].length) ?? 0);
|
|
1335
|
-
}, 0);
|
|
1336
|
-
return [
|
|
1337
|
-
{
|
|
1338
|
-
id: "sku",
|
|
1339
|
-
accessorFn: (v) => `${v.code} ${v.name}`,
|
|
1340
|
-
header: () => "Name",
|
|
1341
|
-
size: 350,
|
|
1342
|
-
cell(v) {
|
|
1343
|
-
const n = v.row.original, o = n.adjustedDiffPercentage, u = typeof o == "number" && Math.abs(o) > 10, l = B("div", { class: "flex flex-col gap-4" }, [
|
|
1344
|
-
B(
|
|
1345
|
-
"div",
|
|
1346
|
-
{
|
|
1347
|
-
class: [
|
|
1348
|
-
"line-clamp-1 fm-typo-en-body-lg-400",
|
|
1349
|
-
u ? " text-fm-color-system-error-300" : "text-fm-color-typo-primary"
|
|
1350
|
-
]
|
|
1351
|
-
},
|
|
1352
|
-
n.name
|
|
1353
|
-
),
|
|
1354
|
-
B(
|
|
1355
|
-
"div",
|
|
1356
|
-
{
|
|
1357
|
-
class: [
|
|
1358
|
-
"line-clamp-1 fm-typo-en-body-md-400",
|
|
1359
|
-
u ? " text-fm-color-system-error-300" : "text-fm-color-typo-secondary"
|
|
1360
|
-
]
|
|
1361
|
-
},
|
|
1362
|
-
n.code
|
|
1363
|
-
)
|
|
1364
|
-
]);
|
|
1365
|
-
return B(
|
|
1366
|
-
ge.FmTooltip,
|
|
1367
|
-
{
|
|
1368
|
-
zIndex: 51
|
|
1369
|
-
},
|
|
1370
|
-
{
|
|
1371
|
-
content() {
|
|
1372
|
-
return u ? "Adjustment difference is more than 10%." : `${n.code} - ${n.name}`;
|
|
1373
|
-
},
|
|
1374
|
-
default() {
|
|
1375
|
-
return B("div", { class: "flex items-center gap-4 justify-start w-full" }, [
|
|
1376
|
-
l
|
|
1377
|
-
]);
|
|
1378
|
-
}
|
|
1379
|
-
}
|
|
1380
|
-
);
|
|
1381
|
-
}
|
|
1382
|
-
},
|
|
1383
|
-
{
|
|
1384
|
-
id: "costPerUnit",
|
|
1385
|
-
accessorKey: "costPerUnit",
|
|
1386
|
-
header: () => te("Cost per unit"),
|
|
1387
|
-
size: 160,
|
|
1388
|
-
cell(v) {
|
|
1389
|
-
const n = v.row.original.costPerUnit;
|
|
1390
|
-
return B("div", { class: "text-right" }, n.toFixed(2));
|
|
1391
|
-
},
|
|
1392
|
-
meta: {
|
|
1393
|
-
textAlign: "right"
|
|
1394
|
-
}
|
|
1395
|
-
},
|
|
1396
|
-
{
|
|
1397
|
-
id: "costUnit",
|
|
1398
|
-
header: () => "UOM",
|
|
1399
|
-
size: 120,
|
|
1400
|
-
cell(v) {
|
|
1401
|
-
var $;
|
|
1402
|
-
const n = v.row.original, o = n.costUnit, u = n.baseUnit, l = o ?? u;
|
|
1403
|
-
if (o && o !== u) {
|
|
1404
|
-
const A = q.value.find((N) => N._id === n.id), L = ($ = A == null ? void 0 : A.defaultCost) == null ? void 0 : $.measurement;
|
|
1405
|
-
if (L) {
|
|
1406
|
-
const N = L.conversion.amount / Math.pow(10, L.conversion.precision);
|
|
1407
|
-
return B("div", { class: "flex flex-col" }, [
|
|
1408
|
-
B(
|
|
1409
|
-
"span",
|
|
1410
|
-
{ class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary" },
|
|
1411
|
-
l
|
|
1412
|
-
),
|
|
1413
|
-
B("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, [
|
|
1414
|
-
"1 ",
|
|
1415
|
-
B("span", { class: "fm-typo-en-body-sm-600" }, o),
|
|
1416
|
-
` = ${N} `,
|
|
1417
|
-
B("span", { class: "fm-typo-en-body-sm-600" }, u)
|
|
1418
|
-
])
|
|
1419
|
-
]);
|
|
1420
|
-
}
|
|
1421
|
-
}
|
|
1422
|
-
return l;
|
|
1423
|
-
}
|
|
1424
|
-
},
|
|
1425
|
-
{
|
|
1426
|
-
id: "opening",
|
|
1427
|
-
accessorKey: "opening",
|
|
1428
|
-
header: () => te("Opening (B/F)", "The opening balance brought forward from previous period."),
|
|
1429
|
-
size: 150,
|
|
1430
|
-
cell(v) {
|
|
1431
|
-
const n = v.row.original.opening;
|
|
1432
|
-
return B("div", { class: "text-right" }, n.toFixed(2));
|
|
1433
|
-
},
|
|
1434
|
-
meta: {
|
|
1435
|
-
textAlign: "right"
|
|
1436
|
-
}
|
|
1437
|
-
},
|
|
1438
|
-
// Dynamic adjustment type columns
|
|
1439
|
-
...I.value.map(
|
|
1440
|
-
(v) => ({
|
|
1441
|
-
id: `adjustment_${v}`,
|
|
1442
|
-
accessorFn: (n) => n.adjustmentAmounts[v] ?? { amount: 0, precision: 0 },
|
|
1443
|
-
header: () => te(Oe(v)),
|
|
1444
|
-
size: 150,
|
|
1445
|
-
cell(n) {
|
|
1446
|
-
const o = n.row.original.adjustmentAmounts[v] ?? { amount: 0, precision: 0 };
|
|
1447
|
-
return B("div", { class: "text-right" }, Xe(o));
|
|
1448
|
-
},
|
|
1449
|
-
meta: {
|
|
1450
|
-
textAlign: "right"
|
|
1451
|
-
}
|
|
1452
|
-
})
|
|
1453
|
-
),
|
|
1454
|
-
{
|
|
1455
|
-
id: "systemBalance",
|
|
1456
|
-
accessorKey: "systemBalance",
|
|
1457
|
-
header: () => te("System Balance", "The system calculated balance before stock take."),
|
|
1458
|
-
size: 200,
|
|
1459
|
-
meta: {
|
|
1460
|
-
textAlign: "right"
|
|
1461
|
-
}
|
|
1462
|
-
},
|
|
1463
|
-
{
|
|
1464
|
-
id: "physicalBalance",
|
|
1465
|
-
accessorFn: (v) => {
|
|
1466
|
-
var o;
|
|
1467
|
-
const n = (o = D.value.find((u) => u.id === v.id)) == null ? void 0 : o.balance;
|
|
1468
|
-
return n ? E.toFormatString({ value: n }) : v.physicalBalance;
|
|
1469
|
-
},
|
|
1470
|
-
header: () => te("Stock Take balance", "The physical balance recorded during stock take."),
|
|
1471
|
-
cell(v) {
|
|
1472
|
-
var A;
|
|
1473
|
-
const n = v.row.original, o = E.fromNumber(n.physicalBalance);
|
|
1474
|
-
let u = !0, l = n.physicalBalance;
|
|
1475
|
-
const $ = (A = D.value.find((L) => L.id === n.id)) == null ? void 0 : A.balance;
|
|
1476
|
-
return $ && (E.equals({
|
|
1477
|
-
a: o,
|
|
1478
|
-
b: $
|
|
1479
|
-
}) || (u = !1, l = Number(E.toFormatString({ value: $ })))), B("div", { class: "flex flex-col" }, [
|
|
1480
|
-
B(
|
|
1481
|
-
"span",
|
|
1482
|
-
{ class: "line-clamp-1 fm-typo-en-body-lg-400 text-fm-color-typo-primary" },
|
|
1483
|
-
l
|
|
1484
|
-
),
|
|
1485
|
-
u ? null : B(
|
|
1486
|
-
"span",
|
|
1487
|
-
{ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" },
|
|
1488
|
-
`Draft: ${n.physicalBalance.toString()}`
|
|
1489
|
-
)
|
|
1490
|
-
]);
|
|
1491
|
-
},
|
|
1492
|
-
size: 200,
|
|
1493
|
-
meta: {
|
|
1494
|
-
textAlign: "right"
|
|
1495
|
-
}
|
|
1496
|
-
},
|
|
1497
|
-
{
|
|
1498
|
-
id: "adjustedAmount",
|
|
1499
|
-
accessorKey: "adjustedAmount",
|
|
1500
|
-
header: () => te("Variance", "The difference between Stock Take balance and System Balance."),
|
|
1501
|
-
size: 200,
|
|
1502
|
-
meta: {
|
|
1503
|
-
textAlign: "right"
|
|
1504
|
-
}
|
|
1505
|
-
},
|
|
1506
|
-
{
|
|
1507
|
-
id: "varianceInCost",
|
|
1508
|
-
accessorKey: "varianceInCost",
|
|
1509
|
-
header: () => te(`Variance (${d.value})`),
|
|
1510
|
-
size: 150,
|
|
1511
|
-
cell(v) {
|
|
1512
|
-
const n = v.row.original.varianceInCost;
|
|
1513
|
-
return B(
|
|
1514
|
-
"div",
|
|
1515
|
-
{ class: "text-right" },
|
|
1516
|
-
n.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 4 })
|
|
1517
|
-
);
|
|
1518
|
-
},
|
|
1519
|
-
meta: {
|
|
1520
|
-
textAlign: "right"
|
|
1521
|
-
}
|
|
1522
|
-
},
|
|
1523
|
-
{
|
|
1524
|
-
id: "adjustedDiffPercentage",
|
|
1525
|
-
accessorKey: "adjustedDiffPercentage",
|
|
1526
|
-
header: () => te(
|
|
1527
|
-
"Variance (%)",
|
|
1528
|
-
"Difference between Stock Take balance and System Balance in percentage."
|
|
1529
|
-
),
|
|
1530
|
-
size: 200,
|
|
1531
|
-
cell(v) {
|
|
1532
|
-
const n = v.row.original.adjustedDiffPercentage;
|
|
1533
|
-
if (!n) return xn;
|
|
1534
|
-
const o = n.toFixed(2);
|
|
1535
|
-
if (o === "0.00")
|
|
1536
|
-
return B("div", { class: "flex items-center gap-4 justify-end" }, ["0.00"]);
|
|
1537
|
-
const u = n > 0;
|
|
1538
|
-
return B("div", { class: "flex items-center gap-4 justify-end" }, [
|
|
1539
|
-
B(ge.FmIcon, {
|
|
1540
|
-
name: u ? "arrow_drop_up" : "arrow_drop_down",
|
|
1541
|
-
color: u ? "system-success-300" : "system-error-300",
|
|
1542
|
-
size: "md"
|
|
1543
|
-
}),
|
|
1544
|
-
o
|
|
1545
|
-
]);
|
|
1546
|
-
},
|
|
1547
|
-
meta: {
|
|
1548
|
-
textAlign: "right"
|
|
1549
|
-
}
|
|
1550
|
-
},
|
|
1551
|
-
{
|
|
1552
|
-
id: "stockTakeValue",
|
|
1553
|
-
accessorKey: "stockTakeValue",
|
|
1554
|
-
header: () => te(`Stock take value (${d.value})`),
|
|
1555
|
-
size: 180,
|
|
1556
|
-
cell(v) {
|
|
1557
|
-
var L;
|
|
1558
|
-
const n = v.row.original, o = n.stockTakeValue, u = q.value.find((N) => N._id === n.id), l = (L = u == null ? void 0 : u.defaultCost) == null ? void 0 : L.measurement, $ = n.physicalBalance, A = n.costPerUnit;
|
|
1559
|
-
if (l) {
|
|
1560
|
-
const N = E.toFormatString({ value: l.conversion }), ie = `${$.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 })} ${n.baseUnit} ÷ ${N} × ${A} ${d.value}`;
|
|
1561
|
-
return B(
|
|
1562
|
-
ge.FmTooltip,
|
|
1563
|
-
{ zIndex: 51 },
|
|
1564
|
-
{
|
|
1565
|
-
content() {
|
|
1566
|
-
return ie;
|
|
1567
|
-
},
|
|
1568
|
-
default() {
|
|
1569
|
-
return B(
|
|
1570
|
-
"div",
|
|
1571
|
-
{ class: "text-right" },
|
|
1572
|
-
o.toLocaleString("en-US", {
|
|
1573
|
-
minimumFractionDigits: 2,
|
|
1574
|
-
maximumFractionDigits: 4
|
|
1575
|
-
})
|
|
1576
|
-
);
|
|
1577
|
-
}
|
|
1578
|
-
}
|
|
1579
|
-
);
|
|
1580
|
-
} else {
|
|
1581
|
-
const N = `${$.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 })} ${n.baseUnit} × ${A} ${d.value}`;
|
|
1582
|
-
return B(
|
|
1583
|
-
ge.FmTooltip,
|
|
1584
|
-
{ zIndex: 51 },
|
|
1585
|
-
{
|
|
1586
|
-
content() {
|
|
1587
|
-
return N;
|
|
1588
|
-
},
|
|
1589
|
-
default() {
|
|
1590
|
-
return B(
|
|
1591
|
-
"div",
|
|
1592
|
-
{ class: "text-right" },
|
|
1593
|
-
o.toLocaleString("en-US", {
|
|
1594
|
-
minimumFractionDigits: 2,
|
|
1595
|
-
maximumFractionDigits: 4
|
|
1596
|
-
})
|
|
1597
|
-
);
|
|
1598
|
-
}
|
|
1599
|
-
}
|
|
1600
|
-
);
|
|
1601
|
-
}
|
|
1602
|
-
},
|
|
1603
|
-
meta: {
|
|
1604
|
-
textAlign: "right"
|
|
1605
|
-
}
|
|
1606
|
-
},
|
|
1607
|
-
{
|
|
1608
|
-
id: "systemValue",
|
|
1609
|
-
accessorKey: "systemValue",
|
|
1610
|
-
header: () => te(`System value (${d.value})`),
|
|
1611
|
-
size: 180,
|
|
1612
|
-
cell(v) {
|
|
1613
|
-
var L;
|
|
1614
|
-
const n = v.row.original, o = n.systemValue, u = q.value.find((N) => N._id === n.id), l = (L = u == null ? void 0 : u.defaultCost) == null ? void 0 : L.measurement, $ = n.systemBalance, A = n.costPerUnit;
|
|
1615
|
-
if (l) {
|
|
1616
|
-
const N = E.toFormatString({ value: l.conversion }), ie = `${$.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 4 })} ${n.baseUnit} ÷ ${N} × ${A} ${d.value}`;
|
|
1617
|
-
return B(
|
|
1618
|
-
ge.FmTooltip,
|
|
1619
|
-
{ zIndex: 51 },
|
|
1620
|
-
{
|
|
1621
|
-
content() {
|
|
1622
|
-
return ie;
|
|
1623
|
-
},
|
|
1624
|
-
default() {
|
|
1625
|
-
return B(
|
|
1626
|
-
"div",
|
|
1627
|
-
{ class: "text-right" },
|
|
1628
|
-
o.toLocaleString("en-US", {
|
|
1629
|
-
minimumFractionDigits: 2,
|
|
1630
|
-
maximumFractionDigits: 4
|
|
1631
|
-
})
|
|
1632
|
-
);
|
|
1633
|
-
}
|
|
1634
|
-
}
|
|
1635
|
-
);
|
|
1636
|
-
} else {
|
|
1637
|
-
const N = `${$.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 4 })} ${n.baseUnit} × ${A} ${d.value}`;
|
|
1638
|
-
return B(
|
|
1639
|
-
ge.FmTooltip,
|
|
1640
|
-
{ zIndex: 51 },
|
|
1641
|
-
{
|
|
1642
|
-
content() {
|
|
1643
|
-
return N;
|
|
1644
|
-
},
|
|
1645
|
-
default() {
|
|
1646
|
-
return B(
|
|
1647
|
-
"div",
|
|
1648
|
-
{ class: "text-right" },
|
|
1649
|
-
o.toLocaleString("en-US", {
|
|
1650
|
-
minimumFractionDigits: 2,
|
|
1651
|
-
maximumFractionDigits: 4
|
|
1652
|
-
})
|
|
1653
|
-
);
|
|
1654
|
-
}
|
|
1655
|
-
}
|
|
1656
|
-
);
|
|
1657
|
-
}
|
|
1658
|
-
},
|
|
1659
|
-
meta: {
|
|
1660
|
-
textAlign: "right"
|
|
1661
|
-
}
|
|
1662
|
-
},
|
|
1663
|
-
{
|
|
1664
|
-
id: "physicalBalances",
|
|
1665
|
-
header: () => "Amounts",
|
|
1666
|
-
enableSorting: !1,
|
|
1667
|
-
cell(v) {
|
|
1668
|
-
const n = v.row.original, o = (l, $) => B(
|
|
1669
|
-
ge.FmTooltip,
|
|
1670
|
-
{ zIndex: 50 },
|
|
1671
|
-
{
|
|
1672
|
-
default() {
|
|
1673
|
-
return B(
|
|
1674
|
-
"div",
|
|
1675
|
-
{
|
|
1676
|
-
class: "fm-typo-en-body-md-400 py-4 px-8 border-1 border-fm-color-typo-secondary fm-corner-radius-md line-clamp-1"
|
|
1677
|
-
},
|
|
1678
|
-
[
|
|
1679
|
-
B("span", { class: "text-fm-color-typo-primary" }, `${l} `),
|
|
1680
|
-
B(
|
|
1681
|
-
"span",
|
|
1682
|
-
{
|
|
1683
|
-
class: "text-fm-color-typo-secondary",
|
|
1684
|
-
style: { maxWidth: "80px" }
|
|
1685
|
-
},
|
|
1686
|
-
$
|
|
1687
|
-
)
|
|
1688
|
-
]
|
|
1689
|
-
);
|
|
1690
|
-
},
|
|
1691
|
-
content() {
|
|
1692
|
-
return `${l} ${$}`;
|
|
1693
|
-
}
|
|
1694
|
-
}
|
|
1695
|
-
);
|
|
1696
|
-
let u = Array.from({ length: c }).map((l, $) => {
|
|
1697
|
-
if (!n[`measurementAmount${$}`])
|
|
1698
|
-
return null;
|
|
1699
|
-
const A = n[`measurementAmount${$}`], L = n[`measurementAbbrev${$}`];
|
|
1700
|
-
return o(A, L);
|
|
1701
|
-
}).filter((l) => l);
|
|
1702
|
-
return (n.baseUnitAmount || !u.length) && (u = [o(n.baseUnitAmount, n.baseUnit), ...u]), B(
|
|
1703
|
-
"div",
|
|
1704
|
-
{
|
|
1705
|
-
class: "flex gap-8 flex-nowrap",
|
|
1706
|
-
style: {
|
|
1707
|
-
minWidth: `${120 * u.length}px`
|
|
1708
|
-
}
|
|
1709
|
-
},
|
|
1710
|
-
u
|
|
1711
|
-
);
|
|
1712
|
-
}
|
|
1713
|
-
}
|
|
1714
|
-
];
|
|
1715
|
-
}), Pe = M(() => Te.value.map((c) => c.size ?? 0).reduce((c, a) => c + a)), xe = Y(""), je = M(() => {
|
|
1716
|
-
var v, n;
|
|
1717
|
-
const c = ((n = (v = e.draft) == null ? void 0 : v.negativeStockItems) == null ? void 0 : n.reduce(
|
|
1718
|
-
(o, u) => (o[u.sku._id] = u, o),
|
|
1719
|
-
{}
|
|
1720
|
-
)) ?? {};
|
|
1721
|
-
return q.value.map((o) => {
|
|
1722
|
-
var rt, lt, it, ct, ut, dt, mt, ft, pt, vt, gt;
|
|
1723
|
-
const u = (rt = he.value.get(o._id)) == null ? void 0 : rt[0], l = ((lt = me.value.get(o._id)) == null ? void 0 : lt[0]) ?? b, $ = ((it = o.defaultCost) == null ? void 0 : it.costPerUnit) ?? b, A = Number(E.toFormatString({ value: $ })), L = ((ut = (ct = o.defaultCost) == null ? void 0 : ct.measurement) == null ? void 0 : ut.conversion) ?? {
|
|
1724
|
-
amount: 1,
|
|
1725
|
-
precision: 0
|
|
1726
|
-
}, N = Number(
|
|
1727
|
-
E.toFormatString({ value: L })
|
|
1728
|
-
), ie = Ve.value.get(o._id), ue = ie ? Number(E.toFormatString({ value: ie })) : 0, De = ke.value.get(o._id), pe = {};
|
|
1729
|
-
if (I.value.forEach((ee) => {
|
|
1730
|
-
const de = pe[ee] ?? { amount: 0, precision: 0 }, fe = De == null ? void 0 : De[ee];
|
|
1731
|
-
fe && (pe[ee] = Xt(de, fe));
|
|
1732
|
-
}), !u) {
|
|
1733
|
-
const ee = Number(E.toFormatString({ value: l })), de = ee - 0, fe = de * A / N, Ne = 0, Pt = ee * A / N;
|
|
1734
|
-
return {
|
|
1735
|
-
id: o._id,
|
|
1736
|
-
code: o.code,
|
|
1737
|
-
name: o.name,
|
|
1738
|
-
costUnit: ((mt = (dt = o.defaultCost) == null ? void 0 : dt.measurement) == null ? void 0 : mt.abbrev) ?? null,
|
|
1739
|
-
baseUnit: o.unit.abbrev,
|
|
1740
|
-
baseUnitAmount: 0,
|
|
1741
|
-
systemBalance: ee,
|
|
1742
|
-
physicalBalance: 0,
|
|
1743
|
-
adjustedAmount: -ee,
|
|
1744
|
-
adjustedDiffPercentage: -100,
|
|
1745
|
-
isTemplateItem: !c[o._id],
|
|
1746
|
-
costPerUnit: A,
|
|
1747
|
-
opening: ue,
|
|
1748
|
-
varianceQty: de,
|
|
1749
|
-
varianceInCost: fe,
|
|
1750
|
-
stockTakeValue: Ne,
|
|
1751
|
-
systemValue: Pt,
|
|
1752
|
-
adjustmentAmounts: pe
|
|
1753
|
-
};
|
|
1754
|
-
}
|
|
1755
|
-
const U = $t(u), X = (pt = (ft = D.value) == null ? void 0 : ft.find(
|
|
1756
|
-
(ee) => ee.id === o._id
|
|
1757
|
-
)) == null ? void 0 : pt.balance, ae = St(
|
|
1758
|
-
X ?? U,
|
|
1759
|
-
l
|
|
1760
|
-
), ve = l.amount === 0 ? null : wt(ae, {
|
|
1761
|
-
...l,
|
|
1762
|
-
amount: Math.abs(l.amount)
|
|
1763
|
-
}), Fe = ve ? at(ve, G) : null, Ie = Number(E.toFormatString({ value: l })), We = Number(E.toFormatString({ value: U })), st = Ie - We, Ut = st * A / N, Rt = We * A / N, Vt = Ie * A / N;
|
|
1764
|
-
return {
|
|
1765
|
-
id: o._id,
|
|
1766
|
-
code: o.code,
|
|
1767
|
-
name: o.name,
|
|
1768
|
-
costUnit: ((gt = (vt = o.defaultCost) == null ? void 0 : vt.measurement) == null ? void 0 : gt.abbrev) ?? null,
|
|
1769
|
-
baseUnit: o.unit.abbrev,
|
|
1770
|
-
baseUnitAmount: Number(E.toFormatString({ value: u.baseAmount })),
|
|
1771
|
-
...u.measurementsAmounts.filter((ee) => {
|
|
1772
|
-
var de, fe, Ne;
|
|
1773
|
-
return (Ne = (fe = (de = C.value) == null ? void 0 : de.get(o._id)) == null ? void 0 : fe[0]) == null ? void 0 : Ne.includes(ee.measurement.id);
|
|
1774
|
-
}).reduce((ee, de, fe) => (ee[`measurementAbbrev${fe}`] = `(${de.measurement.abbrev}) × ${E.toFormatString({ value: de.measurement.conversion })}`, ee[`measurementAmount${fe}`] = Number(E.toFormatString({ value: de.amount })), ee), {}),
|
|
1775
|
-
systemBalance: Ie,
|
|
1776
|
-
physicalBalance: We,
|
|
1777
|
-
adjustedAmount: Number(E.toFormatString({ value: ae })),
|
|
1778
|
-
adjustedDiffPercentage: Fe ? Number(
|
|
1779
|
-
E.toFormatString({
|
|
1780
|
-
value: Ft(Fe, 2)
|
|
1781
|
-
})
|
|
1782
|
-
) : null,
|
|
1783
|
-
isTemplateItem: !c[o._id],
|
|
1784
|
-
costPerUnit: A,
|
|
1785
|
-
opening: ue,
|
|
1786
|
-
varianceQty: st,
|
|
1787
|
-
varianceInCost: Ut,
|
|
1788
|
-
stockTakeValue: Rt,
|
|
1789
|
-
systemValue: Vt,
|
|
1790
|
-
adjustmentAmounts: pe
|
|
1791
|
-
};
|
|
1792
|
-
}).filter((o) => !!(o.isTemplateItem && w.value.templateItem || !o.isTemplateItem && w.value.nonTemplateItem));
|
|
1793
|
-
}), Ae = M(() => {
|
|
1794
|
-
var a, v, n, o, u;
|
|
1795
|
-
if (!e.draft) return [];
|
|
1796
|
-
const c = e.draft.approvedAt ? {
|
|
1797
|
-
action: `Approve at ${ye(e.draft.approvedAt)}`,
|
|
1798
|
-
// actionAt: props.draft.approvedAt,
|
|
1799
|
-
actionBy: e.draft.approvedBy,
|
|
1800
|
-
remark: e.draft.approveRemark
|
|
1801
|
-
} : (a = e.draft.rejectionHistory) == null ? void 0 : a.computeFirst((l) => ({
|
|
1802
|
-
action: `Reject at ${ye(l.rejectedAt)}`,
|
|
1803
|
-
// actionAt: e.rejectedAt,
|
|
1804
|
-
actionBy: l.rejectedBy,
|
|
1805
|
-
remark: l.rejectRemark
|
|
1806
|
-
}));
|
|
1807
|
-
return [
|
|
1808
|
-
{
|
|
1809
|
-
label: "Location",
|
|
1810
|
-
value: ((v = R._currentLocation) == null ? void 0 : v.name) ?? "N/A"
|
|
1811
|
-
},
|
|
1812
|
-
{
|
|
1813
|
-
label: "Created at",
|
|
1814
|
-
value: ye(e.draft.createdAt)
|
|
1815
|
-
},
|
|
1816
|
-
{
|
|
1817
|
-
label: "Created by",
|
|
1818
|
-
value: e.draft.createdBy.name
|
|
1819
|
-
},
|
|
1820
|
-
{
|
|
1821
|
-
label: "Updated at",
|
|
1822
|
-
value: ye(e.draft.updatedAt)
|
|
1823
|
-
},
|
|
1824
|
-
{
|
|
1825
|
-
label: "Updated by",
|
|
1826
|
-
value: e.draft.updatedBy.name
|
|
1827
|
-
},
|
|
1828
|
-
{
|
|
1829
|
-
label: "Effective at",
|
|
1830
|
-
value: ye(e.draft.effectiveAt ?? He((n = e.draft) == null ? void 0 : n._id))
|
|
1831
|
-
},
|
|
1832
|
-
{
|
|
1833
|
-
label: "Using template",
|
|
1834
|
-
value: ((o = e.draft.usingTemplates.find((l) => l)) == null ? void 0 : o.name) ?? "None"
|
|
1835
|
-
},
|
|
1836
|
-
e.draft.remark ? {
|
|
1837
|
-
label: "Remark",
|
|
1838
|
-
value: e.draft.remark
|
|
1839
|
-
} : null,
|
|
1840
|
-
c ? {
|
|
1841
|
-
label: "Last action",
|
|
1842
|
-
value: c.action
|
|
1843
|
-
} : null,
|
|
1844
|
-
c && c.actionBy ? {
|
|
1845
|
-
label: "Last action by",
|
|
1846
|
-
value: (u = c.actionBy) == null ? void 0 : u.name
|
|
1847
|
-
} : null,
|
|
1848
|
-
c && c.remark ? {
|
|
1849
|
-
label: "Action remark",
|
|
1850
|
-
value: c.remark
|
|
1851
|
-
} : null
|
|
1852
|
-
].filter((l) => l).map((l) => l);
|
|
1853
|
-
}), Se = [
|
|
1854
|
-
{
|
|
1855
|
-
label: "Overview",
|
|
1856
|
-
value: "overview"
|
|
1857
|
-
},
|
|
1858
|
-
{
|
|
1859
|
-
label: "Action history",
|
|
1860
|
-
value: "history"
|
|
1861
|
-
}
|
|
1862
|
-
], _e = Y(Se[0]), we = M(() => {
|
|
1863
|
-
var n, o, u;
|
|
1864
|
-
const c = ((n = e.draft) == null ? void 0 : n.activityLogs) ?? [], a = ((o = e.draft) == null ? void 0 : o.rejectionHistory) ?? [];
|
|
1865
|
-
for (const l of a)
|
|
1866
|
-
c.find(
|
|
1867
|
-
(A) => `${A.action}_${A.performedAt}` == `${Q.enum.rejectDraft}_${l.rejectedAt}`
|
|
1868
|
-
) || c.push({
|
|
1869
|
-
action: Q.enum.rejectDraft,
|
|
1870
|
-
performedAt: l.rejectedAt,
|
|
1871
|
-
performedBy: l.rejectedBy,
|
|
1872
|
-
remark: l.rejectRemark
|
|
1873
|
-
});
|
|
1874
|
-
return (u = e.draft) != null && u.approvedAt && (c.find(
|
|
1875
|
-
($) => {
|
|
1876
|
-
var A;
|
|
1877
|
-
return `${$.action}_${$.performedAt}` == `${Q.enum.approveDraft}_${(A = e.draft) == null ? void 0 : A.approvedAt}`;
|
|
1878
|
-
}
|
|
1879
|
-
) || c.push({
|
|
1880
|
-
action: Q.enum.approveDraft,
|
|
1881
|
-
performedAt: e.draft.approvedAt,
|
|
1882
|
-
performedBy: e.draft.approvedBy ?? { name: "Unknown", id: "unknown" },
|
|
1883
|
-
remark: e.draft.approveRemark
|
|
1884
|
-
})), c.sort((l, $) => new Date($.performedAt).getTime() - new Date(l.performedAt).getTime()).map(
|
|
1885
|
-
(l) => ({
|
|
1886
|
-
header: Oe(l.action),
|
|
1887
|
-
date: ye(l.performedAt),
|
|
1888
|
-
info: [
|
|
1889
|
-
{
|
|
1890
|
-
label: "Performed by",
|
|
1891
|
-
values: [l.performedBy.name]
|
|
1892
|
-
},
|
|
1893
|
-
{
|
|
1894
|
-
label: "Remark",
|
|
1895
|
-
values: [l.remark ?? ""]
|
|
1896
|
-
}
|
|
1897
|
-
]
|
|
1898
|
-
})
|
|
1899
|
-
);
|
|
1900
|
-
}), Me = Y(!1), Le = Y(!1), jt = M(() => {
|
|
1901
|
-
var o, u;
|
|
1902
|
-
const c = je.value.filter((l) => l.physicalBalance < 0).map((l) => ({
|
|
1903
|
-
code: l.code,
|
|
1904
|
-
name: l.name
|
|
1905
|
-
})), a = ((u = (o = _.stockBalance.skus) == null ? void 0 : o.filter((l) => l.balance.amount < 0)) == null ? void 0 : u.map((l) => l.id)) ?? [], v = new Set(q.value.map((l) => l._id)), n = a.filter((l) => !v.has(l)).map((l) => {
|
|
1906
|
-
var $, A;
|
|
1907
|
-
return {
|
|
1908
|
-
code: (($ = S.skuById[l]) == null ? void 0 : $.code) ?? "N/A",
|
|
1909
|
-
name: ((A = S.skuById[l]) == null ? void 0 : A.name) ?? "N/A"
|
|
1910
|
-
};
|
|
1911
|
-
});
|
|
1912
|
-
return [...c, ...n];
|
|
1913
|
-
}), ot = M(() => {
|
|
1914
|
-
var c;
|
|
1915
|
-
return ((c = e.draft) == null ? void 0 : c.status) !== be.enum.DRAFT ? "Status is not draft." : null;
|
|
1916
|
-
});
|
|
1917
|
-
function It() {
|
|
1918
|
-
e.draft && (Le.value = !0, y.approveDraft(
|
|
1919
|
-
e.draft,
|
|
1920
|
-
() => {
|
|
1921
|
-
Le.value = !1, Me.value = !1, p("submitted");
|
|
1922
|
-
},
|
|
1923
|
-
() => {
|
|
1924
|
-
Le.value = !1;
|
|
1925
|
-
}
|
|
1926
|
-
));
|
|
1927
|
-
}
|
|
1928
|
-
return (c, a) => {
|
|
1929
|
-
var pe;
|
|
1930
|
-
const v = K("FmButtonGroup"), n = K("FmMenuDivider"), o = K("FmCard"), u = K("FmButton"), l = K("FmCircularProgress"), $ = K("FmChip"), A = K("FmTextField"), L = K("FmIcon"), N = K("FmTable"), ie = K("FmSpacer"), ue = K("FmTooltip"), De = K("FmSideSheet");
|
|
1931
|
-
return F(), P(oe, null, [
|
|
1932
|
-
k(De, {
|
|
1933
|
-
"dismiss-away": "",
|
|
1934
|
-
"max-width": 9999,
|
|
1935
|
-
"model-value": g(f),
|
|
1936
|
-
"onUpdate:modelValue": a[9] || (a[9] = (U) => bt(f) ? f.value = U : null),
|
|
1937
|
-
header: "Closing details"
|
|
1938
|
-
}, {
|
|
1939
|
-
"side-sheet-footer": O(() => {
|
|
1940
|
-
var U, X, ae, ve;
|
|
1941
|
-
return [
|
|
1942
|
-
s("div", Dn, [
|
|
1943
|
-
((U = e.draft) == null ? void 0 : U.status) === g(be).enum.DRAFT ? (F(), P(oe, { key: 0 }, [
|
|
1944
|
-
ot.value ? (F(), ce(ue, {
|
|
1945
|
-
key: 0,
|
|
1946
|
-
"z-index": 51,
|
|
1947
|
-
placement: "right"
|
|
1948
|
-
}, {
|
|
1949
|
-
content: O(() => [
|
|
1950
|
-
re(Z(ot.value), 1)
|
|
1951
|
-
]),
|
|
1952
|
-
default: O(() => [
|
|
1953
|
-
k(u, {
|
|
1954
|
-
disabled: "",
|
|
1955
|
-
key: "approve key",
|
|
1956
|
-
label: "Approve"
|
|
1957
|
-
})
|
|
1958
|
-
]),
|
|
1959
|
-
_: 1
|
|
1960
|
-
})) : (F(), ce(u, {
|
|
1961
|
-
key: "approve key",
|
|
1962
|
-
label: "Approve",
|
|
1963
|
-
onClick: a[5] || (a[5] = (Fe) => Me.value = !0)
|
|
1964
|
-
}))
|
|
1965
|
-
], 64)) : J("", !0),
|
|
1966
|
-
((X = e.draft) == null ? void 0 : X.status) === g(be).enum.DRAFT ? (F(), ce(u, {
|
|
1967
|
-
key: 1,
|
|
1968
|
-
label: "Reject",
|
|
1969
|
-
variant: "destructive",
|
|
1970
|
-
onClick: a[6] || (a[6] = () => e.draft && g(y).rejectDraft(e.draft, () => p("submitted")))
|
|
1971
|
-
})) : J("", !0),
|
|
1972
|
-
(ae = e.draft) != null && ae.approvedAt && ((ve = e.draft) == null ? void 0 : ve.status) !== g(be).enum.COMPLETED ? (F(), ce(Je, { key: 2 }, {
|
|
1973
|
-
default: O(() => [
|
|
1974
|
-
k(u, {
|
|
1975
|
-
label: "Sync",
|
|
1976
|
-
loading: T.value,
|
|
1977
|
-
onClick: a[7] || (a[7] = () => {
|
|
1978
|
-
e.draft && (T.value = !0, g(y).syncDraft(e.draft, () => {
|
|
1979
|
-
T.value = !1, p("submitted");
|
|
1980
|
-
}));
|
|
1981
|
-
})
|
|
1982
|
-
}, null, 8, ["loading"])
|
|
1983
|
-
]),
|
|
1984
|
-
_: 1
|
|
1985
|
-
})) : J("", !0),
|
|
1986
|
-
k(u, {
|
|
1987
|
-
label: "Close",
|
|
1988
|
-
variant: "tertiary",
|
|
1989
|
-
onClick: a[8] || (a[8] = (Fe) => f.value = !1)
|
|
1990
|
-
})
|
|
1991
|
-
])
|
|
1992
|
-
];
|
|
1993
|
-
}),
|
|
1994
|
-
default: O(() => [
|
|
1995
|
-
s("div", Ea, [
|
|
1996
|
-
s("div", null, [
|
|
1997
|
-
k(v, {
|
|
1998
|
-
items: Se,
|
|
1999
|
-
modelValue: _e.value,
|
|
2000
|
-
"onUpdate:modelValue": a[0] || (a[0] = (U) => _e.value = U)
|
|
2001
|
-
}, null, 8, ["modelValue"])
|
|
2002
|
-
]),
|
|
2003
|
-
_e.value.value === "overview" ? (F(), P(oe, { key: 0 }, [
|
|
2004
|
-
k(o, {
|
|
2005
|
-
variant: "outlined",
|
|
2006
|
-
class: "flex flex-col gap-8 px-12 py-16"
|
|
2007
|
-
}, {
|
|
2008
|
-
default: O(() => {
|
|
2009
|
-
var U, X;
|
|
2010
|
-
return [
|
|
2011
|
-
s("div", za, [
|
|
2012
|
-
a[11] || (a[11] = s("div", { class: "fm-typo-en-body-lg-600" }, "Closing summary", -1)),
|
|
2013
|
-
s("div", Ha, [
|
|
2014
|
-
s("div", {
|
|
2015
|
-
class: Be(["fm-status-badge", g(Ke)(((U = c.draft) == null ? void 0 : U.status) ?? "DRAFT")])
|
|
2016
|
-
}, Z(g(Oe)(((X = c.draft) == null ? void 0 : X.status) ?? "")), 3)
|
|
2017
|
-
])
|
|
2018
|
-
]),
|
|
2019
|
-
k(n),
|
|
2020
|
-
s("div", Oa, [
|
|
2021
|
-
(F(!0), P(oe, null, $e(Ae.value, (ae, ve) => (F(), P("div", {
|
|
2022
|
-
class: "flex flex-col gap-4",
|
|
2023
|
-
key: ve
|
|
2024
|
-
}, [
|
|
2025
|
-
s("div", Ka, [
|
|
2026
|
-
s("div", Ya, Z(ae.label), 1)
|
|
2027
|
-
]),
|
|
2028
|
-
s("div", Qa, Z(ae.value), 1)
|
|
2029
|
-
]))), 128))
|
|
2030
|
-
])
|
|
2031
|
-
];
|
|
2032
|
-
}),
|
|
2033
|
-
_: 1
|
|
2034
|
-
}),
|
|
2035
|
-
s("div", qa, [
|
|
2036
|
-
s("div", Ga, [
|
|
2037
|
-
a[12] || (a[12] = s("div", { class: "flex-1 fm-typo-en-title-sm-600 text-fm-color-typo-primary" }, " Closing items ", -1)),
|
|
2038
|
-
j.value ? J("", !0) : (F(), P("div", Wa, [
|
|
2039
|
-
k(Je, null, {
|
|
2040
|
-
default: O(() => [
|
|
2041
|
-
k(u, {
|
|
2042
|
-
label: "Invalidate Draft Cache",
|
|
2043
|
-
"prepend-icon": "refresh",
|
|
2044
|
-
variant: "secondary",
|
|
2045
|
-
"text-color": "primary",
|
|
2046
|
-
"bg-color": "transparent",
|
|
2047
|
-
"border-color": "primary",
|
|
2048
|
-
loading: V.value,
|
|
2049
|
-
onClick: le
|
|
2050
|
-
}, null, 8, ["loading"])
|
|
2051
|
-
]),
|
|
2052
|
-
_: 1
|
|
2053
|
-
}),
|
|
2054
|
-
k(u, {
|
|
2055
|
-
label: "Export data",
|
|
2056
|
-
"prepend-icon": "download",
|
|
2057
|
-
variant: "secondary",
|
|
2058
|
-
"text-color": "primary",
|
|
2059
|
-
"bg-color": "transparent",
|
|
2060
|
-
"border-color": "primary",
|
|
2061
|
-
onClick: a[1] || (a[1] = (U) => c.draft ? g(y).exportDraft(
|
|
2062
|
-
c.draft,
|
|
2063
|
-
x.value,
|
|
2064
|
-
D.value
|
|
2065
|
-
) : null)
|
|
2066
|
-
})
|
|
2067
|
-
]))
|
|
2068
|
-
]),
|
|
2069
|
-
j.value ? (F(), P("div", Za, [
|
|
2070
|
-
a[14] || (a[14] = s("div", { class: "h-80" }, null, -1)),
|
|
2071
|
-
s("div", Ja, [
|
|
2072
|
-
s("div", null, [
|
|
2073
|
-
k(l, { size: "md" })
|
|
2074
|
-
]),
|
|
2075
|
-
a[13] || (a[13] = s("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Fetching info... ", -1))
|
|
2076
|
-
]),
|
|
2077
|
-
a[15] || (a[15] = s("div", { class: "h-80" }, null, -1))
|
|
2078
|
-
])) : (F(), P(oe, { key: 1 }, [
|
|
2079
|
-
s("div", Xa, [
|
|
2080
|
-
s("div", en, [
|
|
2081
|
-
k($, {
|
|
2082
|
-
label: "Template Item(s)",
|
|
2083
|
-
selected: w.value.templateItem,
|
|
2084
|
-
onClick: a[2] || (a[2] = (U) => w.value.templateItem = !w.value.templateItem)
|
|
2085
|
-
}, null, 8, ["selected"]),
|
|
2086
|
-
k($, {
|
|
2087
|
-
label: "Non-template Item(s)",
|
|
2088
|
-
selected: w.value.nonTemplateItem,
|
|
2089
|
-
onClick: a[3] || (a[3] = (U) => w.value.nonTemplateItem = !w.value.nonTemplateItem)
|
|
2090
|
-
}, null, 8, ["selected"])
|
|
2091
|
-
]),
|
|
2092
|
-
k(A, {
|
|
2093
|
-
modelValue: xe.value,
|
|
2094
|
-
"onUpdate:modelValue": a[4] || (a[4] = (U) => xe.value = U),
|
|
2095
|
-
placeholder: "Filter items"
|
|
2096
|
-
}, null, 8, ["modelValue"])
|
|
2097
|
-
]),
|
|
2098
|
-
g(S).skuTags.size ? (F(), P("div", tn, [
|
|
2099
|
-
(F(!0), P(oe, null, $e(g(S).skuTags.keys(), (U) => (F(), ce($, {
|
|
2100
|
-
key: `${U}`,
|
|
2101
|
-
label: `${U}`,
|
|
2102
|
-
selectable: "",
|
|
2103
|
-
selected: z[`${U}`],
|
|
2104
|
-
onClick: (X) => z[`${U}`] = !z[`${U}`]
|
|
2105
|
-
}, {
|
|
2106
|
-
default: O(() => [
|
|
2107
|
-
z[`${U}`] ? (F(), ce(L, {
|
|
2108
|
-
key: 0,
|
|
2109
|
-
name: "check",
|
|
2110
|
-
class: "text-white",
|
|
2111
|
-
size: "sm"
|
|
2112
|
-
})) : J("", !0),
|
|
2113
|
-
s("span", {
|
|
2114
|
-
class: Be([
|
|
2115
|
-
"",
|
|
2116
|
-
{
|
|
2117
|
-
"text-white fm-typo-en-body-md-600": z[`${U}`],
|
|
2118
|
-
"text-fm-color-typo-primary fm-typo-en-body-md-400": !z[`${U}`]
|
|
2119
|
-
}
|
|
2120
|
-
])
|
|
2121
|
-
}, Z(U), 3)
|
|
2122
|
-
]),
|
|
2123
|
-
_: 2
|
|
2124
|
-
}, 1032, ["label", "selected", "onClick"]))), 128))
|
|
2125
|
-
])) : J("", !0),
|
|
2126
|
-
s("div", an, [
|
|
2127
|
-
s("div", {
|
|
2128
|
-
style: ht({ height: "600px", minWidth: `${Pe.value}px` })
|
|
2129
|
-
}, [
|
|
2130
|
-
k(N, {
|
|
2131
|
-
"column-defs": Te.value,
|
|
2132
|
-
"row-data": je.value,
|
|
2133
|
-
"search-value": xe.value
|
|
2134
|
-
}, null, 8, ["column-defs", "row-data", "search-value"])
|
|
2135
|
-
], 4)
|
|
2136
|
-
])
|
|
2137
|
-
], 64))
|
|
2138
|
-
])
|
|
2139
|
-
], 64)) : J("", !0),
|
|
2140
|
-
_e.value.value === "history" ? (F(), P("div", nn, [
|
|
2141
|
-
we.value.length ? (F(), P("div", rn, [
|
|
2142
|
-
(F(!0), P(oe, null, $e(we.value, (U, X) => (F(), P(oe, { key: X }, [
|
|
2143
|
-
s("div", ln, [
|
|
2144
|
-
s("div", cn, [
|
|
2145
|
-
s("div", un, [
|
|
2146
|
-
s("div", {
|
|
2147
|
-
class: Be([
|
|
2148
|
-
{
|
|
2149
|
-
"bg-fm-color-primary": X !== 0,
|
|
2150
|
-
"bg-white": X === 0
|
|
2151
|
-
},
|
|
2152
|
-
"w-[2px] h-full"
|
|
2153
|
-
])
|
|
2154
|
-
}, null, 2)
|
|
2155
|
-
]),
|
|
2156
|
-
a[18] || (a[18] = s("div", { class: "h-24 w-24 bg-fm-color-primary rounded-full" }, null, -1)),
|
|
2157
|
-
s("div", dn, [
|
|
2158
|
-
s("div", {
|
|
2159
|
-
class: Be([
|
|
2160
|
-
{
|
|
2161
|
-
"bg-fm-color-primary": X < we.value.length - 1,
|
|
2162
|
-
"bg-white": X >= we.value.length - 1
|
|
2163
|
-
},
|
|
2164
|
-
"w-[2px] h-full"
|
|
2165
|
-
])
|
|
2166
|
-
}, null, 2)
|
|
2167
|
-
])
|
|
2168
|
-
]),
|
|
2169
|
-
s("div", mn, [
|
|
2170
|
-
s("div", fn, Z(U.header), 1),
|
|
2171
|
-
s("div", pn, Z(U.date), 1)
|
|
2172
|
-
])
|
|
2173
|
-
]),
|
|
2174
|
-
s("div", vn, [
|
|
2175
|
-
s("div", gn, [
|
|
2176
|
-
s("div", yn, [
|
|
2177
|
-
s("div", {
|
|
2178
|
-
class: Be([
|
|
2179
|
-
{
|
|
2180
|
-
"bg-fm-color-primary": X < we.value.length - 1,
|
|
2181
|
-
"bg-white": X >= we.value.length - 1
|
|
2182
|
-
},
|
|
2183
|
-
"w-[2px] h-full"
|
|
2184
|
-
])
|
|
2185
|
-
}, null, 2)
|
|
2186
|
-
])
|
|
2187
|
-
]),
|
|
2188
|
-
s("div", bn, [
|
|
2189
|
-
k(o, {
|
|
2190
|
-
variant: "outlined",
|
|
2191
|
-
class: "py-12 px-16"
|
|
2192
|
-
}, {
|
|
2193
|
-
default: O(() => [
|
|
2194
|
-
s("div", hn, [
|
|
2195
|
-
(F(!0), P(oe, null, $e(U.info, (ae, ve) => (F(), P("div", {
|
|
2196
|
-
key: ve,
|
|
2197
|
-
class: "flex flex-col gap-4"
|
|
2198
|
-
}, [
|
|
2199
|
-
s("div", kn, Z(ae == null ? void 0 : ae.label), 1),
|
|
2200
|
-
s("div", _n, [
|
|
2201
|
-
(F(!0), P(oe, null, $e(ae == null ? void 0 : ae.values, (Fe, Ie) => (F(), P("div", {
|
|
2202
|
-
key: Ie,
|
|
2203
|
-
class: "fm-typo-en-body-lg-600"
|
|
2204
|
-
}, Z(Fe), 1))), 128))
|
|
2205
|
-
])
|
|
2206
|
-
]))), 128))
|
|
2207
|
-
])
|
|
2208
|
-
]),
|
|
2209
|
-
_: 2
|
|
2210
|
-
}, 1024)
|
|
2211
|
-
])
|
|
2212
|
-
])
|
|
2213
|
-
], 64))), 128))
|
|
2214
|
-
])) : (F(), P("div", on, [
|
|
2215
|
-
k(ie),
|
|
2216
|
-
s("div", null, [
|
|
2217
|
-
s("img", {
|
|
2218
|
-
src: g(ra),
|
|
2219
|
-
alt: "List is empty"
|
|
2220
|
-
}, null, 8, sn)
|
|
2221
|
-
]),
|
|
2222
|
-
a[16] || (a[16] = s("div", { class: "fm-typo-en-body-lg-600" }, Z("No records found"), -1)),
|
|
2223
|
-
a[17] || (a[17] = s("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary px-16" }, Z("You can track approval and rejection history here"), -1)),
|
|
2224
|
-
k(ie),
|
|
2225
|
-
k(ie)
|
|
2226
|
-
]))
|
|
2227
|
-
])) : J("", !0)
|
|
2228
|
-
])
|
|
2229
|
-
]),
|
|
2230
|
-
_: 1
|
|
2231
|
-
}, 8, ["model-value"]),
|
|
2232
|
-
g(f) ? (F(), ce(Na, {
|
|
2233
|
-
key: 0,
|
|
2234
|
-
show: Me.value,
|
|
2235
|
-
"onUpdate:show": a[10] || (a[10] = (U) => Me.value = U),
|
|
2236
|
-
"negative-items": jt.value,
|
|
2237
|
-
refreshing: V.value,
|
|
2238
|
-
approving: Le.value,
|
|
2239
|
-
"has-stock-snapshot": !!((pe = e.draft) != null && pe.stockSnapshot),
|
|
2240
|
-
onRefresh: se,
|
|
2241
|
-
onApprove: It
|
|
2242
|
-
}, null, 8, ["show", "negative-items", "refreshing", "approving", "has-stock-snapshot"])) : J("", !0)
|
|
2243
|
-
], 64);
|
|
2244
|
-
};
|
|
2245
|
-
}
|
|
2246
|
-
}), Sn = { class: "flex-1 flex flex-col gap-8" }, wn = { class: "flex flex-col" }, Fn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Cn = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, $n = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-2" }, Bn = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, Wn = /* @__PURE__ */ Re({
|
|
2247
|
-
__name: "ClosingDraftView",
|
|
2248
|
-
setup(i) {
|
|
2249
|
-
const { t: r } = _t(), { viewDraft: e } = Qe(), { viewClosingDraftProps: d, viewClosingDraftShow: _ } = Gt(Qe()), y = qe(), f = Sa(), j = Et(), { breakpoints: V } = Kt();
|
|
2250
|
-
y.watchLocation(f.fetchDrafts);
|
|
2251
|
-
const T = M(() => f.loading), x = Y(""), D = M(() => V.value.xs || V.value.sm), I = M(() => D.value ? 10 : 20);
|
|
2252
|
-
function W(S) {
|
|
2253
|
-
switch (S) {
|
|
2254
|
-
case "refresh":
|
|
2255
|
-
return f.fetchDrafts();
|
|
2256
|
-
}
|
|
2257
|
-
}
|
|
2258
|
-
function m(S) {
|
|
2259
|
-
return S;
|
|
2260
|
-
}
|
|
2261
|
-
const t = M(() => D.value ? [
|
|
2262
|
-
{
|
|
2263
|
-
label: r("inventory.common.refresh"),
|
|
2264
|
-
value: "refresh",
|
|
2265
|
-
isPrimary: !1
|
|
2266
|
-
}
|
|
2267
|
-
] : [
|
|
2268
|
-
{
|
|
2269
|
-
label: r("inventory.common.refresh"),
|
|
2270
|
-
value: "refresh",
|
|
2271
|
-
isPrimary: !1
|
|
2272
|
-
}
|
|
2273
|
-
]);
|
|
2274
|
-
return (S, R) => {
|
|
2275
|
-
const z = K("FmTable");
|
|
2276
|
-
return F(), P(oe, null, [
|
|
2277
|
-
k(zt, {
|
|
2278
|
-
title: g(r)("inventory.closing.draft.title"),
|
|
2279
|
-
actions: t.value,
|
|
2280
|
-
"onClick:action": W
|
|
2281
|
-
}, {
|
|
2282
|
-
default: O(() => [
|
|
2283
|
-
s("div", {
|
|
2284
|
-
class: Be([
|
|
2285
|
-
"flex flex-col gap-8 max-h-full",
|
|
2286
|
-
{
|
|
2287
|
-
"p-0": D.value,
|
|
2288
|
-
"px-24 ": !D.value
|
|
2289
|
-
}
|
|
2290
|
-
])
|
|
2291
|
-
}, [
|
|
2292
|
-
k(sa, {
|
|
2293
|
-
"change-location": "",
|
|
2294
|
-
searchable: "",
|
|
2295
|
-
search: x.value,
|
|
2296
|
-
"onUpdate:search": R[0] || (R[0] = (h) => x.value = h)
|
|
2297
|
-
}, null, 8, ["search"]),
|
|
2298
|
-
k(z, {
|
|
2299
|
-
style: ht(g(j).tableHeight),
|
|
2300
|
-
"column-defs": g(f).columnDefs,
|
|
2301
|
-
"row-data": g(f).drafts,
|
|
2302
|
-
"search-value": x.value,
|
|
2303
|
-
loading: T.value,
|
|
2304
|
-
onRowClick: R[1] || (R[1] = (h) => g(e)(h.original)),
|
|
2305
|
-
"page-size": I.value
|
|
2306
|
-
}, {
|
|
2307
|
-
"list-row": O((h) => [
|
|
2308
|
-
k(na, {
|
|
2309
|
-
row: h,
|
|
2310
|
-
onRowClick: (p) => g(e)(p)
|
|
2311
|
-
}, {
|
|
2312
|
-
default: O((p) => {
|
|
2313
|
-
var w, H, q, C, b, G, ne, se, le, me, he, ke, Ve, te, Te, Pe, xe, je, Ae, Se;
|
|
2314
|
-
return [
|
|
2315
|
-
s("div", Sn, [
|
|
2316
|
-
s("div", wn, [
|
|
2317
|
-
s("div", Fn, [
|
|
2318
|
-
k(g(Ee), {
|
|
2319
|
-
render: (q = (H = (w = p._id) == null ? void 0 : w.column) == null ? void 0 : H.columnDef) == null ? void 0 : q.cell,
|
|
2320
|
-
props: (b = (C = p._id) == null ? void 0 : C.getContext) == null ? void 0 : b.call(C)
|
|
2321
|
-
}, null, 8, ["render", "props"])
|
|
2322
|
-
]),
|
|
2323
|
-
s("div", Cn, [
|
|
2324
|
-
k(g(Ee), {
|
|
2325
|
-
render: (se = (ne = (G = p.name) == null ? void 0 : G.column) == null ? void 0 : ne.columnDef) == null ? void 0 : se.cell,
|
|
2326
|
-
props: (me = (le = p.name) == null ? void 0 : le.getContext) == null ? void 0 : me.call(le)
|
|
2327
|
-
}, null, 8, ["render", "props"])
|
|
2328
|
-
]),
|
|
2329
|
-
s("div", $n, Z([
|
|
2330
|
-
...h.original.items.slice(0, 3).map((_e) => _e.sku.name),
|
|
2331
|
-
...h.original.items.length >= 3 ? [`and ${h.original.items.length - 3} more items`] : []
|
|
2332
|
-
].join(", ")), 1),
|
|
2333
|
-
s("div", Bn, [
|
|
2334
|
-
k(g(Ee), {
|
|
2335
|
-
render: (Ve = (ke = (he = p.ref) == null ? void 0 : he.column) == null ? void 0 : ke.columnDef) == null ? void 0 : Ve.cell,
|
|
2336
|
-
props: (Te = (te = p.ref) == null ? void 0 : te.getContext) == null ? void 0 : Te.call(te)
|
|
2337
|
-
}, null, 8, ["render", "props"])
|
|
2338
|
-
])
|
|
2339
|
-
]),
|
|
2340
|
-
s("div", null, [
|
|
2341
|
-
k(g(Ee), {
|
|
2342
|
-
render: (je = (xe = (Pe = p.status) == null ? void 0 : Pe.column) == null ? void 0 : xe.columnDef) == null ? void 0 : je.cell,
|
|
2343
|
-
props: (Se = (Ae = p.status) == null ? void 0 : Ae.getContext) == null ? void 0 : Se.call(Ae)
|
|
2344
|
-
}, null, 8, ["render", "props"])
|
|
2345
|
-
])
|
|
2346
|
-
])
|
|
2347
|
-
];
|
|
2348
|
-
}),
|
|
2349
|
-
_: 2
|
|
2350
|
-
}, 1032, ["row", "onRowClick"])
|
|
2351
|
-
]),
|
|
2352
|
-
_: 1
|
|
2353
|
-
}, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"])
|
|
2354
|
-
], 2)
|
|
2355
|
-
]),
|
|
2356
|
-
_: 1
|
|
2357
|
-
}, 8, ["title", "actions"]),
|
|
2358
|
-
(F(), ce(Lt, { to: "body" }, [
|
|
2359
|
-
k(An, Nt(g(d), {
|
|
2360
|
-
show: g(_),
|
|
2361
|
-
"onUpdate:show": R[2] || (R[2] = (h) => bt(_) ? _.value = h : null),
|
|
2362
|
-
onSubmitted: R[3] || (R[3] = () => (_.value = !1, g(f).fetchDrafts())),
|
|
2363
|
-
onRefresh: R[4] || (R[4] = (h) => g(f).updateDraftRef(h))
|
|
2364
|
-
}), null, 16, ["show"])
|
|
2365
|
-
]))
|
|
2366
|
-
], 64);
|
|
2367
|
-
};
|
|
2368
|
-
}
|
|
2369
|
-
});
|
|
2370
|
-
export {
|
|
2371
|
-
Wn as default
|
|
2372
|
-
};
|