@feedmepos/mf-inventory-portal 1.5.13 → 1.5.15
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-DqGcS6Gm.js → App-TjZvFoxX.js} +4 -4
- package/dist/{ApprovalView-BpLssvwC.js → ApprovalView-eEOIQ5l4.js} +19 -19
- package/dist/{BindingsDialog-Bjca56rZ.js → BindingsDialog-BYDTVkcl.js} +2 -2
- package/dist/{BindingsPicker-D3bSjNn3.js → BindingsPicker-YGTnb6hO.js} +2 -2
- package/dist/{BindingsTable-b8uwBXvE.js → BindingsTable-BKbMhIJH.js} +3 -3
- package/dist/ClosingDraftView-DXRIBkkV.js +3351 -0
- package/dist/{ClosingHistoryView-C3V5brh9.js → ClosingHistoryView-BjbIJJbU.js} +5 -5
- package/dist/{ClosingTemplateView-B6hpp5B8.js → ClosingTemplateView-ojf8BIDw.js} +14 -14
- package/dist/{DefaultView-DeN96J1z.js → DefaultView-BjO5Xsog.js} +2 -2
- package/dist/{DeliveryOrderPrintPreview-EnFKjxtA.js → DeliveryOrderPrintPreview-D0regrG3.js} +11 -11
- package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-6M_CG9Xi.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DPuhonzY.js} +2 -2
- package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-RH37--FG.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DPMA4Wb2.js} +2 -2
- package/dist/{FmMultiselectDialog-6mShWQom.js → FmMultiselectDialog-Bp9yki3P.js} +1 -1
- package/dist/{FmMultiselectDialog-CfjwOjv0.js → FmMultiselectDialog-DRzivfHM.js} +2 -2
- package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-ILexyjQI.js → FmUnitInput.vue_vue_type_script_setup_true_lang-Bi4WSj7R.js} +5 -5
- package/dist/{ImportView-Aksgpj3u.js → ImportView-DxaQzZYo.js} +6 -6
- package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-BVa8U4y-.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-D20RwH02.js} +1 -1
- package/dist/{IngredientGroupView-BbJFosjR.js → IngredientGroupView-wxXTJag8.js} +5 -5
- package/dist/{IngredientsView-CN933oCR.js → IngredientsView-B4C9FGWi.js} +15 -15
- package/dist/{IntegrationExplorerView-CAjxn-PC.js → IntegrationExplorerView-B0rs949d.js} +5 -5
- package/dist/{IntegrationView-w4fp4oT4.js → IntegrationView-DzExCwvo.js} +13 -13
- package/dist/{InventoryBindingForm-EBJ3QGaU.js → InventoryBindingForm-JvmnY8AF.js} +1 -1
- package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-CoUtIP_H.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-DwbgSFx4.js} +5 -5
- package/dist/{InventoryBindingSummary-DqplMp3W.js → InventoryBindingSummary-CItjVLcv.js} +1 -1
- package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DtBoicPG.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DvUD7fHl.js} +1 -1
- package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-DsYsq73l.js → PremiumBadge.vue_vue_type_script_setup_true_lang-BJKqDrwG.js} +1 -1
- package/dist/{PublishView-BJIsXl8d.js → PublishView-D_QegMs3.js} +3 -3
- package/dist/{PurchaseOrderPrintPreview-C7HgcwTx.js → PurchaseOrderPrintPreview-CmuKeNIf.js} +11 -11
- package/dist/{ReceiveRequestView-BKfE6CFa.js → ReceiveRequestView-DI6g5jC6.js} +26 -26
- package/dist/{RecipeView-CIcat7Oq.js → RecipeView-BVgOcfrR.js} +17 -17
- package/dist/{SettingsView-DAg0_Cxw.js → SettingsView-CixGxRQd.js} +4 -4
- package/dist/{StockView-DkkBhXdb.js → StockView-Daf-I3IL.js} +600 -574
- package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-B_7-SpUx.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-CSO_q5JA.js} +1 -1
- package/dist/{SupplierView-DdBM6_mn.js → SupplierView-B8Qev2rg.js} +12 -12
- package/dist/{SurchargeView-DO7ccJw4.js → SurchargeView-BuN94QI6.js} +6 -6
- package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-CnmxlHSe.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-kJYfXFm4.js} +2 -2
- package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-CsxPLRxW.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-CEE7xCST.js} +1 -1
- package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-UAe7BwyU.js → TransferDetails.vue_vue_type_script_setup_true_lang-DeKobV0Z.js} +122 -122
- package/dist/{TransferTemplateView-DwNMWpQG.js → TransferTemplateView-BV9NxME9.js} +18 -18
- package/dist/{UnitCostHistoryView-BR_DzquD.js → UnitCostHistoryView-rKLq62kr.js} +4 -4
- package/dist/{UnitDisplayControl.vue_vue_type_script_setup_true_lang-1frVLUSk.js → UnitDisplayControl.vue_vue_type_script_setup_true_lang-mxwyPnQe.js} +5 -5
- package/dist/{UnitView-DHhs6eAM.js → UnitView-COxrM_LG.js} +7 -7
- package/dist/{WarehouseView-BncF3L-E.js → WarehouseView-BMdzvurU.js} +5 -5
- package/dist/WastageTemplateView-Dic2YkjV.js +2381 -0
- package/dist/api/netsuite.d.ts +4 -0
- package/dist/{app-BM6mngFA.js → app-D1BdwMzz.js} +6651 -6545
- package/dist/app.d.ts +4 -0
- package/dist/app.js +1 -1
- package/dist/{closing-template-BD6V7qLl.js → closing-template-C8pRBnl7.js} +1 -1
- package/dist/{date2-DDlrt2dw.js → date2-hnxJPo1W.js} +1 -1
- package/dist/{dayjs.min-CRtl6lAo.js → dayjs.min-CBXl2BVF.js} +20 -20
- package/dist/{decimal-C05Zbycy.js → decimal-CZI0amBj.js} +2 -2
- package/dist/{defineDeepModel-B0S3YXv1.js → defineDeepModel-DHUJaxuI.js} +1 -1
- package/dist/{duplicate-template-DLoKowb8.js → duplicate-template-BLVGBO_d.js} +1 -1
- package/dist/{feature-Hkq4qHGO.js → feature-CR2SCAm3.js} +2 -2
- package/dist/{format-time-from-id-BsGskcws.js → format-time-from-id-BBtkQIyN.js} +1 -1
- package/dist/{format-unit-display-Dbb2764O.js → format-unit-display-Dt5-WxN8.js} +11 -11
- package/dist/{import-export.helper-CwHS2Pr0.js → import-export.helper-DiR7t2zp.js} +6 -6
- package/dist/{index-DOZ0kYer.js → index-BZILIv0R.js} +1 -1
- package/dist/{index-BosCKut7.js → index-DO4GBTOR.js} +1 -1
- package/dist/{index-C-Z_O_57.js → index-aonyAqoo.js} +3 -3
- package/dist/{inventory-core-dart.default-DsrlA0VP.js → inventory-core-dart.default-DG8rR0ha.js} +1 -1
- package/dist/{lz-string-jug66pQ2.js → lz-string-D4Cmx1DN.js} +1 -1
- package/dist/{netsuite-CM1xsb3Q.js → netsuite-DnDj1l4p.js} +2 -2
- package/dist/{number-B1kR4U7C.js → number-DcC1WWRi.js} +3 -3
- package/dist/{predefined-templates-B3VXqLxq.js → predefined-templates-DVM3qSu0.js} +1 -1
- package/dist/{purchase-order-template-BZ7ubNPM.js → purchase-order-template-DqUT1bSb.js} +1 -1
- package/dist/{recalculationUtils-DT_K_oBV.js → recalculationUtils-D4xwsjLG.js} +1 -1
- package/dist/{rules-DXN5yNM9.js → rules-CpKqSvPr.js} +2 -2
- package/dist/{stock-Cwp99-w7.js → stock-BpYiZWJZ.js} +1 -1
- package/dist/{supplier-CNblYzcC.js → supplier-BtBydND7.js} +2 -2
- package/dist/{surcharge-DiXkOxK8.js → surcharge-CR0gICNY.js} +1 -1
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/dist/{uom-rules-B0cj4nFH.js → uom-rules-Cyng_yjk.js} +1 -1
- package/dist/{use-ingredient-select-dialog-CHqjDEzy.js → use-ingredient-select-dialog-CA-c6K22.js} +2 -2
- package/dist/{use-inventory-binding-dialog-CqKj6_hT.js → use-inventory-binding-dialog-B94XDnjH.js} +2 -2
- package/dist/{use-template-enabled-locations-CZf0oezR.js → use-template-enabled-locations-D1HnfBdU.js} +2 -2
- package/dist/{use-transfer-locations-BTRfRrp8.js → use-transfer-locations-CpJ1uF6O.js} +7 -7
- package/dist/{useHrmPermission-CYeY_uQ0.js → useHrmPermission-0V5Ljtou.js} +1 -1
- package/dist/{useNavigationMenu-D2DBZszb.js → useNavigationMenu-D-nZnQTJ.js} +2 -2
- package/dist/{useSseClient-DNe-54JD.js → useSseClient-DkJ6O71e.js} +12 -12
- package/dist/views/adjustment-template/wastage-template/actions.d.ts +12 -0
- package/dist/views/adjustment-template/wastage-template/helpers.d.ts +33 -0
- package/dist/views/adjustment-template/wastage-template/helpers.spec.d.ts +1 -0
- package/dist/views/adjustment-template/wastage-template/props.d.ts +2 -0
- package/dist/views/adjustment-template/wastage-template/table.d.ts +12 -0
- package/dist/{vue-i18n-CRix8f2i.js → vue-i18n-B14xUn_-.js} +169 -169
- package/dist/{xlsx-4npyDw84.js → xlsx-DL2bAGsa.js} +1 -1
- package/dist/{xlsx.util-C-DEH9b0.js → xlsx.util-BwcP3er4.js} +3 -3
- package/package.json +5 -5
- package/dist/ClosingDraftView-DufSupv2.js +0 -3343
- package/dist/WastageTemplateView-e3ixwHt1.js +0 -2327
|
@@ -0,0 +1,3351 @@
|
|
|
1
|
+
import { defineComponent as Be, ref as q, computed as T, onMounted as Ot, resolveComponent as Q, openBlock as k, createElementBlock as M, Fragment as le, createTextVNode as ce, createBlock as ne, withCtx as Z, createElementVNode as o, toDisplayString as H, unref as d, createVNode as $, createCommentVNode as Y, h as _, watch as Ie, renderList as he, onUnmounted as wn, reactive as zt, isRef as kt, normalizeClass as Ae, normalizeStyle as Ht, createSlots as xn, Teleport as Dn, mergeProps as An } from "vue";
|
|
2
|
+
import { u as Cn, _ as Sn } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-DGlWE5I8.js";
|
|
3
|
+
import { useCoreStore as Yt, useI18n as Oe } from "@feedmepos/mf-common";
|
|
4
|
+
import { useSnackbar as He, useDialog as $n, components as fe, useProxiedModel as Kt, useBreakpoints as Fn } from "@feedmepos/ui-library";
|
|
5
|
+
import { m as In, u as Ye, M as re, w as ee, q as Wt, s as $e, O as we, B as Fe, c as Bn, a as _t, j as Tn } from "./app-D1BdwMzz.js";
|
|
6
|
+
import { defineStore as qt, storeToRefs as jn } from "pinia";
|
|
7
|
+
import { b as lt, e as Gt, f as Mn, a as De } from "./date2-hnxJPo1W.js";
|
|
8
|
+
import { R as Un } from "./rules-CpKqSvPr.js";
|
|
9
|
+
import { e as it, a as ht, t as Qt, c as Le, l as Zt, m as Jt, j as Xt, k as en, o as te } from "./number-DcC1WWRi.js";
|
|
10
|
+
import { b as Rn, d as Pn } from "./xlsx.util-BwcP3er4.js";
|
|
11
|
+
import { i as tn, u as nn } from "./uom-rules-Cyng_yjk.js";
|
|
12
|
+
import { u as Vn, a as Nn } from "./useSseClient-DkJ6O71e.js";
|
|
13
|
+
import { u as ut } from "./stock-BpYiZWJZ.js";
|
|
14
|
+
import { D as Et, R as Ve } from "./row-action.enum-DQ9bJ_uv.js";
|
|
15
|
+
import { c as zn } from "./component-kqxARxvM.js";
|
|
16
|
+
import { f as En } from "./format-time-from-id-BBtkQIyN.js";
|
|
17
|
+
import { f as Ln } from "./recalculationUtils-D4xwsjLG.js";
|
|
18
|
+
import { _ as On } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DPMA4Wb2.js";
|
|
19
|
+
import { _ as Hn } from "./empty-placeholder-B0QU467o.js";
|
|
20
|
+
import { F as gt } from "./FmAdminBadge-DjnBAgyv.js";
|
|
21
|
+
import { u as Yn } from "./vue-i18n-B14xUn_-.js";
|
|
22
|
+
import { F as Kn } from "./decimal-CZI0amBj.js";
|
|
23
|
+
import { r as Wn, u as st, w as qn } from "./xlsx-DL2bAGsa.js";
|
|
24
|
+
import { d as Gn } from "./dayjs.min-CBXl2BVF.js";
|
|
25
|
+
import { F as Qn } from "./FmDroppableField-J0xUsOTV.js";
|
|
26
|
+
import { _ as Zn } from "./FmConfirmationButton.vue_vue_type_script_setup_true_lang-DLrMEGFR.js";
|
|
27
|
+
import { _ as Jn, F as ot } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-Ca_eYa8-.js";
|
|
28
|
+
const Ke = In((a, l) => {
|
|
29
|
+
function t() {
|
|
30
|
+
return Ye().currentLocation.dbName;
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
getDbName: t,
|
|
34
|
+
async getDraft(s) {
|
|
35
|
+
const b = t(), i = `${a.inventoryBackendUrl}/${b}/closing-draft/${s}`;
|
|
36
|
+
return l.get(i);
|
|
37
|
+
},
|
|
38
|
+
async readDrafts() {
|
|
39
|
+
const s = t(), b = `${a.inventoryBackendUrl}/${s}/closing-draft`;
|
|
40
|
+
return l.get(b);
|
|
41
|
+
},
|
|
42
|
+
async runOperation(s) {
|
|
43
|
+
const b = t(), i = `${a.inventoryBackendUrl}/${b}/closing-draft/run-operation`;
|
|
44
|
+
return l.post(i, s);
|
|
45
|
+
},
|
|
46
|
+
async runOperationV1(s) {
|
|
47
|
+
const b = t(), i = `${a.inventoryBackendUrl}/${b}/closing-draft/v1/run-operation`;
|
|
48
|
+
return l.post(i, s);
|
|
49
|
+
},
|
|
50
|
+
async sync(s) {
|
|
51
|
+
const b = t(), i = `${a.inventoryBackendUrl}/${b}/closing-draft/sync`;
|
|
52
|
+
return l.post(i, s);
|
|
53
|
+
},
|
|
54
|
+
async cloneDraft(s) {
|
|
55
|
+
const b = t(), i = `${a.inventoryBackendUrl}/${b}/closing-draft/${s}/clone`;
|
|
56
|
+
return l.post(i, {});
|
|
57
|
+
},
|
|
58
|
+
async createQuickModeDraftWithItems(s) {
|
|
59
|
+
const b = t(), i = `${a.inventoryBackendUrl}/${b}/closing-draft/quick-mode/new-with-items`;
|
|
60
|
+
return l.post(i, s);
|
|
61
|
+
},
|
|
62
|
+
initializeStockSnapshot(s, b) {
|
|
63
|
+
const i = t(), r = `${a.inventoryBackendUrl}/${i}/closing-draft/${encodeURIComponent(s)}/initialize-stock-snapshot`;
|
|
64
|
+
return l.post(r, { effectiveAt: b });
|
|
65
|
+
},
|
|
66
|
+
async getRefreshBalanceStatus(s, b) {
|
|
67
|
+
const i = t(), r = `${a.inventoryBackendUrl}/${i}/closing-draft/${s}/refresh-balance/status?closingDraftRevision=${encodeURIComponent(b)}`;
|
|
68
|
+
return l.get(r);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}), Xn = { class: "fm-typo-en-body-lg-400" }, ea = { class: "fm-typo-en-body-lg-600" }, ta = {
|
|
72
|
+
key: 0,
|
|
73
|
+
class: "flex flex-col"
|
|
74
|
+
}, na = {
|
|
75
|
+
key: 0,
|
|
76
|
+
class: "fm-typo-en-body-sm-400 text-fm-color-typo-error mt-4"
|
|
77
|
+
}, aa = { class: "flex gap-12 py-8 justify-end w-full" }, bt = /* @__PURE__ */ Be({
|
|
78
|
+
__name: "ClosingDraftAction",
|
|
79
|
+
props: {
|
|
80
|
+
draft: {},
|
|
81
|
+
action: {},
|
|
82
|
+
onCancel: { type: Function },
|
|
83
|
+
onFinished: { type: Function }
|
|
84
|
+
},
|
|
85
|
+
setup(a) {
|
|
86
|
+
const l = a, t = q(), s = Ke(), b = He(), i = q(!1), r = q(null), c = q(!1), w = T(() => {
|
|
87
|
+
switch (l.action) {
|
|
88
|
+
case re.enum.approveDraft:
|
|
89
|
+
return "Approve";
|
|
90
|
+
case re.enum.rejectDraft:
|
|
91
|
+
return "Reject";
|
|
92
|
+
case re.enum.markAsFailed:
|
|
93
|
+
return "Mark as Failed";
|
|
94
|
+
}
|
|
95
|
+
throw new Error(`Unknown action: ${l.action}`);
|
|
96
|
+
}), A = T(() => {
|
|
97
|
+
switch (l.action) {
|
|
98
|
+
case re.enum.approveDraft:
|
|
99
|
+
return "primary";
|
|
100
|
+
case re.enum.rejectDraft:
|
|
101
|
+
return "destructive";
|
|
102
|
+
case re.enum.markAsFailed:
|
|
103
|
+
return "destructive";
|
|
104
|
+
}
|
|
105
|
+
throw new Error(`Unknown action: ${l.action}`);
|
|
106
|
+
});
|
|
107
|
+
Ot(() => {
|
|
108
|
+
if (l.draft.effectiveAt)
|
|
109
|
+
r.value = new Date(l.draft.effectiveAt);
|
|
110
|
+
else {
|
|
111
|
+
const I = new Date(l.draft.createdAt);
|
|
112
|
+
I.setHours(23, 59, 59, 999), r.value = I;
|
|
113
|
+
}
|
|
114
|
+
c.value = !0;
|
|
115
|
+
});
|
|
116
|
+
const p = T({
|
|
117
|
+
get() {
|
|
118
|
+
return r.value === null ? "" : lt(r.value);
|
|
119
|
+
},
|
|
120
|
+
set(I) {
|
|
121
|
+
if (I) {
|
|
122
|
+
const D = /* @__PURE__ */ new Date(`${I} ${j.value}`);
|
|
123
|
+
D.setSeconds(59, 999), r.value = D;
|
|
124
|
+
} else
|
|
125
|
+
r.value = null;
|
|
126
|
+
}
|
|
127
|
+
}), j = T({
|
|
128
|
+
get() {
|
|
129
|
+
return r.value === null ? "" : Gt(r.value);
|
|
130
|
+
},
|
|
131
|
+
set(I) {
|
|
132
|
+
if (I) {
|
|
133
|
+
const D = /* @__PURE__ */ new Date(`${p.value} ${I}`);
|
|
134
|
+
D.setSeconds(59, 999), r.value = D;
|
|
135
|
+
} else
|
|
136
|
+
r.value = null;
|
|
137
|
+
}
|
|
138
|
+
}), N = T(() => r.value ? r.value.getTime() > (/* @__PURE__ */ new Date()).getTime() : !1);
|
|
139
|
+
async function z(I) {
|
|
140
|
+
i.value = !0;
|
|
141
|
+
try {
|
|
142
|
+
I ? await s.runOperationV1({
|
|
143
|
+
_id: l.draft._id,
|
|
144
|
+
_rev: l.draft._rev ?? "",
|
|
145
|
+
action: l.action,
|
|
146
|
+
data: {
|
|
147
|
+
effectiveAt: r.value ? r.value.toISOString() : null,
|
|
148
|
+
remark: t.value
|
|
149
|
+
}
|
|
150
|
+
}).delayed(500) : await s.runOperation({
|
|
151
|
+
_id: l.draft._id,
|
|
152
|
+
_rev: l.draft._rev ?? "",
|
|
153
|
+
action: l.action,
|
|
154
|
+
data: {
|
|
155
|
+
effectiveAt: r.value ? r.value.toISOString() : null,
|
|
156
|
+
remark: t.value
|
|
157
|
+
}
|
|
158
|
+
}).delayed(500), b.open({
|
|
159
|
+
title: "Success",
|
|
160
|
+
message: "Action submitted",
|
|
161
|
+
type: "success"
|
|
162
|
+
}), l.onFinished();
|
|
163
|
+
} catch (D) {
|
|
164
|
+
b.open({
|
|
165
|
+
title: "Something went wrong",
|
|
166
|
+
message: (D == null ? void 0 : D.message) ?? "Unable to submit action. Please try again",
|
|
167
|
+
type: "error"
|
|
168
|
+
}), console.error("error on submit closing draft action", D);
|
|
169
|
+
} finally {
|
|
170
|
+
i.value = !1;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return (I, D) => {
|
|
174
|
+
const P = Q("FmLabel"), v = Q("FmDatePicker"), m = Q("FmTimePicker"), f = Q("FmTextField"), g = Q("FmButton"), y = Q("FmForm");
|
|
175
|
+
return c.value ? (k(), ne(y, {
|
|
176
|
+
key: 1,
|
|
177
|
+
onValidationSuccess: z,
|
|
178
|
+
class: "flex flex-col gap-32",
|
|
179
|
+
disabled: i.value
|
|
180
|
+
}, {
|
|
181
|
+
default: Z(() => [
|
|
182
|
+
o("div", Xn, [
|
|
183
|
+
D[4] || (D[4] = ce(" You are about to ")),
|
|
184
|
+
o("span", ea, H(w.value), 1),
|
|
185
|
+
D[5] || (D[5] = ce(" this draft. Please provide a remark to justify this action. "))
|
|
186
|
+
]),
|
|
187
|
+
I.action === d(re).enum.approveDraft ? (k(), M("div", ta, [
|
|
188
|
+
$(P, { class: "fm-typo-en-body-lg-600" }, {
|
|
189
|
+
default: Z(() => D[6] || (D[6] = [
|
|
190
|
+
ce("Closing Date")
|
|
191
|
+
])),
|
|
192
|
+
_: 1
|
|
193
|
+
}),
|
|
194
|
+
$(v, {
|
|
195
|
+
modelValue: p.value,
|
|
196
|
+
"onUpdate:modelValue": D[0] || (D[0] = (x) => p.value = x),
|
|
197
|
+
max: d(lt)(/* @__PURE__ */ new Date())
|
|
198
|
+
}, null, 8, ["modelValue", "max"]),
|
|
199
|
+
$(P, { class: "fm-typo-en-body-lg-600" }, {
|
|
200
|
+
default: Z(() => D[7] || (D[7] = [
|
|
201
|
+
ce("Closing Time")
|
|
202
|
+
])),
|
|
203
|
+
_: 1
|
|
204
|
+
}),
|
|
205
|
+
$(m, {
|
|
206
|
+
modelValue: j.value,
|
|
207
|
+
"onUpdate:modelValue": D[1] || (D[1] = (x) => j.value = x)
|
|
208
|
+
}, null, 8, ["modelValue"]),
|
|
209
|
+
N.value ? (k(), M("div", na, " Cannot select future date ")) : Y("", !0)
|
|
210
|
+
])) : Y("", !0),
|
|
211
|
+
$(f, {
|
|
212
|
+
modelValue: t.value,
|
|
213
|
+
"onUpdate:modelValue": D[2] || (D[2] = (x) => t.value = x),
|
|
214
|
+
label: "Remark",
|
|
215
|
+
"label-mark": "required",
|
|
216
|
+
rules: [d(Un)()]
|
|
217
|
+
}, null, 8, ["modelValue", "rules"]),
|
|
218
|
+
o("div", aa, [
|
|
219
|
+
$(g, {
|
|
220
|
+
label: "Cancel",
|
|
221
|
+
variant: "tertiary",
|
|
222
|
+
onClick: D[3] || (D[3] = (x) => I.onCancel())
|
|
223
|
+
}),
|
|
224
|
+
$(g, {
|
|
225
|
+
label: w.value,
|
|
226
|
+
type: "submit",
|
|
227
|
+
variant: A.value,
|
|
228
|
+
loading: i.value
|
|
229
|
+
}, null, 8, ["label", "variant", "loading"])
|
|
230
|
+
])
|
|
231
|
+
]),
|
|
232
|
+
_: 1
|
|
233
|
+
}, 8, ["disabled"])) : (k(), M(le, { key: 0 }, [
|
|
234
|
+
ce("Loading")
|
|
235
|
+
], 64));
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
}), oa = Le(0);
|
|
239
|
+
function an(a) {
|
|
240
|
+
const l = a.measurementsAmounts.groupBy((s) => s.measurement.id), t = a.sku.unit.measurements.reduce((s, b) => {
|
|
241
|
+
var c, w;
|
|
242
|
+
const i = ((w = (c = l.get(b.id)) == null ? void 0 : c[0]) == null ? void 0 : w.amount) ?? oa, r = it(b.conversion, i);
|
|
243
|
+
return s + +ht(r);
|
|
244
|
+
}, +ht(a.baseAmount));
|
|
245
|
+
return Qt(t, a.baseAmount.precision);
|
|
246
|
+
}
|
|
247
|
+
const sa = Le(0), ra = Le(100);
|
|
248
|
+
function la(a, l, t, s, b, i, r, c) {
|
|
249
|
+
var W, de, V, C, oe;
|
|
250
|
+
const w = an(a), A = s ?? w, p = Zt(A, l), j = l.amount === 0 ? null : Jt(p, {
|
|
251
|
+
...l,
|
|
252
|
+
amount: Math.abs(l.amount)
|
|
253
|
+
}), N = j ? it(j, ra) : null, z = ((W = a.sku.defaultCost) == null ? void 0 : W.costPerUnit) ?? { amount: 0, precision: 0 }, I = Number(ee.toFormatString({ value: z })), D = ((V = (de = a.sku.defaultCost) == null ? void 0 : de.measurement) == null ? void 0 : V.conversion) ?? {
|
|
254
|
+
amount: 1,
|
|
255
|
+
precision: 0
|
|
256
|
+
}, P = Number(
|
|
257
|
+
ee.toFormatString({ value: D })
|
|
258
|
+
), v = b ? Number(ee.toFormatString({ value: b })) : 0, m = Number(ee.toFormatString({ value: l })), f = Number(ee.toFormatString({ value: A })), g = f - m, y = g * I / P, x = f * I / P, L = m * I / P, K = {};
|
|
259
|
+
return r && i && r.forEach((E) => {
|
|
260
|
+
const F = { amount: 0, precision: 0 }, G = i[E];
|
|
261
|
+
if (G) {
|
|
262
|
+
const ue = Xt(F, G);
|
|
263
|
+
K[`adjustment_${E}`] = ht(ue);
|
|
264
|
+
} else
|
|
265
|
+
K[`adjustment_${E}`] = "0";
|
|
266
|
+
}), {
|
|
267
|
+
code: a.sku.code,
|
|
268
|
+
name: a.sku.name,
|
|
269
|
+
baseUnit: a.sku.unit.abbrev,
|
|
270
|
+
costUnit: ((oe = (C = a.sku.defaultCost) == null ? void 0 : C.measurement) == null ? void 0 : oe.abbrev) ?? null,
|
|
271
|
+
baseUnitAmount: Number(ee.toFormatString({ value: a.baseAmount })),
|
|
272
|
+
...t.reduce(
|
|
273
|
+
(E, F, G) => {
|
|
274
|
+
const ue = ee.toFormatString({ value: F.conversion }), xe = F.orphan ? " [invalid UOM]" : F.inactive ? " [NetSuite-inactive]" : "";
|
|
275
|
+
return E[`measurementAbbrev${G}`] = `(${F.abbrev}) × ${ue}${xe}`, E[`measurementAmount${G}`] = Number(ee.toFormatString({ value: F.amount })), E;
|
|
276
|
+
},
|
|
277
|
+
{}
|
|
278
|
+
),
|
|
279
|
+
systemBalance: m,
|
|
280
|
+
physicalBalance: f,
|
|
281
|
+
adjustedAmount: Number(ee.toFormatString({ value: p })),
|
|
282
|
+
adjustedDiffPercentage: N ? Number(
|
|
283
|
+
ee.toFormatString({
|
|
284
|
+
value: en(N, 2)
|
|
285
|
+
})
|
|
286
|
+
) : null,
|
|
287
|
+
costPerUnit: I,
|
|
288
|
+
opening: v,
|
|
289
|
+
...K,
|
|
290
|
+
varianceQty: g,
|
|
291
|
+
varianceInCost: y,
|
|
292
|
+
stockTakeValue: x,
|
|
293
|
+
systemValue: L,
|
|
294
|
+
// Include custom attribute values
|
|
295
|
+
...(c ?? []).reduce(
|
|
296
|
+
(E, F) => {
|
|
297
|
+
var ue;
|
|
298
|
+
const G = (ue = a.sku.customAttributes) == null ? void 0 : ue[F];
|
|
299
|
+
return E[`customAttr_${F}`] = G != null ? String(G) : null, E;
|
|
300
|
+
},
|
|
301
|
+
{}
|
|
302
|
+
)
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
function ia(a) {
|
|
306
|
+
let l = 0;
|
|
307
|
+
for (const t of a.values())
|
|
308
|
+
t.length > l && (l = t.length);
|
|
309
|
+
return l;
|
|
310
|
+
}
|
|
311
|
+
function ca(a, l) {
|
|
312
|
+
const t = /* @__PURE__ */ new Map();
|
|
313
|
+
for (const s of a) {
|
|
314
|
+
if (t.has(s.sku._id)) continue;
|
|
315
|
+
const b = new Map(s.sku.unit.measurements.map((c) => [c.id, c])), i = new Map(
|
|
316
|
+
s.measurementsAmounts.map((c) => [c.measurement.id, c.amount])
|
|
317
|
+
), r = [];
|
|
318
|
+
for (const c of s.sku.unit.measurements) {
|
|
319
|
+
const w = i.get(c.id);
|
|
320
|
+
w && r.push({
|
|
321
|
+
id: c.id,
|
|
322
|
+
abbrev: c.abbrev,
|
|
323
|
+
conversion: c.conversion,
|
|
324
|
+
amount: w,
|
|
325
|
+
inactive: tn(c, l),
|
|
326
|
+
orphan: !1
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
for (const c of s.measurementsAmounts)
|
|
330
|
+
b.has(c.measurement.id) || r.push({
|
|
331
|
+
id: c.measurement.id,
|
|
332
|
+
abbrev: c.measurement.abbrev,
|
|
333
|
+
conversion: c.measurement.conversion,
|
|
334
|
+
amount: c.amount,
|
|
335
|
+
inactive: !1,
|
|
336
|
+
orphan: !0
|
|
337
|
+
});
|
|
338
|
+
t.set(s.sku._id, r);
|
|
339
|
+
}
|
|
340
|
+
return t;
|
|
341
|
+
}
|
|
342
|
+
function ua(a, l = [], t = []) {
|
|
343
|
+
const s = Wt(), b = s === "MYR" ? "RM" : s;
|
|
344
|
+
return [
|
|
345
|
+
{
|
|
346
|
+
id: "code",
|
|
347
|
+
name: "Code"
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
id: "name",
|
|
351
|
+
name: "Name"
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
id: "baseUnit",
|
|
355
|
+
name: "Base unit"
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
id: "costPerUnit",
|
|
359
|
+
name: "Cost per unit"
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
id: "costUnit",
|
|
363
|
+
name: "UOM"
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
id: "opening",
|
|
367
|
+
name: "Opening (B/F)"
|
|
368
|
+
},
|
|
369
|
+
// Dynamic adjustment type columns
|
|
370
|
+
...l.map((r) => ({
|
|
371
|
+
id: `adjustment_${r}`,
|
|
372
|
+
name: $e(r)
|
|
373
|
+
})),
|
|
374
|
+
{
|
|
375
|
+
id: "systemBalance",
|
|
376
|
+
name: "System balance (Qty)"
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
id: "physicalBalance",
|
|
380
|
+
name: "Stock take (Qty)"
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
id: "adjustedAmount",
|
|
384
|
+
name: "Variance"
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
id: "varianceInCost",
|
|
388
|
+
name: `Variance (${b})`
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
id: "adjustedDiffPercentage",
|
|
392
|
+
name: "Variance (%)"
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
id: "stockTakeValue",
|
|
396
|
+
name: `Stock take value (${b})`
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
id: "systemValue",
|
|
400
|
+
name: `System value (${b})`
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
id: "baseUnitAmount",
|
|
404
|
+
name: "Base unit amount"
|
|
405
|
+
},
|
|
406
|
+
...Array.from({ length: a }).flatMap((r, c) => [
|
|
407
|
+
{
|
|
408
|
+
id: `measurementAmount${c}`,
|
|
409
|
+
name: `UOM amount ${c + 1}`
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
id: `measurementAbbrev${c}`,
|
|
413
|
+
name: `UOM ${c + 1}`
|
|
414
|
+
}
|
|
415
|
+
]),
|
|
416
|
+
// Dynamic custom attribute columns
|
|
417
|
+
...t.map((r) => ({
|
|
418
|
+
id: `customAttr_${r}`,
|
|
419
|
+
name: $e(r)
|
|
420
|
+
}))
|
|
421
|
+
];
|
|
422
|
+
}
|
|
423
|
+
function da(a, l, t, s = [], b) {
|
|
424
|
+
var ae, W, de, V, C, oe, E;
|
|
425
|
+
const i = l.groupBy(
|
|
426
|
+
(F) => F.id,
|
|
427
|
+
(F) => F.balance
|
|
428
|
+
), r = t.groupBy(
|
|
429
|
+
(F) => F.id,
|
|
430
|
+
(F) => F.balance
|
|
431
|
+
), c = /* @__PURE__ */ new Map();
|
|
432
|
+
if (a.opening)
|
|
433
|
+
for (const F of a.opening)
|
|
434
|
+
c.set(F.skuId, F.balance);
|
|
435
|
+
const w = /* @__PURE__ */ new Set(), A = /* @__PURE__ */ new Map();
|
|
436
|
+
if (a.adjustmentSnapshot)
|
|
437
|
+
for (const F of a.adjustmentSnapshot)
|
|
438
|
+
F.adjustmentsByType && (Object.keys(F.adjustmentsByType).forEach((G) => w.add(G)), A.set(F.skuId, F.adjustmentsByType));
|
|
439
|
+
const p = ["receive", "sales", "wastage"], j = [];
|
|
440
|
+
p.forEach((F) => {
|
|
441
|
+
w.has(F) && (j.push(F), w.delete(F));
|
|
442
|
+
});
|
|
443
|
+
const N = Array.from(w).sort(), z = [...j, ...N], I = [...a.items, ...a.negativeStockItems ?? []], P = Yt().currentBusiness.value, v = ca(I, b), m = I.map((F) => {
|
|
444
|
+
var ve, Ce;
|
|
445
|
+
const G = ((ve = i.get(F.sku._id)) == null ? void 0 : ve[0]) ?? sa, ue = v.get(F.sku._id) ?? [], xe = c.get(F.sku._id), ke = A.get(F.sku._id);
|
|
446
|
+
return la(
|
|
447
|
+
F,
|
|
448
|
+
G,
|
|
449
|
+
ue,
|
|
450
|
+
(Ce = r.get(F.sku._id)) == null ? void 0 : Ce[0],
|
|
451
|
+
xe,
|
|
452
|
+
ke,
|
|
453
|
+
z,
|
|
454
|
+
s
|
|
455
|
+
);
|
|
456
|
+
}), f = ia(v), g = ua(f, z, s), y = [
|
|
457
|
+
["Business name:", P == null ? void 0 : P.name],
|
|
458
|
+
["Business ID:", P == null ? void 0 : P._id],
|
|
459
|
+
["Menu version", P == null ? void 0 : P.menuVersion],
|
|
460
|
+
["Created at", new Date(a.createdAt)],
|
|
461
|
+
["Created by", (ae = a.createdBy) == null ? void 0 : ae.name],
|
|
462
|
+
["Updated at", new Date(a.updatedAt)],
|
|
463
|
+
["Updated by", (W = a.updatedBy) == null ? void 0 : W.name],
|
|
464
|
+
["Recent action", a.approvedAt ? "Approve" : a.rejectionHistory ? "Reject" : ""],
|
|
465
|
+
[
|
|
466
|
+
"Action by",
|
|
467
|
+
a.approvedAt ? (de = a.approvedBy) == null ? void 0 : de.name : a.rejectionHistory ? (C = (V = a.rejectionHistory[0]) == null ? void 0 : V.rejectedBy) == null ? void 0 : C.name : ""
|
|
468
|
+
],
|
|
469
|
+
[
|
|
470
|
+
"Action at",
|
|
471
|
+
a.approvedAt ? new Date(a.approvedAt) : a.rejectionHistory ? new Date((oe = a.rejectionHistory[0]) == null ? void 0 : oe.rejectedAt) : ""
|
|
472
|
+
],
|
|
473
|
+
[
|
|
474
|
+
"Action remark",
|
|
475
|
+
a.approvedAt ? a.approveRemark : a.rejectionHistory ? new Date((E = a.rejectionHistory[0]) == null ? void 0 : E.rejectRemark) : ""
|
|
476
|
+
],
|
|
477
|
+
[],
|
|
478
|
+
g.map((F) => F.name),
|
|
479
|
+
...m.map((F) => g.map((G) => F[G.id]))
|
|
480
|
+
], x = g.map((F) => `system:${F.id}`), L = Rn(y, x), K = `[${P == null ? void 0 : P.name}] closing draft (${Mn(new Date(a.updatedAt))}).xlsx`;
|
|
481
|
+
return Pn(L, K), K;
|
|
482
|
+
}
|
|
483
|
+
const ma = { class: "flex flex-col" }, fa = {
|
|
484
|
+
key: 0,
|
|
485
|
+
class: "fm-typo-en-body-sm-400 text-fm-color-typo-error mt-4"
|
|
486
|
+
}, pa = { class: "flex gap-12 py-8 justify-end w-full" }, va = /* @__PURE__ */ Be({
|
|
487
|
+
__name: "RefreshBalanceAction",
|
|
488
|
+
props: {
|
|
489
|
+
draft: {},
|
|
490
|
+
onCancel: { type: Function },
|
|
491
|
+
onFinished: { type: Function }
|
|
492
|
+
},
|
|
493
|
+
setup(a) {
|
|
494
|
+
const l = a;
|
|
495
|
+
ut();
|
|
496
|
+
const t = q(!1), s = q(null), b = q(!1);
|
|
497
|
+
Ot(() => {
|
|
498
|
+
if (l.draft.effectiveAt)
|
|
499
|
+
s.value = new Date(l.draft.effectiveAt);
|
|
500
|
+
else {
|
|
501
|
+
const A = new Date(l.draft.createdAt);
|
|
502
|
+
A.setHours(23, 59, 59, 999), s.value = A;
|
|
503
|
+
}
|
|
504
|
+
b.value = !0;
|
|
505
|
+
});
|
|
506
|
+
const i = T({
|
|
507
|
+
get() {
|
|
508
|
+
return s.value === null ? "" : lt(s.value);
|
|
509
|
+
},
|
|
510
|
+
set(A) {
|
|
511
|
+
if (A) {
|
|
512
|
+
const p = /* @__PURE__ */ new Date(`${A} ${r.value}`);
|
|
513
|
+
p.setSeconds(59, 999), s.value = p;
|
|
514
|
+
} else
|
|
515
|
+
s.value = null;
|
|
516
|
+
}
|
|
517
|
+
}), r = T({
|
|
518
|
+
get() {
|
|
519
|
+
return s.value === null ? "" : Gt(s.value);
|
|
520
|
+
},
|
|
521
|
+
set(A) {
|
|
522
|
+
if (A) {
|
|
523
|
+
const p = /* @__PURE__ */ new Date(`${i.value} ${A}`);
|
|
524
|
+
p.setSeconds(59, 999), s.value = p;
|
|
525
|
+
} else
|
|
526
|
+
s.value = null;
|
|
527
|
+
}
|
|
528
|
+
}), c = T(() => s.value ? s.value.getTime() > (/* @__PURE__ */ new Date()).getTime() : !1);
|
|
529
|
+
async function w() {
|
|
530
|
+
t.value = !0, l.onFinished(s.value.toISOString());
|
|
531
|
+
}
|
|
532
|
+
return (A, p) => {
|
|
533
|
+
const j = Q("FmLabel"), N = Q("FmDatePicker"), z = Q("FmTimePicker"), I = Q("FmButton"), D = Q("FmForm");
|
|
534
|
+
return b.value ? (k(), ne(D, {
|
|
535
|
+
key: 1,
|
|
536
|
+
onValidationSuccess: w,
|
|
537
|
+
class: "flex flex-col gap-32",
|
|
538
|
+
disabled: t.value
|
|
539
|
+
}, {
|
|
540
|
+
default: Z(() => [
|
|
541
|
+
p[5] || (p[5] = o("div", { class: "fm-typo-en-body-lg-400" }, [
|
|
542
|
+
o("p", null, [
|
|
543
|
+
ce(" Performing "),
|
|
544
|
+
o("span", { class: "fm-typo-en-body-lg-600" }, '"Refresh Balance"'),
|
|
545
|
+
ce(" until closing effective date and time. ")
|
|
546
|
+
]),
|
|
547
|
+
o("p", { class: "mt-2" }, [
|
|
548
|
+
ce(" Please note that this action will "),
|
|
549
|
+
o("b", null, "update"),
|
|
550
|
+
ce(" the effective date and time. ")
|
|
551
|
+
])
|
|
552
|
+
], -1)),
|
|
553
|
+
o("div", ma, [
|
|
554
|
+
$(j, { class: "fm-typo-en-body-lg-600" }, {
|
|
555
|
+
default: Z(() => p[3] || (p[3] = [
|
|
556
|
+
ce("Closing Date")
|
|
557
|
+
])),
|
|
558
|
+
_: 1
|
|
559
|
+
}),
|
|
560
|
+
$(N, {
|
|
561
|
+
modelValue: i.value,
|
|
562
|
+
"onUpdate:modelValue": p[0] || (p[0] = (P) => i.value = P),
|
|
563
|
+
max: d(lt)(/* @__PURE__ */ new Date())
|
|
564
|
+
}, null, 8, ["modelValue", "max"]),
|
|
565
|
+
$(j, { class: "fm-typo-en-body-lg-600" }, {
|
|
566
|
+
default: Z(() => p[4] || (p[4] = [
|
|
567
|
+
ce("Closing Time")
|
|
568
|
+
])),
|
|
569
|
+
_: 1
|
|
570
|
+
}),
|
|
571
|
+
$(z, {
|
|
572
|
+
modelValue: r.value,
|
|
573
|
+
"onUpdate:modelValue": p[1] || (p[1] = (P) => r.value = P)
|
|
574
|
+
}, null, 8, ["modelValue"]),
|
|
575
|
+
c.value ? (k(), M("div", fa, " Cannot select future date ")) : Y("", !0)
|
|
576
|
+
]),
|
|
577
|
+
o("div", pa, [
|
|
578
|
+
$(I, {
|
|
579
|
+
label: "Cancel",
|
|
580
|
+
variant: "tertiary",
|
|
581
|
+
onClick: p[2] || (p[2] = (P) => A.onCancel())
|
|
582
|
+
}),
|
|
583
|
+
$(I, {
|
|
584
|
+
label: "Refresh balance",
|
|
585
|
+
type: "submit",
|
|
586
|
+
variant: "primary",
|
|
587
|
+
loading: t.value,
|
|
588
|
+
disabled: c.value
|
|
589
|
+
}, null, 8, ["loading", "disabled"])
|
|
590
|
+
])
|
|
591
|
+
]),
|
|
592
|
+
_: 1
|
|
593
|
+
}, 8, ["disabled"])) : (k(), M(le, { key: 0 }, [
|
|
594
|
+
ce("Loading")
|
|
595
|
+
], 64));
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
}), ct = qt(
|
|
599
|
+
"closingDraftActions",
|
|
600
|
+
function() {
|
|
601
|
+
const l = $n(), t = He(), s = ut(), b = Ke(), i = Vn(), r = nn(), c = q(!1), w = q();
|
|
602
|
+
function A(g) {
|
|
603
|
+
const y = {
|
|
604
|
+
draft: g
|
|
605
|
+
};
|
|
606
|
+
w.value = y, c.value = !0;
|
|
607
|
+
}
|
|
608
|
+
async function p(g) {
|
|
609
|
+
var x;
|
|
610
|
+
if (g.status === we.enum.COMPLETED) {
|
|
611
|
+
const L = g.closingAdjustmentId;
|
|
612
|
+
if (!L)
|
|
613
|
+
return t.open({
|
|
614
|
+
title: "Something went wrong",
|
|
615
|
+
message: "Closing draft is completed but closing document cannot be found.",
|
|
616
|
+
type: "error"
|
|
617
|
+
}), console.error("Closing draft is completed but closing document cannot be found.", {
|
|
618
|
+
draftId: g._id
|
|
619
|
+
}), [];
|
|
620
|
+
const K = await s.readAdjustmentById(L);
|
|
621
|
+
return ((K == null ? void 0 : K.skus) ?? []).map((W) => ({
|
|
622
|
+
id: W.sku._id,
|
|
623
|
+
balance: W.fromBalance,
|
|
624
|
+
costs: W.fromCostBalances
|
|
625
|
+
}));
|
|
626
|
+
} else
|
|
627
|
+
return await i.readStockBalance(), ((x = i.stockBalance) == null ? void 0 : x.skus) ?? [];
|
|
628
|
+
}
|
|
629
|
+
async function j(g, y, x, L) {
|
|
630
|
+
y || (t.open({
|
|
631
|
+
title: "Exporting",
|
|
632
|
+
message: "Fetching data..."
|
|
633
|
+
}), y = await p(g)), da(
|
|
634
|
+
g,
|
|
635
|
+
y,
|
|
636
|
+
x ?? [],
|
|
637
|
+
L ?? [],
|
|
638
|
+
r.value
|
|
639
|
+
);
|
|
640
|
+
}
|
|
641
|
+
function N(g, y, x) {
|
|
642
|
+
l.open({
|
|
643
|
+
title: "Approve draft",
|
|
644
|
+
contentComponent: bt,
|
|
645
|
+
contentComponentProps: {
|
|
646
|
+
draft: g,
|
|
647
|
+
action: re.enum.approveDraft,
|
|
648
|
+
onFinished: () => {
|
|
649
|
+
l.close(), y == null || y();
|
|
650
|
+
},
|
|
651
|
+
onCancel: () => {
|
|
652
|
+
l.close();
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
}).onClose(() => {
|
|
656
|
+
x == null || x();
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
function z(g, y) {
|
|
660
|
+
l.open({
|
|
661
|
+
title: "Reject draft",
|
|
662
|
+
contentComponent: bt,
|
|
663
|
+
contentComponentProps: {
|
|
664
|
+
draft: g,
|
|
665
|
+
action: re.enum.rejectDraft,
|
|
666
|
+
onFinished: () => {
|
|
667
|
+
l.close(), y == null || y();
|
|
668
|
+
},
|
|
669
|
+
onCancel: () => l.close()
|
|
670
|
+
}
|
|
671
|
+
});
|
|
672
|
+
}
|
|
673
|
+
function I(g, y) {
|
|
674
|
+
l.open({
|
|
675
|
+
title: "Mark draft as failed",
|
|
676
|
+
contentComponent: bt,
|
|
677
|
+
contentComponentProps: {
|
|
678
|
+
draft: g,
|
|
679
|
+
action: re.enum.markAsFailed,
|
|
680
|
+
onFinished: () => {
|
|
681
|
+
l.close(), y == null || y();
|
|
682
|
+
},
|
|
683
|
+
onCancel: () => l.close()
|
|
684
|
+
}
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
async function D(g, y) {
|
|
688
|
+
await b.sync({
|
|
689
|
+
_id: g._id,
|
|
690
|
+
_rev: g._rev ?? "",
|
|
691
|
+
action: re.enum.approveDraft,
|
|
692
|
+
data: {
|
|
693
|
+
remark: g.remark ?? ""
|
|
694
|
+
}
|
|
695
|
+
}).delayed(500), t.open({
|
|
696
|
+
title: "Success",
|
|
697
|
+
message: "Sync requested",
|
|
698
|
+
type: "success"
|
|
699
|
+
}), y == null || y();
|
|
700
|
+
}
|
|
701
|
+
function P() {
|
|
702
|
+
c.value = !1;
|
|
703
|
+
}
|
|
704
|
+
async function v(g, y, x) {
|
|
705
|
+
await l.open({
|
|
706
|
+
title: "Refresh balance",
|
|
707
|
+
contentComponent: va,
|
|
708
|
+
contentComponentProps: {
|
|
709
|
+
draft: g,
|
|
710
|
+
onFinished: (L) => {
|
|
711
|
+
l.close(), x == null || x(L);
|
|
712
|
+
},
|
|
713
|
+
onCancel: async () => {
|
|
714
|
+
l.close(), y == null || y();
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
async function m(g) {
|
|
720
|
+
await l.open({
|
|
721
|
+
title: "Invalidate closing draft cache",
|
|
722
|
+
message: "It will invalidate opening and stock movement cache for this draft.",
|
|
723
|
+
primaryActions: { text: "Proceed", close: !0 },
|
|
724
|
+
secondaryActions: { text: "Cancel", close: !0 }
|
|
725
|
+
}).onPrimary(async () => {
|
|
726
|
+
await s.recalculation.scheduleInvalidateClosingDraftCache([g._id]), t.open({
|
|
727
|
+
title: "Success",
|
|
728
|
+
message: "Invalidate cache requested",
|
|
729
|
+
type: "success"
|
|
730
|
+
});
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
async function f(g, y) {
|
|
734
|
+
try {
|
|
735
|
+
t.open({
|
|
736
|
+
title: "Cloning",
|
|
737
|
+
message: "Creating a copy of the draft..."
|
|
738
|
+
}), await b.cloneDraft(g._id), t.open({
|
|
739
|
+
title: "Success",
|
|
740
|
+
message: "Draft cloned successfully",
|
|
741
|
+
type: "success"
|
|
742
|
+
}), y == null || y();
|
|
743
|
+
} catch (x) {
|
|
744
|
+
t.open({
|
|
745
|
+
title: "Error",
|
|
746
|
+
message: (x == null ? void 0 : x.message) || "Failed to clone draft",
|
|
747
|
+
type: "error"
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
return {
|
|
752
|
+
viewDraft: A,
|
|
753
|
+
closeDraftDialog: P,
|
|
754
|
+
approveDraft: N,
|
|
755
|
+
rejectDraft: z,
|
|
756
|
+
markAsFailed: I,
|
|
757
|
+
syncDraft: D,
|
|
758
|
+
exportDraft: j,
|
|
759
|
+
refreshBalance: v,
|
|
760
|
+
cloneDraft: f,
|
|
761
|
+
viewClosingDraftShow: c,
|
|
762
|
+
viewClosingDraftProps: w,
|
|
763
|
+
invalidateDraftCache: m
|
|
764
|
+
};
|
|
765
|
+
}
|
|
766
|
+
);
|
|
767
|
+
function rt(a) {
|
|
768
|
+
switch (a) {
|
|
769
|
+
case "DRAFT":
|
|
770
|
+
return "fm-status-badge-draft";
|
|
771
|
+
case "PROCESSING":
|
|
772
|
+
return "fm-status-badge-processing";
|
|
773
|
+
case "FAILED":
|
|
774
|
+
return "fm-status-badge-cancel";
|
|
775
|
+
case "COMPLETED":
|
|
776
|
+
return "fm-status-badge-complete";
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
const on = qt(
|
|
780
|
+
"closingDraftTable",
|
|
781
|
+
function() {
|
|
782
|
+
const { t: l } = Oe(), t = Yt(), s = ct(), b = q(new Array()), i = q(0), r = q(!1), c = Ye(), w = Ke();
|
|
783
|
+
async function A() {
|
|
784
|
+
if (b.value = [], !!c._currentLocation) {
|
|
785
|
+
r.value = !0;
|
|
786
|
+
try {
|
|
787
|
+
const [v] = await Promise.all([w.readDrafts()]).delayed(1e3);
|
|
788
|
+
b.value = j(v.reverse());
|
|
789
|
+
} catch (v) {
|
|
790
|
+
console.log("Something went wrong when fetching drafts:", v);
|
|
791
|
+
} finally {
|
|
792
|
+
r.value = !1;
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
async function p(v) {
|
|
797
|
+
if (!b.value.find((m) => m._id) && c._currentLocation) {
|
|
798
|
+
r.value = !0;
|
|
799
|
+
try {
|
|
800
|
+
const [m] = await Promise.all([
|
|
801
|
+
w.getDraft(v),
|
|
802
|
+
new Promise((f) => setTimeout(f, 1e3))
|
|
803
|
+
]);
|
|
804
|
+
b.value = j([m]);
|
|
805
|
+
} catch (m) {
|
|
806
|
+
console.log("Something went wrong when fetching drafts:", m);
|
|
807
|
+
} finally {
|
|
808
|
+
r.value = !1;
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
function j(v) {
|
|
813
|
+
const m = Ln(
|
|
814
|
+
v.filter((f) => !!f.closingId).map((f) => ({ closingId: f.closingId, draftCreatedAt: new Date(Fe(f._id)) }))
|
|
815
|
+
);
|
|
816
|
+
return v.map((f) => ({
|
|
817
|
+
...f,
|
|
818
|
+
closingIdDisplay: f.closingId ? m.get(f.closingId) ?? null : null
|
|
819
|
+
}));
|
|
820
|
+
}
|
|
821
|
+
function N(v) {
|
|
822
|
+
b.value = b.value.map((m) => m._id === v._id ? {
|
|
823
|
+
...v,
|
|
824
|
+
_rev: v._rev,
|
|
825
|
+
closingIdDisplay: m.closingIdDisplay
|
|
826
|
+
} : m), i.value++;
|
|
827
|
+
}
|
|
828
|
+
function z(v) {
|
|
829
|
+
var g, y;
|
|
830
|
+
const m = v.items.length + (((g = v.negativeStockItems) == null ? void 0 : g.length) ?? 0), f = (v == null ? void 0 : v.approveRemark) ?? ((y = v == null ? void 0 : v.rejectionHistory) == null ? void 0 : y.computeFirst((x) => x.rejectRemark)) ?? v.remark ?? "";
|
|
831
|
+
return { count: m, remark: f };
|
|
832
|
+
}
|
|
833
|
+
function I() {
|
|
834
|
+
s.closeDraftDialog(), A();
|
|
835
|
+
}
|
|
836
|
+
function D(v, m) {
|
|
837
|
+
switch (m = Bn(m), v) {
|
|
838
|
+
case Ve.Details:
|
|
839
|
+
return s.viewDraft(m);
|
|
840
|
+
case Ve.Export:
|
|
841
|
+
return s.exportDraft(m);
|
|
842
|
+
case re.enum.approveDraft:
|
|
843
|
+
return s.approveDraft(m, I);
|
|
844
|
+
case re.enum.rejectDraft:
|
|
845
|
+
return s.rejectDraft(m, I);
|
|
846
|
+
case re.enum.markAsFailed:
|
|
847
|
+
return s.markAsFailed(m, I);
|
|
848
|
+
case Ve.Duplicate:
|
|
849
|
+
return s.cloneDraft(m, I);
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
return {
|
|
853
|
+
columnDefs: [
|
|
854
|
+
{
|
|
855
|
+
id: "_id",
|
|
856
|
+
accessorKey: "_id",
|
|
857
|
+
header: () => l("inventory.closing.table.createdAt"),
|
|
858
|
+
cell(v) {
|
|
859
|
+
return En(`${v.getValue()}`);
|
|
860
|
+
},
|
|
861
|
+
sortingFn: (v, m) => new Date(Fe(v.original._id)).getTime() - new Date(Fe(m.original._id)).getTime(),
|
|
862
|
+
enableSorting: !0
|
|
863
|
+
},
|
|
864
|
+
{
|
|
865
|
+
id: "closingId",
|
|
866
|
+
accessorFn: (v) => v.closingIdDisplay,
|
|
867
|
+
size: 160,
|
|
868
|
+
header: () => l("inventory.closing.draft.table.id"),
|
|
869
|
+
cell(v) {
|
|
870
|
+
return v.getValue();
|
|
871
|
+
},
|
|
872
|
+
enableSorting: !0
|
|
873
|
+
},
|
|
874
|
+
{
|
|
875
|
+
accessorKey: "effectiveAt",
|
|
876
|
+
header: () => l("inventory.closing.draft.table.effectiveAt"),
|
|
877
|
+
cell(v) {
|
|
878
|
+
const m = v.row.original;
|
|
879
|
+
let f = v.getValue();
|
|
880
|
+
return f || (f = Fe(m._id)), De(f);
|
|
881
|
+
},
|
|
882
|
+
enableSorting: !0,
|
|
883
|
+
size: 230
|
|
884
|
+
},
|
|
885
|
+
{
|
|
886
|
+
id: "description",
|
|
887
|
+
accessorFn: (v) => {
|
|
888
|
+
const { count: m, remark: f } = z(v);
|
|
889
|
+
return `${m} ${f}`;
|
|
890
|
+
},
|
|
891
|
+
header: () => l("inventory.closing.draft.table.description"),
|
|
892
|
+
enableSorting: !0,
|
|
893
|
+
size: 350,
|
|
894
|
+
cell(v) {
|
|
895
|
+
const { count: m, remark: f } = z(v.row.original), g = (y, x) => _("div", { class: "flex gap-4" }, [
|
|
896
|
+
_(
|
|
897
|
+
"span",
|
|
898
|
+
{ class: "fm-typo-en-body-sm-600 text-fm-color-typo-primary" },
|
|
899
|
+
`${y}:`
|
|
900
|
+
),
|
|
901
|
+
_(
|
|
902
|
+
"span",
|
|
903
|
+
{
|
|
904
|
+
class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary",
|
|
905
|
+
style: "white-space: pre-wrap; word-break: break-word;"
|
|
906
|
+
},
|
|
907
|
+
`${x}`
|
|
908
|
+
)
|
|
909
|
+
]);
|
|
910
|
+
return _("div", { class: "flex flex-col gap-2", style: "width: 300px;" }, [
|
|
911
|
+
g(l("inventory.closing.draft.table.items"), m),
|
|
912
|
+
f ? g(l("inventory.closing.draft.table.remark"), f) : null
|
|
913
|
+
]);
|
|
914
|
+
}
|
|
915
|
+
},
|
|
916
|
+
{
|
|
917
|
+
id: "status",
|
|
918
|
+
accessorFn: (v) => v.status,
|
|
919
|
+
header: () => l("inventory.closing.table.status"),
|
|
920
|
+
enableSorting: !1,
|
|
921
|
+
cell(v) {
|
|
922
|
+
var L;
|
|
923
|
+
const m = v.row.original, f = m.status, g = new Date(m.updatedAt), y = (L = m == null ? void 0 : m.rejectionHistory) == null ? void 0 : L.computeFirst((K) => K.rejectedAt), x = y ? new Date(y) : null;
|
|
924
|
+
return f === "DRAFT" && x ? x.getTime() > g.getTime() ? _(
|
|
925
|
+
"div",
|
|
926
|
+
{
|
|
927
|
+
class: "flex"
|
|
928
|
+
},
|
|
929
|
+
_(
|
|
930
|
+
"div",
|
|
931
|
+
{
|
|
932
|
+
class: ["fm-status-badge", rt("FAILED")]
|
|
933
|
+
},
|
|
934
|
+
"Rejected"
|
|
935
|
+
)
|
|
936
|
+
) : _(
|
|
937
|
+
"div",
|
|
938
|
+
{
|
|
939
|
+
class: "flex"
|
|
940
|
+
},
|
|
941
|
+
_(
|
|
942
|
+
"div",
|
|
943
|
+
{
|
|
944
|
+
class: ["fm-status-badge", rt("PROCESSING")]
|
|
945
|
+
},
|
|
946
|
+
"Updated"
|
|
947
|
+
)
|
|
948
|
+
) : _(
|
|
949
|
+
"div",
|
|
950
|
+
{
|
|
951
|
+
class: "flex"
|
|
952
|
+
},
|
|
953
|
+
_(
|
|
954
|
+
"div",
|
|
955
|
+
{
|
|
956
|
+
class: ["fm-status-badge", rt(f)]
|
|
957
|
+
},
|
|
958
|
+
$e(f)
|
|
959
|
+
)
|
|
960
|
+
);
|
|
961
|
+
}
|
|
962
|
+
},
|
|
963
|
+
{
|
|
964
|
+
id: "updatedAt",
|
|
965
|
+
accessorFn: (v) => v.updatedAt,
|
|
966
|
+
header: () => l("inventory.closing.draft.table.lastUpdate"),
|
|
967
|
+
enableSorting: !0,
|
|
968
|
+
size: 200,
|
|
969
|
+
cell(v) {
|
|
970
|
+
var f;
|
|
971
|
+
const m = v.row.original;
|
|
972
|
+
return _("div", { class: "flex flex-col" }, [
|
|
973
|
+
_(
|
|
974
|
+
"div",
|
|
975
|
+
{ class: "fm-typo-en-body-md-600 text-fm-color-typo-primary" },
|
|
976
|
+
((f = m.updatedBy) == null ? void 0 : f.name) ?? ""
|
|
977
|
+
),
|
|
978
|
+
_(
|
|
979
|
+
"div",
|
|
980
|
+
{ class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" },
|
|
981
|
+
De(m.updatedAt)
|
|
982
|
+
)
|
|
983
|
+
]);
|
|
984
|
+
}
|
|
985
|
+
},
|
|
986
|
+
{
|
|
987
|
+
id: "action",
|
|
988
|
+
cell(v) {
|
|
989
|
+
var L;
|
|
990
|
+
const m = v.row.original, f = ((L = t.sessionUser.value) == null ? void 0 : L.role.isAdmin) ?? !1, g = [
|
|
991
|
+
Et[Ve.Details],
|
|
992
|
+
Et[Ve.Export]
|
|
993
|
+
], y = [
|
|
994
|
+
{
|
|
995
|
+
translationKey: "inventory.closing.draft.approveDraft",
|
|
996
|
+
color: "text-fm-color-typo-primary",
|
|
997
|
+
value: re.enum.approveDraft
|
|
998
|
+
},
|
|
999
|
+
{
|
|
1000
|
+
translationKey: "inventory.closing.draft.rejectDraft",
|
|
1001
|
+
color: "text-fm-color-typo-error",
|
|
1002
|
+
value: re.enum.rejectDraft
|
|
1003
|
+
},
|
|
1004
|
+
{
|
|
1005
|
+
translationKey: "inventory.closing.draft.markAsFailed",
|
|
1006
|
+
color: "text-fm-color-typo-error",
|
|
1007
|
+
value: re.enum.markAsFailed
|
|
1008
|
+
}
|
|
1009
|
+
], x = f && m.status !== we.enum.DRAFT ? [
|
|
1010
|
+
{
|
|
1011
|
+
translationKey: "inventory.closing.draft.cloneDraft",
|
|
1012
|
+
color: "text-fm-color-typo-primary",
|
|
1013
|
+
value: Ve.Duplicate
|
|
1014
|
+
}
|
|
1015
|
+
] : [];
|
|
1016
|
+
return zn(
|
|
1017
|
+
[
|
|
1018
|
+
...g,
|
|
1019
|
+
...m.status === we.enum.DRAFT ? y : []
|
|
1020
|
+
],
|
|
1021
|
+
(K) => D(K, m),
|
|
1022
|
+
x
|
|
1023
|
+
);
|
|
1024
|
+
},
|
|
1025
|
+
enableSorting: !1,
|
|
1026
|
+
size: 40,
|
|
1027
|
+
meta: {
|
|
1028
|
+
cellClass: "",
|
|
1029
|
+
headerClass: ""
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
],
|
|
1033
|
+
drafts: b,
|
|
1034
|
+
loading: r,
|
|
1035
|
+
tableKey: i,
|
|
1036
|
+
fetchDrafts: A,
|
|
1037
|
+
loadDraft: p,
|
|
1038
|
+
updateDraftRef: N
|
|
1039
|
+
};
|
|
1040
|
+
}
|
|
1041
|
+
), ya = { class: "fm-typo-en-heading-lg-600" }, ga = { class: "py-4" }, ba = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary mb-4" }, ha = { key: 0 }, ka = { class: "mt-4 flex gap-4" }, _a = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary mb-4" }, wa = { key: 0 }, xa = {
|
|
1042
|
+
key: 0,
|
|
1043
|
+
class: "mb-4"
|
|
1044
|
+
}, Da = { class: "flex flex-col gap-1 max-h-200 overflow-auto w-full" }, Aa = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ca = {
|
|
1045
|
+
key: 0,
|
|
1046
|
+
class: "text-fm-color-system-success-300 mr-1"
|
|
1047
|
+
}, Sa = {
|
|
1048
|
+
key: 1,
|
|
1049
|
+
class: "text-fm-color-system-error-300 mr-1"
|
|
1050
|
+
}, $a = { class: "fm-typo-en-body-md-400" }, Fa = { class: "mt-4 flex gap-4" }, Ia = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary mb-4" }, Ba = {
|
|
1051
|
+
key: 0,
|
|
1052
|
+
class: "flex gap-4"
|
|
1053
|
+
}, Ta = /* @__PURE__ */ Be({
|
|
1054
|
+
__name: "ClosingDraftApprovalDialog",
|
|
1055
|
+
props: {
|
|
1056
|
+
show: { type: Boolean },
|
|
1057
|
+
refreshing: { type: Boolean },
|
|
1058
|
+
approving: { type: Boolean },
|
|
1059
|
+
draft: {}
|
|
1060
|
+
},
|
|
1061
|
+
emits: ["update:show", "refresh", "approve"],
|
|
1062
|
+
setup(a, { emit: l }) {
|
|
1063
|
+
const { FmStepper: t, FmStep: s, FmDialog: b, FmButton: i } = fe, { t: r } = Yn(), c = _t(), w = a, A = l, p = T(
|
|
1064
|
+
() => {
|
|
1065
|
+
var V, C;
|
|
1066
|
+
return ((V = w.draft) == null ? void 0 : V.stockSnapshot) && ((C = w.draft) == null ? void 0 : C.stockSnapshot) !== void 0;
|
|
1067
|
+
}
|
|
1068
|
+
), j = T(() => {
|
|
1069
|
+
var oe, E, F;
|
|
1070
|
+
const V = ((oe = w.draft) == null ? void 0 : oe.items.map((G) => ({
|
|
1071
|
+
id: G.sku._id,
|
|
1072
|
+
code: G.sku.code,
|
|
1073
|
+
name: G.sku.name
|
|
1074
|
+
}))) ?? [], C = ((F = (E = w.draft) == null ? void 0 : E.negativeStockItems) == null ? void 0 : F.map((G) => ({
|
|
1075
|
+
id: G.sku._id,
|
|
1076
|
+
code: G.sku.code,
|
|
1077
|
+
name: G.sku.name
|
|
1078
|
+
}))) ?? [];
|
|
1079
|
+
return [...V, ...C].reduce(
|
|
1080
|
+
(G, ue) => (G[ue.id] = ue, G),
|
|
1081
|
+
{}
|
|
1082
|
+
);
|
|
1083
|
+
}), N = T(
|
|
1084
|
+
() => {
|
|
1085
|
+
var V, C, oe;
|
|
1086
|
+
return (((oe = (C = (V = w.draft) == null ? void 0 : V.stockSnapshot) == null ? void 0 : C.filter((E) => E.balance.amount < 0)) == null ? void 0 : oe.map((E) => {
|
|
1087
|
+
const F = c.skuById[E.id];
|
|
1088
|
+
return F ? {
|
|
1089
|
+
id: F._id,
|
|
1090
|
+
code: F.code,
|
|
1091
|
+
name: F.name
|
|
1092
|
+
} : null;
|
|
1093
|
+
})) ?? []).filter((E) => E !== null);
|
|
1094
|
+
}
|
|
1095
|
+
), z = T(() => {
|
|
1096
|
+
var V;
|
|
1097
|
+
return p.value ? ((V = N.value) == null ? void 0 : V.filter((C) => !j.value[C.id]).map((C) => C.id)) ?? [] : [];
|
|
1098
|
+
}), I = T({
|
|
1099
|
+
get: () => w.show,
|
|
1100
|
+
set: (V) => A("update:show", V)
|
|
1101
|
+
}), D = q(1), P = () => D.value > 1, v = () => D.value > 2, m = () => !1;
|
|
1102
|
+
function f(V) {
|
|
1103
|
+
return V === 1 ? p.value : V === 2 ? z.value.length == 0 : !1;
|
|
1104
|
+
}
|
|
1105
|
+
const g = T(() => !p.value || z.value.length > 0);
|
|
1106
|
+
function y(V) {
|
|
1107
|
+
let C = V + 1;
|
|
1108
|
+
for (; C <= 3 && f(C); ) C++;
|
|
1109
|
+
return C > 3 ? 3 : C;
|
|
1110
|
+
}
|
|
1111
|
+
function x(V) {
|
|
1112
|
+
let C = V - 1;
|
|
1113
|
+
for (; C >= 1 && f(C); ) C--;
|
|
1114
|
+
return C < 1 ? 1 : C;
|
|
1115
|
+
}
|
|
1116
|
+
function L() {
|
|
1117
|
+
return p.value ? g.value ? 3 : 2 : 1;
|
|
1118
|
+
}
|
|
1119
|
+
Ie(
|
|
1120
|
+
() => w.show,
|
|
1121
|
+
(V) => {
|
|
1122
|
+
V && (D.value = L());
|
|
1123
|
+
}
|
|
1124
|
+
), Ie(
|
|
1125
|
+
() => p.value,
|
|
1126
|
+
(V) => {
|
|
1127
|
+
V && D.value === 1 && (D.value = y(1));
|
|
1128
|
+
}
|
|
1129
|
+
), Ie(
|
|
1130
|
+
() => z.value.length,
|
|
1131
|
+
(V) => {
|
|
1132
|
+
V === 0 && D.value === 2 && (D.value = y(2));
|
|
1133
|
+
}
|
|
1134
|
+
);
|
|
1135
|
+
function K() {
|
|
1136
|
+
A("refresh");
|
|
1137
|
+
}
|
|
1138
|
+
function ae() {
|
|
1139
|
+
D.value < 3 && (D.value = y(D.value));
|
|
1140
|
+
}
|
|
1141
|
+
function W() {
|
|
1142
|
+
D.value > 1 && (D.value = x(D.value));
|
|
1143
|
+
}
|
|
1144
|
+
function de() {
|
|
1145
|
+
A("approve");
|
|
1146
|
+
}
|
|
1147
|
+
return (V, C) => {
|
|
1148
|
+
const oe = Q("FmIcon");
|
|
1149
|
+
return k(), ne(d(b), {
|
|
1150
|
+
modelValue: I.value,
|
|
1151
|
+
"onUpdate:modelValue": C[1] || (C[1] = (E) => I.value = E),
|
|
1152
|
+
"max-width": 600
|
|
1153
|
+
}, {
|
|
1154
|
+
"dialog-header": Z(() => [
|
|
1155
|
+
o("div", ya, H(d(r)("inventory.closing.approval.title")), 1)
|
|
1156
|
+
]),
|
|
1157
|
+
default: Z(() => [
|
|
1158
|
+
o("div", ga, [
|
|
1159
|
+
$(d(t), {
|
|
1160
|
+
modelValue: D.value,
|
|
1161
|
+
"onUpdate:modelValue": C[0] || (C[0] = (E) => D.value = E),
|
|
1162
|
+
orientation: "vertical"
|
|
1163
|
+
}, {
|
|
1164
|
+
default: Z(() => [
|
|
1165
|
+
$(d(s), {
|
|
1166
|
+
value: 1,
|
|
1167
|
+
title: d(r)("inventory.closing.approval.step.generateReport.title"),
|
|
1168
|
+
complete: P
|
|
1169
|
+
}, {
|
|
1170
|
+
default: Z(() => [
|
|
1171
|
+
o("div", ba, H(d(r)("inventory.closing.approval.step.generateReport.description")), 1),
|
|
1172
|
+
D.value === 1 ? (k(), M("div", ha, [
|
|
1173
|
+
$(d(i), {
|
|
1174
|
+
label: d(r)("inventory.stock.stock_balance.refreshBalance"),
|
|
1175
|
+
"prepend-icon": "refresh",
|
|
1176
|
+
variant: "secondary",
|
|
1177
|
+
loading: V.refreshing,
|
|
1178
|
+
disabled: V.refreshing,
|
|
1179
|
+
onClick: K
|
|
1180
|
+
}, null, 8, ["label", "loading", "disabled"]),
|
|
1181
|
+
o("div", ka, [
|
|
1182
|
+
$(d(i), {
|
|
1183
|
+
label: d(r)("inventory.common.continue"),
|
|
1184
|
+
disabled: !p.value,
|
|
1185
|
+
onClick: ae
|
|
1186
|
+
}, null, 8, ["label", "disabled"])
|
|
1187
|
+
])
|
|
1188
|
+
])) : Y("", !0)
|
|
1189
|
+
]),
|
|
1190
|
+
_: 1
|
|
1191
|
+
}, 8, ["title"]),
|
|
1192
|
+
$(d(s), {
|
|
1193
|
+
value: 2,
|
|
1194
|
+
title: d(r)("inventory.closing.approval.step.negativeItems.title"),
|
|
1195
|
+
disabled: () => !p.value,
|
|
1196
|
+
complete: v
|
|
1197
|
+
}, {
|
|
1198
|
+
default: Z(() => [
|
|
1199
|
+
o("div", _a, H(N.value.length > 0 ? `${d(r)("inventory.closing.approval.step.negativeItems.resolveMessage")} [${d(r)("inventory.closing.approval.step.negativeItems.itemsHeader")} (${z.value.length})]` : d(r)("inventory.closing.approval.step.negativeItems.noItemsMessage")), 1),
|
|
1200
|
+
D.value === 2 ? (k(), M("div", wa, [
|
|
1201
|
+
N.value.length > 0 ? (k(), M("div", xa, [
|
|
1202
|
+
C[2] || (C[2] = o("div", { class: "fm-typo-en-body-md-600 mb-2" }, null, -1)),
|
|
1203
|
+
o("div", Da, [
|
|
1204
|
+
(k(!0), M(le, null, he(N.value, (E) => (k(), M("div", {
|
|
1205
|
+
key: E.id,
|
|
1206
|
+
class: "flex gap-8"
|
|
1207
|
+
}, [
|
|
1208
|
+
o("div", Aa, [
|
|
1209
|
+
j.value[E.id] ? (k(), M("span", Ca, [
|
|
1210
|
+
$(oe, {
|
|
1211
|
+
name: "check_circle",
|
|
1212
|
+
size: "sm"
|
|
1213
|
+
})
|
|
1214
|
+
])) : (k(), M("span", Sa, [
|
|
1215
|
+
$(oe, {
|
|
1216
|
+
name: "error",
|
|
1217
|
+
size: "sm"
|
|
1218
|
+
})
|
|
1219
|
+
])),
|
|
1220
|
+
ce(" " + H(E.code), 1)
|
|
1221
|
+
]),
|
|
1222
|
+
o("div", $a, H(E.name), 1)
|
|
1223
|
+
]))), 128))
|
|
1224
|
+
])
|
|
1225
|
+
])) : Y("", !0),
|
|
1226
|
+
o("div", Fa, [
|
|
1227
|
+
$(d(i), {
|
|
1228
|
+
label: d(r)("inventory.common.back"),
|
|
1229
|
+
variant: "secondary",
|
|
1230
|
+
onClick: W
|
|
1231
|
+
}, null, 8, ["label"]),
|
|
1232
|
+
$(d(i), {
|
|
1233
|
+
label: d(r)("inventory.common.continue"),
|
|
1234
|
+
disabled: g.value,
|
|
1235
|
+
onClick: ae
|
|
1236
|
+
}, null, 8, ["label", "disabled"])
|
|
1237
|
+
])
|
|
1238
|
+
])) : Y("", !0)
|
|
1239
|
+
]),
|
|
1240
|
+
_: 1
|
|
1241
|
+
}, 8, ["title", "disabled"]),
|
|
1242
|
+
$(d(s), {
|
|
1243
|
+
value: 3,
|
|
1244
|
+
title: d(r)("inventory.closing.approval.step.approval.title"),
|
|
1245
|
+
disabled: () => g.value,
|
|
1246
|
+
complete: m
|
|
1247
|
+
}, {
|
|
1248
|
+
default: Z(() => [
|
|
1249
|
+
o("div", Ia, H(d(r)("inventory.closing.approval.step.approval.warning")), 1),
|
|
1250
|
+
D.value === 3 ? (k(), M("div", Ba, [
|
|
1251
|
+
$(d(i), {
|
|
1252
|
+
label: d(r)("inventory.common.back"),
|
|
1253
|
+
variant: "secondary",
|
|
1254
|
+
onClick: W
|
|
1255
|
+
}, null, 8, ["label"]),
|
|
1256
|
+
$(d(i), {
|
|
1257
|
+
label: d(r)("inventory.common.approve"),
|
|
1258
|
+
variant: "destructive",
|
|
1259
|
+
disabled: g.value,
|
|
1260
|
+
loading: V.approving,
|
|
1261
|
+
onClick: de
|
|
1262
|
+
}, null, 8, ["label", "disabled", "loading"])
|
|
1263
|
+
])) : Y("", !0)
|
|
1264
|
+
]),
|
|
1265
|
+
_: 1
|
|
1266
|
+
}, 8, ["title", "disabled"])
|
|
1267
|
+
]),
|
|
1268
|
+
_: 1
|
|
1269
|
+
}, 8, ["modelValue"])
|
|
1270
|
+
])
|
|
1271
|
+
]),
|
|
1272
|
+
_: 1
|
|
1273
|
+
}, 8, ["modelValue"]);
|
|
1274
|
+
};
|
|
1275
|
+
}
|
|
1276
|
+
});
|
|
1277
|
+
function ja(a) {
|
|
1278
|
+
const l = Ke(), t = Nn(), s = He(), { t: b } = Oe(), i = q(!1), r = q(null);
|
|
1279
|
+
let c = !1, w = null, A = !1, p = !1;
|
|
1280
|
+
function j() {
|
|
1281
|
+
P();
|
|
1282
|
+
const f = a.closingDraftId.value, g = a.currentRev.value;
|
|
1283
|
+
if (!f || !g)
|
|
1284
|
+
return;
|
|
1285
|
+
c = !1;
|
|
1286
|
+
const y = {
|
|
1287
|
+
type: "closing-draft",
|
|
1288
|
+
params: {
|
|
1289
|
+
draftId: f,
|
|
1290
|
+
locationId: l.getDbName(),
|
|
1291
|
+
closingDraftRevision: g
|
|
1292
|
+
}
|
|
1293
|
+
}, { unsubscribe: x, initialState: L } = t.subscribe(y, z);
|
|
1294
|
+
w = x, L.then((K) => {
|
|
1295
|
+
K != null && K.initialState && z(K.initialState);
|
|
1296
|
+
}).catch((K) => {
|
|
1297
|
+
console.error("Failed to fetch initial state", K);
|
|
1298
|
+
});
|
|
1299
|
+
}
|
|
1300
|
+
function N() {
|
|
1301
|
+
p = !0, j();
|
|
1302
|
+
}
|
|
1303
|
+
async function z(f) {
|
|
1304
|
+
var y;
|
|
1305
|
+
if (c || !f) {
|
|
1306
|
+
r.value = f, i.value = !1;
|
|
1307
|
+
return;
|
|
1308
|
+
}
|
|
1309
|
+
if (f.closingDraftId && f.closingDraftId !== a.closingDraftId.value)
|
|
1310
|
+
return;
|
|
1311
|
+
if (r.value = f, f.message === "processing" || !f.completedAt && !f.message) {
|
|
1312
|
+
A = !0, i.value = !0;
|
|
1313
|
+
return;
|
|
1314
|
+
}
|
|
1315
|
+
if (f.message === "completed" || f.completedAt) {
|
|
1316
|
+
if (!A) {
|
|
1317
|
+
i.value = !1;
|
|
1318
|
+
return;
|
|
1319
|
+
}
|
|
1320
|
+
A = !1, await I();
|
|
1321
|
+
return;
|
|
1322
|
+
}
|
|
1323
|
+
const g = A;
|
|
1324
|
+
A = !1, i.value = !1, g && (console.log("Closing draft balance refresh error:", f), s.open({
|
|
1325
|
+
title: b("inventory.common.refreshFailed"),
|
|
1326
|
+
message: b("inventory.stock.stock_balance.refreshBalanceError"),
|
|
1327
|
+
type: "error"
|
|
1328
|
+
}), (y = a.onError) == null || y.call(a, f.message ?? "Unknown error"));
|
|
1329
|
+
}
|
|
1330
|
+
async function I() {
|
|
1331
|
+
const f = a.closingDraftId.value;
|
|
1332
|
+
if (!f) {
|
|
1333
|
+
i.value = !1;
|
|
1334
|
+
return;
|
|
1335
|
+
}
|
|
1336
|
+
try {
|
|
1337
|
+
const g = await l.getDraft(f);
|
|
1338
|
+
i.value = !1, a.onCompleted(g), s.open({
|
|
1339
|
+
title: "Balance refreshed",
|
|
1340
|
+
message: "Stock balance has been recalculated.",
|
|
1341
|
+
type: "success"
|
|
1342
|
+
});
|
|
1343
|
+
} catch {
|
|
1344
|
+
i.value = !1, s.open({
|
|
1345
|
+
title: "Refresh completed",
|
|
1346
|
+
message: "Balance was refreshed but failed to load updated data. Please reload.",
|
|
1347
|
+
type: "warning"
|
|
1348
|
+
});
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
async function D(f) {
|
|
1352
|
+
if (!(!a.closingDraftId.value || i.value || A)) {
|
|
1353
|
+
i.value = !0, A = !0, r.value = {
|
|
1354
|
+
requestId: "",
|
|
1355
|
+
closingDraftId: a.closingDraftId.value,
|
|
1356
|
+
closingDraftRevision: a.currentRev.value ?? "",
|
|
1357
|
+
message: "processing",
|
|
1358
|
+
startedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1359
|
+
};
|
|
1360
|
+
try {
|
|
1361
|
+
await l.initializeStockSnapshot(a.closingDraftId.value, f);
|
|
1362
|
+
} catch (g) {
|
|
1363
|
+
A = !1, i.value = !1, s.open({
|
|
1364
|
+
title: b("inventory.common.refreshFailed"),
|
|
1365
|
+
message: b("inventory.stock.stock_balance.refreshBalanceError"),
|
|
1366
|
+
type: "error"
|
|
1367
|
+
}), console.error("error starting refresh", g);
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
function P() {
|
|
1372
|
+
c = !1, w && (w(), w = null);
|
|
1373
|
+
}
|
|
1374
|
+
function v() {
|
|
1375
|
+
P(), c = !0, i.value = !1, A = !1, r.value = null;
|
|
1376
|
+
}
|
|
1377
|
+
function m() {
|
|
1378
|
+
p = !1, v();
|
|
1379
|
+
}
|
|
1380
|
+
return Ie(
|
|
1381
|
+
[a.closingDraftId, a.currentRev],
|
|
1382
|
+
([f, g], [y, x]) => {
|
|
1383
|
+
p && (f === y && g === x || j());
|
|
1384
|
+
}
|
|
1385
|
+
), wn(() => {
|
|
1386
|
+
m();
|
|
1387
|
+
}), {
|
|
1388
|
+
refreshing: i,
|
|
1389
|
+
refreshStatus: r,
|
|
1390
|
+
startListening: N,
|
|
1391
|
+
startRefresh: D,
|
|
1392
|
+
cleanup: m
|
|
1393
|
+
};
|
|
1394
|
+
}
|
|
1395
|
+
const Ma = { class: "w-full flex flex-col gap-32" }, Ua = { class: "flex flex-col gap-4" }, Ra = { class: "flex justify-between" }, Pa = { class: "flex" }, Va = { class: "grid grid-cols-[repeat(4,1fr)] xs:flex xs:flex-col sm:flex sm:flex-col gap-8" }, Na = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, za = { class: "flex gap-1" }, Ea = {
|
|
1396
|
+
class: "fm-typo-en-body-lg-600",
|
|
1397
|
+
style: { "white-space": "pre-wrap", "word-break": "break-word" }
|
|
1398
|
+
}, La = {
|
|
1399
|
+
key: 0,
|
|
1400
|
+
class: "flex items-start gap-8 p-12 fm-corner-radius-md border-1 border-yellow-500 bg-yellow-50 text-yellow-700"
|
|
1401
|
+
}, Oa = { class: "flex flex-col gap-2" }, Ha = { class: "fm-typo-en-body-sm-400 list-disc pl-16" }, Ya = { key: 0 }, Ka = { key: 1 }, Wa = { class: "flex flex-col gap-16" }, qa = { class: "flex items-center" }, Ga = {
|
|
1402
|
+
key: 0,
|
|
1403
|
+
class: "flex gap-8"
|
|
1404
|
+
}, Qa = {
|
|
1405
|
+
key: 0,
|
|
1406
|
+
class: "w-full flex flex-col items-center"
|
|
1407
|
+
}, Za = { class: "flex items-center gap-8" }, Ja = { class: "flex flex-col gap-8" }, Xa = { class: "flex gap-8" }, eo = {
|
|
1408
|
+
key: 0,
|
|
1409
|
+
class: "flex gap-8"
|
|
1410
|
+
}, to = {
|
|
1411
|
+
key: 1,
|
|
1412
|
+
class: "flex gap-8 flex-wrap"
|
|
1413
|
+
}, no = { class: "overflow-x-auto" }, ao = {
|
|
1414
|
+
key: 1,
|
|
1415
|
+
class: "flex-1 xs:w-screen xs:max-w-full"
|
|
1416
|
+
}, oo = {
|
|
1417
|
+
key: 0,
|
|
1418
|
+
class: "flex flex-col items-center gap-8 h-full"
|
|
1419
|
+
}, so = ["src"], ro = {
|
|
1420
|
+
key: 1,
|
|
1421
|
+
class: "px-4 flex flex-col"
|
|
1422
|
+
}, lo = { class: "flex gap-12 content-stretch" }, io = {
|
|
1423
|
+
class: "flex flex-col w-24",
|
|
1424
|
+
name: "circles"
|
|
1425
|
+
}, co = { class: "flex-1 flex flex-col items-center" }, uo = { class: "flex-1 flex flex-col items-center" }, mo = {
|
|
1426
|
+
class: "py-12 flex flex-col gap-4",
|
|
1427
|
+
name: "received-at header"
|
|
1428
|
+
}, fo = { class: "fm-typo-en-body-lg-400" }, po = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, vo = { class: "flex gap-12 content-stretch" }, yo = {
|
|
1429
|
+
class: "flex flex-col w-24",
|
|
1430
|
+
name: "circles"
|
|
1431
|
+
}, go = { class: "flex-1 flex flex-col items-center" }, bo = {
|
|
1432
|
+
class: "py-12 flex flex-col gap-4 flex-1",
|
|
1433
|
+
name: "delivery details"
|
|
1434
|
+
}, ho = { class: "flex flex-col gap-8" }, ko = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _o = { class: "flex flex-col gap-4" }, wo = { class: "flex items-center justify-between gap-8 w-full" }, xo = { class: "flex items-center gap-8" }, Do = { class: "flex flex-col items-end" }, Ao = { class: "text-2xl font-semibold" }, Lt = "N/A", Co = /* @__PURE__ */ Be({
|
|
1435
|
+
__name: "ClosingDraftDialog",
|
|
1436
|
+
props: {
|
|
1437
|
+
show: { type: Boolean },
|
|
1438
|
+
draft: {}
|
|
1439
|
+
},
|
|
1440
|
+
emits: ["submitted", "refresh"],
|
|
1441
|
+
setup(a, { emit: l }) {
|
|
1442
|
+
const t = a, s = T(() => {
|
|
1443
|
+
const n = Wt();
|
|
1444
|
+
return n === "MYR" ? "RM" : n;
|
|
1445
|
+
}), b = on(), i = T(() => {
|
|
1446
|
+
var n, e;
|
|
1447
|
+
return (n = t.draft) != null && n.closingId ? ((e = b.drafts.find((u) => u._id === t.draft._id)) == null ? void 0 : e.closingIdDisplay) ?? null : null;
|
|
1448
|
+
}), r = ct(), c = Kt(t, "show"), w = q(!1), A = q(!1), p = q(new Array()), j = q(new Array()), N = T(
|
|
1449
|
+
() => {
|
|
1450
|
+
var n;
|
|
1451
|
+
return ((n = t.draft) == null ? void 0 : n.status) === we.enum.COMPLETED;
|
|
1452
|
+
}
|
|
1453
|
+
), z = T(
|
|
1454
|
+
() => {
|
|
1455
|
+
var n;
|
|
1456
|
+
return N.value ? p.value : ((n = t.draft) == null ? void 0 : n.stockSnapshot) ?? [];
|
|
1457
|
+
}
|
|
1458
|
+
), I = T(
|
|
1459
|
+
() => N.value ? j.value : []
|
|
1460
|
+
), D = T(() => {
|
|
1461
|
+
var B;
|
|
1462
|
+
const n = /* @__PURE__ */ new Set();
|
|
1463
|
+
for (const h of ((B = t.draft) == null ? void 0 : B.adjustmentSnapshot) ?? [])
|
|
1464
|
+
h.adjustmentsByType && Object.keys(h.adjustmentsByType).forEach((U) => n.add(U));
|
|
1465
|
+
const u = ["receive", "sales", "wastage"].filter((h) => n.has(h));
|
|
1466
|
+
return u.forEach((h) => n.delete(h)), [...u, ...Array.from(n).sort()];
|
|
1467
|
+
}), P = ut(), v = He(), m = _t(), f = Ye(), g = zt({}), y = T(() => new Set(
|
|
1468
|
+
m.skus.filter((n) => {
|
|
1469
|
+
var e;
|
|
1470
|
+
return g[(e = n.customAttributes) == null ? void 0 : e.tag];
|
|
1471
|
+
}).map((n) => n._id)
|
|
1472
|
+
)), x = l, L = T(() => {
|
|
1473
|
+
var n;
|
|
1474
|
+
return (n = t.draft) == null ? void 0 : n._id;
|
|
1475
|
+
}), K = T(() => {
|
|
1476
|
+
var n;
|
|
1477
|
+
return (n = t.draft) == null ? void 0 : n._rev;
|
|
1478
|
+
}), {
|
|
1479
|
+
refreshing: ae,
|
|
1480
|
+
startListening: W,
|
|
1481
|
+
startRefresh: de,
|
|
1482
|
+
cleanup: V
|
|
1483
|
+
} = ja({
|
|
1484
|
+
closingDraftId: L,
|
|
1485
|
+
currentRev: K,
|
|
1486
|
+
onCompleted: (n) => {
|
|
1487
|
+
x("refresh", n), c.value = !1;
|
|
1488
|
+
}
|
|
1489
|
+
}), C = q({
|
|
1490
|
+
templateItem: !0,
|
|
1491
|
+
nonTemplateItem: !0
|
|
1492
|
+
}), oe = q(null);
|
|
1493
|
+
function E(n, e) {
|
|
1494
|
+
oe.value = e ? n : oe.value === n ? null : oe.value;
|
|
1495
|
+
}
|
|
1496
|
+
const F = (n) => te(n, { minPrecision: 0, maxPrecision: 3 });
|
|
1497
|
+
function G(n, e) {
|
|
1498
|
+
return e ? "text-fm-color-system-error-300" : n ? "text-purple-500" : "";
|
|
1499
|
+
}
|
|
1500
|
+
function ue(n, e) {
|
|
1501
|
+
return e ? _(fe.FmIcon, { name: "warning", size: "sm", color: "system-error-300" }) : n ? _(fe.FmIcon, { name: "rule", size: "sm" }) : null;
|
|
1502
|
+
}
|
|
1503
|
+
function xe(n) {
|
|
1504
|
+
return _(
|
|
1505
|
+
"div",
|
|
1506
|
+
{
|
|
1507
|
+
class: "p-12 flex flex-col gap-4 fm-typo-en-body-md-400 min-w-[280px] max-w-[420px]"
|
|
1508
|
+
},
|
|
1509
|
+
[
|
|
1510
|
+
_("div", { class: "fm-typo-en-body-sm-600 text-fm-color-typo-secondary mb-4" }, "Breakdown"),
|
|
1511
|
+
...n.breakdown.map(
|
|
1512
|
+
(e) => _("div", { class: "flex justify-between gap-12" }, [
|
|
1513
|
+
_(
|
|
1514
|
+
"div",
|
|
1515
|
+
{ class: ["flex items-center gap-4", G(e.inactive, e.orphan)] },
|
|
1516
|
+
[ue(e.inactive, e.orphan), _("span", e.label)]
|
|
1517
|
+
),
|
|
1518
|
+
_(
|
|
1519
|
+
"div",
|
|
1520
|
+
{ class: e.counted ? "" : "line-through text-fm-color-typo-tertiary" },
|
|
1521
|
+
e.orphan ? `${F(e.amount)} ${e.abbrev} (no valid conversion)` : e.counted ? `${F(e.subtotal)} ${n.baseUnit}` : `${F(e.subtotal)} ${n.baseUnit} (ignored)`
|
|
1522
|
+
)
|
|
1523
|
+
])
|
|
1524
|
+
),
|
|
1525
|
+
_("hr", { class: "border-fm-color-typo-secondary my-4" }),
|
|
1526
|
+
_("div", { class: "flex justify-between fm-typo-en-body-lg-600" }, [
|
|
1527
|
+
_("span", "Total"),
|
|
1528
|
+
_("span", `${F(n.physicalBalance)} ${n.baseUnit}`)
|
|
1529
|
+
])
|
|
1530
|
+
]
|
|
1531
|
+
);
|
|
1532
|
+
}
|
|
1533
|
+
const ke = T(() => {
|
|
1534
|
+
var e, u;
|
|
1535
|
+
const n = [...((e = t.draft) == null ? void 0 : e.items) ?? [], ...((u = t.draft) == null ? void 0 : u.negativeStockItems) ?? []];
|
|
1536
|
+
return y.value.size ? n.filter((B) => y.value.has(B.sku._id)) : n;
|
|
1537
|
+
}), ve = T(() => {
|
|
1538
|
+
const n = ke.value.map((e) => e.sku);
|
|
1539
|
+
return n.sort((e, u) => e.code.localeCompare(u.code)), n;
|
|
1540
|
+
}), Ce = nn();
|
|
1541
|
+
Ie(
|
|
1542
|
+
() => t.show,
|
|
1543
|
+
async (n) => {
|
|
1544
|
+
if (!n) {
|
|
1545
|
+
V();
|
|
1546
|
+
return;
|
|
1547
|
+
}
|
|
1548
|
+
ze.value = ft[0], C.value = {
|
|
1549
|
+
templateItem: !0,
|
|
1550
|
+
nonTemplateItem: !0
|
|
1551
|
+
}, oe.value = null, W();
|
|
1552
|
+
},
|
|
1553
|
+
{ immediate: !0 }
|
|
1554
|
+
), Ie(
|
|
1555
|
+
[() => t.show, L],
|
|
1556
|
+
([n]) => {
|
|
1557
|
+
n && qe();
|
|
1558
|
+
},
|
|
1559
|
+
{ immediate: !0 }
|
|
1560
|
+
);
|
|
1561
|
+
const We = T(() => Qe.value.reduce((n, e) => n + Number(e.stockTakeValue), 0)), Ne = Le(0), Te = Le(100);
|
|
1562
|
+
async function qe() {
|
|
1563
|
+
var n, e;
|
|
1564
|
+
if (f._currentLocation) {
|
|
1565
|
+
w.value = !0, p.value = [], j.value = [];
|
|
1566
|
+
try {
|
|
1567
|
+
if (await m.init(), !N.value) return;
|
|
1568
|
+
const u = (n = t.draft) == null ? void 0 : n.closingAdjustmentId;
|
|
1569
|
+
if (!u) {
|
|
1570
|
+
v.open({
|
|
1571
|
+
title: "Something went wrong",
|
|
1572
|
+
message: "Closing draft is completed but closing document cannot be found.",
|
|
1573
|
+
type: "error"
|
|
1574
|
+
}), console.error("Closing draft is completed but closing document cannot be found.", {
|
|
1575
|
+
draftId: (e = t.draft) == null ? void 0 : e._id
|
|
1576
|
+
});
|
|
1577
|
+
return;
|
|
1578
|
+
}
|
|
1579
|
+
const B = await P.readAdjustmentById(u), h = (B == null ? void 0 : B.skus) ?? [];
|
|
1580
|
+
for (const U of h)
|
|
1581
|
+
p.value.push({
|
|
1582
|
+
id: U.sku._id,
|
|
1583
|
+
balance: U.fromBalance,
|
|
1584
|
+
costs: U.fromCostBalances
|
|
1585
|
+
}), j.value.push({
|
|
1586
|
+
id: U.sku._id,
|
|
1587
|
+
balance: U.toBalance,
|
|
1588
|
+
costs: U.toCostBalances
|
|
1589
|
+
});
|
|
1590
|
+
} catch (u) {
|
|
1591
|
+
v.open({
|
|
1592
|
+
title: "Something went wrong",
|
|
1593
|
+
message: "Something went wrong when fetching info. Please try again.",
|
|
1594
|
+
type: "error"
|
|
1595
|
+
}), console.error("error on fetch stock balances", u);
|
|
1596
|
+
} finally {
|
|
1597
|
+
w.value = !1;
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
async function Ge() {
|
|
1602
|
+
var e, u;
|
|
1603
|
+
if (ae.value)
|
|
1604
|
+
return;
|
|
1605
|
+
if (!(((e = t.draft) == null ? void 0 : e.effectiveAt) ?? (t.draft ? Fe((u = t.draft) == null ? void 0 : u._id) : null))) {
|
|
1606
|
+
v.open({
|
|
1607
|
+
title: "Cannot refresh",
|
|
1608
|
+
message: "Effective date is not available for this draft.",
|
|
1609
|
+
type: "error"
|
|
1610
|
+
});
|
|
1611
|
+
return;
|
|
1612
|
+
}
|
|
1613
|
+
await r.refreshBalance(
|
|
1614
|
+
t.draft,
|
|
1615
|
+
() => {
|
|
1616
|
+
},
|
|
1617
|
+
async (B) => {
|
|
1618
|
+
await de(B);
|
|
1619
|
+
}
|
|
1620
|
+
);
|
|
1621
|
+
}
|
|
1622
|
+
async function sn() {
|
|
1623
|
+
var e, u;
|
|
1624
|
+
if (!(((e = t.draft) == null ? void 0 : e.effectiveAt) ?? (t.draft ? Fe((u = t.draft) == null ? void 0 : u._id) : null))) {
|
|
1625
|
+
v.open({
|
|
1626
|
+
title: "Cannot refresh",
|
|
1627
|
+
message: "Effective date is not available for this draft.",
|
|
1628
|
+
type: "error"
|
|
1629
|
+
});
|
|
1630
|
+
return;
|
|
1631
|
+
}
|
|
1632
|
+
await r.invalidateDraftCache(t.draft);
|
|
1633
|
+
}
|
|
1634
|
+
const rn = T(
|
|
1635
|
+
() => z.value.groupBy(
|
|
1636
|
+
(n) => n.id,
|
|
1637
|
+
(n) => n.balance
|
|
1638
|
+
)
|
|
1639
|
+
), ln = T(() => ke.value.groupBy((n) => n.sku._id)), cn = T(() => {
|
|
1640
|
+
var n;
|
|
1641
|
+
return (n = t.draft) != null && n.adjustmentSnapshot ? new Map(t.draft.adjustmentSnapshot.map((e) => [e.skuId, e.adjustmentsByType])) : /* @__PURE__ */ new Map();
|
|
1642
|
+
}), un = T(() => {
|
|
1643
|
+
var n;
|
|
1644
|
+
return (n = t.draft) != null && n.opening ? new Map(t.draft.opening.map((e) => [e.skuId, e.balance])) : /* @__PURE__ */ new Map();
|
|
1645
|
+
});
|
|
1646
|
+
function ye(n, e) {
|
|
1647
|
+
return _(
|
|
1648
|
+
fe.FmTooltip,
|
|
1649
|
+
{ zIndex: 51, placement: "left", class: "w-full flex justify-end" },
|
|
1650
|
+
{
|
|
1651
|
+
default() {
|
|
1652
|
+
return n;
|
|
1653
|
+
},
|
|
1654
|
+
content() {
|
|
1655
|
+
return e || n;
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
);
|
|
1659
|
+
}
|
|
1660
|
+
const wt = T(() => [
|
|
1661
|
+
{
|
|
1662
|
+
id: "sku",
|
|
1663
|
+
accessorFn: (e) => `${e.code} ${e.name}`,
|
|
1664
|
+
header: () => "Name",
|
|
1665
|
+
size: 350,
|
|
1666
|
+
cell(e) {
|
|
1667
|
+
const u = e.row.original, B = u.adjustedDiffPercentage, h = typeof B == "number" && Math.abs(B) > 10, U = _("div", { class: "flex flex-col gap-4" }, [
|
|
1668
|
+
_(
|
|
1669
|
+
"div",
|
|
1670
|
+
{
|
|
1671
|
+
class: [
|
|
1672
|
+
"line-clamp-1 fm-typo-en-body-lg-400",
|
|
1673
|
+
h ? " text-fm-color-system-error-300" : "text-fm-color-typo-primary"
|
|
1674
|
+
]
|
|
1675
|
+
},
|
|
1676
|
+
u.name
|
|
1677
|
+
),
|
|
1678
|
+
_(
|
|
1679
|
+
"div",
|
|
1680
|
+
{
|
|
1681
|
+
class: [
|
|
1682
|
+
"line-clamp-1 fm-typo-en-body-md-400",
|
|
1683
|
+
h ? " text-fm-color-system-error-300" : "text-fm-color-typo-secondary"
|
|
1684
|
+
]
|
|
1685
|
+
},
|
|
1686
|
+
u.code
|
|
1687
|
+
)
|
|
1688
|
+
]);
|
|
1689
|
+
return _(
|
|
1690
|
+
fe.FmTooltip,
|
|
1691
|
+
{
|
|
1692
|
+
zIndex: 51
|
|
1693
|
+
},
|
|
1694
|
+
{
|
|
1695
|
+
content() {
|
|
1696
|
+
return h ? "Adjustment difference is more than 10%." : `${u.code} - ${u.name}`;
|
|
1697
|
+
},
|
|
1698
|
+
default() {
|
|
1699
|
+
return _("div", { class: "flex items-center gap-4 justify-start w-full" }, [
|
|
1700
|
+
U
|
|
1701
|
+
]);
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
);
|
|
1705
|
+
}
|
|
1706
|
+
},
|
|
1707
|
+
// Dynamic custom attribute columns (toggled by user)
|
|
1708
|
+
...At.value.map(
|
|
1709
|
+
(e) => ({
|
|
1710
|
+
id: `customAttr_${e}`,
|
|
1711
|
+
accessorFn: (u) => u.customAttributeValues[e],
|
|
1712
|
+
header: () => ye($e(e)),
|
|
1713
|
+
size: 160,
|
|
1714
|
+
cell(u) {
|
|
1715
|
+
const B = u.row.original.customAttributeValues[e];
|
|
1716
|
+
return B == null ? "N/A" : typeof B == "number" ? _("div", { class: "text-right fm-typo-en-body-lg-400" }, te(B)) : _("div", { class: "text-right fm-typo-en-body-lg-400" }, String(B));
|
|
1717
|
+
},
|
|
1718
|
+
meta: {
|
|
1719
|
+
textAlign: "right"
|
|
1720
|
+
}
|
|
1721
|
+
})
|
|
1722
|
+
),
|
|
1723
|
+
{
|
|
1724
|
+
id: "costPerUnit",
|
|
1725
|
+
accessorKey: "costPerUnit",
|
|
1726
|
+
header: () => ye("Cost per unit"),
|
|
1727
|
+
size: 160,
|
|
1728
|
+
cell(e) {
|
|
1729
|
+
const u = e.row.original.costPerUnit;
|
|
1730
|
+
return _("div", { class: "text-right fm-typo-en-body-lg-400" }, te(u));
|
|
1731
|
+
},
|
|
1732
|
+
meta: {
|
|
1733
|
+
textAlign: "right"
|
|
1734
|
+
}
|
|
1735
|
+
},
|
|
1736
|
+
{
|
|
1737
|
+
id: "costUnit",
|
|
1738
|
+
header: () => "UOM",
|
|
1739
|
+
size: 120,
|
|
1740
|
+
cell(e) {
|
|
1741
|
+
var S;
|
|
1742
|
+
const u = e.row.original, B = u.costUnit, h = u.baseUnit, U = B ?? h;
|
|
1743
|
+
if (B && B !== h) {
|
|
1744
|
+
const X = ve.value.find((se) => se._id === u.id), O = (S = X == null ? void 0 : X.defaultCost) == null ? void 0 : S.measurement;
|
|
1745
|
+
if (O) {
|
|
1746
|
+
const se = O.conversion.amount / Math.pow(10, O.conversion.precision);
|
|
1747
|
+
return _("div", { class: "flex flex-col" }, [
|
|
1748
|
+
_(
|
|
1749
|
+
"span",
|
|
1750
|
+
{ class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary" },
|
|
1751
|
+
U
|
|
1752
|
+
),
|
|
1753
|
+
_("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, [
|
|
1754
|
+
"1 ",
|
|
1755
|
+
_("span", { class: "fm-typo-en-body-sm-600" }, B),
|
|
1756
|
+
` = ${se} `,
|
|
1757
|
+
_("span", { class: "fm-typo-en-body-sm-600" }, h)
|
|
1758
|
+
])
|
|
1759
|
+
]);
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
return U;
|
|
1763
|
+
}
|
|
1764
|
+
},
|
|
1765
|
+
{
|
|
1766
|
+
id: "opening",
|
|
1767
|
+
accessorKey: "opening",
|
|
1768
|
+
header: () => ye("Opening (B/F)", "The opening balance brought forward from previous period."),
|
|
1769
|
+
size: 150,
|
|
1770
|
+
cell(e) {
|
|
1771
|
+
const u = e.row.original.opening;
|
|
1772
|
+
return _("div", { class: "text-right fm-typo-en-body-lg-400" }, te(u));
|
|
1773
|
+
},
|
|
1774
|
+
meta: {
|
|
1775
|
+
textAlign: "right"
|
|
1776
|
+
}
|
|
1777
|
+
},
|
|
1778
|
+
// Dynamic adjustment type columns
|
|
1779
|
+
...D.value.map(
|
|
1780
|
+
(e) => ({
|
|
1781
|
+
id: `adjustment_${e}`,
|
|
1782
|
+
accessorFn: (u) => u.adjustmentAmounts[e] ?? { amount: 0, precision: 0 },
|
|
1783
|
+
header: () => ye($e(e)),
|
|
1784
|
+
size: 150,
|
|
1785
|
+
cell(u) {
|
|
1786
|
+
const B = u.row.original.adjustmentAmounts[e] ?? { amount: 0, precision: 0 };
|
|
1787
|
+
return _("div", { class: "text-right fm-typo-en-body-lg-400" }, te(B));
|
|
1788
|
+
},
|
|
1789
|
+
meta: {
|
|
1790
|
+
textAlign: "right"
|
|
1791
|
+
}
|
|
1792
|
+
})
|
|
1793
|
+
),
|
|
1794
|
+
{
|
|
1795
|
+
id: "systemBalance",
|
|
1796
|
+
accessorKey: "systemBalance",
|
|
1797
|
+
header: () => ye("System Balance", "The system calculated balance before stock take."),
|
|
1798
|
+
size: 200,
|
|
1799
|
+
cell(e) {
|
|
1800
|
+
const u = e.row.original.systemBalance;
|
|
1801
|
+
return _("div", { class: "text-right fm-typo-en-body-lg-400" }, te(u));
|
|
1802
|
+
},
|
|
1803
|
+
meta: {
|
|
1804
|
+
textAlign: "right"
|
|
1805
|
+
}
|
|
1806
|
+
},
|
|
1807
|
+
{
|
|
1808
|
+
id: "physicalBalance",
|
|
1809
|
+
accessorFn: (e) => {
|
|
1810
|
+
var B;
|
|
1811
|
+
const u = (B = I.value.find((h) => h.id === e.id)) == null ? void 0 : B.balance;
|
|
1812
|
+
return u ? Kn.toDouble(u) : e.physicalBalance;
|
|
1813
|
+
},
|
|
1814
|
+
header: () => ye("Stock Take balance", "The physical balance recorded during stock take."),
|
|
1815
|
+
cell(e) {
|
|
1816
|
+
var O;
|
|
1817
|
+
const u = e.row.original, B = ee.fromNumber(u.physicalBalance);
|
|
1818
|
+
let h = !0;
|
|
1819
|
+
const U = (O = I.value.find((se) => se.id === u.id)) == null ? void 0 : O.balance;
|
|
1820
|
+
let S;
|
|
1821
|
+
U && !ee.equals({ a: B, b: U }) ? (h = !1, S = te(U)) : S = te(u.physicalBalance);
|
|
1822
|
+
const X = _("div", { class: "flex flex-col items-end" }, [
|
|
1823
|
+
_(
|
|
1824
|
+
"span",
|
|
1825
|
+
{ class: "line-clamp-1 fm-typo-en-body-lg-400 text-fm-color-typo-primary" },
|
|
1826
|
+
S
|
|
1827
|
+
),
|
|
1828
|
+
h ? null : _(
|
|
1829
|
+
"span",
|
|
1830
|
+
{ class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" },
|
|
1831
|
+
`Draft: ${te(u.physicalBalance)}`
|
|
1832
|
+
)
|
|
1833
|
+
]);
|
|
1834
|
+
return u.breakdown.length ? _(
|
|
1835
|
+
fe.FmPopover,
|
|
1836
|
+
{
|
|
1837
|
+
showPopover: oe.value === u.id,
|
|
1838
|
+
placement: "bottom-end",
|
|
1839
|
+
zIndex: 9999,
|
|
1840
|
+
"onPopover-changed": (se) => E(u.id, se)
|
|
1841
|
+
},
|
|
1842
|
+
{
|
|
1843
|
+
"popover-button": () => _(
|
|
1844
|
+
"button",
|
|
1845
|
+
{
|
|
1846
|
+
type: "button",
|
|
1847
|
+
class: "flex items-center gap-4 ml-auto text-fm-color-typo-secondary hover:text-fm-color-typo-primary"
|
|
1848
|
+
},
|
|
1849
|
+
[
|
|
1850
|
+
X,
|
|
1851
|
+
_(fe.FmIcon, { name: "info", size: "sm", outline: !0 })
|
|
1852
|
+
]
|
|
1853
|
+
),
|
|
1854
|
+
default: () => xe(u)
|
|
1855
|
+
}
|
|
1856
|
+
) : X;
|
|
1857
|
+
},
|
|
1858
|
+
size: 200,
|
|
1859
|
+
meta: {
|
|
1860
|
+
textAlign: "right"
|
|
1861
|
+
}
|
|
1862
|
+
},
|
|
1863
|
+
{
|
|
1864
|
+
id: "adjustedAmount",
|
|
1865
|
+
accessorKey: "adjustedAmount",
|
|
1866
|
+
header: () => ye("Variance", "The difference between Stock Take balance and System Balance."),
|
|
1867
|
+
size: 200,
|
|
1868
|
+
cell(e) {
|
|
1869
|
+
const u = e.row.original.adjustedAmount;
|
|
1870
|
+
return _("div", { class: "text-right fm-typo-en-body-lg-400" }, te(u));
|
|
1871
|
+
},
|
|
1872
|
+
meta: {
|
|
1873
|
+
textAlign: "right"
|
|
1874
|
+
}
|
|
1875
|
+
},
|
|
1876
|
+
{
|
|
1877
|
+
id: "varianceInCost",
|
|
1878
|
+
accessorKey: "varianceInCost",
|
|
1879
|
+
header: () => ye(`Variance (${s.value})`),
|
|
1880
|
+
size: 150,
|
|
1881
|
+
cell(e) {
|
|
1882
|
+
const u = e.row.original.varianceInCost;
|
|
1883
|
+
return _("div", { class: "text-right fm-typo-en-body-lg-400" }, te(u));
|
|
1884
|
+
},
|
|
1885
|
+
meta: {
|
|
1886
|
+
textAlign: "right"
|
|
1887
|
+
}
|
|
1888
|
+
},
|
|
1889
|
+
{
|
|
1890
|
+
id: "adjustedDiffPercentage",
|
|
1891
|
+
accessorKey: "adjustedDiffPercentage",
|
|
1892
|
+
header: () => ye(
|
|
1893
|
+
"Variance (%)",
|
|
1894
|
+
"Difference between Stock Take balance and System Balance in percentage."
|
|
1895
|
+
),
|
|
1896
|
+
size: 200,
|
|
1897
|
+
cell(e) {
|
|
1898
|
+
const u = e.row.original.adjustedDiffPercentage;
|
|
1899
|
+
if (u == null)
|
|
1900
|
+
return _(
|
|
1901
|
+
"div",
|
|
1902
|
+
{ class: "flex items-center gap-4 justify-end fm-typo-en-body-lg-400" },
|
|
1903
|
+
Lt
|
|
1904
|
+
);
|
|
1905
|
+
const B = te(u);
|
|
1906
|
+
if (u === 0)
|
|
1907
|
+
return _("div", { class: "flex items-center gap-4 justify-end fm-typo-en-body-lg-400" }, [
|
|
1908
|
+
te(0)
|
|
1909
|
+
]);
|
|
1910
|
+
const h = u > 0;
|
|
1911
|
+
return _("div", { class: "flex items-center gap-4 justify-end fm-typo-en-body-lg-400" }, [
|
|
1912
|
+
_(fe.FmIcon, {
|
|
1913
|
+
name: h ? "arrow_drop_up" : "arrow_drop_down",
|
|
1914
|
+
color: h ? "system-success-300" : "system-error-300",
|
|
1915
|
+
size: "md"
|
|
1916
|
+
}),
|
|
1917
|
+
B
|
|
1918
|
+
]);
|
|
1919
|
+
},
|
|
1920
|
+
meta: {
|
|
1921
|
+
textAlign: "right"
|
|
1922
|
+
}
|
|
1923
|
+
},
|
|
1924
|
+
{
|
|
1925
|
+
id: "stockTakeValue",
|
|
1926
|
+
accessorKey: "stockTakeValue",
|
|
1927
|
+
header: () => ye(`Stock take value (${s.value})`),
|
|
1928
|
+
size: 180,
|
|
1929
|
+
cell(e) {
|
|
1930
|
+
var O;
|
|
1931
|
+
const u = e.row.original, B = u.stockTakeValue, h = ve.value.find((se) => se._id === u.id), U = (O = h == null ? void 0 : h.defaultCost) == null ? void 0 : O.measurement, S = u.physicalBalance, X = u.costPerUnit;
|
|
1932
|
+
if (U) {
|
|
1933
|
+
const se = ee.toFormatString({ value: U.conversion }), ge = `${te(S, { minPrecision: 2, maxPrecision: 4 })} ${u.baseUnit} ÷ ${se} × ${X} ${s.value}`;
|
|
1934
|
+
return _(
|
|
1935
|
+
fe.FmTooltip,
|
|
1936
|
+
{ zIndex: 51 },
|
|
1937
|
+
{
|
|
1938
|
+
content() {
|
|
1939
|
+
return ge;
|
|
1940
|
+
},
|
|
1941
|
+
default() {
|
|
1942
|
+
return _(
|
|
1943
|
+
"div",
|
|
1944
|
+
{ class: "text-right w-full fm-typo-en-body-lg-400" },
|
|
1945
|
+
te(B)
|
|
1946
|
+
);
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
);
|
|
1950
|
+
} else {
|
|
1951
|
+
const se = `${te(S, { minPrecision: 2, maxPrecision: 4 })} ${u.baseUnit} × ${X} ${s.value}`;
|
|
1952
|
+
return _(
|
|
1953
|
+
fe.FmTooltip,
|
|
1954
|
+
{ zIndex: 51 },
|
|
1955
|
+
{
|
|
1956
|
+
content() {
|
|
1957
|
+
return se;
|
|
1958
|
+
},
|
|
1959
|
+
default() {
|
|
1960
|
+
return _(
|
|
1961
|
+
"div",
|
|
1962
|
+
{ class: "text-right w-full fm-typo-en-body-lg-400" },
|
|
1963
|
+
te(B)
|
|
1964
|
+
);
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1967
|
+
);
|
|
1968
|
+
}
|
|
1969
|
+
},
|
|
1970
|
+
meta: {
|
|
1971
|
+
textAlign: "right"
|
|
1972
|
+
}
|
|
1973
|
+
},
|
|
1974
|
+
{
|
|
1975
|
+
id: "systemValue",
|
|
1976
|
+
accessorKey: "systemValue",
|
|
1977
|
+
header: () => ye(`System value (${s.value})`),
|
|
1978
|
+
size: 180,
|
|
1979
|
+
cell(e) {
|
|
1980
|
+
var O;
|
|
1981
|
+
const u = e.row.original, B = u.systemValue, h = ve.value.find((se) => se._id === u.id), U = (O = h == null ? void 0 : h.defaultCost) == null ? void 0 : O.measurement, S = u.systemBalance, X = u.costPerUnit;
|
|
1982
|
+
if (U) {
|
|
1983
|
+
const se = ee.toFormatString({ value: U.conversion }), ge = `${te(S, { minPrecision: 2, maxPrecision: 4 })} ${u.baseUnit} ÷ ${se} × ${X} ${s.value}`;
|
|
1984
|
+
return _(
|
|
1985
|
+
fe.FmTooltip,
|
|
1986
|
+
{ zIndex: 51 },
|
|
1987
|
+
{
|
|
1988
|
+
content() {
|
|
1989
|
+
return ge;
|
|
1990
|
+
},
|
|
1991
|
+
default() {
|
|
1992
|
+
return _(
|
|
1993
|
+
"div",
|
|
1994
|
+
{ class: "text-right fm-typo-en-body-lg-400" },
|
|
1995
|
+
te(B)
|
|
1996
|
+
);
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
);
|
|
2000
|
+
} else {
|
|
2001
|
+
const se = `${te(S, { minPrecision: 2, maxPrecision: 4 })} ${u.baseUnit} × ${X} ${s.value}`;
|
|
2002
|
+
return _(
|
|
2003
|
+
fe.FmTooltip,
|
|
2004
|
+
{ zIndex: 51 },
|
|
2005
|
+
{
|
|
2006
|
+
content() {
|
|
2007
|
+
return se;
|
|
2008
|
+
},
|
|
2009
|
+
default() {
|
|
2010
|
+
return _(
|
|
2011
|
+
"div",
|
|
2012
|
+
{ class: "text-right fm-typo-en-body-lg-400" },
|
|
2013
|
+
te(B)
|
|
2014
|
+
);
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
);
|
|
2018
|
+
}
|
|
2019
|
+
},
|
|
2020
|
+
meta: {
|
|
2021
|
+
textAlign: "right"
|
|
2022
|
+
}
|
|
2023
|
+
},
|
|
2024
|
+
{
|
|
2025
|
+
id: "physicalBalances",
|
|
2026
|
+
header: () => "Amounts",
|
|
2027
|
+
enableSorting: !1,
|
|
2028
|
+
cell(e) {
|
|
2029
|
+
const u = e.row.original, B = (S, X, O = "normal") => _(
|
|
2030
|
+
fe.FmTooltip,
|
|
2031
|
+
{ zIndex: 50 },
|
|
2032
|
+
{
|
|
2033
|
+
default() {
|
|
2034
|
+
return _(
|
|
2035
|
+
"div",
|
|
2036
|
+
{
|
|
2037
|
+
class: [
|
|
2038
|
+
"fm-typo-en-body-lg-400 py-4 px-8 fm-corner-radius-md line-clamp-1 border-1",
|
|
2039
|
+
O === "orphan" ? "border-fm-color-system-error-300" : O === "inactive" ? "border-purple-500" : "border-fm-color-typo-secondary"
|
|
2040
|
+
]
|
|
2041
|
+
},
|
|
2042
|
+
[
|
|
2043
|
+
_("span", { class: "text-fm-color-typo-primary" }, `${S} `),
|
|
2044
|
+
_(
|
|
2045
|
+
"span",
|
|
2046
|
+
{
|
|
2047
|
+
class: "text-fm-color-typo-secondary",
|
|
2048
|
+
style: { maxWidth: "80px" }
|
|
2049
|
+
},
|
|
2050
|
+
X
|
|
2051
|
+
)
|
|
2052
|
+
]
|
|
2053
|
+
);
|
|
2054
|
+
},
|
|
2055
|
+
content() {
|
|
2056
|
+
return O === "orphan" ? `${S} ${X} (invalid UOM — not on SKU)` : O === "inactive" ? `${S} ${X} (NetSuite-inactive UOM)` : `${S} ${X}`;
|
|
2057
|
+
}
|
|
2058
|
+
}
|
|
2059
|
+
), h = u.measurements.filter((S) => !!S.amount).map((S) => B(S.amount, S.abbrev, S.variant)), U = u.baseUnitAmount || !h.length ? [B(u.baseUnitAmount, u.baseUnit), ...h] : h;
|
|
2060
|
+
return _(
|
|
2061
|
+
"div",
|
|
2062
|
+
{
|
|
2063
|
+
class: "flex gap-8 flex-nowrap",
|
|
2064
|
+
style: { minWidth: `${120 * U.length}px` }
|
|
2065
|
+
},
|
|
2066
|
+
U
|
|
2067
|
+
);
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2070
|
+
]), dn = T(() => wt.value.map((n) => n.size ?? 0).reduce((n, e) => n + e)), dt = q(""), mn = T(() => {
|
|
2071
|
+
var u, B;
|
|
2072
|
+
const n = ((B = (u = t.draft) == null ? void 0 : u.negativeStockItems) == null ? void 0 : B.reduce(
|
|
2073
|
+
(h, U) => (h[U.sku._id] = U, h),
|
|
2074
|
+
{}
|
|
2075
|
+
)) ?? {}, e = new Map(
|
|
2076
|
+
I.value.map((h) => [h.id, h.balance])
|
|
2077
|
+
);
|
|
2078
|
+
return ve.value.map((h) => {
|
|
2079
|
+
var It, Bt, Tt, jt, Mt, Ut, Rt, Pt, Vt;
|
|
2080
|
+
const U = (It = ln.value.get(h._id)) == null ? void 0 : It[0], S = ((Bt = rn.value.get(h._id)) == null ? void 0 : Bt[0]) ?? Ne, X = ((Tt = h.defaultCost) == null ? void 0 : Tt.costPerUnit) ?? Ne, O = Number(ee.toFormatString({ value: X })), se = ((Mt = (jt = h.defaultCost) == null ? void 0 : jt.measurement) == null ? void 0 : Mt.conversion) ?? {
|
|
2081
|
+
amount: 1,
|
|
2082
|
+
precision: 0
|
|
2083
|
+
}, ge = Number(
|
|
2084
|
+
ee.toFormatString({ value: se })
|
|
2085
|
+
), Me = un.value.get(h._id), et = Me ? Number(ee.toFormatString({ value: Me })) : 0, Ee = cn.value.get(h._id), R = {};
|
|
2086
|
+
if (D.value.forEach((J) => {
|
|
2087
|
+
const be = R[J] ?? { amount: 0, precision: 0 }, Se = Ee == null ? void 0 : Ee[J];
|
|
2088
|
+
Se && (R[J] = Xt(be, Se));
|
|
2089
|
+
}), !U) {
|
|
2090
|
+
const J = Number(ee.toFormatString({ value: S })), be = 0 - J, Se = be * O / ge, at = 0, Re = J * O / ge;
|
|
2091
|
+
return {
|
|
2092
|
+
id: h._id,
|
|
2093
|
+
code: h.code,
|
|
2094
|
+
name: h.name,
|
|
2095
|
+
costUnit: ((Rt = (Ut = h.defaultCost) == null ? void 0 : Ut.measurement) == null ? void 0 : Rt.abbrev) ?? null,
|
|
2096
|
+
baseUnit: h.unit.abbrev,
|
|
2097
|
+
baseUnitAmount: 0,
|
|
2098
|
+
systemBalance: J,
|
|
2099
|
+
physicalBalance: 0,
|
|
2100
|
+
adjustedAmount: -J,
|
|
2101
|
+
adjustedDiffPercentage: -100,
|
|
2102
|
+
isTemplateItem: !n[h._id],
|
|
2103
|
+
costPerUnit: O,
|
|
2104
|
+
opening: et,
|
|
2105
|
+
varianceQty: be,
|
|
2106
|
+
varianceInCost: Se,
|
|
2107
|
+
stockTakeValue: at,
|
|
2108
|
+
systemValue: Re,
|
|
2109
|
+
adjustmentAmounts: R,
|
|
2110
|
+
customAttributeValues: h.customAttributes ?? {},
|
|
2111
|
+
measurements: [],
|
|
2112
|
+
breakdown: []
|
|
2113
|
+
};
|
|
2114
|
+
}
|
|
2115
|
+
const ie = an(U), me = e.get(h._id), _e = Zt(
|
|
2116
|
+
me ?? ie,
|
|
2117
|
+
S
|
|
2118
|
+
), Ue = S.amount === 0 ? null : Jt(_e, {
|
|
2119
|
+
...S,
|
|
2120
|
+
amount: Math.abs(S.amount)
|
|
2121
|
+
}), tt = Ue ? it(Ue, Te) : null, pt = Number(ee.toFormatString({ value: S })), vt = Number(ee.toFormatString({ value: ie })), St = vt - pt, yn = St * O / ge, gn = vt * O / ge, bn = pt * O / ge, nt = Number(ee.toFormatString({ value: U.baseAmount })), $t = [], yt = [];
|
|
2122
|
+
nt && yt.push({
|
|
2123
|
+
label: "Base",
|
|
2124
|
+
amount: nt,
|
|
2125
|
+
abbrev: h.unit.abbrev,
|
|
2126
|
+
subtotal: nt,
|
|
2127
|
+
inactive: !1,
|
|
2128
|
+
orphan: !1,
|
|
2129
|
+
counted: !0
|
|
2130
|
+
});
|
|
2131
|
+
const hn = new Map(
|
|
2132
|
+
U.measurementsAmounts.map((J) => [J.measurement.id, J.amount])
|
|
2133
|
+
), kn = new Set(h.unit.measurements.map((J) => J.id)), Ft = (J, be, Se, at, Re) => {
|
|
2134
|
+
const Pe = Number(ee.toFormatString({ value: Se })), Nt = ee.toFormatString({ value: be });
|
|
2135
|
+
if ($t.push({
|
|
2136
|
+
abbrev: `(${J}) × ${Nt}`,
|
|
2137
|
+
amount: Pe,
|
|
2138
|
+
variant: Re ? "orphan" : at ? "inactive" : "normal"
|
|
2139
|
+
}), !Pe) return;
|
|
2140
|
+
const _n = Number(
|
|
2141
|
+
ee.toFormatString({ value: it(Se, be) })
|
|
2142
|
+
);
|
|
2143
|
+
yt.push({
|
|
2144
|
+
label: Re ? `${Pe} ${J}` : `${Pe} ${J} × ${Nt} ${h.unit.abbrev}`,
|
|
2145
|
+
amount: Pe,
|
|
2146
|
+
abbrev: J,
|
|
2147
|
+
subtotal: _n,
|
|
2148
|
+
inactive: at,
|
|
2149
|
+
orphan: Re,
|
|
2150
|
+
counted: !Re
|
|
2151
|
+
});
|
|
2152
|
+
};
|
|
2153
|
+
for (const J of h.unit.measurements) {
|
|
2154
|
+
const be = hn.get(J.id);
|
|
2155
|
+
be && Ft(J.abbrev, J.conversion, be, tn(J, Ce.value), !1);
|
|
2156
|
+
}
|
|
2157
|
+
for (const J of U.measurementsAmounts)
|
|
2158
|
+
kn.has(J.measurement.id) || Ft(J.measurement.abbrev, J.measurement.conversion, J.amount, !1, !0);
|
|
2159
|
+
return {
|
|
2160
|
+
id: h._id,
|
|
2161
|
+
code: h.code,
|
|
2162
|
+
name: h.name,
|
|
2163
|
+
costUnit: ((Vt = (Pt = h.defaultCost) == null ? void 0 : Pt.measurement) == null ? void 0 : Vt.abbrev) ?? null,
|
|
2164
|
+
baseUnit: h.unit.abbrev,
|
|
2165
|
+
baseUnitAmount: nt,
|
|
2166
|
+
measurements: $t,
|
|
2167
|
+
breakdown: yt,
|
|
2168
|
+
systemBalance: pt,
|
|
2169
|
+
physicalBalance: vt,
|
|
2170
|
+
adjustedAmount: Number(ee.toFormatString({ value: _e })),
|
|
2171
|
+
adjustedDiffPercentage: tt ? Number(
|
|
2172
|
+
ee.toFormatString({
|
|
2173
|
+
value: en(tt, 2)
|
|
2174
|
+
})
|
|
2175
|
+
) : null,
|
|
2176
|
+
isTemplateItem: !n[h._id],
|
|
2177
|
+
costPerUnit: O,
|
|
2178
|
+
opening: et,
|
|
2179
|
+
varianceQty: St,
|
|
2180
|
+
varianceInCost: yn,
|
|
2181
|
+
stockTakeValue: gn,
|
|
2182
|
+
systemValue: bn,
|
|
2183
|
+
adjustmentAmounts: R,
|
|
2184
|
+
customAttributeValues: h.customAttributes ?? {}
|
|
2185
|
+
};
|
|
2186
|
+
});
|
|
2187
|
+
}), Qe = T(() => mn.value.filter((n) => !!(n.isTemplateItem && C.value.templateItem || !n.isTemplateItem && C.value.nonTemplateItem))), xt = T(
|
|
2188
|
+
() => Qe.value.some((n) => n.measurements.some((e) => e.variant === "inactive"))
|
|
2189
|
+
), Dt = T(
|
|
2190
|
+
() => Qe.value.some((n) => n.measurements.some((e) => e.variant === "orphan"))
|
|
2191
|
+
), fn = T(
|
|
2192
|
+
() => xt.value || Dt.value
|
|
2193
|
+
), mt = T(() => {
|
|
2194
|
+
const n = /* @__PURE__ */ new Set();
|
|
2195
|
+
for (const e of ve.value)
|
|
2196
|
+
if (e.customAttributes)
|
|
2197
|
+
for (const u of Object.keys(e.customAttributes))
|
|
2198
|
+
u !== "tag" && n.add(u);
|
|
2199
|
+
return Array.from(n).sort();
|
|
2200
|
+
}), Ze = zt({}), At = T(
|
|
2201
|
+
() => mt.value.filter((n) => Ze[n])
|
|
2202
|
+
), pn = T(() => {
|
|
2203
|
+
var e, u, B, h, U;
|
|
2204
|
+
if (!t.draft) return [];
|
|
2205
|
+
const n = t.draft.approvedAt ? {
|
|
2206
|
+
action: `Approve at ${De(t.draft.approvedAt)}`,
|
|
2207
|
+
// actionAt: props.draft.approvedAt,
|
|
2208
|
+
actionBy: t.draft.approvedBy,
|
|
2209
|
+
remark: t.draft.approveRemark
|
|
2210
|
+
} : (e = t.draft.rejectionHistory) == null ? void 0 : e.computeFirst((S) => ({
|
|
2211
|
+
action: `Reject at ${De(S.rejectedAt)}`,
|
|
2212
|
+
// actionAt: e.rejectedAt,
|
|
2213
|
+
actionBy: S.rejectedBy,
|
|
2214
|
+
remark: S.rejectRemark
|
|
2215
|
+
}));
|
|
2216
|
+
return [
|
|
2217
|
+
i.value ? {
|
|
2218
|
+
label: "ID",
|
|
2219
|
+
value: i.value
|
|
2220
|
+
} : null,
|
|
2221
|
+
{
|
|
2222
|
+
label: "Location",
|
|
2223
|
+
value: ((u = f._currentLocation) == null ? void 0 : u.name) ?? Lt
|
|
2224
|
+
},
|
|
2225
|
+
{
|
|
2226
|
+
label: "Created at",
|
|
2227
|
+
value: De(t.draft.createdAt)
|
|
2228
|
+
},
|
|
2229
|
+
{
|
|
2230
|
+
label: "Created by",
|
|
2231
|
+
value: t.draft.createdBy.name
|
|
2232
|
+
},
|
|
2233
|
+
{
|
|
2234
|
+
label: "Updated at",
|
|
2235
|
+
value: De(t.draft.updatedAt)
|
|
2236
|
+
},
|
|
2237
|
+
{
|
|
2238
|
+
label: "Updated by",
|
|
2239
|
+
value: t.draft.updatedBy.name
|
|
2240
|
+
},
|
|
2241
|
+
{
|
|
2242
|
+
label: "Effective at",
|
|
2243
|
+
value: De(t.draft.effectiveAt ?? Fe((B = t.draft) == null ? void 0 : B._id))
|
|
2244
|
+
},
|
|
2245
|
+
{
|
|
2246
|
+
label: "Using template",
|
|
2247
|
+
value: ((h = t.draft.usingTemplates.find((S) => S)) == null ? void 0 : h.name) ?? "None"
|
|
2248
|
+
},
|
|
2249
|
+
t.draft.remark ? {
|
|
2250
|
+
label: "Remark",
|
|
2251
|
+
value: t.draft.remark
|
|
2252
|
+
} : null,
|
|
2253
|
+
n ? {
|
|
2254
|
+
label: "Last action",
|
|
2255
|
+
value: n.action
|
|
2256
|
+
} : null,
|
|
2257
|
+
n && n.actionBy ? {
|
|
2258
|
+
label: "Last action by",
|
|
2259
|
+
value: (U = n.actionBy) == null ? void 0 : U.name
|
|
2260
|
+
} : null,
|
|
2261
|
+
n && n.remark ? {
|
|
2262
|
+
label: "Action remark",
|
|
2263
|
+
value: n.remark
|
|
2264
|
+
} : null
|
|
2265
|
+
].filter((S) => S).map((S) => S);
|
|
2266
|
+
}), ft = [
|
|
2267
|
+
{
|
|
2268
|
+
label: "Overview",
|
|
2269
|
+
value: "overview"
|
|
2270
|
+
},
|
|
2271
|
+
{
|
|
2272
|
+
label: "Action history",
|
|
2273
|
+
value: "history"
|
|
2274
|
+
}
|
|
2275
|
+
], ze = q(ft[0]), je = T(() => {
|
|
2276
|
+
var B, h, U;
|
|
2277
|
+
const n = ((B = t.draft) == null ? void 0 : B.activityLogs) ?? [], e = ((h = t.draft) == null ? void 0 : h.rejectionHistory) ?? [];
|
|
2278
|
+
for (const S of e)
|
|
2279
|
+
n.find(
|
|
2280
|
+
(O) => `${O.action}_${O.performedAt}` == `${re.enum.rejectDraft}_${S.rejectedAt}`
|
|
2281
|
+
) || n.push({
|
|
2282
|
+
action: re.enum.rejectDraft,
|
|
2283
|
+
performedAt: S.rejectedAt,
|
|
2284
|
+
performedBy: S.rejectedBy,
|
|
2285
|
+
remark: S.rejectRemark
|
|
2286
|
+
});
|
|
2287
|
+
return (U = t.draft) != null && U.approvedAt && (n.find(
|
|
2288
|
+
(X) => {
|
|
2289
|
+
var O;
|
|
2290
|
+
return `${X.action}_${X.performedAt}` == `${re.enum.approveDraft}_${(O = t.draft) == null ? void 0 : O.approvedAt}`;
|
|
2291
|
+
}
|
|
2292
|
+
) || n.push({
|
|
2293
|
+
action: re.enum.approveDraft,
|
|
2294
|
+
performedAt: t.draft.approvedAt,
|
|
2295
|
+
performedBy: t.draft.approvedBy ?? { name: "Unknown", id: "unknown" },
|
|
2296
|
+
remark: t.draft.approveRemark
|
|
2297
|
+
})), n.sort((S, X) => new Date(X.performedAt).getTime() - new Date(S.performedAt).getTime()).map(
|
|
2298
|
+
(S) => ({
|
|
2299
|
+
header: $e(S.action),
|
|
2300
|
+
date: De(S.performedAt),
|
|
2301
|
+
info: [
|
|
2302
|
+
{
|
|
2303
|
+
label: "Performed by",
|
|
2304
|
+
values: [S.performedBy.name]
|
|
2305
|
+
},
|
|
2306
|
+
{
|
|
2307
|
+
label: "Remark",
|
|
2308
|
+
values: [S.remark ?? ""]
|
|
2309
|
+
}
|
|
2310
|
+
]
|
|
2311
|
+
})
|
|
2312
|
+
);
|
|
2313
|
+
}), Je = q(!1), Xe = q(!1), Ct = T(() => {
|
|
2314
|
+
var n;
|
|
2315
|
+
return ((n = t.draft) == null ? void 0 : n.status) !== we.enum.DRAFT ? "Status is not draft." : null;
|
|
2316
|
+
});
|
|
2317
|
+
function vn() {
|
|
2318
|
+
t.draft && (Xe.value = !0, r.approveDraft(
|
|
2319
|
+
t.draft,
|
|
2320
|
+
() => {
|
|
2321
|
+
Xe.value = !1, Je.value = !1, x("submitted");
|
|
2322
|
+
},
|
|
2323
|
+
() => {
|
|
2324
|
+
Xe.value = !1;
|
|
2325
|
+
}
|
|
2326
|
+
));
|
|
2327
|
+
}
|
|
2328
|
+
return (n, e) => {
|
|
2329
|
+
const u = Q("FmButtonGroup"), B = Q("FmMenuDivider"), h = Q("FmCard"), U = Q("FmIcon"), S = Q("FmButton"), X = Q("FmCircularProgress"), O = Q("FmChip"), se = Q("FmTextField"), ge = Q("FmTable"), Me = Q("FmSpacer"), et = Q("FmTooltip"), Ee = Q("FmSideSheet");
|
|
2330
|
+
return k(), M(le, null, [
|
|
2331
|
+
$(Ee, {
|
|
2332
|
+
"dismiss-away": "",
|
|
2333
|
+
"max-width": 9999,
|
|
2334
|
+
"model-value": d(c),
|
|
2335
|
+
"onUpdate:modelValue": e[9] || (e[9] = (R) => kt(c) ? c.value = R : null),
|
|
2336
|
+
header: "Closing details"
|
|
2337
|
+
}, {
|
|
2338
|
+
"side-sheet-footer": Z(() => {
|
|
2339
|
+
var R, ie, me, _e;
|
|
2340
|
+
return [
|
|
2341
|
+
o("div", wo, [
|
|
2342
|
+
o("div", xo, [
|
|
2343
|
+
((R = t.draft) == null ? void 0 : R.status) === d(we).enum.DRAFT ? (k(), M(le, { key: 0 }, [
|
|
2344
|
+
Ct.value ? (k(), ne(et, {
|
|
2345
|
+
key: 0,
|
|
2346
|
+
"z-index": 51,
|
|
2347
|
+
placement: "right"
|
|
2348
|
+
}, {
|
|
2349
|
+
content: Z(() => [
|
|
2350
|
+
ce(H(Ct.value), 1)
|
|
2351
|
+
]),
|
|
2352
|
+
default: Z(() => [
|
|
2353
|
+
$(S, {
|
|
2354
|
+
disabled: "",
|
|
2355
|
+
key: "approve key",
|
|
2356
|
+
label: "Approve"
|
|
2357
|
+
})
|
|
2358
|
+
]),
|
|
2359
|
+
_: 1
|
|
2360
|
+
})) : (k(), ne(S, {
|
|
2361
|
+
key: "approve key",
|
|
2362
|
+
label: "Approve",
|
|
2363
|
+
onClick: e[5] || (e[5] = (Ue) => Je.value = !0)
|
|
2364
|
+
}))
|
|
2365
|
+
], 64)) : Y("", !0),
|
|
2366
|
+
((ie = t.draft) == null ? void 0 : ie.status) === d(we).enum.DRAFT ? (k(), ne(S, {
|
|
2367
|
+
key: 1,
|
|
2368
|
+
label: "Reject",
|
|
2369
|
+
variant: "destructive",
|
|
2370
|
+
onClick: e[6] || (e[6] = () => t.draft && d(r).rejectDraft(t.draft, () => x("submitted")))
|
|
2371
|
+
})) : Y("", !0),
|
|
2372
|
+
$(S, {
|
|
2373
|
+
label: "Close",
|
|
2374
|
+
variant: "tertiary",
|
|
2375
|
+
onClick: e[7] || (e[7] = (Ue) => c.value = !1)
|
|
2376
|
+
}),
|
|
2377
|
+
(me = t.draft) != null && me.approvedAt && ((_e = t.draft) == null ? void 0 : _e.status) !== d(we).enum.COMPLETED ? (k(), ne(gt, { key: 2 }, {
|
|
2378
|
+
default: Z(() => [
|
|
2379
|
+
$(S, {
|
|
2380
|
+
label: "Sync",
|
|
2381
|
+
loading: A.value,
|
|
2382
|
+
onClick: e[8] || (e[8] = () => {
|
|
2383
|
+
t.draft && (A.value = !0, d(r).syncDraft(t.draft, () => {
|
|
2384
|
+
A.value = !1, x("submitted");
|
|
2385
|
+
}));
|
|
2386
|
+
})
|
|
2387
|
+
}, null, 8, ["loading"])
|
|
2388
|
+
]),
|
|
2389
|
+
_: 1
|
|
2390
|
+
})) : Y("", !0)
|
|
2391
|
+
]),
|
|
2392
|
+
o("div", Do, [
|
|
2393
|
+
e[23] || (e[23] = o("div", { class: "text-xs text-gray-500 uppercase tracking-wide" }, "Total stock take value", -1)),
|
|
2394
|
+
o("div", Ao, H(s.value) + " " + H(We.value.toFixed(2)), 1)
|
|
2395
|
+
])
|
|
2396
|
+
])
|
|
2397
|
+
];
|
|
2398
|
+
}),
|
|
2399
|
+
default: Z(() => [
|
|
2400
|
+
o("div", Ma, [
|
|
2401
|
+
o("div", null, [
|
|
2402
|
+
$(u, {
|
|
2403
|
+
items: ft,
|
|
2404
|
+
modelValue: ze.value,
|
|
2405
|
+
"onUpdate:modelValue": e[0] || (e[0] = (R) => ze.value = R)
|
|
2406
|
+
}, null, 8, ["modelValue"])
|
|
2407
|
+
]),
|
|
2408
|
+
ze.value.value === "overview" ? (k(), M(le, { key: 0 }, [
|
|
2409
|
+
$(gt, { selectable: "" }, {
|
|
2410
|
+
default: Z(() => {
|
|
2411
|
+
var R;
|
|
2412
|
+
return [
|
|
2413
|
+
o("div", Ua, [
|
|
2414
|
+
e[11] || (e[11] = o("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, [
|
|
2415
|
+
o("div", { class: "flex gap-1" }, "Draft ID")
|
|
2416
|
+
], -1)),
|
|
2417
|
+
ce(" " + H((R = n.draft) == null ? void 0 : R._id), 1)
|
|
2418
|
+
])
|
|
2419
|
+
];
|
|
2420
|
+
}),
|
|
2421
|
+
_: 1
|
|
2422
|
+
}),
|
|
2423
|
+
$(h, {
|
|
2424
|
+
variant: "outlined",
|
|
2425
|
+
class: "flex flex-col gap-8 px-12 py-16"
|
|
2426
|
+
}, {
|
|
2427
|
+
default: Z(() => {
|
|
2428
|
+
var R, ie;
|
|
2429
|
+
return [
|
|
2430
|
+
o("div", Ra, [
|
|
2431
|
+
e[12] || (e[12] = o("div", { class: "fm-typo-en-body-lg-600" }, "Closing summary", -1)),
|
|
2432
|
+
o("div", Pa, [
|
|
2433
|
+
o("div", {
|
|
2434
|
+
class: Ae(["fm-status-badge", d(rt)(((R = n.draft) == null ? void 0 : R.status) ?? "DRAFT")])
|
|
2435
|
+
}, H(d($e)(((ie = n.draft) == null ? void 0 : ie.status) ?? "")), 3)
|
|
2436
|
+
])
|
|
2437
|
+
]),
|
|
2438
|
+
$(B),
|
|
2439
|
+
o("div", Va, [
|
|
2440
|
+
(k(!0), M(le, null, he(pn.value, (me, _e) => (k(), M("div", {
|
|
2441
|
+
class: "flex flex-col gap-4",
|
|
2442
|
+
key: _e
|
|
2443
|
+
}, [
|
|
2444
|
+
o("div", Na, [
|
|
2445
|
+
o("div", za, H(me.label), 1)
|
|
2446
|
+
]),
|
|
2447
|
+
o("div", Ea, H(me.value), 1)
|
|
2448
|
+
]))), 128))
|
|
2449
|
+
])
|
|
2450
|
+
];
|
|
2451
|
+
}),
|
|
2452
|
+
_: 1
|
|
2453
|
+
}),
|
|
2454
|
+
fn.value ? (k(), M("div", La, [
|
|
2455
|
+
$(U, {
|
|
2456
|
+
name: "rule",
|
|
2457
|
+
size: "sm"
|
|
2458
|
+
}),
|
|
2459
|
+
o("div", Oa, [
|
|
2460
|
+
e[14] || (e[14] = o("div", { class: "fm-typo-en-body-md-600" }, "UOM notes", -1)),
|
|
2461
|
+
o("ul", Ha, [
|
|
2462
|
+
xt.value ? (k(), M("li", Ya, e[13] || (e[13] = [
|
|
2463
|
+
ce(" Measurements highlighted in "),
|
|
2464
|
+
o("span", { class: "font-bold" }, "purple", -1),
|
|
2465
|
+
ce(" are NetSuite-inactive UOMs (surfaced for audit; their amounts are part of the base total). ")
|
|
2466
|
+
]))) : Y("", !0),
|
|
2467
|
+
Dt.value ? (k(), M("li", Ka, " Red highlights are UOMs not on the SKU (ignored). ")) : Y("", !0)
|
|
2468
|
+
])
|
|
2469
|
+
])
|
|
2470
|
+
])) : Y("", !0),
|
|
2471
|
+
o("div", Wa, [
|
|
2472
|
+
o("div", qa, [
|
|
2473
|
+
e[15] || (e[15] = o("div", { class: "flex-1 fm-typo-en-title-sm-600 text-fm-color-typo-primary" }, " Closing items ", -1)),
|
|
2474
|
+
w.value ? Y("", !0) : (k(), M("div", Ga, [
|
|
2475
|
+
n.draft && n.draft.status !== d(we).enum.COMPLETED ? (k(), ne(S, {
|
|
2476
|
+
key: 0,
|
|
2477
|
+
label: "Refresh balance",
|
|
2478
|
+
"prepend-icon": "refresh",
|
|
2479
|
+
variant: "secondary",
|
|
2480
|
+
"text-color": "primary",
|
|
2481
|
+
"bg-color": "transparent",
|
|
2482
|
+
"border-color": "primary",
|
|
2483
|
+
loading: d(ae),
|
|
2484
|
+
disabled: d(ae),
|
|
2485
|
+
onClick: Ge
|
|
2486
|
+
}, null, 8, ["loading", "disabled"])) : Y("", !0),
|
|
2487
|
+
$(gt, null, {
|
|
2488
|
+
default: Z(() => [
|
|
2489
|
+
$(S, {
|
|
2490
|
+
label: "Invalidate Draft Cache",
|
|
2491
|
+
"prepend-icon": "refresh",
|
|
2492
|
+
variant: "secondary",
|
|
2493
|
+
"text-color": "primary",
|
|
2494
|
+
"bg-color": "transparent",
|
|
2495
|
+
"border-color": "primary",
|
|
2496
|
+
loading: d(ae),
|
|
2497
|
+
onClick: sn
|
|
2498
|
+
}, null, 8, ["loading"])
|
|
2499
|
+
]),
|
|
2500
|
+
_: 1
|
|
2501
|
+
}),
|
|
2502
|
+
$(S, {
|
|
2503
|
+
label: "Export data",
|
|
2504
|
+
"prepend-icon": "download",
|
|
2505
|
+
variant: "secondary",
|
|
2506
|
+
"text-color": "primary",
|
|
2507
|
+
"bg-color": "transparent",
|
|
2508
|
+
"border-color": "primary",
|
|
2509
|
+
onClick: e[1] || (e[1] = (R) => n.draft ? d(r).exportDraft(
|
|
2510
|
+
n.draft,
|
|
2511
|
+
z.value,
|
|
2512
|
+
I.value,
|
|
2513
|
+
At.value
|
|
2514
|
+
) : null)
|
|
2515
|
+
})
|
|
2516
|
+
]))
|
|
2517
|
+
]),
|
|
2518
|
+
w.value ? (k(), M("div", Qa, [
|
|
2519
|
+
e[17] || (e[17] = o("div", { class: "h-80" }, null, -1)),
|
|
2520
|
+
o("div", Za, [
|
|
2521
|
+
o("div", null, [
|
|
2522
|
+
$(X, { size: "md" })
|
|
2523
|
+
]),
|
|
2524
|
+
e[16] || (e[16] = o("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Fetching info... ", -1))
|
|
2525
|
+
]),
|
|
2526
|
+
e[18] || (e[18] = o("div", { class: "h-80" }, null, -1))
|
|
2527
|
+
])) : (k(), M(le, { key: 1 }, [
|
|
2528
|
+
o("div", Ja, [
|
|
2529
|
+
o("div", Xa, [
|
|
2530
|
+
$(O, {
|
|
2531
|
+
label: "Template Item(s)",
|
|
2532
|
+
selected: C.value.templateItem,
|
|
2533
|
+
onClick: e[2] || (e[2] = (R) => C.value.templateItem = !C.value.templateItem)
|
|
2534
|
+
}, null, 8, ["selected"]),
|
|
2535
|
+
$(O, {
|
|
2536
|
+
label: "Non-template Item(s)",
|
|
2537
|
+
selected: C.value.nonTemplateItem,
|
|
2538
|
+
onClick: e[3] || (e[3] = (R) => C.value.nonTemplateItem = !C.value.nonTemplateItem)
|
|
2539
|
+
}, null, 8, ["selected"])
|
|
2540
|
+
]),
|
|
2541
|
+
$(se, {
|
|
2542
|
+
modelValue: dt.value,
|
|
2543
|
+
"onUpdate:modelValue": e[4] || (e[4] = (R) => dt.value = R),
|
|
2544
|
+
placeholder: "Filter items"
|
|
2545
|
+
}, null, 8, ["modelValue"])
|
|
2546
|
+
]),
|
|
2547
|
+
d(m).skuTags.size ? (k(), M("div", eo, [
|
|
2548
|
+
(k(!0), M(le, null, he(d(m).skuTags.keys(), (R) => (k(), ne(O, {
|
|
2549
|
+
key: `${R}`,
|
|
2550
|
+
label: `${R}`,
|
|
2551
|
+
selectable: "",
|
|
2552
|
+
selected: g[`${R}`],
|
|
2553
|
+
onClick: (ie) => g[`${R}`] = !g[`${R}`]
|
|
2554
|
+
}, {
|
|
2555
|
+
default: Z(() => [
|
|
2556
|
+
g[`${R}`] ? (k(), ne(U, {
|
|
2557
|
+
key: 0,
|
|
2558
|
+
name: "check",
|
|
2559
|
+
class: "text-white",
|
|
2560
|
+
size: "sm"
|
|
2561
|
+
})) : Y("", !0),
|
|
2562
|
+
o("span", {
|
|
2563
|
+
class: Ae([
|
|
2564
|
+
"",
|
|
2565
|
+
{
|
|
2566
|
+
"text-white fm-typo-en-body-md-600": g[`${R}`],
|
|
2567
|
+
"text-fm-color-typo-primary fm-typo-en-body-md-400": !g[`${R}`]
|
|
2568
|
+
}
|
|
2569
|
+
])
|
|
2570
|
+
}, H(R), 3)
|
|
2571
|
+
]),
|
|
2572
|
+
_: 2
|
|
2573
|
+
}, 1032, ["label", "selected", "onClick"]))), 128))
|
|
2574
|
+
])) : Y("", !0),
|
|
2575
|
+
mt.value.length ? (k(), M("div", to, [
|
|
2576
|
+
e[19] || (e[19] = o("span", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary self-center" }, "Extra columns:", -1)),
|
|
2577
|
+
(k(!0), M(le, null, he(mt.value, (R) => (k(), ne(O, {
|
|
2578
|
+
key: R,
|
|
2579
|
+
label: R,
|
|
2580
|
+
selectable: "",
|
|
2581
|
+
selected: Ze[R],
|
|
2582
|
+
onClick: (ie) => Ze[R] = !Ze[R]
|
|
2583
|
+
}, null, 8, ["label", "selected", "onClick"]))), 128))
|
|
2584
|
+
])) : Y("", !0),
|
|
2585
|
+
o("div", no, [
|
|
2586
|
+
o("div", {
|
|
2587
|
+
style: Ht({ height: "600px", minWidth: `${dn.value}px` })
|
|
2588
|
+
}, [
|
|
2589
|
+
$(ge, {
|
|
2590
|
+
"column-defs": wt.value,
|
|
2591
|
+
"row-data": Qe.value,
|
|
2592
|
+
"search-value": dt.value
|
|
2593
|
+
}, null, 8, ["column-defs", "row-data", "search-value"])
|
|
2594
|
+
], 4)
|
|
2595
|
+
])
|
|
2596
|
+
], 64))
|
|
2597
|
+
])
|
|
2598
|
+
], 64)) : Y("", !0),
|
|
2599
|
+
ze.value.value === "history" ? (k(), M("div", ao, [
|
|
2600
|
+
je.value.length ? (k(), M("div", ro, [
|
|
2601
|
+
(k(!0), M(le, null, he(je.value, (R, ie) => (k(), M(le, { key: ie }, [
|
|
2602
|
+
o("div", lo, [
|
|
2603
|
+
o("div", io, [
|
|
2604
|
+
o("div", co, [
|
|
2605
|
+
o("div", {
|
|
2606
|
+
class: Ae([
|
|
2607
|
+
{
|
|
2608
|
+
"bg-fm-color-primary": ie !== 0,
|
|
2609
|
+
"bg-white": ie === 0
|
|
2610
|
+
},
|
|
2611
|
+
"w-[2px] h-full"
|
|
2612
|
+
])
|
|
2613
|
+
}, null, 2)
|
|
2614
|
+
]),
|
|
2615
|
+
e[22] || (e[22] = o("div", { class: "h-24 w-24 bg-fm-color-primary rounded-full" }, null, -1)),
|
|
2616
|
+
o("div", uo, [
|
|
2617
|
+
o("div", {
|
|
2618
|
+
class: Ae([
|
|
2619
|
+
{
|
|
2620
|
+
"bg-fm-color-primary": ie < je.value.length - 1,
|
|
2621
|
+
"bg-white": ie >= je.value.length - 1
|
|
2622
|
+
},
|
|
2623
|
+
"w-[2px] h-full"
|
|
2624
|
+
])
|
|
2625
|
+
}, null, 2)
|
|
2626
|
+
])
|
|
2627
|
+
]),
|
|
2628
|
+
o("div", mo, [
|
|
2629
|
+
o("div", fo, H(R.header), 1),
|
|
2630
|
+
o("div", po, H(R.date), 1)
|
|
2631
|
+
])
|
|
2632
|
+
]),
|
|
2633
|
+
o("div", vo, [
|
|
2634
|
+
o("div", yo, [
|
|
2635
|
+
o("div", go, [
|
|
2636
|
+
o("div", {
|
|
2637
|
+
class: Ae([
|
|
2638
|
+
{
|
|
2639
|
+
"bg-fm-color-primary": ie < je.value.length - 1,
|
|
2640
|
+
"bg-white": ie >= je.value.length - 1
|
|
2641
|
+
},
|
|
2642
|
+
"w-[2px] h-full"
|
|
2643
|
+
])
|
|
2644
|
+
}, null, 2)
|
|
2645
|
+
])
|
|
2646
|
+
]),
|
|
2647
|
+
o("div", bo, [
|
|
2648
|
+
$(h, {
|
|
2649
|
+
variant: "outlined",
|
|
2650
|
+
class: "py-12 px-16"
|
|
2651
|
+
}, {
|
|
2652
|
+
default: Z(() => [
|
|
2653
|
+
o("div", ho, [
|
|
2654
|
+
(k(!0), M(le, null, he(R.info, (me, _e) => (k(), M("div", {
|
|
2655
|
+
key: _e,
|
|
2656
|
+
class: "flex flex-col gap-4"
|
|
2657
|
+
}, [
|
|
2658
|
+
o("div", ko, H(me == null ? void 0 : me.label), 1),
|
|
2659
|
+
o("div", _o, [
|
|
2660
|
+
(k(!0), M(le, null, he(me == null ? void 0 : me.values, (Ue, tt) => (k(), M("div", {
|
|
2661
|
+
key: tt,
|
|
2662
|
+
class: "fm-typo-en-body-lg-600"
|
|
2663
|
+
}, H(Ue), 1))), 128))
|
|
2664
|
+
])
|
|
2665
|
+
]))), 128))
|
|
2666
|
+
])
|
|
2667
|
+
]),
|
|
2668
|
+
_: 2
|
|
2669
|
+
}, 1024)
|
|
2670
|
+
])
|
|
2671
|
+
])
|
|
2672
|
+
], 64))), 128))
|
|
2673
|
+
])) : (k(), M("div", oo, [
|
|
2674
|
+
$(Me),
|
|
2675
|
+
o("div", null, [
|
|
2676
|
+
o("img", {
|
|
2677
|
+
src: d(Hn),
|
|
2678
|
+
alt: "List is empty"
|
|
2679
|
+
}, null, 8, so)
|
|
2680
|
+
]),
|
|
2681
|
+
e[20] || (e[20] = o("div", { class: "fm-typo-en-body-lg-600" }, H("No records found"), -1)),
|
|
2682
|
+
e[21] || (e[21] = o("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary px-16" }, H("You can track approval and rejection history here"), -1)),
|
|
2683
|
+
$(Me),
|
|
2684
|
+
$(Me)
|
|
2685
|
+
]))
|
|
2686
|
+
])) : Y("", !0)
|
|
2687
|
+
])
|
|
2688
|
+
]),
|
|
2689
|
+
_: 1
|
|
2690
|
+
}, 8, ["model-value"]),
|
|
2691
|
+
d(c) && t.draft ? (k(), ne(Ta, {
|
|
2692
|
+
key: 0,
|
|
2693
|
+
show: Je.value,
|
|
2694
|
+
"onUpdate:show": e[10] || (e[10] = (R) => Je.value = R),
|
|
2695
|
+
refreshing: d(ae),
|
|
2696
|
+
approving: Xe.value,
|
|
2697
|
+
draft: t.draft,
|
|
2698
|
+
onRefresh: Ge,
|
|
2699
|
+
onApprove: vn
|
|
2700
|
+
}, null, 8, ["show", "refreshing", "approving", "draft"])) : Y("", !0)
|
|
2701
|
+
], 64);
|
|
2702
|
+
};
|
|
2703
|
+
}
|
|
2704
|
+
});
|
|
2705
|
+
var pe = /* @__PURE__ */ ((a) => (a.ready = "ready", a.negative = "negative", a.systemNegative = "systemNegative", a))(pe || {});
|
|
2706
|
+
async function So(a) {
|
|
2707
|
+
return new Promise((l, t) => {
|
|
2708
|
+
const s = new FileReader();
|
|
2709
|
+
s.onload = (b) => {
|
|
2710
|
+
var i;
|
|
2711
|
+
try {
|
|
2712
|
+
const r = (i = b.target) == null ? void 0 : i.result, c = Wn(r, { type: "array" }), w = c.SheetNames[0], A = c.Sheets[w], p = st.sheet_to_json(A, {
|
|
2713
|
+
header: 1,
|
|
2714
|
+
defval: ""
|
|
2715
|
+
}), j = (m) => String(m).trim().toLowerCase().replace(/^\uFEFF/, ""), N = p.findIndex(
|
|
2716
|
+
(m) => m.some((f) => j(f) === "code")
|
|
2717
|
+
);
|
|
2718
|
+
if (N === -1) {
|
|
2719
|
+
l([]);
|
|
2720
|
+
return;
|
|
2721
|
+
}
|
|
2722
|
+
const z = p[N], I = z.findIndex((m) => j(m) === "code"), D = z.findIndex((m) => j(m) === "balance");
|
|
2723
|
+
if (I === -1 || D === -1) {
|
|
2724
|
+
t(
|
|
2725
|
+
new Error(
|
|
2726
|
+
`Missing required columns: ${I === -1 ? '"Code" ' : ""}${D === -1 ? '"Balance"' : ""}.`.trim()
|
|
2727
|
+
)
|
|
2728
|
+
);
|
|
2729
|
+
return;
|
|
2730
|
+
}
|
|
2731
|
+
const v = p.slice(N + 1).filter((m) => String(m[I]).trim()).map((m) => ({
|
|
2732
|
+
itemCode: String(m[I]).trim(),
|
|
2733
|
+
quantity: Number(m[D]) || 0
|
|
2734
|
+
}));
|
|
2735
|
+
l(v);
|
|
2736
|
+
} catch (r) {
|
|
2737
|
+
t(r);
|
|
2738
|
+
}
|
|
2739
|
+
}, s.onerror = t, s.readAsArrayBuffer(a);
|
|
2740
|
+
});
|
|
2741
|
+
}
|
|
2742
|
+
function $o(a) {
|
|
2743
|
+
const l = /* @__PURE__ */ new Map();
|
|
2744
|
+
return a.forEach((t) => {
|
|
2745
|
+
const s = l.get(t.itemCode) || 0;
|
|
2746
|
+
l.set(t.itemCode, s + t.quantity);
|
|
2747
|
+
}), l;
|
|
2748
|
+
}
|
|
2749
|
+
function Fo(a, l) {
|
|
2750
|
+
const t = [], s = [];
|
|
2751
|
+
for (const [b, i] of l.entries()) {
|
|
2752
|
+
const r = a[b];
|
|
2753
|
+
if (!r) {
|
|
2754
|
+
s.push(b);
|
|
2755
|
+
continue;
|
|
2756
|
+
}
|
|
2757
|
+
const c = i < 0 ? "negative" : "ready";
|
|
2758
|
+
t.push({
|
|
2759
|
+
sku: r,
|
|
2760
|
+
physicalCount: i,
|
|
2761
|
+
// Note: filled by composable after readStockBalance()
|
|
2762
|
+
systemBalance: { amount: 0, precision: 0 },
|
|
2763
|
+
variance: i - 0,
|
|
2764
|
+
status: c
|
|
2765
|
+
});
|
|
2766
|
+
}
|
|
2767
|
+
return { mergedItems: t, unrecognisedItemCodes: s };
|
|
2768
|
+
}
|
|
2769
|
+
function Io(a, l) {
|
|
2770
|
+
const t = a.filter((w) => !w.isInactive), s = Gn().format("YYYY-MM-DD"), b = `${l} - ${s}.csv`, i = [
|
|
2771
|
+
["Code", "Name", "Balance"],
|
|
2772
|
+
...t.map((w) => [w.code, w.name, ""])
|
|
2773
|
+
], r = st.aoa_to_sheet(i), c = st.book_new();
|
|
2774
|
+
st.book_append_sheet(c, r, "Template"), qn(c, b, { bookType: "csv" });
|
|
2775
|
+
}
|
|
2776
|
+
function Bo() {
|
|
2777
|
+
const a = q([]), l = q([]), t = q(!1), s = _t(), b = Ye(), i = ut(), r = T(
|
|
2778
|
+
() => a.value.some((p) => p.status === pe.negative)
|
|
2779
|
+
);
|
|
2780
|
+
async function c(p) {
|
|
2781
|
+
a.value = [], l.value = [], t.value = !0;
|
|
2782
|
+
try {
|
|
2783
|
+
const j = await So(p), N = $o(j), z = s.skuByCode, { mergedItems: I, unrecognisedItemCodes: D } = Fo(
|
|
2784
|
+
z,
|
|
2785
|
+
N
|
|
2786
|
+
), P = await i.readStockBalance(), v = P.skus ?? [];
|
|
2787
|
+
v.length === 0 && console.warn(
|
|
2788
|
+
"No SKU balances found when importing closing draft. All system balances will be set to 0.",
|
|
2789
|
+
{
|
|
2790
|
+
stockBalance: P
|
|
2791
|
+
}
|
|
2792
|
+
);
|
|
2793
|
+
const m = new Map(
|
|
2794
|
+
v.map((g) => [g.id, g.balance])
|
|
2795
|
+
), f = new Set(I.map((g) => g.sku._id));
|
|
2796
|
+
a.value = I.map((g) => {
|
|
2797
|
+
const y = m.get(g.sku._id) ?? { amount: 0, precision: 0 }, x = y.amount / Math.pow(10, y.precision);
|
|
2798
|
+
return { ...g, systemBalance: y, variance: g.physicalCount - x };
|
|
2799
|
+
});
|
|
2800
|
+
for (const g of Object.values(s.skuByCode)) {
|
|
2801
|
+
if (f.has(g._id)) continue;
|
|
2802
|
+
const y = m.get(g._id);
|
|
2803
|
+
if (!y) continue;
|
|
2804
|
+
const x = y.amount / Math.pow(10, y.precision);
|
|
2805
|
+
x >= 0 || a.value.push({
|
|
2806
|
+
sku: g,
|
|
2807
|
+
physicalCount: 0,
|
|
2808
|
+
systemBalance: y,
|
|
2809
|
+
variance: 0 - x,
|
|
2810
|
+
status: pe.systemNegative
|
|
2811
|
+
});
|
|
2812
|
+
}
|
|
2813
|
+
l.value = D;
|
|
2814
|
+
} catch (j) {
|
|
2815
|
+
a.value = [], l.value = [], console.error("Error processing uploaded file", { error: j });
|
|
2816
|
+
} finally {
|
|
2817
|
+
t.value = !1;
|
|
2818
|
+
}
|
|
2819
|
+
}
|
|
2820
|
+
async function w() {
|
|
2821
|
+
const p = Ke(), j = a.value.filter((v) => v.status === pe.ready), N = a.value.filter(
|
|
2822
|
+
(v) => v.status === pe.systemNegative
|
|
2823
|
+
), z = (v) => ({
|
|
2824
|
+
sku: {
|
|
2825
|
+
_id: v.sku._id,
|
|
2826
|
+
code: v.sku.code,
|
|
2827
|
+
name: v.sku.name,
|
|
2828
|
+
unit: v.sku.unit
|
|
2829
|
+
},
|
|
2830
|
+
baseAmount: Qt(v.physicalCount, v.sku.unit.precision),
|
|
2831
|
+
measurementsAmounts: []
|
|
2832
|
+
}), I = j.map(z), D = N.map(z), P = {
|
|
2833
|
+
effectiveAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2834
|
+
items: I,
|
|
2835
|
+
negativeStockItems: D
|
|
2836
|
+
};
|
|
2837
|
+
return await p.createQuickModeDraftWithItems(P);
|
|
2838
|
+
}
|
|
2839
|
+
function A() {
|
|
2840
|
+
var j;
|
|
2841
|
+
const p = ((j = b.currentLocation) == null ? void 0 : j.name) ?? "template";
|
|
2842
|
+
Io(s.skus, p);
|
|
2843
|
+
}
|
|
2844
|
+
return { mergedItems: a, unrecognisedItemCodes: l, hasBlockingErrors: r, isLoading: t, onFileUpload: c, submit: w, downloadTemplate: A };
|
|
2845
|
+
}
|
|
2846
|
+
const To = { class: "flex flex-col gap-16" }, jo = {
|
|
2847
|
+
key: 0,
|
|
2848
|
+
class: "px-16 py-12 rounded-8 bg-fm-color-danger-weak text-fm-color-danger-default"
|
|
2849
|
+
}, Mo = { key: 1 }, Uo = { class: "fm-typo-en-label-md-400 cursor-pointer" }, Ro = { class: "mt-8 flex flex-col gap-4" }, Po = { key: 2 }, Vo = { class: "fm-typo-en-label-md-400 cursor-pointer" }, No = { class: "mt-8 flex flex-col gap-4" }, zo = /* @__PURE__ */ Be({
|
|
2850
|
+
__name: "ClosingDraftCreatePreviewTable",
|
|
2851
|
+
props: {
|
|
2852
|
+
items: {},
|
|
2853
|
+
unrecognisedItemCodes: {}
|
|
2854
|
+
},
|
|
2855
|
+
setup(a) {
|
|
2856
|
+
const l = a, { t } = Oe(), s = T(
|
|
2857
|
+
() => l.items.filter((c) => c.status === pe.negative)
|
|
2858
|
+
), b = T(
|
|
2859
|
+
() => l.items.filter((c) => c.status === pe.systemNegative)
|
|
2860
|
+
), i = T(() => ({
|
|
2861
|
+
[pe.negative]: {
|
|
2862
|
+
bgColor: "bg-fm-color-danger-weak",
|
|
2863
|
+
textColor: "text-fm-color-danger-default",
|
|
2864
|
+
icon: "🚫",
|
|
2865
|
+
label: t("inventory.closing.draft.createDraft.previewTable.status.negative")
|
|
2866
|
+
},
|
|
2867
|
+
[pe.systemNegative]: {
|
|
2868
|
+
bgColor: "bg-fm-color-warning-weak",
|
|
2869
|
+
textColor: "text-fm-color-warning-default",
|
|
2870
|
+
icon: "⚠️",
|
|
2871
|
+
label: t("inventory.closing.draft.createDraft.previewTable.status.systemNegative")
|
|
2872
|
+
}
|
|
2873
|
+
})), r = [
|
|
2874
|
+
{
|
|
2875
|
+
id: "name",
|
|
2876
|
+
header: () => t("inventory.ingredient.name"),
|
|
2877
|
+
cell: (c) => c.row.original.sku.name
|
|
2878
|
+
},
|
|
2879
|
+
{
|
|
2880
|
+
id: "uom",
|
|
2881
|
+
header: () => t("inventory.closing.draft.createDraft.previewTable.uom"),
|
|
2882
|
+
size: 80,
|
|
2883
|
+
cell: (c) => c.row.original.sku.unit.abbrev
|
|
2884
|
+
},
|
|
2885
|
+
{
|
|
2886
|
+
id: "systemBalance",
|
|
2887
|
+
header: () => t("inventory.closing.draft.createDraft.previewTable.systemBalance"),
|
|
2888
|
+
size: 180,
|
|
2889
|
+
cell: (c) => {
|
|
2890
|
+
const w = c.row.original;
|
|
2891
|
+
return _("div", te(w.systemBalance));
|
|
2892
|
+
}
|
|
2893
|
+
},
|
|
2894
|
+
{
|
|
2895
|
+
id: "physicalCount",
|
|
2896
|
+
header: () => t("inventory.closing.draft.createDraft.previewTable.stockTakeBalance"),
|
|
2897
|
+
cell: (c) => {
|
|
2898
|
+
const w = c.row.original;
|
|
2899
|
+
return _("div", te(w.physicalCount));
|
|
2900
|
+
}
|
|
2901
|
+
},
|
|
2902
|
+
{
|
|
2903
|
+
id: "variance",
|
|
2904
|
+
header: () => t("inventory.closing.draft.createDraft.previewTable.variance"),
|
|
2905
|
+
cell: (c) => {
|
|
2906
|
+
const A = c.row.original.variance, p = A < 0 ? "text-fm-color-danger-default" : A > 0 ? "text-fm-color-success-default" : "";
|
|
2907
|
+
return _("span", { class: p }, te(A));
|
|
2908
|
+
}
|
|
2909
|
+
},
|
|
2910
|
+
{
|
|
2911
|
+
id: "variancePercentage",
|
|
2912
|
+
header: () => t("inventory.closing.draft.createDraft.previewTable.variancePercentage"),
|
|
2913
|
+
size: 130,
|
|
2914
|
+
cell: (c) => {
|
|
2915
|
+
const w = c.row.original, A = w.systemBalance.amount / Math.pow(10, w.systemBalance.precision), p = A === 0 ? null : Math.max(
|
|
2916
|
+
-100,
|
|
2917
|
+
Math.min(100, Math.round(w.variance / Math.abs(A) * 1e4) / 100)
|
|
2918
|
+
);
|
|
2919
|
+
if (p === null)
|
|
2920
|
+
return _(
|
|
2921
|
+
"div",
|
|
2922
|
+
{ class: "flex items-center gap-4 justify-end fm-typo-en-body-md-400" },
|
|
2923
|
+
t("inventory.closing.draft.createDraft.previewTable.notApplicable")
|
|
2924
|
+
);
|
|
2925
|
+
const j = `${te(p)}`;
|
|
2926
|
+
if (p === 0)
|
|
2927
|
+
return _(
|
|
2928
|
+
"div",
|
|
2929
|
+
{ class: "flex items-center gap-4 justify-end fm-typo-en-body-md-400" },
|
|
2930
|
+
j
|
|
2931
|
+
);
|
|
2932
|
+
const N = p > 0;
|
|
2933
|
+
return _("div", { class: "flex items-center gap-4 justify-end fm-typo-en-body-md-400" }, [
|
|
2934
|
+
_(fe.FmIcon, {
|
|
2935
|
+
name: N ? "arrow_drop_up" : "arrow_drop_down",
|
|
2936
|
+
color: N ? "system-success-300" : "system-error-300",
|
|
2937
|
+
size: "md"
|
|
2938
|
+
}),
|
|
2939
|
+
j
|
|
2940
|
+
]);
|
|
2941
|
+
}
|
|
2942
|
+
},
|
|
2943
|
+
{
|
|
2944
|
+
id: "status",
|
|
2945
|
+
header: () => t("inventory.common.status"),
|
|
2946
|
+
cell: (c) => {
|
|
2947
|
+
const w = c.row.original.status, A = i.value[w];
|
|
2948
|
+
return A ? _(
|
|
2949
|
+
"span",
|
|
2950
|
+
{
|
|
2951
|
+
class: `px-8 py-2 rounded-4 ${A.bgColor} ${A.textColor} fm-typo-en-label-sm-400`
|
|
2952
|
+
},
|
|
2953
|
+
`${A.icon} ${A.label}`
|
|
2954
|
+
) : null;
|
|
2955
|
+
}
|
|
2956
|
+
}
|
|
2957
|
+
];
|
|
2958
|
+
return (c, w) => {
|
|
2959
|
+
const A = Q("FmTable");
|
|
2960
|
+
return k(), M("div", To, [
|
|
2961
|
+
s.value.length > 0 ? (k(), M("div", jo, [
|
|
2962
|
+
ce(H(d(t)("inventory.closing.draft.createDraft.previewTable.cannotSubmitNegative")) + " ", 1),
|
|
2963
|
+
o("strong", null, H(s.value.map((p) => p.sku.code).join(", ")), 1)
|
|
2964
|
+
])) : Y("", !0),
|
|
2965
|
+
b.value.length > 0 ? (k(), M("details", Mo, [
|
|
2966
|
+
o("summary", Uo, H(d(t)("inventory.closing.draft.createDraft.previewTable.systemNegativeNote", [b.value.length])), 1),
|
|
2967
|
+
o("ul", Ro, [
|
|
2968
|
+
(k(!0), M(le, null, he(b.value, (p) => (k(), M("li", {
|
|
2969
|
+
key: p.sku._id,
|
|
2970
|
+
class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
|
|
2971
|
+
}, H(p.sku.code), 1))), 128))
|
|
2972
|
+
])
|
|
2973
|
+
])) : Y("", !0),
|
|
2974
|
+
c.unrecognisedItemCodes.length > 0 ? (k(), M("details", Po, [
|
|
2975
|
+
o("summary", Vo, H(d(t)("inventory.closing.draft.createDraft.previewTable.unrecognisedNote", [c.unrecognisedItemCodes.length])), 1),
|
|
2976
|
+
o("ul", No, [
|
|
2977
|
+
(k(!0), M(le, null, he(c.unrecognisedItemCodes, (p) => (k(), M("li", {
|
|
2978
|
+
key: p,
|
|
2979
|
+
class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
|
|
2980
|
+
}, H(p), 1))), 128))
|
|
2981
|
+
])
|
|
2982
|
+
])) : Y("", !0),
|
|
2983
|
+
$(A, {
|
|
2984
|
+
"row-data": l.items,
|
|
2985
|
+
"column-defs": r,
|
|
2986
|
+
pagination: { pageSize: 20 }
|
|
2987
|
+
}, null, 8, ["row-data"])
|
|
2988
|
+
]);
|
|
2989
|
+
};
|
|
2990
|
+
}
|
|
2991
|
+
}), Eo = { class: "flex flex-col gap-16" }, Lo = { class: "flex flex-col gap-8" }, Oo = { class: "fm-typo-en-body-lg-600" }, Ho = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Yo = { class: "fm-corner-radius-md p-16 flex items-center gap-16 border border-fm-color-border-default" }, Ko = { class: "flex flex-col flex-1 gap-4" }, Wo = { class: "fm-typo-en-body-md-600" }, qo = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Go = {
|
|
2992
|
+
key: 0,
|
|
2993
|
+
class: "flex flex-col gap-8"
|
|
2994
|
+
}, Qo = { class: "fm-typo-en-body-lg-600" }, Zo = {
|
|
2995
|
+
key: 0,
|
|
2996
|
+
class: "fm-typo-en-body-sm-400 text-fm-color-system-error-300 flex items-center gap-8"
|
|
2997
|
+
}, Jo = { class: "grid grid-cols-[repeat(3,1fr)] gap-12" }, Xo = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary flex items-center gap-4" }, es = { class: "flex items-center gap-8 w-full" }, ts = /* @__PURE__ */ Be({
|
|
2998
|
+
__name: "ClosingDraftCreateSideSheet",
|
|
2999
|
+
props: {
|
|
3000
|
+
show: { type: Boolean }
|
|
3001
|
+
},
|
|
3002
|
+
emits: ["update:show", "submitted"],
|
|
3003
|
+
setup(a, { emit: l }) {
|
|
3004
|
+
const t = a, s = l, b = Kt(t, "show"), { t: i } = Oe(), r = He(), c = q("upload"), w = q(null), A = q(!1), { mergedItems: p, unrecognisedItemCodes: j, hasBlockingErrors: N, isLoading: z, onFileUpload: I, submit: D, downloadTemplate: P } = Bo(), v = T(
|
|
3005
|
+
() => w.value && !z.value && p.value.length > 0
|
|
3006
|
+
), m = T(() => {
|
|
3007
|
+
const x = p.value.filter(
|
|
3008
|
+
(W) => W.status === pe.ready
|
|
3009
|
+
).length, L = p.value.filter(
|
|
3010
|
+
(W) => W.status === pe.negative
|
|
3011
|
+
).length, K = p.value.filter(
|
|
3012
|
+
(W) => W.status === pe.systemNegative
|
|
3013
|
+
).length, ae = p.value.filter((W) => W.variance !== 0).length;
|
|
3014
|
+
return [
|
|
3015
|
+
{ label: i("inventory.closing.draft.createDraft.summary.totalItems"), value: p.value.length },
|
|
3016
|
+
{ label: i("inventory.closing.draft.createDraft.summary.itemsWithCount"), value: x },
|
|
3017
|
+
{
|
|
3018
|
+
label: i("inventory.closing.draft.createDraft.summary.unrecognisedItems"),
|
|
3019
|
+
value: j.value.length,
|
|
3020
|
+
isWarning: j.value.length > 0
|
|
3021
|
+
},
|
|
3022
|
+
{ label: i("inventory.closing.draft.createDraft.summary.itemsWithVariance"), value: ae },
|
|
3023
|
+
{ label: i("inventory.closing.draft.createDraft.summary.negativeCounts"), value: L, isError: L > 0 },
|
|
3024
|
+
{
|
|
3025
|
+
label: i("inventory.closing.draft.createDraft.summary.systemNegative"),
|
|
3026
|
+
value: K,
|
|
3027
|
+
isWarning: K > 0
|
|
3028
|
+
}
|
|
3029
|
+
];
|
|
3030
|
+
});
|
|
3031
|
+
async function f(x) {
|
|
3032
|
+
w.value = x, await I(x);
|
|
3033
|
+
}
|
|
3034
|
+
async function g() {
|
|
3035
|
+
A.value = !0;
|
|
3036
|
+
try {
|
|
3037
|
+
await D(), y(), s("submitted"), r.open({
|
|
3038
|
+
title: "Success",
|
|
3039
|
+
message: "Closing draft created successfully",
|
|
3040
|
+
type: "success"
|
|
3041
|
+
});
|
|
3042
|
+
} catch (x) {
|
|
3043
|
+
console.error("Failed to create closing draft", { error: x }), r.open({
|
|
3044
|
+
title: "Something went wrong",
|
|
3045
|
+
message: "Failed to create closing draft. Please try again",
|
|
3046
|
+
type: "error"
|
|
3047
|
+
});
|
|
3048
|
+
} finally {
|
|
3049
|
+
A.value = !1;
|
|
3050
|
+
}
|
|
3051
|
+
}
|
|
3052
|
+
Ie(b, (x) => {
|
|
3053
|
+
x || (c.value = "upload", w.value = null);
|
|
3054
|
+
});
|
|
3055
|
+
function y() {
|
|
3056
|
+
b.value = !1;
|
|
3057
|
+
}
|
|
3058
|
+
return (x, L) => {
|
|
3059
|
+
const K = Q("FmCircularProgress"), ae = Q("FmIcon"), W = Q("FmButton"), de = Q("FmCard"), V = Q("FmSideSheet");
|
|
3060
|
+
return k(), ne(V, {
|
|
3061
|
+
"dismiss-away": "",
|
|
3062
|
+
"max-width": 9999,
|
|
3063
|
+
"model-value": d(b),
|
|
3064
|
+
"onUpdate:modelValue": L[2] || (L[2] = (C) => kt(b) ? b.value = C : null),
|
|
3065
|
+
header: d(i)("inventory.closing.draft.createDraft.title")
|
|
3066
|
+
}, {
|
|
3067
|
+
default: Z(() => [
|
|
3068
|
+
o("div", Eo, [
|
|
3069
|
+
c.value === "upload" ? (k(), M(le, { key: 0 }, [
|
|
3070
|
+
o("div", Lo, [
|
|
3071
|
+
o("div", Oo, H(d(i)("inventory.closing.draft.createDraft.importCsv")), 1),
|
|
3072
|
+
o("div", Ho, H(d(i)("inventory.closing.draft.createDraft.uploadDescription")), 1),
|
|
3073
|
+
$(Qn, {
|
|
3074
|
+
class: Ae({ "h-[200px]": !w.value }),
|
|
3075
|
+
accept: ".csv",
|
|
3076
|
+
disabled: d(z),
|
|
3077
|
+
onFileUpload: f
|
|
3078
|
+
}, xn({ _: 2 }, [
|
|
3079
|
+
w.value ? {
|
|
3080
|
+
name: "default",
|
|
3081
|
+
fn: Z(({ openFileDialog: C }) => [
|
|
3082
|
+
o("div", Yo, [
|
|
3083
|
+
d(z) ? (k(), ne(K, {
|
|
3084
|
+
key: 0,
|
|
3085
|
+
size: "md",
|
|
3086
|
+
color: "neutral-gray-200"
|
|
3087
|
+
})) : (k(), ne(ae, {
|
|
3088
|
+
key: 1,
|
|
3089
|
+
name: "check_circle",
|
|
3090
|
+
color: "system-success-400",
|
|
3091
|
+
size: "lg"
|
|
3092
|
+
})),
|
|
3093
|
+
o("div", Ko, [
|
|
3094
|
+
o("div", Wo, H(w.value.name), 1),
|
|
3095
|
+
o("div", qo, H(d(z) ? d(i)("inventory.closing.draft.createDraft.processing") : d(i)("inventory.closing.draft.createDraft.itemsLoaded", [d(p).length])), 1)
|
|
3096
|
+
]),
|
|
3097
|
+
d(z) ? Y("", !0) : (k(), ne(W, {
|
|
3098
|
+
key: 2,
|
|
3099
|
+
label: d(i)("inventory.closing.draft.createDraft.replaceFile"),
|
|
3100
|
+
variant: "secondary",
|
|
3101
|
+
"prepend-icon": "autorenew",
|
|
3102
|
+
onClick: C
|
|
3103
|
+
}, null, 8, ["label", "onClick"]))
|
|
3104
|
+
])
|
|
3105
|
+
]),
|
|
3106
|
+
key: "0"
|
|
3107
|
+
} : void 0
|
|
3108
|
+
]), 1032, ["class", "disabled"])
|
|
3109
|
+
]),
|
|
3110
|
+
v.value ? (k(), M("div", Go, [
|
|
3111
|
+
o("div", Qo, H(d(i)("inventory.closing.draft.createDraft.importSummary")), 1),
|
|
3112
|
+
d(N) ? (k(), M("div", Zo, [
|
|
3113
|
+
$(ae, {
|
|
3114
|
+
name: "error",
|
|
3115
|
+
size: "sm",
|
|
3116
|
+
color: "system-error-300"
|
|
3117
|
+
}),
|
|
3118
|
+
o("span", null, H(d(i)("inventory.closing.draft.createDraft.reviewIssues")), 1)
|
|
3119
|
+
])) : Y("", !0),
|
|
3120
|
+
$(de, {
|
|
3121
|
+
variant: "outlined",
|
|
3122
|
+
class: "flex flex-col gap-12 px-16 py-12"
|
|
3123
|
+
}, {
|
|
3124
|
+
default: Z(() => [
|
|
3125
|
+
o("div", Jo, [
|
|
3126
|
+
(k(!0), M(le, null, he(m.value, (C) => (k(), M("div", {
|
|
3127
|
+
key: C.label,
|
|
3128
|
+
class: "flex flex-col gap-4"
|
|
3129
|
+
}, [
|
|
3130
|
+
o("div", Xo, [
|
|
3131
|
+
C.isError ? (k(), ne(ae, {
|
|
3132
|
+
key: 0,
|
|
3133
|
+
name: "error",
|
|
3134
|
+
size: "sm",
|
|
3135
|
+
color: "system-error-300"
|
|
3136
|
+
})) : Y("", !0),
|
|
3137
|
+
C.isWarning && !C.isError ? (k(), ne(ae, {
|
|
3138
|
+
key: 1,
|
|
3139
|
+
name: "warning",
|
|
3140
|
+
size: "sm",
|
|
3141
|
+
color: "system-warning-300"
|
|
3142
|
+
})) : Y("", !0),
|
|
3143
|
+
o("span", null, H(C.label), 1)
|
|
3144
|
+
]),
|
|
3145
|
+
o("div", {
|
|
3146
|
+
class: Ae([
|
|
3147
|
+
"fm-typo-en-body-lg-600",
|
|
3148
|
+
{
|
|
3149
|
+
"text-fm-color-system-error-300": C.isError,
|
|
3150
|
+
"text-fm-color-system-warning-300": C.isWarning && !C.isError
|
|
3151
|
+
}
|
|
3152
|
+
])
|
|
3153
|
+
}, H(C.value), 3)
|
|
3154
|
+
]))), 128))
|
|
3155
|
+
])
|
|
3156
|
+
]),
|
|
3157
|
+
_: 1
|
|
3158
|
+
})
|
|
3159
|
+
])) : Y("", !0)
|
|
3160
|
+
], 64)) : Y("", !0),
|
|
3161
|
+
c.value === "preview" ? (k(), ne(zo, {
|
|
3162
|
+
key: 1,
|
|
3163
|
+
items: d(p),
|
|
3164
|
+
"unrecognised-item-codes": d(j)
|
|
3165
|
+
}, null, 8, ["items", "unrecognised-item-codes"])) : Y("", !0)
|
|
3166
|
+
])
|
|
3167
|
+
]),
|
|
3168
|
+
"side-sheet-footer": Z(() => [
|
|
3169
|
+
o("div", es, [
|
|
3170
|
+
c.value === "preview" ? (k(), ne(W, {
|
|
3171
|
+
key: 0,
|
|
3172
|
+
variant: "secondary",
|
|
3173
|
+
label: d(i)("inventory.common.back"),
|
|
3174
|
+
"prepend-icon": "arrow_back",
|
|
3175
|
+
onClick: L[0] || (L[0] = (C) => c.value = "upload")
|
|
3176
|
+
}, null, 8, ["label"])) : Y("", !0),
|
|
3177
|
+
c.value === "upload" ? (k(), ne(W, {
|
|
3178
|
+
key: 1,
|
|
3179
|
+
variant: "primary",
|
|
3180
|
+
label: d(i)("inventory.common.next"),
|
|
3181
|
+
disabled: !w.value || d(z),
|
|
3182
|
+
onClick: L[1] || (L[1] = (C) => c.value = "preview")
|
|
3183
|
+
}, null, 8, ["label", "disabled"])) : Y("", !0),
|
|
3184
|
+
c.value === "preview" ? (k(), ne(Zn, {
|
|
3185
|
+
key: 2,
|
|
3186
|
+
label: d(i)("inventory.closing.draft.createDraft.submit"),
|
|
3187
|
+
disabled: d(N) || d(p).length === 0 || A.value,
|
|
3188
|
+
loading: A.value,
|
|
3189
|
+
"confirm-title": d(i)("inventory.closing.draft.createDraft.confirmTitle"),
|
|
3190
|
+
"confirm-message": d(i)("inventory.closing.draft.createDraft.confirmMessage"),
|
|
3191
|
+
onConfirm: g
|
|
3192
|
+
}, null, 8, ["label", "disabled", "loading", "confirm-title", "confirm-message"])) : Y("", !0),
|
|
3193
|
+
$(W, {
|
|
3194
|
+
variant: "tertiary",
|
|
3195
|
+
label: d(i)("inventory.common.close"),
|
|
3196
|
+
onClick: y
|
|
3197
|
+
}, null, 8, ["label"]),
|
|
3198
|
+
c.value === "upload" ? (k(), ne(W, {
|
|
3199
|
+
key: 3,
|
|
3200
|
+
class: "ml-auto",
|
|
3201
|
+
variant: "secondary",
|
|
3202
|
+
label: d(i)("inventory.closing.draft.createDraft.downloadTemplate"),
|
|
3203
|
+
"prepend-icon": "download",
|
|
3204
|
+
onClick: d(P)
|
|
3205
|
+
}, null, 8, ["label", "onClick"])) : Y("", !0)
|
|
3206
|
+
])
|
|
3207
|
+
]),
|
|
3208
|
+
_: 1
|
|
3209
|
+
}, 8, ["model-value", "header"]);
|
|
3210
|
+
};
|
|
3211
|
+
}
|
|
3212
|
+
}), ns = { class: "flex-1 flex flex-col gap-8" }, as = { class: "flex flex-col" }, os = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ss = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, rs = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-2" }, ls = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, Rs = /* @__PURE__ */ Be({
|
|
3213
|
+
__name: "ClosingDraftView",
|
|
3214
|
+
setup(a) {
|
|
3215
|
+
const { t: l } = Oe(), { viewDraft: t } = ct(), { viewClosingDraftProps: s, viewClosingDraftShow: b } = jn(ct()), i = Ye(), r = on(), c = Cn(), { breakpoints: w } = Fn();
|
|
3216
|
+
i.watchLocation(r.fetchDrafts);
|
|
3217
|
+
const A = T(() => r.loading), p = q(""), j = q(!1), N = T(() => w.value.xs || w.value.sm), z = T(() => N.value ? 10 : 20), I = T(
|
|
3218
|
+
() => {
|
|
3219
|
+
var m;
|
|
3220
|
+
return ((m = i.currentLocation) == null ? void 0 : m.type) === Tn.enum.warehouse;
|
|
3221
|
+
}
|
|
3222
|
+
);
|
|
3223
|
+
function D(m) {
|
|
3224
|
+
switch (m) {
|
|
3225
|
+
case "add":
|
|
3226
|
+
return j.value = !0;
|
|
3227
|
+
case "refresh":
|
|
3228
|
+
return r.fetchDrafts();
|
|
3229
|
+
}
|
|
3230
|
+
}
|
|
3231
|
+
function P(m) {
|
|
3232
|
+
return m;
|
|
3233
|
+
}
|
|
3234
|
+
const v = T(() => {
|
|
3235
|
+
const m = {
|
|
3236
|
+
label: l("inventory.closing.draft.createDraft.title"),
|
|
3237
|
+
value: "add",
|
|
3238
|
+
isPrimary: !0,
|
|
3239
|
+
prependIcon: "add"
|
|
3240
|
+
}, f = {
|
|
3241
|
+
label: l("inventory.common.refresh"),
|
|
3242
|
+
value: "refresh",
|
|
3243
|
+
isPrimary: !1
|
|
3244
|
+
};
|
|
3245
|
+
return [...I.value ? [m] : [], f];
|
|
3246
|
+
});
|
|
3247
|
+
return (m, f) => {
|
|
3248
|
+
const g = Q("FmTable");
|
|
3249
|
+
return k(), M(le, null, [
|
|
3250
|
+
$(Sn, {
|
|
3251
|
+
title: d(l)("inventory.closing.draft.title"),
|
|
3252
|
+
actions: v.value,
|
|
3253
|
+
"onClick:action": D
|
|
3254
|
+
}, {
|
|
3255
|
+
default: Z(() => [
|
|
3256
|
+
o("div", {
|
|
3257
|
+
class: Ae([
|
|
3258
|
+
"flex flex-col gap-8 max-h-full",
|
|
3259
|
+
{
|
|
3260
|
+
"p-0": N.value,
|
|
3261
|
+
"px-24 ": !N.value
|
|
3262
|
+
}
|
|
3263
|
+
])
|
|
3264
|
+
}, [
|
|
3265
|
+
$(On, {
|
|
3266
|
+
"change-location": "",
|
|
3267
|
+
searchable: "",
|
|
3268
|
+
search: p.value,
|
|
3269
|
+
"onUpdate:search": f[0] || (f[0] = (y) => p.value = y)
|
|
3270
|
+
}, null, 8, ["search"]),
|
|
3271
|
+
(k(), ne(g, {
|
|
3272
|
+
key: d(r).tableKey,
|
|
3273
|
+
style: Ht(d(c).tableHeight),
|
|
3274
|
+
"column-defs": d(r).columnDefs,
|
|
3275
|
+
"row-data": d(r).drafts,
|
|
3276
|
+
"search-value": p.value,
|
|
3277
|
+
loading: A.value,
|
|
3278
|
+
onRowClick: f[1] || (f[1] = (y) => d(t)(y.original)),
|
|
3279
|
+
"page-size": z.value
|
|
3280
|
+
}, {
|
|
3281
|
+
"list-row": Z((y) => [
|
|
3282
|
+
$(Jn, {
|
|
3283
|
+
row: y,
|
|
3284
|
+
onRowClick: (x) => d(t)(x)
|
|
3285
|
+
}, {
|
|
3286
|
+
default: Z((x) => {
|
|
3287
|
+
var L, K, ae, W, de, V, C, oe, E, F, G, ue, xe, ke, ve, Ce, We, Ne, Te, qe;
|
|
3288
|
+
return [
|
|
3289
|
+
o("div", ns, [
|
|
3290
|
+
o("div", as, [
|
|
3291
|
+
o("div", os, [
|
|
3292
|
+
$(d(ot), {
|
|
3293
|
+
render: (ae = (K = (L = x._id) == null ? void 0 : L.column) == null ? void 0 : K.columnDef) == null ? void 0 : ae.cell,
|
|
3294
|
+
props: (de = (W = x._id) == null ? void 0 : W.getContext) == null ? void 0 : de.call(W)
|
|
3295
|
+
}, null, 8, ["render", "props"])
|
|
3296
|
+
]),
|
|
3297
|
+
o("div", ss, [
|
|
3298
|
+
$(d(ot), {
|
|
3299
|
+
render: (oe = (C = (V = x.name) == null ? void 0 : V.column) == null ? void 0 : C.columnDef) == null ? void 0 : oe.cell,
|
|
3300
|
+
props: (F = (E = x.name) == null ? void 0 : E.getContext) == null ? void 0 : F.call(E)
|
|
3301
|
+
}, null, 8, ["render", "props"])
|
|
3302
|
+
]),
|
|
3303
|
+
o("div", rs, H([
|
|
3304
|
+
...y.original.items.slice(0, 3).map((Ge) => Ge.sku.name),
|
|
3305
|
+
...y.original.items.length >= 3 ? [`and ${y.original.items.length - 3} more items`] : []
|
|
3306
|
+
].join(", ")), 1),
|
|
3307
|
+
o("div", ls, [
|
|
3308
|
+
$(d(ot), {
|
|
3309
|
+
render: (xe = (ue = (G = x.ref) == null ? void 0 : G.column) == null ? void 0 : ue.columnDef) == null ? void 0 : xe.cell,
|
|
3310
|
+
props: (ve = (ke = x.ref) == null ? void 0 : ke.getContext) == null ? void 0 : ve.call(ke)
|
|
3311
|
+
}, null, 8, ["render", "props"])
|
|
3312
|
+
])
|
|
3313
|
+
]),
|
|
3314
|
+
o("div", null, [
|
|
3315
|
+
$(d(ot), {
|
|
3316
|
+
render: (Ne = (We = (Ce = x.status) == null ? void 0 : Ce.column) == null ? void 0 : We.columnDef) == null ? void 0 : Ne.cell,
|
|
3317
|
+
props: (qe = (Te = x.status) == null ? void 0 : Te.getContext) == null ? void 0 : qe.call(Te)
|
|
3318
|
+
}, null, 8, ["render", "props"])
|
|
3319
|
+
])
|
|
3320
|
+
])
|
|
3321
|
+
];
|
|
3322
|
+
}),
|
|
3323
|
+
_: 2
|
|
3324
|
+
}, 1032, ["row", "onRowClick"])
|
|
3325
|
+
]),
|
|
3326
|
+
_: 1
|
|
3327
|
+
}, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
|
|
3328
|
+
], 2)
|
|
3329
|
+
]),
|
|
3330
|
+
_: 1
|
|
3331
|
+
}, 8, ["title", "actions"]),
|
|
3332
|
+
$(ts, {
|
|
3333
|
+
show: j.value,
|
|
3334
|
+
"onUpdate:show": f[2] || (f[2] = (y) => j.value = y),
|
|
3335
|
+
onSubmitted: d(r).fetchDrafts
|
|
3336
|
+
}, null, 8, ["show", "onSubmitted"]),
|
|
3337
|
+
(k(), ne(Dn, { to: "body" }, [
|
|
3338
|
+
$(Co, An(d(s), {
|
|
3339
|
+
show: d(b),
|
|
3340
|
+
"onUpdate:show": f[3] || (f[3] = (y) => kt(b) ? b.value = y : null),
|
|
3341
|
+
onSubmitted: f[4] || (f[4] = () => (b.value = !1, d(r).fetchDrafts())),
|
|
3342
|
+
onRefresh: f[5] || (f[5] = (y) => d(r).updateDraftRef(y))
|
|
3343
|
+
}), null, 16, ["show"])
|
|
3344
|
+
]))
|
|
3345
|
+
], 64);
|
|
3346
|
+
};
|
|
3347
|
+
}
|
|
3348
|
+
});
|
|
3349
|
+
export {
|
|
3350
|
+
Rs as default
|
|
3351
|
+
};
|