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