@feedmepos/mf-inventory-portal 0.0.23-dev.4 → 0.0.23-dev.40

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