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