@feedmepos/mf-inventory-portal 1.5.9 → 1.5.11-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 (92) hide show
  1. package/dist/{App-D_elK-3W.js → App-D4rysNfh.js} +4 -4
  2. package/dist/{ApprovalView-WdSQEpGQ.js → ApprovalView-DpYJmgiG.js} +7 -7
  3. package/dist/{BindingsDialog-CkqhKrrD.js → BindingsDialog-C7z0HH48.js} +2 -2
  4. package/dist/{BindingsPicker-HPjbSTJd.js → BindingsPicker-C5IKp9CT.js} +2 -2
  5. package/dist/{BindingsTable-BF4WTUsf.js → BindingsTable-BRDooCs4.js} +3 -3
  6. package/dist/{ClosingDraftView-CTEaBuhS.js → ClosingDraftView-CSCbfIFE.js} +159 -158
  7. package/dist/ClosingHistoryView-DCIJ5ONT.js +1114 -0
  8. package/dist/{ClosingTemplateView-DMtIj04r.js → ClosingTemplateView-D1n9_dFc.js} +14 -14
  9. package/dist/{DefaultView-v-32G42G.js → DefaultView-Llrh9ufI.js} +2 -2
  10. package/dist/{DeliveryOrderPrintPreview-DHD9kykc.js → DeliveryOrderPrintPreview-DSkU-sqv.js} +2 -2
  11. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-FRe1RX5T.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DL6AKT9H.js} +2 -2
  12. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-KTtYD7qS.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-JHabBWJb.js} +2 -2
  13. package/dist/{FmMultiselectDialog-BTNJvhnt.js → FmMultiselectDialog-BWujDEnX.js} +2 -2
  14. package/dist/{FmMultiselectDialog-LmjSdrn3.js → FmMultiselectDialog-C0lCYHla.js} +1 -1
  15. package/dist/FmUnitInput.vue_vue_type_script_setup_true_lang-CjCNHugK.js +388 -0
  16. package/dist/{ImportView-DoHL35I-.js → ImportView-C6q4gB3S.js} +6 -6
  17. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-D8JocFRD.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-Df7B8ZEG.js} +1 -1
  18. package/dist/{IngredientGroupView-CVhShbuq.js → IngredientGroupView-DO8OKEVU.js} +5 -5
  19. package/dist/{IngredientsView-XOTuP5ZI.js → IngredientsView-CD2YtXPJ.js} +15 -15
  20. package/dist/{IntegrationExplorerView-BsY4Ca2E.js → IntegrationExplorerView-CZCMnwZG.js} +352 -352
  21. package/dist/{IntegrationView-C_Y3_I_8.js → IntegrationView--3nVS_X6.js} +13 -13
  22. package/dist/{InventoryBindingForm-CHsrJSnp.js → InventoryBindingForm-FjFTiN7R.js} +1 -1
  23. package/dist/InventoryBindingForm.vue_vue_type_script_setup_true_lang-CcF5cko8.js +441 -0
  24. package/dist/{InventoryBindingSummary-C9UE6Zh2.js → InventoryBindingSummary-D90hAi96.js} +1 -1
  25. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DFj3HtnZ.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-1iDUXU2T.js} +1 -1
  26. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-oNk0zO9K.js → PremiumBadge.vue_vue_type_script_setup_true_lang-DTYnX8kn.js} +1 -1
  27. package/dist/{PublishView-DVk0ZUlG.js → PublishView-BtcGl7zM.js} +3 -3
  28. package/dist/{PurchaseOrderPrintPreview-poHk4RMP.js → PurchaseOrderPrintPreview-DvkMQv1w.js} +2 -2
  29. package/dist/{ReceiveRequestView-CaPoxKBs.js → ReceiveRequestView-DSfj36r3.js} +9631 -9552
  30. package/dist/{RecipeView-bbhd-mNL.js → RecipeView-DkDSr3LN.js} +1304 -1267
  31. package/dist/{SettingsView-DxiMiFpz.js → SettingsView-iRqUoEPg.js} +4 -4
  32. package/dist/{StockView-Dc4ICHq3.js → StockView-DxUXHYD_.js} +279 -278
  33. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-Cn3NL6mQ.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-WJ0Fz21v.js} +1 -1
  34. package/dist/{SupplierView-6fETAO2h.js → SupplierView-BYQjWeU7.js} +12 -12
  35. package/dist/{SurchargeView-7ucdobpg.js → SurchargeView-CyhTe1B8.js} +6 -6
  36. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-C4EeNPwc.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-CBM8jJqP.js} +2 -2
  37. package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-D-PqQ3Mi.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-DM9Cg0uk.js} +1 -1
  38. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-D-nG9kcq.js → TransferDetails.vue_vue_type_script_setup_true_lang-D2MztVse.js} +20 -20
  39. package/dist/{TransferTemplateView-CDD_5s5s.js → TransferTemplateView-FNI6jVh0.js} +18 -18
  40. package/dist/{UnitCostHistoryView-BrYXJWz0.js → UnitCostHistoryView-sGxNtk0Y.js} +4 -4
  41. package/dist/UnitDisplayControl.vue_vue_type_script_setup_true_lang-Cn6q11Ts.js +160 -0
  42. package/dist/{UnitView-CMXUZZvZ.js → UnitView-P8jU14k8.js} +7 -7
  43. package/dist/{WarehouseView-CUgJ4YGF.js → WarehouseView-NILk42Zj.js} +5 -5
  44. package/dist/{WastageTemplateView-Di6ffpTU.js → WastageTemplateView-DNrKoK3S.js} +14 -14
  45. package/dist/{app-D3gm3Lsw.js → app-DIOXPCfI.js} +23 -11
  46. package/dist/app.d.ts +12 -0
  47. package/dist/app.js +1 -1
  48. package/dist/{closing-template-BiSW9398.js → closing-template-DAlwSsqC.js} +1 -1
  49. package/dist/{date2-DJotzNeB.js → date2-DBIy5hnh.js} +1 -1
  50. package/dist/{dayjs.min-DxOA6M7_.js → dayjs.min-B2EqUP7W.js} +1 -1
  51. package/dist/{decimal-BPZo97WQ.js → decimal-e6enR5yT.js} +2 -2
  52. package/dist/{defineDeepModel-BMU9Poed.js → defineDeepModel-CwqnmttS.js} +1 -1
  53. package/dist/{duplicate-template-4bkTBQu0.js → duplicate-template-DRtq-b-P.js} +1 -1
  54. package/dist/{feature-WVA_2Jx-.js → feature-BCSp38rL.js} +2 -2
  55. package/dist/{format-time-from-id-gcRrHjjv.js → format-time-from-id-CTWNRFSC.js} +1 -1
  56. package/dist/{format-unit-display-BXkR_Hu0.js → format-unit-display-BFP12VU7.js} +11 -11
  57. package/dist/{import-export.helper-5AEiNKim.js → import-export.helper-Dr7R0Zql.js} +6 -6
  58. package/dist/{index-DkCy3EG9.js → index-BhS1AhF-.js} +1 -1
  59. package/dist/{index-YVMa0U0j.js → index-C2MhE26a.js} +3 -3
  60. package/dist/{index-DU4iyU3D.js → index-Df-NlbKu.js} +1 -1
  61. package/dist/{inventory-core-dart.default-B7xHV5Y6.js → inventory-core-dart.default-CW9d8gJh.js} +1 -1
  62. package/dist/{lz-string-BtgOc0yQ.js → lz-string-BHfmMoLE.js} +1 -1
  63. package/dist/{netsuite-DmXOUJo-.js → netsuite-BSEnJOMn.js} +2 -2
  64. package/dist/{number-BfNWSAkN.js → number-B1buZ_S4.js} +3 -3
  65. package/dist/{predefined-templates-BKxLIZg6.js → predefined-templates-BIFClpKf.js} +1 -1
  66. package/dist/{purchase-order-template-7iNDStWd.js → purchase-order-template-BCt-pDW-.js} +1 -1
  67. package/dist/{recalculationUtils-BVuC0H2j.js → recalculationUtils-CASVCqt7.js} +1 -1
  68. package/dist/{rules-BK8yTx5p.js → rules-C60UHyIn.js} +2 -2
  69. package/dist/{stock-BSA86fOX.js → stock-CkWMLoi7.js} +1 -1
  70. package/dist/{supplier-DA3y7WoU.js → supplier-CiW6zfX_.js} +2 -2
  71. package/dist/{surcharge-BiYvWPv-.js → surcharge-B9FUKx0L.js} +1 -1
  72. package/dist/tsconfig.app.tsbuildinfo +1 -1
  73. package/dist/{uom-rules-BxHGqiP7.js → uom-rules-DXiQ0ZIA.js} +1 -1
  74. package/dist/{use-ingredient-select-dialog-CPiX95uf.js → use-ingredient-select-dialog-Bn8C8IG1.js} +2 -2
  75. package/dist/{use-inventory-binding-dialog-CxKLW2Xh.js → use-inventory-binding-dialog-DZQ1WG1S.js} +2 -2
  76. package/dist/{use-template-enabled-locations-CrwOCxDu.js → use-template-enabled-locations-B9YKq5YY.js} +2 -2
  77. package/dist/{use-transfer-locations-CNY1m-5P.js → use-transfer-locations-D0mDjUMQ.js} +2 -2
  78. package/dist/{useHrmPermission-YEdf2QFW.js → useHrmPermission-BTkOHa4h.js} +1 -1
  79. package/dist/{useNavigationMenu-Bz5AabkY.js → useNavigationMenu-CSfM_5Wy.js} +2 -2
  80. package/dist/{useSseClient-BWrz2czP.js → useSseClient-DwJXBOEF.js} +3 -3
  81. package/dist/views/receive-request/components/transfer-form/TransferFormProps.d.ts +2 -0
  82. package/dist/views/receive-request/components/transfer-form/composables/use-stock-balance-toggle.d.ts +3 -0
  83. package/dist/views/receive-request/components/transfer-form/composables/use-transfer-items.d.ts +4 -0
  84. package/dist/{vue-i18n-DyHvEzel.js → vue-i18n-BWe-vqm2.js} +287 -287
  85. package/dist/{xlsx-DQfBpM_Q.js → xlsx-BT7Z_gt_.js} +1 -1
  86. package/dist/{xlsx.util-XLH11fha.js → xlsx.util-Bm6lJRyh.js} +3 -3
  87. package/package.json +5 -5
  88. package/dist/ClosingHistoryView-DL9g4naX.js +0 -1108
  89. package/dist/FmUnitInput.vue_vue_type_script_setup_true_lang-CvUDKcli.js +0 -362
  90. package/dist/InventoryBindingForm.vue_vue_type_script_setup_true_lang-DMGMZ556.js +0 -404
  91. package/dist/UnitDisplayControl.vue_vue_type_script_setup_true_lang-Cj15fCG9.js +0 -137
  92. package/dist/export-BS0TrI3Q.js +0 -26
@@ -1,1108 +0,0 @@
1
- import { defineComponent as ne, ref as g, computed as w, watch as ie, resolveComponent as x, openBlock as n, createElementBlock as p, createBlock as H, withModifiers as ue, createCommentVNode as b, createVNode as _, withCtx as I, createElementVNode as o, toDisplayString as a, unref as c, Fragment as G, createTextVNode as Z, renderList as le, normalizeClass as me, h as X, Teleport as ye } from "vue";
2
- import { _ as pe } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-DGlWE5I8.js";
3
- import { useI18n as se, useCoreStore as ge } from "@feedmepos/mf-common";
4
- import { E as ce, B as P, a as he, u as _e } from "./app-D3gm3Lsw.js";
5
- import { F as de } from "./FmAdminBadge-DjnBAgyv.js";
6
- import { _ as be } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-KTtYD7qS.js";
7
- import { useSnackbar as re, useDialog as ke } from "@feedmepos/ui-library";
8
- import { u as fe } from "./stock-BSA86fOX.js";
9
- import { g as ve, f as xe } from "./recalculationUtils-BVuC0H2j.js";
10
- import { _ as De } from "./UnitDisplayControl.vue_vue_type_script_setup_true_lang-Cj15fCG9.js";
11
- const we = { class: "fm-typo-en-heading-lg-600" }, Se = { class: "flex flex-col gap-16" }, Ve = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ce = { class: "flex flex-col gap-8" }, $e = { class: "fm-typo-en-body-md-600" }, Ae = { class: "flex flex-col gap-8" }, Fe = { class: "fm-typo-en-body-md-600" }, Re = { class: "flex items-center gap-8 mb-8" }, Ie = {
12
- key: 2,
13
- class: "text-red-500 text-sm mt-2"
14
- }, Te = { class: "fm-typo-en-body-sm-400" }, Be = {
15
- key: 1,
16
- class: "p-12 border border-fm-color-border-primary rounded-8 bg-fm-color-background-secondary"
17
- }, Le = {
18
- key: 0,
19
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
20
- }, Oe = {
21
- key: 1,
22
- class: "flex flex-col gap-8"
23
- }, Ee = { class: "fm-typo-en-body-sm-600" }, Ue = { class: "flex flex-col gap-4" }, Pe = { key: 0 }, Ne = {
24
- key: 1,
25
- class: "flex flex-col gap-8"
26
- }, Me = { class: "fm-typo-en-body-md-600" }, Ke = { class: "flex flex-col gap-8 max-h-[300px] overflow-y-auto" }, He = { class: "flex items-center justify-between" }, je = { class: "fm-typo-en-body-sm-600" }, ze = { class: "flex items-center gap-8" }, We = {
27
- key: 0,
28
- class: "fm-typo-en-body-xs-600 px-8 py-4 rounded-4 bg-fm-color-neutral-100 text-fm-color-typo-secondary"
29
- }, Ye = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Ge = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Je = {
30
- key: 0,
31
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
32
- }, Qe = {
33
- key: 1,
34
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
35
- }, Xe = {
36
- key: 2,
37
- class: "fm-typo-en-body-xs-400 text-fm-color-system-error-500"
38
- }, Ze = {
39
- key: 0,
40
- class: "flex gap-8 ml-auto"
41
- }, qe = {
42
- key: 1,
43
- class: "flex gap-8 ml-auto"
44
- }, et = /* @__PURE__ */ ne({
45
- __name: "RecalculationDialog",
46
- props: {
47
- showButton: { type: Boolean }
48
- },
49
- emits: ["submitted"],
50
- setup(ae, { expose: S, emit: V }) {
51
- const M = V, { t } = se(), L = fe(), T = ce(), k = re(), D = g(!1), v = g(""), f = g(""), $ = g(!1), U = g([]), l = g(!1), s = g([]), C = g(!1), h = g([]), F = g(!1), N = w(() => ve(U.value)), O = w(() => {
52
- if (!v.value) return [];
53
- const d = N.value.find((e) => e.value === v.value);
54
- return d ? N.value.filter((e) => e.date.getTime() > d.date.getTime()).sort((e, u) => u.date.getTime() - e.date.getTime()) : [];
55
- }), j = w({
56
- get: () => {
57
- if ($.value && f.value) {
58
- const d = U.value.find((e) => P(e._id) === f.value);
59
- return (d == null ? void 0 : d._id) || f.value;
60
- }
61
- return f.value;
62
- },
63
- set: (d) => {
64
- $.value && d ? f.value = P(d) : f.value = d;
65
- }
66
- }), z = w(() => {
67
- if (v.value)
68
- try {
69
- const d = P(v.value);
70
- if (d)
71
- return d;
72
- } catch (d) {
73
- console.error("Error parsing date from closing ID:", d);
74
- }
75
- }), E = w(() => {
76
- if (!v.value || !f.value) return "";
77
- const d = P(v.value), e = f.value;
78
- if (d && e) {
79
- const u = new Date(d).getTime();
80
- if (new Date(e).getTime() <= u)
81
- return t("inventory.stock.recalculation.error.endDateBeforeOpening");
82
- }
83
- return "";
84
- }), K = w(() => !!v.value && !!f.value && !E.value), J = w(() => s.value.some(
85
- (d) => !d.completedAt && !d.failedReason
86
- ));
87
- async function Q() {
88
- D.value = !0, await Promise.all([ee(), W()]), v.value = "", f.value = "", $.value = !1;
89
- }
90
- function q() {
91
- D.value = !1;
92
- }
93
- S({
94
- open: Q,
95
- close: q
96
- });
97
- async function ee() {
98
- l.value = !0;
99
- try {
100
- const d = await T.getLastNClosings(30);
101
- U.value = d;
102
- } catch (d) {
103
- console.error("Error fetching recent closings:", d), k.open({
104
- title: t("common.error"),
105
- message: "Failed to fetch recent closings",
106
- type: "error"
107
- });
108
- } finally {
109
- l.value = !1;
110
- }
111
- }
112
- async function W() {
113
- C.value = !0;
114
- try {
115
- const d = await L.recalculation.recalculationRequests();
116
- s.value = d;
117
- } catch (d) {
118
- console.error("Error fetching recalculation requests:", d);
119
- } finally {
120
- C.value = !1;
121
- }
122
- }
123
- async function Y() {
124
- if (!v.value || !f.value) {
125
- h.value = [];
126
- return;
127
- }
128
- F.value = !0;
129
- try {
130
- const d = await L.recalculation.getAffectedClosingDrafts(
131
- v.value,
132
- f.value
133
- );
134
- h.value = d;
135
- } catch {
136
- k.open({
137
- title: t("common.error"),
138
- message: "Failed to fetch affected closing drafts",
139
- type: "error"
140
- }), h.value = [];
141
- } finally {
142
- F.value = !1;
143
- }
144
- }
145
- ie(
146
- [v, f],
147
- () => {
148
- v.value && f.value && !E.value ? Y() : h.value = [];
149
- },
150
- { immediate: !1 }
151
- );
152
- async function te() {
153
- if (K.value) {
154
- l.value = !0;
155
- try {
156
- if (await L.recalculation.scheduleRecalculation({
157
- openingId: v.value,
158
- untilDate: f.value
159
- }), h.value.length > 0) {
160
- const d = h.value.map((e) => e._id);
161
- await L.recalculation.scheduleInvalidateClosingDraftCache(d);
162
- }
163
- k.open({
164
- title: t("common.success"),
165
- message: "Stock recalculation has been scheduled successfully",
166
- type: "success"
167
- }), await W(), D.value = !1, M("submitted");
168
- } catch (d) {
169
- console.error("Error scheduling recalculation:", d), k.open({
170
- title: t("common.error"),
171
- message: "Failed to schedule stock recalculation",
172
- type: "error"
173
- });
174
- } finally {
175
- l.value = !1;
176
- }
177
- }
178
- }
179
- return (d, e) => {
180
- const u = x("FmButton"), i = x("FmSelect"), m = x("FmRadio"), R = x("FmDatePicker"), B = x("FmAlert"), oe = x("FmDialog");
181
- return n(), p("div", null, [
182
- d.showButton ? (n(), H(u, {
183
- key: 0,
184
- "prepend-icon": "info",
185
- variant: "tertiary",
186
- onClick: ue(Q, ["stop"])
187
- })) : b("", !0),
188
- _(oe, {
189
- modelValue: D.value,
190
- "onUpdate:modelValue": e[7] || (e[7] = (r) => D.value = r),
191
- "close-button": "",
192
- dismissAway: "",
193
- "max-width": "600px"
194
- }, {
195
- "dialog-header": I(() => [
196
- o("div", we, a(c(t)("inventory.stock.recalculation.title")), 1)
197
- ]),
198
- "dialog-footer": I(() => [
199
- J.value ? (n(), p("div", qe, [
200
- _(u, {
201
- variant: "tertiary",
202
- onClick: e[6] || (e[6] = (r) => D.value = !1),
203
- label: c(t)("common.close")
204
- }, null, 8, ["label"])
205
- ])) : (n(), p("div", Ze, [
206
- _(u, {
207
- variant: "tertiary",
208
- onClick: e[5] || (e[5] = (r) => D.value = !1),
209
- disabled: l.value,
210
- label: c(t)("common.cancel")
211
- }, null, 8, ["disabled", "label"]),
212
- _(u, {
213
- variant: "primary",
214
- onClick: te,
215
- disabled: !K.value || l.value,
216
- loading: l.value,
217
- label: c(t)("inventory.stock.recalculation.schedule")
218
- }, null, 8, ["disabled", "loading", "label"])
219
- ]))
220
- ]),
221
- default: I(() => [
222
- o("div", Se, [
223
- o("div", Ve, a(c(t)("inventory.stock.recalculation.description")), 1),
224
- J.value ? b("", !0) : (n(), p(G, { key: 0 }, [
225
- o("div", Ce, [
226
- o("p", $e, [
227
- Z(a(c(t)("inventory.stock.recalculation.openingDate")) + " ", 1),
228
- e[8] || (e[8] = o("span", { class: "text-fm-color-system-error-300" }, "*", -1))
229
- ]),
230
- e[9] || (e[9] = o("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary mb-4" }, " Showing the last 30 closing records. Select the opening date to start recalculation. ", -1)),
231
- _(i, {
232
- modelValue: v.value,
233
- "onUpdate:modelValue": e[0] || (e[0] = (r) => v.value = r),
234
- items: N.value,
235
- placeholder: c(t)("inventory.stock.recalculation.selectOpening"),
236
- loading: l.value,
237
- disabled: l.value
238
- }, null, 8, ["modelValue", "items", "placeholder", "loading", "disabled"])
239
- ]),
240
- o("div", Ae, [
241
- o("p", Fe, [
242
- Z(a(c(t)("inventory.stock.recalculation.untilDate")) + " ", 1),
243
- e[10] || (e[10] = o("span", { class: "text-fm-color-system-error-300" }, "*", -1))
244
- ]),
245
- o("div", Re, [
246
- _(m, {
247
- modelValue: $.value,
248
- "onUpdate:modelValue": e[1] || (e[1] = (r) => $.value = r),
249
- value: !1,
250
- label: c(t)("inventory.stock.recalculation.selectByDate")
251
- }, null, 8, ["modelValue", "label"]),
252
- _(m, {
253
- modelValue: $.value,
254
- "onUpdate:modelValue": e[2] || (e[2] = (r) => $.value = r),
255
- value: !0,
256
- label: c(t)("inventory.stock.recalculation.selectByClosing")
257
- }, null, 8, ["modelValue", "label"])
258
- ]),
259
- $.value ? (n(), H(i, {
260
- key: 1,
261
- modelValue: j.value,
262
- "onUpdate:modelValue": e[4] || (e[4] = (r) => j.value = r),
263
- items: O.value,
264
- placeholder: c(t)("inventory.stock.recalculation.selectClosing"),
265
- loading: l.value,
266
- disabled: !v.value || l.value
267
- }, null, 8, ["modelValue", "items", "placeholder", "loading", "disabled"])) : (n(), H(R, {
268
- key: 0,
269
- modelValue: f.value,
270
- "onUpdate:modelValue": e[3] || (e[3] = (r) => f.value = r),
271
- placeholder: c(t)("inventory.stock.recalculation.selectDate"),
272
- min: z.value,
273
- disabled: !v.value || l.value
274
- }, null, 8, ["modelValue", "placeholder", "min", "disabled"])),
275
- E.value ? (n(), p("div", Ie, a(E.value), 1)) : b("", !0)
276
- ]),
277
- v.value && f.value && !E.value ? (n(), H(B, {
278
- key: 0,
279
- type: "info"
280
- }, {
281
- default: I(() => [
282
- o("div", Te, a(c(t)("inventory.stock.recalculation.info")), 1)
283
- ]),
284
- _: 1
285
- })) : b("", !0),
286
- h.value.length > 0 ? (n(), p("div", Be, [
287
- F.value ? (n(), p("div", Le, " Loading affected closing drafts... ")) : (n(), p("div", Oe, [
288
- o("div", Ee, " Affected closing draft(s): " + a(h.value.length), 1),
289
- o("div", Ue, [
290
- (n(!0), p(G, null, le(h.value, (r) => (n(), p("div", {
291
- key: r._id,
292
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
293
- }, [
294
- Z(" • " + a(r._id) + " ", 1),
295
- r.effectiveAt ? (n(), p("span", Pe, " (" + a(new Date(r.effectiveAt).toLocaleString()) + ") ", 1)) : b("", !0)
296
- ]))), 128))
297
- ])
298
- ]))
299
- ])) : b("", !0)
300
- ], 64)),
301
- s.value.length > 0 ? (n(), p("div", Ne, [
302
- o("p", Me, a(c(t)("inventory.stock.recalculation.recentRequests")), 1),
303
- o("div", Ke, [
304
- (n(!0), p(G, null, le(s.value, (r) => {
305
- var y;
306
- return n(), p("div", {
307
- key: r._id,
308
- class: "p-12 border border-fm-color-border-primary rounded-8 flex flex-col gap-4"
309
- }, [
310
- o("div", He, [
311
- o("div", je, a(c(t)("inventory.stock.recalculation.requestedAt")) + ": " + a(new Date(r.createdAt).toLocaleString()), 1),
312
- o("div", ze, [
313
- (y = r.meta) != null && y.openingType ? (n(), p("div", We, a(r.meta.openingType === "stockSnapshot" ? "Snapshot" : "Closing"), 1)) : b("", !0),
314
- o("div", {
315
- class: me(["fm-typo-en-body-xs-600 px-8 py-4 rounded-4", {
316
- "bg-fm-color-system-error-100 text-fm-color-system-error-500": r.failedReason,
317
- "bg-fm-color-system-success-100 text-fm-color-system-success-500": r.completedAt,
318
- "bg-fm-color-system-info-100 text-fm-color-system-info-500": !r.failedReason && !r.completedAt
319
- }])
320
- }, a(r.failedReason ? c(t)("inventory.stock.recalculation.status.failed") : r.completedAt ? c(t)("inventory.stock.recalculation.status.completed") : c(t)("inventory.stock.recalculation.status.inProgress")), 3)
321
- ])
322
- ]),
323
- o("div", Ye, a(c(t)("inventory.stock.recalculation.from")) + ": " + a(new Date(r.recalculateStartDate).toLocaleDateString()), 1),
324
- o("div", Ge, a(c(t)("inventory.stock.recalculation.to")) + ": " + a(new Date(r.recalculateEndDate).toLocaleDateString()), 1),
325
- r.createdBy ? (n(), p("div", Je, a(c(t)("inventory.stock.recalculation.requestedBy")) + ": " + a(r.createdBy.name || r.createdBy.id), 1)) : b("", !0),
326
- r.completedAt ? (n(), p("div", Qe, a(c(t)("inventory.stock.recalculation.completedAt")) + ": " + a(new Date(r.completedAt).toLocaleString()), 1)) : b("", !0),
327
- r.failedReason ? (n(), p("div", Xe, a(r.failedReason), 1)) : b("", !0)
328
- ]);
329
- }), 128))
330
- ])
331
- ])) : b("", !0)
332
- ])
333
- ]),
334
- _: 1
335
- }, 8, ["modelValue"])
336
- ]);
337
- };
338
- }
339
- }), tt = { class: "fm-typo-en-heading-lg-600" }, ot = { class: "flex flex-col gap-16" }, at = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, lt = { class: "flex flex-col gap-8" }, nt = { class: "fm-typo-en-body-md-600" }, st = { class: "flex flex-col gap-8" }, it = { class: "fm-typo-en-body-md-600" }, ct = {
340
- key: 0,
341
- class: "text-red-500 text-sm mt-2"
342
- }, rt = { class: "fm-typo-en-body-sm-400" }, dt = {
343
- key: 1,
344
- class: "p-12 border border-fm-color-border-primary rounded-8 bg-fm-color-background-secondary"
345
- }, ut = {
346
- key: 0,
347
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
348
- }, mt = {
349
- key: 1,
350
- class: "flex flex-col gap-8"
351
- }, ft = { class: "fm-typo-en-body-sm-600" }, vt = { class: "flex flex-col gap-4" }, yt = { key: 0 }, pt = { key: 1 }, gt = { key: 2 }, ht = {
352
- key: 1,
353
- class: "flex flex-col gap-8"
354
- }, _t = { class: "fm-typo-en-body-md-600" }, bt = { class: "flex flex-col gap-8 max-h-[300px] overflow-y-auto" }, kt = { class: "flex items-center justify-between" }, xt = { class: "fm-typo-en-body-sm-600" }, Dt = { class: "flex items-center gap-8" }, wt = {
355
- key: 0,
356
- class: "fm-typo-en-body-xs-600 px-8 py-4 rounded-4 bg-fm-color-neutral-100 text-fm-color-typo-secondary"
357
- }, St = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Vt = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Ct = {
358
- key: 0,
359
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
360
- }, $t = {
361
- key: 1,
362
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
363
- }, At = {
364
- key: 2,
365
- class: "fm-typo-en-body-xs-400 text-fm-color-system-error-500"
366
- }, Ft = {
367
- key: 0,
368
- class: "flex gap-8 ml-auto"
369
- }, Rt = {
370
- key: 1,
371
- class: "flex gap-8 ml-auto"
372
- }, It = /* @__PURE__ */ ne({
373
- __name: "SnapshotRecalculationDialog",
374
- props: {
375
- showButton: { type: Boolean }
376
- },
377
- emits: ["submitted"],
378
- setup(ae, { expose: S, emit: V }) {
379
- const M = V, { t } = se(), L = fe(), T = ce(), k = re(), D = g(!1), v = g(""), f = g(""), $ = g([]), U = g([]), l = g(!1), s = g([]), C = g(!1), h = g([]), F = g(!1), N = w(
380
- () => ve($.value, U.value)
381
- ), O = w(() => xe(
382
- h.value.filter((e) => !!e.closingId).map((e) => ({ closingId: e.closingId, draftCreatedAt: new Date(P(e._id)) }))
383
- )), j = w(() => {
384
- if (v.value)
385
- try {
386
- const e = P(v.value);
387
- if (e)
388
- return e;
389
- } catch (e) {
390
- console.error("Error parsing date from opening ID:", e);
391
- }
392
- }), z = w(() => {
393
- if (!v.value || !f.value) return "";
394
- const e = P(v.value);
395
- if (e && f.value) {
396
- const u = new Date(e).getTime();
397
- if (new Date(f.value).getTime() <= u)
398
- return t("inventory.stock.recalculation.error.endDateBeforeOpening");
399
- }
400
- return "";
401
- }), E = w(() => {
402
- if (!f.value) return !1;
403
- const e = new Date(f.value), u = /* @__PURE__ */ new Date();
404
- return u.setHours(0, 0, 0, 0), e.setHours(0, 0, 0, 0), e >= u;
405
- }), K = w(() => !!v.value && !!f.value && !z.value), J = w(() => s.value.some(
406
- (e) => !e.completedAt && !e.failedReason
407
- ));
408
- async function Q() {
409
- D.value = !0, await Promise.all([ee(), W(), Y()]), v.value = "", f.value = "";
410
- }
411
- function q() {
412
- D.value = !1;
413
- }
414
- S({
415
- open: Q,
416
- close: q
417
- });
418
- async function ee() {
419
- l.value = !0;
420
- try {
421
- const e = await T.getLastNClosings(30);
422
- $.value = e;
423
- } catch (e) {
424
- console.error("Error fetching recent closings:", e), k.open({
425
- title: t("common.error"),
426
- message: "Failed to fetch recent closings",
427
- type: "error"
428
- });
429
- } finally {
430
- l.value = !1;
431
- }
432
- }
433
- async function W() {
434
- try {
435
- const e = await T.getLastNStockSnapshots(30);
436
- U.value = e;
437
- } catch (e) {
438
- console.error("Error fetching recent snapshots:", e);
439
- }
440
- }
441
- async function Y() {
442
- C.value = !0;
443
- try {
444
- const e = await L.recalculation.recalculationRequests();
445
- s.value = e;
446
- } catch (e) {
447
- console.error("Error fetching recalculation requests:", e);
448
- } finally {
449
- C.value = !1;
450
- }
451
- }
452
- async function te() {
453
- if (!v.value || !f.value) {
454
- h.value = [];
455
- return;
456
- }
457
- F.value = !0;
458
- try {
459
- const e = new Date(f.value);
460
- e.setHours(23, 59, 59, 999);
461
- const u = await L.recalculation.getAffectedClosingDrafts(
462
- v.value,
463
- e.toISOString()
464
- );
465
- h.value = u;
466
- } catch {
467
- k.open({
468
- title: t("common.error"),
469
- message: "Failed to fetch affected closing drafts",
470
- type: "error"
471
- }), h.value = [];
472
- } finally {
473
- F.value = !1;
474
- }
475
- }
476
- ie(
477
- [v, f],
478
- () => {
479
- v.value && f.value && !z.value ? te() : h.value = [];
480
- },
481
- { immediate: !1 }
482
- );
483
- async function d() {
484
- if (!(!K.value || !f.value)) {
485
- l.value = !0;
486
- try {
487
- if (await L.recalculation.scheduleRecalculation({
488
- openingId: v.value,
489
- untilDate: new Date(f.value).toISOString(),
490
- recalculateBySnapshot: !0
491
- }), h.value.length > 0) {
492
- const e = h.value.map((u) => u._id);
493
- await L.recalculation.scheduleInvalidateClosingDraftCache(e);
494
- }
495
- k.open({
496
- title: t("common.success"),
497
- message: "Stock recalculation has been scheduled successfully",
498
- type: "success"
499
- }), await Y(), D.value = !1, M("submitted");
500
- } catch (e) {
501
- console.error("Error scheduling recalculation:", e), k.open({
502
- title: t("common.error"),
503
- message: "Failed to schedule stock recalculation",
504
- type: "error"
505
- });
506
- } finally {
507
- l.value = !1;
508
- }
509
- }
510
- }
511
- return (e, u) => {
512
- const i = x("FmButton"), m = x("FmSelect"), R = x("FmDatePicker"), B = x("FmSnackbar"), oe = x("FmAlert"), r = x("FmDialog");
513
- return n(), p("div", null, [
514
- e.showButton ? (n(), H(i, {
515
- key: 0,
516
- "prepend-icon": "info",
517
- variant: "tertiary",
518
- onClick: ue(Q, ["stop"])
519
- })) : b("", !0),
520
- _(r, {
521
- modelValue: D.value,
522
- "onUpdate:modelValue": u[4] || (u[4] = (y) => D.value = y),
523
- "close-button": "",
524
- dismissAway: "",
525
- "max-width": "600px"
526
- }, {
527
- "dialog-header": I(() => [
528
- o("div", tt, a(c(t)("inventory.stock.recalculation.title")), 1)
529
- ]),
530
- "dialog-footer": I(() => [
531
- J.value ? (n(), p("div", Rt, [
532
- _(i, {
533
- variant: "tertiary",
534
- onClick: u[3] || (u[3] = (y) => D.value = !1),
535
- label: c(t)("common.close")
536
- }, null, 8, ["label"])
537
- ])) : (n(), p("div", Ft, [
538
- _(i, {
539
- variant: "tertiary",
540
- onClick: u[2] || (u[2] = (y) => D.value = !1),
541
- disabled: l.value,
542
- label: c(t)("common.cancel")
543
- }, null, 8, ["disabled", "label"]),
544
- _(i, {
545
- variant: "primary",
546
- onClick: d,
547
- disabled: !K.value || l.value,
548
- loading: l.value,
549
- label: c(t)("inventory.stock.recalculation.schedule")
550
- }, null, 8, ["disabled", "loading", "label"])
551
- ]))
552
- ]),
553
- default: I(() => [
554
- o("div", ot, [
555
- o("div", at, a(c(t)("inventory.stock.recalculation.description")), 1),
556
- J.value ? b("", !0) : (n(), p(G, { key: 0 }, [
557
- o("div", lt, [
558
- o("p", nt, [
559
- Z(a(c(t)("inventory.stock.recalculation.openingDate")) + " ", 1),
560
- u[5] || (u[5] = o("span", { class: "text-fm-color-system-error-300" }, "*", -1))
561
- ]),
562
- u[6] || (u[6] = o("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary mb-4" }, " Select from the last 30 closing or snapshot records as the opening date for recalculation. ", -1)),
563
- _(m, {
564
- modelValue: v.value,
565
- "onUpdate:modelValue": u[0] || (u[0] = (y) => v.value = y),
566
- items: N.value,
567
- placeholder: c(t)("inventory.stock.recalculation.selectOpening"),
568
- loading: l.value,
569
- disabled: l.value
570
- }, null, 8, ["modelValue", "items", "placeholder", "loading", "disabled"])
571
- ]),
572
- o("div", st, [
573
- o("p", it, [
574
- Z(a(c(t)("inventory.stock.recalculation.untilDate")) + " ", 1),
575
- u[7] || (u[7] = o("span", { class: "text-fm-color-system-error-300" }, "*", -1))
576
- ]),
577
- u[8] || (u[8] = o("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary mb-4" }, " Select the end date for recalculation. Must be after the selected opening date. ", -1)),
578
- _(R, {
579
- modelValue: f.value,
580
- "onUpdate:modelValue": u[1] || (u[1] = (y) => f.value = y),
581
- placeholder: c(t)("inventory.stock.recalculation.selectDate"),
582
- min: j.value,
583
- disabled: !v.value || l.value
584
- }, null, 8, ["modelValue", "placeholder", "min", "disabled"]),
585
- z.value ? (n(), p("div", ct, a(z.value), 1)) : b("", !0),
586
- E.value ? (n(), H(B, {
587
- key: 1,
588
- title: "Warning",
589
- variant: "warning",
590
- description: "You have selected today or a future date. The stock balance will be refreshed accordingly."
591
- })) : b("", !0)
592
- ]),
593
- v.value && f.value && !z.value ? (n(), H(oe, {
594
- key: 0,
595
- type: "info"
596
- }, {
597
- default: I(() => [
598
- o("div", rt, a(c(t)("inventory.stock.recalculation.info")), 1)
599
- ]),
600
- _: 1
601
- })) : b("", !0),
602
- h.value.length > 0 ? (n(), p("div", dt, [
603
- F.value ? (n(), p("div", ut, " Loading affected closing drafts... ")) : (n(), p("div", mt, [
604
- o("div", ft, " Affected closing draft(s): " + a(h.value.length), 1),
605
- o("div", vt, [
606
- (n(!0), p(G, null, le(h.value, (y) => (n(), p("div", {
607
- key: y._id,
608
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
609
- }, [
610
- u[9] || (u[9] = Z(" • ")),
611
- y.closingId && O.value.get(y.closingId) ? (n(), p("span", yt, a(O.value.get(y.closingId)), 1)) : (n(), p("span", pt, a(y._id), 1)),
612
- y.effectiveAt ? (n(), p("span", gt, " (" + a(new Date(y.effectiveAt).toLocaleString()) + ") ", 1)) : b("", !0)
613
- ]))), 128))
614
- ])
615
- ]))
616
- ])) : b("", !0)
617
- ], 64)),
618
- s.value.length > 0 ? (n(), p("div", ht, [
619
- o("p", _t, a(c(t)("inventory.stock.recalculation.recentRequests")), 1),
620
- o("div", bt, [
621
- (n(!0), p(G, null, le(s.value, (y) => {
622
- var A;
623
- return n(), p("div", {
624
- key: y._id,
625
- class: "p-12 border border-fm-color-border-primary rounded-8 flex flex-col gap-4"
626
- }, [
627
- o("div", kt, [
628
- o("div", xt, a(c(t)("inventory.stock.recalculation.requestedAt")) + ": " + a(new Date(y.createdAt).toLocaleString()), 1),
629
- o("div", Dt, [
630
- (A = y.meta) != null && A.openingType ? (n(), p("div", wt, a(y.meta.openingType === "stockSnapshot" ? "Snapshot" : "Closing"), 1)) : b("", !0),
631
- o("div", {
632
- class: me(["fm-typo-en-body-xs-600 px-8 py-4 rounded-4", {
633
- "bg-fm-color-system-error-100 text-fm-color-system-error-500": y.failedReason,
634
- "bg-fm-color-system-success-100 text-fm-color-system-success-500": y.completedAt,
635
- "bg-fm-color-system-info-100 text-fm-color-system-info-500": !y.failedReason && !y.completedAt
636
- }])
637
- }, a(y.failedReason ? c(t)("inventory.stock.recalculation.status.failed") : y.completedAt ? c(t)("inventory.stock.recalculation.status.completed") : c(t)("inventory.stock.recalculation.status.inProgress")), 3)
638
- ])
639
- ]),
640
- o("div", St, a(c(t)("inventory.stock.recalculation.from")) + ": " + a(new Date(y.recalculateStartDate).toLocaleDateString()), 1),
641
- o("div", Vt, a(c(t)("inventory.stock.recalculation.to")) + ": " + a(new Date(y.recalculateEndDate).toLocaleDateString()), 1),
642
- y.createdBy ? (n(), p("div", Ct, a(c(t)("inventory.stock.recalculation.requestedBy")) + ": " + a(y.createdBy.name || y.createdBy.id), 1)) : b("", !0),
643
- y.completedAt ? (n(), p("div", $t, a(c(t)("inventory.stock.recalculation.completedAt")) + ": " + a(new Date(y.completedAt).toLocaleString()), 1)) : b("", !0),
644
- y.failedReason ? (n(), p("div", At, a(y.failedReason), 1)) : b("", !0)
645
- ]);
646
- }), 128))
647
- ])
648
- ])) : b("", !0)
649
- ])
650
- ]),
651
- _: 1
652
- }, 8, ["modelValue"])
653
- ]);
654
- };
655
- }
656
- }), Tt = { class: "fm-typo-en-heading-lg-600" }, Bt = { class: "flex flex-col gap-16" }, Lt = { class: "flex flex-col gap-4" }, Ot = { class: "fm-typo-en-label-md-400 text-fm-color-typo-secondary" }, Et = { class: "fm-typo-en-body-md-400" }, Ut = { class: "flex flex-col gap-4" }, Pt = { class: "fm-typo-en-label-md-400 text-fm-color-typo-secondary" }, Nt = { class: "fm-typo-en-body-md-400" }, Mt = { class: "flex flex-col gap-4" }, Kt = { class: "fm-typo-en-label-md-400 text-fm-color-typo-secondary" }, Ht = { class: "flex gap-8 ml-auto" }, jt = /* @__PURE__ */ ne({
657
- __name: "ClosingDetailDialog",
658
- props: {
659
- modelValue: { type: Boolean },
660
- type: {},
661
- data: {}
662
- },
663
- emits: ["update:modelValue"],
664
- setup(ae, { emit: S }) {
665
- const { t: V } = se(), M = he(), t = ae, L = S, T = w({
666
- get: () => t.modelValue,
667
- set: (l) => L("update:modelValue", l)
668
- }), k = g("");
669
- ie(T, (l) => {
670
- l || (k.value = "");
671
- });
672
- const D = w(() => {
673
- var l;
674
- return ((l = t.data) == null ? void 0 : l.skus) ?? [];
675
- }), v = w(() => {
676
- var h;
677
- const l = (h = t.data) == null ? void 0 : h._id;
678
- if (!l) return "-";
679
- const s = P(l);
680
- return new Date(s).toLocaleString();
681
- }), f = w(() => t.type === "closing" ? V("inventory.closing.history.closingDetail", "Closing Detail") : V("inventory.closing.history.snapshotDetail", "Snapshot Detail")), $ = w(() => D.value.map((l) => {
682
- const s = M.skuById[l.id] ?? null, C = !s;
683
- return {
684
- id: l.id,
685
- sku: s,
686
- skuName: (s == null ? void 0 : s.name) ?? l.id,
687
- skuCode: (s == null ? void 0 : s.code) ?? "-",
688
- balance: l.balance ?? { amount: 0, precision: 0 },
689
- isMissing: C,
690
- costs: l.costs,
691
- weightedAverage: l.weightedAverage
692
- };
693
- })), U = [
694
- {
695
- accessorKey: "skuName",
696
- header: () => V("inventory.ingredient.name", "Ingredient Name"),
697
- cell: (l) => {
698
- const s = l.row.original;
699
- return s.isMissing ? X("div", { class: "flex items-center gap-8" }, [
700
- X("span", {}, s.id),
701
- X(
702
- "span",
703
- {
704
- class: "px-8 py-2 rounded-4 bg-fm-color-danger-weak text-fm-color-danger-default fm-typo-en-label-sm-400"
705
- },
706
- "Missing"
707
- )
708
- ]) : l.getValue();
709
- }
710
- },
711
- {
712
- accessorKey: "skuCode",
713
- header: () => V("inventory.ingredient.code", "Code")
714
- },
715
- {
716
- id: "balance",
717
- header: () => V("inventory.closing.history.balance", "Balance"),
718
- cell: (l) => {
719
- var h;
720
- const s = l.row.original;
721
- if (s.isMissing || !((h = s.sku) != null && h.unit))
722
- return `${s.balance.amount / Math.pow(10, s.balance.precision)}`;
723
- const C = {
724
- unit: s.sku.unit,
725
- sku: s.sku,
726
- amount: s.balance,
727
- defaultTrackingMeasurement: s.sku.trackingMeasurement ?? void 0
728
- };
729
- return X(De, C);
730
- },
731
- size: 180
732
- },
733
- {
734
- accessorKey: "weightedAverage",
735
- header: () => V("inventory.closing.history.weightedAvgCost", "Weighted Avg Cost"),
736
- cell: (l) => {
737
- const s = l.getValue();
738
- if (!s) return "-";
739
- const C = s.amount ?? 0, h = s.precision ?? 0, F = s.currency ?? "", N = C / Math.pow(10, h);
740
- return `${F} ${N.toFixed(2)}`;
741
- }
742
- }
743
- ];
744
- return (l, s) => {
745
- const C = x("FmTextField"), h = x("FmTable"), F = x("FmButton"), N = x("FmDialog");
746
- return n(), H(N, {
747
- modelValue: T.value,
748
- "onUpdate:modelValue": s[2] || (s[2] = (O) => T.value = O),
749
- "close-button": "",
750
- dismissAway: "",
751
- "max-width": "900px"
752
- }, {
753
- "dialog-header": I(() => [
754
- o("div", Tt, a(f.value), 1)
755
- ]),
756
- default: I(() => {
757
- var O;
758
- return [
759
- o("div", Bt, [
760
- o("div", Lt, [
761
- o("div", Ot, a(t.type === "closing" ? c(V)("inventory.closing.history.closingId") : c(V)("inventory.closing.history.snapshotId", "Snapshot ID")), 1),
762
- o("div", Et, a(((O = t.data) == null ? void 0 : O._id) ?? "-"), 1)
763
- ]),
764
- o("div", Ut, [
765
- o("div", Pt, a(c(V)("inventory.closing.history.date")), 1),
766
- o("div", Nt, a(v.value), 1)
767
- ]),
768
- o("div", Mt, [
769
- o("div", Kt, a(c(V)("inventory.closing.history.ingredientBalances", "Ingredient Balances")) + " (" + a(D.value.length) + ") ", 1),
770
- _(C, {
771
- modelValue: k.value,
772
- "onUpdate:modelValue": s[0] || (s[0] = (j) => k.value = j),
773
- placeholder: "Filter by code or name"
774
- }, null, 8, ["modelValue"]),
775
- _(h, {
776
- "row-data": $.value,
777
- "column-defs": U,
778
- pagination: { pageSize: 10 },
779
- "search-value": k.value
780
- }, null, 8, ["row-data", "search-value"])
781
- ])
782
- ])
783
- ];
784
- }),
785
- "dialog-footer": I(() => [
786
- o("div", Ht, [
787
- _(F, {
788
- variant: "tertiary",
789
- onClick: s[1] || (s[1] = (O) => T.value = !1),
790
- label: "Close"
791
- })
792
- ])
793
- ]),
794
- _: 1
795
- }, 8, ["modelValue"]);
796
- };
797
- }
798
- }), zt = { class: "flex flex-col gap-16 p-16" }, Wt = { class: "flex flex-col gap-16" }, Yt = { class: "flex gap-8 ml-auto" }, lo = /* @__PURE__ */ ne({
799
- __name: "ClosingHistoryView",
800
- setup(ae) {
801
- var e, u;
802
- const { t: S } = se(), V = ce(), M = _e(), t = ge(), L = ke(), T = re(), k = g("closings"), D = [
803
- { label: "Closings", value: "closings" },
804
- { label: "Snapshots", value: "snapshots" }
805
- ], v = g([]), f = g(!1), $ = g([]), U = g(!1), l = g(!1), s = g("closing"), C = g(null), h = new Date(Date.now() - 864e5), F = g(h.toISOString().split("T")[0]), N = w(() => {
806
- const i = [];
807
- return k.value === "closings" ? i.push(
808
- {
809
- label: S("inventory.stock.recalculation.title"),
810
- value: "recalculation",
811
- prependIcon: "history",
812
- isAdminOnly: !0
813
- },
814
- {
815
- label: S("inventory.closing.history.initiate_opening"),
816
- value: "initiateOpening",
817
- prependIcon: "add_box",
818
- isAdminOnly: !0
819
- },
820
- {
821
- label: "Refresh",
822
- value: "refreshOpening",
823
- prependIcon: "refresh"
824
- }
825
- ) : i.push(
826
- {
827
- label: `${S("inventory.stock.recalculation.title")} (BETA)`,
828
- value: "recalculation",
829
- prependIcon: "history",
830
- isAdminOnly: !0
831
- },
832
- {
833
- label: `${S("inventory.closing.history.initiate_snapshot")} (BETA)`,
834
- value: "initiateStockSnapshot",
835
- prependIcon: "camera",
836
- isAdminOnly: !0
837
- },
838
- {
839
- label: "Refresh",
840
- value: "refreshStockSnapshot",
841
- prependIcon: "refresh"
842
- }
843
- ), i;
844
- }), O = g(), j = g();
845
- function z(i) {
846
- var m, R;
847
- switch (i) {
848
- case "recalculation":
849
- return k.value === "closings" ? (m = O.value) == null ? void 0 : m.open() : (R = j.value) == null ? void 0 : R.open();
850
- case "initiateOpening": {
851
- L.open({
852
- title: "Initiate Opening Balance",
853
- message: "Initiate opening balance if no opening balance exists for the current location.",
854
- primaryActions: { text: "Confirm", close: !0 }
855
- }).onPrimary(async () => {
856
- try {
857
- await V.initiateClosing(), T.open({
858
- message: "Opening balance initiated successfully.",
859
- type: "success"
860
- }), await W();
861
- } catch (B) {
862
- T.open({
863
- message: B.message || "Failed to initiate opening balance. Please try again.",
864
- type: "error"
865
- });
866
- }
867
- });
868
- break;
869
- }
870
- case "initiateStockSnapshot": {
871
- const B = new Date(Date.now() - 864e5);
872
- F.value = B.toISOString().split("T")[0], E.value = !0;
873
- break;
874
- }
875
- case "refreshOpening": {
876
- W();
877
- break;
878
- }
879
- case "refreshStockSnapshot": {
880
- Y();
881
- break;
882
- }
883
- }
884
- }
885
- const E = g(!1), K = g(!1), J = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
886
- async function Q() {
887
- K.value = !0;
888
- try {
889
- const i = new Date(F.value).toISOString();
890
- await V.initiateStockSnapshot(i), T.open({
891
- message: "Stock snapshot created successfully.",
892
- type: "success"
893
- }), E.value = !1, await Y();
894
- } catch (i) {
895
- T.open({
896
- message: i.message || "Failed to create stock snapshot. Please try again.",
897
- type: "error"
898
- });
899
- } finally {
900
- K.value = !1;
901
- }
902
- }
903
- const q = [
904
- ...(e = t.sessionUser.value) != null && e.role.isAdmin ? [
905
- {
906
- accessorKey: "_id",
907
- header: () => X(de, {}, () => `${S("inventory.closing.history.closingId")}`),
908
- cell: (i) => i.getValue()
909
- }
910
- ] : [],
911
- {
912
- accessorKey: "_id",
913
- id: "date",
914
- header: () => S("inventory.closing.history.date"),
915
- cell: (i) => {
916
- const m = i.getValue(), R = P(m);
917
- return new Date(R).toLocaleDateString();
918
- }
919
- },
920
- {
921
- accessorKey: "_id",
922
- id: "time",
923
- header: () => S("inventory.closing.history.time"),
924
- cell: (i) => {
925
- const m = i.getValue(), R = P(m);
926
- return new Date(R).toLocaleTimeString();
927
- }
928
- },
929
- {
930
- accessorKey: "ref",
931
- header: () => S("inventory.closing.history.createdFrom"),
932
- cell: (i) => i.getValue() || "-"
933
- }
934
- ], ee = [
935
- ...(u = t.sessionUser.value) != null && u.role.isAdmin ? [
936
- {
937
- accessorKey: "_id",
938
- header: () => X(
939
- de,
940
- {},
941
- () => `${S("inventory.closing.history.snapshotId", "Snapshot ID")}`
942
- ),
943
- cell: (i) => i.getValue()
944
- }
945
- ] : [],
946
- {
947
- accessorKey: "_id",
948
- id: "date",
949
- header: () => S("inventory.closing.history.date"),
950
- cell: (i) => {
951
- const m = i.getValue(), R = P(m);
952
- return new Date(R).toLocaleDateString();
953
- }
954
- },
955
- {
956
- accessorKey: "_id",
957
- id: "time",
958
- header: () => S("inventory.closing.history.time"),
959
- cell: (i) => {
960
- const m = i.getValue(), R = P(m);
961
- return new Date(R).toLocaleTimeString();
962
- }
963
- },
964
- {
965
- accessorKey: "remark",
966
- header: () => S("inventory.closing.history.createdFrom"),
967
- cell: (i) => i.getValue() || "-"
968
- }
969
- ];
970
- async function W() {
971
- if (M.currentLocationDBName) {
972
- f.value = !0;
973
- try {
974
- const i = await V.getLastNClosings(30);
975
- v.value = i;
976
- } catch (i) {
977
- console.error("Error fetching closings:", i), v.value = [];
978
- } finally {
979
- f.value = !1;
980
- }
981
- }
982
- }
983
- async function Y() {
984
- if (M.currentLocationDBName) {
985
- U.value = !0;
986
- try {
987
- const i = await V.getLastNStockSnapshots(30);
988
- $.value = i;
989
- } catch (i) {
990
- console.error("Error fetching stock snapshots:", i), $.value = [];
991
- } finally {
992
- U.value = !1;
993
- }
994
- }
995
- }
996
- function te(i) {
997
- s.value = "closing", C.value = i, l.value = !0;
998
- }
999
- function d(i) {
1000
- s.value = "snapshot", C.value = i, l.value = !0;
1001
- }
1002
- return M.watchLocation(async () => {
1003
- M.currentLocationDBName && (await W(), await Y());
1004
- }), (i, m) => {
1005
- const R = x("FmTabs"), B = x("FmTable"), oe = x("FmDatePicker"), r = x("FmButton"), y = x("FmDialog");
1006
- return n(), H(pe, {
1007
- actions: N.value,
1008
- title: c(S)("inventory.closing.history.title"),
1009
- "onClick:action": z
1010
- }, {
1011
- default: I(() => [
1012
- o("div", zt, [
1013
- _(be, {
1014
- "change-location": "",
1015
- "hide-filter-options": !0
1016
- }),
1017
- _(R, {
1018
- "model-value": k.value,
1019
- "onUpdate:modelValue": m[0] || (m[0] = (A) => k.value = A),
1020
- items: D
1021
- }, null, 8, ["model-value"]),
1022
- k.value === "closings" ? (n(), p(G, { key: 0 }, [
1023
- m[9] || (m[9] = o("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Displaying the last 30 closing records. Click on a row to view details. ", -1)),
1024
- _(B, {
1025
- loading: f.value,
1026
- "row-data": v.value,
1027
- "column-defs": q,
1028
- onRowClick: m[1] || (m[1] = (A) => te(A.original))
1029
- }, null, 8, ["loading", "row-data"])
1030
- ], 64)) : b("", !0),
1031
- k.value === "snapshots" ? (n(), p(G, { key: 1 }, [
1032
- m[10] || (m[10] = o("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Displaying the last 30 stock snapshot records. Snapshots are generated based on adjustments from the last 60 days. Click on a row to view details. ", -1)),
1033
- _(B, {
1034
- loading: U.value,
1035
- "row-data": $.value,
1036
- "column-defs": ee,
1037
- onRowClick: m[2] || (m[2] = (A) => d(A.original))
1038
- }, null, 8, ["loading", "row-data"])
1039
- ], 64)) : b("", !0)
1040
- ]),
1041
- (n(), H(ye, { to: "body" }, [
1042
- _(et, {
1043
- "show-button": !1,
1044
- ref_key: "recalculationDialogRef",
1045
- ref: O,
1046
- onSubmitted: m[3] || (m[3] = (A) => W())
1047
- }, null, 512),
1048
- _(It, {
1049
- "show-button": !1,
1050
- ref_key: "snapshotRecalculationDialogRef",
1051
- ref: j,
1052
- onSubmitted: m[4] || (m[4] = (A) => Y())
1053
- }, null, 512),
1054
- _(jt, {
1055
- modelValue: l.value,
1056
- "onUpdate:modelValue": m[5] || (m[5] = (A) => l.value = A),
1057
- type: s.value,
1058
- data: C.value
1059
- }, null, 8, ["modelValue", "type", "data"]),
1060
- _(y, {
1061
- modelValue: E.value,
1062
- "onUpdate:modelValue": m[8] || (m[8] = (A) => E.value = A),
1063
- "close-button": "",
1064
- dismissAway: "",
1065
- "max-width": "400px"
1066
- }, {
1067
- "dialog-header": I(() => m[11] || (m[11] = [
1068
- o("div", { class: "fm-typo-en-heading-lg-600" }, "Initiate Stock Snapshot", -1)
1069
- ])),
1070
- default: I(() => [
1071
- o("div", Wt, [
1072
- m[12] || (m[12] = o("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Create a stock snapshot for the selected date. The snapshot will capture stock balances based on adjustments from the last 60 days before the selected date. ", -1)),
1073
- _(oe, {
1074
- modelValue: F.value,
1075
- "onUpdate:modelValue": m[6] || (m[6] = (A) => F.value = A),
1076
- label: "Snapshot Date",
1077
- max: c(J)
1078
- }, null, 8, ["modelValue", "max"])
1079
- ])
1080
- ]),
1081
- "dialog-footer": I(() => [
1082
- o("div", Yt, [
1083
- _(r, {
1084
- variant: "tertiary",
1085
- onClick: m[7] || (m[7] = (A) => E.value = !1),
1086
- label: "Cancel",
1087
- disabled: K.value
1088
- }, null, 8, ["disabled"]),
1089
- _(r, {
1090
- variant: "primary",
1091
- onClick: Q,
1092
- label: "Confirm",
1093
- loading: K.value
1094
- }, null, 8, ["loading"])
1095
- ])
1096
- ]),
1097
- _: 1
1098
- }, 8, ["modelValue"])
1099
- ]))
1100
- ]),
1101
- _: 1
1102
- }, 8, ["actions", "title"]);
1103
- };
1104
- }
1105
- });
1106
- export {
1107
- lo as default
1108
- };