@feedmepos/mf-inventory-portal 1.5.8 → 1.5.9-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-CkuUHPEo.js → App-CRKhmCwm.js} +4 -4
  2. package/dist/{ApprovalView-DubepVw0.js → ApprovalView-BdvNZ3Mi.js} +7 -7
  3. package/dist/{BindingsDialog-B4WNBwyC.js → BindingsDialog-UieCgCDS.js} +13 -13
  4. package/dist/{BindingsPicker-BRrLqG1M.js → BindingsPicker-Bo7xvsut.js} +2 -2
  5. package/dist/{BindingsTable-CsL2_ZUy.js → BindingsTable-CUaQzSBn.js} +3 -3
  6. package/dist/ClosingDraftView-QgRaat2h.js +3335 -0
  7. package/dist/{ClosingHistoryView-C9Hidhix.js → ClosingHistoryView-C_qw6v7h.js} +469 -459
  8. package/dist/{ClosingTemplateView-gzJmYQLL.js → ClosingTemplateView-BAsHjB3H.js} +14 -14
  9. package/dist/{DefaultView-Wd26nwBn.js → DefaultView-CaWfkTXn.js} +2 -2
  10. package/dist/{DeliveryOrderPrintPreview-5Jm6QgAP.js → DeliveryOrderPrintPreview-Dv2fXveZ.js} +2 -2
  11. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-Bye4GWOd.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-BFzPTyKA.js} +2 -2
  12. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-D0u8X0Bk.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-Y_AhN6qb.js} +2 -2
  13. package/dist/{FmMultiselectDialog-BuXhazyF.js → FmMultiselectDialog-DT28lMdK.js} +1 -1
  14. package/dist/{FmMultiselectDialog-CrbCQvck.js → FmMultiselectDialog-e4dbq-bB.js} +2 -2
  15. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-U0Io6FhR.js → FmUnitInput.vue_vue_type_script_setup_true_lang-CO2Uom0f.js} +111 -110
  16. package/dist/{ImportView-PBP1w1_z.js → ImportView-Brvxm1EN.js} +6 -6
  17. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-BvlBuk3S.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-DSqbdU3A.js} +1 -1
  18. package/dist/{IngredientGroupView-ZavZf2r_.js → IngredientGroupView-CqqD1_5X.js} +5 -5
  19. package/dist/{IngredientsView-DXKIqdoR.js → IngredientsView-BmOSo8oo.js} +17 -17
  20. package/dist/{IntegrationExplorerView-D-7q6p_s.js → IntegrationExplorerView-CZH3568k.js} +5 -5
  21. package/dist/{IntegrationView-ByvhMaCO.js → IntegrationView-CJv9Ps4v.js} +13 -13
  22. package/dist/{InventoryBindingForm-DAAeny2A.js → InventoryBindingForm-BZVAC4x1.js} +1 -1
  23. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-DpR5ySFv.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-BPl9weMj.js} +5 -5
  24. package/dist/{InventoryBindingSummary-CZBnbomV.js → InventoryBindingSummary-C7Xl5Fd7.js} +1 -1
  25. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BJ6gswNM.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CyjRq3A-.js} +1 -1
  26. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-mlVRfnxo.js → PremiumBadge.vue_vue_type_script_setup_true_lang-DIoYx-x4.js} +1 -1
  27. package/dist/{PublishView-CsMKko5l.js → PublishView-DHK3MPsP.js} +3 -3
  28. package/dist/{PurchaseOrderPrintPreview-B-jchSYL.js → PurchaseOrderPrintPreview-DLg01buw.js} +2 -2
  29. package/dist/{ReceiveRequestView-DfOcn_OW.js → ReceiveRequestView-B1n42VJ5.js} +25 -25
  30. package/dist/{RecipeView-C-1PuiaO.js → RecipeView-BOEfiTuN.js} +19 -19
  31. package/dist/{SettingsView-C3vB5Vjb.js → SettingsView-Bqx3woVD.js} +4 -4
  32. package/dist/{StockView-BAXULvMh.js → StockView-UjWpz_eL.js} +775 -765
  33. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-BI_hHa88.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-BxyFAK_X.js} +1 -1
  34. package/dist/{SupplierView-B9y9d6C0.js → SupplierView-_zK2xohX.js} +12 -12
  35. package/dist/{SurchargeView-D3lq3G0g.js → SurchargeView-BtUebfil.js} +6 -6
  36. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-D54FjCtg.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-DF3seGmT.js} +2 -2
  37. package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-Bi-9US2G.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-Bpo1u5g2.js} +1 -1
  38. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-BkmO63qQ.js → TransferDetails.vue_vue_type_script_setup_true_lang-B_kdNBCT.js} +20 -20
  39. package/dist/{TransferTemplateView-B7hDis-b.js → TransferTemplateView-OlHTVdCG.js} +18 -18
  40. package/dist/{UnitCostHistoryView-DR-RJ6lO.js → UnitCostHistoryView-BIvYaMio.js} +4 -4
  41. package/dist/{UnitDisplayControl.vue_vue_type_script_setup_true_lang-WSYbNJL_.js → UnitDisplayControl.vue_vue_type_script_setup_true_lang-DqTis1lE.js} +4 -4
  42. package/dist/{UnitView-Dx3NUFp2.js → UnitView-DAtDiu3f.js} +9 -9
  43. package/dist/{WarehouseView-CSmq2xhS.js → WarehouseView-B3mXQpoO.js} +5 -5
  44. package/dist/{WastageTemplateView-Bya8Ptja.js → WastageTemplateView-BOoybeCb.js} +14 -14
  45. package/dist/api/error.d.ts +6 -3
  46. package/dist/{app-BtIUZZer.js → app-cwueji6m.js} +10353 -10377
  47. package/dist/app.d.ts +8 -0
  48. package/dist/app.js +4 -4
  49. package/dist/{closing-template-CY4I4oi6.js → closing-template-CobmAqhD.js} +1 -1
  50. package/dist/{date2-BXHREmqe.js → date2-D_-j6u1x.js} +1 -1
  51. package/dist/{dayjs.min-B15_mmz6.js → dayjs.min-iDeAwg0n.js} +1 -1
  52. package/dist/{decimal-CfCuBc7o.js → decimal-DcHr_uvI.js} +2 -2
  53. package/dist/{defineDeepModel-CeW3ETAv.js → defineDeepModel-BhC1n6G-.js} +1 -1
  54. package/dist/{duplicate-template-CTHciPHW.js → duplicate-template-Y9iggS9l.js} +1 -1
  55. package/dist/{export-CCbJ-2Gk.js → export-CAHG4EbP.js} +2 -2
  56. package/dist/{feature-RoG35971.js → feature-BhK4XmmS.js} +86 -86
  57. package/dist/{format-time-from-id-q1T46zz9.js → format-time-from-id-2IFiQNTX.js} +1 -1
  58. package/dist/{format-unit-display-DUaKGmsk.js → format-unit-display-CTYZvXcZ.js} +11 -11
  59. package/dist/helper/uom-rules.d.ts +12 -0
  60. package/dist/{import-export.helper-B2ZzXsyT.js → import-export.helper-DtWH9atw.js} +6 -6
  61. package/dist/{index-CKErlM6H.js → index-Ckhb0CMq.js} +1 -1
  62. package/dist/{index-CF466Sy_.js → index-dfAAA8HA.js} +3 -3
  63. package/dist/{index-BC06YbP9.js → index-iGt85nBk.js} +1 -1
  64. package/dist/{inventory-core-dart.default-BEB7pV9M.js → inventory-core-dart.default-R1tOn2RS.js} +1319 -1264
  65. package/dist/{lz-string-D3Jm7T7Q.js → lz-string-DUT6tVSg.js} +1 -1
  66. package/dist/{menu-usage-module-BiCPifRX.js → menu-usage-module-D7cxkbEk.js} +11 -12
  67. package/dist/netsuite-BiF6Fo7G.js +9381 -0
  68. package/dist/{number-C6mI12qg.js → number-Cqsx9s88.js} +3 -3
  69. package/dist/{predefined-templates-DfpzUsNl.js → predefined-templates-CHExzSjx.js} +1 -1
  70. package/dist/{purchase-order-template-Dq3N4vgB.js → purchase-order-template-_FfLY2u1.js} +1 -1
  71. package/dist/{recalculationUtils-D0A7mbSs.js → recalculationUtils-KdVSBljW.js} +1 -1
  72. package/dist/{rules-Dajxj04v.js → rules-DB26S6qs.js} +2 -2
  73. package/dist/{stock-D6d8tS4B.js → stock-n6h8HkNk.js} +1 -1
  74. package/dist/{supplier-CkfePT6a.js → supplier-6K9Cbfcf.js} +2 -2
  75. package/dist/{surcharge-C3uSQoRw.js → surcharge-BV03ItuR.js} +1 -1
  76. package/dist/tsconfig.app.tsbuildinfo +1 -1
  77. package/dist/uom-rules-CzTxRiqL.js +21 -0
  78. package/dist/{use-ingredient-select-dialog-C3zCgi5E.js → use-ingredient-select-dialog-Bs_4jjVy.js} +2 -2
  79. package/dist/{use-inventory-binding-dialog-CsDrU6sx.js → use-inventory-binding-dialog-CgtoqJ2D.js} +2 -2
  80. package/dist/{use-template-enabled-locations-DpZY_R7j.js → use-template-enabled-locations-C6fQtFF0.js} +2 -2
  81. package/dist/{use-transfer-locations-DlHF5kG-.js → use-transfer-locations-DI48leYd.js} +2 -2
  82. package/dist/{useHrmPermission-C1G3BVpn.js → useHrmPermission-Co1Jgyvq.js} +1 -1
  83. package/dist/{useNavigationMenu-tNJYWFkU.js → useNavigationMenu-JenXwvSv.js} +2 -2
  84. package/dist/{useSseClient-4qu-xO3k.js → useSseClient-gIA58rTS.js} +3 -3
  85. package/dist/views/closing-draft/helpers/export-draft.helper.d.ts +11 -2
  86. package/dist/{vue-i18n-eqPSat_0.js → vue-i18n-C3I0upD3.js} +331 -331
  87. package/dist/{xlsx-DB2JHegF.js → xlsx-4BYDayT5.js} +1 -1
  88. package/dist/{xlsx.util-TwDCO4ay.js → xlsx.util-CD_xD6ZX.js} +3 -3
  89. package/package.json +1 -1
  90. package/dist/ClosingDraftView-Psl49bhd.js +0 -3202
  91. package/dist/lodash-D9rnJgGZ.js +0 -3678
  92. package/dist/netsuite-CuPJ_UTs.js +0 -5708
@@ -1,14 +1,14 @@
1
- import { defineComponent as ne, ref as g, computed as D, watch as de, resolveComponent as w, openBlock as n, createElementBlock as p, createBlock as M, withModifiers as ue, createCommentVNode as b, createVNode as _, withCtx as T, createElementVNode as o, toDisplayString as l, unref as i, Fragment as z, createTextVNode as Z, renderList as le, normalizeClass as me, h as X, Teleport as pe } from "vue";
2
- import { _ as ve } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-DGlWE5I8.js";
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
3
  import { useI18n as se, useCoreStore as ge } from "@feedmepos/mf-common";
4
- import { E as ie, B as P, a as he, u as _e } from "./app-BtIUZZer.js";
5
- import { F as re } from "./FmAdminBadge-DjnBAgyv.js";
6
- import { _ as be } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-D0u8X0Bk.js";
7
- import { useSnackbar as ce, useDialog as ke } from "@feedmepos/ui-library";
8
- import { u as fe } from "./stock-D6d8tS4B.js";
9
- import { g as ye, f as xe } from "./recalculationUtils-D0A7mbSs.js";
10
- import { _ as De } from "./UnitDisplayControl.vue_vue_type_script_setup_true_lang-WSYbNJL_.js";
11
- const we = { class: "fm-typo-en-heading-lg-600" }, Se = { class: "flex flex-col gap-16" }, Ce = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ve = { 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 = {
4
+ import { E as ce, B as P, a as he, u as _e } from "./app-cwueji6m.js";
5
+ import { F as de } from "./FmAdminBadge-DjnBAgyv.js";
6
+ import { _ as be } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-Y_AhN6qb.js";
7
+ import { useSnackbar as re, useDialog as ke } from "@feedmepos/ui-library";
8
+ import { u as fe } from "./stock-n6h8HkNk.js";
9
+ import { g as ve, f as xe } from "./recalculationUtils-KdVSBljW.js";
10
+ import { _ as De } from "./UnitDisplayControl.vue_vue_type_script_setup_true_lang-DqTis1lE.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
12
  key: 2,
13
13
  class: "text-red-500 text-sm mt-2"
14
14
  }, Te = { class: "fm-typo-en-body-sm-400" }, Be = {
@@ -20,7 +20,7 @@ const we = { class: "fm-typo-en-heading-lg-600" }, Se = { class: "flex flex-col
20
20
  }, Oe = {
21
21
  key: 1,
22
22
  class: "flex flex-col gap-8"
23
- }, Ee = { class: "fm-typo-en-body-sm-600" }, Pe = { class: "flex flex-col gap-4" }, Ue = { key: 0 }, Ne = {
23
+ }, Ee = { class: "fm-typo-en-body-sm-600" }, Ue = { class: "flex flex-col gap-4" }, Pe = { key: 0 }, Ne = {
24
24
  key: 1,
25
25
  class: "flex flex-col gap-8"
26
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 = {
@@ -47,284 +47,284 @@ const we = { class: "fm-typo-en-heading-lg-600" }, Se = { class: "flex flex-col
47
47
  showButton: { type: Boolean }
48
48
  },
49
49
  emits: ["submitted"],
50
- setup(ae, { expose: S, emit: C }) {
51
- const U = C, { t } = se(), L = fe(), O = ie(), V = ce(), $ = g(!1), f = g(""), m = g(""), F = g(!1), v = g([]), a = g(!1), k = g([]), A = g(!1), h = g([]), x = g(!1), W = D(() => ye(v.value)), Y = D(() => {
52
- if (!f.value) return [];
53
- const r = W.value.find((e) => e.value === f.value);
54
- return r ? W.value.filter((e) => e.date.getTime() > r.date.getTime()).sort((e, d) => d.date.getTime() - e.date.getTime()) : [];
55
- }), G = D({
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
56
  get: () => {
57
- if (F.value && m.value) {
58
- const r = v.value.find((e) => P(e._id) === m.value);
59
- return (r == null ? void 0 : r._id) || m.value;
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
60
  }
61
- return m.value;
61
+ return f.value;
62
62
  },
63
- set: (r) => {
64
- F.value && r ? m.value = P(r) : m.value = r;
63
+ set: (d) => {
64
+ $.value && d ? f.value = P(d) : f.value = d;
65
65
  }
66
- }), K = D(() => {
67
- if (f.value)
66
+ }), z = w(() => {
67
+ if (v.value)
68
68
  try {
69
- const r = P(f.value);
70
- if (r)
71
- return r;
72
- } catch (r) {
73
- console.error("Error parsing date from closing ID:", r);
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
74
  }
75
- }), E = D(() => {
76
- if (!f.value || !m.value) return "";
77
- const r = P(f.value), e = m.value;
78
- if (r && e) {
79
- const d = new Date(r).getTime();
80
- if (new Date(e).getTime() <= d)
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
81
  return t("inventory.stock.recalculation.error.endDateBeforeOpening");
82
82
  }
83
83
  return "";
84
- }), N = D(() => !!f.value && !!m.value && !E.value), J = D(() => k.value.some(
85
- (r) => !r.completedAt && !r.failedReason
84
+ }), K = w(() => !!v.value && !!f.value && !E.value), J = w(() => s.value.some(
85
+ (d) => !d.completedAt && !d.failedReason
86
86
  ));
87
87
  async function Q() {
88
- $.value = !0, await Promise.all([ee(), H()]), f.value = "", m.value = "", F.value = !1;
88
+ D.value = !0, await Promise.all([ee(), W()]), v.value = "", f.value = "", $.value = !1;
89
89
  }
90
90
  function q() {
91
- $.value = !1;
91
+ D.value = !1;
92
92
  }
93
93
  S({
94
94
  open: Q,
95
95
  close: q
96
96
  });
97
97
  async function ee() {
98
- a.value = !0;
98
+ l.value = !0;
99
99
  try {
100
- const r = await O.getLastNClosings(30);
101
- v.value = r;
102
- } catch (r) {
103
- console.error("Error fetching recent closings:", r), V.open({
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
104
  title: t("common.error"),
105
105
  message: "Failed to fetch recent closings",
106
106
  type: "error"
107
107
  });
108
108
  } finally {
109
- a.value = !1;
109
+ l.value = !1;
110
110
  }
111
111
  }
112
- async function H() {
113
- A.value = !0;
112
+ async function W() {
113
+ C.value = !0;
114
114
  try {
115
- const r = await L.recalculation.recalculationRequests();
116
- k.value = r;
117
- } catch (r) {
118
- console.error("Error fetching recalculation requests:", r);
115
+ const d = await L.recalculation.recalculationRequests();
116
+ s.value = d;
117
+ } catch (d) {
118
+ console.error("Error fetching recalculation requests:", d);
119
119
  } finally {
120
- A.value = !1;
120
+ C.value = !1;
121
121
  }
122
122
  }
123
- async function j() {
124
- if (!f.value || !m.value) {
123
+ async function Y() {
124
+ if (!v.value || !f.value) {
125
125
  h.value = [];
126
126
  return;
127
127
  }
128
- x.value = !0;
128
+ F.value = !0;
129
129
  try {
130
- const r = await L.recalculation.getAffectedClosingDrafts(
131
- f.value,
132
- m.value
130
+ const d = await L.recalculation.getAffectedClosingDrafts(
131
+ v.value,
132
+ f.value
133
133
  );
134
- h.value = r;
134
+ h.value = d;
135
135
  } catch {
136
- V.open({
136
+ k.open({
137
137
  title: t("common.error"),
138
138
  message: "Failed to fetch affected closing drafts",
139
139
  type: "error"
140
140
  }), h.value = [];
141
141
  } finally {
142
- x.value = !1;
142
+ F.value = !1;
143
143
  }
144
144
  }
145
- de(
146
- [f, m],
145
+ ie(
146
+ [v, f],
147
147
  () => {
148
- f.value && m.value && !E.value ? j() : h.value = [];
148
+ v.value && f.value && !E.value ? Y() : h.value = [];
149
149
  },
150
150
  { immediate: !1 }
151
151
  );
152
152
  async function te() {
153
- if (N.value) {
154
- a.value = !0;
153
+ if (K.value) {
154
+ l.value = !0;
155
155
  try {
156
156
  if (await L.recalculation.scheduleRecalculation({
157
- openingId: f.value,
158
- untilDate: m.value
157
+ openingId: v.value,
158
+ untilDate: f.value
159
159
  }), h.value.length > 0) {
160
- const r = h.value.map((e) => e._id);
161
- await L.recalculation.scheduleInvalidateClosingDraftCache(r);
160
+ const d = h.value.map((e) => e._id);
161
+ await L.recalculation.scheduleInvalidateClosingDraftCache(d);
162
162
  }
163
- V.open({
163
+ k.open({
164
164
  title: t("common.success"),
165
165
  message: "Stock recalculation has been scheduled successfully",
166
166
  type: "success"
167
- }), await H(), $.value = !1, U("submitted");
168
- } catch (r) {
169
- console.error("Error scheduling recalculation:", r), V.open({
167
+ }), await W(), D.value = !1, M("submitted");
168
+ } catch (d) {
169
+ console.error("Error scheduling recalculation:", d), k.open({
170
170
  title: t("common.error"),
171
171
  message: "Failed to schedule stock recalculation",
172
172
  type: "error"
173
173
  });
174
174
  } finally {
175
- a.value = !1;
175
+ l.value = !1;
176
176
  }
177
177
  }
178
178
  }
179
- return (r, e) => {
180
- const d = w("FmButton"), s = w("FmSelect"), u = w("FmRadio"), I = w("FmDatePicker"), B = w("FmAlert"), oe = w("FmDialog");
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
181
  return n(), p("div", null, [
182
- r.showButton ? (n(), M(d, {
182
+ d.showButton ? (n(), H(u, {
183
183
  key: 0,
184
184
  "prepend-icon": "info",
185
185
  variant: "tertiary",
186
186
  onClick: ue(Q, ["stop"])
187
187
  })) : b("", !0),
188
188
  _(oe, {
189
- modelValue: $.value,
190
- "onUpdate:modelValue": e[7] || (e[7] = (c) => $.value = c),
189
+ modelValue: D.value,
190
+ "onUpdate:modelValue": e[7] || (e[7] = (r) => D.value = r),
191
191
  "close-button": "",
192
192
  dismissAway: "",
193
193
  "max-width": "600px"
194
194
  }, {
195
- "dialog-header": T(() => [
196
- o("div", we, l(i(t)("inventory.stock.recalculation.title")), 1)
195
+ "dialog-header": I(() => [
196
+ o("div", we, a(c(t)("inventory.stock.recalculation.title")), 1)
197
197
  ]),
198
- "dialog-footer": T(() => [
198
+ "dialog-footer": I(() => [
199
199
  J.value ? (n(), p("div", qe, [
200
- _(d, {
200
+ _(u, {
201
201
  variant: "tertiary",
202
- onClick: e[6] || (e[6] = (c) => $.value = !1),
203
- label: i(t)("common.close")
202
+ onClick: e[6] || (e[6] = (r) => D.value = !1),
203
+ label: c(t)("common.close")
204
204
  }, null, 8, ["label"])
205
205
  ])) : (n(), p("div", Ze, [
206
- _(d, {
206
+ _(u, {
207
207
  variant: "tertiary",
208
- onClick: e[5] || (e[5] = (c) => $.value = !1),
209
- disabled: a.value,
210
- label: i(t)("common.cancel")
208
+ onClick: e[5] || (e[5] = (r) => D.value = !1),
209
+ disabled: l.value,
210
+ label: c(t)("common.cancel")
211
211
  }, null, 8, ["disabled", "label"]),
212
- _(d, {
212
+ _(u, {
213
213
  variant: "primary",
214
214
  onClick: te,
215
- disabled: !N.value || a.value,
216
- loading: a.value,
217
- label: i(t)("inventory.stock.recalculation.schedule")
215
+ disabled: !K.value || l.value,
216
+ loading: l.value,
217
+ label: c(t)("inventory.stock.recalculation.schedule")
218
218
  }, null, 8, ["disabled", "loading", "label"])
219
219
  ]))
220
220
  ]),
221
- default: T(() => [
221
+ default: I(() => [
222
222
  o("div", Se, [
223
- o("div", Ce, l(i(t)("inventory.stock.recalculation.description")), 1),
224
- J.value ? b("", !0) : (n(), p(z, { key: 0 }, [
225
- o("div", Ve, [
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
226
  o("p", $e, [
227
- Z(l(i(t)("inventory.stock.recalculation.openingDate")) + " ", 1),
227
+ Z(a(c(t)("inventory.stock.recalculation.openingDate")) + " ", 1),
228
228
  e[8] || (e[8] = o("span", { class: "text-fm-color-system-error-300" }, "*", -1))
229
229
  ]),
230
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
- _(s, {
232
- modelValue: f.value,
233
- "onUpdate:modelValue": e[0] || (e[0] = (c) => f.value = c),
234
- items: W.value,
235
- placeholder: i(t)("inventory.stock.recalculation.selectOpening"),
236
- loading: a.value,
237
- disabled: a.value
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
238
  }, null, 8, ["modelValue", "items", "placeholder", "loading", "disabled"])
239
239
  ]),
240
240
  o("div", Ae, [
241
241
  o("p", Fe, [
242
- Z(l(i(t)("inventory.stock.recalculation.untilDate")) + " ", 1),
242
+ Z(a(c(t)("inventory.stock.recalculation.untilDate")) + " ", 1),
243
243
  e[10] || (e[10] = o("span", { class: "text-fm-color-system-error-300" }, "*", -1))
244
244
  ]),
245
245
  o("div", Re, [
246
- _(u, {
247
- modelValue: F.value,
248
- "onUpdate:modelValue": e[1] || (e[1] = (c) => F.value = c),
246
+ _(m, {
247
+ modelValue: $.value,
248
+ "onUpdate:modelValue": e[1] || (e[1] = (r) => $.value = r),
249
249
  value: !1,
250
- label: i(t)("inventory.stock.recalculation.selectByDate")
250
+ label: c(t)("inventory.stock.recalculation.selectByDate")
251
251
  }, null, 8, ["modelValue", "label"]),
252
- _(u, {
253
- modelValue: F.value,
254
- "onUpdate:modelValue": e[2] || (e[2] = (c) => F.value = c),
252
+ _(m, {
253
+ modelValue: $.value,
254
+ "onUpdate:modelValue": e[2] || (e[2] = (r) => $.value = r),
255
255
  value: !0,
256
- label: i(t)("inventory.stock.recalculation.selectByClosing")
256
+ label: c(t)("inventory.stock.recalculation.selectByClosing")
257
257
  }, null, 8, ["modelValue", "label"])
258
258
  ]),
259
- F.value ? (n(), M(s, {
259
+ $.value ? (n(), H(i, {
260
260
  key: 1,
261
- modelValue: G.value,
262
- "onUpdate:modelValue": e[4] || (e[4] = (c) => G.value = c),
263
- items: Y.value,
264
- placeholder: i(t)("inventory.stock.recalculation.selectClosing"),
265
- loading: a.value,
266
- disabled: !f.value || a.value
267
- }, null, 8, ["modelValue", "items", "placeholder", "loading", "disabled"])) : (n(), M(I, {
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
268
  key: 0,
269
- modelValue: m.value,
270
- "onUpdate:modelValue": e[3] || (e[3] = (c) => m.value = c),
271
- placeholder: i(t)("inventory.stock.recalculation.selectDate"),
272
- min: K.value,
273
- disabled: !f.value || a.value
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
274
  }, null, 8, ["modelValue", "placeholder", "min", "disabled"])),
275
- E.value ? (n(), p("div", Ie, l(E.value), 1)) : b("", !0)
275
+ E.value ? (n(), p("div", Ie, a(E.value), 1)) : b("", !0)
276
276
  ]),
277
- f.value && m.value && !E.value ? (n(), M(B, {
277
+ v.value && f.value && !E.value ? (n(), H(B, {
278
278
  key: 0,
279
279
  type: "info"
280
280
  }, {
281
- default: T(() => [
282
- o("div", Te, l(i(t)("inventory.stock.recalculation.info")), 1)
281
+ default: I(() => [
282
+ o("div", Te, a(c(t)("inventory.stock.recalculation.info")), 1)
283
283
  ]),
284
284
  _: 1
285
285
  })) : b("", !0),
286
286
  h.value.length > 0 ? (n(), p("div", Be, [
287
- x.value ? (n(), p("div", Le, " Loading affected closing drafts... ")) : (n(), p("div", Oe, [
288
- o("div", Ee, " Affected closing draft(s): " + l(h.value.length), 1),
289
- o("div", Pe, [
290
- (n(!0), p(z, null, le(h.value, (c) => (n(), p("div", {
291
- key: c._id,
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
292
  class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
293
293
  }, [
294
- Z(" • " + l(c._id) + " ", 1),
295
- c.effectiveAt ? (n(), p("span", Ue, " (" + l(new Date(c.effectiveAt).toLocaleString()) + ") ", 1)) : b("", !0)
294
+ Z(" • " + a(r._id) + " ", 1),
295
+ r.effectiveAt ? (n(), p("span", Pe, " (" + a(new Date(r.effectiveAt).toLocaleString()) + ") ", 1)) : b("", !0)
296
296
  ]))), 128))
297
297
  ])
298
298
  ]))
299
299
  ])) : b("", !0)
300
300
  ], 64)),
301
- k.value.length > 0 ? (n(), p("div", Ne, [
302
- o("p", Me, l(i(t)("inventory.stock.recalculation.recentRequests")), 1),
301
+ s.value.length > 0 ? (n(), p("div", Ne, [
302
+ o("p", Me, a(c(t)("inventory.stock.recalculation.recentRequests")), 1),
303
303
  o("div", Ke, [
304
- (n(!0), p(z, null, le(k.value, (c) => {
304
+ (n(!0), p(G, null, le(s.value, (r) => {
305
305
  var y;
306
306
  return n(), p("div", {
307
- key: c._id,
307
+ key: r._id,
308
308
  class: "p-12 border border-fm-color-border-primary rounded-8 flex flex-col gap-4"
309
309
  }, [
310
310
  o("div", He, [
311
- o("div", je, l(i(t)("inventory.stock.recalculation.requestedAt")) + ": " + l(new Date(c.createdAt).toLocaleString()), 1),
311
+ o("div", je, a(c(t)("inventory.stock.recalculation.requestedAt")) + ": " + a(new Date(r.createdAt).toLocaleString()), 1),
312
312
  o("div", ze, [
313
- (y = c.meta) != null && y.openingType ? (n(), p("div", We, l(c.meta.openingType === "stockSnapshot" ? "Snapshot" : "Closing"), 1)) : b("", !0),
313
+ (y = r.meta) != null && y.openingType ? (n(), p("div", We, a(r.meta.openingType === "stockSnapshot" ? "Snapshot" : "Closing"), 1)) : b("", !0),
314
314
  o("div", {
315
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": c.failedReason,
317
- "bg-fm-color-system-success-100 text-fm-color-system-success-500": c.completedAt,
318
- "bg-fm-color-system-info-100 text-fm-color-system-info-500": !c.failedReason && !c.completedAt
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
319
  }])
320
- }, l(c.failedReason ? i(t)("inventory.stock.recalculation.status.failed") : c.completedAt ? i(t)("inventory.stock.recalculation.status.completed") : i(t)("inventory.stock.recalculation.status.inProgress")), 3)
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
321
  ])
322
322
  ]),
323
- o("div", Ye, l(i(t)("inventory.stock.recalculation.from")) + ": " + l(new Date(c.recalculateStartDate).toLocaleDateString()), 1),
324
- o("div", Ge, l(i(t)("inventory.stock.recalculation.to")) + ": " + l(new Date(c.recalculateEndDate).toLocaleDateString()), 1),
325
- c.createdBy ? (n(), p("div", Je, l(i(t)("inventory.stock.recalculation.requestedBy")) + ": " + l(c.createdBy.name || c.createdBy.id), 1)) : b("", !0),
326
- c.completedAt ? (n(), p("div", Qe, l(i(t)("inventory.stock.recalculation.completedAt")) + ": " + l(new Date(c.completedAt).toLocaleString()), 1)) : b("", !0),
327
- c.failedReason ? (n(), p("div", Xe, l(c.failedReason), 1)) : b("", !0)
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
328
  ]);
329
329
  }), 128))
330
330
  ])
@@ -348,13 +348,13 @@ const we = { class: "fm-typo-en-heading-lg-600" }, Se = { class: "flex flex-col
348
348
  }, mt = {
349
349
  key: 1,
350
350
  class: "flex flex-col gap-8"
351
- }, ft = { class: "fm-typo-en-body-sm-600" }, yt = { class: "flex flex-col gap-4" }, pt = { key: 0 }, vt = { key: 1 }, gt = { key: 2 }, ht = {
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
352
  key: 1,
353
353
  class: "flex flex-col gap-8"
354
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
355
  key: 0,
356
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" }, Ct = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Vt = {
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
358
  key: 0,
359
359
  class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
360
360
  }, $t = {
@@ -375,273 +375,273 @@ const we = { class: "fm-typo-en-heading-lg-600" }, Se = { class: "flex flex-col
375
375
  showButton: { type: Boolean }
376
376
  },
377
377
  emits: ["submitted"],
378
- setup(ae, { expose: S, emit: C }) {
379
- const U = C, { t } = se(), L = fe(), O = ie(), V = ce(), $ = g(!1), f = g(""), m = g(""), F = g([]), v = g([]), a = g(!1), k = g([]), A = g(!1), h = g([]), x = g(!1), W = D(
380
- () => ye(F.value, v.value)
381
- ), Y = D(() => xe(
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
382
  h.value.filter((e) => !!e.closingId).map((e) => ({ closingId: e.closingId, draftCreatedAt: new Date(P(e._id)) }))
383
- )), G = D(() => {
384
- if (f.value)
383
+ )), j = w(() => {
384
+ if (v.value)
385
385
  try {
386
- const e = P(f.value);
386
+ const e = P(v.value);
387
387
  if (e)
388
388
  return e;
389
389
  } catch (e) {
390
390
  console.error("Error parsing date from opening ID:", e);
391
391
  }
392
- }), K = D(() => {
393
- if (!f.value || !m.value) return "";
394
- const e = P(f.value);
395
- if (e && m.value) {
396
- const d = new Date(e).getTime();
397
- if (new Date(m.value).getTime() <= d)
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
398
  return t("inventory.stock.recalculation.error.endDateBeforeOpening");
399
399
  }
400
400
  return "";
401
- }), E = D(() => {
402
- if (!m.value) return !1;
403
- const e = new Date(m.value), d = /* @__PURE__ */ new Date();
404
- return d.setHours(0, 0, 0, 0), e.setHours(0, 0, 0, 0), e >= d;
405
- }), N = D(() => !!f.value && !!m.value && !K.value), J = D(() => k.value.some(
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
406
  (e) => !e.completedAt && !e.failedReason
407
407
  ));
408
408
  async function Q() {
409
- $.value = !0, await Promise.all([ee(), H(), j()]), f.value = "", m.value = "";
409
+ D.value = !0, await Promise.all([ee(), W(), Y()]), v.value = "", f.value = "";
410
410
  }
411
411
  function q() {
412
- $.value = !1;
412
+ D.value = !1;
413
413
  }
414
414
  S({
415
415
  open: Q,
416
416
  close: q
417
417
  });
418
418
  async function ee() {
419
- a.value = !0;
419
+ l.value = !0;
420
420
  try {
421
- const e = await O.getLastNClosings(30);
422
- F.value = e;
421
+ const e = await T.getLastNClosings(30);
422
+ $.value = e;
423
423
  } catch (e) {
424
- console.error("Error fetching recent closings:", e), V.open({
424
+ console.error("Error fetching recent closings:", e), k.open({
425
425
  title: t("common.error"),
426
426
  message: "Failed to fetch recent closings",
427
427
  type: "error"
428
428
  });
429
429
  } finally {
430
- a.value = !1;
430
+ l.value = !1;
431
431
  }
432
432
  }
433
- async function H() {
433
+ async function W() {
434
434
  try {
435
- const e = await O.getLastNStockSnapshots(30);
436
- v.value = e;
435
+ const e = await T.getLastNStockSnapshots(30);
436
+ U.value = e;
437
437
  } catch (e) {
438
438
  console.error("Error fetching recent snapshots:", e);
439
439
  }
440
440
  }
441
- async function j() {
442
- A.value = !0;
441
+ async function Y() {
442
+ C.value = !0;
443
443
  try {
444
444
  const e = await L.recalculation.recalculationRequests();
445
- k.value = e;
445
+ s.value = e;
446
446
  } catch (e) {
447
447
  console.error("Error fetching recalculation requests:", e);
448
448
  } finally {
449
- A.value = !1;
449
+ C.value = !1;
450
450
  }
451
451
  }
452
452
  async function te() {
453
- if (!f.value || !m.value) {
453
+ if (!v.value || !f.value) {
454
454
  h.value = [];
455
455
  return;
456
456
  }
457
- x.value = !0;
457
+ F.value = !0;
458
458
  try {
459
- const e = new Date(m.value);
459
+ const e = new Date(f.value);
460
460
  e.setHours(23, 59, 59, 999);
461
- const d = await L.recalculation.getAffectedClosingDrafts(
462
- f.value,
461
+ const u = await L.recalculation.getAffectedClosingDrafts(
462
+ v.value,
463
463
  e.toISOString()
464
464
  );
465
- h.value = d;
465
+ h.value = u;
466
466
  } catch {
467
- V.open({
467
+ k.open({
468
468
  title: t("common.error"),
469
469
  message: "Failed to fetch affected closing drafts",
470
470
  type: "error"
471
471
  }), h.value = [];
472
472
  } finally {
473
- x.value = !1;
473
+ F.value = !1;
474
474
  }
475
475
  }
476
- de(
477
- [f, m],
476
+ ie(
477
+ [v, f],
478
478
  () => {
479
- f.value && m.value && !K.value ? te() : h.value = [];
479
+ v.value && f.value && !z.value ? te() : h.value = [];
480
480
  },
481
481
  { immediate: !1 }
482
482
  );
483
- async function r() {
484
- if (!(!N.value || !m.value)) {
485
- a.value = !0;
483
+ async function d() {
484
+ if (!(!K.value || !f.value)) {
485
+ l.value = !0;
486
486
  try {
487
487
  if (await L.recalculation.scheduleRecalculation({
488
- openingId: f.value,
489
- untilDate: new Date(m.value).toISOString(),
488
+ openingId: v.value,
489
+ untilDate: new Date(f.value).toISOString(),
490
490
  recalculateBySnapshot: !0
491
491
  }), h.value.length > 0) {
492
- const e = h.value.map((d) => d._id);
492
+ const e = h.value.map((u) => u._id);
493
493
  await L.recalculation.scheduleInvalidateClosingDraftCache(e);
494
494
  }
495
- V.open({
495
+ k.open({
496
496
  title: t("common.success"),
497
497
  message: "Stock recalculation has been scheduled successfully",
498
498
  type: "success"
499
- }), await j(), $.value = !1, U("submitted");
499
+ }), await Y(), D.value = !1, M("submitted");
500
500
  } catch (e) {
501
- console.error("Error scheduling recalculation:", e), V.open({
501
+ console.error("Error scheduling recalculation:", e), k.open({
502
502
  title: t("common.error"),
503
503
  message: "Failed to schedule stock recalculation",
504
504
  type: "error"
505
505
  });
506
506
  } finally {
507
- a.value = !1;
507
+ l.value = !1;
508
508
  }
509
509
  }
510
510
  }
511
- return (e, d) => {
512
- const s = w("FmButton"), u = w("FmSelect"), I = w("FmDatePicker"), B = w("FmSnackbar"), oe = w("FmAlert"), c = w("FmDialog");
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
513
  return n(), p("div", null, [
514
- e.showButton ? (n(), M(s, {
514
+ e.showButton ? (n(), H(i, {
515
515
  key: 0,
516
516
  "prepend-icon": "info",
517
517
  variant: "tertiary",
518
518
  onClick: ue(Q, ["stop"])
519
519
  })) : b("", !0),
520
- _(c, {
521
- modelValue: $.value,
522
- "onUpdate:modelValue": d[4] || (d[4] = (y) => $.value = y),
520
+ _(r, {
521
+ modelValue: D.value,
522
+ "onUpdate:modelValue": u[4] || (u[4] = (y) => D.value = y),
523
523
  "close-button": "",
524
524
  dismissAway: "",
525
525
  "max-width": "600px"
526
526
  }, {
527
- "dialog-header": T(() => [
528
- o("div", tt, l(i(t)("inventory.stock.recalculation.title")), 1)
527
+ "dialog-header": I(() => [
528
+ o("div", tt, a(c(t)("inventory.stock.recalculation.title")), 1)
529
529
  ]),
530
- "dialog-footer": T(() => [
530
+ "dialog-footer": I(() => [
531
531
  J.value ? (n(), p("div", Rt, [
532
- _(s, {
532
+ _(i, {
533
533
  variant: "tertiary",
534
- onClick: d[3] || (d[3] = (y) => $.value = !1),
535
- label: i(t)("common.close")
534
+ onClick: u[3] || (u[3] = (y) => D.value = !1),
535
+ label: c(t)("common.close")
536
536
  }, null, 8, ["label"])
537
537
  ])) : (n(), p("div", Ft, [
538
- _(s, {
538
+ _(i, {
539
539
  variant: "tertiary",
540
- onClick: d[2] || (d[2] = (y) => $.value = !1),
541
- disabled: a.value,
542
- label: i(t)("common.cancel")
540
+ onClick: u[2] || (u[2] = (y) => D.value = !1),
541
+ disabled: l.value,
542
+ label: c(t)("common.cancel")
543
543
  }, null, 8, ["disabled", "label"]),
544
- _(s, {
544
+ _(i, {
545
545
  variant: "primary",
546
- onClick: r,
547
- disabled: !N.value || a.value,
548
- loading: a.value,
549
- label: i(t)("inventory.stock.recalculation.schedule")
546
+ onClick: d,
547
+ disabled: !K.value || l.value,
548
+ loading: l.value,
549
+ label: c(t)("inventory.stock.recalculation.schedule")
550
550
  }, null, 8, ["disabled", "loading", "label"])
551
551
  ]))
552
552
  ]),
553
- default: T(() => [
553
+ default: I(() => [
554
554
  o("div", ot, [
555
- o("div", at, l(i(t)("inventory.stock.recalculation.description")), 1),
556
- J.value ? b("", !0) : (n(), p(z, { key: 0 }, [
555
+ o("div", at, a(c(t)("inventory.stock.recalculation.description")), 1),
556
+ J.value ? b("", !0) : (n(), p(G, { key: 0 }, [
557
557
  o("div", lt, [
558
558
  o("p", nt, [
559
- Z(l(i(t)("inventory.stock.recalculation.openingDate")) + " ", 1),
560
- d[5] || (d[5] = o("span", { class: "text-fm-color-system-error-300" }, "*", -1))
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
561
  ]),
562
- d[6] || (d[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
- _(u, {
564
- modelValue: f.value,
565
- "onUpdate:modelValue": d[0] || (d[0] = (y) => f.value = y),
566
- items: W.value,
567
- placeholder: i(t)("inventory.stock.recalculation.selectOpening"),
568
- loading: a.value,
569
- disabled: a.value
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
570
  }, null, 8, ["modelValue", "items", "placeholder", "loading", "disabled"])
571
571
  ]),
572
572
  o("div", st, [
573
573
  o("p", it, [
574
- Z(l(i(t)("inventory.stock.recalculation.untilDate")) + " ", 1),
575
- d[7] || (d[7] = o("span", { class: "text-fm-color-system-error-300" }, "*", -1))
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
576
  ]),
577
- d[8] || (d[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
- _(I, {
579
- modelValue: m.value,
580
- "onUpdate:modelValue": d[1] || (d[1] = (y) => m.value = y),
581
- placeholder: i(t)("inventory.stock.recalculation.selectDate"),
582
- min: G.value,
583
- disabled: !f.value || a.value
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
584
  }, null, 8, ["modelValue", "placeholder", "min", "disabled"]),
585
- K.value ? (n(), p("div", ct, l(K.value), 1)) : b("", !0),
586
- E.value ? (n(), M(B, {
585
+ z.value ? (n(), p("div", ct, a(z.value), 1)) : b("", !0),
586
+ E.value ? (n(), H(B, {
587
587
  key: 1,
588
588
  title: "Warning",
589
589
  variant: "warning",
590
590
  description: "You have selected today or a future date. The stock balance will be refreshed accordingly."
591
591
  })) : b("", !0)
592
592
  ]),
593
- f.value && m.value && !K.value ? (n(), M(oe, {
593
+ v.value && f.value && !z.value ? (n(), H(oe, {
594
594
  key: 0,
595
595
  type: "info"
596
596
  }, {
597
- default: T(() => [
598
- o("div", rt, l(i(t)("inventory.stock.recalculation.info")), 1)
597
+ default: I(() => [
598
+ o("div", rt, a(c(t)("inventory.stock.recalculation.info")), 1)
599
599
  ]),
600
600
  _: 1
601
601
  })) : b("", !0),
602
602
  h.value.length > 0 ? (n(), p("div", dt, [
603
- x.value ? (n(), p("div", ut, " Loading affected closing drafts... ")) : (n(), p("div", mt, [
604
- o("div", ft, " Affected closing draft(s): " + l(h.value.length), 1),
605
- o("div", yt, [
606
- (n(!0), p(z, null, le(h.value, (y) => (n(), p("div", {
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
607
  key: y._id,
608
608
  class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
609
609
  }, [
610
- d[9] || (d[9] = Z(" • ")),
611
- y.closingId && Y.value.get(y.closingId) ? (n(), p("span", pt, l(Y.value.get(y.closingId)), 1)) : (n(), p("span", vt, l(y._id), 1)),
612
- y.effectiveAt ? (n(), p("span", gt, " (" + l(new Date(y.effectiveAt).toLocaleString()) + ") ", 1)) : b("", !0)
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
613
  ]))), 128))
614
614
  ])
615
615
  ]))
616
616
  ])) : b("", !0)
617
617
  ], 64)),
618
- k.value.length > 0 ? (n(), p("div", ht, [
619
- o("p", _t, l(i(t)("inventory.stock.recalculation.recentRequests")), 1),
618
+ s.value.length > 0 ? (n(), p("div", ht, [
619
+ o("p", _t, a(c(t)("inventory.stock.recalculation.recentRequests")), 1),
620
620
  o("div", bt, [
621
- (n(!0), p(z, null, le(k.value, (y) => {
622
- var R;
621
+ (n(!0), p(G, null, le(s.value, (y) => {
622
+ var A;
623
623
  return n(), p("div", {
624
624
  key: y._id,
625
625
  class: "p-12 border border-fm-color-border-primary rounded-8 flex flex-col gap-4"
626
626
  }, [
627
627
  o("div", kt, [
628
- o("div", xt, l(i(t)("inventory.stock.recalculation.requestedAt")) + ": " + l(new Date(y.createdAt).toLocaleString()), 1),
628
+ o("div", xt, a(c(t)("inventory.stock.recalculation.requestedAt")) + ": " + a(new Date(y.createdAt).toLocaleString()), 1),
629
629
  o("div", Dt, [
630
- (R = y.meta) != null && R.openingType ? (n(), p("div", wt, l(y.meta.openingType === "stockSnapshot" ? "Snapshot" : "Closing"), 1)) : b("", !0),
630
+ (A = y.meta) != null && A.openingType ? (n(), p("div", wt, a(y.meta.openingType === "stockSnapshot" ? "Snapshot" : "Closing"), 1)) : b("", !0),
631
631
  o("div", {
632
632
  class: me(["fm-typo-en-body-xs-600 px-8 py-4 rounded-4", {
633
633
  "bg-fm-color-system-error-100 text-fm-color-system-error-500": y.failedReason,
634
634
  "bg-fm-color-system-success-100 text-fm-color-system-success-500": y.completedAt,
635
635
  "bg-fm-color-system-info-100 text-fm-color-system-info-500": !y.failedReason && !y.completedAt
636
636
  }])
637
- }, l(y.failedReason ? i(t)("inventory.stock.recalculation.status.failed") : y.completedAt ? i(t)("inventory.stock.recalculation.status.completed") : i(t)("inventory.stock.recalculation.status.inProgress")), 3)
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
638
  ])
639
639
  ]),
640
- o("div", St, l(i(t)("inventory.stock.recalculation.from")) + ": " + l(new Date(y.recalculateStartDate).toLocaleDateString()), 1),
641
- o("div", Ct, l(i(t)("inventory.stock.recalculation.to")) + ": " + l(new Date(y.recalculateEndDate).toLocaleDateString()), 1),
642
- y.createdBy ? (n(), p("div", Vt, l(i(t)("inventory.stock.recalculation.requestedBy")) + ": " + l(y.createdBy.name || y.createdBy.id), 1)) : b("", !0),
643
- y.completedAt ? (n(), p("div", $t, l(i(t)("inventory.stock.recalculation.completedAt")) + ": " + l(new Date(y.completedAt).toLocaleString()), 1)) : b("", !0),
644
- y.failedReason ? (n(), p("div", At, l(y.failedReason), 1)) : b("", !0)
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
645
  ]);
646
646
  }), 128))
647
647
  ])
@@ -653,7 +653,7 @@ const we = { class: "fm-typo-en-heading-lg-600" }, Se = { class: "flex flex-col
653
653
  ]);
654
654
  };
655
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" }, Pt = { class: "flex flex-col gap-4" }, Ut = { 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({
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
657
  __name: "ClosingDetailDialog",
658
658
  props: {
659
659
  modelValue: { type: Boolean },
@@ -662,38 +662,42 @@ const we = { class: "fm-typo-en-heading-lg-600" }, Se = { class: "flex flex-col
662
662
  },
663
663
  emits: ["update:modelValue"],
664
664
  setup(ae, { emit: S }) {
665
- const { t: C } = se(), U = he(), t = ae, L = S, O = D({
665
+ const { t: V } = se(), M = he(), t = ae, L = S, T = w({
666
666
  get: () => t.modelValue,
667
- set: (v) => L("update:modelValue", v)
668
- }), V = D(() => {
669
- var v;
670
- return ((v = t.data) == null ? void 0 : v.skus) ?? [];
671
- }), $ = D(() => {
672
- var A;
673
- const v = (A = t.data) == null ? void 0 : A._id;
674
- if (!v) return "-";
675
- const a = P(v);
676
- return new Date(a).toLocaleString();
677
- }), f = D(() => t.type === "closing" ? C("inventory.closing.history.closingDetail", "Closing Detail") : C("inventory.closing.history.snapshotDetail", "Snapshot Detail")), m = D(() => V.value.map((v) => {
678
- const a = U.skuById[v.id] ?? null, k = !a;
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;
679
683
  return {
680
- id: v.id,
681
- sku: a,
682
- skuName: (a == null ? void 0 : a.name) ?? v.id,
683
- skuCode: (a == null ? void 0 : a.code) ?? "-",
684
- balance: v.balance ?? { amount: 0, precision: 0 },
685
- isMissing: k,
686
- costs: v.costs,
687
- weightedAverage: v.weightedAverage
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
688
692
  };
689
- })), F = [
693
+ })), U = [
690
694
  {
691
695
  accessorKey: "skuName",
692
- header: () => C("inventory.ingredient.name", "Ingredient Name"),
693
- cell: (v) => {
694
- const a = v.row.original;
695
- return a.isMissing ? X("div", { class: "flex items-center gap-8" }, [
696
- X("span", {}, a.id),
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),
697
701
  X(
698
702
  "span",
699
703
  {
@@ -701,82 +705,88 @@ const we = { class: "fm-typo-en-heading-lg-600" }, Se = { class: "flex flex-col
701
705
  },
702
706
  "Missing"
703
707
  )
704
- ]) : v.getValue();
708
+ ]) : l.getValue();
705
709
  }
706
710
  },
707
711
  {
708
712
  accessorKey: "skuCode",
709
- header: () => C("inventory.ingredient.code", "Code")
713
+ header: () => V("inventory.ingredient.code", "Code")
710
714
  },
711
715
  {
712
716
  id: "balance",
713
- header: () => C("inventory.closing.history.balance", "Balance"),
714
- cell: (v) => {
715
- var A;
716
- const a = v.row.original;
717
- if (a.isMissing || !((A = a.sku) != null && A.unit))
718
- return `${a.balance.amount / Math.pow(10, a.balance.precision)}`;
719
- const k = {
720
- unit: a.sku.unit,
721
- sku: a.sku,
722
- amount: a.balance,
723
- defaultTrackingMeasurement: a.sku.trackingMeasurement ?? void 0
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
724
728
  };
725
- return X(De, k);
729
+ return X(De, C);
726
730
  },
727
731
  size: 180
728
732
  },
729
733
  {
730
734
  accessorKey: "weightedAverage",
731
- header: () => C("inventory.closing.history.weightedAvgCost", "Weighted Avg Cost"),
732
- cell: (v) => {
733
- const a = v.getValue();
734
- if (!a) return "-";
735
- const k = a.amount ?? 0, A = a.precision ?? 0, h = a.currency ?? "", x = k / Math.pow(10, A);
736
- return `${h} ${x.toFixed(2)}`;
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)}`;
737
741
  }
738
742
  }
739
743
  ];
740
- return (v, a) => {
741
- const k = w("FmTable"), A = w("FmButton"), h = w("FmDialog");
742
- return n(), M(h, {
743
- modelValue: O.value,
744
- "onUpdate:modelValue": a[1] || (a[1] = (x) => O.value = x),
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),
745
749
  "close-button": "",
746
750
  dismissAway: "",
747
751
  "max-width": "900px"
748
752
  }, {
749
- "dialog-header": T(() => [
750
- o("div", Tt, l(f.value), 1)
753
+ "dialog-header": I(() => [
754
+ o("div", Tt, a(f.value), 1)
751
755
  ]),
752
- default: T(() => {
753
- var x;
756
+ default: I(() => {
757
+ var O;
754
758
  return [
755
759
  o("div", Bt, [
756
760
  o("div", Lt, [
757
- o("div", Ot, l(t.type === "closing" ? i(C)("inventory.closing.history.closingId") : i(C)("inventory.closing.history.snapshotId", "Snapshot ID")), 1),
758
- o("div", Et, l(((x = t.data) == null ? void 0 : x._id) ?? "-"), 1)
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)
759
763
  ]),
760
- o("div", Pt, [
761
- o("div", Ut, l(i(C)("inventory.closing.history.date")), 1),
762
- o("div", Nt, l($.value), 1)
764
+ o("div", Ut, [
765
+ o("div", Pt, a(c(V)("inventory.closing.history.date")), 1),
766
+ o("div", Nt, a(v.value), 1)
763
767
  ]),
764
768
  o("div", Mt, [
765
- o("div", Kt, l(i(C)("inventory.closing.history.ingredientBalances", "Ingredient Balances")) + " (" + l(V.value.length) + ") ", 1),
766
- _(k, {
767
- "row-data": m.value,
768
- "column-defs": F,
769
- pagination: { pageSize: 10 }
770
- }, null, 8, ["row-data"])
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"])
771
781
  ])
772
782
  ])
773
783
  ];
774
784
  }),
775
- "dialog-footer": T(() => [
785
+ "dialog-footer": I(() => [
776
786
  o("div", Ht, [
777
- _(A, {
787
+ _(F, {
778
788
  variant: "tertiary",
779
- onClick: a[0] || (a[0] = (x) => O.value = !1),
789
+ onClick: s[1] || (s[1] = (O) => T.value = !1),
780
790
  label: "Close"
781
791
  })
782
792
  ])
@@ -788,13 +798,13 @@ const we = { class: "fm-typo-en-heading-lg-600" }, Se = { class: "flex flex-col
788
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({
789
799
  __name: "ClosingHistoryView",
790
800
  setup(ae) {
791
- var e, d;
792
- const { t: S } = se(), C = ie(), U = _e(), t = ge(), L = ke(), O = ce(), V = g("closings"), $ = [
801
+ var e, u;
802
+ const { t: S } = se(), V = ce(), M = _e(), t = ge(), L = ke(), T = re(), k = g("closings"), D = [
793
803
  { label: "Closings", value: "closings" },
794
804
  { label: "Snapshots", value: "snapshots" }
795
- ], f = g([]), m = g(!1), F = g([]), v = g(!1), a = g(!1), k = g("closing"), A = g(null), h = new Date(Date.now() - 864e5), x = g(h.toISOString().split("T")[0]), W = D(() => {
796
- const s = [];
797
- return V.value === "closings" ? s.push(
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(
798
808
  {
799
809
  label: S("inventory.stock.recalculation.title"),
800
810
  value: "recalculation",
@@ -812,7 +822,7 @@ const we = { class: "fm-typo-en-heading-lg-600" }, Se = { class: "flex flex-col
812
822
  value: "refreshOpening",
813
823
  prependIcon: "refresh"
814
824
  }
815
- ) : s.push(
825
+ ) : i.push(
816
826
  {
817
827
  label: `${S("inventory.stock.recalculation.title")} (BETA)`,
818
828
  value: "recalculation",
@@ -830,13 +840,13 @@ const we = { class: "fm-typo-en-heading-lg-600" }, Se = { class: "flex flex-col
830
840
  value: "refreshStockSnapshot",
831
841
  prependIcon: "refresh"
832
842
  }
833
- ), s;
834
- }), Y = g(), G = g();
835
- function K(s) {
836
- var u, I;
837
- switch (s) {
843
+ ), i;
844
+ }), O = g(), j = g();
845
+ function z(i) {
846
+ var m, R;
847
+ switch (i) {
838
848
  case "recalculation":
839
- return V.value === "closings" ? (u = Y.value) == null ? void 0 : u.open() : (I = G.value) == null ? void 0 : I.open();
849
+ return k.value === "closings" ? (m = O.value) == null ? void 0 : m.open() : (R = j.value) == null ? void 0 : R.open();
840
850
  case "initiateOpening": {
841
851
  L.open({
842
852
  title: "Initiate Opening Balance",
@@ -844,12 +854,12 @@ const we = { class: "fm-typo-en-heading-lg-600" }, Se = { class: "flex flex-col
844
854
  primaryActions: { text: "Confirm", close: !0 }
845
855
  }).onPrimary(async () => {
846
856
  try {
847
- await C.initiateClosing(), O.open({
857
+ await V.initiateClosing(), T.open({
848
858
  message: "Opening balance initiated successfully.",
849
859
  type: "success"
850
- }), await H();
860
+ }), await W();
851
861
  } catch (B) {
852
- O.open({
862
+ T.open({
853
863
  message: B.message || "Failed to initiate opening balance. Please try again.",
854
864
  type: "error"
855
865
  });
@@ -859,228 +869,228 @@ const we = { class: "fm-typo-en-heading-lg-600" }, Se = { class: "flex flex-col
859
869
  }
860
870
  case "initiateStockSnapshot": {
861
871
  const B = new Date(Date.now() - 864e5);
862
- x.value = B.toISOString().split("T")[0], E.value = !0;
872
+ F.value = B.toISOString().split("T")[0], E.value = !0;
863
873
  break;
864
874
  }
865
875
  case "refreshOpening": {
866
- H();
876
+ W();
867
877
  break;
868
878
  }
869
879
  case "refreshStockSnapshot": {
870
- j();
880
+ Y();
871
881
  break;
872
882
  }
873
883
  }
874
884
  }
875
- const E = g(!1), N = g(!1), J = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
885
+ const E = g(!1), K = g(!1), J = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
876
886
  async function Q() {
877
- N.value = !0;
887
+ K.value = !0;
878
888
  try {
879
- const s = new Date(x.value).toISOString();
880
- await C.initiateStockSnapshot(s), O.open({
889
+ const i = new Date(F.value).toISOString();
890
+ await V.initiateStockSnapshot(i), T.open({
881
891
  message: "Stock snapshot created successfully.",
882
892
  type: "success"
883
- }), E.value = !1, await j();
884
- } catch (s) {
885
- O.open({
886
- message: s.message || "Failed to create stock snapshot. Please try again.",
893
+ }), E.value = !1, await Y();
894
+ } catch (i) {
895
+ T.open({
896
+ message: i.message || "Failed to create stock snapshot. Please try again.",
887
897
  type: "error"
888
898
  });
889
899
  } finally {
890
- N.value = !1;
900
+ K.value = !1;
891
901
  }
892
902
  }
893
903
  const q = [
894
904
  ...(e = t.sessionUser.value) != null && e.role.isAdmin ? [
895
905
  {
896
906
  accessorKey: "_id",
897
- header: () => X(re, {}, () => `${S("inventory.closing.history.closingId")}`),
898
- cell: (s) => s.getValue()
907
+ header: () => X(de, {}, () => `${S("inventory.closing.history.closingId")}`),
908
+ cell: (i) => i.getValue()
899
909
  }
900
910
  ] : [],
901
911
  {
902
912
  accessorKey: "_id",
903
913
  id: "date",
904
914
  header: () => S("inventory.closing.history.date"),
905
- cell: (s) => {
906
- const u = s.getValue(), I = P(u);
907
- return new Date(I).toLocaleDateString();
915
+ cell: (i) => {
916
+ const m = i.getValue(), R = P(m);
917
+ return new Date(R).toLocaleDateString();
908
918
  }
909
919
  },
910
920
  {
911
921
  accessorKey: "_id",
912
922
  id: "time",
913
923
  header: () => S("inventory.closing.history.time"),
914
- cell: (s) => {
915
- const u = s.getValue(), I = P(u);
916
- return new Date(I).toLocaleTimeString();
924
+ cell: (i) => {
925
+ const m = i.getValue(), R = P(m);
926
+ return new Date(R).toLocaleTimeString();
917
927
  }
918
928
  },
919
929
  {
920
930
  accessorKey: "ref",
921
931
  header: () => S("inventory.closing.history.createdFrom"),
922
- cell: (s) => s.getValue() || "-"
932
+ cell: (i) => i.getValue() || "-"
923
933
  }
924
934
  ], ee = [
925
- ...(d = t.sessionUser.value) != null && d.role.isAdmin ? [
935
+ ...(u = t.sessionUser.value) != null && u.role.isAdmin ? [
926
936
  {
927
937
  accessorKey: "_id",
928
938
  header: () => X(
929
- re,
939
+ de,
930
940
  {},
931
941
  () => `${S("inventory.closing.history.snapshotId", "Snapshot ID")}`
932
942
  ),
933
- cell: (s) => s.getValue()
943
+ cell: (i) => i.getValue()
934
944
  }
935
945
  ] : [],
936
946
  {
937
947
  accessorKey: "_id",
938
948
  id: "date",
939
949
  header: () => S("inventory.closing.history.date"),
940
- cell: (s) => {
941
- const u = s.getValue(), I = P(u);
942
- return new Date(I).toLocaleDateString();
950
+ cell: (i) => {
951
+ const m = i.getValue(), R = P(m);
952
+ return new Date(R).toLocaleDateString();
943
953
  }
944
954
  },
945
955
  {
946
956
  accessorKey: "_id",
947
957
  id: "time",
948
958
  header: () => S("inventory.closing.history.time"),
949
- cell: (s) => {
950
- const u = s.getValue(), I = P(u);
951
- return new Date(I).toLocaleTimeString();
959
+ cell: (i) => {
960
+ const m = i.getValue(), R = P(m);
961
+ return new Date(R).toLocaleTimeString();
952
962
  }
953
963
  },
954
964
  {
955
965
  accessorKey: "remark",
956
966
  header: () => S("inventory.closing.history.createdFrom"),
957
- cell: (s) => s.getValue() || "-"
967
+ cell: (i) => i.getValue() || "-"
958
968
  }
959
969
  ];
960
- async function H() {
961
- if (U.currentLocationDBName) {
962
- m.value = !0;
970
+ async function W() {
971
+ if (M.currentLocationDBName) {
972
+ f.value = !0;
963
973
  try {
964
- const s = await C.getLastNClosings(30);
965
- f.value = s;
966
- } catch (s) {
967
- console.error("Error fetching closings:", s), f.value = [];
974
+ const i = await V.getLastNClosings(30);
975
+ v.value = i;
976
+ } catch (i) {
977
+ console.error("Error fetching closings:", i), v.value = [];
968
978
  } finally {
969
- m.value = !1;
979
+ f.value = !1;
970
980
  }
971
981
  }
972
982
  }
973
- async function j() {
974
- if (U.currentLocationDBName) {
975
- v.value = !0;
983
+ async function Y() {
984
+ if (M.currentLocationDBName) {
985
+ U.value = !0;
976
986
  try {
977
- const s = await C.getLastNStockSnapshots(30);
978
- F.value = s;
979
- } catch (s) {
980
- console.error("Error fetching stock snapshots:", s), F.value = [];
987
+ const i = await V.getLastNStockSnapshots(30);
988
+ $.value = i;
989
+ } catch (i) {
990
+ console.error("Error fetching stock snapshots:", i), $.value = [];
981
991
  } finally {
982
- v.value = !1;
992
+ U.value = !1;
983
993
  }
984
994
  }
985
995
  }
986
- function te(s) {
987
- k.value = "closing", A.value = s, a.value = !0;
996
+ function te(i) {
997
+ s.value = "closing", C.value = i, l.value = !0;
988
998
  }
989
- function r(s) {
990
- k.value = "snapshot", A.value = s, a.value = !0;
999
+ function d(i) {
1000
+ s.value = "snapshot", C.value = i, l.value = !0;
991
1001
  }
992
- return U.watchLocation(async () => {
993
- U.currentLocationDBName && (await H(), await j());
994
- }), (s, u) => {
995
- const I = w("FmTabs"), B = w("FmTable"), oe = w("FmDatePicker"), c = w("FmButton"), y = w("FmDialog");
996
- return n(), M(ve, {
997
- actions: W.value,
998
- title: i(S)("inventory.closing.history.title"),
999
- "onClick:action": K
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
1000
1010
  }, {
1001
- default: T(() => [
1011
+ default: I(() => [
1002
1012
  o("div", zt, [
1003
1013
  _(be, {
1004
1014
  "change-location": "",
1005
1015
  "hide-filter-options": !0
1006
1016
  }),
1007
- _(I, {
1008
- "model-value": V.value,
1009
- "onUpdate:modelValue": u[0] || (u[0] = (R) => V.value = R),
1010
- items: $
1017
+ _(R, {
1018
+ "model-value": k.value,
1019
+ "onUpdate:modelValue": m[0] || (m[0] = (A) => k.value = A),
1020
+ items: D
1011
1021
  }, null, 8, ["model-value"]),
1012
- V.value === "closings" ? (n(), p(z, { key: 0 }, [
1013
- u[9] || (u[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)),
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)),
1014
1024
  _(B, {
1015
- loading: m.value,
1016
- "row-data": f.value,
1025
+ loading: f.value,
1026
+ "row-data": v.value,
1017
1027
  "column-defs": q,
1018
- onRowClick: u[1] || (u[1] = (R) => te(R.original))
1028
+ onRowClick: m[1] || (m[1] = (A) => te(A.original))
1019
1029
  }, null, 8, ["loading", "row-data"])
1020
1030
  ], 64)) : b("", !0),
1021
- V.value === "snapshots" ? (n(), p(z, { key: 1 }, [
1022
- u[10] || (u[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)),
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)),
1023
1033
  _(B, {
1024
- loading: v.value,
1025
- "row-data": F.value,
1034
+ loading: U.value,
1035
+ "row-data": $.value,
1026
1036
  "column-defs": ee,
1027
- onRowClick: u[2] || (u[2] = (R) => r(R.original))
1037
+ onRowClick: m[2] || (m[2] = (A) => d(A.original))
1028
1038
  }, null, 8, ["loading", "row-data"])
1029
1039
  ], 64)) : b("", !0)
1030
1040
  ]),
1031
- (n(), M(pe, { to: "body" }, [
1041
+ (n(), H(ye, { to: "body" }, [
1032
1042
  _(et, {
1033
1043
  "show-button": !1,
1034
1044
  ref_key: "recalculationDialogRef",
1035
- ref: Y,
1036
- onSubmitted: u[3] || (u[3] = (R) => H())
1045
+ ref: O,
1046
+ onSubmitted: m[3] || (m[3] = (A) => W())
1037
1047
  }, null, 512),
1038
1048
  _(It, {
1039
1049
  "show-button": !1,
1040
1050
  ref_key: "snapshotRecalculationDialogRef",
1041
- ref: G,
1042
- onSubmitted: u[4] || (u[4] = (R) => j())
1051
+ ref: j,
1052
+ onSubmitted: m[4] || (m[4] = (A) => Y())
1043
1053
  }, null, 512),
1044
1054
  _(jt, {
1045
- modelValue: a.value,
1046
- "onUpdate:modelValue": u[5] || (u[5] = (R) => a.value = R),
1047
- type: k.value,
1048
- data: A.value
1055
+ modelValue: l.value,
1056
+ "onUpdate:modelValue": m[5] || (m[5] = (A) => l.value = A),
1057
+ type: s.value,
1058
+ data: C.value
1049
1059
  }, null, 8, ["modelValue", "type", "data"]),
1050
1060
  _(y, {
1051
1061
  modelValue: E.value,
1052
- "onUpdate:modelValue": u[8] || (u[8] = (R) => E.value = R),
1062
+ "onUpdate:modelValue": m[8] || (m[8] = (A) => E.value = A),
1053
1063
  "close-button": "",
1054
1064
  dismissAway: "",
1055
1065
  "max-width": "400px"
1056
1066
  }, {
1057
- "dialog-header": T(() => u[11] || (u[11] = [
1067
+ "dialog-header": I(() => m[11] || (m[11] = [
1058
1068
  o("div", { class: "fm-typo-en-heading-lg-600" }, "Initiate Stock Snapshot", -1)
1059
1069
  ])),
1060
- default: T(() => [
1070
+ default: I(() => [
1061
1071
  o("div", Wt, [
1062
- u[12] || (u[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)),
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)),
1063
1073
  _(oe, {
1064
- modelValue: x.value,
1065
- "onUpdate:modelValue": u[6] || (u[6] = (R) => x.value = R),
1074
+ modelValue: F.value,
1075
+ "onUpdate:modelValue": m[6] || (m[6] = (A) => F.value = A),
1066
1076
  label: "Snapshot Date",
1067
- max: i(J)
1077
+ max: c(J)
1068
1078
  }, null, 8, ["modelValue", "max"])
1069
1079
  ])
1070
1080
  ]),
1071
- "dialog-footer": T(() => [
1081
+ "dialog-footer": I(() => [
1072
1082
  o("div", Yt, [
1073
- _(c, {
1083
+ _(r, {
1074
1084
  variant: "tertiary",
1075
- onClick: u[7] || (u[7] = (R) => E.value = !1),
1085
+ onClick: m[7] || (m[7] = (A) => E.value = !1),
1076
1086
  label: "Cancel",
1077
- disabled: N.value
1087
+ disabled: K.value
1078
1088
  }, null, 8, ["disabled"]),
1079
- _(c, {
1089
+ _(r, {
1080
1090
  variant: "primary",
1081
1091
  onClick: Q,
1082
1092
  label: "Confirm",
1083
- loading: N.value
1093
+ loading: K.value
1084
1094
  }, null, 8, ["loading"])
1085
1095
  ])
1086
1096
  ]),