@feedmepos/mf-inventory-portal 0.0.23-dev.7 → 0.0.23-dev.9
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-MWE4uZN2.js → App-ByLgARNp.js} +37 -33
- package/dist/{ApprovalView-DTBGzcfq.js → ApprovalView-e85YmdZN.js} +4 -4
- package/dist/{BindingsDialog-BaK8KE5C.js → BindingsDialog-giBUD0IH.js} +2 -2
- package/dist/{BindingsPicker-C6YXPChW.js → BindingsPicker-CC4MmPbF.js} +2 -2
- package/dist/{BindingsTable-BO3FV22B.js → BindingsTable-WphZdzrA.js} +6 -6
- package/dist/ClosingDraftView-CQM1Sx45.js +755 -0
- package/dist/{ClosingTemplateView--hHcPJJj.js → ClosingTemplateView-1lzoDyet.js} +32 -31
- package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-C6setquX.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-Cv-vvzr5.js} +19 -19
- package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-IRl6BsoL.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BvkN-71q.js} +2 -2
- package/dist/{FmMultiselectDialog-jlCh7zDq.js → FmMultiselectDialog-DScMA6iG.js} +15 -15
- package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-TeysdWIy.js → FmUnitInput.vue_vue_type_script_setup_true_lang-DIFQcrc0.js} +2 -2
- package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-BAj6ln1k.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-t4pim_k9.js} +1 -1
- package/dist/{IngredientGroupView-BM07A4fB.js → IngredientGroupView-UegBM_JK.js} +12 -11
- package/dist/{IngredientsView-J9NM-pfU.js → IngredientsView-BfW-jZLM.js} +13 -12
- package/dist/{IntegrationView-DeR9JiDO.js → IntegrationView-FYNNzKia.js} +50 -50
- package/dist/{InventoryBindingForm-Bhk9dMsL.js → InventoryBindingForm-DsHv_IHG.js} +1 -1
- package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-yaHMbpFX.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-BURSXafS.js} +13 -13
- package/dist/{InventoryBindingSummary-BVujhHLB.js → InventoryBindingSummary-BLb4MRPZ.js} +1 -1
- package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-ClaOjAPR.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BG78-DHs.js} +1 -1
- package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-Dh9RYSdM.js → PremiumBadge.vue_vue_type_script_setup_true_lang-CqID5_7v.js} +2 -2
- package/dist/{PurchaseOrderPrintPreview-B7SKVm_d.js → PurchaseOrderPrintPreview-BBMU3teq.js} +1 -1
- package/dist/{ReceiveRequestView-CNaohBx7.js → ReceiveRequestView-vbANEzne.js} +19 -19
- package/dist/{RecipeView-B5POouqT.js → RecipeView-DW4DY0C0.js} +11 -10
- package/dist/{StockView-DxBkg4B1.js → StockView-C5btudss.js} +1356 -1457
- package/dist/{SupplierView-DSmE8k_W.js → SupplierView-B2aObtwK.js} +14 -13
- package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-_luCbCMS.js → TransferDetails.vue_vue_type_script_setup_true_lang-B2LOvVef.js} +18 -17
- package/dist/{TransferTemplateView-CE8FN02v.js → TransferTemplateView-BKumN_p6.js} +57 -56
- package/dist/{UnitView-LmhfuQ7G.js → UnitView-CHLucv9s.js} +81 -80
- package/dist/{WarehouseView-DNPfTpbR.js → WarehouseView-G8pej6Y2.js} +25 -24
- package/dist/api/closing-draft.d.ts +6 -0
- package/dist/api/closing.d.ts +1 -0
- package/dist/{app-CHUTVCqW.js → app-BXjk74IB.js} +2175 -2140
- package/dist/app.d.ts +3 -0
- package/dist/app.js +1 -1
- package/dist/components/row-action.enum.d.ts +1 -0
- package/dist/{date2-jflNp4un.js → date2-CWAt9bRf.js} +1 -1
- package/dist/{dayjs.min-Ura1hQS9.js → dayjs.min-D3jPOnu6.js} +17 -17
- package/dist/{decimal-MDopy-42.js → decimal-DC07xoJW.js} +1 -1
- package/dist/{defineDeepModel-DJJQtyLG.js → defineDeepModel-CiD4GtOw.js} +1 -1
- package/dist/{feature-1MCtECkH.js → feature-6tcLMotY.js} +1 -1
- package/dist/form-mode.enum-BKiNVH6A.js +4 -0
- package/dist/{format-time-from-id-C_Ql1G1m.js → format-time-from-id-CYU5Z9Mt.js} +1 -1
- package/dist/{format-unit-display-8CZtD9mX.js → format-unit-display-CY-0bznr.js} +83 -82
- package/dist/{fuzzy-BYzBSFQ9.js → fuzzy-BMkhNYLR.js} +1 -1
- package/dist/{index-BfpXXehq.js → index-BXwQa14X.js} +1 -1
- package/dist/{index-B17P8VA1.js → index-CRLd5xyg.js} +1 -1
- package/dist/{index-DacyZLBG.js → index-DqwAtOgI.js} +1 -1
- package/dist/{netsuite-N4WoiSJk.js → netsuite-fYUUk_ss.js} +1 -1
- package/dist/router/name.d.ts +1 -0
- package/dist/{row-action.enum-PMKMRrZR.js → row-action.enum-7rGLGZ5v.js} +10 -5
- package/dist/{rules-XXZyqauM.js → rules-BmRGm3yv.js} +39 -35
- package/dist/stock-CEX0DP2B.js +111 -0
- package/dist/stores/inventory.d.ts +1 -4
- package/dist/style.css +1 -1
- package/dist/{supplier-CTbtvSjM.js → supplier-CdJmZr7w.js} +22 -22
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/dist/{use-inventory-binding-dialog-Ri_zc-M3.js → use-inventory-binding-dialog-B0G2XYSw.js} +2 -2
- package/dist/{use-template-enabled-locations-2-BfvnBeUQ.js → use-template-enabled-locations-2-xbPJWHCs.js} +2 -2
- 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 +447 -0
- package/dist/views/closing-draft/composables/use-closing-draft-actions.d.ts +22 -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-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/{xlsx-BHa16rol.js → xlsx-CTOKp7SQ.js} +1 -1
- package/dist/{xlsx.util-CNw5O-OJ.js → xlsx.util-D5NFSfDg.js} +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,755 @@
|
|
|
1
|
+
import { defineComponent as te, ref as z, resolveComponent as R, openBlock as $, createBlock as H, withCtx as K, createElementVNode as s, createTextVNode as ie, toDisplayString as Y, unref as c, createVNode as y, h as ce, computed as x, onMounted as ke, watch as xe, isRef as pe, createCommentVNode as ue, normalizeClass as ve, createElementBlock as O, Fragment as ge, renderList as Se, normalizeStyle as ye, Teleport as Be, mergeProps as Fe } from "vue";
|
|
2
|
+
import { u as je, _ as $e, a as Re } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BvkN-71q.js";
|
|
3
|
+
import { useI18n as be } from "@feedmepos/mf-common";
|
|
4
|
+
import { useSnackbar as De, useDialog as Te, useProxiedModel as Pe, useBreakpoints as Me } from "@feedmepos/ui-library";
|
|
5
|
+
import { k as ze, u as ae, p as M, s as he, q as J, c as Ue, r as Ie, a as Ke } from "./app-BXjk74IB.js";
|
|
6
|
+
import { defineStore as _e, storeToRefs as Le } from "pinia";
|
|
7
|
+
import { R as Ne, a as P, l as Ee, m as Ve, b as de, c as me, i as Oe } from "./rules-BmRGm3yv.js";
|
|
8
|
+
import { D as ee, R as V } from "./row-action.enum-7rGLGZ5v.js";
|
|
9
|
+
import { c as He, _ as Ye, F as Z } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-DlNJ6kRg.js";
|
|
10
|
+
import { f as qe } from "./format-time-from-id-CYU5Z9Mt.js";
|
|
11
|
+
import { d as L } from "./date2-CWAt9bRf.js";
|
|
12
|
+
import { u as Ge } from "./stock-CEX0DP2B.js";
|
|
13
|
+
const Ae = ze((w, e) => {
|
|
14
|
+
function m() {
|
|
15
|
+
return ae().currentLocation.dbName;
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
async getDraft(d) {
|
|
19
|
+
const i = m(), f = `${w.inventoryBackendUrl}/${i}/closing-draft/${d}`;
|
|
20
|
+
return e.get(f);
|
|
21
|
+
},
|
|
22
|
+
async readDrafts() {
|
|
23
|
+
const d = m(), i = `${w.inventoryBackendUrl}/${d}/closing-draft`;
|
|
24
|
+
return e.get(i);
|
|
25
|
+
},
|
|
26
|
+
async runOperation(d) {
|
|
27
|
+
const i = m(), f = `${w.inventoryBackendUrl}/${i}/closing-draft/run-operation`;
|
|
28
|
+
return e.post(f, d);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}), We = { class: "fm-typo-en-body-lg-400" }, Ze = { class: "fm-typo-en-body-lg-600" }, Je = { class: "flex gap-12 py-8 justify-end w-full" }, fe = /* @__PURE__ */ te({
|
|
32
|
+
__name: "ClosingDraftAction",
|
|
33
|
+
props: {
|
|
34
|
+
draft: {},
|
|
35
|
+
action: {},
|
|
36
|
+
onCancel: { type: Function },
|
|
37
|
+
onFinished: { type: Function }
|
|
38
|
+
},
|
|
39
|
+
setup(w) {
|
|
40
|
+
const e = w, m = z(), d = Ae(), i = De(), f = z(!1);
|
|
41
|
+
async function g() {
|
|
42
|
+
f.value = !0;
|
|
43
|
+
try {
|
|
44
|
+
await d.runOperation({
|
|
45
|
+
_id: e.draft._id,
|
|
46
|
+
_rev: e.draft._rev ?? "",
|
|
47
|
+
action: e.action,
|
|
48
|
+
data: {
|
|
49
|
+
remark: m.value
|
|
50
|
+
}
|
|
51
|
+
}).delayed(500), i.open({
|
|
52
|
+
title: "Success",
|
|
53
|
+
message: "Action submitted",
|
|
54
|
+
type: "success"
|
|
55
|
+
}), e.onFinished();
|
|
56
|
+
} catch (h) {
|
|
57
|
+
i.open({
|
|
58
|
+
title: "Something went wrong",
|
|
59
|
+
message: "Unable to submit actino. Please try again",
|
|
60
|
+
type: "error"
|
|
61
|
+
}), console.error("error on submit closing draft aciont", h);
|
|
62
|
+
} finally {
|
|
63
|
+
f.value = !1;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return (h, u) => {
|
|
67
|
+
const v = R("FmTextField"), S = R("FmButton"), n = R("FmForm");
|
|
68
|
+
return $(), H(n, {
|
|
69
|
+
onValidationSuccess: g,
|
|
70
|
+
class: "flex flex-col gap-32",
|
|
71
|
+
disabled: f.value
|
|
72
|
+
}, {
|
|
73
|
+
default: K(() => [
|
|
74
|
+
s("div", We, [
|
|
75
|
+
u[2] || (u[2] = ie(" You are about to ")),
|
|
76
|
+
s("span", Ze, Y(h.action == c(M).enum.approveDraft ? "approve" : "reject"), 1),
|
|
77
|
+
u[3] || (u[3] = ie(" this draft. Please provider a remark to justify this action. "))
|
|
78
|
+
]),
|
|
79
|
+
y(v, {
|
|
80
|
+
modelValue: m.value,
|
|
81
|
+
"onUpdate:modelValue": u[0] || (u[0] = (l) => m.value = l),
|
|
82
|
+
label: "Remark",
|
|
83
|
+
"label-mark": "required",
|
|
84
|
+
rules: [c(Ne)()]
|
|
85
|
+
}, null, 8, ["modelValue", "rules"]),
|
|
86
|
+
s("div", Je, [
|
|
87
|
+
y(S, {
|
|
88
|
+
label: "Cancel",
|
|
89
|
+
variant: "tertiary",
|
|
90
|
+
onClick: u[1] || (u[1] = (l) => h.onCancel())
|
|
91
|
+
}),
|
|
92
|
+
y(S, {
|
|
93
|
+
label: h.action == c(M).enum.approveDraft ? "Approve" : "Reject",
|
|
94
|
+
type: "submit",
|
|
95
|
+
variant: h.action == c(M).enum.approveDraft ? "primary" : "destructive",
|
|
96
|
+
loading: f.value
|
|
97
|
+
}, null, 8, ["label", "variant", "loading"])
|
|
98
|
+
])
|
|
99
|
+
]),
|
|
100
|
+
_: 1
|
|
101
|
+
}, 8, ["disabled"]);
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}), Q = _e(
|
|
105
|
+
"closingDraftActions",
|
|
106
|
+
function() {
|
|
107
|
+
const e = Te(), m = z(!1), d = z();
|
|
108
|
+
function i(u) {
|
|
109
|
+
const v = {
|
|
110
|
+
draft: u
|
|
111
|
+
};
|
|
112
|
+
d.value = v, m.value = !0;
|
|
113
|
+
}
|
|
114
|
+
function f(u) {
|
|
115
|
+
}
|
|
116
|
+
function g(u, v) {
|
|
117
|
+
e.open({
|
|
118
|
+
title: "Approve draft",
|
|
119
|
+
contentComponent: fe,
|
|
120
|
+
contentComponentProps: {
|
|
121
|
+
draft: u,
|
|
122
|
+
action: M.enum.approveDraft,
|
|
123
|
+
onFinished: () => {
|
|
124
|
+
e.close(), v == null || v();
|
|
125
|
+
},
|
|
126
|
+
onCancel: () => e.close()
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
function h(u, v) {
|
|
131
|
+
e.open({
|
|
132
|
+
title: "Reject draft",
|
|
133
|
+
contentComponent: fe,
|
|
134
|
+
contentComponentProps: {
|
|
135
|
+
draft: u,
|
|
136
|
+
action: M.enum.rejectDraft,
|
|
137
|
+
onFinished: () => {
|
|
138
|
+
e.close(), v == null || v();
|
|
139
|
+
},
|
|
140
|
+
onCancel: () => e.close()
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
return {
|
|
145
|
+
viewDraft: i,
|
|
146
|
+
approveDraft: g,
|
|
147
|
+
rejectDraft: h,
|
|
148
|
+
exportDraft: f,
|
|
149
|
+
viewClosingDraftShow: m,
|
|
150
|
+
viewClosingDraftProps: d
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
function Ce(w) {
|
|
155
|
+
switch (w) {
|
|
156
|
+
case "DRAFT":
|
|
157
|
+
return "fm-status-badge-draft";
|
|
158
|
+
case "PROCESSING":
|
|
159
|
+
return "fm-status-badge-processing";
|
|
160
|
+
case "FAILED":
|
|
161
|
+
return "fm-status-badge-cancel";
|
|
162
|
+
case "COMPLETED":
|
|
163
|
+
return "fm-status-badge-complete";
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
const Qe = _e("closingTable", function() {
|
|
167
|
+
const { t: e } = be(), m = Q(), d = z(new Array()), i = z(!1), f = ae(), g = Ae();
|
|
168
|
+
async function h() {
|
|
169
|
+
if (d.value = [], !!f._currentLocation) {
|
|
170
|
+
i.value = !0;
|
|
171
|
+
try {
|
|
172
|
+
const [n] = await Promise.all([g.readDrafts()]).delayed(1e3);
|
|
173
|
+
d.value = n.reverse();
|
|
174
|
+
} catch (n) {
|
|
175
|
+
console.log("Something went wrong when fetching drafts:", n);
|
|
176
|
+
} finally {
|
|
177
|
+
i.value = !1;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
async function u(n) {
|
|
182
|
+
if (!d.value.find((l) => l._id) && f._currentLocation) {
|
|
183
|
+
i.value = !0;
|
|
184
|
+
try {
|
|
185
|
+
const [l] = await Promise.all([
|
|
186
|
+
g.getDraft(n),
|
|
187
|
+
new Promise((A) => setTimeout(A, 1e3))
|
|
188
|
+
]);
|
|
189
|
+
d.value = [l];
|
|
190
|
+
} catch (l) {
|
|
191
|
+
console.log("Something went wrong when fetching drafts:", l);
|
|
192
|
+
} finally {
|
|
193
|
+
i.value = !1;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
function v(n, l) {
|
|
198
|
+
switch (l = Ue(l), n) {
|
|
199
|
+
case V.Details:
|
|
200
|
+
return m.viewDraft(l);
|
|
201
|
+
case V.Export:
|
|
202
|
+
return m.exportDraft(l);
|
|
203
|
+
case M.enum.approveDraft:
|
|
204
|
+
return m.approveDraft(l);
|
|
205
|
+
case M.enum.rejectDraft:
|
|
206
|
+
return m.rejectDraft(l);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return {
|
|
210
|
+
columnDefs: [
|
|
211
|
+
{
|
|
212
|
+
id: "_id",
|
|
213
|
+
accessorKey: "_id",
|
|
214
|
+
header: () => e("inventory.closing.table.createdAt"),
|
|
215
|
+
cell(n) {
|
|
216
|
+
return qe(`${n.getValue()}`);
|
|
217
|
+
},
|
|
218
|
+
enableSorting: !0
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
id: "updatedAt",
|
|
222
|
+
accessorFn: (n) => L(n.updatedAt),
|
|
223
|
+
header: () => "Updated at",
|
|
224
|
+
enableSorting: !0,
|
|
225
|
+
size: 200
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
id: "updatedBy",
|
|
229
|
+
accessorKey: "updatedBy.name",
|
|
230
|
+
header: () => "Last update by",
|
|
231
|
+
enableSorting: !0,
|
|
232
|
+
size: 200
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
id: "noOfItems",
|
|
236
|
+
accessorKey: "items.length",
|
|
237
|
+
header: () => e("inventory.closing.table.noOfItems"),
|
|
238
|
+
enableSorting: !1,
|
|
239
|
+
meta: {
|
|
240
|
+
width: "10rem",
|
|
241
|
+
textAlign: "right"
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
id: "recentRemark",
|
|
246
|
+
accessorFn: (n) => {
|
|
247
|
+
var l;
|
|
248
|
+
return (n == null ? void 0 : n.approveRemark) ?? ((l = n == null ? void 0 : n.rejectionHistory) == null ? void 0 : l.computeFirst((A) => A.rejectRemark));
|
|
249
|
+
},
|
|
250
|
+
header: () => "Recent remark"
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
id: "status",
|
|
254
|
+
accessorFn: (n) => n.status,
|
|
255
|
+
header: () => e("inventory.closing.table.status"),
|
|
256
|
+
enableSorting: !1,
|
|
257
|
+
cell(n) {
|
|
258
|
+
const A = n.row.original.status;
|
|
259
|
+
return ce(
|
|
260
|
+
"div",
|
|
261
|
+
{
|
|
262
|
+
class: "flex"
|
|
263
|
+
},
|
|
264
|
+
ce(
|
|
265
|
+
"div",
|
|
266
|
+
{
|
|
267
|
+
class: ["fm-status-badge", Ce(A)]
|
|
268
|
+
},
|
|
269
|
+
he(A)
|
|
270
|
+
)
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
id: "action",
|
|
276
|
+
cell(n) {
|
|
277
|
+
const l = n.row.original, A = [
|
|
278
|
+
ee[V.Edit],
|
|
279
|
+
ee[V.Delete],
|
|
280
|
+
ee[V.Export]
|
|
281
|
+
], q = [
|
|
282
|
+
{
|
|
283
|
+
translationKey: "inventory.closing.draft.approveDraft",
|
|
284
|
+
color: "text-fm-color-typo-primary",
|
|
285
|
+
value: M.enum.approveDraft
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
translationKey: "inventory.closing.draft.rejectDraft",
|
|
289
|
+
color: "text-fm-color-typo-error",
|
|
290
|
+
value: M.enum.rejectDraft
|
|
291
|
+
}
|
|
292
|
+
];
|
|
293
|
+
return He(
|
|
294
|
+
[...A, ...l.status === J.enum.DRAFT ? q : []],
|
|
295
|
+
(N) => v(N, l)
|
|
296
|
+
);
|
|
297
|
+
},
|
|
298
|
+
enableSorting: !1,
|
|
299
|
+
size: 40,
|
|
300
|
+
meta: {
|
|
301
|
+
cellClass: "",
|
|
302
|
+
headerClass: ""
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
],
|
|
306
|
+
drafts: d,
|
|
307
|
+
loading: i,
|
|
308
|
+
fetchDrafts: h,
|
|
309
|
+
loadDraft: u
|
|
310
|
+
};
|
|
311
|
+
}), Xe = { class: "w-full flex flex-col gap-32" }, et = { class: "flex justify-between" }, tt = { class: "inline-flex rounded-md items-center gap-4 justify-center h-[22px] px-8 bg-fm-color-neutral-gray-100 fm-status-badge fm-status-badge-receiving" }, at = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, nt = { class: "flex gap-1" }, ot = { class: "fm-typo-en-body-lg-600" }, st = { class: "flex flex-col gap-16" }, rt = {
|
|
312
|
+
key: 0,
|
|
313
|
+
class: "w-full flex flex-col items-center"
|
|
314
|
+
}, lt = { class: "flex items-center gap-8" }, it = {
|
|
315
|
+
key: 1,
|
|
316
|
+
class: "overflow-x-auto"
|
|
317
|
+
}, ct = { class: "flex gap-8" }, ut = /* @__PURE__ */ te({
|
|
318
|
+
__name: "ClosingDraftDialog",
|
|
319
|
+
props: {
|
|
320
|
+
show: { type: Boolean },
|
|
321
|
+
draft: {}
|
|
322
|
+
},
|
|
323
|
+
setup(w) {
|
|
324
|
+
const e = w, m = Ge(), d = Q(), i = Pe(e, "show"), f = z(!1), g = z(new Array()), h = Ie(), u = De(), v = Ke(), S = x(() => {
|
|
325
|
+
var a;
|
|
326
|
+
const t = ((a = e.draft) == null ? void 0 : a.items.map((r) => r.sku)) ?? [];
|
|
327
|
+
return t.sort((r, o) => r.code.localeCompare(o.code)), t;
|
|
328
|
+
});
|
|
329
|
+
x(() => S.value.groupBy((t) => t._id)), ke(A), xe(
|
|
330
|
+
() => e.show,
|
|
331
|
+
(t) => {
|
|
332
|
+
t && A();
|
|
333
|
+
}
|
|
334
|
+
);
|
|
335
|
+
const n = me(0), l = me(100);
|
|
336
|
+
async function A() {
|
|
337
|
+
var a, r, o;
|
|
338
|
+
f.value = !0;
|
|
339
|
+
const t = ((a = e.draft) == null ? void 0 : a.status) === J.enum.COMPLETED;
|
|
340
|
+
try {
|
|
341
|
+
if (await v.init(), t) {
|
|
342
|
+
const b = e.draft.items.groupBy(
|
|
343
|
+
(T) => T.sku._id,
|
|
344
|
+
(T) => T.sku
|
|
345
|
+
), p = e.draft.closingId;
|
|
346
|
+
if (!p) {
|
|
347
|
+
u.open({
|
|
348
|
+
title: "Something went wrong",
|
|
349
|
+
message: "Closing draft is completed but closing document cannot be found.",
|
|
350
|
+
type: "error"
|
|
351
|
+
}), console.error("Closing draft is completed but closing document cannot be found.", {
|
|
352
|
+
draftId: (r = e.draft) == null ? void 0 : r._id
|
|
353
|
+
});
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
const _ = await h.getClosingById(p);
|
|
357
|
+
g.value = (_ == null ? void 0 : _.skus) ?? [];
|
|
358
|
+
} else {
|
|
359
|
+
await m.readStockBalance();
|
|
360
|
+
const b = (((o = m.stockBalance) == null ? void 0 : o.skus) ?? []).groupBy(
|
|
361
|
+
(p) => p.id,
|
|
362
|
+
(p) => p.balance
|
|
363
|
+
);
|
|
364
|
+
g.value = v.skus.map(
|
|
365
|
+
(p) => b[p._id] ?? n
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
} catch (b) {
|
|
369
|
+
u.open({
|
|
370
|
+
title: "Something went wrong",
|
|
371
|
+
message: "Something went wrong when fetching info. Please try again.",
|
|
372
|
+
type: "error"
|
|
373
|
+
}), console.error("error on fetch stock balances", b);
|
|
374
|
+
} finally {
|
|
375
|
+
f.value = !1;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
const q = x(
|
|
379
|
+
() => g.value.groupBy(
|
|
380
|
+
(t) => t.id,
|
|
381
|
+
(t) => t.balance
|
|
382
|
+
)
|
|
383
|
+
), N = x(() => {
|
|
384
|
+
var a;
|
|
385
|
+
return (((a = e.draft) == null ? void 0 : a.items) ?? []).groupBy((r) => r.sku._id);
|
|
386
|
+
}), I = x(() => {
|
|
387
|
+
const t = S.value.reduce((r, o) => Math.max(r, o.unit.measurements.length), 0);
|
|
388
|
+
return [
|
|
389
|
+
{
|
|
390
|
+
id: "code",
|
|
391
|
+
accessorKey: "code",
|
|
392
|
+
header: () => "Code",
|
|
393
|
+
size: 200
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
id: "name",
|
|
397
|
+
accessorKey: "name",
|
|
398
|
+
header: () => "Name",
|
|
399
|
+
size: 300
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
id: "baseUnit",
|
|
403
|
+
accessorKey: "baseUnit",
|
|
404
|
+
header: () => "Base unit",
|
|
405
|
+
size: 200
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
id: "baseUnitAmount",
|
|
409
|
+
accessorKey: "baseUnitAmount",
|
|
410
|
+
header: () => "Base unit amount",
|
|
411
|
+
size: 200
|
|
412
|
+
},
|
|
413
|
+
...Array.from({ length: t }).flatMap((r, o) => {
|
|
414
|
+
const b = `measurementAbbrev${o}`, p = `measurementAmount${o}`;
|
|
415
|
+
return [
|
|
416
|
+
{
|
|
417
|
+
id: p,
|
|
418
|
+
accessorKey: p,
|
|
419
|
+
header: () => `Sub unit amount ${o + 1}`,
|
|
420
|
+
size: 200
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
id: b,
|
|
424
|
+
accessorKey: b,
|
|
425
|
+
header: () => `Sub unit ${o + 1}`,
|
|
426
|
+
size: 200
|
|
427
|
+
}
|
|
428
|
+
];
|
|
429
|
+
}),
|
|
430
|
+
{
|
|
431
|
+
id: "systemBalance",
|
|
432
|
+
accessorKey: "systemBalance",
|
|
433
|
+
header: () => "System balance",
|
|
434
|
+
size: 200
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
id: "physicalBalance",
|
|
438
|
+
accessorKey: "physicalBalance",
|
|
439
|
+
header: () => "Physical balance",
|
|
440
|
+
size: 200
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
id: "adjustedBalance",
|
|
444
|
+
accessorKey: "adjustedBalance",
|
|
445
|
+
header: () => "Adjusted balance",
|
|
446
|
+
size: 200
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
id: "adjustedDiffPercentage",
|
|
450
|
+
accessorKey: "adjustedDiffPercentage",
|
|
451
|
+
header: () => "Diff (%)",
|
|
452
|
+
size: 200
|
|
453
|
+
}
|
|
454
|
+
];
|
|
455
|
+
}), j = x(() => I.value.map((t) => t.size ?? 0).reduce((t, a) => t + a));
|
|
456
|
+
function X(t) {
|
|
457
|
+
return t.sku.unit.measurements.reduce((a, r) => {
|
|
458
|
+
const o = de(a, r.conversion);
|
|
459
|
+
return Oe(a, o);
|
|
460
|
+
}, t.baseAmount);
|
|
461
|
+
}
|
|
462
|
+
const C = x(() => S.value.map((t) => {
|
|
463
|
+
var D, B;
|
|
464
|
+
const a = (D = N.value.get(t._id)) == null ? void 0 : D[0], r = ((B = q.value.get(t._id)) == null ? void 0 : B[0]) ?? n;
|
|
465
|
+
if (!a)
|
|
466
|
+
return {
|
|
467
|
+
code: t.code,
|
|
468
|
+
name: t.name,
|
|
469
|
+
baseUnit: t.unit.abbrev,
|
|
470
|
+
baseUnitAmount: 0,
|
|
471
|
+
systemBalance: +P(r),
|
|
472
|
+
physicalBalance: 0,
|
|
473
|
+
adjustedBalance: -+P(r),
|
|
474
|
+
adjustedDiffPercentage: -100
|
|
475
|
+
};
|
|
476
|
+
const o = X(a), b = Ee(o, r), p = r.amount === 0 ? null : Ve(b, r), _ = p ? de(p, l) : null;
|
|
477
|
+
return {
|
|
478
|
+
code: t.code,
|
|
479
|
+
name: t.name,
|
|
480
|
+
baseUnit: t.unit.abbrev,
|
|
481
|
+
baseUnitAmount: +P(a.baseAmount),
|
|
482
|
+
...a.measurementsAmounts.reduce((F, U, E) => (F[`measurementAbbrev${E}`] = `(${U.measurement.abbrev}) × ${P(U.measurement.conversion)}`, F[`measurementAmount${E}`] = +P(U.amount), F), {}),
|
|
483
|
+
systemBalance: +P(r),
|
|
484
|
+
physicalBalance: +P(o),
|
|
485
|
+
adjustedBalance: +P(b),
|
|
486
|
+
adjustedDiffPercentage: _ ? +P(_) : null
|
|
487
|
+
};
|
|
488
|
+
})), k = x(() => {
|
|
489
|
+
var a, r;
|
|
490
|
+
if (!e.draft) return [];
|
|
491
|
+
const t = e.draft.approvedAt ? {
|
|
492
|
+
action: `Approve at ${L(e.draft.approvedAt)}`,
|
|
493
|
+
// actionAt: props.draft.approvedAt,
|
|
494
|
+
actionBy: e.draft.approvedBy,
|
|
495
|
+
remark: e.draft.approveRemark
|
|
496
|
+
} : (a = e.draft.rejectionHistory) == null ? void 0 : a.computeFirst((o) => ({
|
|
497
|
+
action: `Reject at ${L(o.rejectedAt)}`,
|
|
498
|
+
// actionAt: e.rejectedAt,
|
|
499
|
+
actionBy: o.rejectedBy,
|
|
500
|
+
remark: o.rejectRemark
|
|
501
|
+
}));
|
|
502
|
+
return [
|
|
503
|
+
{
|
|
504
|
+
label: "Created at",
|
|
505
|
+
value: L(e.draft.createdAt)
|
|
506
|
+
},
|
|
507
|
+
{
|
|
508
|
+
label: "Created by",
|
|
509
|
+
value: e.draft.createdBy.name
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
label: "Updated at",
|
|
513
|
+
value: L(e.draft.updatedAt)
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
label: "Updated by",
|
|
517
|
+
value: e.draft.updatedBy.name
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
label: "Effective at",
|
|
521
|
+
value: L(e.draft.effectiveAt ?? e.draft.updatedAt)
|
|
522
|
+
},
|
|
523
|
+
t ? {
|
|
524
|
+
label: "Last action",
|
|
525
|
+
value: t.action
|
|
526
|
+
} : null,
|
|
527
|
+
t && t.actionBy ? {
|
|
528
|
+
label: "Last action by",
|
|
529
|
+
value: (r = t.actionBy) == null ? void 0 : r.name
|
|
530
|
+
} : null,
|
|
531
|
+
t && t.remark ? {
|
|
532
|
+
label: "Action remark",
|
|
533
|
+
value: t.remark
|
|
534
|
+
} : null
|
|
535
|
+
].filter((o) => o).map((o) => o);
|
|
536
|
+
});
|
|
537
|
+
return (t, a) => {
|
|
538
|
+
const r = R("FmMenuDivider"), o = R("FmCard"), b = R("FmCircularProgress"), p = R("FmTable"), _ = R("FmButton"), T = R("FmSideSheet");
|
|
539
|
+
return $(), H(T, {
|
|
540
|
+
"dismiss-away": "",
|
|
541
|
+
"max-width": 900,
|
|
542
|
+
"model-value": c(i),
|
|
543
|
+
"onUpdate:modelValue": a[3] || (a[3] = (D) => pe(i) ? i.value = D : null),
|
|
544
|
+
header: "Closing details"
|
|
545
|
+
}, {
|
|
546
|
+
"side-sheet-footer": K(() => {
|
|
547
|
+
var D, B;
|
|
548
|
+
return [
|
|
549
|
+
s("div", ct, [
|
|
550
|
+
((D = e.draft) == null ? void 0 : D.status) === c(J).enum.DRAFT ? ($(), H(_, {
|
|
551
|
+
key: 0,
|
|
552
|
+
label: "Approve",
|
|
553
|
+
onClick: a[0] || (a[0] = () => e.draft && c(d).approveDraft(e.draft))
|
|
554
|
+
})) : ue("", !0),
|
|
555
|
+
((B = e.draft) == null ? void 0 : B.status) === c(J).enum.DRAFT ? ($(), H(_, {
|
|
556
|
+
key: 1,
|
|
557
|
+
label: "Reject",
|
|
558
|
+
variant: "destructive",
|
|
559
|
+
onClick: a[1] || (a[1] = () => e.draft && c(d).rejectDraft(e.draft))
|
|
560
|
+
})) : ue("", !0),
|
|
561
|
+
y(_, {
|
|
562
|
+
label: "Close",
|
|
563
|
+
variant: "tertiary",
|
|
564
|
+
onClick: a[2] || (a[2] = (F) => i.value = !1)
|
|
565
|
+
})
|
|
566
|
+
])
|
|
567
|
+
];
|
|
568
|
+
}),
|
|
569
|
+
default: K(() => [
|
|
570
|
+
s("div", Xe, [
|
|
571
|
+
y(o, {
|
|
572
|
+
variant: "outlined",
|
|
573
|
+
class: "flex flex-col gap-8 px-12 py-16"
|
|
574
|
+
}, {
|
|
575
|
+
default: K(() => {
|
|
576
|
+
var D, B;
|
|
577
|
+
return [
|
|
578
|
+
s("div", et, [
|
|
579
|
+
a[4] || (a[4] = s("div", { class: "fm-typo-en-body-lg-600" }, "Closing summary", -1)),
|
|
580
|
+
s("div", null, [
|
|
581
|
+
s("div", tt, [
|
|
582
|
+
s("div", {
|
|
583
|
+
class: ve(c(Ce)(((D = t.draft) == null ? void 0 : D.status) ?? "DRAFT"))
|
|
584
|
+
}, Y(c(he)(((B = t.draft) == null ? void 0 : B.status) ?? "")), 3)
|
|
585
|
+
])
|
|
586
|
+
])
|
|
587
|
+
]),
|
|
588
|
+
y(r),
|
|
589
|
+
($(!0), O(ge, null, Se(k.value, (F, U) => ($(), O("div", {
|
|
590
|
+
class: "flex flex-col gap-4",
|
|
591
|
+
key: U
|
|
592
|
+
}, [
|
|
593
|
+
s("div", at, [
|
|
594
|
+
s("div", nt, Y(F.label), 1)
|
|
595
|
+
]),
|
|
596
|
+
s("div", ot, Y(F.value), 1)
|
|
597
|
+
]))), 128))
|
|
598
|
+
];
|
|
599
|
+
}),
|
|
600
|
+
_: 1
|
|
601
|
+
}),
|
|
602
|
+
s("div", st, [
|
|
603
|
+
a[8] || (a[8] = s("div", { class: "fm-typo-en-title-sm-600 text-fm-color-typo-primary" }, "Closing items", -1)),
|
|
604
|
+
f.value ? ($(), O("div", rt, [
|
|
605
|
+
a[6] || (a[6] = s("div", { class: "h-80" }, null, -1)),
|
|
606
|
+
s("div", lt, [
|
|
607
|
+
s("div", null, [
|
|
608
|
+
y(b, { size: "md" })
|
|
609
|
+
]),
|
|
610
|
+
a[5] || (a[5] = s("div", { class: "fm-typo-en-body-lg-600 text-fm-color-typo-secondary" }, " Fetching info... ", -1))
|
|
611
|
+
]),
|
|
612
|
+
a[7] || (a[7] = s("div", { class: "h-80" }, null, -1))
|
|
613
|
+
])) : ($(), O("div", it, [
|
|
614
|
+
s("div", {
|
|
615
|
+
style: ye({ width: `${j.value}px` })
|
|
616
|
+
}, [
|
|
617
|
+
y(p, {
|
|
618
|
+
"column-defs": I.value,
|
|
619
|
+
"row-data": C.value
|
|
620
|
+
}, null, 8, ["column-defs", "row-data"])
|
|
621
|
+
], 4)
|
|
622
|
+
]))
|
|
623
|
+
])
|
|
624
|
+
])
|
|
625
|
+
]),
|
|
626
|
+
_: 1
|
|
627
|
+
}, 8, ["model-value"]);
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
}), dt = { class: "flex-1 flex flex-col gap-8" }, mt = { class: "flex flex-col" }, ft = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, pt = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, vt = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-2" }, gt = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, Ft = /* @__PURE__ */ te({
|
|
631
|
+
__name: "ClosingDraftView",
|
|
632
|
+
setup(w) {
|
|
633
|
+
const { t: e } = be(), { viewDraft: m } = Q(), { viewClosingDraftProps: d, viewClosingDraftShow: i } = Le(Q()), f = ae(), g = Qe(), h = je(), { breakpoints: u } = Me();
|
|
634
|
+
f.watchLocation(g.fetchDrafts);
|
|
635
|
+
const v = x(() => g.loading), S = z(""), n = x(() => u.value.xs || u.value.sm), l = x(() => n.value ? 10 : 20);
|
|
636
|
+
function A(I) {
|
|
637
|
+
switch (I) {
|
|
638
|
+
case "refresh":
|
|
639
|
+
return g.fetchDrafts();
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
function q(I) {
|
|
643
|
+
return I;
|
|
644
|
+
}
|
|
645
|
+
const N = x(() => n.value ? [
|
|
646
|
+
{
|
|
647
|
+
label: "Refresh",
|
|
648
|
+
value: "refresh",
|
|
649
|
+
isPrimary: !1
|
|
650
|
+
}
|
|
651
|
+
] : [
|
|
652
|
+
{
|
|
653
|
+
label: "Refresh",
|
|
654
|
+
value: "refresh",
|
|
655
|
+
isPrimary: !1
|
|
656
|
+
}
|
|
657
|
+
]);
|
|
658
|
+
return (I, j) => {
|
|
659
|
+
const X = R("FmTable");
|
|
660
|
+
return $(), O(ge, null, [
|
|
661
|
+
y($e, {
|
|
662
|
+
title: c(e)("inventory.closing.draft.title"),
|
|
663
|
+
actions: N.value,
|
|
664
|
+
"onClick:action": A
|
|
665
|
+
}, {
|
|
666
|
+
default: K(() => [
|
|
667
|
+
s("div", {
|
|
668
|
+
class: ve([
|
|
669
|
+
"flex flex-col gap-8 max-h-full",
|
|
670
|
+
{
|
|
671
|
+
"p-0": n.value,
|
|
672
|
+
"px-24 ": !n.value
|
|
673
|
+
}
|
|
674
|
+
])
|
|
675
|
+
}, [
|
|
676
|
+
y(Re, {
|
|
677
|
+
"change-location": "",
|
|
678
|
+
searchable: "",
|
|
679
|
+
search: S.value,
|
|
680
|
+
"onUpdate:search": j[0] || (j[0] = (C) => S.value = C)
|
|
681
|
+
}, null, 8, ["search"]),
|
|
682
|
+
y(X, {
|
|
683
|
+
style: ye(c(h).tableHeight),
|
|
684
|
+
"column-defs": c(g).columnDefs,
|
|
685
|
+
"row-data": c(g).drafts,
|
|
686
|
+
"search-value": S.value,
|
|
687
|
+
loading: v.value,
|
|
688
|
+
onRowClick: j[1] || (j[1] = (C) => c(m)(C.original)),
|
|
689
|
+
"page-size": l.value
|
|
690
|
+
}, {
|
|
691
|
+
"list-row": K((C) => [
|
|
692
|
+
y(Ye, {
|
|
693
|
+
row: C,
|
|
694
|
+
onRowClick: (k) => c(m)(k)
|
|
695
|
+
}, {
|
|
696
|
+
default: K((k) => {
|
|
697
|
+
var t, a, r, o, b, p, _, T, D, B, F, U, E, G, ne, oe, se, re, W, le;
|
|
698
|
+
return [
|
|
699
|
+
s("div", dt, [
|
|
700
|
+
s("div", mt, [
|
|
701
|
+
s("div", ft, [
|
|
702
|
+
y(c(Z), {
|
|
703
|
+
render: (r = (a = (t = k._id) == null ? void 0 : t.column) == null ? void 0 : a.columnDef) == null ? void 0 : r.cell,
|
|
704
|
+
props: (b = (o = k._id) == null ? void 0 : o.getContext) == null ? void 0 : b.call(o)
|
|
705
|
+
}, null, 8, ["render", "props"])
|
|
706
|
+
]),
|
|
707
|
+
s("div", pt, [
|
|
708
|
+
y(c(Z), {
|
|
709
|
+
render: (T = (_ = (p = k.name) == null ? void 0 : p.column) == null ? void 0 : _.columnDef) == null ? void 0 : T.cell,
|
|
710
|
+
props: (B = (D = k.name) == null ? void 0 : D.getContext) == null ? void 0 : B.call(D)
|
|
711
|
+
}, null, 8, ["render", "props"])
|
|
712
|
+
]),
|
|
713
|
+
s("div", vt, Y([
|
|
714
|
+
...C.original.items.slice(0, 3).map((we) => we.sku.name),
|
|
715
|
+
...C.original.items.length >= 3 ? [`and ${C.original.items.length - 3} more items`] : []
|
|
716
|
+
].join(", ")), 1),
|
|
717
|
+
s("div", gt, [
|
|
718
|
+
y(c(Z), {
|
|
719
|
+
render: (E = (U = (F = k.ref) == null ? void 0 : F.column) == null ? void 0 : U.columnDef) == null ? void 0 : E.cell,
|
|
720
|
+
props: (ne = (G = k.ref) == null ? void 0 : G.getContext) == null ? void 0 : ne.call(G)
|
|
721
|
+
}, null, 8, ["render", "props"])
|
|
722
|
+
])
|
|
723
|
+
]),
|
|
724
|
+
s("div", null, [
|
|
725
|
+
y(c(Z), {
|
|
726
|
+
render: (re = (se = (oe = k.status) == null ? void 0 : oe.column) == null ? void 0 : se.columnDef) == null ? void 0 : re.cell,
|
|
727
|
+
props: (le = (W = k.status) == null ? void 0 : W.getContext) == null ? void 0 : le.call(W)
|
|
728
|
+
}, null, 8, ["render", "props"])
|
|
729
|
+
])
|
|
730
|
+
])
|
|
731
|
+
];
|
|
732
|
+
}),
|
|
733
|
+
_: 2
|
|
734
|
+
}, 1032, ["row", "onRowClick"])
|
|
735
|
+
]),
|
|
736
|
+
_: 1
|
|
737
|
+
}, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"])
|
|
738
|
+
], 2)
|
|
739
|
+
]),
|
|
740
|
+
_: 1
|
|
741
|
+
}, 8, ["title", "actions"]),
|
|
742
|
+
($(), H(Be, { to: "body" }, [
|
|
743
|
+
y(ut, Fe(c(d), {
|
|
744
|
+
show: c(i),
|
|
745
|
+
"onUpdate:show": j[2] || (j[2] = (C) => pe(i) ? i.value = C : null),
|
|
746
|
+
onSubmitted: j[3] || (j[3] = (C) => c(g).fetchDrafts())
|
|
747
|
+
}), null, 16, ["show"])
|
|
748
|
+
]))
|
|
749
|
+
], 64);
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
});
|
|
753
|
+
export {
|
|
754
|
+
Ft as default
|
|
755
|
+
};
|