@feedmepos/mf-inventory-portal 1.2.61 → 1.2.63-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 (124) hide show
  1. package/dist/{App-BqScGtJx.js → App-BHssUobV.js} +82 -78
  2. package/dist/{ApprovalView-BFdlYIot.js → ApprovalView-DRGCQeGY.js} +5 -5
  3. package/dist/{BindingsDialog-Dvmrms77.js → BindingsDialog-CWl3LpdO.js} +5 -5
  4. package/dist/{BindingsPicker-fPVSXv-h.js → BindingsPicker-BcASw3JJ.js} +3 -3
  5. package/dist/{BindingsTable-CnUa8VOi.js → BindingsTable-BiKiLiVY.js} +5 -5
  6. package/dist/{ClosingDraftView-10BcpWkm.js → ClosingDraftView-mh5Kw46x.js} +217 -216
  7. package/dist/{ClosingHistoryView-zLh0HCIb.js → ClosingHistoryView-C-ZrFei9.js} +36 -36
  8. package/dist/{ClosingTemplateView-BFupX87V.js → ClosingTemplateView-DBNRH0Tt.js} +14 -14
  9. package/dist/{DeliveryOrderPrintPreview-BLBqmOjw.js → DeliveryOrderPrintPreview-Dv3JZ3yr.js} +7 -7
  10. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DN8ziFA_.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CfL1adhx.js} +16 -16
  11. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DJT_7Uus.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-Db0JeXbc.js} +2 -2
  12. package/dist/{FmMultiselectDialog-DmnYEmN1.js → FmMultiselectDialog-D9g07F_c.js} +1 -1
  13. package/dist/{FmMultiselectDialog-B5paZk6T.js → FmMultiselectDialog-DuYKQng9.js} +16 -16
  14. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-MW749j29.js → FmUnitInput.vue_vue_type_script_setup_true_lang-CeXRT7Lf.js} +23 -22
  15. package/dist/{ImportView-BsI1_unJ.js → ImportView-DoMyJ1NE.js} +6 -6
  16. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-D8hvH-4n.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-CqJQcOBK.js} +1 -1
  17. package/dist/{IngredientGroupView-BALVTSwF.js → IngredientGroupView-D_Cl4kJy.js} +5 -5
  18. package/dist/{IngredientsView-C-sauieO.js → IngredientsView-CG6wUGzt.js} +25 -24
  19. package/dist/{IntegrationView-GG2E4Yrl.js → IntegrationView-BIWPp1JH.js} +18 -17
  20. package/dist/{InventoryBindingForm-DCSBFj6b.js → InventoryBindingForm-BrL6-2He.js} +1 -1
  21. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-4_i25unG.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-M3uVquEq.js} +17 -16
  22. package/dist/{InventoryBindingSummary-6dFJPewB.js → InventoryBindingSummary-mnlQU1Mp.js} +1 -1
  23. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CU9mgYbv.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-ByPOKZRm.js} +5 -5
  24. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-DC1HpuMm.js → PremiumBadge.vue_vue_type_script_setup_true_lang-DHwXNoTs.js} +2 -2
  25. package/dist/{PublishView-DO7k1AeP.js → PublishView-B4iVMq25.js} +8 -8
  26. package/dist/{PurchaseOrderPrintPreview-C3VqOLCi.js → PurchaseOrderPrintPreview-ws-SKrEC.js} +11 -11
  27. package/dist/{ReceiveRequestView-CpgLQtbw.js → ReceiveRequestView-deSiORNX.js} +143 -142
  28. package/dist/RecipeView-EEK7PiKl.js +1558 -0
  29. package/dist/{StockView-CtC3ldc6.js → StockView-6j_t2Kf1.js} +106 -105
  30. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-Cj6cVmd0.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-CgAMsW8n.js} +1 -1
  31. package/dist/{SupplierView-DKFtc22j.js → SupplierView-D5tSOECx.js} +20 -19
  32. package/dist/{SurchargeView-B-EYMp6w.js → SurchargeView-CP81Q4dW.js} +6 -6
  33. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-CDeeFvnm.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-Bmuw4PTO.js} +2 -2
  34. package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-CH3hjFS8.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-D1FuB-kv.js} +1 -1
  35. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-rAyYuhku.js → TransferDetails.vue_vue_type_script_setup_true_lang-Canrz2ri.js} +501 -501
  36. package/dist/{TransferTemplateView-FeC34QoJ.js → TransferTemplateView-CRI_Lexa.js} +22 -21
  37. package/dist/UnitCostHistoryView-CT-4QDK8.js +651 -0
  38. package/dist/{UnitView-BoJisnXd.js → UnitView-BZmfd-aw.js} +11 -10
  39. package/dist/{WarehouseView-s-xF6xJ0.js → WarehouseView-BcmSyjA0.js} +5 -5
  40. package/dist/{WastageTemplateView-BQBlHZLh.js → WastageTemplateView-CNsdu0ga.js} +14 -14
  41. package/dist/api/inventory.d.ts +126 -36
  42. package/dist/api/netsuite.d.ts +8 -1
  43. package/dist/api/unit-cost-history.d.ts +28 -0
  44. package/dist/{app-_4kRbuQl.js → app-ayv5Jw7D.js} +8041 -7036
  45. package/dist/app.d.ts +228 -0
  46. package/dist/app.js +1 -1
  47. package/dist/{closing-template-BBWYKm_X.js → closing-template-D9UR8sMo.js} +1 -1
  48. package/dist/components/inventory-binding/InventoryBinding.vue.d.ts +37 -1
  49. package/dist/components/shell/inventory/binding-dialog.vue.d.ts +14 -0
  50. package/dist/components/shell/inventory/binding-ui.vue.d.ts +16 -1
  51. package/dist/{date2-Cd93SZu4.js → date2-GNP-79dA.js} +1 -1
  52. package/dist/{dayjs.min-DeHn_Fz-.js → dayjs.min-Bg_wgP2J.js} +16 -16
  53. package/dist/{defineDeepModel-DUOLQh1E.js → defineDeepModel-Co03tZfS.js} +1 -1
  54. package/dist/{duplicate-template-BgpMF-fd.js → duplicate-template-BiPU4Z2Y.js} +1 -1
  55. package/dist/{feature-DqGkM6Yx.js → feature-BGeFfaiX.js} +95 -90
  56. package/dist/{format-time-from-id-BkH4swoc.js → format-time-from-id-ByV0VX1x.js} +1 -1
  57. package/dist/{format-unit-display-rkrD3WLD.js → format-unit-display-r1Hb4DfH.js} +16 -15
  58. package/dist/{import-export.helper-C8Q4AMQx.js → import-export.helper-PB9pPO3m.js} +16 -15
  59. package/dist/{index-B3m_9m2a.js → index-ClbYCYSU.js} +3 -3
  60. package/dist/{index-O5M93j6z.js → index-DMqOVOHw.js} +1 -1
  61. package/dist/{index-B0WTs-3a.js → index-DWWlEK_r.js} +1471 -1412
  62. package/dist/{lodash-Dj6GdEkm.js → lodash-BbWPSHMM.js} +1 -1
  63. package/dist/{netsuite-DpQxb3vH.js → netsuite-VGghPz8h.js} +92 -92
  64. package/dist/number-DPuTdA-J.js +232 -0
  65. package/dist/{purchase-order-template-DKuo07gT.js → purchase-order-template-BMNxJR59.js} +1 -1
  66. package/dist/router/name.d.ts +1 -0
  67. package/dist/rules-CyF-4tvp.js +98 -0
  68. package/dist/stock-D1SElOsp.js +75 -0
  69. package/dist/{stock-D7HQf4-H.js → stock-b7nNc6ko.js} +1 -1
  70. package/dist/stores/feature.d.ts +2 -0
  71. package/dist/stores/integration/netsuite.d.ts +8 -1
  72. package/dist/stores/inventory.d.ts +119 -30
  73. package/dist/{supplier-B3kE2tbF.js → supplier-Dm-bxVXL.js} +2 -2
  74. package/dist/{surcharge-Cc9vownX.js → surcharge-ZM-_XIvY.js} +1 -1
  75. package/dist/tsconfig.app.tsbuildinfo +1 -1
  76. package/dist/{use-ingredient-select-dialog-MnUTm-3P.js → use-ingredient-select-dialog-BYxTRqif.js} +2 -2
  77. package/dist/{use-inventory-binding-dialog-_J9LNiGo.js → use-inventory-binding-dialog-Dg9Mp0Vk.js} +2 -2
  78. package/dist/{use-template-enabled-locations-2-B9gbuIPM.js → use-template-enabled-locations-2-BmgcViqJ.js} +2 -2
  79. package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftDialog.vue.d.ts +64 -8
  80. package/dist/views/closing-draft/composables/use-closing-draft-table.d.ts +192 -24
  81. package/dist/views/closing-template/components/closing-template-form/composables/use-closing-template-items.d.ts +8 -1
  82. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +96 -12
  83. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +96 -12
  84. package/dist/views/ingredient-group/composables/use-ingredient-group-table.d.ts +18 -18
  85. package/dist/views/ingredients/components/convert/ConvertForm.vue.d.ts +14 -0
  86. package/dist/views/ingredients/components/ingredient-form/IngredientForm.vue.d.ts +32 -4
  87. package/dist/views/ingredients/components/inventory-binding/InventoryBindingForm.vue.d.ts +28 -0
  88. package/dist/views/ingredients/components/inventory-binding/v2/InventoryBindingFormV2.vue.d.ts +169 -0
  89. package/dist/views/ingredients/components/inventory-binding/v2/components/InventoryBindingAlternative.vue.d.ts +43 -0
  90. package/dist/views/ingredients/components/inventory-binding/v2/components/InventoryBindingRule.vue.d.ts +25 -0
  91. package/dist/views/ingredients/components/inventory-binding/v2/components/InventoryRecipeBindingV2Field.vue.d.ts +125 -0
  92. package/dist/views/ingredients/components/inventory-binding/v2/components/InventorySkuBindingV2Field.vue.d.ts +129 -0
  93. package/dist/views/ingredients/components/inventory-binding/v2/composables/use-inventory-binding-alternative-table.d.ts +30 -0
  94. package/dist/views/ingredients/components/inventory-binding/v2/composables/use-inventory-binding-dialog.d.ts +4 -0
  95. package/dist/views/ingredients/composables/use-ingredient-table.d.ts +8 -1
  96. package/dist/views/integration/components/netsuite/InventoryTransferIngredientTable.vue.d.ts +16 -2
  97. package/dist/views/receive-request/components/transfer-form/TransferFormWithController.vue.d.ts +33 -5
  98. package/dist/views/receive-request/components/transfer-form/components/ForecastStock.vue.d.ts +16 -2
  99. package/dist/views/receive-request/components/transfer-form/components/TransferItemTable.vue.d.ts +32 -4
  100. package/dist/views/receive-request/components/transfer-form/composables/use-transfer-items.d.ts +8 -1
  101. package/dist/views/receive-request/composables/use-process-purchase-order.d.ts +41 -6
  102. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +246 -36
  103. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +287 -42
  104. package/dist/views/recipe/components/recipe-form/RecipeForm.vue.d.ts +16 -0
  105. package/dist/views/stock/components/StockRecordCard.vue.d.ts +1 -0
  106. package/dist/views/stock/components/dialog/AdjustedItemForm.vue.d.ts +16 -2
  107. package/dist/views/transfer-template/components/transfer-template-dialog/TransferTemplateDialog.vue.d.ts +16 -2
  108. package/dist/views/transfer-template/components/transfer-template-form/components/NetSuiteCustomCodeSelection.vue.d.ts +16 -2
  109. package/dist/views/transfer-template/components/transfer-template-form/components/TransferTemplateItemTable.vue.d.ts +16 -2
  110. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.d.ts +8 -1
  111. package/dist/views/transfer-template/composables/use-netsuite-custom-field.d.ts +24 -3
  112. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +96 -12
  113. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +96 -12
  114. package/dist/views/unit-cost-history/UnitCostHistoryView.vue.d.ts +2 -0
  115. package/dist/views/unit-cost-history/components/UnitCostDetailsSideSheet.vue.d.ts +19 -0
  116. package/dist/views/unit-cost-history/components/UnitCostRecalculationDialog.vue.d.ts +11 -0
  117. package/dist/views/unit-cost-history/composables/use-unit-cost-history.d.ts +65 -0
  118. package/dist/{vue-i18n-BvsTy4Fg.js → vue-i18n-BwxQzDKn.js} +535 -535
  119. package/dist/{xlsx-BvjocXXw.js → xlsx-dJMIfias.js} +1 -1
  120. package/dist/{xlsx.util-D65Nsat4.js → xlsx.util-dclbjq8C.js} +1 -1
  121. package/package.json +3 -3
  122. package/dist/RecipeView-C2D7FdzN.js +0 -646
  123. package/dist/rules-D6o4zK8x.js +0 -327
  124. package/dist/stock-DLFjfcAv.js +0 -75
@@ -0,0 +1,651 @@
1
+ import { ref as h, defineComponent as Q, computed as b, resolveComponent as L, openBlock as u, createElementBlock as g, createVNode as p, withModifiers as oe, withCtx as A, createElementVNode as t, toDisplayString as n, unref as r, Fragment as O, createTextVNode as H, createCommentVNode as F, createBlock as T, renderList as se, normalizeClass as E, normalizeStyle as ae, Teleport as X } from "vue";
2
+ import { F as ne, u as le, _ as re } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-CWZkVCAj.js";
3
+ import { o as ie, u as J, a as Z } from "./app-ayv5Jw7D.js";
4
+ import { useSnackbar as q, useBreakpoints as ce } from "@feedmepos/ui-library";
5
+ import { _ as ue } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-Db0JeXbc.js";
6
+ import { useI18n as ee, useCoreStore as de } from "@feedmepos/mf-common";
7
+ import { d as Y } from "./date2-GNP-79dA.js";
8
+ import { d as j } from "./number-DPuTdA-J.js";
9
+ import { P as me, J as fe } from "./app-DiX-EfV6.js";
10
+ const te = ie((w, _) => {
11
+ const i = J();
12
+ return {
13
+ async getLatestCostForAllSkus(d) {
14
+ const o = `${w.inventoryBackendUrl}/api/unit-cost-history?locationId=${encodeURIComponent(d)}`;
15
+ return await _.get(o);
16
+ },
17
+ async recalculate(d) {
18
+ const o = `${w.inventoryBackendUrl}/api/unit-cost-history/recalculate`;
19
+ return await _.post(o, d);
20
+ },
21
+ async getJobStatus(d) {
22
+ const o = `${w.inventoryBackendUrl}/api/unit-cost-history/jobs/${d}`;
23
+ return await _.get(o);
24
+ },
25
+ async listRecentRecalculationRequests() {
26
+ var C;
27
+ const d = (C = i._currentLocation) == null ? void 0 : C.dbName;
28
+ if (!d) return [];
29
+ const o = `${w.inventoryBackendUrl}/api/unit-cost-history/recalculation-requests?location=${encodeURIComponent(d)}`;
30
+ return await _.get(o);
31
+ }
32
+ };
33
+ });
34
+ function ye() {
35
+ const w = te(), _ = J(), i = h([]), d = h(!1);
36
+ async function o() {
37
+ if (!_._currentLocation)
38
+ return [];
39
+ d.value = !0;
40
+ try {
41
+ const C = _.currentLocation.doc._id, m = await w.getLatestCostForAllSkus(C);
42
+ return i.value = m, m;
43
+ } finally {
44
+ d.value = !1;
45
+ }
46
+ }
47
+ return {
48
+ historyData: i,
49
+ isLoading: d,
50
+ fetchHistory: o
51
+ };
52
+ }
53
+ const pe = { class: "fm-typo-en-heading-lg-600" }, ve = { class: "flex flex-col gap-16" }, ge = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, be = { class: "flex flex-col gap-8" }, he = { class: "fm-typo-en-body-md-600" }, _e = { class: "flex flex-col gap-8" }, xe = { class: "fm-typo-en-body-md-600" }, Ce = {
54
+ key: 0,
55
+ class: "text-red-500 text-sm mt-2"
56
+ }, ke = { class: "fm-typo-en-body-sm-400" }, Se = {
57
+ key: 1,
58
+ class: "flex flex-col gap-8"
59
+ }, we = { class: "fm-typo-en-body-md-600" }, De = { class: "flex flex-col gap-8 max-h-[300px] overflow-y-auto" }, Ae = { class: "flex items-center justify-between" }, $e = { class: "fm-typo-en-body-sm-600" }, Re = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Ie = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Fe = {
60
+ key: 0,
61
+ class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
62
+ }, Le = {
63
+ key: 1,
64
+ class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
65
+ }, Ue = {
66
+ key: 2,
67
+ class: "fm-typo-en-body-xs-400 text-fm-color-system-error-500"
68
+ }, Ne = {
69
+ key: 0,
70
+ class: "flex gap-8 ml-auto"
71
+ }, Be = {
72
+ key: 1,
73
+ class: "flex gap-8 ml-auto"
74
+ }, Ve = /* @__PURE__ */ Q({
75
+ __name: "UnitCostRecalculationDialog",
76
+ emits: ["submitted"],
77
+ setup(w, { expose: _, emit: i }) {
78
+ const d = i, { t: o } = ee(), C = te(), m = q(), U = de(), M = J(), x = h(!1), s = h(""), a = h(""), v = h(!1), $ = h([]), B = h(!1), D = b(() => {
79
+ if (!s.value || !a.value) return "";
80
+ const f = new Date(s.value).getTime();
81
+ return new Date(a.value).getTime() <= f ? o("inventory.unitCost.recalculation.error.endDateBeforeStart") : "";
82
+ }), R = b(() => !!s.value && !!a.value && !D.value), k = b(() => $.value.some(
83
+ (f) => !f.completedAt && !f.failedReason
84
+ ));
85
+ async function V() {
86
+ x.value = !0, await K();
87
+ const f = /* @__PURE__ */ new Date();
88
+ a.value = f.toISOString().split("T")[0];
89
+ const c = new Date(f.getFullYear(), 0, 1);
90
+ s.value = c.toISOString().split("T")[0];
91
+ }
92
+ function P() {
93
+ x.value = !1;
94
+ }
95
+ _({
96
+ open: V,
97
+ close: P
98
+ });
99
+ async function K() {
100
+ B.value = !0;
101
+ try {
102
+ const f = await C.listRecentRecalculationRequests();
103
+ $.value = f;
104
+ } catch (f) {
105
+ console.error("Error fetching recalculation requests:", f);
106
+ } finally {
107
+ B.value = !1;
108
+ }
109
+ }
110
+ async function W() {
111
+ var f, c;
112
+ if (R.value) {
113
+ v.value = !0;
114
+ try {
115
+ const S = ((f = U.currentBusiness.value) == null ? void 0 : f._id) ?? "", N = ((c = M._currentLocation) == null ? void 0 : c.dbName) ?? "";
116
+ if (!S)
117
+ throw new Error("No active business selected");
118
+ if (!N)
119
+ throw new Error("No active location selected");
120
+ await C.recalculate({
121
+ businessId: S,
122
+ locationId: N,
123
+ startDate: s.value,
124
+ endDate: a.value
125
+ }), m.open({
126
+ title: o("common.success"),
127
+ message: o("inventory.unitCost.recalculation.successMessage"),
128
+ type: "success"
129
+ }), await K(), x.value = !1, d("submitted");
130
+ } catch (S) {
131
+ console.error("Error scheduling recalculation:", S), m.open({
132
+ title: o("common.error"),
133
+ message: o("inventory.unitCost.recalculation.errorMessage"),
134
+ type: "error"
135
+ });
136
+ } finally {
137
+ v.value = !1;
138
+ }
139
+ }
140
+ }
141
+ return (f, c) => {
142
+ const S = L("FmButton"), N = L("FmDatePicker"), G = L("FmAlert"), l = L("FmDialog");
143
+ return u(), g("div", null, [
144
+ p(S, {
145
+ "prepend-icon": "info",
146
+ variant: "tertiary",
147
+ onClick: oe(V, ["stop"])
148
+ }),
149
+ p(l, {
150
+ modelValue: x.value,
151
+ "onUpdate:modelValue": c[4] || (c[4] = (e) => x.value = e),
152
+ "close-button": "",
153
+ dismissAway: "",
154
+ "max-width": "600px"
155
+ }, {
156
+ "dialog-header": A(() => [
157
+ t("div", pe, n(r(o)("inventory.unitCost.recalculation.title")), 1)
158
+ ]),
159
+ "dialog-footer": A(() => [
160
+ k.value ? (u(), g("div", Be, [
161
+ p(S, {
162
+ variant: "tertiary",
163
+ onClick: c[3] || (c[3] = (e) => x.value = !1),
164
+ label: r(o)("common.close")
165
+ }, null, 8, ["label"])
166
+ ])) : (u(), g("div", Ne, [
167
+ p(S, {
168
+ variant: "tertiary",
169
+ onClick: c[2] || (c[2] = (e) => x.value = !1),
170
+ disabled: v.value,
171
+ label: r(o)("common.cancel")
172
+ }, null, 8, ["disabled", "label"]),
173
+ p(S, {
174
+ variant: "primary",
175
+ onClick: W,
176
+ disabled: !R.value || v.value,
177
+ loading: v.value,
178
+ label: r(o)("inventory.unitCost.recalculation.schedule")
179
+ }, null, 8, ["disabled", "loading", "label"])
180
+ ]))
181
+ ]),
182
+ default: A(() => [
183
+ t("div", ve, [
184
+ t("div", ge, n(r(o)("inventory.unitCost.recalculation.description")), 1),
185
+ k.value ? F("", !0) : (u(), g(O, { key: 0 }, [
186
+ t("div", be, [
187
+ t("p", he, [
188
+ H(n(r(o)("inventory.unitCost.recalculation.startDate")) + " ", 1),
189
+ c[5] || (c[5] = t("span", { class: "text-fm-color-system-error-300" }, "*", -1))
190
+ ]),
191
+ p(N, {
192
+ modelValue: s.value,
193
+ "onUpdate:modelValue": c[0] || (c[0] = (e) => s.value = e),
194
+ placeholder: r(o)("inventory.unitCost.recalculation.selectStartDate"),
195
+ disabled: v.value
196
+ }, null, 8, ["modelValue", "placeholder", "disabled"])
197
+ ]),
198
+ t("div", _e, [
199
+ t("p", xe, [
200
+ H(n(r(o)("inventory.unitCost.recalculation.endDate")) + " ", 1),
201
+ c[6] || (c[6] = t("span", { class: "text-fm-color-system-error-300" }, "*", -1))
202
+ ]),
203
+ p(N, {
204
+ modelValue: a.value,
205
+ "onUpdate:modelValue": c[1] || (c[1] = (e) => a.value = e),
206
+ placeholder: r(o)("inventory.unitCost.recalculation.selectEndDate"),
207
+ disabled: !s.value || v.value,
208
+ min: s.value
209
+ }, null, 8, ["modelValue", "placeholder", "disabled", "min"]),
210
+ D.value ? (u(), g("div", Ce, n(D.value), 1)) : F("", !0)
211
+ ]),
212
+ s.value && a.value && !D.value ? (u(), T(G, {
213
+ key: 0,
214
+ type: "info"
215
+ }, {
216
+ default: A(() => [
217
+ t("div", ke, n(r(o)("inventory.unitCost.recalculation.info")), 1)
218
+ ]),
219
+ _: 1
220
+ })) : F("", !0)
221
+ ], 64)),
222
+ $.value.length > 0 ? (u(), g("div", Se, [
223
+ t("p", we, n(r(o)("inventory.unitCost.recalculation.recentRequests")), 1),
224
+ t("div", De, [
225
+ (u(!0), g(O, null, se($.value, (e) => (u(), g("div", {
226
+ key: e._id,
227
+ class: "p-12 border border-fm-color-border-primary rounded-8 flex flex-col gap-4"
228
+ }, [
229
+ t("div", Ae, [
230
+ t("div", $e, n(r(o)("inventory.unitCost.recalculation.requestedAt")) + ": " + n(new Date(e.createdAt).toLocaleString()), 1),
231
+ t("div", {
232
+ class: E(["fm-typo-en-body-xs-600 px-8 py-4 rounded-4", {
233
+ "bg-fm-color-system-error-100 text-fm-color-system-error-500": e.failedReason,
234
+ "bg-fm-color-system-success-100 text-fm-color-system-success-500": e.completedAt,
235
+ "bg-fm-color-system-info-100 text-fm-color-system-info-500": !e.failedReason && !e.completedAt
236
+ }])
237
+ }, n(e.failedReason ? r(o)("inventory.unitCost.recalculation.status.failed") : e.completedAt ? r(o)("inventory.unitCost.recalculation.status.completed") : r(o)("inventory.unitCost.recalculation.status.inProgress")), 3)
238
+ ]),
239
+ t("div", Re, n(r(o)("inventory.unitCost.recalculation.from")) + ": " + n(new Date(e.recalculateStartDate).toLocaleDateString()), 1),
240
+ t("div", Ie, n(r(o)("inventory.unitCost.recalculation.to")) + ": " + n(new Date(e.recalculateEndDate).toLocaleDateString()), 1),
241
+ e.createdBy ? (u(), g("div", Fe, n(r(o)("inventory.unitCost.recalculation.requestedBy")) + ": " + n(e.createdBy.name || e.createdBy._id), 1)) : F("", !0),
242
+ e.completedAt ? (u(), g("div", Le, n(r(o)("inventory.unitCost.recalculation.completedAt")) + ": " + n(new Date(e.completedAt).toLocaleString()), 1)) : F("", !0),
243
+ e.failedReason ? (u(), g("div", Ue, n(e.failedReason), 1)) : F("", !0)
244
+ ]))), 128))
245
+ ])
246
+ ])) : F("", !0)
247
+ ])
248
+ ]),
249
+ _: 1
250
+ }, 8, ["modelValue"])
251
+ ]);
252
+ };
253
+ }
254
+ }), Te = {
255
+ key: 0,
256
+ class: "flex flex-col gap-24"
257
+ }, Me = { class: "flex flex-col gap-8" }, ze = { class: "flex flex-col gap-5" }, He = { class: "flex flex-col gap-4" }, Ee = { class: "fm-typo-en-body-lg-600 flex gap-2" }, Pe = { class: "flex flex-col gap-4" }, Ke = { class: "fm-typo-en-body-lg-600 flex gap-2" }, Oe = { class: "flex flex-col gap-4" }, Ye = { class: "fm-typo-en-body-lg-600 flex gap-2" }, je = { class: "flex flex-col gap-4" }, Je = { class: "fm-typo-en-body-lg-600" }, We = { class: "flex flex-col gap-4" }, Ge = { class: "fm-typo-en-body-lg-600" }, Qe = { class: "flex flex-col gap-4" }, Xe = { class: "fm-typo-en-body-lg-600" }, Ze = { class: "flex flex-col gap-4" }, qe = { class: "fm-typo-en-body-lg-600" }, et = { class: "flex flex-col gap-8" }, tt = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary whitespace-pre-wrap" }, ot = { class: "flex gap-4" }, st = /* @__PURE__ */ Q({
258
+ __name: "UnitCostDetailsSideSheet",
259
+ props: {
260
+ record: {}
261
+ },
262
+ setup(w, { expose: _ }) {
263
+ const i = w, d = Z(), o = h(!1), C = b(() => {
264
+ var s;
265
+ return (s = i.record) != null && s.skuId ? d.skus.find((a) => a._id === i.record.skuId) : null;
266
+ }), m = b(() => {
267
+ if (!i.record || !i.record.previousCost) return null;
268
+ const s = i.record.previousCost.amount, v = i.record.cost.amount - s;
269
+ return {
270
+ amount: Math.abs(v),
271
+ precision: i.record.cost.precision,
272
+ currency: i.record.cost.currency,
273
+ isIncrease: v > 0
274
+ };
275
+ }), U = b(() => i.record ? {
276
+ default: "Default",
277
+ weightedAverage: "Weighted Average (WAVG)",
278
+ netsuite: "NetSuite",
279
+ "netsuite-average": "NetSuite Average"
280
+ }[i.record.mechanism] || i.record.mechanism : "");
281
+ b(() => {
282
+ var s;
283
+ return !((s = i.record) != null && s.meta) || i.record.mechanism !== "netsuite" ? null : i.record.meta;
284
+ });
285
+ function M() {
286
+ o.value = !0;
287
+ }
288
+ function x() {
289
+ o.value = !1;
290
+ }
291
+ return _({
292
+ open: M,
293
+ close: x
294
+ }), (s, a) => {
295
+ const v = L("FmMenuDivider"), $ = L("FmCard"), B = L("FmButton"), D = L("FmSideSheet");
296
+ return u(), T(D, {
297
+ "model-value": o.value,
298
+ "onUpdate:modelValue": a[0] || (a[0] = (R) => o.value = R),
299
+ header: "Unit Cost History Details",
300
+ "close-button": "",
301
+ "dismiss-away": "",
302
+ "max-width": 500
303
+ }, {
304
+ "side-sheet-footer": A(() => [
305
+ t("div", ot, [
306
+ p(B, {
307
+ variant: "tertiary",
308
+ onClick: x,
309
+ label: "Close"
310
+ })
311
+ ])
312
+ ]),
313
+ default: A(() => [
314
+ s.record ? (u(), g("div", Te, [
315
+ p($, {
316
+ variant: "outlined",
317
+ class: "flex flex-col gap-8 px-12 py-16"
318
+ }, {
319
+ default: A(() => {
320
+ var R, k;
321
+ return [
322
+ a[8] || (a[8] = t("div", { class: "flex justify-between" }, [
323
+ t("div", { class: "fm-typo-en-body-lg-600" }, "Details")
324
+ ], -1)),
325
+ p(v),
326
+ t("div", Me, [
327
+ t("div", ze, [
328
+ t("div", He, [
329
+ a[1] || (a[1] = t("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "Ingredient Code", -1)),
330
+ t("div", Ee, n((R = C.value) == null ? void 0 : R.code), 1)
331
+ ]),
332
+ t("div", Pe, [
333
+ a[2] || (a[2] = t("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "Ingredient Name", -1)),
334
+ t("div", Ke, n((k = C.value) == null ? void 0 : k.name), 1)
335
+ ]),
336
+ t("div", Oe, [
337
+ a[3] || (a[3] = t("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "New Cost", -1)),
338
+ t("div", Ye, [
339
+ H(n(r(j)(s.record.cost, !0, s.record.cost.precision)) + " ", 1),
340
+ m.value ? (u(), g("div", {
341
+ key: 0,
342
+ class: E(["fm-typo-en-body-md-600 flex items-center gap-4", {
343
+ "text-fm-color-system-success-500": m.value.isIncrease,
344
+ "text-fm-color-system-error-500": !m.value.isIncrease
345
+ }])
346
+ }, [
347
+ t("span", {
348
+ class: E({
349
+ "text-red-500": m.value.isIncrease,
350
+ "text-green-600": !m.value.isIncrease
351
+ })
352
+ }, n(m.value.isIncrease ? "↑" : "↓"), 3),
353
+ t("span", {
354
+ class: E({
355
+ "text-red-500": m.value.isIncrease,
356
+ "text-green-600": !m.value.isIncrease
357
+ })
358
+ }, n(m.value.isIncrease ? "Increase" : "Decrease"), 3)
359
+ ], 2)) : F("", !0)
360
+ ])
361
+ ]),
362
+ t("div", je, [
363
+ a[4] || (a[4] = t("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "Previous Cost", -1)),
364
+ t("div", Je, n(s.record.previousCost ? r(j)(
365
+ s.record.previousCost,
366
+ !0,
367
+ s.record.previousCost.precision
368
+ ) : "-"), 1)
369
+ ]),
370
+ t("div", We, [
371
+ a[5] || (a[5] = t("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "Mechanism", -1)),
372
+ t("div", Ge, n(U.value), 1)
373
+ ]),
374
+ t("div", Qe, [
375
+ a[6] || (a[6] = t("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "Snapshot At", -1)),
376
+ t("div", Xe, n(r(Y)(new Date(s.record.snapshotAt))) + " " + n(new Date(s.record.snapshotAt).toLocaleTimeString()), 1)
377
+ ]),
378
+ t("div", Ze, [
379
+ a[7] || (a[7] = t("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "Updated At", -1)),
380
+ t("div", qe, [
381
+ s.record.updatedAt ? (u(), g(O, { key: 0 }, [
382
+ H(n(r(Y)(new Date(s.record.updatedAt))) + " " + n(new Date(s.record.updatedAt).toLocaleTimeString()), 1)
383
+ ], 64)) : (u(), g(O, { key: 1 }, [
384
+ H("-")
385
+ ], 64))
386
+ ])
387
+ ])
388
+ ])
389
+ ])
390
+ ];
391
+ }),
392
+ _: 1
393
+ }),
394
+ p(ne, null, {
395
+ default: A(() => [
396
+ p($, {
397
+ variant: "outlined",
398
+ class: "flex flex-col gap-8 px-12 py-16"
399
+ }, {
400
+ default: A(() => [
401
+ a[9] || (a[9] = t("div", { class: "flex justify-between" }, [
402
+ t("div", { class: "fm-typo-en-body-lg-600" }, "Raw data")
403
+ ], -1)),
404
+ p(v),
405
+ t("div", et, [
406
+ t("pre", tt, n(JSON.stringify(s.record, null, 2)) + `
407
+ `, 1)
408
+ ])
409
+ ]),
410
+ _: 1
411
+ })
412
+ ]),
413
+ _: 1
414
+ })
415
+ ])) : F("", !0)
416
+ ]),
417
+ _: 1
418
+ }, 8, ["model-value"]);
419
+ };
420
+ }
421
+ }), ft = /* @__PURE__ */ Q({
422
+ __name: "UnitCostHistoryView",
423
+ setup(w) {
424
+ const { t: _ } = ee(), i = J(), d = Z(), o = q(), C = le(), { breakpoints: m } = ce(), U = b(() => m.value.xs || m.value.sm), M = b(() => U.value ? 10 : 20), x = h(), s = h(), a = h(null), { historyData: v, isLoading: $, fetchHistory: B } = ye(), D = h(""), R = b(() => [
425
+ {
426
+ type: "string",
427
+ key: "skuCode",
428
+ entity: "sku",
429
+ values: d.skus.map((e) => e.code)
430
+ },
431
+ {
432
+ type: "string",
433
+ key: "skuName",
434
+ entity: "sku",
435
+ values: d.skus.map((e) => e.name)
436
+ },
437
+ {
438
+ type: "string",
439
+ key: "mechanism",
440
+ entity: "sku",
441
+ values: ["weightedAverage", "netsuite", "netsuite-average"]
442
+ }
443
+ ]), k = h(null);
444
+ i.watchLocation(V);
445
+ async function V() {
446
+ if (i._currentLocation)
447
+ try {
448
+ await B();
449
+ } catch (l) {
450
+ o.open({
451
+ title: "Error",
452
+ message: "Failed to fetch unit cost history. Please try again.",
453
+ type: "error"
454
+ }), console.error("Error fetching unit cost history:", l);
455
+ }
456
+ }
457
+ const P = b(() => {
458
+ const l = /* @__PURE__ */ new Map();
459
+ for (const e of d.skus)
460
+ l.set(e._id, e);
461
+ return l;
462
+ }), K = b(() => {
463
+ let l = v.value;
464
+ if (k.value) {
465
+ const e = me.build(k.value);
466
+ l = l.filter((y) => {
467
+ const I = P.value.get(y.skuId);
468
+ return fe(
469
+ {
470
+ skuCode: (I == null ? void 0 : I.code) ?? y.skuId,
471
+ skuName: (I == null ? void 0 : I.name) ?? y.skuId,
472
+ mechanism: y.mechanism
473
+ },
474
+ e
475
+ );
476
+ });
477
+ }
478
+ return l.map((e) => {
479
+ const y = P.value.get(e.skuId);
480
+ return {
481
+ ...e,
482
+ skuCode: (y == null ? void 0 : y.code) ?? e.skuId,
483
+ skuName: (y == null ? void 0 : y.name) ?? "Unknown SKU"
484
+ };
485
+ });
486
+ }), W = b(() => [
487
+ {
488
+ accessorKey: "snapshotAt",
489
+ header: () => "Snapshot At",
490
+ cell: (l) => {
491
+ const e = new Date(l.row.original.snapshotAt);
492
+ return Y(e) + " " + e.toLocaleTimeString();
493
+ },
494
+ enableSorting: !0,
495
+ size: 180
496
+ },
497
+ {
498
+ accessorKey: "skuCode",
499
+ header: () => "SKU Code",
500
+ enableSorting: !0,
501
+ size: 150
502
+ },
503
+ {
504
+ accessorKey: "skuName",
505
+ header: () => "SKU Name",
506
+ enableSorting: !0,
507
+ size: "auto"
508
+ },
509
+ {
510
+ accessorKey: "previousCost",
511
+ header: () => "Previous Cost",
512
+ cell: (l) => {
513
+ const e = l.row.original.previousCost;
514
+ return e ? j(e, !1, e.precision) : "-";
515
+ },
516
+ enableSorting: !1,
517
+ size: 150
518
+ },
519
+ {
520
+ accessorKey: "cost",
521
+ header: () => "Current Cost",
522
+ cell: (l) => {
523
+ const e = l.row.original.cost;
524
+ return e ? j(e, !1, e.precision) : "-";
525
+ },
526
+ enableSorting: !1,
527
+ size: 150
528
+ },
529
+ {
530
+ accessorKey: "mechanism",
531
+ header: () => "Mechanism",
532
+ cell: (l) => {
533
+ const e = l.row.original.mechanism;
534
+ return {
535
+ default: "Default",
536
+ weightedAverage: "Weighted Average",
537
+ netsuite: "NetSuite",
538
+ "netsuite-average": "NetSuite Average"
539
+ }[e] ?? e;
540
+ },
541
+ enableSorting: !0,
542
+ size: 150
543
+ },
544
+ {
545
+ accessorKey: "updatedAt",
546
+ header: () => "Updated At",
547
+ cell: (l) => {
548
+ const e = l.row.original.updatedAt;
549
+ if (!e) return "-";
550
+ const y = new Date(e);
551
+ return Y(y) + " " + y.toLocaleTimeString();
552
+ },
553
+ enableSorting: !0,
554
+ size: 180
555
+ }
556
+ ]), f = b(() => [
557
+ {
558
+ label: "Recalculate Cost History",
559
+ value: "recalculate",
560
+ isPrimary: !0,
561
+ prependIcon: "calculate",
562
+ isAdminOnly: !0
563
+ },
564
+ {
565
+ label: _("inventory.common.refresh"),
566
+ value: "refresh"
567
+ }
568
+ ]);
569
+ function c() {
570
+ var l;
571
+ (l = x.value) == null || l.open();
572
+ }
573
+ function S() {
574
+ V();
575
+ }
576
+ function N(l) {
577
+ var e;
578
+ a.value = l, (e = s.value) == null || e.open();
579
+ }
580
+ function G(l) {
581
+ switch (l) {
582
+ case "recalculate":
583
+ return c();
584
+ case "refresh":
585
+ return V();
586
+ }
587
+ }
588
+ return (l, e) => {
589
+ const y = L("FmTable");
590
+ return u(), T(re, {
591
+ title: "Unit Cost History",
592
+ actions: f.value,
593
+ "onClick:action": G
594
+ }, {
595
+ default: A(() => {
596
+ var I;
597
+ return [
598
+ t("div", {
599
+ class: E([
600
+ "flex flex-col gap-8 max-h-full",
601
+ {
602
+ "p-0": U.value,
603
+ "px-24": !U.value
604
+ }
605
+ ])
606
+ }, [
607
+ p(ue, {
608
+ searchable: "",
609
+ "change-location": "",
610
+ search: D.value,
611
+ "onUpdate:search": e[0] || (e[0] = (z) => D.value = z),
612
+ filterable: "",
613
+ "filter-attributes": R.value,
614
+ filter: k.value,
615
+ "onUpdate:filter": e[1] || (e[1] = (z) => k.value = z)
616
+ }, null, 8, ["search", "filter-attributes", "filter"]),
617
+ (u(), T(y, {
618
+ key: `${(I = r(i)._currentLocation) == null ? void 0 : I.dbName}-${JSON.stringify(k.value)}`,
619
+ style: ae(r(C).tableHeight),
620
+ "column-defs": W.value,
621
+ "row-data": K.value,
622
+ "search-value": D.value,
623
+ loading: r($) || !r(i)._currentLocation,
624
+ "page-size": M.value,
625
+ onRowClick: e[2] || (e[2] = (z) => N(z.original))
626
+ }, null, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
627
+ ], 2),
628
+ (u(), T(X, { to: "body" }, [
629
+ p(Ve, {
630
+ ref_key: "recalculationDialogRef",
631
+ ref: x,
632
+ onSubmitted: S
633
+ }, null, 512)
634
+ ])),
635
+ (u(), T(X, { to: "body" }, [
636
+ p(st, {
637
+ ref_key: "detailsSideSheetRef",
638
+ ref: s,
639
+ record: a.value
640
+ }, null, 8, ["record"])
641
+ ]))
642
+ ];
643
+ }),
644
+ _: 1
645
+ }, 8, ["actions"]);
646
+ };
647
+ }
648
+ });
649
+ export {
650
+ ft as default
651
+ };