@feedmepos/mf-inventory-portal 1.7.1 → 1.7.2-dev.1
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-B0lFktSW.js → App-CPiZvK24.js} +4 -4
- package/dist/{ApprovalView-Ka7ehCQd.js → ApprovalView-j2I6kj-5.js} +8 -8
- package/dist/{BindingsDialog-B_YgAtlu.js → BindingsDialog-C1MnTVRl.js} +2 -2
- package/dist/{BindingsPicker-CtCjgzt7.js → BindingsPicker-CpFT0xnq.js} +2 -2
- package/dist/{BindingsTable-BNPP0R_A.js → BindingsTable-CFDJOUOJ.js} +3 -3
- package/dist/{BulkReceiveRequestView-B0bj9Syr.js → BulkReceiveRequestView-LgTAo-XE.js} +19 -19
- package/dist/{ChangeLocationComponent.vue_vue_type_script_setup_true_lang-CiGVQ_6T.js → ChangeLocationComponent.vue_vue_type_script_setup_true_lang-CiUxzxG1.js} +1 -1
- package/dist/ClosingDraftView-CjSrjCXS.js +4496 -0
- package/dist/{ClosingHistoryView-BS3DFkAz.js → ClosingHistoryView-BcV1olc-.js} +5 -5
- package/dist/{ClosingTemplateView-B8njPb4E.js → ClosingTemplateView-B6664Bln.js} +16 -16
- package/dist/{DefaultView-BLv5wqcv.js → DefaultView-k_cX_Rgq.js} +2 -2
- package/dist/{DeliveryOrderPrintPreview-CnuwXphl.js → DeliveryOrderPrintPreview-Cndz9b3u.js} +2 -2
- package/dist/{EmailDialog.vue_vue_type_script_setup_true_lang-9lUR6kHg.js → EmailDialog.vue_vue_type_script_setup_true_lang-iQkhFqNy.js} +2262 -2262
- package/dist/{FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-fC_rbTfa.js → FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-DYkSnV3W.js} +1 -1
- package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DvX5xI9b.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CaC6H0vH.js} +2 -2
- package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-hFKGb0Aa.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DHGRyJJ2.js} +2 -2
- package/dist/{FmMultiselectDialog-QrLJQhIf.js → FmMultiselectDialog-CqSQTy19.js} +2 -2
- package/dist/{FmMultiselectDialog-D231CKWQ.js → FmMultiselectDialog-DcbsQv6c.js} +1 -1
- package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-C6RH3VSF.js → FmUnitInput.vue_vue_type_script_setup_true_lang-Bw3hWPX4.js} +5 -5
- package/dist/{ImportView-DwLmW0jr.js → ImportView-BEmVVjdx.js} +6 -6
- package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-LrPxsgOW.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-DVcaNiLi.js} +1 -1
- package/dist/{IngredientGroupView-D4SUVGTu.js → IngredientGroupView-Bcprjpgu.js} +5 -5
- package/dist/{IngredientsView-CUUYlGfs.js → IngredientsView-DUDgGzz8.js} +15 -15
- package/dist/{IntegrationExplorerView-C2xZMSEm.js → IntegrationExplorerView-D5RBT4zR.js} +4 -4
- package/dist/{IntegrationView-4J5SmJPp.js → IntegrationView-AXBRZnWR.js} +2680 -2531
- package/dist/{InventoryBindingForm-B7YadUXu.js → InventoryBindingForm-DRjr8bvd.js} +1 -1
- package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-B3lKJcut.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-B-2yPbAm.js} +5 -5
- package/dist/{InventoryBindingSummary-Cw8ppkq9.js → InventoryBindingSummary-BHUNtJey.js} +1 -1
- package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CvXdUIPp.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BeCnzNZk.js} +1 -1
- package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-C7Gol-ne.js → PremiumBadge.vue_vue_type_script_setup_true_lang-D7bm57E7.js} +1 -1
- package/dist/{ProductionView-D7_RHbkz.js → ProductionView-B3SBsS5h.js} +7 -7
- package/dist/{PublishView-CXalRknq.js → PublishView-BpjI7rmM.js} +3 -3
- package/dist/{PurchaseOrderPrintPreview-CRrYe6dD.js → PurchaseOrderPrintPreview-C8M6Yax5.js} +2 -2
- package/dist/{ReceiveRequestView-CR2_mNj2.js → ReceiveRequestView-BlBrbNoW.js} +13 -13
- package/dist/{RecipeView-Yzx4gY33.js → RecipeView-BdBjxgQF.js} +17 -17
- package/dist/{SettingsView-Dfih5z0X.js → SettingsView-D5h0Kjma.js} +4 -4
- package/dist/{StockView-B-OIr9-B.js → StockView-6niOF2HE.js} +21 -21
- package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-B2vo0BFA.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-95yKD8E_.js} +1 -1
- package/dist/{SupplierView-CKCPRXZV.js → SupplierView-BOfucFHD.js} +12 -12
- package/dist/{SurchargeView-Da7YbT5A.js → SurchargeView-B4NOWDNm.js} +6 -6
- package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-Btecdwc5.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-B-T5hfVU.js} +2 -2
- package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-DgDzjf87.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-BS0WQ2q-.js} +1 -1
- package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-BMFNKKmV.js +4660 -0
- package/dist/{TransferTemplateView-C3Nx1W5t.js → TransferTemplateView-CKytDs9X.js} +20 -20
- package/dist/{UnitCostHistoryView-DYHBMjfW.js → UnitCostHistoryView-Pk7ErOkB.js} +4 -4
- package/dist/{UnitDisplayControl.vue_vue_type_script_setup_true_lang-BmLZ-7TM.js → UnitDisplayControl.vue_vue_type_script_setup_true_lang-D0vgeUur.js} +4 -4
- package/dist/{UnitView-Ccwmj-B0.js → UnitView-CR8xb5TS.js} +7 -7
- package/dist/{WarehouseView-DiXvpGkL.js → WarehouseView-DxCFvRDK.js} +5 -5
- package/dist/{WastageTemplateView-CAbu77vo.js → WastageTemplateView-ZOcx-Sw1.js} +14 -14
- package/dist/api/closing-draft.d.ts +5 -1
- package/dist/api/codemax.d.ts +22 -0
- package/dist/{app-BWvf7Pbw.js → app-UXaVUOFj.js} +1330 -1277
- package/dist/app.d.ts +24 -0
- package/dist/app.js +1 -1
- package/dist/{closing-template-hsPMmSJP.js → closing-template-BL_7K26j.js} +1 -1
- package/dist/{date2-BJfdfeJO.js → date2-DWsaERsg.js} +1 -1
- package/dist/{dayjs.min-DadksG29.js → dayjs.min-D9-6o_pb.js} +1 -1
- package/dist/{decimal-C9idbIOo.js → decimal-D9akmsuY.js} +2 -2
- package/dist/{defineDeepModel-CH4cTogB.js → defineDeepModel-CRz54q7h.js} +1 -1
- package/dist/{duplicate-template-BMd6tF6Y.js → duplicate-template-CXCfl2NH.js} +1 -1
- package/dist/{feature-Bt9vQSu_.js → feature-4PKcZSe0.js} +2 -2
- package/dist/{format-time-from-id-B6Oxxcmv.js → format-time-from-id-DoWSyd1w.js} +1 -1
- package/dist/{format-unit-display-B32MF8YP.js → format-unit-display-BXx5PrhU.js} +12 -12
- package/dist/{import-export.helper-BWex8GSP.js → import-export.helper-C-njSW-F.js} +6 -6
- package/dist/index-DYf5BKra.js +267 -0
- package/dist/{index-G8zX1OUg.js → index-D__km1gW.js} +1 -1
- package/dist/{index-BrmQVR18.js → index-xatqRsUm.js} +1 -1
- package/dist/{inventory-core-dart.default-DMYZxr7z.js → inventory-core-dart.default-CG-4fho4.js} +1 -1
- package/dist/{jszip.min-BiUtLGgB.js → jszip.min-CuKGTB3Q.js} +129 -129
- package/dist/{lz-string-CVwhv8uD.js → lz-string-Di2ld6md.js} +1 -1
- package/dist/{netsuite-jqgyyem9.js → netsuite-B_qujeBG.js} +2 -2
- package/dist/{number-4scgLaMY.js → number-BaHim51P.js} +3 -3
- package/dist/{predefined-templates-CK5XSRe_.js → predefined-templates-BSLRBeB0.js} +1 -1
- package/dist/{purchase-order-template-D4JHGs3l.js → purchase-order-template-QNfXyt-d.js} +1 -1
- package/dist/{recalculationUtils-B9BLpNFc.js → recalculationUtils-B3CX9rQC.js} +1 -1
- package/dist/{rules-CEKN0fON.js → rules-DYMYmtzv.js} +2 -2
- package/dist/{stock-DEDIyrA9.js → stock-5uSaJQTg.js} +1 -1
- package/dist/{stock-BSIJKbLk.js → stock-C1jT8ufE.js} +3 -3
- package/dist/stores/integration/codemax.d.ts +0 -7
- package/dist/{supplier-CnEm0FdT.js → supplier-BoX9Fh0G.js} +2 -2
- package/dist/{surcharge-BTe4mWtB.js → surcharge-FJVEiOpa.js} +1 -1
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/dist/{uom-rules-C1nV-lQn.js → uom-rules-BHrAwdAH.js} +1 -1
- package/dist/{use-ingredient-select-dialog-COiU0eIQ.js → use-ingredient-select-dialog-mGOA_61r.js} +2 -2
- package/dist/{use-inventory-binding-dialog-Dhpo1L4-.js → use-inventory-binding-dialog-BSN0xrPb.js} +2 -2
- package/dist/{use-template-enabled-locations-BZN5nUrH.js → use-template-enabled-locations-Dy-dcIiU.js} +2 -2
- package/dist/{use-transfer-locations-DDtX2nBf.js → use-transfer-locations-Da0XeXxv.js} +2 -2
- package/dist/{useHrmPermission-EZ3pfyTj.js → useHrmPermission-Bp7HhhKY.js} +1 -1
- package/dist/{useNavigationMenu-CIGwi2pS.js → useNavigationMenu-DGixRVd0.js} +2 -2
- package/dist/{useSseClient-Ccmg1XUC.js → useSseClient-C5GrB7_M.js} +1 -1
- package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftApprovalDialog.vue.d.ts +6 -2
- package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftDialog.vue.d.ts +4 -4
- package/dist/views/closing-draft/components/closing-draft-groups/ClosingGroupAction.vue.d.ts +2 -2
- package/dist/views/closing-draft/components/closing-draft-groups/ClosingGroupDetailSideSheet.vue.d.ts +2 -2
- package/dist/views/closing-draft/composables/use-closing-draft-actions.d.ts +6 -6
- package/dist/views/closing-draft/composables/use-closing-draft-import.d.ts +1 -1
- package/dist/views/closing-draft/composables/use-closing-draft-table.d.ts +12 -12
- package/dist/views/integration/components/ApplyProductDialogCodemax.vue.d.ts +0 -14
- package/dist/views/integration/components/CodemaxDialog.vue.d.ts +0 -14
- package/dist/views/integration/components/CodemaxSyncStatusDialog.vue.d.ts +19 -0
- package/dist/{vue-i18n-XR3XXGIN.js → vue-i18n-DvlJg9yn.js} +299 -299
- package/dist/{xlsx.util-Cit0fL6n.js → xlsx.util-BF_fV-5o.js} +2 -2
- package/package.json +5 -5
- package/dist/ClosingDraftView-QJKj8C9l.js +0 -4398
- package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-DuKUOvt4.js +0 -4682
- package/dist/index-BgS2MztF.js +0 -257
- package/dist/views/receive-request/helper/resolve-po-item-cost.d.ts +0 -12
- /package/dist/views/{receive-request/helper/resolve-po-item-cost.spec.d.ts → closing-draft/components/closing-draft-dialog/ClosingDraftApprovalDialog.spec.d.ts} +0 -0
|
@@ -0,0 +1,4496 @@
|
|
|
1
|
+
import { defineComponent as Se, ref as q, computed as S, onMounted as ro, resolveComponent as ee, createElementBlock as C, createBlock as ne, openBlock as f, Fragment as ie, createTextVNode as ge, withCtx as te, createElementVNode as a, createCommentVNode as W, createVNode as D, toDisplayString as E, unref as d, h, watch as Te, renderList as _e, onUnmounted as Go, withModifiers as zo, normalizeStyle as gt, normalizeClass as we, isRef as bt, reactive as no, createSlots as Oo, Teleport as Ho, mergeProps as Yo } from "vue";
|
|
2
|
+
import { u as Wo, _ as Ko } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-DwrLsWX_.js";
|
|
3
|
+
import { useCoreStore as lo, useI18n as ot } from "@feedmepos/mf-common";
|
|
4
|
+
import { useSnackbar as Ue, useDialog as io, components as be, useProxiedModel as Tt, useBreakpoints as qo } from "@feedmepos/ui-library";
|
|
5
|
+
import { m as Qo, u as Qe, M as fe, w as se, q as co, s as Ie, O as xe, B as Le, c as Jo, a as jt, j as Zo } from "./app-UXaVUOFj.js";
|
|
6
|
+
import { defineStore as uo, storeToRefs as Xo } from "pinia";
|
|
7
|
+
import { b as qe, e as mo, f as en, a as Fe } from "./date2-DWsaERsg.js";
|
|
8
|
+
import { R as po } from "./rules-DYMYmtzv.js";
|
|
9
|
+
import { e as ht, c as et, j as tt, l as fo, m as vo, a as tn, k as go, o as me, t as on } from "./number-BaHim51P.js";
|
|
10
|
+
import { b as nn, d as an, u as vt, w as sn, c as rn } from "./xlsx.util-BF_fV-5o.js";
|
|
11
|
+
import { i as Rt, u as Mt } from "./uom-rules-BHrAwdAH.js";
|
|
12
|
+
import { u as ln } from "./stock-C1jT8ufE.js";
|
|
13
|
+
import { u as _t } from "./stock-5uSaJQTg.js";
|
|
14
|
+
import { D as ao, R as Ye } from "./row-action.enum-DQ9bJ_uv.js";
|
|
15
|
+
import { c as cn } from "./component-kqxARxvM.js";
|
|
16
|
+
import { f as un } from "./format-time-from-id-DoWSyd1w.js";
|
|
17
|
+
import { i as dn } from "./FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-DYkSnV3W.js";
|
|
18
|
+
import { f as mn } from "./recalculationUtils-B3CX9rQC.js";
|
|
19
|
+
import { _ as pn } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DHGRyJJ2.js";
|
|
20
|
+
import { _ as fn } from "./CursorPaginatedTable.vue_vue_type_script_setup_true_lang-4KT9rH9e.js";
|
|
21
|
+
import { _ as yo } from "./empty-placeholder-B0QU467o.js";
|
|
22
|
+
import { F as Ft } from "./FmAdminBadge-DlplQOHb.js";
|
|
23
|
+
import { u as vn } from "./vue-i18n-DvlJg9yn.js";
|
|
24
|
+
import { F as gn } from "./decimal-D9akmsuY.js";
|
|
25
|
+
import { u as yn } from "./useSseClient-C5GrB7_M.js";
|
|
26
|
+
import { d as bn } from "./dayjs.min-D9-6o_pb.js";
|
|
27
|
+
import { F as hn } from "./FmDroppableField-J0tG_U3w.js";
|
|
28
|
+
import { _ as _n } from "./FmConfirmationButton.vue_vue_type_script_setup_true_lang-Vg8U7WMZ.js";
|
|
29
|
+
import { _ as kn, F as Ze } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-DAMpuZ1X.js";
|
|
30
|
+
const Ge = Qo((t, o) => {
|
|
31
|
+
function e() {
|
|
32
|
+
return Qe().currentLocation.dbName;
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
getDbName: e,
|
|
36
|
+
async getDraft(n) {
|
|
37
|
+
const i = e(), r = `${t.inventoryBackendUrl}/${i}/closing-draft/${n}`;
|
|
38
|
+
return o.get(r);
|
|
39
|
+
},
|
|
40
|
+
/** Combined trimmed payload for the detail dialog: draft + groups +
|
|
41
|
+
* closing adjustment balances in one request. */
|
|
42
|
+
async getDraftDetail(n, i) {
|
|
43
|
+
const r = e(), s = `${t.inventoryBackendUrl}/${r}/closing-draft/${n}/detail`;
|
|
44
|
+
return o.get(s, i);
|
|
45
|
+
},
|
|
46
|
+
async readDrafts() {
|
|
47
|
+
const n = e(), i = `${t.inventoryBackendUrl}/${n}/closing-draft`;
|
|
48
|
+
return o.get(i);
|
|
49
|
+
},
|
|
50
|
+
/** Single page of the trimmed listing endpoint (cursor-based).
|
|
51
|
+
* `from`/`to` window by created date (backend caps span at 6 months). */
|
|
52
|
+
async listDraftsPage(n) {
|
|
53
|
+
const i = e(), r = `${t.inventoryBackendUrl}/${i}/closing-draft/list`;
|
|
54
|
+
return o.post(r, n);
|
|
55
|
+
},
|
|
56
|
+
async runOperation(n) {
|
|
57
|
+
const i = e(), r = `${t.inventoryBackendUrl}/${i}/closing-draft/run-operation`;
|
|
58
|
+
return o.post(r, n);
|
|
59
|
+
},
|
|
60
|
+
async runOperationV1(n) {
|
|
61
|
+
const i = e(), r = `${t.inventoryBackendUrl}/${i}/closing-draft/v1/run-operation`;
|
|
62
|
+
return o.post(r, n);
|
|
63
|
+
},
|
|
64
|
+
async sync(n) {
|
|
65
|
+
const i = e(), r = `${t.inventoryBackendUrl}/${i}/closing-draft/sync`;
|
|
66
|
+
return o.post(r, n);
|
|
67
|
+
},
|
|
68
|
+
async cloneDraft(n) {
|
|
69
|
+
const i = e(), r = `${t.inventoryBackendUrl}/${i}/closing-draft/${n}/clone`;
|
|
70
|
+
return o.post(r, {});
|
|
71
|
+
},
|
|
72
|
+
/** Closing groups belonging to a parent closing draft. */
|
|
73
|
+
async getClosingGroups(n) {
|
|
74
|
+
const i = e(), r = `${t.inventoryBackendUrl}/${i}/closing-draft/${n}/groups`;
|
|
75
|
+
return o.get(r);
|
|
76
|
+
},
|
|
77
|
+
/** Approve a closing group (sub-closing): status -> COMPLETED, no recalculation. */
|
|
78
|
+
async approveClosingGroup(n, i) {
|
|
79
|
+
const r = e(), s = `${t.inventoryBackendUrl}/${r}/closing-draft/${n}/group/approve`;
|
|
80
|
+
return o.post(s, { remark: i });
|
|
81
|
+
},
|
|
82
|
+
/** Submit a closing group (sub-closing) for approval: DRAFT -> PENDING_APPROVAL. */
|
|
83
|
+
async submitClosingGroup(n, i) {
|
|
84
|
+
const r = e(), s = `${t.inventoryBackendUrl}/${r}/closing-draft/${n}/group/submit`;
|
|
85
|
+
return o.post(s, { remark: i });
|
|
86
|
+
},
|
|
87
|
+
/** Reject a closing group (sub-closing): records a rejection note, resets to DRAFT. */
|
|
88
|
+
async rejectClosingGroup(n, i) {
|
|
89
|
+
const r = e(), s = `${t.inventoryBackendUrl}/${r}/closing-draft/${n}/group/reject`;
|
|
90
|
+
return o.post(s, { remark: i });
|
|
91
|
+
},
|
|
92
|
+
/** Approve all pending closing groups for a parent draft at once (master-approver override). */
|
|
93
|
+
async approveAllClosingGroups(n, i) {
|
|
94
|
+
const r = e(), s = `${t.inventoryBackendUrl}/${r}/closing-draft/${n}/groups/approve-all`;
|
|
95
|
+
return o.post(s, { remark: i });
|
|
96
|
+
},
|
|
97
|
+
async createQuickModeDraftWithItems(n) {
|
|
98
|
+
const i = e(), r = `${t.inventoryBackendUrl}/${i}/closing-draft/quick-mode/new-with-items`;
|
|
99
|
+
return o.post(r, n);
|
|
100
|
+
},
|
|
101
|
+
initializeStockSnapshot(n, i) {
|
|
102
|
+
const r = e(), s = `${t.inventoryBackendUrl}/${r}/closing-draft/${encodeURIComponent(n)}/initialize-stock-snapshot`;
|
|
103
|
+
return o.post(s, { effectiveAt: i });
|
|
104
|
+
},
|
|
105
|
+
async getRefreshBalanceStatus(n, i) {
|
|
106
|
+
const r = e(), s = `${t.inventoryBackendUrl}/${r}/closing-draft/${n}/refresh-balance/status?closingDraftRevision=${encodeURIComponent(i)}`;
|
|
107
|
+
return o.get(s);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
}), xn = { class: "fm-typo-en-body-lg-400" }, wn = { class: "fm-typo-en-body-lg-600" }, Dn = {
|
|
111
|
+
key: 0,
|
|
112
|
+
class: "flex flex-col"
|
|
113
|
+
}, An = {
|
|
114
|
+
key: 0,
|
|
115
|
+
class: "fm-typo-en-body-sm-400 text-fm-color-typo-error mt-4"
|
|
116
|
+
}, $n = { class: "flex gap-12 py-8 justify-end w-full" }, It = /* @__PURE__ */ Se({
|
|
117
|
+
__name: "ClosingDraftAction",
|
|
118
|
+
props: {
|
|
119
|
+
draft: {},
|
|
120
|
+
action: {},
|
|
121
|
+
onCancel: { type: Function },
|
|
122
|
+
onFinished: { type: Function }
|
|
123
|
+
},
|
|
124
|
+
setup(t) {
|
|
125
|
+
const o = t, e = q(), n = Ge(), i = Ue(), r = q(!1), s = q(null), u = q(!1), c = S(() => {
|
|
126
|
+
switch (o.action) {
|
|
127
|
+
case fe.enum.approveDraft:
|
|
128
|
+
return "Approve";
|
|
129
|
+
case fe.enum.rejectDraft:
|
|
130
|
+
return "Reject";
|
|
131
|
+
case fe.enum.markAsFailed:
|
|
132
|
+
return "Mark as Failed";
|
|
133
|
+
}
|
|
134
|
+
throw new Error(`Unknown action: ${o.action}`);
|
|
135
|
+
}), b = S(() => {
|
|
136
|
+
switch (o.action) {
|
|
137
|
+
case fe.enum.approveDraft:
|
|
138
|
+
return "primary";
|
|
139
|
+
case fe.enum.rejectDraft:
|
|
140
|
+
return "destructive";
|
|
141
|
+
case fe.enum.markAsFailed:
|
|
142
|
+
return "destructive";
|
|
143
|
+
}
|
|
144
|
+
throw new Error(`Unknown action: ${o.action}`);
|
|
145
|
+
});
|
|
146
|
+
ro(() => {
|
|
147
|
+
if (o.draft.effectiveAt)
|
|
148
|
+
s.value = new Date(o.draft.effectiveAt);
|
|
149
|
+
else {
|
|
150
|
+
const B = new Date(o.draft.createdAt);
|
|
151
|
+
B.setHours(23, 59, 59, 999), s.value = B;
|
|
152
|
+
}
|
|
153
|
+
u.value = !0;
|
|
154
|
+
});
|
|
155
|
+
const y = S({
|
|
156
|
+
get() {
|
|
157
|
+
return s.value === null ? "" : qe(s.value);
|
|
158
|
+
},
|
|
159
|
+
set(B) {
|
|
160
|
+
if (B) {
|
|
161
|
+
const I = /* @__PURE__ */ new Date(`${B} ${$.value}`);
|
|
162
|
+
I.setSeconds(59, 999), s.value = I;
|
|
163
|
+
} else
|
|
164
|
+
s.value = null;
|
|
165
|
+
}
|
|
166
|
+
}), $ = S({
|
|
167
|
+
get() {
|
|
168
|
+
return s.value === null ? "" : mo(s.value);
|
|
169
|
+
},
|
|
170
|
+
set(B) {
|
|
171
|
+
if (B) {
|
|
172
|
+
const I = /* @__PURE__ */ new Date(`${y.value} ${B}`);
|
|
173
|
+
I.setSeconds(59, 999), s.value = I;
|
|
174
|
+
} else
|
|
175
|
+
s.value = null;
|
|
176
|
+
}
|
|
177
|
+
}), Q = S(() => s.value ? s.value.getTime() > (/* @__PURE__ */ new Date()).getTime() : !1);
|
|
178
|
+
async function V(B) {
|
|
179
|
+
r.value = !0;
|
|
180
|
+
try {
|
|
181
|
+
B ? await n.runOperationV1({
|
|
182
|
+
_id: o.draft._id,
|
|
183
|
+
_rev: o.draft._rev ?? "",
|
|
184
|
+
action: o.action,
|
|
185
|
+
data: {
|
|
186
|
+
effectiveAt: s.value ? s.value.toISOString() : null,
|
|
187
|
+
remark: e.value
|
|
188
|
+
}
|
|
189
|
+
}).delayed(500) : await n.runOperation({
|
|
190
|
+
_id: o.draft._id,
|
|
191
|
+
_rev: o.draft._rev ?? "",
|
|
192
|
+
action: o.action,
|
|
193
|
+
data: {
|
|
194
|
+
effectiveAt: s.value ? s.value.toISOString() : null,
|
|
195
|
+
remark: e.value
|
|
196
|
+
}
|
|
197
|
+
}).delayed(500), i.open({
|
|
198
|
+
title: "Success",
|
|
199
|
+
message: "Action submitted",
|
|
200
|
+
type: "success"
|
|
201
|
+
}), o.onFinished();
|
|
202
|
+
} catch (I) {
|
|
203
|
+
i.open({
|
|
204
|
+
title: "Something went wrong",
|
|
205
|
+
message: (I == null ? void 0 : I.message) ?? "Unable to submit action. Please try again",
|
|
206
|
+
type: "error"
|
|
207
|
+
}), console.error("error on submit closing draft action", I);
|
|
208
|
+
} finally {
|
|
209
|
+
r.value = !1;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return (B, I) => {
|
|
213
|
+
const N = ee("FmLabel"), J = ee("FmDatePicker"), X = ee("FmTimePicker"), O = ee("FmTextField"), F = ee("FmButton"), T = ee("FmForm");
|
|
214
|
+
return u.value ? (f(), ne(T, {
|
|
215
|
+
key: 1,
|
|
216
|
+
onValidationSuccess: V,
|
|
217
|
+
class: "flex flex-col gap-32",
|
|
218
|
+
disabled: r.value
|
|
219
|
+
}, {
|
|
220
|
+
default: te(() => [
|
|
221
|
+
a("div", xn, [
|
|
222
|
+
I[4] || (I[4] = ge(" You are about to ")),
|
|
223
|
+
a("span", wn, E(c.value), 1),
|
|
224
|
+
I[5] || (I[5] = ge(" this draft. Please provide a remark to justify this action. "))
|
|
225
|
+
]),
|
|
226
|
+
B.action === d(fe).enum.approveDraft ? (f(), C("div", Dn, [
|
|
227
|
+
D(N, { class: "fm-typo-en-body-lg-600" }, {
|
|
228
|
+
default: te(() => I[6] || (I[6] = [
|
|
229
|
+
ge("Closing Date")
|
|
230
|
+
])),
|
|
231
|
+
_: 1
|
|
232
|
+
}),
|
|
233
|
+
D(J, {
|
|
234
|
+
modelValue: y.value,
|
|
235
|
+
"onUpdate:modelValue": I[0] || (I[0] = (k) => y.value = k),
|
|
236
|
+
max: d(qe)(/* @__PURE__ */ new Date())
|
|
237
|
+
}, null, 8, ["modelValue", "max"]),
|
|
238
|
+
D(N, { class: "fm-typo-en-body-lg-600" }, {
|
|
239
|
+
default: te(() => I[7] || (I[7] = [
|
|
240
|
+
ge("Closing Time")
|
|
241
|
+
])),
|
|
242
|
+
_: 1
|
|
243
|
+
}),
|
|
244
|
+
D(X, {
|
|
245
|
+
modelValue: $.value,
|
|
246
|
+
"onUpdate:modelValue": I[1] || (I[1] = (k) => $.value = k)
|
|
247
|
+
}, null, 8, ["modelValue"]),
|
|
248
|
+
Q.value ? (f(), C("div", An, " Cannot select future date ")) : W("", !0)
|
|
249
|
+
])) : W("", !0),
|
|
250
|
+
D(O, {
|
|
251
|
+
modelValue: e.value,
|
|
252
|
+
"onUpdate:modelValue": I[2] || (I[2] = (k) => e.value = k),
|
|
253
|
+
label: "Remark",
|
|
254
|
+
"label-mark": "required",
|
|
255
|
+
rules: [d(po)()]
|
|
256
|
+
}, null, 8, ["modelValue", "rules"]),
|
|
257
|
+
a("div", $n, [
|
|
258
|
+
D(F, {
|
|
259
|
+
label: "Cancel",
|
|
260
|
+
variant: "tertiary",
|
|
261
|
+
onClick: I[3] || (I[3] = (k) => B.onCancel())
|
|
262
|
+
}),
|
|
263
|
+
D(F, {
|
|
264
|
+
label: c.value,
|
|
265
|
+
type: "submit",
|
|
266
|
+
variant: b.value,
|
|
267
|
+
loading: r.value
|
|
268
|
+
}, null, 8, ["label", "variant", "loading"])
|
|
269
|
+
])
|
|
270
|
+
]),
|
|
271
|
+
_: 1
|
|
272
|
+
}, 8, ["disabled"])) : (f(), C(ie, { key: 0 }, [
|
|
273
|
+
ge("Loading")
|
|
274
|
+
], 64));
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
}), Cn = et(0);
|
|
278
|
+
function kt(t) {
|
|
279
|
+
const o = t.measurementsAmounts.groupBy((e) => e.measurement.id);
|
|
280
|
+
return t.sku.unit.measurements.reduce((e, n) => {
|
|
281
|
+
var s, u;
|
|
282
|
+
const i = ((u = (s = o.get(n.id)) == null ? void 0 : s[0]) == null ? void 0 : u.amount) ?? Cn, r = ht(n.conversion, i);
|
|
283
|
+
return tt(e, r);
|
|
284
|
+
}, t.baseAmount);
|
|
285
|
+
}
|
|
286
|
+
const Sn = et(0), Fn = et(100);
|
|
287
|
+
function In(t, o, e, n, i, r, s, u) {
|
|
288
|
+
var _, A, L, P, ve;
|
|
289
|
+
const c = kt(t), b = n ?? c, y = fo(b, o), $ = o.amount === 0 ? null : vo(y, {
|
|
290
|
+
...o,
|
|
291
|
+
amount: Math.abs(o.amount)
|
|
292
|
+
}), Q = $ ? ht($, Fn) : null, V = ((_ = t.sku.defaultCost) == null ? void 0 : _.costPerUnit) ?? { amount: 0, precision: 0 }, B = Number(se.toFormatString({ value: V })), I = ((L = (A = t.sku.defaultCost) == null ? void 0 : A.measurement) == null ? void 0 : L.conversion) ?? {
|
|
293
|
+
amount: 1,
|
|
294
|
+
precision: 0
|
|
295
|
+
}, N = Number(
|
|
296
|
+
se.toFormatString({ value: I })
|
|
297
|
+
), J = i ? Number(se.toFormatString({ value: i })) : 0, X = Number(se.toFormatString({ value: o })), O = Number(se.toFormatString({ value: b })), F = O - X, T = F * B / N, k = O * B / N, w = X * B / N, x = {};
|
|
298
|
+
return s && r && s.forEach((oe) => {
|
|
299
|
+
const R = { amount: 0, precision: 0 }, p = r[oe];
|
|
300
|
+
if (p) {
|
|
301
|
+
const g = tt(R, p);
|
|
302
|
+
x[`adjustment_${oe}`] = tn(g);
|
|
303
|
+
} else
|
|
304
|
+
x[`adjustment_${oe}`] = "0";
|
|
305
|
+
}), {
|
|
306
|
+
code: t.sku.code,
|
|
307
|
+
name: t.sku.name,
|
|
308
|
+
baseUnit: t.sku.unit.abbrev,
|
|
309
|
+
costUnit: ((ve = (P = t.sku.defaultCost) == null ? void 0 : P.measurement) == null ? void 0 : ve.abbrev) ?? null,
|
|
310
|
+
baseUnitAmount: Number(se.toFormatString({ value: t.baseAmount })),
|
|
311
|
+
...e.reduce(
|
|
312
|
+
(oe, R, p) => {
|
|
313
|
+
const g = se.toFormatString({ value: R.conversion }), M = R.orphan ? " [invalid UOM]" : R.inactive ? " [NetSuite-inactive]" : "";
|
|
314
|
+
return oe[`measurementAbbrev${p}`] = `(${R.abbrev}) × ${g}${M}`, oe[`measurementAmount${p}`] = Number(se.toFormatString({ value: R.amount })), oe;
|
|
315
|
+
},
|
|
316
|
+
{}
|
|
317
|
+
),
|
|
318
|
+
systemBalance: X,
|
|
319
|
+
physicalBalance: O,
|
|
320
|
+
adjustedAmount: Number(se.toFormatString({ value: y })),
|
|
321
|
+
adjustedDiffPercentage: Q ? Number(
|
|
322
|
+
se.toFormatString({
|
|
323
|
+
value: go(Q, 2)
|
|
324
|
+
})
|
|
325
|
+
) : null,
|
|
326
|
+
costPerUnit: B,
|
|
327
|
+
opening: J,
|
|
328
|
+
...x,
|
|
329
|
+
varianceQty: F,
|
|
330
|
+
varianceInCost: T,
|
|
331
|
+
stockTakeValue: k,
|
|
332
|
+
systemValue: w,
|
|
333
|
+
// Include custom attribute values
|
|
334
|
+
...(u ?? []).reduce(
|
|
335
|
+
(oe, R) => {
|
|
336
|
+
var g;
|
|
337
|
+
const p = (g = t.sku.customAttributes) == null ? void 0 : g[R];
|
|
338
|
+
return oe[`customAttr_${R}`] = p != null ? String(p) : null, oe;
|
|
339
|
+
},
|
|
340
|
+
{}
|
|
341
|
+
)
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
function Bn(t) {
|
|
345
|
+
let o = 0;
|
|
346
|
+
for (const e of t.values())
|
|
347
|
+
e.length > o && (o = e.length);
|
|
348
|
+
return o;
|
|
349
|
+
}
|
|
350
|
+
function Tn(t, o) {
|
|
351
|
+
const e = /* @__PURE__ */ new Map();
|
|
352
|
+
for (const n of t) {
|
|
353
|
+
if (e.has(n.sku._id)) continue;
|
|
354
|
+
const i = new Map(n.sku.unit.measurements.map((u) => [u.id, u])), r = new Map(
|
|
355
|
+
n.measurementsAmounts.map((u) => [u.measurement.id, u.amount])
|
|
356
|
+
), s = [];
|
|
357
|
+
for (const u of n.sku.unit.measurements) {
|
|
358
|
+
const c = r.get(u.id);
|
|
359
|
+
c && s.push({
|
|
360
|
+
id: u.id,
|
|
361
|
+
abbrev: u.abbrev,
|
|
362
|
+
conversion: u.conversion,
|
|
363
|
+
amount: c,
|
|
364
|
+
inactive: Rt(u, o),
|
|
365
|
+
orphan: !1
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
for (const u of n.measurementsAmounts)
|
|
369
|
+
i.has(u.measurement.id) || s.push({
|
|
370
|
+
id: u.measurement.id,
|
|
371
|
+
abbrev: u.measurement.abbrev,
|
|
372
|
+
conversion: u.measurement.conversion,
|
|
373
|
+
amount: u.amount,
|
|
374
|
+
inactive: !1,
|
|
375
|
+
orphan: !0
|
|
376
|
+
});
|
|
377
|
+
e.set(n.sku._id, s);
|
|
378
|
+
}
|
|
379
|
+
return e;
|
|
380
|
+
}
|
|
381
|
+
function jn(t, o = [], e = []) {
|
|
382
|
+
const n = co(), i = n === "MYR" ? "RM" : n;
|
|
383
|
+
return [
|
|
384
|
+
{
|
|
385
|
+
id: "code",
|
|
386
|
+
name: "Code"
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
id: "name",
|
|
390
|
+
name: "Name"
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
id: "baseUnit",
|
|
394
|
+
name: "Base unit"
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
id: "costPerUnit",
|
|
398
|
+
name: "Cost per unit"
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
id: "costUnit",
|
|
402
|
+
name: "UOM"
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
id: "opening",
|
|
406
|
+
name: "Opening (B/F)"
|
|
407
|
+
},
|
|
408
|
+
// Dynamic adjustment type columns
|
|
409
|
+
...o.map((s) => ({
|
|
410
|
+
id: `adjustment_${s}`,
|
|
411
|
+
name: Ie(s)
|
|
412
|
+
})),
|
|
413
|
+
{
|
|
414
|
+
id: "systemBalance",
|
|
415
|
+
name: "System balance (Qty)"
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
id: "physicalBalance",
|
|
419
|
+
name: "Stock take (Qty)"
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
id: "adjustedAmount",
|
|
423
|
+
name: "Variance"
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
id: "varianceInCost",
|
|
427
|
+
name: `Variance (${i})`
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
id: "adjustedDiffPercentage",
|
|
431
|
+
name: "Variance (%)"
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
id: "stockTakeValue",
|
|
435
|
+
name: `Stock take value (${i})`
|
|
436
|
+
},
|
|
437
|
+
{
|
|
438
|
+
id: "systemValue",
|
|
439
|
+
name: `System value (${i})`
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
id: "baseUnitAmount",
|
|
443
|
+
name: "Base unit amount"
|
|
444
|
+
},
|
|
445
|
+
...Array.from({ length: t }).flatMap((s, u) => [
|
|
446
|
+
{
|
|
447
|
+
id: `measurementAmount${u}`,
|
|
448
|
+
name: `UOM amount ${u + 1}`
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
id: `measurementAbbrev${u}`,
|
|
452
|
+
name: `UOM ${u + 1}`
|
|
453
|
+
}
|
|
454
|
+
]),
|
|
455
|
+
// Dynamic custom attribute columns
|
|
456
|
+
...e.map((s) => ({
|
|
457
|
+
id: `customAttr_${s}`,
|
|
458
|
+
name: Ie(s)
|
|
459
|
+
}))
|
|
460
|
+
];
|
|
461
|
+
}
|
|
462
|
+
function Rn(t, o, e, n = [], i) {
|
|
463
|
+
var re, _, A, L, P, ve, oe;
|
|
464
|
+
const r = o.groupBy(
|
|
465
|
+
(R) => R.id,
|
|
466
|
+
(R) => R.balance
|
|
467
|
+
), s = e.groupBy(
|
|
468
|
+
(R) => R.id,
|
|
469
|
+
(R) => R.balance
|
|
470
|
+
), u = /* @__PURE__ */ new Map();
|
|
471
|
+
if (t.opening)
|
|
472
|
+
for (const R of t.opening)
|
|
473
|
+
u.set(R.skuId, R.balance);
|
|
474
|
+
const c = /* @__PURE__ */ new Set(), b = /* @__PURE__ */ new Map();
|
|
475
|
+
if (t.adjustmentSnapshot)
|
|
476
|
+
for (const R of t.adjustmentSnapshot)
|
|
477
|
+
R.adjustmentsByType && (Object.keys(R.adjustmentsByType).forEach((p) => c.add(p)), b.set(R.skuId, R.adjustmentsByType));
|
|
478
|
+
const y = ["receive", "sales", "wastage"], $ = [];
|
|
479
|
+
y.forEach((R) => {
|
|
480
|
+
c.has(R) && ($.push(R), c.delete(R));
|
|
481
|
+
});
|
|
482
|
+
const Q = Array.from(c).sort(), V = [...$, ...Q], B = [...t.items, ...t.negativeStockItems ?? []], N = lo().currentBusiness.value, J = Tn(B, i), X = B.map((R) => {
|
|
483
|
+
var de, j;
|
|
484
|
+
const p = ((de = r.get(R.sku._id)) == null ? void 0 : de[0]) ?? Sn, g = J.get(R.sku._id) ?? [], M = u.get(R.sku._id), H = b.get(R.sku._id);
|
|
485
|
+
return In(
|
|
486
|
+
R,
|
|
487
|
+
p,
|
|
488
|
+
g,
|
|
489
|
+
(j = s.get(R.sku._id)) == null ? void 0 : j[0],
|
|
490
|
+
M,
|
|
491
|
+
H,
|
|
492
|
+
V,
|
|
493
|
+
n
|
|
494
|
+
);
|
|
495
|
+
}), O = Bn(J), F = jn(O, V, n), T = [
|
|
496
|
+
["Business name:", N == null ? void 0 : N.name],
|
|
497
|
+
["Business ID:", N == null ? void 0 : N._id],
|
|
498
|
+
["Menu version", N == null ? void 0 : N.menuVersion],
|
|
499
|
+
["Created at", new Date(t.createdAt)],
|
|
500
|
+
["Created by", (re = t.createdBy) == null ? void 0 : re.name],
|
|
501
|
+
["Updated at", new Date(t.updatedAt)],
|
|
502
|
+
["Updated by", (_ = t.updatedBy) == null ? void 0 : _.name],
|
|
503
|
+
["Recent action", t.approvedAt ? "Approve" : t.rejectionHistory ? "Reject" : ""],
|
|
504
|
+
[
|
|
505
|
+
"Action by",
|
|
506
|
+
t.approvedAt ? (A = t.approvedBy) == null ? void 0 : A.name : t.rejectionHistory ? (P = (L = t.rejectionHistory[0]) == null ? void 0 : L.rejectedBy) == null ? void 0 : P.name : ""
|
|
507
|
+
],
|
|
508
|
+
[
|
|
509
|
+
"Action at",
|
|
510
|
+
t.approvedAt ? new Date(t.approvedAt) : t.rejectionHistory ? new Date((ve = t.rejectionHistory[0]) == null ? void 0 : ve.rejectedAt) : ""
|
|
511
|
+
],
|
|
512
|
+
[
|
|
513
|
+
"Action remark",
|
|
514
|
+
t.approvedAt ? t.approveRemark : t.rejectionHistory ? new Date((oe = t.rejectionHistory[0]) == null ? void 0 : oe.rejectRemark) : ""
|
|
515
|
+
],
|
|
516
|
+
[],
|
|
517
|
+
F.map((R) => R.name),
|
|
518
|
+
...X.map((R) => F.map((p) => R[p.id]))
|
|
519
|
+
], k = F.map((R) => `system:${R.id}`), w = nn(T, k), x = `[${N == null ? void 0 : N.name}] closing draft (${en(new Date(t.updatedAt))}).xlsx`;
|
|
520
|
+
return an(w, x), x;
|
|
521
|
+
}
|
|
522
|
+
const Mn = { class: "flex flex-col" }, Nn = {
|
|
523
|
+
key: 0,
|
|
524
|
+
class: "fm-typo-en-body-sm-400 text-fm-color-typo-error mt-4"
|
|
525
|
+
}, Un = { class: "flex gap-12 py-8 justify-end w-full" }, Pn = /* @__PURE__ */ Se({
|
|
526
|
+
__name: "RefreshBalanceAction",
|
|
527
|
+
props: {
|
|
528
|
+
draft: {},
|
|
529
|
+
onCancel: { type: Function },
|
|
530
|
+
onFinished: { type: Function }
|
|
531
|
+
},
|
|
532
|
+
setup(t) {
|
|
533
|
+
const o = t;
|
|
534
|
+
_t();
|
|
535
|
+
const e = q(!1), n = q(null), i = q(!1);
|
|
536
|
+
ro(() => {
|
|
537
|
+
if (o.draft.effectiveAt)
|
|
538
|
+
n.value = new Date(o.draft.effectiveAt);
|
|
539
|
+
else {
|
|
540
|
+
const b = new Date(o.draft.createdAt);
|
|
541
|
+
b.setHours(23, 59, 59, 999), n.value = b;
|
|
542
|
+
}
|
|
543
|
+
i.value = !0;
|
|
544
|
+
});
|
|
545
|
+
const r = S({
|
|
546
|
+
get() {
|
|
547
|
+
return n.value === null ? "" : qe(n.value);
|
|
548
|
+
},
|
|
549
|
+
set(b) {
|
|
550
|
+
if (b) {
|
|
551
|
+
const y = /* @__PURE__ */ new Date(`${b} ${s.value}`);
|
|
552
|
+
y.setSeconds(59, 999), n.value = y;
|
|
553
|
+
} else
|
|
554
|
+
n.value = null;
|
|
555
|
+
}
|
|
556
|
+
}), s = S({
|
|
557
|
+
get() {
|
|
558
|
+
return n.value === null ? "" : mo(n.value);
|
|
559
|
+
},
|
|
560
|
+
set(b) {
|
|
561
|
+
if (b) {
|
|
562
|
+
const y = /* @__PURE__ */ new Date(`${r.value} ${b}`);
|
|
563
|
+
y.setSeconds(59, 999), n.value = y;
|
|
564
|
+
} else
|
|
565
|
+
n.value = null;
|
|
566
|
+
}
|
|
567
|
+
}), u = S(() => n.value ? n.value.getTime() > (/* @__PURE__ */ new Date()).getTime() : !1);
|
|
568
|
+
async function c() {
|
|
569
|
+
e.value = !0, o.onFinished(n.value.toISOString());
|
|
570
|
+
}
|
|
571
|
+
return (b, y) => {
|
|
572
|
+
const $ = ee("FmLabel"), Q = ee("FmDatePicker"), V = ee("FmTimePicker"), B = ee("FmButton"), I = ee("FmForm");
|
|
573
|
+
return i.value ? (f(), ne(I, {
|
|
574
|
+
key: 1,
|
|
575
|
+
onValidationSuccess: c,
|
|
576
|
+
class: "flex flex-col gap-32",
|
|
577
|
+
disabled: e.value
|
|
578
|
+
}, {
|
|
579
|
+
default: te(() => [
|
|
580
|
+
y[5] || (y[5] = a("div", { class: "fm-typo-en-body-lg-400" }, [
|
|
581
|
+
a("p", null, [
|
|
582
|
+
ge(" Performing "),
|
|
583
|
+
a("span", { class: "fm-typo-en-body-lg-600" }, '"Refresh Balance"'),
|
|
584
|
+
ge(" until closing effective date and time. ")
|
|
585
|
+
]),
|
|
586
|
+
a("p", { class: "mt-2" }, [
|
|
587
|
+
ge(" Please note that this action will "),
|
|
588
|
+
a("b", null, "update"),
|
|
589
|
+
ge(" the effective date and time. ")
|
|
590
|
+
])
|
|
591
|
+
], -1)),
|
|
592
|
+
a("div", Mn, [
|
|
593
|
+
D($, { class: "fm-typo-en-body-lg-600" }, {
|
|
594
|
+
default: te(() => y[3] || (y[3] = [
|
|
595
|
+
ge("Closing Date")
|
|
596
|
+
])),
|
|
597
|
+
_: 1
|
|
598
|
+
}),
|
|
599
|
+
D(Q, {
|
|
600
|
+
modelValue: r.value,
|
|
601
|
+
"onUpdate:modelValue": y[0] || (y[0] = (N) => r.value = N),
|
|
602
|
+
max: d(qe)(/* @__PURE__ */ new Date())
|
|
603
|
+
}, null, 8, ["modelValue", "max"]),
|
|
604
|
+
D($, { class: "fm-typo-en-body-lg-600" }, {
|
|
605
|
+
default: te(() => y[4] || (y[4] = [
|
|
606
|
+
ge("Closing Time")
|
|
607
|
+
])),
|
|
608
|
+
_: 1
|
|
609
|
+
}),
|
|
610
|
+
D(V, {
|
|
611
|
+
modelValue: s.value,
|
|
612
|
+
"onUpdate:modelValue": y[1] || (y[1] = (N) => s.value = N)
|
|
613
|
+
}, null, 8, ["modelValue"]),
|
|
614
|
+
u.value ? (f(), C("div", Nn, " Cannot select future date ")) : W("", !0)
|
|
615
|
+
]),
|
|
616
|
+
a("div", Un, [
|
|
617
|
+
D(B, {
|
|
618
|
+
label: "Cancel",
|
|
619
|
+
variant: "tertiary",
|
|
620
|
+
onClick: y[2] || (y[2] = (N) => b.onCancel())
|
|
621
|
+
}),
|
|
622
|
+
D(B, {
|
|
623
|
+
label: "Refresh balance",
|
|
624
|
+
type: "submit",
|
|
625
|
+
variant: "primary",
|
|
626
|
+
loading: e.value,
|
|
627
|
+
disabled: u.value
|
|
628
|
+
}, null, 8, ["loading", "disabled"])
|
|
629
|
+
])
|
|
630
|
+
]),
|
|
631
|
+
_: 1
|
|
632
|
+
}, 8, ["disabled"])) : (f(), C(ie, { key: 0 }, [
|
|
633
|
+
ge("Loading")
|
|
634
|
+
], 64));
|
|
635
|
+
};
|
|
636
|
+
}
|
|
637
|
+
}), yt = uo(
|
|
638
|
+
"closingDraftActions",
|
|
639
|
+
function() {
|
|
640
|
+
const o = io(), e = Ue(), n = _t(), i = Ge(), r = ln(), s = Mt(), u = q(!1), c = q();
|
|
641
|
+
async function b(F, T) {
|
|
642
|
+
const k = await i.getDraftDetail(F, T), w = {
|
|
643
|
+
draft: k
|
|
644
|
+
};
|
|
645
|
+
return c.value = w, u.value = !0, k;
|
|
646
|
+
}
|
|
647
|
+
async function y(F) {
|
|
648
|
+
var k;
|
|
649
|
+
if (F.status === xe.enum.COMPLETED) {
|
|
650
|
+
const w = F.closingAdjustmentId;
|
|
651
|
+
if (!w)
|
|
652
|
+
return e.open({
|
|
653
|
+
title: "Something went wrong",
|
|
654
|
+
message: "Closing draft is completed but closing document cannot be found.",
|
|
655
|
+
type: "error"
|
|
656
|
+
}), console.error("Closing draft is completed but closing document cannot be found.", {
|
|
657
|
+
draftId: F._id
|
|
658
|
+
}), [];
|
|
659
|
+
const x = await n.readAdjustmentById(w);
|
|
660
|
+
return ((x == null ? void 0 : x.skus) ?? []).map((_) => ({
|
|
661
|
+
id: _.sku._id,
|
|
662
|
+
balance: _.fromBalance,
|
|
663
|
+
costs: _.fromCostBalances
|
|
664
|
+
}));
|
|
665
|
+
} else
|
|
666
|
+
return await r.readStockBalance(), ((k = r.stockBalance) == null ? void 0 : k.skus) ?? [];
|
|
667
|
+
}
|
|
668
|
+
async function $(F, T, k, w) {
|
|
669
|
+
T || (e.open({
|
|
670
|
+
title: "Exporting",
|
|
671
|
+
message: "Fetching data..."
|
|
672
|
+
}), T = await y(F)), Rn(
|
|
673
|
+
F,
|
|
674
|
+
T,
|
|
675
|
+
k ?? [],
|
|
676
|
+
w ?? [],
|
|
677
|
+
s.value
|
|
678
|
+
);
|
|
679
|
+
}
|
|
680
|
+
function Q(F, T, k) {
|
|
681
|
+
o.open({
|
|
682
|
+
title: "Approve draft",
|
|
683
|
+
contentComponent: It,
|
|
684
|
+
contentComponentProps: {
|
|
685
|
+
draft: F,
|
|
686
|
+
action: fe.enum.approveDraft,
|
|
687
|
+
onFinished: () => {
|
|
688
|
+
o.close(), T == null || T();
|
|
689
|
+
},
|
|
690
|
+
onCancel: () => {
|
|
691
|
+
o.close();
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
}).onClose(() => {
|
|
695
|
+
k == null || k();
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
function V(F, T) {
|
|
699
|
+
o.open({
|
|
700
|
+
title: "Reject draft",
|
|
701
|
+
contentComponent: It,
|
|
702
|
+
contentComponentProps: {
|
|
703
|
+
draft: F,
|
|
704
|
+
action: fe.enum.rejectDraft,
|
|
705
|
+
onFinished: () => {
|
|
706
|
+
o.close(), T == null || T();
|
|
707
|
+
},
|
|
708
|
+
onCancel: () => o.close()
|
|
709
|
+
}
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
function B(F, T) {
|
|
713
|
+
o.open({
|
|
714
|
+
title: "Mark draft as failed",
|
|
715
|
+
contentComponent: It,
|
|
716
|
+
contentComponentProps: {
|
|
717
|
+
draft: F,
|
|
718
|
+
action: fe.enum.markAsFailed,
|
|
719
|
+
onFinished: () => {
|
|
720
|
+
o.close(), T == null || T();
|
|
721
|
+
},
|
|
722
|
+
onCancel: () => o.close()
|
|
723
|
+
}
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
async function I(F, T) {
|
|
727
|
+
await i.sync({
|
|
728
|
+
_id: F._id,
|
|
729
|
+
_rev: F._rev ?? "",
|
|
730
|
+
action: fe.enum.approveDraft,
|
|
731
|
+
data: {
|
|
732
|
+
remark: F.remark ?? ""
|
|
733
|
+
}
|
|
734
|
+
}).delayed(500), e.open({
|
|
735
|
+
title: "Success",
|
|
736
|
+
message: "Sync requested",
|
|
737
|
+
type: "success"
|
|
738
|
+
}), T == null || T();
|
|
739
|
+
}
|
|
740
|
+
function N() {
|
|
741
|
+
u.value = !1;
|
|
742
|
+
}
|
|
743
|
+
async function J(F, T, k) {
|
|
744
|
+
await o.open({
|
|
745
|
+
title: "Refresh balance",
|
|
746
|
+
contentComponent: Pn,
|
|
747
|
+
contentComponentProps: {
|
|
748
|
+
draft: F,
|
|
749
|
+
onFinished: (w) => {
|
|
750
|
+
o.close(), k == null || k(w);
|
|
751
|
+
},
|
|
752
|
+
onCancel: async () => {
|
|
753
|
+
o.close(), T == null || T();
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
});
|
|
757
|
+
}
|
|
758
|
+
async function X(F) {
|
|
759
|
+
await o.open({
|
|
760
|
+
title: "Invalidate closing draft cache",
|
|
761
|
+
message: "It will invalidate opening and stock movement cache for this draft.",
|
|
762
|
+
primaryActions: { text: "Proceed", close: !0 },
|
|
763
|
+
secondaryActions: { text: "Cancel", close: !0 }
|
|
764
|
+
}).onPrimary(async () => {
|
|
765
|
+
await n.recalculation.scheduleInvalidateClosingDraftCache([F._id]), e.open({
|
|
766
|
+
title: "Success",
|
|
767
|
+
message: "Invalidate cache requested",
|
|
768
|
+
type: "success"
|
|
769
|
+
});
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
async function O(F, T) {
|
|
773
|
+
try {
|
|
774
|
+
e.open({
|
|
775
|
+
title: "Cloning",
|
|
776
|
+
message: "Creating a copy of the draft..."
|
|
777
|
+
}), await i.cloneDraft(F._id), e.open({
|
|
778
|
+
title: "Success",
|
|
779
|
+
message: "Draft cloned successfully",
|
|
780
|
+
type: "success"
|
|
781
|
+
}), T == null || T();
|
|
782
|
+
} catch (k) {
|
|
783
|
+
e.open({
|
|
784
|
+
title: "Error",
|
|
785
|
+
message: (k == null ? void 0 : k.message) || "Failed to clone draft",
|
|
786
|
+
type: "error"
|
|
787
|
+
});
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
return {
|
|
791
|
+
viewDraft: b,
|
|
792
|
+
closeDraftDialog: N,
|
|
793
|
+
approveDraft: Q,
|
|
794
|
+
rejectDraft: V,
|
|
795
|
+
markAsFailed: B,
|
|
796
|
+
syncDraft: I,
|
|
797
|
+
exportDraft: $,
|
|
798
|
+
refreshBalance: J,
|
|
799
|
+
cloneDraft: O,
|
|
800
|
+
viewClosingDraftShow: u,
|
|
801
|
+
viewClosingDraftProps: c,
|
|
802
|
+
invalidateDraftCache: X
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
);
|
|
806
|
+
function Ne(t) {
|
|
807
|
+
switch (t) {
|
|
808
|
+
case "DRAFT":
|
|
809
|
+
return "fm-status-badge-draft";
|
|
810
|
+
case "PROCESSING":
|
|
811
|
+
return "fm-status-badge-processing";
|
|
812
|
+
case "FAILED":
|
|
813
|
+
return "fm-status-badge-cancel";
|
|
814
|
+
case "COMPLETED":
|
|
815
|
+
return "fm-status-badge-complete";
|
|
816
|
+
case "PENDING_APPROVAL":
|
|
817
|
+
return "fm-status-badge-processing";
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
function Nt(t) {
|
|
821
|
+
var n, i;
|
|
822
|
+
if (t.status !== "DRAFT") return t.status;
|
|
823
|
+
const o = (i = (n = t.rejectionHistory) == null ? void 0 : n[0]) == null ? void 0 : i.rejectedAt;
|
|
824
|
+
if (!o) return "DRAFT";
|
|
825
|
+
const e = t.updatedAt ? new Date(t.updatedAt) : null;
|
|
826
|
+
return !e || new Date(o).getTime() > e.getTime() ? "REJECTED" : "UPDATED";
|
|
827
|
+
}
|
|
828
|
+
function Vn(t) {
|
|
829
|
+
return t.baseAmount.amount > 0 ? !0 : t.measurementsAmounts.some((o) => o.amount.amount !== 0);
|
|
830
|
+
}
|
|
831
|
+
function En(t) {
|
|
832
|
+
var i, r, s;
|
|
833
|
+
const o = Number(se.toFormatString({ value: kt(t) })), e = Number(
|
|
834
|
+
se.toFormatString({
|
|
835
|
+
value: ((i = t.sku.defaultCost) == null ? void 0 : i.costPerUnit) ?? { amount: 0, precision: 0 }
|
|
836
|
+
})
|
|
837
|
+
), n = Number(
|
|
838
|
+
se.toFormatString({
|
|
839
|
+
value: ((s = (r = t.sku.defaultCost) == null ? void 0 : r.measurement) == null ? void 0 : s.conversion) ?? { amount: 1, precision: 0 }
|
|
840
|
+
})
|
|
841
|
+
);
|
|
842
|
+
return o * e / n;
|
|
843
|
+
}
|
|
844
|
+
function xt(t) {
|
|
845
|
+
var o, e;
|
|
846
|
+
return ((e = (o = t.usingTemplates) == null ? void 0 : o[0]) == null ? void 0 : e.name) || "Group";
|
|
847
|
+
}
|
|
848
|
+
function Ln(t) {
|
|
849
|
+
var e;
|
|
850
|
+
const o = (e = t.usingTemplates) == null ? void 0 : e[0];
|
|
851
|
+
return o != null && o.ref ? o.ref : xt(t).replace(/[^a-z0-9]/gi, "").slice(0, 6).toUpperCase() || "GROUP";
|
|
852
|
+
}
|
|
853
|
+
function Bt(t) {
|
|
854
|
+
var r, s, u;
|
|
855
|
+
const o = [...t.items, ...t.negativeStockItems ?? []], e = o.filter(Vn).length, n = o.reduce((c, b) => c + En(b), 0), i = ((r = t.updatedBy) == null ? void 0 : r.name) || ((s = t.createdBy) == null ? void 0 : s.name) || void 0;
|
|
856
|
+
return {
|
|
857
|
+
id: t._id,
|
|
858
|
+
name: xt(t),
|
|
859
|
+
code: Ln(t),
|
|
860
|
+
status: t.status,
|
|
861
|
+
rejectionHistory: t.rejectionHistory,
|
|
862
|
+
itemCount: o.length,
|
|
863
|
+
totalAmount: n,
|
|
864
|
+
countedCount: e,
|
|
865
|
+
countedBy: e > 0 ? i : void 0,
|
|
866
|
+
verifiedBy: (u = t.approvedBy) == null ? void 0 : u.name,
|
|
867
|
+
updatedBy: i,
|
|
868
|
+
updatedAt: t.updatedAt || t.createdAt
|
|
869
|
+
};
|
|
870
|
+
}
|
|
871
|
+
function Gn(t) {
|
|
872
|
+
return t.reduce(
|
|
873
|
+
(o, e) => {
|
|
874
|
+
o.totalItems += e.itemCount, o.totalAmount += e.totalAmount;
|
|
875
|
+
const n = Nt(e);
|
|
876
|
+
return n === "COMPLETED" ? o.completed++ : n === "REJECTED" ? o.rejected++ : o.draft++, o;
|
|
877
|
+
},
|
|
878
|
+
{
|
|
879
|
+
groupCount: t.length,
|
|
880
|
+
totalItems: 0,
|
|
881
|
+
totalAmount: 0,
|
|
882
|
+
completed: 0,
|
|
883
|
+
draft: 0,
|
|
884
|
+
rejected: 0
|
|
885
|
+
}
|
|
886
|
+
);
|
|
887
|
+
}
|
|
888
|
+
const bo = uo(
|
|
889
|
+
"closingDraftTable",
|
|
890
|
+
function() {
|
|
891
|
+
var R;
|
|
892
|
+
const { t: o } = ot(), e = lo(), n = yt(), i = q(new Array()), r = q(0), s = q(!1), u = Qe(), c = Ge(), b = Ue();
|
|
893
|
+
function y(p) {
|
|
894
|
+
console.error("Row action failed:", p), b.open({
|
|
895
|
+
title: o("inventory.common.somethingWentWrong"),
|
|
896
|
+
message: (p == null ? void 0 : p.message) || o("inventory.common.tryAgain"),
|
|
897
|
+
type: "error"
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
let $ = {}, Q = (R = u._currentLocation) == null ? void 0 : R.dbName;
|
|
901
|
+
const V = 6, B = q(dn());
|
|
902
|
+
function I(p) {
|
|
903
|
+
const g = new Date(p.endDate);
|
|
904
|
+
return g.setMonth(g.getMonth() - V), new Date(p.startDate) < g ? { startDate: qe(g), endDate: p.endDate } : p;
|
|
905
|
+
}
|
|
906
|
+
function N(p) {
|
|
907
|
+
const g = I(p);
|
|
908
|
+
return (g.startDate !== B.value.startDate || g.endDate !== B.value.endDate) && (B.value = g, O()), g;
|
|
909
|
+
}
|
|
910
|
+
async function J(p) {
|
|
911
|
+
return u._currentLocation ? (Q = c.getDbName(), c.listDraftsPage({
|
|
912
|
+
...p,
|
|
913
|
+
from: B.value.startDate,
|
|
914
|
+
to: B.value.endDate
|
|
915
|
+
})) : { docs: [], nextStartkey: null, hasMore: !1 };
|
|
916
|
+
}
|
|
917
|
+
function X(p) {
|
|
918
|
+
return k(p);
|
|
919
|
+
}
|
|
920
|
+
function O() {
|
|
921
|
+
$ = {}, i.value = [], r.value++;
|
|
922
|
+
}
|
|
923
|
+
async function F() {
|
|
924
|
+
(u._currentLocation ? c.getDbName() : void 0) !== Q && O();
|
|
925
|
+
}
|
|
926
|
+
async function T(p) {
|
|
927
|
+
if (!i.value.find((g) => g._id) && u._currentLocation) {
|
|
928
|
+
s.value = !0;
|
|
929
|
+
try {
|
|
930
|
+
const [g] = await Promise.all([
|
|
931
|
+
c.getDraft(p),
|
|
932
|
+
new Promise((H) => setTimeout(H, 1e3))
|
|
933
|
+
]), { toClosingDraftListItem: M } = await import("./index-xatqRsUm.js");
|
|
934
|
+
i.value = k([
|
|
935
|
+
M(g)
|
|
936
|
+
]), w(p);
|
|
937
|
+
} catch (g) {
|
|
938
|
+
console.log("Something went wrong when fetching drafts:", g);
|
|
939
|
+
} finally {
|
|
940
|
+
s.value = !1;
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
function k(p) {
|
|
945
|
+
for (const H of p) $[H._id] = H;
|
|
946
|
+
const g = Object.values($), M = mn(
|
|
947
|
+
g.filter((H) => !!H.closingId).map((H) => ({ closingId: H.closingId, draftCreatedAt: new Date(Le(H._id)) }))
|
|
948
|
+
);
|
|
949
|
+
return p.map((H) => ({
|
|
950
|
+
...H,
|
|
951
|
+
closingIdDisplay: H.closingId ? M.get(H.closingId) ?? null : null
|
|
952
|
+
}));
|
|
953
|
+
}
|
|
954
|
+
async function w(p) {
|
|
955
|
+
try {
|
|
956
|
+
const M = (await c.getClosingGroups(p)).map(Bt);
|
|
957
|
+
i.value = i.value.map((H) => H._id === p ? { ...H, groups: M } : H);
|
|
958
|
+
} catch (g) {
|
|
959
|
+
console.log(`Something went wrong when refreshing groups for ${p}:`, g);
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
async function x(p, g) {
|
|
963
|
+
const { toClosingDraftListItem: M } = await import("./index-xatqRsUm.js");
|
|
964
|
+
return {
|
|
965
|
+
...M(
|
|
966
|
+
p
|
|
967
|
+
),
|
|
968
|
+
_rev: p._rev,
|
|
969
|
+
closingIdDisplay: g.closingIdDisplay,
|
|
970
|
+
groups: (p.groups ?? []).map(
|
|
971
|
+
(H) => Bt(H)
|
|
972
|
+
)
|
|
973
|
+
};
|
|
974
|
+
}
|
|
975
|
+
async function re(p) {
|
|
976
|
+
const { toClosingDraftListItem: g } = await import("./index-xatqRsUm.js");
|
|
977
|
+
i.value = i.value.map((M) => M._id === p._id ? {
|
|
978
|
+
...g(p),
|
|
979
|
+
_rev: p._rev,
|
|
980
|
+
closingIdDisplay: M.closingIdDisplay,
|
|
981
|
+
// The full doc carries no groups; keep the row's embedded
|
|
982
|
+
// summaries until refreshDraftGroups below replaces them.
|
|
983
|
+
groups: M.groups
|
|
984
|
+
} : M), w(p._id);
|
|
985
|
+
}
|
|
986
|
+
function _(p) {
|
|
987
|
+
var H;
|
|
988
|
+
const g = p.itemCount + p.negativeStockItemCount, M = (p == null ? void 0 : p.approveRemark) ?? ((H = p == null ? void 0 : p.rejectionHistory) == null ? void 0 : H.computeFirst((de) => de.rejectRemark)) ?? p.remark ?? "";
|
|
989
|
+
return { count: g, remark: M };
|
|
990
|
+
}
|
|
991
|
+
function A(p, g = "") {
|
|
992
|
+
return h(
|
|
993
|
+
"span",
|
|
994
|
+
{
|
|
995
|
+
class: [
|
|
996
|
+
"inline-flex items-center rounded-sm bg-fm-color-neutral-gray-100 px-8 py-4 fm-typo-en-body-sm-400 text-fm-color-typo-secondary",
|
|
997
|
+
g
|
|
998
|
+
]
|
|
999
|
+
},
|
|
1000
|
+
p
|
|
1001
|
+
);
|
|
1002
|
+
}
|
|
1003
|
+
function L(p) {
|
|
1004
|
+
if (!p.length) return null;
|
|
1005
|
+
const g = p.reduce(
|
|
1006
|
+
(M, H) => {
|
|
1007
|
+
const de = Nt(H);
|
|
1008
|
+
return de === "COMPLETED" ? M.completed++ : de === "REJECTED" ? M.rejected++ : M.draft++, M;
|
|
1009
|
+
},
|
|
1010
|
+
{ completed: 0, draft: 0, rejected: 0 }
|
|
1011
|
+
);
|
|
1012
|
+
return h("div", { class: "mt-8 flex flex-wrap gap-6" }, [
|
|
1013
|
+
A(`${p.length} groups`),
|
|
1014
|
+
g.completed ? A(`${g.completed} completed`, "text-fm-color-typo-success") : null,
|
|
1015
|
+
g.draft ? A(`${g.draft} draft`) : null,
|
|
1016
|
+
g.rejected ? A(`${g.rejected} rejected`, "text-fm-color-typo-error") : null
|
|
1017
|
+
]);
|
|
1018
|
+
}
|
|
1019
|
+
function P() {
|
|
1020
|
+
n.closeDraftDialog(), O();
|
|
1021
|
+
}
|
|
1022
|
+
async function ve(p, g) {
|
|
1023
|
+
switch (g = Jo(g), p) {
|
|
1024
|
+
case Ye.Details:
|
|
1025
|
+
return n.viewDraft(g._id).then(
|
|
1026
|
+
() => {
|
|
1027
|
+
},
|
|
1028
|
+
y
|
|
1029
|
+
);
|
|
1030
|
+
case Ye.Export:
|
|
1031
|
+
return c.getDraft(g._id).then((M) => n.exportDraft(M)).catch(y);
|
|
1032
|
+
case fe.enum.approveDraft:
|
|
1033
|
+
return n.approveDraft(g, P);
|
|
1034
|
+
case fe.enum.rejectDraft:
|
|
1035
|
+
return n.rejectDraft(g, P);
|
|
1036
|
+
case fe.enum.markAsFailed:
|
|
1037
|
+
return n.markAsFailed(g, P);
|
|
1038
|
+
case Ye.Duplicate:
|
|
1039
|
+
return n.cloneDraft(g, P);
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
return {
|
|
1043
|
+
columnDefs: [
|
|
1044
|
+
{
|
|
1045
|
+
id: "_id",
|
|
1046
|
+
accessorKey: "_id",
|
|
1047
|
+
header: () => o("inventory.closing.table.createdAt"),
|
|
1048
|
+
cell(p) {
|
|
1049
|
+
return un(`${p.getValue()}`);
|
|
1050
|
+
},
|
|
1051
|
+
sortingFn: (p, g) => new Date(Le(p.original._id)).getTime() - new Date(Le(g.original._id)).getTime(),
|
|
1052
|
+
enableSorting: !0
|
|
1053
|
+
},
|
|
1054
|
+
{
|
|
1055
|
+
id: "closingId",
|
|
1056
|
+
accessorFn: (p) => p.closingIdDisplay,
|
|
1057
|
+
size: 160,
|
|
1058
|
+
header: () => o("inventory.closing.draft.table.id"),
|
|
1059
|
+
cell(p) {
|
|
1060
|
+
return p.getValue();
|
|
1061
|
+
},
|
|
1062
|
+
enableSorting: !0
|
|
1063
|
+
},
|
|
1064
|
+
{
|
|
1065
|
+
accessorKey: "effectiveAt",
|
|
1066
|
+
header: () => o("inventory.closing.draft.table.effectiveAt"),
|
|
1067
|
+
cell(p) {
|
|
1068
|
+
const g = p.row.original;
|
|
1069
|
+
let M = p.getValue();
|
|
1070
|
+
return M || (M = Le(g._id)), Fe(M);
|
|
1071
|
+
},
|
|
1072
|
+
enableSorting: !0,
|
|
1073
|
+
size: 230
|
|
1074
|
+
},
|
|
1075
|
+
{
|
|
1076
|
+
id: "description",
|
|
1077
|
+
accessorFn: (p) => {
|
|
1078
|
+
const { count: g, remark: M } = _(p);
|
|
1079
|
+
return `${g} ${M}`;
|
|
1080
|
+
},
|
|
1081
|
+
header: () => o("inventory.closing.draft.table.description"),
|
|
1082
|
+
enableSorting: !0,
|
|
1083
|
+
size: 350,
|
|
1084
|
+
cell(p) {
|
|
1085
|
+
const { count: g, remark: M } = _(p.row.original), H = p.row.original.groups ?? [], de = (j, z) => h("div", { class: "flex gap-4" }, [
|
|
1086
|
+
h(
|
|
1087
|
+
"span",
|
|
1088
|
+
{ class: "fm-typo-en-body-sm-600 text-fm-color-typo-primary" },
|
|
1089
|
+
`${j}:`
|
|
1090
|
+
),
|
|
1091
|
+
h(
|
|
1092
|
+
"span",
|
|
1093
|
+
{
|
|
1094
|
+
class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary",
|
|
1095
|
+
style: "white-space: pre-wrap; word-break: break-word;"
|
|
1096
|
+
},
|
|
1097
|
+
`${z}`
|
|
1098
|
+
)
|
|
1099
|
+
]);
|
|
1100
|
+
return h("div", { class: "flex flex-col gap-2", style: "width: 300px;" }, [
|
|
1101
|
+
de(o("inventory.closing.draft.table.items"), g),
|
|
1102
|
+
M ? de(o("inventory.closing.draft.table.remark"), M) : null,
|
|
1103
|
+
L(H)
|
|
1104
|
+
]);
|
|
1105
|
+
}
|
|
1106
|
+
},
|
|
1107
|
+
{
|
|
1108
|
+
id: "status",
|
|
1109
|
+
accessorFn: (p) => p.status,
|
|
1110
|
+
header: () => o("inventory.closing.table.status"),
|
|
1111
|
+
enableSorting: !1,
|
|
1112
|
+
cell(p) {
|
|
1113
|
+
var z;
|
|
1114
|
+
const g = p.row.original, M = g.status, H = new Date(g.updatedAt), de = (z = g == null ? void 0 : g.rejectionHistory) == null ? void 0 : z.computeFirst((le) => le.rejectedAt), j = de ? new Date(de) : null;
|
|
1115
|
+
return M === "DRAFT" && j ? j.getTime() > H.getTime() ? h(
|
|
1116
|
+
"div",
|
|
1117
|
+
{
|
|
1118
|
+
class: "flex"
|
|
1119
|
+
},
|
|
1120
|
+
h(
|
|
1121
|
+
"div",
|
|
1122
|
+
{
|
|
1123
|
+
class: ["fm-status-badge", Ne("FAILED")]
|
|
1124
|
+
},
|
|
1125
|
+
"Rejected"
|
|
1126
|
+
)
|
|
1127
|
+
) : h(
|
|
1128
|
+
"div",
|
|
1129
|
+
{
|
|
1130
|
+
class: "flex"
|
|
1131
|
+
},
|
|
1132
|
+
h(
|
|
1133
|
+
"div",
|
|
1134
|
+
{
|
|
1135
|
+
class: ["fm-status-badge", Ne("PROCESSING")]
|
|
1136
|
+
},
|
|
1137
|
+
"Updated"
|
|
1138
|
+
)
|
|
1139
|
+
) : h(
|
|
1140
|
+
"div",
|
|
1141
|
+
{
|
|
1142
|
+
class: "flex"
|
|
1143
|
+
},
|
|
1144
|
+
h(
|
|
1145
|
+
"div",
|
|
1146
|
+
{
|
|
1147
|
+
class: ["fm-status-badge", Ne(M)]
|
|
1148
|
+
},
|
|
1149
|
+
Ie(M)
|
|
1150
|
+
)
|
|
1151
|
+
);
|
|
1152
|
+
}
|
|
1153
|
+
},
|
|
1154
|
+
{
|
|
1155
|
+
id: "updatedAt",
|
|
1156
|
+
accessorFn: (p) => p.updatedAt,
|
|
1157
|
+
header: () => o("inventory.closing.draft.table.lastUpdate"),
|
|
1158
|
+
enableSorting: !0,
|
|
1159
|
+
size: 200,
|
|
1160
|
+
cell(p) {
|
|
1161
|
+
var M;
|
|
1162
|
+
const g = p.row.original;
|
|
1163
|
+
return h("div", { class: "flex flex-col" }, [
|
|
1164
|
+
h(
|
|
1165
|
+
"div",
|
|
1166
|
+
{ class: "fm-typo-en-body-md-600 text-fm-color-typo-primary" },
|
|
1167
|
+
((M = g.updatedBy) == null ? void 0 : M.name) ?? ""
|
|
1168
|
+
),
|
|
1169
|
+
h(
|
|
1170
|
+
"div",
|
|
1171
|
+
{ class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" },
|
|
1172
|
+
Fe(g.updatedAt)
|
|
1173
|
+
)
|
|
1174
|
+
]);
|
|
1175
|
+
}
|
|
1176
|
+
},
|
|
1177
|
+
{
|
|
1178
|
+
id: "action",
|
|
1179
|
+
cell(p) {
|
|
1180
|
+
var z;
|
|
1181
|
+
const g = p.row.original, M = ((z = e.sessionUser.value) == null ? void 0 : z.role.isAdmin) ?? !1, H = [
|
|
1182
|
+
ao[Ye.Details],
|
|
1183
|
+
ao[Ye.Export]
|
|
1184
|
+
], de = [
|
|
1185
|
+
{
|
|
1186
|
+
translationKey: "inventory.closing.draft.approveDraft",
|
|
1187
|
+
color: "text-fm-color-typo-primary",
|
|
1188
|
+
value: fe.enum.approveDraft
|
|
1189
|
+
},
|
|
1190
|
+
{
|
|
1191
|
+
translationKey: "inventory.closing.draft.rejectDraft",
|
|
1192
|
+
color: "text-fm-color-typo-error",
|
|
1193
|
+
value: fe.enum.rejectDraft
|
|
1194
|
+
},
|
|
1195
|
+
{
|
|
1196
|
+
translationKey: "inventory.closing.draft.markAsFailed",
|
|
1197
|
+
color: "text-fm-color-typo-error",
|
|
1198
|
+
value: fe.enum.markAsFailed
|
|
1199
|
+
}
|
|
1200
|
+
], j = M && g.status !== xe.enum.DRAFT ? [
|
|
1201
|
+
{
|
|
1202
|
+
translationKey: "inventory.closing.draft.cloneDraft",
|
|
1203
|
+
color: "text-fm-color-typo-primary",
|
|
1204
|
+
value: Ye.Duplicate
|
|
1205
|
+
}
|
|
1206
|
+
] : [];
|
|
1207
|
+
return cn(
|
|
1208
|
+
[
|
|
1209
|
+
...H,
|
|
1210
|
+
...g.status === xe.enum.DRAFT ? de : []
|
|
1211
|
+
],
|
|
1212
|
+
(le) => ve(le, g),
|
|
1213
|
+
j
|
|
1214
|
+
);
|
|
1215
|
+
},
|
|
1216
|
+
enableSorting: !1,
|
|
1217
|
+
size: 40,
|
|
1218
|
+
meta: {
|
|
1219
|
+
cellClass: "",
|
|
1220
|
+
headerClass: ""
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
],
|
|
1224
|
+
drafts: i,
|
|
1225
|
+
loading: s,
|
|
1226
|
+
tableKey: r,
|
|
1227
|
+
dateRange: B,
|
|
1228
|
+
setDateRange: N,
|
|
1229
|
+
detailToRow: x,
|
|
1230
|
+
refreshDraftGroups: w,
|
|
1231
|
+
fetchDraftsPage: J,
|
|
1232
|
+
transformDrafts: X,
|
|
1233
|
+
refresh: O,
|
|
1234
|
+
onLocationChanged: F,
|
|
1235
|
+
loadDraft: T,
|
|
1236
|
+
updateDraftRef: re
|
|
1237
|
+
};
|
|
1238
|
+
}
|
|
1239
|
+
);
|
|
1240
|
+
function zn(t) {
|
|
1241
|
+
const o = /* @__PURE__ */ new Map();
|
|
1242
|
+
for (const e of t)
|
|
1243
|
+
for (const n of e) {
|
|
1244
|
+
const i = o.get(n.sku._id);
|
|
1245
|
+
if (!i) {
|
|
1246
|
+
o.set(n.sku._id, {
|
|
1247
|
+
...n,
|
|
1248
|
+
baseAmount: { ...n.baseAmount },
|
|
1249
|
+
measurementsAmounts: n.measurementsAmounts.map((r) => ({
|
|
1250
|
+
...r,
|
|
1251
|
+
amount: { ...r.amount }
|
|
1252
|
+
}))
|
|
1253
|
+
});
|
|
1254
|
+
continue;
|
|
1255
|
+
}
|
|
1256
|
+
i.baseAmount = tt(i.baseAmount, n.baseAmount);
|
|
1257
|
+
for (const r of n.measurementsAmounts) {
|
|
1258
|
+
const s = i.measurementsAmounts.findIndex(
|
|
1259
|
+
(u) => u.measurement.id === r.measurement.id
|
|
1260
|
+
);
|
|
1261
|
+
s > -1 ? i.measurementsAmounts[s].amount = tt(
|
|
1262
|
+
i.measurementsAmounts[s].amount,
|
|
1263
|
+
r.amount
|
|
1264
|
+
) : i.measurementsAmounts.push({ ...r, amount: { ...r.amount } });
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
return [...o.values()];
|
|
1268
|
+
}
|
|
1269
|
+
const On = { class: "fm-typo-en-heading-lg-600" }, Hn = { class: "py-4" }, Yn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary mb-4" }, Wn = { key: 0 }, Kn = { class: "flex flex-col gap-1 max-h-200 overflow-auto w-full mb-4" }, qn = {
|
|
1270
|
+
key: 0,
|
|
1271
|
+
class: "text-fm-color-system-success-300"
|
|
1272
|
+
}, Qn = {
|
|
1273
|
+
key: 1,
|
|
1274
|
+
class: "text-fm-color-system-error-300"
|
|
1275
|
+
}, Jn = { class: "fm-typo-en-body-md-400" }, Zn = { class: "mt-4 flex gap-4" }, Xn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary mb-4" }, ea = { key: 0 }, ta = { class: "mt-4 flex gap-4" }, oa = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary mb-4" }, na = { key: 0 }, aa = {
|
|
1276
|
+
key: 0,
|
|
1277
|
+
class: "mb-4"
|
|
1278
|
+
}, sa = { class: "flex flex-col gap-1 max-h-200 overflow-auto w-full" }, ra = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, la = {
|
|
1279
|
+
key: 0,
|
|
1280
|
+
class: "text-fm-color-system-success-300 mr-1"
|
|
1281
|
+
}, ia = {
|
|
1282
|
+
key: 1,
|
|
1283
|
+
class: "text-fm-color-system-error-300 mr-1"
|
|
1284
|
+
}, ca = { class: "fm-typo-en-body-md-400" }, ua = { class: "mt-4 flex gap-4" }, da = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary mb-4" }, ma = {
|
|
1285
|
+
key: 0,
|
|
1286
|
+
class: "flex gap-4"
|
|
1287
|
+
}, pa = { class: "fm-typo-en-heading-lg-600" }, fa = { class: "py-4 flex flex-col gap-4" }, va = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ga = { class: "flex gap-4 justify-end" }, Xe = 1, We = 2, Ke = 3, Ee = 4, ya = /* @__PURE__ */ Se({
|
|
1288
|
+
__name: "ClosingDraftApprovalDialog",
|
|
1289
|
+
props: {
|
|
1290
|
+
show: { type: Boolean },
|
|
1291
|
+
refreshing: { type: Boolean },
|
|
1292
|
+
approving: { type: Boolean },
|
|
1293
|
+
approvingAllGroups: { type: Boolean },
|
|
1294
|
+
draft: {},
|
|
1295
|
+
groups: {}
|
|
1296
|
+
},
|
|
1297
|
+
emits: ["update:show", "refresh", "approve", "approve-all-groups"],
|
|
1298
|
+
setup(t, { emit: o }) {
|
|
1299
|
+
const { FmStepper: e, FmStep: n, FmDialog: i, FmButton: r } = be, { t: s } = vn(), u = jt(), c = t, b = o, y = q(!1);
|
|
1300
|
+
function $() {
|
|
1301
|
+
y.value = !0;
|
|
1302
|
+
}
|
|
1303
|
+
function Q() {
|
|
1304
|
+
y.value = !1, b("approve-all-groups", "Bulk approval");
|
|
1305
|
+
}
|
|
1306
|
+
const V = S(
|
|
1307
|
+
() => {
|
|
1308
|
+
var j, z;
|
|
1309
|
+
return ((j = c.draft) == null ? void 0 : j.stockSnapshot) && ((z = c.draft) == null ? void 0 : z.stockSnapshot) !== void 0;
|
|
1310
|
+
}
|
|
1311
|
+
), B = S(() => {
|
|
1312
|
+
var le, ae, De;
|
|
1313
|
+
const j = ((le = c.draft) == null ? void 0 : le.items.map((he) => ({
|
|
1314
|
+
id: he.sku._id,
|
|
1315
|
+
code: he.sku.code,
|
|
1316
|
+
name: he.sku.name
|
|
1317
|
+
}))) ?? [], z = ((De = (ae = c.draft) == null ? void 0 : ae.negativeStockItems) == null ? void 0 : De.map((he) => ({
|
|
1318
|
+
id: he.sku._id,
|
|
1319
|
+
code: he.sku.code,
|
|
1320
|
+
name: he.sku.name
|
|
1321
|
+
}))) ?? [];
|
|
1322
|
+
return [...j, ...z].reduce(
|
|
1323
|
+
(he, je) => (he[je.id] = je, he),
|
|
1324
|
+
{}
|
|
1325
|
+
);
|
|
1326
|
+
}), I = S(
|
|
1327
|
+
() => {
|
|
1328
|
+
var j, z, le;
|
|
1329
|
+
return (((le = (z = (j = c.draft) == null ? void 0 : j.stockSnapshot) == null ? void 0 : z.filter((ae) => ae.balance.amount < 0)) == null ? void 0 : le.map((ae) => {
|
|
1330
|
+
const De = u.skuById[ae.id];
|
|
1331
|
+
return De ? {
|
|
1332
|
+
id: De._id,
|
|
1333
|
+
code: De.code,
|
|
1334
|
+
name: De.name
|
|
1335
|
+
} : null;
|
|
1336
|
+
})) ?? []).filter((ae) => ae !== null);
|
|
1337
|
+
}
|
|
1338
|
+
), N = S(() => {
|
|
1339
|
+
var j;
|
|
1340
|
+
return V.value ? ((j = I.value) == null ? void 0 : j.filter((z) => !B.value[z.id]).map((z) => z.id)) ?? [] : [];
|
|
1341
|
+
}), J = S({
|
|
1342
|
+
get: () => c.show,
|
|
1343
|
+
set: (j) => b("update:show", j)
|
|
1344
|
+
}), X = S(() => {
|
|
1345
|
+
var j;
|
|
1346
|
+
return (((j = c.groups) == null ? void 0 : j.length) ?? 0) > 0;
|
|
1347
|
+
}), O = S(
|
|
1348
|
+
() => {
|
|
1349
|
+
var j;
|
|
1350
|
+
return ((j = c.groups) == null ? void 0 : j.filter((z) => z.status !== xe.enum.COMPLETED)) ?? [];
|
|
1351
|
+
}
|
|
1352
|
+
), F = S(() => O.value.length === 0), T = S(
|
|
1353
|
+
() => {
|
|
1354
|
+
var j;
|
|
1355
|
+
return ((j = c.groups) == null ? void 0 : j.some(
|
|
1356
|
+
(z) => z.status === xe.enum.DRAFT || z.status === xe.enum.PENDING_APPROVAL
|
|
1357
|
+
)) ?? !1;
|
|
1358
|
+
}
|
|
1359
|
+
), k = q(Xe), w = () => k.value > Xe, x = () => k.value > We, re = () => k.value > Ke, _ = () => !1;
|
|
1360
|
+
function A(j) {
|
|
1361
|
+
return j === Xe ? !X.value : j === We ? V.value : j === Ke ? N.value.length == 0 : !1;
|
|
1362
|
+
}
|
|
1363
|
+
const L = S(() => !V.value || N.value.length > 0 || X.value && !F.value);
|
|
1364
|
+
function P() {
|
|
1365
|
+
let j = 1;
|
|
1366
|
+
for (; j < Ee && A(j); ) j++;
|
|
1367
|
+
return j;
|
|
1368
|
+
}
|
|
1369
|
+
const ve = S(() => k.value > P());
|
|
1370
|
+
function oe(j) {
|
|
1371
|
+
let z = j + 1;
|
|
1372
|
+
for (; z <= Ee && A(z); ) z++;
|
|
1373
|
+
return z > Ee ? Ee : z;
|
|
1374
|
+
}
|
|
1375
|
+
function R(j) {
|
|
1376
|
+
let z = j - 1;
|
|
1377
|
+
for (; z >= 1 && A(z); ) z--;
|
|
1378
|
+
const le = P();
|
|
1379
|
+
return z < le ? le : z;
|
|
1380
|
+
}
|
|
1381
|
+
function p() {
|
|
1382
|
+
return P();
|
|
1383
|
+
}
|
|
1384
|
+
Te(
|
|
1385
|
+
() => c.show,
|
|
1386
|
+
(j) => {
|
|
1387
|
+
j && (k.value = p());
|
|
1388
|
+
}
|
|
1389
|
+
), Te(
|
|
1390
|
+
() => V.value,
|
|
1391
|
+
(j) => {
|
|
1392
|
+
j && k.value === We && (k.value = oe(We));
|
|
1393
|
+
}
|
|
1394
|
+
), Te(
|
|
1395
|
+
() => N.value.length,
|
|
1396
|
+
(j) => {
|
|
1397
|
+
j === 0 && k.value === Ke && (k.value = oe(Ke));
|
|
1398
|
+
}
|
|
1399
|
+
);
|
|
1400
|
+
function g() {
|
|
1401
|
+
b("refresh");
|
|
1402
|
+
}
|
|
1403
|
+
function M() {
|
|
1404
|
+
k.value < Ee && (k.value = oe(k.value));
|
|
1405
|
+
}
|
|
1406
|
+
function H() {
|
|
1407
|
+
k.value > 1 && (k.value = R(k.value));
|
|
1408
|
+
}
|
|
1409
|
+
function de() {
|
|
1410
|
+
b("approve");
|
|
1411
|
+
}
|
|
1412
|
+
return (j, z) => {
|
|
1413
|
+
const le = ee("FmIcon");
|
|
1414
|
+
return f(), C(ie, null, [
|
|
1415
|
+
D(d(i), {
|
|
1416
|
+
modelValue: J.value,
|
|
1417
|
+
"onUpdate:modelValue": z[1] || (z[1] = (ae) => J.value = ae),
|
|
1418
|
+
"max-width": 600
|
|
1419
|
+
}, {
|
|
1420
|
+
"dialog-header": te(() => [
|
|
1421
|
+
a("div", On, E(d(s)("inventory.closing.approval.title")), 1)
|
|
1422
|
+
]),
|
|
1423
|
+
default: te(() => [
|
|
1424
|
+
a("div", Hn, [
|
|
1425
|
+
D(d(e), {
|
|
1426
|
+
modelValue: k.value,
|
|
1427
|
+
"onUpdate:modelValue": z[0] || (z[0] = (ae) => k.value = ae),
|
|
1428
|
+
orientation: "vertical"
|
|
1429
|
+
}, {
|
|
1430
|
+
default: te(() => [
|
|
1431
|
+
X.value ? (f(), ne(d(n), {
|
|
1432
|
+
key: 0,
|
|
1433
|
+
value: Xe,
|
|
1434
|
+
title: d(s)("inventory.closing.approval.step.groups.title"),
|
|
1435
|
+
complete: w
|
|
1436
|
+
}, {
|
|
1437
|
+
default: te(() => [
|
|
1438
|
+
a("div", Yn, E(F.value ? d(s)("inventory.closing.approval.step.groups.completedMessage") : d(s)("inventory.closing.approval.step.groups.pendingMessage")), 1),
|
|
1439
|
+
k.value === Xe ? (f(), C("div", Wn, [
|
|
1440
|
+
a("div", Kn, [
|
|
1441
|
+
(f(!0), C(ie, null, _e(j.groups ?? [], (ae) => (f(), C("div", {
|
|
1442
|
+
key: ae._id,
|
|
1443
|
+
class: "flex gap-8 items-center"
|
|
1444
|
+
}, [
|
|
1445
|
+
ae.status === d(xe).enum.COMPLETED ? (f(), C("span", qn, [
|
|
1446
|
+
D(le, {
|
|
1447
|
+
name: "check_circle",
|
|
1448
|
+
size: "sm"
|
|
1449
|
+
})
|
|
1450
|
+
])) : (f(), C("span", Qn, [
|
|
1451
|
+
D(le, {
|
|
1452
|
+
name: "error",
|
|
1453
|
+
size: "sm"
|
|
1454
|
+
})
|
|
1455
|
+
])),
|
|
1456
|
+
a("div", Jn, E(d(xt)(ae)), 1)
|
|
1457
|
+
]))), 128))
|
|
1458
|
+
]),
|
|
1459
|
+
a("div", Zn, [
|
|
1460
|
+
T.value ? (f(), ne(d(r), {
|
|
1461
|
+
key: 0,
|
|
1462
|
+
label: d(s)("inventory.closing.approval.step.groups.approveAll"),
|
|
1463
|
+
variant: "secondary",
|
|
1464
|
+
loading: j.approvingAllGroups,
|
|
1465
|
+
disabled: j.approvingAllGroups,
|
|
1466
|
+
onClick: $
|
|
1467
|
+
}, null, 8, ["label", "loading", "disabled"])) : W("", !0),
|
|
1468
|
+
D(d(r), {
|
|
1469
|
+
label: d(s)("inventory.common.continue"),
|
|
1470
|
+
disabled: !F.value,
|
|
1471
|
+
onClick: M
|
|
1472
|
+
}, null, 8, ["label", "disabled"])
|
|
1473
|
+
])
|
|
1474
|
+
])) : W("", !0)
|
|
1475
|
+
]),
|
|
1476
|
+
_: 1
|
|
1477
|
+
}, 8, ["title"])) : W("", !0),
|
|
1478
|
+
D(d(n), {
|
|
1479
|
+
value: We,
|
|
1480
|
+
title: d(s)("inventory.closing.approval.step.generateReport.title"),
|
|
1481
|
+
disabled: () => X.value && !F.value,
|
|
1482
|
+
complete: x
|
|
1483
|
+
}, {
|
|
1484
|
+
default: te(() => [
|
|
1485
|
+
a("div", Xn, E(d(s)("inventory.closing.approval.step.generateReport.description")), 1),
|
|
1486
|
+
k.value === We ? (f(), C("div", ea, [
|
|
1487
|
+
D(d(r), {
|
|
1488
|
+
label: d(s)("inventory.stock.stock_balance.refreshBalance"),
|
|
1489
|
+
"prepend-icon": "refresh",
|
|
1490
|
+
variant: "secondary",
|
|
1491
|
+
loading: j.refreshing,
|
|
1492
|
+
disabled: j.refreshing,
|
|
1493
|
+
onClick: g
|
|
1494
|
+
}, null, 8, ["label", "loading", "disabled"]),
|
|
1495
|
+
a("div", ta, [
|
|
1496
|
+
ve.value ? (f(), ne(d(r), {
|
|
1497
|
+
key: 0,
|
|
1498
|
+
label: d(s)("inventory.common.back"),
|
|
1499
|
+
variant: "secondary",
|
|
1500
|
+
onClick: H
|
|
1501
|
+
}, null, 8, ["label"])) : W("", !0),
|
|
1502
|
+
D(d(r), {
|
|
1503
|
+
label: d(s)("inventory.common.continue"),
|
|
1504
|
+
disabled: !V.value,
|
|
1505
|
+
onClick: M
|
|
1506
|
+
}, null, 8, ["label", "disabled"])
|
|
1507
|
+
])
|
|
1508
|
+
])) : W("", !0)
|
|
1509
|
+
]),
|
|
1510
|
+
_: 1
|
|
1511
|
+
}, 8, ["title", "disabled"]),
|
|
1512
|
+
D(d(n), {
|
|
1513
|
+
value: Ke,
|
|
1514
|
+
title: d(s)("inventory.closing.approval.step.negativeItems.title"),
|
|
1515
|
+
disabled: () => !V.value,
|
|
1516
|
+
complete: re
|
|
1517
|
+
}, {
|
|
1518
|
+
default: te(() => [
|
|
1519
|
+
a("div", oa, E(I.value.length > 0 ? `${d(s)("inventory.closing.approval.step.negativeItems.resolveMessage")} [${d(s)("inventory.closing.approval.step.negativeItems.itemsHeader")} (${N.value.length})]` : d(s)("inventory.closing.approval.step.negativeItems.noItemsMessage")), 1),
|
|
1520
|
+
k.value === Ke ? (f(), C("div", na, [
|
|
1521
|
+
I.value.length > 0 ? (f(), C("div", aa, [
|
|
1522
|
+
z[4] || (z[4] = a("div", { class: "fm-typo-en-body-md-600 mb-2" }, null, -1)),
|
|
1523
|
+
a("div", sa, [
|
|
1524
|
+
(f(!0), C(ie, null, _e(I.value, (ae) => (f(), C("div", {
|
|
1525
|
+
key: ae.id,
|
|
1526
|
+
class: "flex gap-8"
|
|
1527
|
+
}, [
|
|
1528
|
+
a("div", ra, [
|
|
1529
|
+
B.value[ae.id] ? (f(), C("span", la, [
|
|
1530
|
+
D(le, {
|
|
1531
|
+
name: "check_circle",
|
|
1532
|
+
size: "sm"
|
|
1533
|
+
})
|
|
1534
|
+
])) : (f(), C("span", ia, [
|
|
1535
|
+
D(le, {
|
|
1536
|
+
name: "error",
|
|
1537
|
+
size: "sm"
|
|
1538
|
+
})
|
|
1539
|
+
])),
|
|
1540
|
+
ge(" " + E(ae.code), 1)
|
|
1541
|
+
]),
|
|
1542
|
+
a("div", ca, E(ae.name), 1)
|
|
1543
|
+
]))), 128))
|
|
1544
|
+
])
|
|
1545
|
+
])) : W("", !0),
|
|
1546
|
+
a("div", ua, [
|
|
1547
|
+
ve.value ? (f(), ne(d(r), {
|
|
1548
|
+
key: 0,
|
|
1549
|
+
label: d(s)("inventory.common.back"),
|
|
1550
|
+
variant: "secondary",
|
|
1551
|
+
onClick: H
|
|
1552
|
+
}, null, 8, ["label"])) : W("", !0),
|
|
1553
|
+
D(d(r), {
|
|
1554
|
+
label: d(s)("inventory.common.continue"),
|
|
1555
|
+
disabled: L.value,
|
|
1556
|
+
onClick: M
|
|
1557
|
+
}, null, 8, ["label", "disabled"])
|
|
1558
|
+
])
|
|
1559
|
+
])) : W("", !0)
|
|
1560
|
+
]),
|
|
1561
|
+
_: 1
|
|
1562
|
+
}, 8, ["title", "disabled"]),
|
|
1563
|
+
D(d(n), {
|
|
1564
|
+
value: Ee,
|
|
1565
|
+
title: d(s)("inventory.closing.approval.step.approval.title"),
|
|
1566
|
+
disabled: () => L.value,
|
|
1567
|
+
complete: _
|
|
1568
|
+
}, {
|
|
1569
|
+
default: te(() => [
|
|
1570
|
+
a("div", da, E(d(s)("inventory.closing.approval.step.approval.warning")), 1),
|
|
1571
|
+
k.value === Ee ? (f(), C("div", ma, [
|
|
1572
|
+
ve.value ? (f(), ne(d(r), {
|
|
1573
|
+
key: 0,
|
|
1574
|
+
label: d(s)("inventory.common.back"),
|
|
1575
|
+
variant: "secondary",
|
|
1576
|
+
onClick: H
|
|
1577
|
+
}, null, 8, ["label"])) : W("", !0),
|
|
1578
|
+
D(d(r), {
|
|
1579
|
+
label: d(s)("inventory.common.approve"),
|
|
1580
|
+
variant: "destructive",
|
|
1581
|
+
disabled: L.value,
|
|
1582
|
+
loading: j.approving,
|
|
1583
|
+
onClick: de
|
|
1584
|
+
}, null, 8, ["label", "disabled", "loading"])
|
|
1585
|
+
])) : W("", !0)
|
|
1586
|
+
]),
|
|
1587
|
+
_: 1
|
|
1588
|
+
}, 8, ["title", "disabled"])
|
|
1589
|
+
]),
|
|
1590
|
+
_: 1
|
|
1591
|
+
}, 8, ["modelValue"])
|
|
1592
|
+
])
|
|
1593
|
+
]),
|
|
1594
|
+
_: 1
|
|
1595
|
+
}, 8, ["modelValue"]),
|
|
1596
|
+
D(d(i), {
|
|
1597
|
+
modelValue: y.value,
|
|
1598
|
+
"onUpdate:modelValue": z[3] || (z[3] = (ae) => y.value = ae),
|
|
1599
|
+
"max-width": 480
|
|
1600
|
+
}, {
|
|
1601
|
+
"dialog-header": te(() => [
|
|
1602
|
+
a("div", pa, E(d(s)("inventory.closing.approval.step.groups.approveAllConfirm.title")), 1)
|
|
1603
|
+
]),
|
|
1604
|
+
default: te(() => [
|
|
1605
|
+
a("div", fa, [
|
|
1606
|
+
a("div", va, E(d(s)("inventory.closing.approval.step.groups.approveAllConfirm.warning")), 1),
|
|
1607
|
+
a("div", ga, [
|
|
1608
|
+
D(d(r), {
|
|
1609
|
+
label: d(s)("inventory.common.cancel"),
|
|
1610
|
+
variant: "secondary",
|
|
1611
|
+
onClick: z[2] || (z[2] = (ae) => y.value = !1)
|
|
1612
|
+
}, null, 8, ["label"]),
|
|
1613
|
+
D(d(r), {
|
|
1614
|
+
label: d(s)("inventory.closing.approval.step.groups.approveAllConfirm.confirm"),
|
|
1615
|
+
variant: "destructive",
|
|
1616
|
+
onClick: Q
|
|
1617
|
+
}, null, 8, ["label"])
|
|
1618
|
+
])
|
|
1619
|
+
])
|
|
1620
|
+
]),
|
|
1621
|
+
_: 1
|
|
1622
|
+
}, 8, ["modelValue"])
|
|
1623
|
+
], 64);
|
|
1624
|
+
};
|
|
1625
|
+
}
|
|
1626
|
+
});
|
|
1627
|
+
function ba(t) {
|
|
1628
|
+
const o = Ge(), e = yn(), n = Ue(), { t: i } = ot(), r = q(!1), s = q(null);
|
|
1629
|
+
let u = !1, c = null, b = !1, y = !1;
|
|
1630
|
+
function $() {
|
|
1631
|
+
N();
|
|
1632
|
+
const O = t.closingDraftId.value, F = t.currentRev.value;
|
|
1633
|
+
if (!O || !F)
|
|
1634
|
+
return;
|
|
1635
|
+
u = !1;
|
|
1636
|
+
const T = {
|
|
1637
|
+
type: "closing-draft",
|
|
1638
|
+
params: {
|
|
1639
|
+
draftId: O,
|
|
1640
|
+
locationId: o.getDbName(),
|
|
1641
|
+
closingDraftRevision: F
|
|
1642
|
+
}
|
|
1643
|
+
}, { unsubscribe: k, initialState: w } = e.subscribe(T, V);
|
|
1644
|
+
c = k, w.then((x) => {
|
|
1645
|
+
x != null && x.initialState && V(x.initialState);
|
|
1646
|
+
}).catch((x) => {
|
|
1647
|
+
console.error("Failed to fetch initial state", x);
|
|
1648
|
+
});
|
|
1649
|
+
}
|
|
1650
|
+
function Q() {
|
|
1651
|
+
y = !0, $();
|
|
1652
|
+
}
|
|
1653
|
+
async function V(O) {
|
|
1654
|
+
var T;
|
|
1655
|
+
if (u || !O) {
|
|
1656
|
+
s.value = O, r.value = !1;
|
|
1657
|
+
return;
|
|
1658
|
+
}
|
|
1659
|
+
if (O.closingDraftId && O.closingDraftId !== t.closingDraftId.value)
|
|
1660
|
+
return;
|
|
1661
|
+
if (s.value = O, O.message === "processing" || !O.completedAt && !O.message) {
|
|
1662
|
+
b = !0, r.value = !0;
|
|
1663
|
+
return;
|
|
1664
|
+
}
|
|
1665
|
+
if (O.message === "completed" || O.completedAt) {
|
|
1666
|
+
if (!b) {
|
|
1667
|
+
r.value = !1;
|
|
1668
|
+
return;
|
|
1669
|
+
}
|
|
1670
|
+
b = !1, await B();
|
|
1671
|
+
return;
|
|
1672
|
+
}
|
|
1673
|
+
const F = b;
|
|
1674
|
+
b = !1, r.value = !1, F && (console.log("Closing draft balance refresh error:", O), n.open({
|
|
1675
|
+
title: i("inventory.common.refreshFailed"),
|
|
1676
|
+
message: i("inventory.stock.stock_balance.refreshBalanceError"),
|
|
1677
|
+
type: "error"
|
|
1678
|
+
}), (T = t.onError) == null || T.call(t, O.message ?? "Unknown error"));
|
|
1679
|
+
}
|
|
1680
|
+
async function B() {
|
|
1681
|
+
const O = t.closingDraftId.value;
|
|
1682
|
+
if (!O) {
|
|
1683
|
+
r.value = !1;
|
|
1684
|
+
return;
|
|
1685
|
+
}
|
|
1686
|
+
try {
|
|
1687
|
+
const F = await o.getDraft(O);
|
|
1688
|
+
r.value = !1, t.onCompleted(F), n.open({
|
|
1689
|
+
title: "Balance refreshed",
|
|
1690
|
+
message: "Stock balance has been recalculated.",
|
|
1691
|
+
type: "success"
|
|
1692
|
+
});
|
|
1693
|
+
} catch {
|
|
1694
|
+
r.value = !1, n.open({
|
|
1695
|
+
title: "Refresh completed",
|
|
1696
|
+
message: "Balance was refreshed but failed to load updated data. Please reload.",
|
|
1697
|
+
type: "warning"
|
|
1698
|
+
});
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
async function I(O) {
|
|
1702
|
+
if (!(!t.closingDraftId.value || r.value || b)) {
|
|
1703
|
+
r.value = !0, b = !0, s.value = {
|
|
1704
|
+
requestId: "",
|
|
1705
|
+
closingDraftId: t.closingDraftId.value,
|
|
1706
|
+
closingDraftRevision: t.currentRev.value ?? "",
|
|
1707
|
+
message: "processing",
|
|
1708
|
+
startedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1709
|
+
};
|
|
1710
|
+
try {
|
|
1711
|
+
await o.initializeStockSnapshot(t.closingDraftId.value, O);
|
|
1712
|
+
} catch (F) {
|
|
1713
|
+
b = !1, r.value = !1, n.open({
|
|
1714
|
+
title: i("inventory.common.refreshFailed"),
|
|
1715
|
+
message: i("inventory.stock.stock_balance.refreshBalanceError"),
|
|
1716
|
+
type: "error"
|
|
1717
|
+
}), console.error("error starting refresh", F);
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
function N() {
|
|
1722
|
+
u = !1, c && (c(), c = null);
|
|
1723
|
+
}
|
|
1724
|
+
function J() {
|
|
1725
|
+
N(), u = !0, r.value = !1, b = !1, s.value = null;
|
|
1726
|
+
}
|
|
1727
|
+
function X() {
|
|
1728
|
+
y = !1, J();
|
|
1729
|
+
}
|
|
1730
|
+
return Te(
|
|
1731
|
+
[t.closingDraftId, t.currentRev],
|
|
1732
|
+
([O, F], [T, k]) => {
|
|
1733
|
+
y && (O === T && F === k || $());
|
|
1734
|
+
}
|
|
1735
|
+
), Go(() => {
|
|
1736
|
+
X();
|
|
1737
|
+
}), {
|
|
1738
|
+
refreshing: r,
|
|
1739
|
+
refreshStatus: s,
|
|
1740
|
+
startListening: Q,
|
|
1741
|
+
startRefresh: I,
|
|
1742
|
+
cleanup: X
|
|
1743
|
+
};
|
|
1744
|
+
}
|
|
1745
|
+
function ha(t) {
|
|
1746
|
+
const o = Nt(t);
|
|
1747
|
+
return o === "REJECTED" ? { label: "Rejected", className: Ne("FAILED") } : o === "UPDATED" ? { label: "Updated", className: Ne("PROCESSING") } : { label: Ie(o), className: Ne(o) };
|
|
1748
|
+
}
|
|
1749
|
+
const _a = { class: "flex items-start justify-between gap-8" }, ka = { class: "flex items-center gap-8 min-w-0" }, xa = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary truncate" }, wa = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary" }, Da = { class: "fm-typo-en-body-md-600" }, Aa = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-tertiary" }, $a = /* @__PURE__ */ Se({
|
|
1750
|
+
__name: "ClosingGroupCard",
|
|
1751
|
+
props: {
|
|
1752
|
+
group: {}
|
|
1753
|
+
},
|
|
1754
|
+
emits: ["select"],
|
|
1755
|
+
setup(t, { emit: o }) {
|
|
1756
|
+
const e = t, n = o, i = S(() => ha(e.group)), r = S(
|
|
1757
|
+
() => `RM ${e.group.totalAmount.toLocaleString("en-MY", {
|
|
1758
|
+
minimumFractionDigits: 2,
|
|
1759
|
+
maximumFractionDigits: 2
|
|
1760
|
+
})}`
|
|
1761
|
+
), s = S(() => {
|
|
1762
|
+
const u = e.group.updatedBy ?? "—", c = e.group.updatedAt ? Fe(e.group.updatedAt) : "—";
|
|
1763
|
+
return `Last updated by ${u} · ${c}`;
|
|
1764
|
+
});
|
|
1765
|
+
return (u, c) => (f(), C("div", {
|
|
1766
|
+
class: "flex flex-col gap-8 rounded-lg border border-fm-color-neutral-gray-200 bg-white p-16 cursor-pointer hover:border-fm-color-primary",
|
|
1767
|
+
onClick: c[0] || (c[0] = zo((b) => n("select", u.group.id), ["stop"]))
|
|
1768
|
+
}, [
|
|
1769
|
+
a("div", _a, [
|
|
1770
|
+
a("div", ka, [
|
|
1771
|
+
u.group.color ? (f(), C("span", {
|
|
1772
|
+
key: 0,
|
|
1773
|
+
class: "w-8 h-8 rounded-full shrink-0",
|
|
1774
|
+
style: gt({ backgroundColor: u.group.color })
|
|
1775
|
+
}, null, 4)) : W("", !0),
|
|
1776
|
+
a("span", xa, E(u.group.name), 1)
|
|
1777
|
+
]),
|
|
1778
|
+
a("div", {
|
|
1779
|
+
class: we(["fm-status-badge shrink-0", i.value.className])
|
|
1780
|
+
}, E(i.value.label), 3)
|
|
1781
|
+
]),
|
|
1782
|
+
a("div", wa, [
|
|
1783
|
+
a("span", Da, E(u.group.itemCount), 1),
|
|
1784
|
+
ge(" items · " + E(r.value), 1)
|
|
1785
|
+
]),
|
|
1786
|
+
c[1] || (c[1] = a("div", { class: "border-t border-dashed border-fm-color-neutral-gray-200" }, null, -1)),
|
|
1787
|
+
a("div", Aa, E(s.value), 1)
|
|
1788
|
+
]));
|
|
1789
|
+
}
|
|
1790
|
+
}), Ca = {
|
|
1791
|
+
key: 0,
|
|
1792
|
+
class: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-16"
|
|
1793
|
+
}, Sa = {
|
|
1794
|
+
key: 1,
|
|
1795
|
+
class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
|
|
1796
|
+
}, Fa = /* @__PURE__ */ Se({
|
|
1797
|
+
__name: "ClosingGroupGrid",
|
|
1798
|
+
props: {
|
|
1799
|
+
groups: {}
|
|
1800
|
+
},
|
|
1801
|
+
emits: ["select"],
|
|
1802
|
+
setup(t, { emit: o }) {
|
|
1803
|
+
const e = o;
|
|
1804
|
+
return (n, i) => n.groups.length ? (f(), C("div", Ca, [
|
|
1805
|
+
(f(!0), C(ie, null, _e(n.groups, (r) => (f(), ne($a, {
|
|
1806
|
+
key: r.id,
|
|
1807
|
+
group: r,
|
|
1808
|
+
onSelect: i[0] || (i[0] = (s) => e("select", s))
|
|
1809
|
+
}, null, 8, ["group"]))), 128))
|
|
1810
|
+
])) : (f(), C("div", Sa, "No closing groups"));
|
|
1811
|
+
}
|
|
1812
|
+
});
|
|
1813
|
+
function ho(t, o) {
|
|
1814
|
+
const e = t.sku, n = [], i = Number(se.toFormatString({ value: t.baseAmount }));
|
|
1815
|
+
i && n.push({
|
|
1816
|
+
label: "Base",
|
|
1817
|
+
amount: i,
|
|
1818
|
+
abbrev: e.unit.abbrev,
|
|
1819
|
+
subtotal: i,
|
|
1820
|
+
inactive: !1,
|
|
1821
|
+
orphan: !1,
|
|
1822
|
+
counted: !0
|
|
1823
|
+
});
|
|
1824
|
+
const r = new Map(
|
|
1825
|
+
t.measurementsAmounts.map((c) => [c.measurement.id, c.amount])
|
|
1826
|
+
), s = new Set(e.unit.measurements.map((c) => c.id)), u = (c, b, y, $, Q) => {
|
|
1827
|
+
const V = Number(se.toFormatString({ value: y }));
|
|
1828
|
+
if (!V) return;
|
|
1829
|
+
const B = se.toFormatString({ value: b }), I = Number(
|
|
1830
|
+
se.toFormatString({
|
|
1831
|
+
value: ht(y, b)
|
|
1832
|
+
})
|
|
1833
|
+
);
|
|
1834
|
+
n.push({
|
|
1835
|
+
label: Q ? `${V} ${c}` : `${V} ${c} × ${B} ${e.unit.abbrev}`,
|
|
1836
|
+
amount: V,
|
|
1837
|
+
abbrev: c,
|
|
1838
|
+
subtotal: I,
|
|
1839
|
+
inactive: $,
|
|
1840
|
+
orphan: Q,
|
|
1841
|
+
counted: !Q
|
|
1842
|
+
});
|
|
1843
|
+
};
|
|
1844
|
+
for (const c of e.unit.measurements) {
|
|
1845
|
+
const b = r.get(c.id);
|
|
1846
|
+
b && u(c.abbrev, c.conversion, b, Rt(c, o), !1);
|
|
1847
|
+
}
|
|
1848
|
+
for (const c of t.measurementsAmounts)
|
|
1849
|
+
s.has(c.measurement.id) || u(c.measurement.abbrev, c.measurement.conversion, c.amount, !1, !0);
|
|
1850
|
+
return n;
|
|
1851
|
+
}
|
|
1852
|
+
const ft = (t) => me(t, { minPrecision: 0, maxPrecision: 3 });
|
|
1853
|
+
function Ia(t, o) {
|
|
1854
|
+
return o ? "text-fm-color-system-error-300" : t ? "text-purple-500" : "";
|
|
1855
|
+
}
|
|
1856
|
+
function Ba(t, o) {
|
|
1857
|
+
return o ? h(be.FmIcon, { name: "warning", size: "sm", color: "system-error-300" }) : t ? h(be.FmIcon, { name: "rule", size: "sm" }) : null;
|
|
1858
|
+
}
|
|
1859
|
+
function _o(t, o, e) {
|
|
1860
|
+
return h(
|
|
1861
|
+
"div",
|
|
1862
|
+
{
|
|
1863
|
+
class: "p-12 flex flex-col gap-4 fm-typo-en-body-md-400 min-w-[280px] max-w-[420px]"
|
|
1864
|
+
},
|
|
1865
|
+
[
|
|
1866
|
+
h("div", { class: "fm-typo-en-body-sm-600 text-fm-color-typo-secondary mb-4" }, "Breakdown"),
|
|
1867
|
+
...t.map(
|
|
1868
|
+
(n) => h("div", { class: "flex justify-between gap-12" }, [
|
|
1869
|
+
h(
|
|
1870
|
+
"div",
|
|
1871
|
+
{ class: ["flex items-center gap-4", Ia(n.inactive, n.orphan)] },
|
|
1872
|
+
[Ba(n.inactive, n.orphan), h("span", n.label)]
|
|
1873
|
+
),
|
|
1874
|
+
h(
|
|
1875
|
+
"div",
|
|
1876
|
+
{ class: n.counted ? "" : "line-through text-fm-color-typo-tertiary" },
|
|
1877
|
+
n.orphan ? `${ft(n.amount)} ${n.abbrev} (no valid conversion)` : n.counted ? `${ft(n.subtotal)} ${e}` : `${ft(n.subtotal)} ${e} (ignored)`
|
|
1878
|
+
)
|
|
1879
|
+
])
|
|
1880
|
+
),
|
|
1881
|
+
h("hr", { class: "border-fm-color-typo-secondary my-4" }),
|
|
1882
|
+
h("div", { class: "flex justify-between fm-typo-en-body-lg-600" }, [
|
|
1883
|
+
h("span", "Total"),
|
|
1884
|
+
h("span", `${ft(o)} ${e}`)
|
|
1885
|
+
])
|
|
1886
|
+
]
|
|
1887
|
+
);
|
|
1888
|
+
}
|
|
1889
|
+
function Ut(t, o) {
|
|
1890
|
+
const e = t.sku, n = Number(se.toFormatString({ value: t.baseAmount })), i = new Map(
|
|
1891
|
+
t.measurementsAmounts.map((c) => [c.measurement.id, c.amount])
|
|
1892
|
+
), r = new Set(e.unit.measurements.map((c) => c.id)), s = [], u = (c, b, y, $, Q) => {
|
|
1893
|
+
const V = Number(se.toFormatString({ value: y })), B = se.toFormatString({ value: b });
|
|
1894
|
+
s.push({
|
|
1895
|
+
abbrev: `(${c}) × ${B}`,
|
|
1896
|
+
amount: V,
|
|
1897
|
+
variant: Q ? "orphan" : $ ? "inactive" : "normal"
|
|
1898
|
+
});
|
|
1899
|
+
};
|
|
1900
|
+
for (const c of e.unit.measurements) {
|
|
1901
|
+
const b = i.get(c.id);
|
|
1902
|
+
b && u(c.abbrev, c.conversion, b, Rt(c, o), !1);
|
|
1903
|
+
}
|
|
1904
|
+
for (const c of t.measurementsAmounts)
|
|
1905
|
+
r.has(c.measurement.id) || u(c.measurement.abbrev, c.measurement.conversion, c.amount, !1, !0);
|
|
1906
|
+
return { baseUnitAmount: n, measurements: s };
|
|
1907
|
+
}
|
|
1908
|
+
function so(t, o, e) {
|
|
1909
|
+
const n = t.sku, { baseUnitAmount: i, measurements: r } = Ut(t, e);
|
|
1910
|
+
return {
|
|
1911
|
+
id: n._id,
|
|
1912
|
+
code: n.code,
|
|
1913
|
+
name: n.name,
|
|
1914
|
+
baseUnit: n.unit.abbrev,
|
|
1915
|
+
baseUnitAmount: i,
|
|
1916
|
+
isTemplateItem: o,
|
|
1917
|
+
measurements: r,
|
|
1918
|
+
physicalBalance: Number(se.toFormatString({ value: kt(t) })),
|
|
1919
|
+
breakdown: ho(t, e)
|
|
1920
|
+
};
|
|
1921
|
+
}
|
|
1922
|
+
function Ta(t, o) {
|
|
1923
|
+
const e = [
|
|
1924
|
+
...t.items.map((n) => so(n, !0, o)),
|
|
1925
|
+
...(t.negativeStockItems ?? []).map((n) => so(n, !1, o))
|
|
1926
|
+
];
|
|
1927
|
+
return e.sort((n, i) => n.code.localeCompare(i.code)), e;
|
|
1928
|
+
}
|
|
1929
|
+
function Pt(t, o, e) {
|
|
1930
|
+
const n = (s, u, c = "normal") => h(
|
|
1931
|
+
be.FmTooltip,
|
|
1932
|
+
{ zIndex: 50 },
|
|
1933
|
+
{
|
|
1934
|
+
default() {
|
|
1935
|
+
return h(
|
|
1936
|
+
"div",
|
|
1937
|
+
{
|
|
1938
|
+
class: [
|
|
1939
|
+
"fm-typo-en-body-lg-400 py-4 px-8 fm-corner-radius-md line-clamp-1 border-1",
|
|
1940
|
+
c === "orphan" ? "border-fm-color-system-error-300" : c === "inactive" ? "border-purple-500" : "border-fm-color-typo-secondary"
|
|
1941
|
+
]
|
|
1942
|
+
},
|
|
1943
|
+
[
|
|
1944
|
+
h("span", { class: "text-fm-color-typo-primary" }, `${s} `),
|
|
1945
|
+
h(
|
|
1946
|
+
"span",
|
|
1947
|
+
{ class: "text-fm-color-typo-secondary", style: { maxWidth: "80px" } },
|
|
1948
|
+
u
|
|
1949
|
+
)
|
|
1950
|
+
]
|
|
1951
|
+
);
|
|
1952
|
+
},
|
|
1953
|
+
content() {
|
|
1954
|
+
return c === "orphan" ? `${s} ${u} (invalid UOM — not on SKU)` : c === "inactive" ? `${s} ${u} (NetSuite-inactive UOM)` : `${s} ${u}`;
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
), i = e.filter((s) => !!s.amount).map((s) => n(s.amount, s.abbrev, s.variant)), r = t || !i.length ? [n(t, o), ...i] : i;
|
|
1958
|
+
return h(
|
|
1959
|
+
"div",
|
|
1960
|
+
{ class: "flex gap-8 flex-nowrap", style: { minWidth: `${120 * r.length}px` } },
|
|
1961
|
+
r
|
|
1962
|
+
);
|
|
1963
|
+
}
|
|
1964
|
+
function ja(t, o, e) {
|
|
1965
|
+
const n = [];
|
|
1966
|
+
for (const i of o) {
|
|
1967
|
+
const r = i.items.find((b) => b.sku._id === t);
|
|
1968
|
+
if (!r) continue;
|
|
1969
|
+
const { baseUnitAmount: s, measurements: u } = Ut(r, e);
|
|
1970
|
+
(s !== 0 || u.some((b) => b.amount !== 0)) && n.push({ label: i.label, isSub: i.isSub, baseUnitAmount: s, measurements: u });
|
|
1971
|
+
}
|
|
1972
|
+
return n;
|
|
1973
|
+
}
|
|
1974
|
+
function Ra(t, o) {
|
|
1975
|
+
return h(
|
|
1976
|
+
"div",
|
|
1977
|
+
{ class: "flex flex-col gap-8" },
|
|
1978
|
+
t.map(
|
|
1979
|
+
(e) => h("div", { class: "flex flex-col gap-4" }, [
|
|
1980
|
+
h(
|
|
1981
|
+
"div",
|
|
1982
|
+
{ class: "fm-typo-en-body-sm-600 text-fm-color-typo-tertiary uppercase" },
|
|
1983
|
+
e.label
|
|
1984
|
+
),
|
|
1985
|
+
Pt(e.baseUnitAmount, o, e.measurements)
|
|
1986
|
+
])
|
|
1987
|
+
)
|
|
1988
|
+
);
|
|
1989
|
+
}
|
|
1990
|
+
const Ma = "N/A";
|
|
1991
|
+
function ko(t, o) {
|
|
1992
|
+
var n, i;
|
|
1993
|
+
const e = t.approvedAt ? {
|
|
1994
|
+
action: `Approve at ${Fe(t.approvedAt)}`,
|
|
1995
|
+
actionBy: t.approvedBy,
|
|
1996
|
+
remark: t.approveRemark
|
|
1997
|
+
} : (n = t.rejectionHistory) == null ? void 0 : n.computeFirst((r) => ({
|
|
1998
|
+
action: `Reject at ${Fe(r.rejectedAt)}`,
|
|
1999
|
+
actionBy: r.rejectedBy,
|
|
2000
|
+
remark: r.rejectRemark
|
|
2001
|
+
}));
|
|
2002
|
+
return [
|
|
2003
|
+
o.idDisplay ? { label: "ID", value: o.idDisplay } : null,
|
|
2004
|
+
{
|
|
2005
|
+
label: "Location",
|
|
2006
|
+
value: o.locationName ?? Ma
|
|
2007
|
+
},
|
|
2008
|
+
{
|
|
2009
|
+
label: "Created at",
|
|
2010
|
+
value: Fe(t.createdAt)
|
|
2011
|
+
},
|
|
2012
|
+
{
|
|
2013
|
+
label: "Created by",
|
|
2014
|
+
value: t.createdBy.name
|
|
2015
|
+
},
|
|
2016
|
+
{
|
|
2017
|
+
label: "Updated at",
|
|
2018
|
+
value: Fe(t.updatedAt)
|
|
2019
|
+
},
|
|
2020
|
+
{
|
|
2021
|
+
label: "Updated by",
|
|
2022
|
+
value: t.updatedBy.name
|
|
2023
|
+
},
|
|
2024
|
+
{
|
|
2025
|
+
label: "Effective at",
|
|
2026
|
+
value: Fe(t.effectiveAt ?? Le(t._id))
|
|
2027
|
+
},
|
|
2028
|
+
{
|
|
2029
|
+
label: "Using template",
|
|
2030
|
+
value: ((i = t.usingTemplates.find((r) => r)) == null ? void 0 : i.name) ?? "None"
|
|
2031
|
+
},
|
|
2032
|
+
t.remark ? { label: "Remark", value: t.remark } : null,
|
|
2033
|
+
e ? { label: "Last action", value: e.action } : null,
|
|
2034
|
+
e && e.actionBy ? { label: "Last action by", value: e.actionBy.name } : null,
|
|
2035
|
+
e && e.remark ? { label: "Action remark", value: e.remark } : null
|
|
2036
|
+
].filter((r) => !!r);
|
|
2037
|
+
}
|
|
2038
|
+
const Na = { class: "fm-typo-en-body-lg-400" }, Ua = { class: "fm-typo-en-body-lg-600" }, Pa = { class: "flex gap-12 py-8 justify-end w-full" }, Va = /* @__PURE__ */ Se({
|
|
2039
|
+
__name: "ClosingGroupAction",
|
|
2040
|
+
props: {
|
|
2041
|
+
group: {},
|
|
2042
|
+
action: {},
|
|
2043
|
+
onCancel: { type: Function },
|
|
2044
|
+
onFinished: { type: Function }
|
|
2045
|
+
},
|
|
2046
|
+
setup(t) {
|
|
2047
|
+
const o = t, e = Ge(), n = Ue(), i = q(), r = q(!1), s = S(
|
|
2048
|
+
() => ({ approve: "Approve", reject: "Reject", submit: "Submit for approval" })[o.action]
|
|
2049
|
+
), u = S(
|
|
2050
|
+
() => ({ approve: "Approve", reject: "Reject", submit: "Submit" })[o.action]
|
|
2051
|
+
), c = S(() => o.action === "reject" ? "destructive" : "primary");
|
|
2052
|
+
async function b() {
|
|
2053
|
+
r.value = !0;
|
|
2054
|
+
try {
|
|
2055
|
+
o.action === "approve" ? await e.approveClosingGroup(o.group._id, i.value).delayed(500) : o.action === "submit" ? await e.submitClosingGroup(o.group._id, i.value).delayed(500) : await e.rejectClosingGroup(o.group._id, i.value).delayed(500), n.open({ title: "Success", message: "Action submitted", type: "success" }), o.onFinished();
|
|
2056
|
+
} catch (y) {
|
|
2057
|
+
n.open({
|
|
2058
|
+
title: "Something went wrong",
|
|
2059
|
+
message: (y == null ? void 0 : y.message) ?? "Unable to submit action. Please try again",
|
|
2060
|
+
type: "error"
|
|
2061
|
+
}), console.error("error on submit closing group action", y);
|
|
2062
|
+
} finally {
|
|
2063
|
+
r.value = !1;
|
|
2064
|
+
}
|
|
2065
|
+
}
|
|
2066
|
+
return (y, $) => {
|
|
2067
|
+
const Q = ee("FmTextField"), V = ee("FmButton"), B = ee("FmForm");
|
|
2068
|
+
return f(), ne(B, {
|
|
2069
|
+
onValidationSuccess: b,
|
|
2070
|
+
class: "flex flex-col gap-32",
|
|
2071
|
+
disabled: r.value
|
|
2072
|
+
}, {
|
|
2073
|
+
default: te(() => [
|
|
2074
|
+
a("div", Na, [
|
|
2075
|
+
$[2] || ($[2] = ge(" You are about to ")),
|
|
2076
|
+
a("span", Ua, E(u.value), 1),
|
|
2077
|
+
$[3] || ($[3] = ge(" this group. Please provide a remark to justify this action. "))
|
|
2078
|
+
]),
|
|
2079
|
+
D(Q, {
|
|
2080
|
+
modelValue: i.value,
|
|
2081
|
+
"onUpdate:modelValue": $[0] || ($[0] = (I) => i.value = I),
|
|
2082
|
+
label: "Remark",
|
|
2083
|
+
"label-mark": "required",
|
|
2084
|
+
rules: [d(po)()]
|
|
2085
|
+
}, null, 8, ["modelValue", "rules"]),
|
|
2086
|
+
a("div", Pa, [
|
|
2087
|
+
D(V, {
|
|
2088
|
+
label: "Cancel",
|
|
2089
|
+
variant: "tertiary",
|
|
2090
|
+
onClick: $[1] || ($[1] = (I) => y.onCancel())
|
|
2091
|
+
}),
|
|
2092
|
+
D(V, {
|
|
2093
|
+
label: s.value,
|
|
2094
|
+
type: "submit",
|
|
2095
|
+
variant: c.value,
|
|
2096
|
+
loading: r.value
|
|
2097
|
+
}, null, 8, ["label", "variant", "loading"])
|
|
2098
|
+
])
|
|
2099
|
+
]),
|
|
2100
|
+
_: 1
|
|
2101
|
+
}, 8, ["disabled"]);
|
|
2102
|
+
};
|
|
2103
|
+
}
|
|
2104
|
+
}), Ea = { class: "w-full flex flex-col gap-32" }, La = { class: "fm-typo-en-title-md-600" }, Ga = { class: "text-fm-color-typo-secondary" }, za = { class: "text-fm-color-primary" }, Oa = { class: "flex justify-between" }, Ha = { class: "flex" }, Ya = { class: "grid grid-cols-[repeat(4,1fr)] xs:flex xs:flex-col sm:flex sm:flex-col gap-8" }, Wa = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ka = { class: "flex gap-1" }, qa = {
|
|
2105
|
+
class: "fm-typo-en-body-lg-600",
|
|
2106
|
+
style: { "white-space": "pre-wrap", "word-break": "break-word" }
|
|
2107
|
+
}, Qa = { class: "fm-typo-en-body-lg-600" }, Ja = { class: "flex gap-8" }, Za = { class: "overflow-x-auto" }, Xa = {
|
|
2108
|
+
key: 1,
|
|
2109
|
+
class: "flex-1 xs:w-screen xs:max-w-full"
|
|
2110
|
+
}, es = {
|
|
2111
|
+
key: 0,
|
|
2112
|
+
class: "flex flex-col items-center gap-8 h-full"
|
|
2113
|
+
}, ts = ["src"], os = {
|
|
2114
|
+
key: 1,
|
|
2115
|
+
class: "px-4 flex flex-col"
|
|
2116
|
+
}, ns = { class: "flex gap-12 content-stretch" }, as = {
|
|
2117
|
+
class: "flex flex-col w-24",
|
|
2118
|
+
name: "circles"
|
|
2119
|
+
}, ss = { class: "flex-1 flex flex-col items-center" }, rs = { class: "flex-1 flex flex-col items-center" }, ls = {
|
|
2120
|
+
class: "py-12 flex flex-col gap-4",
|
|
2121
|
+
name: "received-at header"
|
|
2122
|
+
}, is = { class: "fm-typo-en-body-lg-400" }, cs = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, us = { class: "flex gap-12 content-stretch" }, ds = {
|
|
2123
|
+
class: "flex flex-col w-24",
|
|
2124
|
+
name: "circles"
|
|
2125
|
+
}, ms = { class: "flex-1 flex flex-col items-center" }, ps = {
|
|
2126
|
+
class: "py-12 flex flex-col gap-4 flex-1",
|
|
2127
|
+
name: "delivery details"
|
|
2128
|
+
}, fs = { class: "flex flex-col gap-8" }, vs = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, gs = { class: "flex flex-col gap-4" }, ys = { class: "flex items-center gap-8 w-full" }, bs = /* @__PURE__ */ Se({
|
|
2129
|
+
__name: "ClosingGroupDetailSideSheet",
|
|
2130
|
+
props: {
|
|
2131
|
+
show: { type: Boolean },
|
|
2132
|
+
group: {},
|
|
2133
|
+
parentName: {}
|
|
2134
|
+
},
|
|
2135
|
+
emits: ["update:show", "updated"],
|
|
2136
|
+
setup(t, { emit: o }) {
|
|
2137
|
+
const e = t, n = o, i = Tt(e, "show"), r = Mt(), s = Qe(), u = io(), c = S(() => {
|
|
2138
|
+
var w, x, re;
|
|
2139
|
+
return ((re = (x = (w = e.group) == null ? void 0 : w.usingTemplates) == null ? void 0 : x.find((_) => _)) == null ? void 0 : re.name) ?? "Group";
|
|
2140
|
+
}), b = S(() => {
|
|
2141
|
+
var w;
|
|
2142
|
+
return ((w = e.group) == null ? void 0 : w.status) === xe.enum.DRAFT;
|
|
2143
|
+
}), y = S(
|
|
2144
|
+
() => {
|
|
2145
|
+
var w;
|
|
2146
|
+
return b.value || ((w = e.group) == null ? void 0 : w.status) === xe.enum.PENDING_APPROVAL;
|
|
2147
|
+
}
|
|
2148
|
+
);
|
|
2149
|
+
function $(w) {
|
|
2150
|
+
e.group && u.open({
|
|
2151
|
+
title: { approve: "Approve group", reject: "Reject group", submit: "Submit group for approval" }[w],
|
|
2152
|
+
contentComponent: Va,
|
|
2153
|
+
contentComponentProps: {
|
|
2154
|
+
group: e.group,
|
|
2155
|
+
action: w,
|
|
2156
|
+
onFinished: () => {
|
|
2157
|
+
u.close(), n("updated"), i.value = !1;
|
|
2158
|
+
},
|
|
2159
|
+
onCancel: () => u.close()
|
|
2160
|
+
}
|
|
2161
|
+
});
|
|
2162
|
+
}
|
|
2163
|
+
const Q = S(() => {
|
|
2164
|
+
var w;
|
|
2165
|
+
return e.group ? ko(e.group, {
|
|
2166
|
+
locationName: (w = s._currentLocation) == null ? void 0 : w.name
|
|
2167
|
+
}) : [];
|
|
2168
|
+
}), V = [
|
|
2169
|
+
{ label: "Overview", value: "overview" },
|
|
2170
|
+
{ label: "Action history", value: "history" }
|
|
2171
|
+
], B = q(V[0]), I = q(""), N = q({ templateItem: !0, nonTemplateItem: !0 }), J = q(null);
|
|
2172
|
+
function X(w, x) {
|
|
2173
|
+
J.value = x ? w : J.value === w ? null : J.value;
|
|
2174
|
+
}
|
|
2175
|
+
Te(
|
|
2176
|
+
() => e.show,
|
|
2177
|
+
(w) => {
|
|
2178
|
+
w && (B.value = V[0], I.value = "", N.value = { templateItem: !0, nonTemplateItem: !0 }, J.value = null);
|
|
2179
|
+
}
|
|
2180
|
+
);
|
|
2181
|
+
const O = S(
|
|
2182
|
+
() => e.group ? Ta(e.group, r.value) : []
|
|
2183
|
+
), F = S(
|
|
2184
|
+
() => O.value.filter((w) => !!(w.isTemplateItem && N.value.templateItem || !w.isTemplateItem && N.value.nonTemplateItem))
|
|
2185
|
+
), T = S(() => [
|
|
2186
|
+
{
|
|
2187
|
+
id: "sku",
|
|
2188
|
+
accessorFn: (w) => `${w.code} ${w.name}`,
|
|
2189
|
+
header: () => "Name",
|
|
2190
|
+
size: 350,
|
|
2191
|
+
cell(w) {
|
|
2192
|
+
const x = w.row.original;
|
|
2193
|
+
return h("div", { class: "flex flex-col gap-4" }, [
|
|
2194
|
+
h(
|
|
2195
|
+
"div",
|
|
2196
|
+
{ class: "line-clamp-1 fm-typo-en-body-lg-400 text-fm-color-typo-primary" },
|
|
2197
|
+
x.name
|
|
2198
|
+
),
|
|
2199
|
+
h(
|
|
2200
|
+
"div",
|
|
2201
|
+
{ class: "line-clamp-1 fm-typo-en-body-md-400 text-fm-color-typo-secondary" },
|
|
2202
|
+
x.code
|
|
2203
|
+
)
|
|
2204
|
+
]);
|
|
2205
|
+
}
|
|
2206
|
+
},
|
|
2207
|
+
{
|
|
2208
|
+
id: "uom",
|
|
2209
|
+
accessorFn: (w) => w.baseUnit,
|
|
2210
|
+
header: () => "UOM (base)",
|
|
2211
|
+
size: 120
|
|
2212
|
+
},
|
|
2213
|
+
{
|
|
2214
|
+
id: "physicalBalance",
|
|
2215
|
+
accessorKey: "physicalBalance",
|
|
2216
|
+
header: () => h(
|
|
2217
|
+
be.FmTooltip,
|
|
2218
|
+
{ zIndex: 51, placement: "left", class: "w-full flex justify-end" },
|
|
2219
|
+
{
|
|
2220
|
+
default: () => "Stock Take balance",
|
|
2221
|
+
content: () => "The physical balance recorded during stock take."
|
|
2222
|
+
}
|
|
2223
|
+
),
|
|
2224
|
+
size: 180,
|
|
2225
|
+
cell(w) {
|
|
2226
|
+
const x = w.row.original, re = h(
|
|
2227
|
+
"div",
|
|
2228
|
+
{ class: "text-right fm-typo-en-body-lg-400" },
|
|
2229
|
+
me(x.physicalBalance)
|
|
2230
|
+
);
|
|
2231
|
+
return x.breakdown.length ? h(
|
|
2232
|
+
be.FmPopover,
|
|
2233
|
+
{
|
|
2234
|
+
showPopover: J.value === x.id,
|
|
2235
|
+
placement: "bottom-end",
|
|
2236
|
+
zIndex: 9999,
|
|
2237
|
+
"onPopover-changed": (_) => X(x.id, _)
|
|
2238
|
+
},
|
|
2239
|
+
{
|
|
2240
|
+
"popover-button": () => h(
|
|
2241
|
+
"button",
|
|
2242
|
+
{
|
|
2243
|
+
type: "button",
|
|
2244
|
+
class: "flex items-center gap-4 ml-auto text-fm-color-typo-secondary hover:text-fm-color-typo-primary"
|
|
2245
|
+
},
|
|
2246
|
+
[re, h(be.FmIcon, { name: "info", size: "sm", outline: !0 })]
|
|
2247
|
+
),
|
|
2248
|
+
default: () => _o(x.breakdown, x.physicalBalance, x.baseUnit)
|
|
2249
|
+
}
|
|
2250
|
+
) : re;
|
|
2251
|
+
},
|
|
2252
|
+
meta: { textAlign: "right" }
|
|
2253
|
+
},
|
|
2254
|
+
{
|
|
2255
|
+
id: "amounts",
|
|
2256
|
+
header: () => "Amounts",
|
|
2257
|
+
enableSorting: !1,
|
|
2258
|
+
cell(w) {
|
|
2259
|
+
const x = w.row.original;
|
|
2260
|
+
return Pt(x.baseUnitAmount, x.baseUnit, x.measurements);
|
|
2261
|
+
}
|
|
2262
|
+
}
|
|
2263
|
+
]), k = S(() => {
|
|
2264
|
+
const w = e.group;
|
|
2265
|
+
if (!w) return [];
|
|
2266
|
+
const x = [...w.activityLogs ?? []], re = w.rejectionHistory ?? [];
|
|
2267
|
+
for (const _ of re)
|
|
2268
|
+
x.find(
|
|
2269
|
+
(L) => `${L.action}_${L.performedAt}` == `${fe.enum.rejectDraft}_${_.rejectedAt}`
|
|
2270
|
+
) || x.push({
|
|
2271
|
+
action: fe.enum.rejectDraft,
|
|
2272
|
+
performedAt: _.rejectedAt,
|
|
2273
|
+
performedBy: _.rejectedBy,
|
|
2274
|
+
remark: _.rejectRemark
|
|
2275
|
+
});
|
|
2276
|
+
return w.approvedAt && (x.find(
|
|
2277
|
+
(A) => `${A.action}_${A.performedAt}` == `${fe.enum.approveDraft}_${w.approvedAt}`
|
|
2278
|
+
) || x.push({
|
|
2279
|
+
action: fe.enum.approveDraft,
|
|
2280
|
+
performedAt: w.approvedAt,
|
|
2281
|
+
performedBy: w.approvedBy ?? { name: "Unknown", id: "unknown" },
|
|
2282
|
+
remark: w.approveRemark
|
|
2283
|
+
})), x.sort((_, A) => new Date(A.performedAt).getTime() - new Date(_.performedAt).getTime()).map((_) => ({
|
|
2284
|
+
header: Ie(_.action),
|
|
2285
|
+
date: Fe(_.performedAt),
|
|
2286
|
+
info: [
|
|
2287
|
+
{ label: "Performed by", values: [_.performedBy.name] },
|
|
2288
|
+
{ label: "Remark", values: [_.remark ?? ""] }
|
|
2289
|
+
]
|
|
2290
|
+
}));
|
|
2291
|
+
});
|
|
2292
|
+
return (w, x) => {
|
|
2293
|
+
const re = ee("FmButtonGroup"), _ = ee("FmMenuDivider"), A = ee("FmCard"), L = ee("FmChip"), P = ee("FmTextField"), ve = ee("FmTable"), oe = ee("FmSpacer"), R = ee("FmButton"), p = ee("FmSideSheet");
|
|
2294
|
+
return f(), ne(p, {
|
|
2295
|
+
"dismiss-away": "",
|
|
2296
|
+
"max-width": 9999,
|
|
2297
|
+
"model-value": d(i),
|
|
2298
|
+
"onUpdate:modelValue": x[8] || (x[8] = (g) => bt(i) ? i.value = g : null),
|
|
2299
|
+
header: "Group details"
|
|
2300
|
+
}, {
|
|
2301
|
+
"side-sheet-footer": te(() => [
|
|
2302
|
+
a("div", ys, [
|
|
2303
|
+
b.value ? (f(), ne(R, {
|
|
2304
|
+
key: 0,
|
|
2305
|
+
label: "Submit for approval",
|
|
2306
|
+
variant: "secondary",
|
|
2307
|
+
onClick: x[4] || (x[4] = (g) => $("submit"))
|
|
2308
|
+
})) : W("", !0),
|
|
2309
|
+
y.value ? (f(), ne(R, {
|
|
2310
|
+
key: 1,
|
|
2311
|
+
label: "Approve",
|
|
2312
|
+
onClick: x[5] || (x[5] = (g) => $("approve"))
|
|
2313
|
+
})) : W("", !0),
|
|
2314
|
+
y.value ? (f(), ne(R, {
|
|
2315
|
+
key: 2,
|
|
2316
|
+
label: "Reject",
|
|
2317
|
+
variant: "destructive",
|
|
2318
|
+
onClick: x[6] || (x[6] = (g) => $("reject"))
|
|
2319
|
+
})) : W("", !0),
|
|
2320
|
+
D(R, {
|
|
2321
|
+
label: "Close",
|
|
2322
|
+
variant: "tertiary",
|
|
2323
|
+
onClick: x[7] || (x[7] = (g) => i.value = !1)
|
|
2324
|
+
})
|
|
2325
|
+
])
|
|
2326
|
+
]),
|
|
2327
|
+
default: te(() => [
|
|
2328
|
+
a("div", Ea, [
|
|
2329
|
+
a("div", La, [
|
|
2330
|
+
w.parentName ? (f(), C(ie, { key: 0 }, [
|
|
2331
|
+
a("span", Ga, E(w.parentName), 1),
|
|
2332
|
+
x[9] || (x[9] = ge(" · "))
|
|
2333
|
+
], 64)) : W("", !0),
|
|
2334
|
+
x[10] || (x[10] = ge(" Group · ")),
|
|
2335
|
+
a("span", za, E(c.value), 1)
|
|
2336
|
+
]),
|
|
2337
|
+
a("div", null, [
|
|
2338
|
+
D(re, {
|
|
2339
|
+
items: V,
|
|
2340
|
+
modelValue: B.value,
|
|
2341
|
+
"onUpdate:modelValue": x[0] || (x[0] = (g) => B.value = g)
|
|
2342
|
+
}, null, 8, ["modelValue"])
|
|
2343
|
+
]),
|
|
2344
|
+
B.value.value === "overview" ? (f(), C(ie, { key: 0 }, [
|
|
2345
|
+
D(A, {
|
|
2346
|
+
variant: "outlined",
|
|
2347
|
+
class: "flex flex-col gap-8 px-12 py-16"
|
|
2348
|
+
}, {
|
|
2349
|
+
default: te(() => {
|
|
2350
|
+
var g, M;
|
|
2351
|
+
return [
|
|
2352
|
+
a("div", Oa, [
|
|
2353
|
+
x[11] || (x[11] = a("div", { class: "fm-typo-en-body-lg-600" }, "Closing summary", -1)),
|
|
2354
|
+
a("div", Ha, [
|
|
2355
|
+
a("div", {
|
|
2356
|
+
class: we(["fm-status-badge", d(Ne)(((g = w.group) == null ? void 0 : g.status) ?? "DRAFT")])
|
|
2357
|
+
}, E(d(Ie)(((M = w.group) == null ? void 0 : M.status) ?? "")), 3)
|
|
2358
|
+
])
|
|
2359
|
+
]),
|
|
2360
|
+
D(_),
|
|
2361
|
+
a("div", Ya, [
|
|
2362
|
+
(f(!0), C(ie, null, _e(Q.value, (H, de) => (f(), C("div", {
|
|
2363
|
+
class: "flex flex-col gap-4",
|
|
2364
|
+
key: de
|
|
2365
|
+
}, [
|
|
2366
|
+
a("div", Wa, [
|
|
2367
|
+
a("div", Ka, E(H.label), 1)
|
|
2368
|
+
]),
|
|
2369
|
+
a("div", qa, E(H.value), 1)
|
|
2370
|
+
]))), 128))
|
|
2371
|
+
])
|
|
2372
|
+
];
|
|
2373
|
+
}),
|
|
2374
|
+
_: 1
|
|
2375
|
+
}),
|
|
2376
|
+
D(A, {
|
|
2377
|
+
variant: "outlined",
|
|
2378
|
+
class: "flex flex-col gap-16 px-12 py-16"
|
|
2379
|
+
}, {
|
|
2380
|
+
default: te(() => [
|
|
2381
|
+
a("div", Qa, E(c.value) + " items", 1),
|
|
2382
|
+
a("div", Ja, [
|
|
2383
|
+
D(L, {
|
|
2384
|
+
label: "Template Item(s)",
|
|
2385
|
+
selected: N.value.templateItem,
|
|
2386
|
+
onClick: x[1] || (x[1] = (g) => N.value.templateItem = !N.value.templateItem)
|
|
2387
|
+
}, null, 8, ["selected"]),
|
|
2388
|
+
D(L, {
|
|
2389
|
+
label: "Non-template Item(s)",
|
|
2390
|
+
selected: N.value.nonTemplateItem,
|
|
2391
|
+
onClick: x[2] || (x[2] = (g) => N.value.nonTemplateItem = !N.value.nonTemplateItem)
|
|
2392
|
+
}, null, 8, ["selected"])
|
|
2393
|
+
]),
|
|
2394
|
+
D(P, {
|
|
2395
|
+
modelValue: I.value,
|
|
2396
|
+
"onUpdate:modelValue": x[3] || (x[3] = (g) => I.value = g),
|
|
2397
|
+
placeholder: "Filter items"
|
|
2398
|
+
}, null, 8, ["modelValue"]),
|
|
2399
|
+
a("div", Za, [
|
|
2400
|
+
D(ve, {
|
|
2401
|
+
"column-defs": T.value,
|
|
2402
|
+
"row-data": F.value,
|
|
2403
|
+
"search-value": I.value,
|
|
2404
|
+
"page-size": 10
|
|
2405
|
+
}, null, 8, ["column-defs", "row-data", "search-value"])
|
|
2406
|
+
])
|
|
2407
|
+
]),
|
|
2408
|
+
_: 1
|
|
2409
|
+
})
|
|
2410
|
+
], 64)) : W("", !0),
|
|
2411
|
+
B.value.value === "history" ? (f(), C("div", Xa, [
|
|
2412
|
+
k.value.length ? (f(), C("div", os, [
|
|
2413
|
+
(f(!0), C(ie, null, _e(k.value, (g, M) => (f(), C(ie, { key: M }, [
|
|
2414
|
+
a("div", ns, [
|
|
2415
|
+
a("div", as, [
|
|
2416
|
+
a("div", ss, [
|
|
2417
|
+
a("div", {
|
|
2418
|
+
class: we([
|
|
2419
|
+
{ "bg-fm-color-primary": M !== 0, "bg-white": M === 0 },
|
|
2420
|
+
"w-[2px] h-full"
|
|
2421
|
+
])
|
|
2422
|
+
}, null, 2)
|
|
2423
|
+
]),
|
|
2424
|
+
x[14] || (x[14] = a("div", { class: "h-24 w-24 bg-fm-color-primary rounded-full" }, null, -1)),
|
|
2425
|
+
a("div", rs, [
|
|
2426
|
+
a("div", {
|
|
2427
|
+
class: we([
|
|
2428
|
+
{
|
|
2429
|
+
"bg-fm-color-primary": M < k.value.length - 1,
|
|
2430
|
+
"bg-white": M >= k.value.length - 1
|
|
2431
|
+
},
|
|
2432
|
+
"w-[2px] h-full"
|
|
2433
|
+
])
|
|
2434
|
+
}, null, 2)
|
|
2435
|
+
])
|
|
2436
|
+
]),
|
|
2437
|
+
a("div", ls, [
|
|
2438
|
+
a("div", is, E(g.header), 1),
|
|
2439
|
+
a("div", cs, E(g.date), 1)
|
|
2440
|
+
])
|
|
2441
|
+
]),
|
|
2442
|
+
a("div", us, [
|
|
2443
|
+
a("div", ds, [
|
|
2444
|
+
a("div", ms, [
|
|
2445
|
+
a("div", {
|
|
2446
|
+
class: we([
|
|
2447
|
+
{
|
|
2448
|
+
"bg-fm-color-primary": M < k.value.length - 1,
|
|
2449
|
+
"bg-white": M >= k.value.length - 1
|
|
2450
|
+
},
|
|
2451
|
+
"w-[2px] h-full"
|
|
2452
|
+
])
|
|
2453
|
+
}, null, 2)
|
|
2454
|
+
])
|
|
2455
|
+
]),
|
|
2456
|
+
a("div", ps, [
|
|
2457
|
+
D(A, {
|
|
2458
|
+
variant: "outlined",
|
|
2459
|
+
class: "py-12 px-16"
|
|
2460
|
+
}, {
|
|
2461
|
+
default: te(() => [
|
|
2462
|
+
a("div", fs, [
|
|
2463
|
+
(f(!0), C(ie, null, _e(g.info, (H, de) => (f(), C("div", {
|
|
2464
|
+
key: de,
|
|
2465
|
+
class: "flex flex-col gap-4"
|
|
2466
|
+
}, [
|
|
2467
|
+
a("div", vs, E(H.label), 1),
|
|
2468
|
+
a("div", gs, [
|
|
2469
|
+
(f(!0), C(ie, null, _e(H.values, (j, z) => (f(), C("div", {
|
|
2470
|
+
key: z,
|
|
2471
|
+
class: "fm-typo-en-body-lg-600"
|
|
2472
|
+
}, E(j), 1))), 128))
|
|
2473
|
+
])
|
|
2474
|
+
]))), 128))
|
|
2475
|
+
])
|
|
2476
|
+
]),
|
|
2477
|
+
_: 2
|
|
2478
|
+
}, 1024)
|
|
2479
|
+
])
|
|
2480
|
+
])
|
|
2481
|
+
], 64))), 128))
|
|
2482
|
+
])) : (f(), C("div", es, [
|
|
2483
|
+
D(oe),
|
|
2484
|
+
a("div", null, [
|
|
2485
|
+
a("img", {
|
|
2486
|
+
src: d(yo),
|
|
2487
|
+
alt: "List is empty"
|
|
2488
|
+
}, null, 8, ts)
|
|
2489
|
+
]),
|
|
2490
|
+
x[12] || (x[12] = a("div", { class: "fm-typo-en-body-lg-600" }, "No records found", -1)),
|
|
2491
|
+
x[13] || (x[13] = a("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary px-16" }, " You can track approval and rejection history here ", -1)),
|
|
2492
|
+
D(oe),
|
|
2493
|
+
D(oe)
|
|
2494
|
+
]))
|
|
2495
|
+
])) : W("", !0)
|
|
2496
|
+
])
|
|
2497
|
+
]),
|
|
2498
|
+
_: 1
|
|
2499
|
+
}, 8, ["model-value"]);
|
|
2500
|
+
};
|
|
2501
|
+
}
|
|
2502
|
+
}), hs = { class: "w-full flex flex-col gap-32" }, _s = { class: "flex flex-col gap-4" }, ks = { class: "flex justify-between" }, xs = { class: "flex" }, ws = { class: "grid grid-cols-[repeat(4,1fr)] xs:flex xs:flex-col sm:flex sm:flex-col gap-8" }, Ds = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, As = { class: "flex gap-1" }, $s = {
|
|
2503
|
+
class: "fm-typo-en-body-lg-600",
|
|
2504
|
+
style: { "white-space": "pre-wrap", "word-break": "break-word" }
|
|
2505
|
+
}, Cs = { class: "flex items-center justify-between" }, Ss = { class: "fm-typo-en-body-lg-600" }, Fs = {
|
|
2506
|
+
key: 1,
|
|
2507
|
+
class: "flex items-start gap-8 p-12 fm-corner-radius-md border-1 border-yellow-500 bg-yellow-50 text-yellow-700"
|
|
2508
|
+
}, Is = { class: "flex flex-col gap-2" }, Bs = { class: "fm-typo-en-body-sm-400 list-disc pl-16" }, Ts = { key: 0 }, js = { key: 1 }, Rs = { class: "flex flex-col gap-16" }, Ms = { class: "flex items-center" }, Ns = {
|
|
2509
|
+
key: 0,
|
|
2510
|
+
class: "flex gap-8"
|
|
2511
|
+
}, Us = {
|
|
2512
|
+
key: 0,
|
|
2513
|
+
class: "w-full flex flex-col items-center"
|
|
2514
|
+
}, Ps = { class: "flex items-center gap-8" }, Vs = { class: "flex flex-col gap-8" }, Es = { class: "flex gap-8" }, Ls = {
|
|
2515
|
+
key: 0,
|
|
2516
|
+
class: "flex gap-8"
|
|
2517
|
+
}, Gs = {
|
|
2518
|
+
key: 1,
|
|
2519
|
+
class: "flex gap-8 flex-wrap"
|
|
2520
|
+
}, zs = { class: "overflow-x-auto" }, Os = {
|
|
2521
|
+
key: 1,
|
|
2522
|
+
class: "flex-1 xs:w-screen xs:max-w-full"
|
|
2523
|
+
}, Hs = {
|
|
2524
|
+
key: 0,
|
|
2525
|
+
class: "flex flex-col items-center gap-8 h-full"
|
|
2526
|
+
}, Ys = ["src"], Ws = {
|
|
2527
|
+
key: 1,
|
|
2528
|
+
class: "px-4 flex flex-col"
|
|
2529
|
+
}, Ks = { class: "flex gap-12 content-stretch" }, qs = {
|
|
2530
|
+
class: "flex flex-col w-24",
|
|
2531
|
+
name: "circles"
|
|
2532
|
+
}, Qs = { class: "flex-1 flex flex-col items-center" }, Js = { class: "flex-1 flex flex-col items-center" }, Zs = {
|
|
2533
|
+
class: "py-12 flex flex-col gap-4",
|
|
2534
|
+
name: "received-at header"
|
|
2535
|
+
}, Xs = { class: "fm-typo-en-body-lg-400" }, er = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, tr = { class: "flex gap-12 content-stretch" }, or = {
|
|
2536
|
+
class: "flex flex-col w-24",
|
|
2537
|
+
name: "circles"
|
|
2538
|
+
}, nr = { class: "flex-1 flex flex-col items-center" }, ar = {
|
|
2539
|
+
class: "py-12 flex flex-col gap-4 flex-1",
|
|
2540
|
+
name: "delivery details"
|
|
2541
|
+
}, sr = { class: "flex flex-col gap-8" }, rr = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, lr = { class: "flex flex-col gap-4" }, ir = { class: "flex items-center justify-between gap-8 w-full" }, cr = { class: "flex items-center gap-8" }, ur = { class: "flex flex-col items-end" }, dr = { class: "text-2xl font-semibold" }, mr = "N/A", pr = /* @__PURE__ */ Se({
|
|
2542
|
+
__name: "ClosingDraftDialog",
|
|
2543
|
+
props: {
|
|
2544
|
+
show: { type: Boolean },
|
|
2545
|
+
draft: {}
|
|
2546
|
+
},
|
|
2547
|
+
emits: ["submitted", "refresh"],
|
|
2548
|
+
setup(t, { emit: o }) {
|
|
2549
|
+
const e = t, n = S(() => {
|
|
2550
|
+
const m = co();
|
|
2551
|
+
return m === "MYR" ? "RM" : m;
|
|
2552
|
+
}), i = bo(), r = S(() => {
|
|
2553
|
+
var m, l;
|
|
2554
|
+
return (m = e.draft) != null && m.closingId ? ((l = i.drafts.find((v) => v._id === e.draft._id)) == null ? void 0 : l.closingIdDisplay) ?? null : null;
|
|
2555
|
+
}), s = yt(), u = Ge(), c = Tt(e, "show"), b = q(!1), y = q(!1), $ = q([]), Q = S(
|
|
2556
|
+
() => e.draft
|
|
2557
|
+
);
|
|
2558
|
+
let V = 0, B;
|
|
2559
|
+
async function I() {
|
|
2560
|
+
var G, Y;
|
|
2561
|
+
const m = (G = e.draft) == null ? void 0 : G._id;
|
|
2562
|
+
if ($.value = [], !m) return;
|
|
2563
|
+
const l = (Y = Q.value) == null ? void 0 : Y.groups;
|
|
2564
|
+
if (l && B !== m) {
|
|
2565
|
+
B = m, ++V, $.value = l;
|
|
2566
|
+
return;
|
|
2567
|
+
}
|
|
2568
|
+
const v = ++V;
|
|
2569
|
+
try {
|
|
2570
|
+
const U = await u.getClosingGroups(m);
|
|
2571
|
+
if (v !== V) return;
|
|
2572
|
+
$.value = U;
|
|
2573
|
+
} catch (U) {
|
|
2574
|
+
if (v !== V) return;
|
|
2575
|
+
console.error("Failed to fetch closing groups", U);
|
|
2576
|
+
}
|
|
2577
|
+
}
|
|
2578
|
+
const N = S(() => $.value.map(Bt)), J = S(() => {
|
|
2579
|
+
var m, l, v;
|
|
2580
|
+
return (v = (l = (m = e.draft) == null ? void 0 : m.usingTemplates) == null ? void 0 : l.find((G) => G)) == null ? void 0 : v.name;
|
|
2581
|
+
}), X = q(null), O = q(!1);
|
|
2582
|
+
function F(m) {
|
|
2583
|
+
const l = $.value.find((v) => v._id === m);
|
|
2584
|
+
l && (X.value = l, O.value = !0);
|
|
2585
|
+
}
|
|
2586
|
+
const T = q(new Array()), k = q(new Array()), w = S(
|
|
2587
|
+
() => {
|
|
2588
|
+
var m;
|
|
2589
|
+
return ((m = e.draft) == null ? void 0 : m.status) === xe.enum.COMPLETED;
|
|
2590
|
+
}
|
|
2591
|
+
), x = S(
|
|
2592
|
+
() => {
|
|
2593
|
+
var m;
|
|
2594
|
+
return w.value ? T.value : ((m = e.draft) == null ? void 0 : m.stockSnapshot) ?? [];
|
|
2595
|
+
}
|
|
2596
|
+
), re = S(
|
|
2597
|
+
() => w.value ? k.value : []
|
|
2598
|
+
), _ = S(() => {
|
|
2599
|
+
var G;
|
|
2600
|
+
const m = /* @__PURE__ */ new Set();
|
|
2601
|
+
for (const Y of ((G = e.draft) == null ? void 0 : G.adjustmentSnapshot) ?? [])
|
|
2602
|
+
Y.adjustmentsByType && Object.keys(Y.adjustmentsByType).forEach((U) => m.add(U));
|
|
2603
|
+
const v = ["receive", "sales", "wastage"].filter((Y) => m.has(Y));
|
|
2604
|
+
return v.forEach((Y) => m.delete(Y)), [...v, ...Array.from(m).sort()];
|
|
2605
|
+
}), A = _t(), L = Ue(), P = jt(), ve = Qe(), oe = no({}), R = S(() => new Set(
|
|
2606
|
+
P.skus.filter((m) => {
|
|
2607
|
+
var l;
|
|
2608
|
+
return oe[(l = m.customAttributes) == null ? void 0 : l.tag];
|
|
2609
|
+
}).map((m) => m._id)
|
|
2610
|
+
)), p = o, g = S(() => {
|
|
2611
|
+
var m;
|
|
2612
|
+
return (m = e.draft) == null ? void 0 : m._id;
|
|
2613
|
+
}), M = S(() => {
|
|
2614
|
+
var m;
|
|
2615
|
+
return (m = e.draft) == null ? void 0 : m._rev;
|
|
2616
|
+
}), {
|
|
2617
|
+
refreshing: H,
|
|
2618
|
+
startListening: de,
|
|
2619
|
+
startRefresh: j,
|
|
2620
|
+
cleanup: z
|
|
2621
|
+
} = ba({
|
|
2622
|
+
closingDraftId: g,
|
|
2623
|
+
currentRev: M,
|
|
2624
|
+
onCompleted: (m) => {
|
|
2625
|
+
p("refresh", m), c.value = !1;
|
|
2626
|
+
}
|
|
2627
|
+
}), le = q({
|
|
2628
|
+
templateItem: !0,
|
|
2629
|
+
nonTemplateItem: !0
|
|
2630
|
+
}), ae = q(null);
|
|
2631
|
+
function De(m, l) {
|
|
2632
|
+
ae.value = l ? m : ae.value === m ? null : ae.value;
|
|
2633
|
+
}
|
|
2634
|
+
const he = S(() => {
|
|
2635
|
+
var m, l;
|
|
2636
|
+
return [
|
|
2637
|
+
{
|
|
2638
|
+
label: "Main",
|
|
2639
|
+
isSub: !1,
|
|
2640
|
+
items: [...((m = e.draft) == null ? void 0 : m.items) ?? [], ...((l = e.draft) == null ? void 0 : l.negativeStockItems) ?? []]
|
|
2641
|
+
},
|
|
2642
|
+
...$.value.map((v) => ({
|
|
2643
|
+
label: xt(v),
|
|
2644
|
+
isSub: !0,
|
|
2645
|
+
items: [...v.items ?? [], ...v.negativeStockItems ?? []]
|
|
2646
|
+
}))
|
|
2647
|
+
];
|
|
2648
|
+
}), je = S(() => {
|
|
2649
|
+
var G, Y;
|
|
2650
|
+
const m = [
|
|
2651
|
+
...((G = e.draft) == null ? void 0 : G.items) ?? [],
|
|
2652
|
+
...((Y = e.draft) == null ? void 0 : Y.negativeStockItems) ?? []
|
|
2653
|
+
], l = $.value.map((U) => [
|
|
2654
|
+
...U.items ?? [],
|
|
2655
|
+
...U.negativeStockItems ?? []
|
|
2656
|
+
]), v = zn([m, ...l]);
|
|
2657
|
+
return R.value.size ? v.filter((U) => R.value.has(U.sku._id)) : v;
|
|
2658
|
+
}), Re = S(() => {
|
|
2659
|
+
const m = je.value.map((l) => l.sku);
|
|
2660
|
+
return m.sort((l, v) => l.code.localeCompare(v.code)), m;
|
|
2661
|
+
}), ze = Mt();
|
|
2662
|
+
Te(
|
|
2663
|
+
() => e.show,
|
|
2664
|
+
async (m) => {
|
|
2665
|
+
if (!m) {
|
|
2666
|
+
z();
|
|
2667
|
+
return;
|
|
2668
|
+
}
|
|
2669
|
+
Je.value = At[0], le.value = {
|
|
2670
|
+
templateItem: !0,
|
|
2671
|
+
nonTemplateItem: !0
|
|
2672
|
+
}, ae.value = null, de();
|
|
2673
|
+
},
|
|
2674
|
+
{ immediate: !0 }
|
|
2675
|
+
), Te(
|
|
2676
|
+
[() => e.show, g],
|
|
2677
|
+
([m]) => {
|
|
2678
|
+
m && (I(), xo());
|
|
2679
|
+
},
|
|
2680
|
+
{ immediate: !0 }
|
|
2681
|
+
);
|
|
2682
|
+
const nt = S(() => st.value.reduce((m, l) => m + Number(l.stockTakeValue), 0)), Pe = et(0), at = et(100);
|
|
2683
|
+
async function xo() {
|
|
2684
|
+
var m, l, v;
|
|
2685
|
+
if (ve._currentLocation) {
|
|
2686
|
+
b.value = !0, T.value = [], k.value = [];
|
|
2687
|
+
try {
|
|
2688
|
+
if (await P.init(), !w.value) return;
|
|
2689
|
+
const G = (m = e.draft) == null ? void 0 : m.closingAdjustmentId;
|
|
2690
|
+
if (!G) {
|
|
2691
|
+
L.open({
|
|
2692
|
+
title: "Something went wrong",
|
|
2693
|
+
message: "Closing draft is completed but closing document cannot be found.",
|
|
2694
|
+
type: "error"
|
|
2695
|
+
}), console.error("Closing draft is completed but closing document cannot be found.", {
|
|
2696
|
+
draftId: (l = e.draft) == null ? void 0 : l._id
|
|
2697
|
+
});
|
|
2698
|
+
return;
|
|
2699
|
+
}
|
|
2700
|
+
const Y = ((v = Q.value) == null ? void 0 : v.closingAdjustment) ?? await A.readAdjustmentById(G), U = (Y == null ? void 0 : Y.skus) ?? [];
|
|
2701
|
+
for (const K of U)
|
|
2702
|
+
T.value.push({
|
|
2703
|
+
id: K.sku._id,
|
|
2704
|
+
balance: K.fromBalance,
|
|
2705
|
+
costs: K.fromCostBalances
|
|
2706
|
+
}), k.value.push({
|
|
2707
|
+
id: K.sku._id,
|
|
2708
|
+
balance: K.toBalance,
|
|
2709
|
+
costs: K.toCostBalances
|
|
2710
|
+
});
|
|
2711
|
+
} catch (G) {
|
|
2712
|
+
L.open({
|
|
2713
|
+
title: "Something went wrong",
|
|
2714
|
+
message: "Something went wrong when fetching info. Please try again.",
|
|
2715
|
+
type: "error"
|
|
2716
|
+
}), console.error("error on fetch stock balances", G);
|
|
2717
|
+
} finally {
|
|
2718
|
+
b.value = !1;
|
|
2719
|
+
}
|
|
2720
|
+
}
|
|
2721
|
+
}
|
|
2722
|
+
async function Vt() {
|
|
2723
|
+
var l, v;
|
|
2724
|
+
if (H.value)
|
|
2725
|
+
return;
|
|
2726
|
+
if (!(((l = e.draft) == null ? void 0 : l.effectiveAt) ?? (e.draft ? Le((v = e.draft) == null ? void 0 : v._id) : null))) {
|
|
2727
|
+
L.open({
|
|
2728
|
+
title: "Cannot refresh",
|
|
2729
|
+
message: "Effective date is not available for this draft.",
|
|
2730
|
+
type: "error"
|
|
2731
|
+
});
|
|
2732
|
+
return;
|
|
2733
|
+
}
|
|
2734
|
+
await s.refreshBalance(
|
|
2735
|
+
e.draft,
|
|
2736
|
+
() => {
|
|
2737
|
+
},
|
|
2738
|
+
async (G) => {
|
|
2739
|
+
await j(G);
|
|
2740
|
+
}
|
|
2741
|
+
);
|
|
2742
|
+
}
|
|
2743
|
+
async function wo() {
|
|
2744
|
+
var l, v;
|
|
2745
|
+
if (!(((l = e.draft) == null ? void 0 : l.effectiveAt) ?? (e.draft ? Le((v = e.draft) == null ? void 0 : v._id) : null))) {
|
|
2746
|
+
L.open({
|
|
2747
|
+
title: "Cannot refresh",
|
|
2748
|
+
message: "Effective date is not available for this draft.",
|
|
2749
|
+
type: "error"
|
|
2750
|
+
});
|
|
2751
|
+
return;
|
|
2752
|
+
}
|
|
2753
|
+
await s.invalidateDraftCache(e.draft);
|
|
2754
|
+
}
|
|
2755
|
+
const Do = S(
|
|
2756
|
+
() => x.value.groupBy(
|
|
2757
|
+
(m) => m.id,
|
|
2758
|
+
(m) => m.balance
|
|
2759
|
+
)
|
|
2760
|
+
), Ao = S(() => je.value.groupBy((m) => m.sku._id)), $o = S(() => {
|
|
2761
|
+
var m;
|
|
2762
|
+
return (m = e.draft) != null && m.adjustmentSnapshot ? new Map(e.draft.adjustmentSnapshot.map((l) => [l.skuId, l.adjustmentsByType])) : /* @__PURE__ */ new Map();
|
|
2763
|
+
}), Co = S(() => {
|
|
2764
|
+
var m;
|
|
2765
|
+
return (m = e.draft) != null && m.opening ? new Map(e.draft.opening.map((l) => [l.skuId, l.balance])) : /* @__PURE__ */ new Map();
|
|
2766
|
+
});
|
|
2767
|
+
function Ce(m, l) {
|
|
2768
|
+
return h(
|
|
2769
|
+
be.FmTooltip,
|
|
2770
|
+
{ zIndex: 51, placement: "left", class: "w-full flex justify-end" },
|
|
2771
|
+
{
|
|
2772
|
+
default() {
|
|
2773
|
+
return m;
|
|
2774
|
+
},
|
|
2775
|
+
content() {
|
|
2776
|
+
return l || m;
|
|
2777
|
+
}
|
|
2778
|
+
}
|
|
2779
|
+
);
|
|
2780
|
+
}
|
|
2781
|
+
const Et = S(() => [
|
|
2782
|
+
{
|
|
2783
|
+
id: "sku",
|
|
2784
|
+
accessorFn: (l) => `${l.code} ${l.name}`,
|
|
2785
|
+
header: () => "Name",
|
|
2786
|
+
size: 350,
|
|
2787
|
+
cell(l) {
|
|
2788
|
+
const v = l.row.original, G = v.adjustedDiffPercentage, Y = typeof G == "number" && Math.abs(G) > 10, U = h("div", { class: "flex flex-col gap-4" }, [
|
|
2789
|
+
h(
|
|
2790
|
+
"div",
|
|
2791
|
+
{
|
|
2792
|
+
class: [
|
|
2793
|
+
"line-clamp-1 fm-typo-en-body-lg-400",
|
|
2794
|
+
Y ? " text-fm-color-system-error-300" : "text-fm-color-typo-primary"
|
|
2795
|
+
]
|
|
2796
|
+
},
|
|
2797
|
+
v.name
|
|
2798
|
+
),
|
|
2799
|
+
h(
|
|
2800
|
+
"div",
|
|
2801
|
+
{
|
|
2802
|
+
class: [
|
|
2803
|
+
"line-clamp-1 fm-typo-en-body-md-400",
|
|
2804
|
+
Y ? " text-fm-color-system-error-300" : "text-fm-color-typo-secondary"
|
|
2805
|
+
]
|
|
2806
|
+
},
|
|
2807
|
+
v.code
|
|
2808
|
+
),
|
|
2809
|
+
// Flags items whose counts come from more than one sub — a heads-up
|
|
2810
|
+
// that the displayed total is summed across subs.
|
|
2811
|
+
v.subSources.length >= 2 ? h(
|
|
2812
|
+
"div",
|
|
2813
|
+
{
|
|
2814
|
+
class: "flex items-center gap-4 w-fit px-8 py-2 fm-corner-radius-md bg-orange-50 text-fm-color-primary fm-typo-en-body-md-600"
|
|
2815
|
+
},
|
|
2816
|
+
[
|
|
2817
|
+
h(be.FmIcon, { name: "refresh", size: "sm" }),
|
|
2818
|
+
h("span", `Counted in ${v.subSources.length} subs: ${v.subSources.join(", ")}`)
|
|
2819
|
+
]
|
|
2820
|
+
) : null
|
|
2821
|
+
]);
|
|
2822
|
+
return h(
|
|
2823
|
+
be.FmTooltip,
|
|
2824
|
+
{
|
|
2825
|
+
zIndex: 51
|
|
2826
|
+
},
|
|
2827
|
+
{
|
|
2828
|
+
content() {
|
|
2829
|
+
return Y ? "Adjustment difference is more than 10%." : `${v.code} - ${v.name}`;
|
|
2830
|
+
},
|
|
2831
|
+
default() {
|
|
2832
|
+
return h("div", { class: "flex items-center gap-4 justify-start w-full" }, [
|
|
2833
|
+
U
|
|
2834
|
+
]);
|
|
2835
|
+
}
|
|
2836
|
+
}
|
|
2837
|
+
);
|
|
2838
|
+
}
|
|
2839
|
+
},
|
|
2840
|
+
// Dynamic custom attribute columns (toggled by user)
|
|
2841
|
+
...zt.value.map(
|
|
2842
|
+
(l) => ({
|
|
2843
|
+
id: `customAttr_${l}`,
|
|
2844
|
+
accessorFn: (v) => v.customAttributeValues[l],
|
|
2845
|
+
header: () => Ce(Ie(l)),
|
|
2846
|
+
size: 160,
|
|
2847
|
+
cell(v) {
|
|
2848
|
+
const G = v.row.original.customAttributeValues[l];
|
|
2849
|
+
return G == null ? "N/A" : typeof G == "number" ? h("div", { class: "text-right fm-typo-en-body-lg-400" }, me(G)) : h("div", { class: "text-right fm-typo-en-body-lg-400" }, String(G));
|
|
2850
|
+
},
|
|
2851
|
+
meta: {
|
|
2852
|
+
textAlign: "right"
|
|
2853
|
+
}
|
|
2854
|
+
})
|
|
2855
|
+
),
|
|
2856
|
+
{
|
|
2857
|
+
id: "costPerUnit",
|
|
2858
|
+
accessorKey: "costPerUnit",
|
|
2859
|
+
header: () => Ce("Cost per unit"),
|
|
2860
|
+
size: 160,
|
|
2861
|
+
cell(l) {
|
|
2862
|
+
const v = l.row.original.costPerUnit;
|
|
2863
|
+
return h("div", { class: "text-right fm-typo-en-body-lg-400" }, me(v));
|
|
2864
|
+
},
|
|
2865
|
+
meta: {
|
|
2866
|
+
textAlign: "right"
|
|
2867
|
+
}
|
|
2868
|
+
},
|
|
2869
|
+
{
|
|
2870
|
+
id: "costUnit",
|
|
2871
|
+
header: () => "UOM",
|
|
2872
|
+
size: 120,
|
|
2873
|
+
cell(l) {
|
|
2874
|
+
var K;
|
|
2875
|
+
const v = l.row.original, G = v.costUnit, Y = v.baseUnit, U = G ?? Y;
|
|
2876
|
+
if (G && G !== Y) {
|
|
2877
|
+
const ue = Re.value.find((ce) => ce._id === v.id), pe = (K = ue == null ? void 0 : ue.defaultCost) == null ? void 0 : K.measurement;
|
|
2878
|
+
if (pe) {
|
|
2879
|
+
const ce = pe.conversion.amount / Math.pow(10, pe.conversion.precision);
|
|
2880
|
+
return h("div", { class: "flex flex-col" }, [
|
|
2881
|
+
h(
|
|
2882
|
+
"span",
|
|
2883
|
+
{ class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary" },
|
|
2884
|
+
U
|
|
2885
|
+
),
|
|
2886
|
+
h("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, [
|
|
2887
|
+
"1 ",
|
|
2888
|
+
h("span", { class: "fm-typo-en-body-sm-600" }, G),
|
|
2889
|
+
` = ${ce} `,
|
|
2890
|
+
h("span", { class: "fm-typo-en-body-sm-600" }, Y)
|
|
2891
|
+
])
|
|
2892
|
+
]);
|
|
2893
|
+
}
|
|
2894
|
+
}
|
|
2895
|
+
return U;
|
|
2896
|
+
}
|
|
2897
|
+
},
|
|
2898
|
+
{
|
|
2899
|
+
id: "opening",
|
|
2900
|
+
accessorKey: "opening",
|
|
2901
|
+
header: () => Ce("Opening (B/F)", "The opening balance brought forward from previous period."),
|
|
2902
|
+
size: 150,
|
|
2903
|
+
cell(l) {
|
|
2904
|
+
const v = l.row.original.opening;
|
|
2905
|
+
return h("div", { class: "text-right fm-typo-en-body-lg-400" }, me(v));
|
|
2906
|
+
},
|
|
2907
|
+
meta: {
|
|
2908
|
+
textAlign: "right"
|
|
2909
|
+
}
|
|
2910
|
+
},
|
|
2911
|
+
// Dynamic adjustment type columns
|
|
2912
|
+
..._.value.map(
|
|
2913
|
+
(l) => ({
|
|
2914
|
+
id: `adjustment_${l}`,
|
|
2915
|
+
accessorFn: (v) => v.adjustmentAmounts[l] ?? { amount: 0, precision: 0 },
|
|
2916
|
+
header: () => Ce(Ie(l)),
|
|
2917
|
+
size: 150,
|
|
2918
|
+
cell(v) {
|
|
2919
|
+
const G = v.row.original.adjustmentAmounts[l] ?? { amount: 0, precision: 0 };
|
|
2920
|
+
return h("div", { class: "text-right fm-typo-en-body-lg-400" }, me(G));
|
|
2921
|
+
},
|
|
2922
|
+
meta: {
|
|
2923
|
+
textAlign: "right"
|
|
2924
|
+
}
|
|
2925
|
+
})
|
|
2926
|
+
),
|
|
2927
|
+
{
|
|
2928
|
+
id: "systemBalance",
|
|
2929
|
+
accessorKey: "systemBalance",
|
|
2930
|
+
header: () => Ce("System Balance", "The system calculated balance before stock take."),
|
|
2931
|
+
size: 200,
|
|
2932
|
+
cell(l) {
|
|
2933
|
+
const v = l.row.original.systemBalance;
|
|
2934
|
+
return h("div", { class: "text-right fm-typo-en-body-lg-400" }, me(v));
|
|
2935
|
+
},
|
|
2936
|
+
meta: {
|
|
2937
|
+
textAlign: "right"
|
|
2938
|
+
}
|
|
2939
|
+
},
|
|
2940
|
+
{
|
|
2941
|
+
id: "physicalBalance",
|
|
2942
|
+
accessorFn: (l) => {
|
|
2943
|
+
var G;
|
|
2944
|
+
const v = (G = re.value.find((Y) => Y.id === l.id)) == null ? void 0 : G.balance;
|
|
2945
|
+
return v ? gn.toDouble(v) : l.physicalBalance;
|
|
2946
|
+
},
|
|
2947
|
+
header: () => Ce("Stock Take balance", "The physical balance recorded during stock take."),
|
|
2948
|
+
cell(l) {
|
|
2949
|
+
var pe;
|
|
2950
|
+
const v = l.row.original, G = se.fromNumber(v.physicalBalance);
|
|
2951
|
+
let Y = !0;
|
|
2952
|
+
const U = (pe = re.value.find((ce) => ce.id === v.id)) == null ? void 0 : pe.balance;
|
|
2953
|
+
let K;
|
|
2954
|
+
U && !se.equals({ a: G, b: U }) ? (Y = !1, K = me(U)) : K = me(v.physicalBalance);
|
|
2955
|
+
const ue = h("div", { class: "flex flex-col items-end" }, [
|
|
2956
|
+
h(
|
|
2957
|
+
"span",
|
|
2958
|
+
{ class: "line-clamp-1 fm-typo-en-body-lg-400 text-fm-color-typo-primary" },
|
|
2959
|
+
K
|
|
2960
|
+
),
|
|
2961
|
+
Y ? null : h(
|
|
2962
|
+
"span",
|
|
2963
|
+
{ class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" },
|
|
2964
|
+
`Draft: ${me(v.physicalBalance)}`
|
|
2965
|
+
)
|
|
2966
|
+
]);
|
|
2967
|
+
return v.breakdown.length ? h(
|
|
2968
|
+
be.FmPopover,
|
|
2969
|
+
{
|
|
2970
|
+
showPopover: ae.value === v.id,
|
|
2971
|
+
placement: "bottom-end",
|
|
2972
|
+
zIndex: 9999,
|
|
2973
|
+
"onPopover-changed": (ce) => De(v.id, ce)
|
|
2974
|
+
},
|
|
2975
|
+
{
|
|
2976
|
+
"popover-button": () => h(
|
|
2977
|
+
"button",
|
|
2978
|
+
{
|
|
2979
|
+
type: "button",
|
|
2980
|
+
class: "flex items-center gap-4 ml-auto text-fm-color-typo-secondary hover:text-fm-color-typo-primary"
|
|
2981
|
+
},
|
|
2982
|
+
[
|
|
2983
|
+
ue,
|
|
2984
|
+
h(be.FmIcon, { name: "info", size: "sm", outline: !0 })
|
|
2985
|
+
]
|
|
2986
|
+
),
|
|
2987
|
+
default: () => _o(v.breakdown, v.physicalBalance, v.baseUnit)
|
|
2988
|
+
}
|
|
2989
|
+
) : ue;
|
|
2990
|
+
},
|
|
2991
|
+
size: 200,
|
|
2992
|
+
meta: {
|
|
2993
|
+
textAlign: "right"
|
|
2994
|
+
}
|
|
2995
|
+
},
|
|
2996
|
+
{
|
|
2997
|
+
id: "adjustedAmount",
|
|
2998
|
+
accessorKey: "adjustedAmount",
|
|
2999
|
+
header: () => Ce("Variance", "The difference between Stock Take balance and System Balance."),
|
|
3000
|
+
size: 200,
|
|
3001
|
+
cell(l) {
|
|
3002
|
+
const v = l.row.original.adjustedAmount;
|
|
3003
|
+
return h("div", { class: "text-right fm-typo-en-body-lg-400" }, me(v));
|
|
3004
|
+
},
|
|
3005
|
+
meta: {
|
|
3006
|
+
textAlign: "right"
|
|
3007
|
+
}
|
|
3008
|
+
},
|
|
3009
|
+
{
|
|
3010
|
+
id: "varianceInCost",
|
|
3011
|
+
accessorKey: "varianceInCost",
|
|
3012
|
+
header: () => Ce(`Variance (${n.value})`),
|
|
3013
|
+
size: 150,
|
|
3014
|
+
cell(l) {
|
|
3015
|
+
const v = l.row.original.varianceInCost;
|
|
3016
|
+
return h("div", { class: "text-right fm-typo-en-body-lg-400" }, me(v));
|
|
3017
|
+
},
|
|
3018
|
+
meta: {
|
|
3019
|
+
textAlign: "right"
|
|
3020
|
+
}
|
|
3021
|
+
},
|
|
3022
|
+
{
|
|
3023
|
+
id: "adjustedDiffPercentage",
|
|
3024
|
+
accessorKey: "adjustedDiffPercentage",
|
|
3025
|
+
header: () => Ce(
|
|
3026
|
+
"Variance (%)",
|
|
3027
|
+
"Difference between Stock Take balance and System Balance in percentage."
|
|
3028
|
+
),
|
|
3029
|
+
size: 200,
|
|
3030
|
+
cell(l) {
|
|
3031
|
+
const v = l.row.original.adjustedDiffPercentage;
|
|
3032
|
+
if (v == null)
|
|
3033
|
+
return h(
|
|
3034
|
+
"div",
|
|
3035
|
+
{ class: "flex items-center gap-4 justify-end fm-typo-en-body-lg-400" },
|
|
3036
|
+
mr
|
|
3037
|
+
);
|
|
3038
|
+
const G = me(v);
|
|
3039
|
+
if (v === 0)
|
|
3040
|
+
return h("div", { class: "flex items-center gap-4 justify-end fm-typo-en-body-lg-400" }, [
|
|
3041
|
+
me(0)
|
|
3042
|
+
]);
|
|
3043
|
+
const Y = v > 0;
|
|
3044
|
+
return h("div", { class: "flex items-center gap-4 justify-end fm-typo-en-body-lg-400" }, [
|
|
3045
|
+
h(be.FmIcon, {
|
|
3046
|
+
name: Y ? "arrow_drop_up" : "arrow_drop_down",
|
|
3047
|
+
color: Y ? "system-success-300" : "system-error-300",
|
|
3048
|
+
size: "md"
|
|
3049
|
+
}),
|
|
3050
|
+
G
|
|
3051
|
+
]);
|
|
3052
|
+
},
|
|
3053
|
+
meta: {
|
|
3054
|
+
textAlign: "right"
|
|
3055
|
+
}
|
|
3056
|
+
},
|
|
3057
|
+
{
|
|
3058
|
+
id: "stockTakeValue",
|
|
3059
|
+
accessorKey: "stockTakeValue",
|
|
3060
|
+
header: () => Ce(`Stock take value (${n.value})`),
|
|
3061
|
+
size: 180,
|
|
3062
|
+
cell(l) {
|
|
3063
|
+
var pe;
|
|
3064
|
+
const v = l.row.original, G = v.stockTakeValue, Y = Re.value.find((ce) => ce._id === v.id), U = (pe = Y == null ? void 0 : Y.defaultCost) == null ? void 0 : pe.measurement, K = v.physicalBalance, ue = v.costPerUnit;
|
|
3065
|
+
if (U) {
|
|
3066
|
+
const ce = se.toFormatString({ value: U.conversion }), Ve = `${me(K, { minPrecision: 2, maxPrecision: 4 })} ${v.baseUnit} ÷ ${ce} × ${ue} ${n.value}`;
|
|
3067
|
+
return h(
|
|
3068
|
+
be.FmTooltip,
|
|
3069
|
+
{ zIndex: 51 },
|
|
3070
|
+
{
|
|
3071
|
+
content() {
|
|
3072
|
+
return Ve;
|
|
3073
|
+
},
|
|
3074
|
+
default() {
|
|
3075
|
+
return h(
|
|
3076
|
+
"div",
|
|
3077
|
+
{ class: "text-right w-full fm-typo-en-body-lg-400" },
|
|
3078
|
+
me(G)
|
|
3079
|
+
);
|
|
3080
|
+
}
|
|
3081
|
+
}
|
|
3082
|
+
);
|
|
3083
|
+
} else {
|
|
3084
|
+
const ce = `${me(K, { minPrecision: 2, maxPrecision: 4 })} ${v.baseUnit} × ${ue} ${n.value}`;
|
|
3085
|
+
return h(
|
|
3086
|
+
be.FmTooltip,
|
|
3087
|
+
{ zIndex: 51 },
|
|
3088
|
+
{
|
|
3089
|
+
content() {
|
|
3090
|
+
return ce;
|
|
3091
|
+
},
|
|
3092
|
+
default() {
|
|
3093
|
+
return h(
|
|
3094
|
+
"div",
|
|
3095
|
+
{ class: "text-right w-full fm-typo-en-body-lg-400" },
|
|
3096
|
+
me(G)
|
|
3097
|
+
);
|
|
3098
|
+
}
|
|
3099
|
+
}
|
|
3100
|
+
);
|
|
3101
|
+
}
|
|
3102
|
+
},
|
|
3103
|
+
meta: {
|
|
3104
|
+
textAlign: "right"
|
|
3105
|
+
}
|
|
3106
|
+
},
|
|
3107
|
+
{
|
|
3108
|
+
id: "systemValue",
|
|
3109
|
+
accessorKey: "systemValue",
|
|
3110
|
+
header: () => Ce(`System value (${n.value})`),
|
|
3111
|
+
size: 180,
|
|
3112
|
+
cell(l) {
|
|
3113
|
+
var pe;
|
|
3114
|
+
const v = l.row.original, G = v.systemValue, Y = Re.value.find((ce) => ce._id === v.id), U = (pe = Y == null ? void 0 : Y.defaultCost) == null ? void 0 : pe.measurement, K = v.systemBalance, ue = v.costPerUnit;
|
|
3115
|
+
if (U) {
|
|
3116
|
+
const ce = se.toFormatString({ value: U.conversion }), Ve = `${me(K, { minPrecision: 2, maxPrecision: 4 })} ${v.baseUnit} ÷ ${ce} × ${ue} ${n.value}`;
|
|
3117
|
+
return h(
|
|
3118
|
+
be.FmTooltip,
|
|
3119
|
+
{ zIndex: 51 },
|
|
3120
|
+
{
|
|
3121
|
+
content() {
|
|
3122
|
+
return Ve;
|
|
3123
|
+
},
|
|
3124
|
+
default() {
|
|
3125
|
+
return h(
|
|
3126
|
+
"div",
|
|
3127
|
+
{ class: "text-right fm-typo-en-body-lg-400" },
|
|
3128
|
+
me(G)
|
|
3129
|
+
);
|
|
3130
|
+
}
|
|
3131
|
+
}
|
|
3132
|
+
);
|
|
3133
|
+
} else {
|
|
3134
|
+
const ce = `${me(K, { minPrecision: 2, maxPrecision: 4 })} ${v.baseUnit} × ${ue} ${n.value}`;
|
|
3135
|
+
return h(
|
|
3136
|
+
be.FmTooltip,
|
|
3137
|
+
{ zIndex: 51 },
|
|
3138
|
+
{
|
|
3139
|
+
content() {
|
|
3140
|
+
return ce;
|
|
3141
|
+
},
|
|
3142
|
+
default() {
|
|
3143
|
+
return h(
|
|
3144
|
+
"div",
|
|
3145
|
+
{ class: "text-right fm-typo-en-body-lg-400" },
|
|
3146
|
+
me(G)
|
|
3147
|
+
);
|
|
3148
|
+
}
|
|
3149
|
+
}
|
|
3150
|
+
);
|
|
3151
|
+
}
|
|
3152
|
+
},
|
|
3153
|
+
meta: {
|
|
3154
|
+
textAlign: "right"
|
|
3155
|
+
}
|
|
3156
|
+
},
|
|
3157
|
+
{
|
|
3158
|
+
id: "physicalBalances",
|
|
3159
|
+
header: () => "Amounts",
|
|
3160
|
+
enableSorting: !1,
|
|
3161
|
+
cell(l) {
|
|
3162
|
+
const v = l.row.original;
|
|
3163
|
+
return $.value.length && v.sourceBuckets.length ? Ra(v.sourceBuckets, v.baseUnit) : Pt(v.baseUnitAmount, v.baseUnit, v.measurements);
|
|
3164
|
+
}
|
|
3165
|
+
}
|
|
3166
|
+
]), So = S(() => Et.value.map((m) => m.size ?? 0).reduce((m, l) => m + l)), wt = q(""), Fo = S(() => {
|
|
3167
|
+
var G, Y;
|
|
3168
|
+
const m = ((Y = (G = e.draft) == null ? void 0 : G.negativeStockItems) == null ? void 0 : Y.reduce(
|
|
3169
|
+
(U, K) => (U[K.sku._id] = K, U),
|
|
3170
|
+
{}
|
|
3171
|
+
)) ?? {}, l = new Map(
|
|
3172
|
+
re.value.map((U) => [U.id, U.balance])
|
|
3173
|
+
);
|
|
3174
|
+
return Re.value.map((U) => {
|
|
3175
|
+
var Kt, qt, Qt, Jt, Zt, Xt, eo, to, oo;
|
|
3176
|
+
const K = (Kt = Ao.value.get(U._id)) == null ? void 0 : Kt[0], ue = ((qt = Do.value.get(U._id)) == null ? void 0 : qt[0]) ?? Pe, pe = ((Qt = U.defaultCost) == null ? void 0 : Qt.costPerUnit) ?? Pe, ce = Number(se.toFormatString({ value: pe })), Ve = ((Zt = (Jt = U.defaultCost) == null ? void 0 : Jt.measurement) == null ? void 0 : Zt.conversion) ?? {
|
|
3177
|
+
amount: 1,
|
|
3178
|
+
precision: 0
|
|
3179
|
+
}, Be = Number(
|
|
3180
|
+
se.toFormatString({ value: Ve })
|
|
3181
|
+
), ct = Co.value.get(U._id), ut = ct ? Number(se.toFormatString({ value: ct })) : 0, Z = $o.value.get(U._id), ye = {};
|
|
3182
|
+
if (_.value.forEach((Ae) => {
|
|
3183
|
+
const mt = ye[Ae] ?? { amount: 0, precision: 0 }, pt = Z == null ? void 0 : Z[Ae];
|
|
3184
|
+
pt && (ye[Ae] = tt(mt, pt));
|
|
3185
|
+
}), !K) {
|
|
3186
|
+
const Ae = Number(se.toFormatString({ value: ue })), mt = 0 - Ae, pt = mt * ce / Be, Eo = 0, Lo = Ae * ce / Be;
|
|
3187
|
+
return {
|
|
3188
|
+
id: U._id,
|
|
3189
|
+
code: U.code,
|
|
3190
|
+
name: U.name,
|
|
3191
|
+
costUnit: ((eo = (Xt = U.defaultCost) == null ? void 0 : Xt.measurement) == null ? void 0 : eo.abbrev) ?? null,
|
|
3192
|
+
baseUnit: U.unit.abbrev,
|
|
3193
|
+
baseUnitAmount: 0,
|
|
3194
|
+
systemBalance: Ae,
|
|
3195
|
+
physicalBalance: 0,
|
|
3196
|
+
adjustedAmount: -Ae,
|
|
3197
|
+
adjustedDiffPercentage: -100,
|
|
3198
|
+
isTemplateItem: !m[U._id],
|
|
3199
|
+
costPerUnit: ce,
|
|
3200
|
+
opening: ut,
|
|
3201
|
+
varianceQty: mt,
|
|
3202
|
+
varianceInCost: pt,
|
|
3203
|
+
stockTakeValue: Eo,
|
|
3204
|
+
systemValue: Lo,
|
|
3205
|
+
adjustmentAmounts: ye,
|
|
3206
|
+
customAttributeValues: U.customAttributes ?? {},
|
|
3207
|
+
measurements: [],
|
|
3208
|
+
breakdown: [],
|
|
3209
|
+
sourceBuckets: [],
|
|
3210
|
+
subSources: []
|
|
3211
|
+
};
|
|
3212
|
+
}
|
|
3213
|
+
const ke = kt(K), Me = l.get(U._id), He = fo(
|
|
3214
|
+
Me ?? ke,
|
|
3215
|
+
ue
|
|
3216
|
+
), dt = ue.amount === 0 ? null : vo(He, {
|
|
3217
|
+
...ue,
|
|
3218
|
+
amount: Math.abs(ue.amount)
|
|
3219
|
+
}), Ht = dt ? ht(dt, at) : null, Ct = Number(se.toFormatString({ value: ue })), St = Number(se.toFormatString({ value: ke })), Yt = St - Ct, Ro = Yt * ce / Be, Mo = St * ce / Be, No = Ct * ce / Be, { baseUnitAmount: Uo, measurements: Po } = Ut(K, ze.value), Vo = ho(K, ze.value), Wt = ja(U._id, he.value, ze.value);
|
|
3220
|
+
return {
|
|
3221
|
+
id: U._id,
|
|
3222
|
+
code: U.code,
|
|
3223
|
+
name: U.name,
|
|
3224
|
+
costUnit: ((oo = (to = U.defaultCost) == null ? void 0 : to.measurement) == null ? void 0 : oo.abbrev) ?? null,
|
|
3225
|
+
baseUnit: U.unit.abbrev,
|
|
3226
|
+
baseUnitAmount: Uo,
|
|
3227
|
+
measurements: Po,
|
|
3228
|
+
breakdown: Vo,
|
|
3229
|
+
systemBalance: Ct,
|
|
3230
|
+
physicalBalance: St,
|
|
3231
|
+
adjustedAmount: Number(se.toFormatString({ value: He })),
|
|
3232
|
+
adjustedDiffPercentage: Ht ? Number(
|
|
3233
|
+
se.toFormatString({
|
|
3234
|
+
value: go(Ht, 2)
|
|
3235
|
+
})
|
|
3236
|
+
) : null,
|
|
3237
|
+
isTemplateItem: !m[U._id],
|
|
3238
|
+
costPerUnit: ce,
|
|
3239
|
+
opening: ut,
|
|
3240
|
+
varianceQty: Yt,
|
|
3241
|
+
varianceInCost: Ro,
|
|
3242
|
+
stockTakeValue: Mo,
|
|
3243
|
+
systemValue: No,
|
|
3244
|
+
adjustmentAmounts: ye,
|
|
3245
|
+
customAttributeValues: U.customAttributes ?? {},
|
|
3246
|
+
sourceBuckets: Wt,
|
|
3247
|
+
subSources: Wt.filter((Ae) => Ae.isSub).map((Ae) => Ae.label)
|
|
3248
|
+
};
|
|
3249
|
+
});
|
|
3250
|
+
}), st = S(() => Fo.value.filter((m) => !!(m.isTemplateItem && le.value.templateItem || !m.isTemplateItem && le.value.nonTemplateItem))), Lt = S(
|
|
3251
|
+
() => st.value.some((m) => m.measurements.some((l) => l.variant === "inactive"))
|
|
3252
|
+
), Gt = S(
|
|
3253
|
+
() => st.value.some((m) => m.measurements.some((l) => l.variant === "orphan"))
|
|
3254
|
+
), Io = S(
|
|
3255
|
+
() => Lt.value || Gt.value
|
|
3256
|
+
), Dt = S(() => {
|
|
3257
|
+
const m = /* @__PURE__ */ new Set();
|
|
3258
|
+
for (const l of Re.value)
|
|
3259
|
+
if (l.customAttributes)
|
|
3260
|
+
for (const v of Object.keys(l.customAttributes))
|
|
3261
|
+
v !== "tag" && m.add(v);
|
|
3262
|
+
return Array.from(m).sort();
|
|
3263
|
+
}), rt = no({}), zt = S(
|
|
3264
|
+
() => Dt.value.filter((m) => rt[m])
|
|
3265
|
+
), Bo = S(() => {
|
|
3266
|
+
var m;
|
|
3267
|
+
return e.draft ? ko(e.draft, {
|
|
3268
|
+
idDisplay: r.value,
|
|
3269
|
+
locationName: (m = ve._currentLocation) == null ? void 0 : m.name
|
|
3270
|
+
}) : [];
|
|
3271
|
+
}), At = [
|
|
3272
|
+
{
|
|
3273
|
+
label: "Overview",
|
|
3274
|
+
value: "overview"
|
|
3275
|
+
},
|
|
3276
|
+
{
|
|
3277
|
+
label: "Action history",
|
|
3278
|
+
value: "history"
|
|
3279
|
+
}
|
|
3280
|
+
], Je = q(At[0]), Oe = S(() => {
|
|
3281
|
+
var G, Y, U;
|
|
3282
|
+
const m = ((G = e.draft) == null ? void 0 : G.activityLogs) ?? [], l = ((Y = e.draft) == null ? void 0 : Y.rejectionHistory) ?? [];
|
|
3283
|
+
for (const K of l)
|
|
3284
|
+
m.find(
|
|
3285
|
+
(pe) => `${pe.action}_${pe.performedAt}` == `${fe.enum.rejectDraft}_${K.rejectedAt}`
|
|
3286
|
+
) || m.push({
|
|
3287
|
+
action: fe.enum.rejectDraft,
|
|
3288
|
+
performedAt: K.rejectedAt,
|
|
3289
|
+
performedBy: K.rejectedBy,
|
|
3290
|
+
remark: K.rejectRemark
|
|
3291
|
+
});
|
|
3292
|
+
return (U = e.draft) != null && U.approvedAt && (m.find(
|
|
3293
|
+
(ue) => {
|
|
3294
|
+
var pe;
|
|
3295
|
+
return `${ue.action}_${ue.performedAt}` == `${fe.enum.approveDraft}_${(pe = e.draft) == null ? void 0 : pe.approvedAt}`;
|
|
3296
|
+
}
|
|
3297
|
+
) || m.push({
|
|
3298
|
+
action: fe.enum.approveDraft,
|
|
3299
|
+
performedAt: e.draft.approvedAt,
|
|
3300
|
+
performedBy: e.draft.approvedBy ?? { name: "Unknown", id: "unknown" },
|
|
3301
|
+
remark: e.draft.approveRemark
|
|
3302
|
+
})), m.sort((K, ue) => new Date(ue.performedAt).getTime() - new Date(K.performedAt).getTime()).map(
|
|
3303
|
+
(K) => ({
|
|
3304
|
+
header: Ie(K.action),
|
|
3305
|
+
date: Fe(K.performedAt),
|
|
3306
|
+
info: [
|
|
3307
|
+
{
|
|
3308
|
+
label: "Performed by",
|
|
3309
|
+
values: [K.performedBy.name]
|
|
3310
|
+
},
|
|
3311
|
+
{
|
|
3312
|
+
label: "Remark",
|
|
3313
|
+
values: [K.remark ?? ""]
|
|
3314
|
+
}
|
|
3315
|
+
]
|
|
3316
|
+
})
|
|
3317
|
+
);
|
|
3318
|
+
}), lt = q(!1), it = q(!1), $t = q(!1), Ot = S(() => {
|
|
3319
|
+
var m;
|
|
3320
|
+
return ((m = e.draft) == null ? void 0 : m.status) !== xe.enum.DRAFT ? "Status is not draft." : null;
|
|
3321
|
+
});
|
|
3322
|
+
async function To(m) {
|
|
3323
|
+
if (e.draft) {
|
|
3324
|
+
$t.value = !0;
|
|
3325
|
+
try {
|
|
3326
|
+
const l = await u.approveAllClosingGroups(e.draft._id, m);
|
|
3327
|
+
$.value = l;
|
|
3328
|
+
} catch (l) {
|
|
3329
|
+
L.open({
|
|
3330
|
+
title: "Failed to approve all groups",
|
|
3331
|
+
message: (l == null ? void 0 : l.message) || "An unexpected error occurred.",
|
|
3332
|
+
type: "error"
|
|
3333
|
+
});
|
|
3334
|
+
} finally {
|
|
3335
|
+
$t.value = !1;
|
|
3336
|
+
}
|
|
3337
|
+
}
|
|
3338
|
+
}
|
|
3339
|
+
function jo() {
|
|
3340
|
+
e.draft && (it.value = !0, s.approveDraft(
|
|
3341
|
+
e.draft,
|
|
3342
|
+
() => {
|
|
3343
|
+
it.value = !1, lt.value = !1, p("submitted");
|
|
3344
|
+
},
|
|
3345
|
+
() => {
|
|
3346
|
+
it.value = !1;
|
|
3347
|
+
}
|
|
3348
|
+
));
|
|
3349
|
+
}
|
|
3350
|
+
return (m, l) => {
|
|
3351
|
+
const v = ee("FmButtonGroup"), G = ee("FmMenuDivider"), Y = ee("FmCard"), U = ee("FmIcon"), K = ee("FmButton"), ue = ee("FmCircularProgress"), pe = ee("FmChip"), ce = ee("FmTextField"), Ve = ee("FmTable"), Be = ee("FmSpacer"), ct = ee("FmTooltip"), ut = ee("FmSideSheet");
|
|
3352
|
+
return f(), C(ie, null, [
|
|
3353
|
+
D(ut, {
|
|
3354
|
+
"dismiss-away": "",
|
|
3355
|
+
"max-width": 9999,
|
|
3356
|
+
"model-value": d(c),
|
|
3357
|
+
"onUpdate:modelValue": l[9] || (l[9] = (Z) => bt(c) ? c.value = Z : null),
|
|
3358
|
+
header: "Closing details"
|
|
3359
|
+
}, {
|
|
3360
|
+
"side-sheet-footer": te(() => {
|
|
3361
|
+
var Z, ye, ke, Me;
|
|
3362
|
+
return [
|
|
3363
|
+
a("div", ir, [
|
|
3364
|
+
a("div", cr, [
|
|
3365
|
+
((Z = e.draft) == null ? void 0 : Z.status) === d(xe).enum.DRAFT ? (f(), C(ie, { key: 0 }, [
|
|
3366
|
+
Ot.value ? (f(), ne(ct, {
|
|
3367
|
+
key: 0,
|
|
3368
|
+
"z-index": 51,
|
|
3369
|
+
placement: "right"
|
|
3370
|
+
}, {
|
|
3371
|
+
content: te(() => [
|
|
3372
|
+
ge(E(Ot.value), 1)
|
|
3373
|
+
]),
|
|
3374
|
+
default: te(() => [
|
|
3375
|
+
D(K, {
|
|
3376
|
+
disabled: "",
|
|
3377
|
+
key: "approve key",
|
|
3378
|
+
label: "Approve"
|
|
3379
|
+
})
|
|
3380
|
+
]),
|
|
3381
|
+
_: 1
|
|
3382
|
+
})) : (f(), ne(K, {
|
|
3383
|
+
key: "approve key",
|
|
3384
|
+
label: "Approve",
|
|
3385
|
+
onClick: l[5] || (l[5] = (He) => lt.value = !0)
|
|
3386
|
+
}))
|
|
3387
|
+
], 64)) : W("", !0),
|
|
3388
|
+
((ye = e.draft) == null ? void 0 : ye.status) === d(xe).enum.DRAFT ? (f(), ne(K, {
|
|
3389
|
+
key: 1,
|
|
3390
|
+
label: "Reject",
|
|
3391
|
+
variant: "destructive",
|
|
3392
|
+
onClick: l[6] || (l[6] = () => e.draft && d(s).rejectDraft(e.draft, () => p("submitted")))
|
|
3393
|
+
})) : W("", !0),
|
|
3394
|
+
D(K, {
|
|
3395
|
+
label: "Close",
|
|
3396
|
+
variant: "tertiary",
|
|
3397
|
+
onClick: l[7] || (l[7] = (He) => c.value = !1)
|
|
3398
|
+
}),
|
|
3399
|
+
(ke = e.draft) != null && ke.approvedAt && ((Me = e.draft) == null ? void 0 : Me.status) !== d(xe).enum.COMPLETED ? (f(), ne(Ft, { key: 2 }, {
|
|
3400
|
+
default: te(() => [
|
|
3401
|
+
D(K, {
|
|
3402
|
+
label: "Sync",
|
|
3403
|
+
loading: y.value,
|
|
3404
|
+
onClick: l[8] || (l[8] = () => {
|
|
3405
|
+
e.draft && (y.value = !0, d(s).syncDraft(e.draft, () => {
|
|
3406
|
+
y.value = !1, p("submitted");
|
|
3407
|
+
}));
|
|
3408
|
+
})
|
|
3409
|
+
}, null, 8, ["loading"])
|
|
3410
|
+
]),
|
|
3411
|
+
_: 1
|
|
3412
|
+
})) : W("", !0)
|
|
3413
|
+
]),
|
|
3414
|
+
a("div", ur, [
|
|
3415
|
+
l[25] || (l[25] = a("div", { class: "text-xs text-gray-500 uppercase tracking-wide" }, "Total stock take value", -1)),
|
|
3416
|
+
a("div", dr, E(n.value) + " " + E(nt.value.toFixed(2)), 1)
|
|
3417
|
+
])
|
|
3418
|
+
])
|
|
3419
|
+
];
|
|
3420
|
+
}),
|
|
3421
|
+
default: te(() => [
|
|
3422
|
+
a("div", hs, [
|
|
3423
|
+
a("div", null, [
|
|
3424
|
+
D(v, {
|
|
3425
|
+
items: At,
|
|
3426
|
+
modelValue: Je.value,
|
|
3427
|
+
"onUpdate:modelValue": l[0] || (l[0] = (Z) => Je.value = Z)
|
|
3428
|
+
}, null, 8, ["modelValue"])
|
|
3429
|
+
]),
|
|
3430
|
+
Je.value.value === "overview" ? (f(), C(ie, { key: 0 }, [
|
|
3431
|
+
D(Ft, { selectable: "" }, {
|
|
3432
|
+
default: te(() => {
|
|
3433
|
+
var Z;
|
|
3434
|
+
return [
|
|
3435
|
+
a("div", _s, [
|
|
3436
|
+
l[12] || (l[12] = a("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, [
|
|
3437
|
+
a("div", { class: "flex gap-1" }, "Draft ID")
|
|
3438
|
+
], -1)),
|
|
3439
|
+
ge(" " + E((Z = m.draft) == null ? void 0 : Z._id), 1)
|
|
3440
|
+
])
|
|
3441
|
+
];
|
|
3442
|
+
}),
|
|
3443
|
+
_: 1
|
|
3444
|
+
}),
|
|
3445
|
+
D(Y, {
|
|
3446
|
+
variant: "outlined",
|
|
3447
|
+
class: "flex flex-col gap-8 px-12 py-16"
|
|
3448
|
+
}, {
|
|
3449
|
+
default: te(() => {
|
|
3450
|
+
var Z, ye;
|
|
3451
|
+
return [
|
|
3452
|
+
a("div", ks, [
|
|
3453
|
+
l[13] || (l[13] = a("div", { class: "fm-typo-en-body-lg-600" }, "Closing summary", -1)),
|
|
3454
|
+
a("div", xs, [
|
|
3455
|
+
a("div", {
|
|
3456
|
+
class: we(["fm-status-badge", d(Ne)(((Z = m.draft) == null ? void 0 : Z.status) ?? "DRAFT")])
|
|
3457
|
+
}, E(d(Ie)(((ye = m.draft) == null ? void 0 : ye.status) ?? "")), 3)
|
|
3458
|
+
])
|
|
3459
|
+
]),
|
|
3460
|
+
D(G),
|
|
3461
|
+
a("div", ws, [
|
|
3462
|
+
(f(!0), C(ie, null, _e(Bo.value, (ke, Me) => (f(), C("div", {
|
|
3463
|
+
class: "flex flex-col gap-4",
|
|
3464
|
+
key: Me
|
|
3465
|
+
}, [
|
|
3466
|
+
a("div", Ds, [
|
|
3467
|
+
a("div", As, E(ke.label), 1)
|
|
3468
|
+
]),
|
|
3469
|
+
a("div", $s, E(ke.value), 1)
|
|
3470
|
+
]))), 128))
|
|
3471
|
+
])
|
|
3472
|
+
];
|
|
3473
|
+
}),
|
|
3474
|
+
_: 1
|
|
3475
|
+
}),
|
|
3476
|
+
N.value.length ? (f(), ne(Y, {
|
|
3477
|
+
key: 0,
|
|
3478
|
+
variant: "outlined",
|
|
3479
|
+
class: "flex flex-col gap-8 px-12 py-16"
|
|
3480
|
+
}, {
|
|
3481
|
+
default: te(() => [
|
|
3482
|
+
a("div", Cs, [
|
|
3483
|
+
a("div", Ss, "Groups " + E(N.value.length), 1),
|
|
3484
|
+
l[14] || (l[14] = a("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Parent totals = sum of all groups ", -1))
|
|
3485
|
+
]),
|
|
3486
|
+
D(G),
|
|
3487
|
+
D(Fa, {
|
|
3488
|
+
groups: N.value,
|
|
3489
|
+
onSelect: F
|
|
3490
|
+
}, null, 8, ["groups"])
|
|
3491
|
+
]),
|
|
3492
|
+
_: 1
|
|
3493
|
+
})) : W("", !0),
|
|
3494
|
+
Io.value ? (f(), C("div", Fs, [
|
|
3495
|
+
D(U, {
|
|
3496
|
+
name: "rule",
|
|
3497
|
+
size: "sm"
|
|
3498
|
+
}),
|
|
3499
|
+
a("div", Is, [
|
|
3500
|
+
l[16] || (l[16] = a("div", { class: "fm-typo-en-body-md-600" }, "UOM notes", -1)),
|
|
3501
|
+
a("ul", Bs, [
|
|
3502
|
+
Lt.value ? (f(), C("li", Ts, l[15] || (l[15] = [
|
|
3503
|
+
ge(" Measurements highlighted in "),
|
|
3504
|
+
a("span", { class: "font-bold" }, "purple", -1),
|
|
3505
|
+
ge(" are NetSuite-inactive UOMs (surfaced for audit; their amounts are part of the base total). ")
|
|
3506
|
+
]))) : W("", !0),
|
|
3507
|
+
Gt.value ? (f(), C("li", js, " Red highlights are UOMs not on the SKU (ignored). ")) : W("", !0)
|
|
3508
|
+
])
|
|
3509
|
+
])
|
|
3510
|
+
])) : W("", !0),
|
|
3511
|
+
a("div", Rs, [
|
|
3512
|
+
a("div", Ms, [
|
|
3513
|
+
l[17] || (l[17] = a("div", { class: "flex-1 fm-typo-en-title-sm-600 text-fm-color-typo-primary" }, " Closing items ", -1)),
|
|
3514
|
+
b.value ? W("", !0) : (f(), C("div", Ns, [
|
|
3515
|
+
m.draft && m.draft.status !== d(xe).enum.COMPLETED ? (f(), ne(K, {
|
|
3516
|
+
key: 0,
|
|
3517
|
+
label: "Refresh balance",
|
|
3518
|
+
"prepend-icon": "refresh",
|
|
3519
|
+
variant: "secondary",
|
|
3520
|
+
"text-color": "primary",
|
|
3521
|
+
"bg-color": "transparent",
|
|
3522
|
+
"border-color": "primary",
|
|
3523
|
+
loading: d(H),
|
|
3524
|
+
disabled: d(H),
|
|
3525
|
+
onClick: Vt
|
|
3526
|
+
}, null, 8, ["loading", "disabled"])) : W("", !0),
|
|
3527
|
+
D(Ft, null, {
|
|
3528
|
+
default: te(() => [
|
|
3529
|
+
D(K, {
|
|
3530
|
+
label: "Invalidate Draft Cache",
|
|
3531
|
+
"prepend-icon": "refresh",
|
|
3532
|
+
variant: "secondary",
|
|
3533
|
+
"text-color": "primary",
|
|
3534
|
+
"bg-color": "transparent",
|
|
3535
|
+
"border-color": "primary",
|
|
3536
|
+
loading: d(H),
|
|
3537
|
+
onClick: wo
|
|
3538
|
+
}, null, 8, ["loading"])
|
|
3539
|
+
]),
|
|
3540
|
+
_: 1
|
|
3541
|
+
}),
|
|
3542
|
+
D(K, {
|
|
3543
|
+
label: "Export data",
|
|
3544
|
+
"prepend-icon": "download",
|
|
3545
|
+
variant: "secondary",
|
|
3546
|
+
"text-color": "primary",
|
|
3547
|
+
"bg-color": "transparent",
|
|
3548
|
+
"border-color": "primary",
|
|
3549
|
+
onClick: l[1] || (l[1] = (Z) => m.draft ? d(s).exportDraft(
|
|
3550
|
+
m.draft,
|
|
3551
|
+
x.value,
|
|
3552
|
+
re.value,
|
|
3553
|
+
zt.value
|
|
3554
|
+
) : null)
|
|
3555
|
+
})
|
|
3556
|
+
]))
|
|
3557
|
+
]),
|
|
3558
|
+
b.value ? (f(), C("div", Us, [
|
|
3559
|
+
l[19] || (l[19] = a("div", { class: "h-80" }, null, -1)),
|
|
3560
|
+
a("div", Ps, [
|
|
3561
|
+
a("div", null, [
|
|
3562
|
+
D(ue, { size: "md" })
|
|
3563
|
+
]),
|
|
3564
|
+
l[18] || (l[18] = a("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Fetching info... ", -1))
|
|
3565
|
+
]),
|
|
3566
|
+
l[20] || (l[20] = a("div", { class: "h-80" }, null, -1))
|
|
3567
|
+
])) : (f(), C(ie, { key: 1 }, [
|
|
3568
|
+
a("div", Vs, [
|
|
3569
|
+
a("div", Es, [
|
|
3570
|
+
D(pe, {
|
|
3571
|
+
label: "Template Item(s)",
|
|
3572
|
+
selected: le.value.templateItem,
|
|
3573
|
+
onClick: l[2] || (l[2] = (Z) => le.value.templateItem = !le.value.templateItem)
|
|
3574
|
+
}, null, 8, ["selected"]),
|
|
3575
|
+
D(pe, {
|
|
3576
|
+
label: "Non-template Item(s)",
|
|
3577
|
+
selected: le.value.nonTemplateItem,
|
|
3578
|
+
onClick: l[3] || (l[3] = (Z) => le.value.nonTemplateItem = !le.value.nonTemplateItem)
|
|
3579
|
+
}, null, 8, ["selected"])
|
|
3580
|
+
]),
|
|
3581
|
+
D(ce, {
|
|
3582
|
+
modelValue: wt.value,
|
|
3583
|
+
"onUpdate:modelValue": l[4] || (l[4] = (Z) => wt.value = Z),
|
|
3584
|
+
placeholder: "Filter items"
|
|
3585
|
+
}, null, 8, ["modelValue"])
|
|
3586
|
+
]),
|
|
3587
|
+
d(P).skuTags.size ? (f(), C("div", Ls, [
|
|
3588
|
+
(f(!0), C(ie, null, _e(d(P).skuTags.keys(), (Z) => (f(), ne(pe, {
|
|
3589
|
+
key: `${Z}`,
|
|
3590
|
+
label: `${Z}`,
|
|
3591
|
+
selectable: "",
|
|
3592
|
+
selected: oe[`${Z}`],
|
|
3593
|
+
onClick: (ye) => oe[`${Z}`] = !oe[`${Z}`]
|
|
3594
|
+
}, {
|
|
3595
|
+
default: te(() => [
|
|
3596
|
+
oe[`${Z}`] ? (f(), ne(U, {
|
|
3597
|
+
key: 0,
|
|
3598
|
+
name: "check",
|
|
3599
|
+
class: "text-white",
|
|
3600
|
+
size: "sm"
|
|
3601
|
+
})) : W("", !0),
|
|
3602
|
+
a("span", {
|
|
3603
|
+
class: we([
|
|
3604
|
+
"",
|
|
3605
|
+
{
|
|
3606
|
+
"text-white fm-typo-en-body-md-600": oe[`${Z}`],
|
|
3607
|
+
"text-fm-color-typo-primary fm-typo-en-body-md-400": !oe[`${Z}`]
|
|
3608
|
+
}
|
|
3609
|
+
])
|
|
3610
|
+
}, E(Z), 3)
|
|
3611
|
+
]),
|
|
3612
|
+
_: 2
|
|
3613
|
+
}, 1032, ["label", "selected", "onClick"]))), 128))
|
|
3614
|
+
])) : W("", !0),
|
|
3615
|
+
Dt.value.length ? (f(), C("div", Gs, [
|
|
3616
|
+
l[21] || (l[21] = a("span", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary self-center" }, "Extra columns:", -1)),
|
|
3617
|
+
(f(!0), C(ie, null, _e(Dt.value, (Z) => (f(), ne(pe, {
|
|
3618
|
+
key: Z,
|
|
3619
|
+
label: Z,
|
|
3620
|
+
selectable: "",
|
|
3621
|
+
selected: rt[Z],
|
|
3622
|
+
onClick: (ye) => rt[Z] = !rt[Z]
|
|
3623
|
+
}, null, 8, ["label", "selected", "onClick"]))), 128))
|
|
3624
|
+
])) : W("", !0),
|
|
3625
|
+
a("div", zs, [
|
|
3626
|
+
a("div", {
|
|
3627
|
+
style: gt({ height: "600px", minWidth: `${So.value}px` })
|
|
3628
|
+
}, [
|
|
3629
|
+
D(Ve, {
|
|
3630
|
+
"column-defs": Et.value,
|
|
3631
|
+
"row-data": st.value,
|
|
3632
|
+
"search-value": wt.value
|
|
3633
|
+
}, null, 8, ["column-defs", "row-data", "search-value"])
|
|
3634
|
+
], 4)
|
|
3635
|
+
])
|
|
3636
|
+
], 64))
|
|
3637
|
+
])
|
|
3638
|
+
], 64)) : W("", !0),
|
|
3639
|
+
Je.value.value === "history" ? (f(), C("div", Os, [
|
|
3640
|
+
Oe.value.length ? (f(), C("div", Ws, [
|
|
3641
|
+
(f(!0), C(ie, null, _e(Oe.value, (Z, ye) => (f(), C(ie, { key: ye }, [
|
|
3642
|
+
a("div", Ks, [
|
|
3643
|
+
a("div", qs, [
|
|
3644
|
+
a("div", Qs, [
|
|
3645
|
+
a("div", {
|
|
3646
|
+
class: we([
|
|
3647
|
+
{
|
|
3648
|
+
"bg-fm-color-primary": ye !== 0,
|
|
3649
|
+
"bg-white": ye === 0
|
|
3650
|
+
},
|
|
3651
|
+
"w-[2px] h-full"
|
|
3652
|
+
])
|
|
3653
|
+
}, null, 2)
|
|
3654
|
+
]),
|
|
3655
|
+
l[24] || (l[24] = a("div", { class: "h-24 w-24 bg-fm-color-primary rounded-full" }, null, -1)),
|
|
3656
|
+
a("div", Js, [
|
|
3657
|
+
a("div", {
|
|
3658
|
+
class: we([
|
|
3659
|
+
{
|
|
3660
|
+
"bg-fm-color-primary": ye < Oe.value.length - 1,
|
|
3661
|
+
"bg-white": ye >= Oe.value.length - 1
|
|
3662
|
+
},
|
|
3663
|
+
"w-[2px] h-full"
|
|
3664
|
+
])
|
|
3665
|
+
}, null, 2)
|
|
3666
|
+
])
|
|
3667
|
+
]),
|
|
3668
|
+
a("div", Zs, [
|
|
3669
|
+
a("div", Xs, E(Z.header), 1),
|
|
3670
|
+
a("div", er, E(Z.date), 1)
|
|
3671
|
+
])
|
|
3672
|
+
]),
|
|
3673
|
+
a("div", tr, [
|
|
3674
|
+
a("div", or, [
|
|
3675
|
+
a("div", nr, [
|
|
3676
|
+
a("div", {
|
|
3677
|
+
class: we([
|
|
3678
|
+
{
|
|
3679
|
+
"bg-fm-color-primary": ye < Oe.value.length - 1,
|
|
3680
|
+
"bg-white": ye >= Oe.value.length - 1
|
|
3681
|
+
},
|
|
3682
|
+
"w-[2px] h-full"
|
|
3683
|
+
])
|
|
3684
|
+
}, null, 2)
|
|
3685
|
+
])
|
|
3686
|
+
]),
|
|
3687
|
+
a("div", ar, [
|
|
3688
|
+
D(Y, {
|
|
3689
|
+
variant: "outlined",
|
|
3690
|
+
class: "py-12 px-16"
|
|
3691
|
+
}, {
|
|
3692
|
+
default: te(() => [
|
|
3693
|
+
a("div", sr, [
|
|
3694
|
+
(f(!0), C(ie, null, _e(Z.info, (ke, Me) => (f(), C("div", {
|
|
3695
|
+
key: Me,
|
|
3696
|
+
class: "flex flex-col gap-4"
|
|
3697
|
+
}, [
|
|
3698
|
+
a("div", rr, E(ke == null ? void 0 : ke.label), 1),
|
|
3699
|
+
a("div", lr, [
|
|
3700
|
+
(f(!0), C(ie, null, _e(ke == null ? void 0 : ke.values, (He, dt) => (f(), C("div", {
|
|
3701
|
+
key: dt,
|
|
3702
|
+
class: "fm-typo-en-body-lg-600"
|
|
3703
|
+
}, E(He), 1))), 128))
|
|
3704
|
+
])
|
|
3705
|
+
]))), 128))
|
|
3706
|
+
])
|
|
3707
|
+
]),
|
|
3708
|
+
_: 2
|
|
3709
|
+
}, 1024)
|
|
3710
|
+
])
|
|
3711
|
+
])
|
|
3712
|
+
], 64))), 128))
|
|
3713
|
+
])) : (f(), C("div", Hs, [
|
|
3714
|
+
D(Be),
|
|
3715
|
+
a("div", null, [
|
|
3716
|
+
a("img", {
|
|
3717
|
+
src: d(yo),
|
|
3718
|
+
alt: "List is empty"
|
|
3719
|
+
}, null, 8, Ys)
|
|
3720
|
+
]),
|
|
3721
|
+
l[22] || (l[22] = a("div", { class: "fm-typo-en-body-lg-600" }, E("No records found"), -1)),
|
|
3722
|
+
l[23] || (l[23] = a("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary px-16" }, E("You can track approval and rejection history here"), -1)),
|
|
3723
|
+
D(Be),
|
|
3724
|
+
D(Be)
|
|
3725
|
+
]))
|
|
3726
|
+
])) : W("", !0)
|
|
3727
|
+
])
|
|
3728
|
+
]),
|
|
3729
|
+
_: 1
|
|
3730
|
+
}, 8, ["model-value"]),
|
|
3731
|
+
d(c) && e.draft ? (f(), ne(ya, {
|
|
3732
|
+
key: 0,
|
|
3733
|
+
show: lt.value,
|
|
3734
|
+
"onUpdate:show": l[10] || (l[10] = (Z) => lt.value = Z),
|
|
3735
|
+
refreshing: d(H),
|
|
3736
|
+
approving: it.value,
|
|
3737
|
+
"approving-all-groups": $t.value,
|
|
3738
|
+
draft: e.draft,
|
|
3739
|
+
groups: $.value,
|
|
3740
|
+
onRefresh: Vt,
|
|
3741
|
+
onApprove: jo,
|
|
3742
|
+
onApproveAllGroups: To
|
|
3743
|
+
}, null, 8, ["show", "refreshing", "approving", "approving-all-groups", "draft", "groups"])) : W("", !0),
|
|
3744
|
+
D(bs, {
|
|
3745
|
+
show: O.value,
|
|
3746
|
+
"onUpdate:show": l[11] || (l[11] = (Z) => O.value = Z),
|
|
3747
|
+
group: X.value ?? void 0,
|
|
3748
|
+
"parent-name": J.value,
|
|
3749
|
+
onUpdated: I
|
|
3750
|
+
}, null, 8, ["show", "group", "parent-name"])
|
|
3751
|
+
], 64);
|
|
3752
|
+
};
|
|
3753
|
+
}
|
|
3754
|
+
});
|
|
3755
|
+
var $e = /* @__PURE__ */ ((t) => (t.ready = "ready", t.negative = "negative", t.systemNegative = "systemNegative", t))($e || {});
|
|
3756
|
+
async function fr(t) {
|
|
3757
|
+
return new Promise((o, e) => {
|
|
3758
|
+
const n = new FileReader();
|
|
3759
|
+
n.onload = (i) => {
|
|
3760
|
+
var r;
|
|
3761
|
+
try {
|
|
3762
|
+
const s = (r = i.target) == null ? void 0 : r.result, u = rn(s, { type: "array" }), c = u.SheetNames[0], b = u.Sheets[c], y = vt.sheet_to_json(b, {
|
|
3763
|
+
header: 1,
|
|
3764
|
+
defval: ""
|
|
3765
|
+
}), $ = (X) => String(X).trim().toLowerCase().replace(/^\uFEFF/, ""), Q = y.findIndex(
|
|
3766
|
+
(X) => X.some((O) => $(O) === "code")
|
|
3767
|
+
);
|
|
3768
|
+
if (Q === -1) {
|
|
3769
|
+
o([]);
|
|
3770
|
+
return;
|
|
3771
|
+
}
|
|
3772
|
+
const V = y[Q], B = V.findIndex((X) => $(X) === "code"), I = V.findIndex((X) => $(X) === "balance");
|
|
3773
|
+
if (B === -1 || I === -1) {
|
|
3774
|
+
e(
|
|
3775
|
+
new Error(
|
|
3776
|
+
`Missing required columns: ${B === -1 ? '"Code" ' : ""}${I === -1 ? '"Balance"' : ""}.`.trim()
|
|
3777
|
+
)
|
|
3778
|
+
);
|
|
3779
|
+
return;
|
|
3780
|
+
}
|
|
3781
|
+
const J = y.slice(Q + 1).filter((X) => String(X[B]).trim()).map((X) => ({
|
|
3782
|
+
itemCode: String(X[B]).trim(),
|
|
3783
|
+
quantity: Number(X[I]) || 0
|
|
3784
|
+
}));
|
|
3785
|
+
o(J);
|
|
3786
|
+
} catch (s) {
|
|
3787
|
+
e(s);
|
|
3788
|
+
}
|
|
3789
|
+
}, n.onerror = e, n.readAsArrayBuffer(t);
|
|
3790
|
+
});
|
|
3791
|
+
}
|
|
3792
|
+
function vr(t) {
|
|
3793
|
+
const o = /* @__PURE__ */ new Map();
|
|
3794
|
+
return t.forEach((e) => {
|
|
3795
|
+
const n = o.get(e.itemCode) || 0;
|
|
3796
|
+
o.set(e.itemCode, n + e.quantity);
|
|
3797
|
+
}), o;
|
|
3798
|
+
}
|
|
3799
|
+
function gr(t, o) {
|
|
3800
|
+
const e = [], n = [];
|
|
3801
|
+
for (const [i, r] of o.entries()) {
|
|
3802
|
+
const s = t[i];
|
|
3803
|
+
if (!s) {
|
|
3804
|
+
n.push(i);
|
|
3805
|
+
continue;
|
|
3806
|
+
}
|
|
3807
|
+
const u = r < 0 ? "negative" : "ready";
|
|
3808
|
+
e.push({
|
|
3809
|
+
sku: s,
|
|
3810
|
+
physicalCount: r,
|
|
3811
|
+
// Note: filled by composable after readStockBalance()
|
|
3812
|
+
systemBalance: { amount: 0, precision: 0 },
|
|
3813
|
+
variance: r - 0,
|
|
3814
|
+
status: u
|
|
3815
|
+
});
|
|
3816
|
+
}
|
|
3817
|
+
return { mergedItems: e, unrecognisedItemCodes: n };
|
|
3818
|
+
}
|
|
3819
|
+
function yr(t, o) {
|
|
3820
|
+
const e = t.filter((c) => !c.isInactive), n = bn().format("YYYY-MM-DD"), i = `${o} - ${n}.csv`, r = [
|
|
3821
|
+
["Code", "Name", "Balance"],
|
|
3822
|
+
...e.map((c) => [c.code, c.name, ""])
|
|
3823
|
+
], s = vt.aoa_to_sheet(r), u = vt.book_new();
|
|
3824
|
+
vt.book_append_sheet(u, s, "Template"), sn(u, i, { bookType: "csv" });
|
|
3825
|
+
}
|
|
3826
|
+
function br() {
|
|
3827
|
+
const t = q([]), o = q([]), e = q(!1), n = jt(), i = Qe(), r = _t(), s = S(
|
|
3828
|
+
() => t.value.some((y) => y.status === $e.negative)
|
|
3829
|
+
);
|
|
3830
|
+
async function u(y) {
|
|
3831
|
+
t.value = [], o.value = [], e.value = !0;
|
|
3832
|
+
try {
|
|
3833
|
+
const $ = await fr(y), Q = vr($), V = n.skuByCode, { mergedItems: B, unrecognisedItemCodes: I } = gr(
|
|
3834
|
+
V,
|
|
3835
|
+
Q
|
|
3836
|
+
), N = await r.readStockBalance(), J = N.skus ?? [];
|
|
3837
|
+
J.length === 0 && console.warn(
|
|
3838
|
+
"No SKU balances found when importing closing draft. All system balances will be set to 0.",
|
|
3839
|
+
{
|
|
3840
|
+
stockBalance: N
|
|
3841
|
+
}
|
|
3842
|
+
);
|
|
3843
|
+
const X = new Map(
|
|
3844
|
+
J.map((F) => [F.id, F.balance])
|
|
3845
|
+
), O = new Set(B.map((F) => F.sku._id));
|
|
3846
|
+
t.value = B.map((F) => {
|
|
3847
|
+
const T = X.get(F.sku._id) ?? { amount: 0, precision: 0 }, k = T.amount / Math.pow(10, T.precision);
|
|
3848
|
+
return { ...F, systemBalance: T, variance: F.physicalCount - k };
|
|
3849
|
+
});
|
|
3850
|
+
for (const F of Object.values(n.skuByCode)) {
|
|
3851
|
+
if (O.has(F._id)) continue;
|
|
3852
|
+
const T = X.get(F._id);
|
|
3853
|
+
if (!T) continue;
|
|
3854
|
+
const k = T.amount / Math.pow(10, T.precision);
|
|
3855
|
+
k >= 0 || t.value.push({
|
|
3856
|
+
sku: F,
|
|
3857
|
+
physicalCount: 0,
|
|
3858
|
+
systemBalance: T,
|
|
3859
|
+
variance: 0 - k,
|
|
3860
|
+
status: $e.systemNegative
|
|
3861
|
+
});
|
|
3862
|
+
}
|
|
3863
|
+
o.value = I;
|
|
3864
|
+
} catch ($) {
|
|
3865
|
+
t.value = [], o.value = [], console.error("Error processing uploaded file", { error: $ });
|
|
3866
|
+
} finally {
|
|
3867
|
+
e.value = !1;
|
|
3868
|
+
}
|
|
3869
|
+
}
|
|
3870
|
+
async function c() {
|
|
3871
|
+
const y = Ge(), $ = t.value.filter((J) => J.status === $e.ready), Q = t.value.filter(
|
|
3872
|
+
(J) => J.status === $e.systemNegative
|
|
3873
|
+
), V = (J) => ({
|
|
3874
|
+
sku: {
|
|
3875
|
+
_id: J.sku._id,
|
|
3876
|
+
code: J.sku.code,
|
|
3877
|
+
name: J.sku.name,
|
|
3878
|
+
unit: J.sku.unit
|
|
3879
|
+
},
|
|
3880
|
+
baseAmount: on(J.physicalCount, J.sku.unit.precision),
|
|
3881
|
+
measurementsAmounts: []
|
|
3882
|
+
}), B = $.map(V), I = Q.map(V), N = {
|
|
3883
|
+
effectiveAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3884
|
+
items: B,
|
|
3885
|
+
negativeStockItems: I
|
|
3886
|
+
};
|
|
3887
|
+
return await y.createQuickModeDraftWithItems(N);
|
|
3888
|
+
}
|
|
3889
|
+
function b() {
|
|
3890
|
+
var $;
|
|
3891
|
+
const y = (($ = i.currentLocation) == null ? void 0 : $.name) ?? "template";
|
|
3892
|
+
yr(n.skus, y);
|
|
3893
|
+
}
|
|
3894
|
+
return { mergedItems: t, unrecognisedItemCodes: o, hasBlockingErrors: s, isLoading: e, onFileUpload: u, submit: c, downloadTemplate: b };
|
|
3895
|
+
}
|
|
3896
|
+
const hr = { class: "flex flex-col gap-16" }, _r = {
|
|
3897
|
+
key: 0,
|
|
3898
|
+
class: "px-16 py-12 rounded-8 bg-fm-color-danger-weak text-fm-color-danger-default"
|
|
3899
|
+
}, kr = { key: 1 }, xr = { class: "fm-typo-en-label-md-400 cursor-pointer" }, wr = { class: "mt-8 flex flex-col gap-4" }, Dr = { key: 2 }, Ar = { class: "fm-typo-en-label-md-400 cursor-pointer" }, $r = { class: "mt-8 flex flex-col gap-4" }, Cr = /* @__PURE__ */ Se({
|
|
3900
|
+
__name: "ClosingDraftCreatePreviewTable",
|
|
3901
|
+
props: {
|
|
3902
|
+
items: {},
|
|
3903
|
+
unrecognisedItemCodes: {}
|
|
3904
|
+
},
|
|
3905
|
+
setup(t) {
|
|
3906
|
+
const o = t, { t: e } = ot(), n = S(
|
|
3907
|
+
() => o.items.filter((u) => u.status === $e.negative)
|
|
3908
|
+
), i = S(
|
|
3909
|
+
() => o.items.filter((u) => u.status === $e.systemNegative)
|
|
3910
|
+
), r = S(() => ({
|
|
3911
|
+
[$e.negative]: {
|
|
3912
|
+
bgColor: "bg-fm-color-danger-weak",
|
|
3913
|
+
textColor: "text-fm-color-danger-default",
|
|
3914
|
+
icon: "🚫",
|
|
3915
|
+
label: e("inventory.closing.draft.createDraft.previewTable.status.negative")
|
|
3916
|
+
},
|
|
3917
|
+
[$e.systemNegative]: {
|
|
3918
|
+
bgColor: "bg-fm-color-warning-weak",
|
|
3919
|
+
textColor: "text-fm-color-warning-default",
|
|
3920
|
+
icon: "⚠️",
|
|
3921
|
+
label: e("inventory.closing.draft.createDraft.previewTable.status.systemNegative")
|
|
3922
|
+
}
|
|
3923
|
+
})), s = [
|
|
3924
|
+
{
|
|
3925
|
+
id: "name",
|
|
3926
|
+
header: () => e("inventory.ingredient.name"),
|
|
3927
|
+
cell: (u) => u.row.original.sku.name
|
|
3928
|
+
},
|
|
3929
|
+
{
|
|
3930
|
+
id: "uom",
|
|
3931
|
+
header: () => e("inventory.closing.draft.createDraft.previewTable.uom"),
|
|
3932
|
+
size: 80,
|
|
3933
|
+
cell: (u) => u.row.original.sku.unit.abbrev
|
|
3934
|
+
},
|
|
3935
|
+
{
|
|
3936
|
+
id: "systemBalance",
|
|
3937
|
+
header: () => e("inventory.closing.draft.createDraft.previewTable.systemBalance"),
|
|
3938
|
+
size: 180,
|
|
3939
|
+
cell: (u) => {
|
|
3940
|
+
const c = u.row.original;
|
|
3941
|
+
return h("div", me(c.systemBalance));
|
|
3942
|
+
}
|
|
3943
|
+
},
|
|
3944
|
+
{
|
|
3945
|
+
id: "physicalCount",
|
|
3946
|
+
header: () => e("inventory.closing.draft.createDraft.previewTable.stockTakeBalance"),
|
|
3947
|
+
cell: (u) => {
|
|
3948
|
+
const c = u.row.original;
|
|
3949
|
+
return h("div", me(c.physicalCount));
|
|
3950
|
+
}
|
|
3951
|
+
},
|
|
3952
|
+
{
|
|
3953
|
+
id: "variance",
|
|
3954
|
+
header: () => e("inventory.closing.draft.createDraft.previewTable.variance"),
|
|
3955
|
+
cell: (u) => {
|
|
3956
|
+
const b = u.row.original.variance, y = b < 0 ? "text-fm-color-danger-default" : b > 0 ? "text-fm-color-success-default" : "";
|
|
3957
|
+
return h("span", { class: y }, me(b));
|
|
3958
|
+
}
|
|
3959
|
+
},
|
|
3960
|
+
{
|
|
3961
|
+
id: "variancePercentage",
|
|
3962
|
+
header: () => e("inventory.closing.draft.createDraft.previewTable.variancePercentage"),
|
|
3963
|
+
size: 130,
|
|
3964
|
+
cell: (u) => {
|
|
3965
|
+
const c = u.row.original, b = c.systemBalance.amount / Math.pow(10, c.systemBalance.precision), y = b === 0 ? null : Math.max(
|
|
3966
|
+
-100,
|
|
3967
|
+
Math.min(100, Math.round(c.variance / Math.abs(b) * 1e4) / 100)
|
|
3968
|
+
);
|
|
3969
|
+
if (y === null)
|
|
3970
|
+
return h(
|
|
3971
|
+
"div",
|
|
3972
|
+
{ class: "flex items-center gap-4 justify-end fm-typo-en-body-md-400" },
|
|
3973
|
+
e("inventory.closing.draft.createDraft.previewTable.notApplicable")
|
|
3974
|
+
);
|
|
3975
|
+
const $ = `${me(y)}`;
|
|
3976
|
+
if (y === 0)
|
|
3977
|
+
return h(
|
|
3978
|
+
"div",
|
|
3979
|
+
{ class: "flex items-center gap-4 justify-end fm-typo-en-body-md-400" },
|
|
3980
|
+
$
|
|
3981
|
+
);
|
|
3982
|
+
const Q = y > 0;
|
|
3983
|
+
return h("div", { class: "flex items-center gap-4 justify-end fm-typo-en-body-md-400" }, [
|
|
3984
|
+
h(be.FmIcon, {
|
|
3985
|
+
name: Q ? "arrow_drop_up" : "arrow_drop_down",
|
|
3986
|
+
color: Q ? "system-success-300" : "system-error-300",
|
|
3987
|
+
size: "md"
|
|
3988
|
+
}),
|
|
3989
|
+
$
|
|
3990
|
+
]);
|
|
3991
|
+
}
|
|
3992
|
+
},
|
|
3993
|
+
{
|
|
3994
|
+
id: "status",
|
|
3995
|
+
header: () => e("inventory.common.status"),
|
|
3996
|
+
cell: (u) => {
|
|
3997
|
+
const c = u.row.original.status, b = r.value[c];
|
|
3998
|
+
return b ? h(
|
|
3999
|
+
"span",
|
|
4000
|
+
{
|
|
4001
|
+
class: `px-8 py-2 rounded-4 ${b.bgColor} ${b.textColor} fm-typo-en-label-sm-400`
|
|
4002
|
+
},
|
|
4003
|
+
`${b.icon} ${b.label}`
|
|
4004
|
+
) : null;
|
|
4005
|
+
}
|
|
4006
|
+
}
|
|
4007
|
+
];
|
|
4008
|
+
return (u, c) => {
|
|
4009
|
+
const b = ee("FmTable");
|
|
4010
|
+
return f(), C("div", hr, [
|
|
4011
|
+
n.value.length > 0 ? (f(), C("div", _r, [
|
|
4012
|
+
ge(E(d(e)("inventory.closing.draft.createDraft.previewTable.cannotSubmitNegative")) + " ", 1),
|
|
4013
|
+
a("strong", null, E(n.value.map((y) => y.sku.code).join(", ")), 1)
|
|
4014
|
+
])) : W("", !0),
|
|
4015
|
+
i.value.length > 0 ? (f(), C("details", kr, [
|
|
4016
|
+
a("summary", xr, E(d(e)("inventory.closing.draft.createDraft.previewTable.systemNegativeNote", [i.value.length])), 1),
|
|
4017
|
+
a("ul", wr, [
|
|
4018
|
+
(f(!0), C(ie, null, _e(i.value, (y) => (f(), C("li", {
|
|
4019
|
+
key: y.sku._id,
|
|
4020
|
+
class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
|
|
4021
|
+
}, E(y.sku.code), 1))), 128))
|
|
4022
|
+
])
|
|
4023
|
+
])) : W("", !0),
|
|
4024
|
+
u.unrecognisedItemCodes.length > 0 ? (f(), C("details", Dr, [
|
|
4025
|
+
a("summary", Ar, E(d(e)("inventory.closing.draft.createDraft.previewTable.unrecognisedNote", [u.unrecognisedItemCodes.length])), 1),
|
|
4026
|
+
a("ul", $r, [
|
|
4027
|
+
(f(!0), C(ie, null, _e(u.unrecognisedItemCodes, (y) => (f(), C("li", {
|
|
4028
|
+
key: y,
|
|
4029
|
+
class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
|
|
4030
|
+
}, E(y), 1))), 128))
|
|
4031
|
+
])
|
|
4032
|
+
])) : W("", !0),
|
|
4033
|
+
D(b, {
|
|
4034
|
+
"row-data": o.items,
|
|
4035
|
+
"column-defs": s,
|
|
4036
|
+
pagination: { pageSize: 20 }
|
|
4037
|
+
}, null, 8, ["row-data"])
|
|
4038
|
+
]);
|
|
4039
|
+
};
|
|
4040
|
+
}
|
|
4041
|
+
}), Sr = { class: "flex flex-col gap-16" }, Fr = { class: "flex flex-col gap-8" }, Ir = { class: "fm-typo-en-body-lg-600" }, Br = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Tr = { class: "fm-corner-radius-md p-16 flex items-center gap-16 border border-fm-color-border-default" }, jr = { class: "flex flex-col flex-1 gap-4" }, Rr = { class: "fm-typo-en-body-md-600" }, Mr = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Nr = {
|
|
4042
|
+
key: 0,
|
|
4043
|
+
class: "flex flex-col gap-8"
|
|
4044
|
+
}, Ur = { class: "fm-typo-en-body-lg-600" }, Pr = {
|
|
4045
|
+
key: 0,
|
|
4046
|
+
class: "fm-typo-en-body-sm-400 text-fm-color-system-error-300 flex items-center gap-8"
|
|
4047
|
+
}, Vr = { class: "grid grid-cols-[repeat(3,1fr)] gap-12" }, Er = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary flex items-center gap-4" }, Lr = { class: "flex items-center gap-8 w-full" }, Gr = /* @__PURE__ */ Se({
|
|
4048
|
+
__name: "ClosingDraftCreateSideSheet",
|
|
4049
|
+
props: {
|
|
4050
|
+
show: { type: Boolean }
|
|
4051
|
+
},
|
|
4052
|
+
emits: ["update:show", "submitted"],
|
|
4053
|
+
setup(t, { emit: o }) {
|
|
4054
|
+
const e = t, n = o, i = Tt(e, "show"), { t: r } = ot(), s = Ue(), u = q("upload"), c = q(null), b = q(!1), { mergedItems: y, unrecognisedItemCodes: $, hasBlockingErrors: Q, isLoading: V, onFileUpload: B, submit: I, downloadTemplate: N } = br(), J = S(
|
|
4055
|
+
() => c.value && !V.value && y.value.length > 0
|
|
4056
|
+
), X = S(() => {
|
|
4057
|
+
const k = y.value.filter(
|
|
4058
|
+
(_) => _.status === $e.ready
|
|
4059
|
+
).length, w = y.value.filter(
|
|
4060
|
+
(_) => _.status === $e.negative
|
|
4061
|
+
).length, x = y.value.filter(
|
|
4062
|
+
(_) => _.status === $e.systemNegative
|
|
4063
|
+
).length, re = y.value.filter((_) => _.variance !== 0).length;
|
|
4064
|
+
return [
|
|
4065
|
+
{ label: r("inventory.closing.draft.createDraft.summary.totalItems"), value: y.value.length },
|
|
4066
|
+
{ label: r("inventory.closing.draft.createDraft.summary.itemsWithCount"), value: k },
|
|
4067
|
+
{
|
|
4068
|
+
label: r("inventory.closing.draft.createDraft.summary.unrecognisedItems"),
|
|
4069
|
+
value: $.value.length,
|
|
4070
|
+
isWarning: $.value.length > 0
|
|
4071
|
+
},
|
|
4072
|
+
{ label: r("inventory.closing.draft.createDraft.summary.itemsWithVariance"), value: re },
|
|
4073
|
+
{ label: r("inventory.closing.draft.createDraft.summary.negativeCounts"), value: w, isError: w > 0 },
|
|
4074
|
+
{
|
|
4075
|
+
label: r("inventory.closing.draft.createDraft.summary.systemNegative"),
|
|
4076
|
+
value: x,
|
|
4077
|
+
isWarning: x > 0
|
|
4078
|
+
}
|
|
4079
|
+
];
|
|
4080
|
+
});
|
|
4081
|
+
async function O(k) {
|
|
4082
|
+
c.value = k, await B(k);
|
|
4083
|
+
}
|
|
4084
|
+
async function F() {
|
|
4085
|
+
b.value = !0;
|
|
4086
|
+
try {
|
|
4087
|
+
await I(), T(), n("submitted"), s.open({
|
|
4088
|
+
title: "Success",
|
|
4089
|
+
message: "Closing draft created successfully",
|
|
4090
|
+
type: "success"
|
|
4091
|
+
});
|
|
4092
|
+
} catch (k) {
|
|
4093
|
+
console.error("Failed to create closing draft", { error: k }), s.open({
|
|
4094
|
+
title: "Something went wrong",
|
|
4095
|
+
message: "Failed to create closing draft. Please try again",
|
|
4096
|
+
type: "error"
|
|
4097
|
+
});
|
|
4098
|
+
} finally {
|
|
4099
|
+
b.value = !1;
|
|
4100
|
+
}
|
|
4101
|
+
}
|
|
4102
|
+
Te(i, (k) => {
|
|
4103
|
+
k || (u.value = "upload", c.value = null);
|
|
4104
|
+
});
|
|
4105
|
+
function T() {
|
|
4106
|
+
i.value = !1;
|
|
4107
|
+
}
|
|
4108
|
+
return (k, w) => {
|
|
4109
|
+
const x = ee("FmCircularProgress"), re = ee("FmIcon"), _ = ee("FmButton"), A = ee("FmCard"), L = ee("FmSideSheet");
|
|
4110
|
+
return f(), ne(L, {
|
|
4111
|
+
"dismiss-away": "",
|
|
4112
|
+
"max-width": 9999,
|
|
4113
|
+
"model-value": d(i),
|
|
4114
|
+
"onUpdate:modelValue": w[2] || (w[2] = (P) => bt(i) ? i.value = P : null),
|
|
4115
|
+
header: d(r)("inventory.closing.draft.createDraft.title")
|
|
4116
|
+
}, {
|
|
4117
|
+
default: te(() => [
|
|
4118
|
+
a("div", Sr, [
|
|
4119
|
+
u.value === "upload" ? (f(), C(ie, { key: 0 }, [
|
|
4120
|
+
a("div", Fr, [
|
|
4121
|
+
a("div", Ir, E(d(r)("inventory.closing.draft.createDraft.importCsv")), 1),
|
|
4122
|
+
a("div", Br, E(d(r)("inventory.closing.draft.createDraft.uploadDescription")), 1),
|
|
4123
|
+
D(hn, {
|
|
4124
|
+
class: we({ "h-[200px]": !c.value }),
|
|
4125
|
+
accept: ".csv",
|
|
4126
|
+
disabled: d(V),
|
|
4127
|
+
onFileUpload: O
|
|
4128
|
+
}, Oo({ _: 2 }, [
|
|
4129
|
+
c.value ? {
|
|
4130
|
+
name: "default",
|
|
4131
|
+
fn: te(({ openFileDialog: P }) => [
|
|
4132
|
+
a("div", Tr, [
|
|
4133
|
+
d(V) ? (f(), ne(x, {
|
|
4134
|
+
key: 0,
|
|
4135
|
+
size: "md",
|
|
4136
|
+
color: "neutral-gray-200"
|
|
4137
|
+
})) : (f(), ne(re, {
|
|
4138
|
+
key: 1,
|
|
4139
|
+
name: "check_circle",
|
|
4140
|
+
color: "system-success-400",
|
|
4141
|
+
size: "lg"
|
|
4142
|
+
})),
|
|
4143
|
+
a("div", jr, [
|
|
4144
|
+
a("div", Rr, E(c.value.name), 1),
|
|
4145
|
+
a("div", Mr, E(d(V) ? d(r)("inventory.closing.draft.createDraft.processing") : d(r)("inventory.closing.draft.createDraft.itemsLoaded", [d(y).length])), 1)
|
|
4146
|
+
]),
|
|
4147
|
+
d(V) ? W("", !0) : (f(), ne(_, {
|
|
4148
|
+
key: 2,
|
|
4149
|
+
label: d(r)("inventory.closing.draft.createDraft.replaceFile"),
|
|
4150
|
+
variant: "secondary",
|
|
4151
|
+
"prepend-icon": "autorenew",
|
|
4152
|
+
onClick: P
|
|
4153
|
+
}, null, 8, ["label", "onClick"]))
|
|
4154
|
+
])
|
|
4155
|
+
]),
|
|
4156
|
+
key: "0"
|
|
4157
|
+
} : void 0
|
|
4158
|
+
]), 1032, ["class", "disabled"])
|
|
4159
|
+
]),
|
|
4160
|
+
J.value ? (f(), C("div", Nr, [
|
|
4161
|
+
a("div", Ur, E(d(r)("inventory.closing.draft.createDraft.importSummary")), 1),
|
|
4162
|
+
d(Q) ? (f(), C("div", Pr, [
|
|
4163
|
+
D(re, {
|
|
4164
|
+
name: "error",
|
|
4165
|
+
size: "sm",
|
|
4166
|
+
color: "system-error-300"
|
|
4167
|
+
}),
|
|
4168
|
+
a("span", null, E(d(r)("inventory.closing.draft.createDraft.reviewIssues")), 1)
|
|
4169
|
+
])) : W("", !0),
|
|
4170
|
+
D(A, {
|
|
4171
|
+
variant: "outlined",
|
|
4172
|
+
class: "flex flex-col gap-12 px-16 py-12"
|
|
4173
|
+
}, {
|
|
4174
|
+
default: te(() => [
|
|
4175
|
+
a("div", Vr, [
|
|
4176
|
+
(f(!0), C(ie, null, _e(X.value, (P) => (f(), C("div", {
|
|
4177
|
+
key: P.label,
|
|
4178
|
+
class: "flex flex-col gap-4"
|
|
4179
|
+
}, [
|
|
4180
|
+
a("div", Er, [
|
|
4181
|
+
P.isError ? (f(), ne(re, {
|
|
4182
|
+
key: 0,
|
|
4183
|
+
name: "error",
|
|
4184
|
+
size: "sm",
|
|
4185
|
+
color: "system-error-300"
|
|
4186
|
+
})) : W("", !0),
|
|
4187
|
+
P.isWarning && !P.isError ? (f(), ne(re, {
|
|
4188
|
+
key: 1,
|
|
4189
|
+
name: "warning",
|
|
4190
|
+
size: "sm",
|
|
4191
|
+
color: "system-warning-300"
|
|
4192
|
+
})) : W("", !0),
|
|
4193
|
+
a("span", null, E(P.label), 1)
|
|
4194
|
+
]),
|
|
4195
|
+
a("div", {
|
|
4196
|
+
class: we([
|
|
4197
|
+
"fm-typo-en-body-lg-600",
|
|
4198
|
+
{
|
|
4199
|
+
"text-fm-color-system-error-300": P.isError,
|
|
4200
|
+
"text-fm-color-system-warning-300": P.isWarning && !P.isError
|
|
4201
|
+
}
|
|
4202
|
+
])
|
|
4203
|
+
}, E(P.value), 3)
|
|
4204
|
+
]))), 128))
|
|
4205
|
+
])
|
|
4206
|
+
]),
|
|
4207
|
+
_: 1
|
|
4208
|
+
})
|
|
4209
|
+
])) : W("", !0)
|
|
4210
|
+
], 64)) : W("", !0),
|
|
4211
|
+
u.value === "preview" ? (f(), ne(Cr, {
|
|
4212
|
+
key: 1,
|
|
4213
|
+
items: d(y),
|
|
4214
|
+
"unrecognised-item-codes": d($)
|
|
4215
|
+
}, null, 8, ["items", "unrecognised-item-codes"])) : W("", !0)
|
|
4216
|
+
])
|
|
4217
|
+
]),
|
|
4218
|
+
"side-sheet-footer": te(() => [
|
|
4219
|
+
a("div", Lr, [
|
|
4220
|
+
u.value === "preview" ? (f(), ne(_, {
|
|
4221
|
+
key: 0,
|
|
4222
|
+
variant: "secondary",
|
|
4223
|
+
label: d(r)("inventory.common.back"),
|
|
4224
|
+
"prepend-icon": "arrow_back",
|
|
4225
|
+
onClick: w[0] || (w[0] = (P) => u.value = "upload")
|
|
4226
|
+
}, null, 8, ["label"])) : W("", !0),
|
|
4227
|
+
u.value === "upload" ? (f(), ne(_, {
|
|
4228
|
+
key: 1,
|
|
4229
|
+
variant: "primary",
|
|
4230
|
+
label: d(r)("inventory.common.next"),
|
|
4231
|
+
disabled: !c.value || d(V),
|
|
4232
|
+
onClick: w[1] || (w[1] = (P) => u.value = "preview")
|
|
4233
|
+
}, null, 8, ["label", "disabled"])) : W("", !0),
|
|
4234
|
+
u.value === "preview" ? (f(), ne(_n, {
|
|
4235
|
+
key: 2,
|
|
4236
|
+
label: d(r)("inventory.closing.draft.createDraft.submit"),
|
|
4237
|
+
disabled: d(Q) || d(y).length === 0 || b.value,
|
|
4238
|
+
loading: b.value,
|
|
4239
|
+
"confirm-title": d(r)("inventory.closing.draft.createDraft.confirmTitle"),
|
|
4240
|
+
"confirm-message": d(r)("inventory.closing.draft.createDraft.confirmMessage"),
|
|
4241
|
+
onConfirm: F
|
|
4242
|
+
}, null, 8, ["label", "disabled", "loading", "confirm-title", "confirm-message"])) : W("", !0),
|
|
4243
|
+
D(_, {
|
|
4244
|
+
variant: "tertiary",
|
|
4245
|
+
label: d(r)("inventory.common.close"),
|
|
4246
|
+
onClick: T
|
|
4247
|
+
}, null, 8, ["label"]),
|
|
4248
|
+
u.value === "upload" ? (f(), ne(_, {
|
|
4249
|
+
key: 3,
|
|
4250
|
+
class: "ml-auto",
|
|
4251
|
+
variant: "secondary",
|
|
4252
|
+
label: d(r)("inventory.closing.draft.createDraft.downloadTemplate"),
|
|
4253
|
+
"prepend-icon": "download",
|
|
4254
|
+
onClick: d(N)
|
|
4255
|
+
}, null, 8, ["label", "onClick"])) : W("", !0)
|
|
4256
|
+
])
|
|
4257
|
+
]),
|
|
4258
|
+
_: 1
|
|
4259
|
+
}, 8, ["model-value", "header"]);
|
|
4260
|
+
};
|
|
4261
|
+
}
|
|
4262
|
+
}), zr = ["onClick"], Or = { class: "flex items-start gap-8" }, Hr = { class: "fm-typo-body-md-400 line-clamp-3 w-full" }, Yr = { class: "flex flex-col gap-8" }, Wr = { class: "flex items-start gap-4" }, Kr = { class: "flex-1 flex flex-col gap-8" }, qr = { class: "flex flex-col" }, Qr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Jr = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Zr = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-2" }, Xr = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, el = {
|
|
4263
|
+
key: 0,
|
|
4264
|
+
class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
|
|
4265
|
+
}, Tl = /* @__PURE__ */ Se({
|
|
4266
|
+
__name: "ClosingDraftView",
|
|
4267
|
+
setup(t) {
|
|
4268
|
+
const { t: o } = ot(), { viewDraft: e } = yt(), { viewClosingDraftProps: n, viewClosingDraftShow: i } = Xo(yt()), r = Qe(), s = bo(), u = Wo(), { breakpoints: c } = qo();
|
|
4269
|
+
r.watchLocation(s.onLocationChanged);
|
|
4270
|
+
const b = q(""), y = Ue();
|
|
4271
|
+
function $(_) {
|
|
4272
|
+
const A = /* @__PURE__ */ new Date();
|
|
4273
|
+
return A.setDate(A.getDate() - _), A;
|
|
4274
|
+
}
|
|
4275
|
+
const Q = (() => {
|
|
4276
|
+
const _ = qe, A = /* @__PURE__ */ new Date(), L = $(A.getDay()), P = $(A.getDay() + 1), ve = $(A.getDay() + 7), oe = new Date(A.getFullYear(), A.getMonth(), 1), R = new Date(A.getFullYear(), A.getMonth() + 1, 0), p = new Date(A.getFullYear(), A.getMonth() - 1, 1), g = new Date(A.getFullYear(), A.getMonth(), 0);
|
|
4277
|
+
return [
|
|
4278
|
+
{ label: "Today", value: { startDate: _(A), endDate: _(A) } },
|
|
4279
|
+
{ label: "Yesterday", value: { startDate: _($(1)), endDate: _($(1)) } },
|
|
4280
|
+
{ label: "This week", value: { startDate: _(L), endDate: _(A) } },
|
|
4281
|
+
{ label: "Last week", value: { startDate: _(ve), endDate: _(P) } },
|
|
4282
|
+
{ label: "Last 7 days", value: { startDate: _($(7)), endDate: _($(1)) } },
|
|
4283
|
+
{ label: "This month", value: { startDate: _(oe), endDate: _(R) } },
|
|
4284
|
+
{ label: "Last month", value: { startDate: _(p), endDate: _(g) } }
|
|
4285
|
+
];
|
|
4286
|
+
})(), V = q();
|
|
4287
|
+
function B(_) {
|
|
4288
|
+
var A;
|
|
4289
|
+
(A = V.value) == null || A.openRowDetail(_);
|
|
4290
|
+
}
|
|
4291
|
+
const I = q({ ...s.dateRange });
|
|
4292
|
+
Te(I, (_) => {
|
|
4293
|
+
const A = s.setDateRange(_);
|
|
4294
|
+
(A.startDate !== _.startDate || A.endDate !== _.endDate) && (I.value = A, y.open({ title: "Date range is limited to 6 months", type: "info" }));
|
|
4295
|
+
});
|
|
4296
|
+
const N = q(!1), J = S(() => c.value.xs || c.value.sm), X = S(() => J.value ? 10 : 20), O = S(
|
|
4297
|
+
() => {
|
|
4298
|
+
var _;
|
|
4299
|
+
return ((_ = r._currentLocation) == null ? void 0 : _.type) === Zo.enum.warehouse;
|
|
4300
|
+
}
|
|
4301
|
+
);
|
|
4302
|
+
function F(_) {
|
|
4303
|
+
switch (_) {
|
|
4304
|
+
case "add":
|
|
4305
|
+
return N.value = !0;
|
|
4306
|
+
case "refresh":
|
|
4307
|
+
return s.refresh();
|
|
4308
|
+
}
|
|
4309
|
+
}
|
|
4310
|
+
function T(_) {
|
|
4311
|
+
return _;
|
|
4312
|
+
}
|
|
4313
|
+
function k(_) {
|
|
4314
|
+
return _.original.groups ?? [];
|
|
4315
|
+
}
|
|
4316
|
+
function w(_) {
|
|
4317
|
+
return _.column.columnDef.meta;
|
|
4318
|
+
}
|
|
4319
|
+
function x(_) {
|
|
4320
|
+
const A = Gn(k(_)), L = A.totalAmount.toLocaleString("en-MY", {
|
|
4321
|
+
minimumFractionDigits: 2,
|
|
4322
|
+
maximumFractionDigits: 2
|
|
4323
|
+
});
|
|
4324
|
+
return [
|
|
4325
|
+
`${A.totalItems} items`,
|
|
4326
|
+
`RM ${L}`,
|
|
4327
|
+
`${A.groupCount} groups`,
|
|
4328
|
+
`${A.completed} completed`,
|
|
4329
|
+
`${A.draft} draft`,
|
|
4330
|
+
A.rejected ? `${A.rejected} rejected` : null
|
|
4331
|
+
].filter(Boolean).join(" · ");
|
|
4332
|
+
}
|
|
4333
|
+
const re = S(() => {
|
|
4334
|
+
const _ = {
|
|
4335
|
+
label: o("inventory.closing.draft.createDraft.title"),
|
|
4336
|
+
value: "add",
|
|
4337
|
+
isPrimary: !0,
|
|
4338
|
+
prependIcon: "add"
|
|
4339
|
+
}, A = {
|
|
4340
|
+
label: o("inventory.common.refresh"),
|
|
4341
|
+
value: "refresh",
|
|
4342
|
+
isPrimary: !1
|
|
4343
|
+
};
|
|
4344
|
+
return [...O.value ? [_] : [], A];
|
|
4345
|
+
});
|
|
4346
|
+
return (_, A) => (f(), C(ie, null, [
|
|
4347
|
+
D(Ko, {
|
|
4348
|
+
title: d(o)("inventory.closing.draft.title"),
|
|
4349
|
+
actions: re.value,
|
|
4350
|
+
"onClick:action": F
|
|
4351
|
+
}, {
|
|
4352
|
+
default: te(() => [
|
|
4353
|
+
a("div", {
|
|
4354
|
+
class: we([
|
|
4355
|
+
"flex flex-col gap-8 max-h-full",
|
|
4356
|
+
{
|
|
4357
|
+
"p-0": J.value,
|
|
4358
|
+
"px-24 ": !J.value
|
|
4359
|
+
}
|
|
4360
|
+
])
|
|
4361
|
+
}, [
|
|
4362
|
+
D(pn, {
|
|
4363
|
+
"change-location": "",
|
|
4364
|
+
searchable: "",
|
|
4365
|
+
"date-range-query": "",
|
|
4366
|
+
"predefined-date-ranges": d(Q),
|
|
4367
|
+
search: b.value,
|
|
4368
|
+
"onUpdate:search": A[0] || (A[0] = (L) => b.value = L),
|
|
4369
|
+
"date-range": I.value,
|
|
4370
|
+
"onUpdate:dateRange": A[1] || (A[1] = (L) => I.value = L)
|
|
4371
|
+
}, null, 8, ["predefined-date-ranges", "search", "date-range"]),
|
|
4372
|
+
D(fn, {
|
|
4373
|
+
style: gt(d(u).tableHeight),
|
|
4374
|
+
"column-defs": d(s).columnDefs,
|
|
4375
|
+
rows: d(s).drafts,
|
|
4376
|
+
"onUpdate:rows": A[2] || (A[2] = (L) => d(s).drafts = L),
|
|
4377
|
+
"fetch-page": d(s).fetchDraftsPage,
|
|
4378
|
+
transform: d(s).transformDrafts,
|
|
4379
|
+
"refresh-key": d(s).tableKey,
|
|
4380
|
+
ref_key: "tableRef",
|
|
4381
|
+
ref: V,
|
|
4382
|
+
"search-value": b.value,
|
|
4383
|
+
loading: d(s).loading,
|
|
4384
|
+
"fetch-detail": (L, P) => d(e)(L._id, P),
|
|
4385
|
+
"detail-to-row": d(s).detailToRow,
|
|
4386
|
+
"page-size": X.value
|
|
4387
|
+
}, {
|
|
4388
|
+
"table-row": te((L) => [
|
|
4389
|
+
a("tr", {
|
|
4390
|
+
class: "border-b border-fm-color-neutral-gray-100 hover:bg-fm-color-opacity-sm cursor-pointer",
|
|
4391
|
+
onClick: (P) => B(L.original)
|
|
4392
|
+
}, [
|
|
4393
|
+
(f(!0), C(ie, null, _e(L.getVisibleCells(), (P) => {
|
|
4394
|
+
var ve, oe, R, p;
|
|
4395
|
+
return f(), C("td", {
|
|
4396
|
+
key: P.id,
|
|
4397
|
+
class: we([
|
|
4398
|
+
"h-[56px] text-fm-color-typo-primary align-top",
|
|
4399
|
+
((ve = w(P)) == null ? void 0 : ve.cellClass) ?? "px-16 py-12"
|
|
4400
|
+
]),
|
|
4401
|
+
style: gt({
|
|
4402
|
+
width: (oe = w(P)) == null ? void 0 : oe.width,
|
|
4403
|
+
maxWidth: (R = w(P)) == null ? void 0 : R.maxWidth,
|
|
4404
|
+
textAlign: ((p = w(P)) == null ? void 0 : p.textAlign) ?? "left"
|
|
4405
|
+
})
|
|
4406
|
+
}, [
|
|
4407
|
+
a("div", Or, [
|
|
4408
|
+
a("span", Hr, [
|
|
4409
|
+
D(d(Ze), {
|
|
4410
|
+
render: P.column.columnDef.cell,
|
|
4411
|
+
props: P.getContext()
|
|
4412
|
+
}, null, 8, ["render", "props"])
|
|
4413
|
+
])
|
|
4414
|
+
])
|
|
4415
|
+
], 6);
|
|
4416
|
+
}), 128))
|
|
4417
|
+
], 8, zr)
|
|
4418
|
+
]),
|
|
4419
|
+
"list-row": te((L) => [
|
|
4420
|
+
a("div", Yr, [
|
|
4421
|
+
a("div", Wr, [
|
|
4422
|
+
D(kn, {
|
|
4423
|
+
class: "flex-1",
|
|
4424
|
+
row: L,
|
|
4425
|
+
onRowClick: (P) => B(P)
|
|
4426
|
+
}, {
|
|
4427
|
+
default: te((P) => {
|
|
4428
|
+
var ve, oe, R, p, g, M, H, de, j, z, le, ae, De, he, je, Re, ze, nt, Pe, at;
|
|
4429
|
+
return [
|
|
4430
|
+
a("div", Kr, [
|
|
4431
|
+
a("div", qr, [
|
|
4432
|
+
a("div", Qr, [
|
|
4433
|
+
D(d(Ze), {
|
|
4434
|
+
render: (R = (oe = (ve = P._id) == null ? void 0 : ve.column) == null ? void 0 : oe.columnDef) == null ? void 0 : R.cell,
|
|
4435
|
+
props: (g = (p = P._id) == null ? void 0 : p.getContext) == null ? void 0 : g.call(p)
|
|
4436
|
+
}, null, 8, ["render", "props"])
|
|
4437
|
+
]),
|
|
4438
|
+
a("div", Jr, [
|
|
4439
|
+
D(d(Ze), {
|
|
4440
|
+
render: (de = (H = (M = P.name) == null ? void 0 : M.column) == null ? void 0 : H.columnDef) == null ? void 0 : de.cell,
|
|
4441
|
+
props: (z = (j = P.name) == null ? void 0 : j.getContext) == null ? void 0 : z.call(j)
|
|
4442
|
+
}, null, 8, ["render", "props"])
|
|
4443
|
+
]),
|
|
4444
|
+
a("div", Zr, E([
|
|
4445
|
+
...L.original.previewItemNames,
|
|
4446
|
+
...L.original.itemCount - L.original.previewItemNames.length > 0 ? [
|
|
4447
|
+
`and ${L.original.itemCount - L.original.previewItemNames.length} more items`
|
|
4448
|
+
] : []
|
|
4449
|
+
].join(", ")), 1),
|
|
4450
|
+
a("div", Xr, [
|
|
4451
|
+
D(d(Ze), {
|
|
4452
|
+
render: (De = (ae = (le = P.ref) == null ? void 0 : le.column) == null ? void 0 : ae.columnDef) == null ? void 0 : De.cell,
|
|
4453
|
+
props: (je = (he = P.ref) == null ? void 0 : he.getContext) == null ? void 0 : je.call(he)
|
|
4454
|
+
}, null, 8, ["render", "props"])
|
|
4455
|
+
])
|
|
4456
|
+
]),
|
|
4457
|
+
k(L).length ? (f(), C("div", el, E(x(L)), 1)) : W("", !0),
|
|
4458
|
+
a("div", null, [
|
|
4459
|
+
D(d(Ze), {
|
|
4460
|
+
render: (nt = (ze = (Re = P.status) == null ? void 0 : Re.column) == null ? void 0 : ze.columnDef) == null ? void 0 : nt.cell,
|
|
4461
|
+
props: (at = (Pe = P.status) == null ? void 0 : Pe.getContext) == null ? void 0 : at.call(Pe)
|
|
4462
|
+
}, null, 8, ["render", "props"])
|
|
4463
|
+
])
|
|
4464
|
+
])
|
|
4465
|
+
];
|
|
4466
|
+
}),
|
|
4467
|
+
_: 2
|
|
4468
|
+
}, 1032, ["row", "onRowClick"])
|
|
4469
|
+
])
|
|
4470
|
+
])
|
|
4471
|
+
]),
|
|
4472
|
+
_: 1
|
|
4473
|
+
}, 8, ["style", "column-defs", "rows", "fetch-page", "transform", "refresh-key", "search-value", "loading", "fetch-detail", "detail-to-row", "page-size"])
|
|
4474
|
+
], 2)
|
|
4475
|
+
]),
|
|
4476
|
+
_: 1
|
|
4477
|
+
}, 8, ["title", "actions"]),
|
|
4478
|
+
D(Gr, {
|
|
4479
|
+
show: N.value,
|
|
4480
|
+
"onUpdate:show": A[3] || (A[3] = (L) => N.value = L),
|
|
4481
|
+
onSubmitted: d(s).refresh
|
|
4482
|
+
}, null, 8, ["show", "onSubmitted"]),
|
|
4483
|
+
(f(), ne(Ho, { to: "body" }, [
|
|
4484
|
+
D(pr, Yo(d(n), {
|
|
4485
|
+
show: d(i),
|
|
4486
|
+
"onUpdate:show": A[4] || (A[4] = (L) => bt(i) ? i.value = L : null),
|
|
4487
|
+
onSubmitted: A[5] || (A[5] = () => (i.value = !1, d(s).refresh())),
|
|
4488
|
+
onRefresh: A[6] || (A[6] = (L) => d(s).updateDraftRef(L))
|
|
4489
|
+
}), null, 16, ["show"])
|
|
4490
|
+
]))
|
|
4491
|
+
], 64));
|
|
4492
|
+
}
|
|
4493
|
+
});
|
|
4494
|
+
export {
|
|
4495
|
+
Tl as default
|
|
4496
|
+
};
|