@feedmepos/mf-inventory-portal 1.7.13 → 1.7.15-dev.0

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 (108) hide show
  1. package/dist/{App-tk0n6XzL.js → App-aeh6OigH.js} +471 -460
  2. package/dist/{ApprovalView-CdnT8CZe.js → ApprovalView-D9U2VmYa.js} +9 -9
  3. package/dist/{BindingsDialog-LfVK-lwi.js → BindingsDialog-Ddh44o3y.js} +2 -2
  4. package/dist/{BindingsPicker-DtFUIIp6.js → BindingsPicker-CFtdG6ld.js} +2 -2
  5. package/dist/{BindingsTable-SM-qs56h.js → BindingsTable-Dl44JUUS.js} +4 -4
  6. package/dist/{BulkReceiveRequestView-CxO4aceI.js → BulkReceiveRequestView-DzjYw8z3.js} +19 -19
  7. package/dist/{ChangeLocationComponent.vue_vue_type_script_setup_true_lang-B_dcsrft.js → ChangeLocationComponent.vue_vue_type_script_setup_true_lang-Bg8FBGzq.js} +6 -2
  8. package/dist/{ClosingDraftView-Bc9VEqFI.js → ClosingDraftView-D0SGlTkF.js} +19 -19
  9. package/dist/ClosingHistoryView-BKfhpOEw.js +761 -0
  10. package/dist/{ClosingTemplateView-Cf6BkJ1p.js → ClosingTemplateView-Ikq2OM4z.js} +16 -16
  11. package/dist/{CustomPrintTemplatePreview.vue_vue_type_script_setup_true_lang-LtI-0ag-.js → CustomPrintTemplatePreview.vue_vue_type_script_setup_true_lang-BhTM2C3K.js} +1 -1
  12. package/dist/{DefaultView-zeN-SUL7.js → DefaultView-ClKfklyX.js} +2 -2
  13. package/dist/{DeliveryOrderPrintPreview-CPdBGfWd.js → DeliveryOrderPrintPreview-Cfz_N8Bf.js} +2 -2
  14. package/dist/{EmailDialog.vue_vue_type_script_setup_true_lang-CttfIuEb.js → EmailDialog.vue_vue_type_script_setup_true_lang-C-GPckzY.js} +23 -23
  15. package/dist/{FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-GYKs_eVT.js → FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-BxkzheM9.js} +1 -1
  16. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-BlHeW9tQ.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CoFcZ-Zv.js} +2 -2
  17. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-CSlAWGWz.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BAEpf31G.js} +2 -2
  18. package/dist/FmLockableField.vue_vue_type_script_setup_true_lang-FCg4K7y8.js +89 -0
  19. package/dist/{FmMultiselectDialog-DtvRQc96.js → FmMultiselectDialog-CiOdsRlf.js} +1 -1
  20. package/dist/{FmMultiselectDialog-gEkSoyOo.js → FmMultiselectDialog-Dr8wRNW7.js} +2 -2
  21. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-DEdVxDAl.js → FmUnitInput.vue_vue_type_script_setup_true_lang-D-Ycop6K.js} +6 -6
  22. package/dist/{ImportView-DvLVmruj.js → ImportView-BBqak01n.js} +6 -6
  23. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-C0eXC_7P.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-CAJDLjrN.js} +1 -1
  24. package/dist/{IngredientGroupView-4nVKjTVO.js → IngredientGroupView-CghsReO0.js} +5 -5
  25. package/dist/IngredientsView-DLxTWo-n.js +2239 -0
  26. package/dist/{IntegrationExplorerView-3wJ_2jLQ.js → IntegrationExplorerView-C05R8EzL.js} +4 -4
  27. package/dist/IntegrationView-DpN7PYPc.js +7623 -0
  28. package/dist/{InventoryBindingForm-BdbHMLKN.js → InventoryBindingForm-CnHzZu12.js} +1 -1
  29. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-mJ0hwtVM.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-Cls49Zgb.js} +5 -5
  30. package/dist/{InventoryBindingSummary-BKkBvlxM.js → InventoryBindingSummary-DK5Z9AKC.js} +1 -1
  31. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-8kEGeYvD.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-FsxbejSt.js} +1 -1
  32. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-BVX6226m.js → PremiumBadge.vue_vue_type_script_setup_true_lang-DvIbqRH9.js} +1 -1
  33. package/dist/{ProductionView-B4nPZTt9.js → ProductionView-DeUmELdm.js} +7 -7
  34. package/dist/{PublishView-do0VvwHk.js → PublishView-CGHFmmCG.js} +3 -3
  35. package/dist/{PurchaseOrderPrintPreview-VEJxKJZA.js → PurchaseOrderPrintPreview-xyXZU3oQ.js} +2 -2
  36. package/dist/{ReceiveRequestView-ycnbtRQp.js → ReceiveRequestView-CVmAUuqN.js} +14 -14
  37. package/dist/{RecipeView-Ce4AgrHT.js → RecipeView-BSd1V9En.js} +17 -17
  38. package/dist/{SettingsView-Bjx1z2gc.js → SettingsView-AI-JaGxh.js} +4 -4
  39. package/dist/{StockView-DqOEaJzz.js → StockView-CRrYes0h.js} +21 -21
  40. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-DDT4AqtX.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-DNXdZVOA.js} +1 -1
  41. package/dist/{SupplierView-C07LyK32.js → SupplierView-BMupiPVi.js} +1156 -1035
  42. package/dist/{SurchargeView-BKapiG5x.js → SurchargeView-77KsLF2T.js} +6 -6
  43. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-BKE4I1gG.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-Brw98Ihw.js} +2 -2
  44. package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-XCYRCjQy.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-Cjt4YAII.js} +1 -1
  45. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-BHeqFlka.js +4797 -0
  46. package/dist/{TransferTemplateView-r1gRvF7q.js → TransferTemplateView-BMF1_tLd.js} +20 -20
  47. package/dist/{UnitCostHistoryView-BzF5Ydfg.js → UnitCostHistoryView-Gp8uWjMQ.js} +4 -4
  48. package/dist/{UnitDisplayControl.vue_vue_type_script_setup_true_lang-D3Qc1b_g.js → UnitDisplayControl.vue_vue_type_script_setup_true_lang-mwAMQ0B3.js} +4 -4
  49. package/dist/{UnitView-CIus7XDF.js → UnitView-Cuk5oaOf.js} +7 -7
  50. package/dist/{WarehouseView-D0LAGPr6.js → WarehouseView-Bat0looR.js} +6 -6
  51. package/dist/{WastageTemplateView-CX_vY8lT.js → WastageTemplateView-Coag2jbG.js} +14 -14
  52. package/dist/api/netsuite.d.ts +2 -0
  53. package/dist/api/stock.d.ts +0 -6
  54. package/dist/{app-BFI89qx8.js → app-C3gNrduY.js} +464 -439
  55. package/dist/app.d.ts +32 -12
  56. package/dist/app.js +1 -1
  57. package/dist/{closing-template-BsT8mozh.js → closing-template-DKklbhBW.js} +1 -1
  58. package/dist/cypress/component/ChangelogPanel.cy.d.ts +1 -0
  59. package/dist/cypress/support/component.d.ts +1 -2
  60. package/dist/{date2-DRguSPlT.js → date2-Cx-YVc4N.js} +1 -1
  61. package/dist/{dayjs.min-CQchvANX.js → dayjs.min-Cj2Eh8Tj.js} +1 -1
  62. package/dist/{decimal-XTxcAfEO.js → decimal-OxPQV_Pd.js} +2 -2
  63. package/dist/{defineDeepModel-BRoQ53kt.js → defineDeepModel-Dud4PiVz.js} +1 -1
  64. package/dist/{duplicate-template-CjRLJUuX.js → duplicate-template-XAhspiYs.js} +1 -1
  65. package/dist/{feature-4NFlAslj.js → feature-gYL54g_K.js} +2 -2
  66. package/dist/{format-time-from-id-HjX4Uw5t.js → format-time-from-id-T7WHy_x1.js} +1 -1
  67. package/dist/{format-unit-display-Bv64TEgM.js → format-unit-display-BsjRSrAe.js} +12 -12
  68. package/dist/{import-export.helper-5GAs3g-u.js → import-export.helper-CEdt0BWR.js} +6 -6
  69. package/dist/{index-wBonClcq.js → index-BZynONs2.js} +3 -3
  70. package/dist/{index-DT7aF_IJ.js → index-CBcKeIhg.js} +1 -1
  71. package/dist/{index-Cy99iIzT.js → index-DQKbOIoT.js} +1 -1
  72. package/dist/{inventory-core-dart.default-aPOgM_iG.js → inventory-core-dart.default-D4zV0IQQ.js} +1428 -1322
  73. package/dist/{lz-string-D4H5yiwN.js → lz-string-BtyfM17N.js} +1 -1
  74. package/dist/{netsuite-CA6GsSZX.js → netsuite-BEW5HsxM.js} +477 -462
  75. package/dist/{number-wdTGPqVx.js → number-CQBgN-M7.js} +3 -3
  76. package/dist/{predefined-templates-5gDm-KTC.js → predefined-templates-CpP9HOqv.js} +1 -1
  77. package/dist/{purchase-order-template-NYXXge2I.js → purchase-order-template-PekDPb4u.js} +1 -1
  78. package/dist/{recalculationUtils-BYxkQ6y9.js → recalculationUtils-lfhKnVFx.js} +1 -1
  79. package/dist/{rules-CTPrTWcQ.js → rules-5x2UEFmU.js} +2 -2
  80. package/dist/{stock-B5SFlbu5.js → stock-Ch5c3jO9.js} +3 -3
  81. package/dist/{stock-BN60-dxD.js → stock-DqIRhhsu.js} +26 -36
  82. package/dist/stores/integration/netsuite.d.ts +54 -0
  83. package/dist/{supplier-qENTmxSk.js → supplier-DVxdFpgr.js} +2 -2
  84. package/dist/{surcharge-DqHTzQ4D.js → surcharge-CNGep-bs.js} +1 -1
  85. package/dist/tsconfig.app.tsbuildinfo +1 -1
  86. package/dist/{uom-rules-BQ2wBmPD.js → uom-rules-RPvKxFQI.js} +1 -1
  87. package/dist/{use-ingredient-select-dialog-DCLCw51r.js → use-ingredient-select-dialog-CPdwTQrN.js} +2 -2
  88. package/dist/{use-inventory-binding-dialog-BsbXZl-i.js → use-inventory-binding-dialog-CeyqcDPW.js} +2 -2
  89. package/dist/{use-template-enabled-locations-aNl_4Yzk.js → use-template-enabled-locations-DJ46fm8w.js} +2 -2
  90. package/dist/{use-transfer-locations-ChEibX9h.js → use-transfer-locations-DBIAb9MY.js} +2 -2
  91. package/dist/{useHrmPermission-DgjpLTc8.js → useHrmPermission-BEDY0i29.js} +1 -1
  92. package/dist/{useNavigationMenu-CMFZ-5F-.js → useNavigationMenu-xXANo9uC.js} +2 -2
  93. package/dist/{useSseClient-CT23c0Mu.js → useSseClient-B-dfDpdW.js} +1 -1
  94. package/dist/views/changelog/components/ChangelogFloatingButton.spec.d.ts +1 -0
  95. package/dist/views/changelog/composables/fab-position.d.ts +21 -0
  96. package/dist/views/changelog/composables/use-inventory-record-commits.d.ts +1 -1
  97. package/dist/views/integration/components/netsuite/business/vendor-publish.d.ts +7 -0
  98. package/dist/views/integration/components/netsuite/business/vendor-publish.spec.d.ts +1 -0
  99. package/dist/views/stock/components/dialog/RecalculationDialog.vue.d.ts +2 -17
  100. package/dist/{vue-i18n-Bj6Jb-Dc.js → vue-i18n-D64MVhs-.js} +295 -295
  101. package/dist/{xlsx.util-iqdZHANo.js → xlsx.util-BntGs-ye.js} +2 -2
  102. package/package.json +3 -3
  103. package/dist/ClosingHistoryView-BOjnPKtQ.js +0 -1112
  104. package/dist/IngredientsView-DQsn-GXv.js +0 -2322
  105. package/dist/IntegrationView-DOC5QhaQ.js +0 -7506
  106. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-CbaCIkH6.js +0 -4781
  107. package/dist/views/stock/components/StockRecalculateDialog.vue.d.ts +0 -9
  108. package/dist/views/stock/components/dialog/SnapshotRecalculationDialog.vue.d.ts +0 -24
@@ -1,1112 +0,0 @@
1
- import { defineComponent as se, ref as g, computed as D, watch as re, resolveComponent as w, createElementBlock as p, openBlock as i, createBlock as j, createCommentVNode as _, createVNode as h, withModifiers as pe, withCtx as F, createElementVNode as a, toDisplayString as l, unref as c, Fragment as G, createTextVNode as te, renderList as le, normalizeClass as ve, h as ee, Teleport as be } from "vue";
2
- import { _ as ke } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-DpwneGOV.js";
3
- import { useI18n as ie, useCoreStore as xe } from "@feedmepos/mf-common";
4
- import { G as de, B as P, a as De, u as Se } from "./app-BFI89qx8.js";
5
- import { F as fe } from "./FmAdminBadge-DlplQOHb.js";
6
- import { _ as we } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-CSlAWGWz.js";
7
- import { _ as ye } from "./CursorPaginatedTable.vue_vue_type_script_setup_true_lang-BCUhtL_B.js";
8
- import { useSnackbar as ue, useDialog as Ve } from "@feedmepos/ui-library";
9
- import { u as ge } from "./stock-BN60-dxD.js";
10
- import { g as he, f as $e } from "./recalculationUtils-BYxkQ6y9.js";
11
- import { _ as Ce } from "./UnitDisplayControl.vue_vue_type_script_setup_true_lang-D3Qc1b_g.js";
12
- const Ae = { class: "fm-typo-en-heading-lg-600" }, Fe = { class: "flex flex-col gap-16" }, Re = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Be = { class: "flex flex-col gap-8" }, Ie = { class: "fm-typo-en-body-md-600" }, Te = { class: "flex flex-col gap-8" }, Le = { class: "fm-typo-en-body-md-600" }, Oe = { class: "flex items-center gap-8 mb-8" }, Pe = {
13
- key: 2,
14
- class: "text-red-500 text-sm mt-2"
15
- }, Ue = { class: "fm-typo-en-body-sm-400" }, Ee = {
16
- key: 1,
17
- class: "p-12 border border-fm-color-border-primary rounded-8 bg-fm-color-background-secondary"
18
- }, Ne = {
19
- key: 0,
20
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
21
- }, Me = {
22
- key: 1,
23
- class: "flex flex-col gap-8"
24
- }, Ke = { class: "fm-typo-en-body-sm-600" }, He = { class: "flex flex-col gap-4" }, je = { key: 0 }, ze = {
25
- key: 1,
26
- class: "flex flex-col gap-8"
27
- }, We = { class: "fm-typo-en-body-md-600" }, Ye = { class: "flex flex-col gap-8 max-h-[300px] overflow-y-auto" }, Ge = { class: "flex items-center justify-between" }, Je = { class: "fm-typo-en-body-sm-600" }, Qe = { class: "flex items-center gap-8" }, Xe = {
28
- key: 0,
29
- class: "fm-typo-en-body-xs-600 px-8 py-4 rounded-4 bg-fm-color-neutral-100 text-fm-color-typo-secondary"
30
- }, Ze = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, qe = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, et = {
31
- key: 0,
32
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
33
- }, tt = {
34
- key: 1,
35
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
36
- }, ot = {
37
- key: 2,
38
- class: "fm-typo-en-body-xs-400 text-fm-color-system-error-500"
39
- }, at = {
40
- key: 0,
41
- class: "flex gap-8 ml-auto"
42
- }, nt = {
43
- key: 1,
44
- class: "flex gap-8 ml-auto"
45
- }, lt = /* @__PURE__ */ se({
46
- __name: "RecalculationDialog",
47
- props: {
48
- showButton: { type: Boolean }
49
- },
50
- emits: ["submitted"],
51
- setup(ne, { expose: b, emit: k }) {
52
- const T = k, { t: o } = ie(), L = ge(), R = de(), x = ue(), S = g(!1), f = g(""), y = g(""), $ = g(!1), U = g([]), s = g(!1), r = g([]), C = g(!1), v = g([]), A = g(!1), B = D(() => he(U.value)), I = D(() => {
53
- if (!f.value) return [];
54
- const u = B.value.find((e) => e.value === f.value);
55
- return u ? B.value.filter((e) => e.date.getTime() > u.date.getTime()).sort((e, m) => m.date.getTime() - e.date.getTime()) : [];
56
- }), N = D({
57
- get: () => {
58
- if ($.value && y.value) {
59
- const u = U.value.find((e) => P(e._id) === y.value);
60
- return (u == null ? void 0 : u._id) || y.value;
61
- }
62
- return y.value;
63
- },
64
- set: (u) => {
65
- $.value && u ? y.value = P(u) : y.value = u;
66
- }
67
- }), z = D(() => {
68
- if (f.value)
69
- try {
70
- const u = P(f.value);
71
- if (u)
72
- return u;
73
- } catch (u) {
74
- console.error("Error parsing date from closing ID:", u);
75
- }
76
- }), E = D(() => {
77
- if (!f.value || !y.value) return "";
78
- const u = P(f.value), e = y.value;
79
- if (u && e) {
80
- const m = new Date(u).getTime();
81
- if (new Date(e).getTime() <= m)
82
- return o("inventory.stock.recalculation.error.endDateBeforeOpening");
83
- }
84
- return "";
85
- }), M = D(() => !!f.value && !!y.value && !E.value), J = D(() => r.value.some(
86
- (u) => !u.completedAt && !u.failedReason
87
- ));
88
- async function Y() {
89
- S.value = !0, await Promise.all([oe(), K()]), f.value = "", y.value = "", $.value = !1;
90
- }
91
- function Q() {
92
- S.value = !1;
93
- }
94
- b({
95
- open: Y,
96
- close: Q
97
- });
98
- async function oe() {
99
- s.value = !0;
100
- try {
101
- const u = await R.getLastNClosings(30);
102
- U.value = u;
103
- } catch (u) {
104
- console.error("Error fetching recent closings:", u), x.open({
105
- title: o("common.error"),
106
- message: "Failed to fetch recent closings",
107
- type: "error"
108
- });
109
- } finally {
110
- s.value = !1;
111
- }
112
- }
113
- async function K() {
114
- C.value = !0;
115
- try {
116
- const u = await L.recalculation.recalculationRequests();
117
- r.value = u;
118
- } catch (u) {
119
- console.error("Error fetching recalculation requests:", u);
120
- } finally {
121
- C.value = !1;
122
- }
123
- }
124
- async function W() {
125
- if (!f.value || !y.value) {
126
- v.value = [];
127
- return;
128
- }
129
- A.value = !0;
130
- try {
131
- const u = await L.recalculation.getAffectedClosingDrafts(
132
- f.value,
133
- y.value
134
- );
135
- v.value = u;
136
- } catch {
137
- x.open({
138
- title: o("common.error"),
139
- message: "Failed to fetch affected closing drafts",
140
- type: "error"
141
- }), v.value = [];
142
- } finally {
143
- A.value = !1;
144
- }
145
- }
146
- re(
147
- [f, y],
148
- () => {
149
- f.value && y.value && !E.value ? W() : v.value = [];
150
- },
151
- { immediate: !1 }
152
- );
153
- async function ae() {
154
- if (M.value) {
155
- s.value = !0;
156
- try {
157
- if (await L.recalculation.scheduleRecalculation({
158
- openingId: f.value,
159
- untilDate: y.value
160
- }), v.value.length > 0) {
161
- const u = v.value.map((e) => e._id);
162
- await L.recalculation.scheduleInvalidateClosingDraftCache(u);
163
- }
164
- x.open({
165
- title: o("common.success"),
166
- message: "Stock recalculation has been scheduled successfully",
167
- type: "success"
168
- }), await K(), S.value = !1, T("submitted");
169
- } catch (u) {
170
- console.error("Error scheduling recalculation:", u), x.open({
171
- title: o("common.error"),
172
- message: "Failed to schedule stock recalculation",
173
- type: "error"
174
- });
175
- } finally {
176
- s.value = !1;
177
- }
178
- }
179
- }
180
- return (u, e) => {
181
- const m = w("FmButton"), O = w("FmSelect"), X = w("FmRadio"), Z = w("FmDatePicker"), q = w("FmAlert"), d = w("FmDialog");
182
- return i(), p("div", null, [
183
- u.showButton ? (i(), j(m, {
184
- key: 0,
185
- "prepend-icon": "info",
186
- variant: "tertiary",
187
- onClick: pe(Y, ["stop"])
188
- })) : _("", !0),
189
- h(d, {
190
- modelValue: S.value,
191
- "onUpdate:modelValue": e[7] || (e[7] = (t) => S.value = t),
192
- "close-button": "",
193
- dismissAway: "",
194
- "max-width": "600px"
195
- }, {
196
- "dialog-header": F(() => [
197
- a("div", Ae, l(c(o)("inventory.stock.recalculation.title")), 1)
198
- ]),
199
- "dialog-footer": F(() => [
200
- J.value ? (i(), p("div", nt, [
201
- h(m, {
202
- variant: "tertiary",
203
- onClick: e[6] || (e[6] = (t) => S.value = !1),
204
- label: c(o)("common.close")
205
- }, null, 8, ["label"])
206
- ])) : (i(), p("div", at, [
207
- h(m, {
208
- variant: "tertiary",
209
- onClick: e[5] || (e[5] = (t) => S.value = !1),
210
- disabled: s.value,
211
- label: c(o)("common.cancel")
212
- }, null, 8, ["disabled", "label"]),
213
- h(m, {
214
- variant: "primary",
215
- onClick: ae,
216
- disabled: !M.value || s.value,
217
- loading: s.value,
218
- label: c(o)("inventory.stock.recalculation.schedule")
219
- }, null, 8, ["disabled", "loading", "label"])
220
- ]))
221
- ]),
222
- default: F(() => [
223
- a("div", Fe, [
224
- a("div", Re, l(c(o)("inventory.stock.recalculation.description")), 1),
225
- J.value ? _("", !0) : (i(), p(G, { key: 0 }, [
226
- a("div", Be, [
227
- a("p", Ie, [
228
- te(l(c(o)("inventory.stock.recalculation.openingDate")) + " ", 1),
229
- e[8] || (e[8] = a("span", { class: "text-fm-color-system-error-300" }, "*", -1))
230
- ]),
231
- e[9] || (e[9] = a("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)),
232
- h(O, {
233
- modelValue: f.value,
234
- "onUpdate:modelValue": e[0] || (e[0] = (t) => f.value = t),
235
- items: B.value,
236
- placeholder: c(o)("inventory.stock.recalculation.selectOpening"),
237
- loading: s.value,
238
- disabled: s.value
239
- }, null, 8, ["modelValue", "items", "placeholder", "loading", "disabled"])
240
- ]),
241
- a("div", Te, [
242
- a("p", Le, [
243
- te(l(c(o)("inventory.stock.recalculation.untilDate")) + " ", 1),
244
- e[10] || (e[10] = a("span", { class: "text-fm-color-system-error-300" }, "*", -1))
245
- ]),
246
- a("div", Oe, [
247
- h(X, {
248
- modelValue: $.value,
249
- "onUpdate:modelValue": e[1] || (e[1] = (t) => $.value = t),
250
- value: !1,
251
- label: c(o)("inventory.stock.recalculation.selectByDate")
252
- }, null, 8, ["modelValue", "label"]),
253
- h(X, {
254
- modelValue: $.value,
255
- "onUpdate:modelValue": e[2] || (e[2] = (t) => $.value = t),
256
- value: !0,
257
- label: c(o)("inventory.stock.recalculation.selectByClosing")
258
- }, null, 8, ["modelValue", "label"])
259
- ]),
260
- $.value ? (i(), j(O, {
261
- key: 1,
262
- modelValue: N.value,
263
- "onUpdate:modelValue": e[4] || (e[4] = (t) => N.value = t),
264
- items: I.value,
265
- placeholder: c(o)("inventory.stock.recalculation.selectClosing"),
266
- loading: s.value,
267
- disabled: !f.value || s.value
268
- }, null, 8, ["modelValue", "items", "placeholder", "loading", "disabled"])) : (i(), j(Z, {
269
- key: 0,
270
- modelValue: y.value,
271
- "onUpdate:modelValue": e[3] || (e[3] = (t) => y.value = t),
272
- placeholder: c(o)("inventory.stock.recalculation.selectDate"),
273
- min: z.value,
274
- disabled: !f.value || s.value
275
- }, null, 8, ["modelValue", "placeholder", "min", "disabled"])),
276
- E.value ? (i(), p("div", Pe, l(E.value), 1)) : _("", !0)
277
- ]),
278
- f.value && y.value && !E.value ? (i(), j(q, {
279
- key: 0,
280
- type: "info"
281
- }, {
282
- default: F(() => [
283
- a("div", Ue, l(c(o)("inventory.stock.recalculation.info")), 1)
284
- ]),
285
- _: 1
286
- })) : _("", !0),
287
- v.value.length > 0 ? (i(), p("div", Ee, [
288
- A.value ? (i(), p("div", Ne, " Loading affected closing drafts... ")) : (i(), p("div", Me, [
289
- a("div", Ke, " Affected closing draft(s): " + l(v.value.length), 1),
290
- a("div", He, [
291
- (i(!0), p(G, null, le(v.value, (t) => (i(), p("div", {
292
- key: t._id,
293
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
294
- }, [
295
- te(" • " + l(t._id) + " ", 1),
296
- t.effectiveAt ? (i(), p("span", je, " (" + l(new Date(t.effectiveAt).toLocaleString()) + ") ", 1)) : _("", !0)
297
- ]))), 128))
298
- ])
299
- ]))
300
- ])) : _("", !0)
301
- ], 64)),
302
- r.value.length > 0 ? (i(), p("div", ze, [
303
- a("p", We, l(c(o)("inventory.stock.recalculation.recentRequests")), 1),
304
- a("div", Ye, [
305
- (i(!0), p(G, null, le(r.value, (t) => {
306
- var n;
307
- return i(), p("div", {
308
- key: t._id,
309
- class: "p-12 border border-fm-color-border-primary rounded-8 flex flex-col gap-4"
310
- }, [
311
- a("div", Ge, [
312
- a("div", Je, l(c(o)("inventory.stock.recalculation.requestedAt")) + ": " + l(new Date(t.createdAt).toLocaleString()), 1),
313
- a("div", Qe, [
314
- (n = t.meta) != null && n.openingType ? (i(), p("div", Xe, l(t.meta.openingType === "stockSnapshot" ? "Snapshot" : "Closing"), 1)) : _("", !0),
315
- a("div", {
316
- class: ve(["fm-typo-en-body-xs-600 px-8 py-4 rounded-4", {
317
- "bg-fm-color-system-error-100 text-fm-color-system-error-500": t.failedReason,
318
- "bg-fm-color-system-success-100 text-fm-color-system-success-500": t.completedAt,
319
- "bg-fm-color-system-info-100 text-fm-color-system-info-500": !t.failedReason && !t.completedAt
320
- }])
321
- }, l(t.failedReason ? c(o)("inventory.stock.recalculation.status.failed") : t.completedAt ? c(o)("inventory.stock.recalculation.status.completed") : c(o)("inventory.stock.recalculation.status.inProgress")), 3)
322
- ])
323
- ]),
324
- a("div", Ze, l(c(o)("inventory.stock.recalculation.from")) + ": " + l(new Date(t.recalculateStartDate).toLocaleDateString()), 1),
325
- a("div", qe, l(c(o)("inventory.stock.recalculation.to")) + ": " + l(new Date(t.recalculateEndDate).toLocaleDateString()), 1),
326
- t.createdBy ? (i(), p("div", et, l(c(o)("inventory.stock.recalculation.requestedBy")) + ": " + l(t.createdBy.name || t.createdBy.id), 1)) : _("", !0),
327
- t.completedAt ? (i(), p("div", tt, l(c(o)("inventory.stock.recalculation.completedAt")) + ": " + l(new Date(t.completedAt).toLocaleString()), 1)) : _("", !0),
328
- t.failedReason ? (i(), p("div", ot, l(t.failedReason), 1)) : _("", !0)
329
- ]);
330
- }), 128))
331
- ])
332
- ])) : _("", !0)
333
- ])
334
- ]),
335
- _: 1
336
- }, 8, ["modelValue"])
337
- ]);
338
- };
339
- }
340
- }), st = { class: "fm-typo-en-heading-lg-600" }, it = { class: "flex flex-col gap-16" }, ct = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, rt = { class: "flex flex-col gap-8" }, dt = { class: "fm-typo-en-body-md-600" }, ut = { class: "flex flex-col gap-8" }, mt = { class: "fm-typo-en-body-md-600" }, ft = {
341
- key: 0,
342
- class: "text-red-500 text-sm mt-2"
343
- }, yt = { class: "fm-typo-en-body-sm-400" }, pt = {
344
- key: 1,
345
- class: "p-12 border border-fm-color-border-primary rounded-8 bg-fm-color-background-secondary"
346
- }, vt = {
347
- key: 0,
348
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
349
- }, gt = {
350
- key: 1,
351
- class: "flex flex-col gap-8"
352
- }, ht = { class: "fm-typo-en-body-sm-600" }, _t = { class: "flex flex-col gap-4" }, bt = { key: 0 }, kt = { key: 1 }, xt = { key: 2 }, Dt = {
353
- key: 1,
354
- class: "flex flex-col gap-8"
355
- }, St = { class: "fm-typo-en-body-md-600" }, wt = { class: "flex flex-col gap-8 max-h-[300px] overflow-y-auto" }, Vt = { class: "flex items-center justify-between" }, $t = { class: "fm-typo-en-body-sm-600" }, Ct = { class: "flex items-center gap-8" }, At = {
356
- key: 0,
357
- class: "fm-typo-en-body-xs-600 px-8 py-4 rounded-4 bg-fm-color-neutral-100 text-fm-color-typo-secondary"
358
- }, Ft = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Rt = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Bt = {
359
- key: 0,
360
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
361
- }, It = {
362
- key: 1,
363
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
364
- }, Tt = {
365
- key: 2,
366
- class: "fm-typo-en-body-xs-400 text-fm-color-system-error-500"
367
- }, Lt = {
368
- key: 0,
369
- class: "flex gap-8 ml-auto"
370
- }, Ot = {
371
- key: 1,
372
- class: "flex gap-8 ml-auto"
373
- }, Pt = /* @__PURE__ */ se({
374
- __name: "SnapshotRecalculationDialog",
375
- props: {
376
- showButton: { type: Boolean }
377
- },
378
- emits: ["submitted"],
379
- setup(ne, { expose: b, emit: k }) {
380
- const T = k, { t: o } = ie(), L = ge(), R = de(), x = ue(), S = g(!1), f = g(""), y = g(""), $ = g([]), U = g([]), s = g(!1), r = g([]), C = g(!1), v = g([]), A = g(!1), B = D(
381
- () => he($.value, U.value)
382
- ), I = D(() => $e(
383
- v.value.filter((e) => !!e.closingId).map((e) => ({ closingId: e.closingId, draftCreatedAt: new Date(P(e._id)) }))
384
- )), N = D(() => {
385
- if (f.value)
386
- try {
387
- const e = P(f.value);
388
- if (e)
389
- return e;
390
- } catch (e) {
391
- console.error("Error parsing date from opening ID:", e);
392
- }
393
- }), z = D(() => {
394
- if (!f.value || !y.value) return "";
395
- const e = P(f.value);
396
- if (e && y.value) {
397
- const m = new Date(e).getTime();
398
- if (new Date(y.value).getTime() <= m)
399
- return o("inventory.stock.recalculation.error.endDateBeforeOpening");
400
- }
401
- return "";
402
- }), E = D(() => {
403
- if (!y.value) return !1;
404
- const e = new Date(y.value), m = /* @__PURE__ */ new Date();
405
- return m.setHours(0, 0, 0, 0), e.setHours(0, 0, 0, 0), e >= m;
406
- }), M = D(() => !!f.value && !!y.value && !z.value), J = D(() => r.value.some(
407
- (e) => !e.completedAt && !e.failedReason
408
- ));
409
- async function Y() {
410
- S.value = !0, await Promise.all([oe(), K(), W()]), f.value = "", y.value = "";
411
- }
412
- function Q() {
413
- S.value = !1;
414
- }
415
- b({
416
- open: Y,
417
- close: Q
418
- });
419
- async function oe() {
420
- s.value = !0;
421
- try {
422
- const e = await R.getLastNClosings(30);
423
- $.value = e;
424
- } catch (e) {
425
- console.error("Error fetching recent closings:", e), x.open({
426
- title: o("common.error"),
427
- message: "Failed to fetch recent closings",
428
- type: "error"
429
- });
430
- } finally {
431
- s.value = !1;
432
- }
433
- }
434
- async function K() {
435
- try {
436
- const e = await R.getLastNStockSnapshots(30);
437
- U.value = e;
438
- } catch (e) {
439
- console.error("Error fetching recent snapshots:", e);
440
- }
441
- }
442
- async function W() {
443
- C.value = !0;
444
- try {
445
- const e = await L.recalculation.recalculationRequests();
446
- r.value = e;
447
- } catch (e) {
448
- console.error("Error fetching recalculation requests:", e);
449
- } finally {
450
- C.value = !1;
451
- }
452
- }
453
- async function ae() {
454
- if (!f.value || !y.value) {
455
- v.value = [];
456
- return;
457
- }
458
- A.value = !0;
459
- try {
460
- const e = new Date(y.value);
461
- e.setHours(23, 59, 59, 999);
462
- const m = await L.recalculation.getAffectedClosingDrafts(
463
- f.value,
464
- e.toISOString()
465
- );
466
- v.value = m;
467
- } catch {
468
- x.open({
469
- title: o("common.error"),
470
- message: "Failed to fetch affected closing drafts",
471
- type: "error"
472
- }), v.value = [];
473
- } finally {
474
- A.value = !1;
475
- }
476
- }
477
- re(
478
- [f, y],
479
- () => {
480
- f.value && y.value && !z.value ? ae() : v.value = [];
481
- },
482
- { immediate: !1 }
483
- );
484
- async function u() {
485
- if (!(!M.value || !y.value)) {
486
- s.value = !0;
487
- try {
488
- const e = new Date(y.value);
489
- if (e.setHours(23, 59, 59, 999), await L.recalculation.scheduleRecalculation({
490
- openingId: f.value,
491
- untilDate: e.toISOString(),
492
- recalculateBySnapshot: !0
493
- }), v.value.length > 0) {
494
- const m = v.value.map((O) => O._id);
495
- await L.recalculation.scheduleInvalidateClosingDraftCache(m);
496
- }
497
- x.open({
498
- title: o("common.success"),
499
- message: "Stock recalculation has been scheduled successfully",
500
- type: "success"
501
- }), await W(), S.value = !1, T("submitted");
502
- } catch (e) {
503
- console.error("Error scheduling recalculation:", e), x.open({
504
- title: o("common.error"),
505
- message: "Failed to schedule stock recalculation",
506
- type: "error"
507
- });
508
- } finally {
509
- s.value = !1;
510
- }
511
- }
512
- }
513
- return (e, m) => {
514
- const O = w("FmButton"), X = w("FmSelect"), Z = w("FmDatePicker"), q = w("FmSnackbar"), d = w("FmAlert"), t = w("FmDialog");
515
- return i(), p("div", null, [
516
- e.showButton ? (i(), j(O, {
517
- key: 0,
518
- "prepend-icon": "info",
519
- variant: "tertiary",
520
- onClick: pe(Y, ["stop"])
521
- })) : _("", !0),
522
- h(t, {
523
- modelValue: S.value,
524
- "onUpdate:modelValue": m[4] || (m[4] = (n) => S.value = n),
525
- "close-button": "",
526
- dismissAway: "",
527
- "max-width": "600px"
528
- }, {
529
- "dialog-header": F(() => [
530
- a("div", st, l(c(o)("inventory.stock.recalculation.title")), 1)
531
- ]),
532
- "dialog-footer": F(() => [
533
- J.value ? (i(), p("div", Ot, [
534
- h(O, {
535
- variant: "tertiary",
536
- onClick: m[3] || (m[3] = (n) => S.value = !1),
537
- label: c(o)("common.close")
538
- }, null, 8, ["label"])
539
- ])) : (i(), p("div", Lt, [
540
- h(O, {
541
- variant: "tertiary",
542
- onClick: m[2] || (m[2] = (n) => S.value = !1),
543
- disabled: s.value,
544
- label: c(o)("common.cancel")
545
- }, null, 8, ["disabled", "label"]),
546
- h(O, {
547
- variant: "primary",
548
- onClick: u,
549
- disabled: !M.value || s.value,
550
- loading: s.value,
551
- label: c(o)("inventory.stock.recalculation.schedule")
552
- }, null, 8, ["disabled", "loading", "label"])
553
- ]))
554
- ]),
555
- default: F(() => [
556
- a("div", it, [
557
- a("div", ct, l(c(o)("inventory.stock.recalculation.description")), 1),
558
- J.value ? _("", !0) : (i(), p(G, { key: 0 }, [
559
- a("div", rt, [
560
- a("p", dt, [
561
- te(l(c(o)("inventory.stock.recalculation.openingDate")) + " ", 1),
562
- m[5] || (m[5] = a("span", { class: "text-fm-color-system-error-300" }, "*", -1))
563
- ]),
564
- m[6] || (m[6] = a("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)),
565
- h(X, {
566
- modelValue: f.value,
567
- "onUpdate:modelValue": m[0] || (m[0] = (n) => f.value = n),
568
- items: B.value,
569
- placeholder: c(o)("inventory.stock.recalculation.selectOpening"),
570
- loading: s.value,
571
- disabled: s.value
572
- }, null, 8, ["modelValue", "items", "placeholder", "loading", "disabled"])
573
- ]),
574
- a("div", ut, [
575
- a("p", mt, [
576
- te(l(c(o)("inventory.stock.recalculation.untilDate")) + " ", 1),
577
- m[7] || (m[7] = a("span", { class: "text-fm-color-system-error-300" }, "*", -1))
578
- ]),
579
- m[8] || (m[8] = a("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)),
580
- h(Z, {
581
- modelValue: y.value,
582
- "onUpdate:modelValue": m[1] || (m[1] = (n) => y.value = n),
583
- placeholder: c(o)("inventory.stock.recalculation.selectDate"),
584
- min: N.value,
585
- disabled: !f.value || s.value
586
- }, null, 8, ["modelValue", "placeholder", "min", "disabled"]),
587
- z.value ? (i(), p("div", ft, l(z.value), 1)) : _("", !0),
588
- E.value ? (i(), j(q, {
589
- key: 1,
590
- title: "Warning",
591
- variant: "warning",
592
- description: "You have selected today or a future date. The stock balance will be refreshed accordingly."
593
- })) : _("", !0)
594
- ]),
595
- f.value && y.value && !z.value ? (i(), j(d, {
596
- key: 0,
597
- type: "info"
598
- }, {
599
- default: F(() => [
600
- a("div", yt, l(c(o)("inventory.stock.recalculation.info")), 1)
601
- ]),
602
- _: 1
603
- })) : _("", !0),
604
- v.value.length > 0 ? (i(), p("div", pt, [
605
- A.value ? (i(), p("div", vt, " Loading affected closing drafts... ")) : (i(), p("div", gt, [
606
- a("div", ht, " Affected closing draft(s): " + l(v.value.length), 1),
607
- a("div", _t, [
608
- (i(!0), p(G, null, le(v.value, (n) => (i(), p("div", {
609
- key: n._id,
610
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
611
- }, [
612
- m[9] || (m[9] = te(" • ")),
613
- n.closingId && I.value.get(n.closingId) ? (i(), p("span", bt, l(I.value.get(n.closingId)), 1)) : (i(), p("span", kt, l(n._id), 1)),
614
- n.effectiveAt ? (i(), p("span", xt, " (" + l(new Date(n.effectiveAt).toLocaleString()) + ") ", 1)) : _("", !0)
615
- ]))), 128))
616
- ])
617
- ]))
618
- ])) : _("", !0)
619
- ], 64)),
620
- r.value.length > 0 ? (i(), p("div", Dt, [
621
- a("p", St, l(c(o)("inventory.stock.recalculation.recentRequests")), 1),
622
- a("div", wt, [
623
- (i(!0), p(G, null, le(r.value, (n) => {
624
- var H;
625
- return i(), p("div", {
626
- key: n._id,
627
- class: "p-12 border border-fm-color-border-primary rounded-8 flex flex-col gap-4"
628
- }, [
629
- a("div", Vt, [
630
- a("div", $t, l(c(o)("inventory.stock.recalculation.requestedAt")) + ": " + l(new Date(n.createdAt).toLocaleString()), 1),
631
- a("div", Ct, [
632
- (H = n.meta) != null && H.openingType ? (i(), p("div", At, l(n.meta.openingType === "stockSnapshot" ? "Snapshot" : "Closing"), 1)) : _("", !0),
633
- a("div", {
634
- class: ve(["fm-typo-en-body-xs-600 px-8 py-4 rounded-4", {
635
- "bg-fm-color-system-error-100 text-fm-color-system-error-500": n.failedReason,
636
- "bg-fm-color-system-success-100 text-fm-color-system-success-500": n.completedAt,
637
- "bg-fm-color-system-info-100 text-fm-color-system-info-500": !n.failedReason && !n.completedAt
638
- }])
639
- }, l(n.failedReason ? c(o)("inventory.stock.recalculation.status.failed") : n.completedAt ? c(o)("inventory.stock.recalculation.status.completed") : c(o)("inventory.stock.recalculation.status.inProgress")), 3)
640
- ])
641
- ]),
642
- a("div", Ft, l(c(o)("inventory.stock.recalculation.from")) + ": " + l(new Date(n.recalculateStartDate).toLocaleDateString()), 1),
643
- a("div", Rt, l(c(o)("inventory.stock.recalculation.to")) + ": " + l(new Date(n.recalculateEndDate).toLocaleDateString()), 1),
644
- n.createdBy ? (i(), p("div", Bt, l(c(o)("inventory.stock.recalculation.requestedBy")) + ": " + l(n.createdBy.name || n.createdBy.id), 1)) : _("", !0),
645
- n.completedAt ? (i(), p("div", It, l(c(o)("inventory.stock.recalculation.completedAt")) + ": " + l(new Date(n.completedAt).toLocaleString()), 1)) : _("", !0),
646
- n.failedReason ? (i(), p("div", Tt, l(n.failedReason), 1)) : _("", !0)
647
- ]);
648
- }), 128))
649
- ])
650
- ])) : _("", !0)
651
- ])
652
- ]),
653
- _: 1
654
- }, 8, ["modelValue"])
655
- ]);
656
- };
657
- }
658
- }), Ut = { class: "fm-typo-en-heading-lg-600" }, Et = { class: "flex flex-col gap-16" }, Nt = { class: "flex flex-col gap-4" }, Mt = { class: "fm-typo-en-label-md-400 text-fm-color-typo-secondary" }, Kt = { class: "fm-typo-en-body-md-400" }, Ht = { class: "flex flex-col gap-4" }, jt = { class: "fm-typo-en-label-md-400 text-fm-color-typo-secondary" }, zt = { class: "fm-typo-en-body-md-400" }, Wt = { class: "flex flex-col gap-4" }, Yt = { class: "fm-typo-en-label-md-400 text-fm-color-typo-secondary" }, Gt = { class: "flex gap-8 ml-auto" }, Jt = /* @__PURE__ */ se({
659
- __name: "ClosingDetailDialog",
660
- props: {
661
- modelValue: { type: Boolean },
662
- type: {},
663
- data: {}
664
- },
665
- emits: ["update:modelValue"],
666
- setup(ne, { emit: b }) {
667
- const { t: k } = ie(), T = De(), o = ne, L = b, R = D({
668
- get: () => o.modelValue,
669
- set: (s) => L("update:modelValue", s)
670
- }), x = g("");
671
- re(R, (s) => {
672
- s || (x.value = "");
673
- });
674
- const S = D(() => {
675
- var s;
676
- return ((s = o.data) == null ? void 0 : s.skus) ?? [];
677
- }), f = D(() => {
678
- var v;
679
- const s = (v = o.data) == null ? void 0 : v._id;
680
- if (!s) return "-";
681
- const r = P(s);
682
- return new Date(r).toLocaleString();
683
- }), y = D(() => o.type === "closing" ? k("inventory.closing.history.closingDetail", "Closing Detail") : k("inventory.closing.history.snapshotDetail", "Snapshot Detail")), $ = D(() => S.value.map((s) => {
684
- const r = T.skuById[s.id] ?? null, C = !r;
685
- return {
686
- id: s.id,
687
- sku: r,
688
- skuName: (r == null ? void 0 : r.name) ?? s.id,
689
- skuCode: (r == null ? void 0 : r.code) ?? "-",
690
- balance: s.balance ?? { amount: 0, precision: 0 },
691
- isMissing: C,
692
- costs: s.costs,
693
- weightedAverage: s.weightedAverage
694
- };
695
- })), U = [
696
- {
697
- accessorKey: "skuName",
698
- header: () => k("inventory.ingredient.name", "Ingredient Name"),
699
- cell: (s) => {
700
- const r = s.row.original;
701
- return r.isMissing ? ee("div", { class: "flex items-center gap-8" }, [
702
- ee("span", {}, r.id),
703
- ee(
704
- "span",
705
- {
706
- class: "px-8 py-2 rounded-4 bg-fm-color-danger-weak text-fm-color-danger-default fm-typo-en-label-sm-400"
707
- },
708
- "Missing"
709
- )
710
- ]) : s.getValue();
711
- }
712
- },
713
- {
714
- accessorKey: "skuCode",
715
- header: () => k("inventory.ingredient.code", "Code")
716
- },
717
- {
718
- id: "balance",
719
- header: () => k("inventory.closing.history.balance", "Balance"),
720
- cell: (s) => {
721
- var v;
722
- const r = s.row.original;
723
- if (r.isMissing || !((v = r.sku) != null && v.unit))
724
- return `${r.balance.amount / Math.pow(10, r.balance.precision)}`;
725
- const C = {
726
- unit: r.sku.unit,
727
- sku: r.sku,
728
- amount: r.balance,
729
- defaultTrackingMeasurement: r.sku.trackingMeasurement ?? void 0
730
- };
731
- return ee(Ce, C);
732
- },
733
- size: 180
734
- },
735
- {
736
- accessorKey: "weightedAverage",
737
- header: () => k("inventory.closing.history.weightedAvgCost", "Weighted Avg Cost"),
738
- cell: (s) => {
739
- const r = s.getValue();
740
- if (!r) return "-";
741
- const C = r.amount ?? 0, v = r.precision ?? 0, A = r.currency ?? "", B = C / Math.pow(10, v);
742
- return `${A} ${B.toFixed(2)}`;
743
- }
744
- }
745
- ];
746
- return (s, r) => {
747
- const C = w("FmTextField"), v = w("FmTable"), A = w("FmButton"), B = w("FmDialog");
748
- return i(), j(B, {
749
- modelValue: R.value,
750
- "onUpdate:modelValue": r[2] || (r[2] = (I) => R.value = I),
751
- "close-button": "",
752
- dismissAway: "",
753
- "max-width": "900px"
754
- }, {
755
- "dialog-header": F(() => [
756
- a("div", Ut, l(y.value), 1)
757
- ]),
758
- default: F(() => {
759
- var I;
760
- return [
761
- a("div", Et, [
762
- a("div", Nt, [
763
- a("div", Mt, l(o.type === "closing" ? c(k)("inventory.closing.history.closingId") : c(k)("inventory.closing.history.snapshotId", "Snapshot ID")), 1),
764
- a("div", Kt, l(((I = o.data) == null ? void 0 : I._id) ?? "-"), 1)
765
- ]),
766
- a("div", Ht, [
767
- a("div", jt, l(c(k)("inventory.closing.history.date")), 1),
768
- a("div", zt, l(f.value), 1)
769
- ]),
770
- a("div", Wt, [
771
- a("div", Yt, l(c(k)("inventory.closing.history.ingredientBalances", "Ingredient Balances")) + " (" + l(S.value.length) + ") ", 1),
772
- h(C, {
773
- modelValue: x.value,
774
- "onUpdate:modelValue": r[0] || (r[0] = (N) => x.value = N),
775
- placeholder: "Filter by code or name"
776
- }, null, 8, ["modelValue"]),
777
- h(v, {
778
- "row-data": $.value,
779
- "column-defs": U,
780
- pagination: { pageSize: 10 },
781
- "search-value": x.value
782
- }, null, 8, ["row-data", "search-value"])
783
- ])
784
- ])
785
- ];
786
- }),
787
- "dialog-footer": F(() => [
788
- a("div", Gt, [
789
- h(A, {
790
- variant: "tertiary",
791
- onClick: r[1] || (r[1] = (I) => R.value = !1),
792
- label: "Close"
793
- })
794
- ])
795
- ]),
796
- _: 1
797
- }, 8, ["modelValue"]);
798
- };
799
- }
800
- }), Qt = { class: "flex flex-col gap-16 p-16" }, Xt = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Zt = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, qt = { class: "flex flex-col gap-16" }, eo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, to = { class: "flex gap-8 ml-auto" }, yo = /* @__PURE__ */ se({
801
- __name: "ClosingHistoryView",
802
- setup(ne) {
803
- var Z, q;
804
- const { t: b } = ie(), k = de(), T = Se(), o = xe(), L = Ve(), R = ue(), x = g("closings"), S = D(() => [
805
- { label: b("inventory.closing.history.closingsTab"), value: "closings" },
806
- { label: b("inventory.closing.history.snapshotsTab"), value: "snapshots" }
807
- ]), f = g([]), y = g(0), $ = g([]), U = g(0);
808
- let s = T.currentLocationDBName;
809
- async function r(d) {
810
- return T.currentLocationDBName ? (s = T.currentLocationDBName, k.listClosingsPage(d)) : { docs: [], nextStartkey: null, hasMore: !1 };
811
- }
812
- async function C(d) {
813
- return T.currentLocationDBName ? (s = T.currentLocationDBName, k.listStockSnapshotsPage(d)) : { docs: [], nextStartkey: null, hasMore: !1 };
814
- }
815
- function v() {
816
- f.value = [], y.value++;
817
- }
818
- function A() {
819
- $.value = [], U.value++;
820
- }
821
- const B = g(!1), I = g("closing"), N = g(null);
822
- function z(d) {
823
- return [
824
- d.getFullYear(),
825
- String(d.getMonth() + 1).padStart(2, "0"),
826
- String(d.getDate()).padStart(2, "0")
827
- ].join("-");
828
- }
829
- const E = () => z(new Date(Date.now() - 864e5)), M = g(E()), J = D(() => {
830
- const d = [];
831
- return x.value === "closings" ? d.push(
832
- {
833
- label: b("inventory.stock.recalculation.title"),
834
- value: "recalculation",
835
- prependIcon: "history",
836
- isAdminOnly: !0
837
- },
838
- {
839
- label: b("inventory.closing.history.initiate_opening"),
840
- value: "initiateOpening",
841
- prependIcon: "add_box",
842
- isAdminOnly: !0
843
- },
844
- {
845
- label: "Refresh",
846
- value: "refreshOpening",
847
- prependIcon: "refresh"
848
- }
849
- ) : d.push(
850
- {
851
- label: `${b("inventory.stock.recalculation.title")} (BETA)`,
852
- value: "recalculation",
853
- prependIcon: "history",
854
- isAdminOnly: !0
855
- },
856
- {
857
- label: `${b("inventory.closing.history.initiate_snapshot")} (BETA)`,
858
- value: "initiateStockSnapshot",
859
- prependIcon: "camera",
860
- isAdminOnly: !0
861
- },
862
- {
863
- label: "Refresh",
864
- value: "refreshStockSnapshot",
865
- prependIcon: "refresh"
866
- }
867
- ), d;
868
- }), Y = g(), Q = g();
869
- function oe(d) {
870
- var t, n;
871
- switch (d) {
872
- case "recalculation":
873
- return x.value === "closings" ? (t = Y.value) == null ? void 0 : t.open() : (n = Q.value) == null ? void 0 : n.open();
874
- case "initiateOpening": {
875
- L.open({
876
- title: "Initiate Opening Balance",
877
- message: "Initiate opening balance if no opening balance exists for the current location.",
878
- primaryActions: { text: "Confirm", close: !0 }
879
- }).onPrimary(async () => {
880
- try {
881
- await k.initiateClosing(), R.open({
882
- message: "Opening balance initiated successfully.",
883
- type: "success"
884
- }), await v();
885
- } catch (H) {
886
- R.open({
887
- message: H.message || "Failed to initiate opening balance. Please try again.",
888
- type: "error"
889
- });
890
- }
891
- });
892
- break;
893
- }
894
- case "initiateStockSnapshot": {
895
- M.value = E(), K.value = !0;
896
- break;
897
- }
898
- case "refreshOpening": {
899
- v();
900
- break;
901
- }
902
- case "refreshStockSnapshot": {
903
- A();
904
- break;
905
- }
906
- }
907
- }
908
- const K = g(!1), W = g(!1), ae = E();
909
- async function u() {
910
- W.value = !0;
911
- try {
912
- await k.initiateStockSnapshot(M.value), R.open({
913
- message: "Stock snapshot created successfully.",
914
- type: "success"
915
- }), K.value = !1, await A();
916
- } catch (d) {
917
- R.open({
918
- message: d.message || "Failed to create stock snapshot. Please try again.",
919
- type: "error"
920
- });
921
- } finally {
922
- W.value = !1;
923
- }
924
- }
925
- const e = [
926
- ...(Z = o.sessionUser.value) != null && Z.role.isAdmin ? [
927
- {
928
- accessorKey: "_id",
929
- header: () => ee(fe, {}, () => `${b("inventory.closing.history.closingId")}`),
930
- cell: (d) => d.getValue()
931
- }
932
- ] : [],
933
- {
934
- accessorKey: "_id",
935
- id: "date",
936
- header: () => b("inventory.closing.history.date"),
937
- cell: (d) => {
938
- const t = d.getValue(), n = P(t);
939
- return new Date(n).toLocaleDateString();
940
- }
941
- },
942
- {
943
- accessorKey: "_id",
944
- id: "time",
945
- header: () => b("inventory.closing.history.time"),
946
- cell: (d) => {
947
- const t = d.getValue(), n = P(t);
948
- return new Date(n).toLocaleTimeString();
949
- }
950
- },
951
- {
952
- accessorKey: "ref",
953
- header: () => b("inventory.closing.history.createdFrom"),
954
- cell: (d) => d.getValue() || "-"
955
- }
956
- ], m = [
957
- ...(q = o.sessionUser.value) != null && q.role.isAdmin ? [
958
- {
959
- accessorKey: "_id",
960
- header: () => ee(
961
- fe,
962
- {},
963
- () => `${b("inventory.closing.history.snapshotId", "Snapshot ID")}`
964
- ),
965
- cell: (d) => d.getValue()
966
- }
967
- ] : [],
968
- {
969
- accessorKey: "_id",
970
- id: "date",
971
- header: () => b("inventory.closing.history.date"),
972
- cell: (d) => {
973
- const t = d.getValue(), n = P(t);
974
- return new Date(n).toLocaleDateString();
975
- }
976
- },
977
- {
978
- accessorKey: "_id",
979
- id: "time",
980
- header: () => b("inventory.closing.history.time"),
981
- cell: (d) => {
982
- const t = d.getValue(), n = P(t);
983
- return new Date(n).toLocaleTimeString();
984
- }
985
- },
986
- {
987
- accessorKey: "remark",
988
- header: () => b("inventory.closing.history.createdFrom"),
989
- cell: (d) => d.getValue() || "-"
990
- }
991
- ];
992
- async function O(d, t) {
993
- const n = await k.getClosingById(d, t);
994
- if (!n) throw new Error(`Closing ${d} not found`);
995
- return I.value = "closing", N.value = n, B.value = !0, n;
996
- }
997
- async function X(d, t) {
998
- const n = await k.getStockSnapshotById(d, t);
999
- if (!n) throw new Error(`Stock snapshot ${d} not found`);
1000
- return I.value = "snapshot", N.value = n, B.value = !0, n;
1001
- }
1002
- return T.watchLocation(async () => {
1003
- (T.currentLocationDBName || void 0) !== s && (v(), A());
1004
- }), (d, t) => {
1005
- const n = w("FmTabs"), H = w("FmDatePicker"), me = w("FmButton"), _e = w("FmDialog");
1006
- return i(), j(ke, {
1007
- actions: J.value,
1008
- title: c(b)("inventory.closing.history.title"),
1009
- "onClick:action": oe
1010
- }, {
1011
- default: F(() => [
1012
- a("div", Qt, [
1013
- h(we, {
1014
- "change-location": "",
1015
- "hide-filter-options": !0
1016
- }),
1017
- h(n, {
1018
- "model-value": x.value,
1019
- "onUpdate:modelValue": t[0] || (t[0] = (V) => x.value = V),
1020
- items: S.value
1021
- }, null, 8, ["model-value", "items"]),
1022
- x.value === "closings" ? (i(), p(G, { key: 0 }, [
1023
- a("div", Xt, l(c(b)("inventory.closing.history.closingsDescription")), 1),
1024
- h(ye, {
1025
- rows: f.value,
1026
- "onUpdate:rows": t[1] || (t[1] = (V) => f.value = V),
1027
- "fetch-page": r,
1028
- "refresh-key": y.value,
1029
- "column-defs": e,
1030
- "fetch-detail": (V, ce) => O(V._id, ce)
1031
- }, null, 8, ["rows", "refresh-key", "fetch-detail"])
1032
- ], 64)) : _("", !0),
1033
- x.value === "snapshots" ? (i(), p(G, { key: 1 }, [
1034
- a("div", Zt, l(c(b)("inventory.closing.history.snapshotsDescription")), 1),
1035
- h(ye, {
1036
- rows: $.value,
1037
- "onUpdate:rows": t[2] || (t[2] = (V) => $.value = V),
1038
- "fetch-page": C,
1039
- "refresh-key": U.value,
1040
- "column-defs": m,
1041
- "fetch-detail": (V, ce) => X(V._id, ce)
1042
- }, null, 8, ["rows", "refresh-key", "fetch-detail"])
1043
- ], 64)) : _("", !0)
1044
- ]),
1045
- (i(), j(be, { to: "body" }, [
1046
- h(lt, {
1047
- "show-button": !1,
1048
- ref_key: "recalculationDialogRef",
1049
- ref: Y,
1050
- onSubmitted: t[3] || (t[3] = (V) => v())
1051
- }, null, 512),
1052
- h(Pt, {
1053
- "show-button": !1,
1054
- ref_key: "snapshotRecalculationDialogRef",
1055
- ref: Q,
1056
- onSubmitted: t[4] || (t[4] = (V) => A())
1057
- }, null, 512),
1058
- h(Jt, {
1059
- modelValue: B.value,
1060
- "onUpdate:modelValue": t[5] || (t[5] = (V) => B.value = V),
1061
- type: I.value,
1062
- data: N.value
1063
- }, null, 8, ["modelValue", "type", "data"]),
1064
- h(_e, {
1065
- modelValue: K.value,
1066
- "onUpdate:modelValue": t[8] || (t[8] = (V) => K.value = V),
1067
- "close-button": "",
1068
- dismissAway: "",
1069
- "max-width": "400px"
1070
- }, {
1071
- "dialog-header": F(() => t[9] || (t[9] = [
1072
- a("div", { class: "fm-typo-en-heading-lg-600" }, "Initiate Stock Snapshot", -1)
1073
- ])),
1074
- default: F(() => [
1075
- a("div", qt, [
1076
- a("div", eo, l(c(b)("inventory.closing.history.snapshotsDescription")), 1),
1077
- h(H, {
1078
- modelValue: M.value,
1079
- "onUpdate:modelValue": t[6] || (t[6] = (V) => M.value = V),
1080
- label: "Snapshot Date",
1081
- max: c(ae)
1082
- }, null, 8, ["modelValue", "max"])
1083
- ])
1084
- ]),
1085
- "dialog-footer": F(() => [
1086
- a("div", to, [
1087
- h(me, {
1088
- variant: "tertiary",
1089
- onClick: t[7] || (t[7] = (V) => K.value = !1),
1090
- label: "Cancel",
1091
- disabled: W.value
1092
- }, null, 8, ["disabled"]),
1093
- h(me, {
1094
- variant: "primary",
1095
- onClick: u,
1096
- label: "Confirm",
1097
- loading: W.value
1098
- }, null, 8, ["loading"])
1099
- ])
1100
- ]),
1101
- _: 1
1102
- }, 8, ["modelValue"])
1103
- ]))
1104
- ]),
1105
- _: 1
1106
- }, 8, ["actions", "title"]);
1107
- };
1108
- }
1109
- });
1110
- export {
1111
- yo as default
1112
- };