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