@feedmepos/mf-inventory-portal 1.8.0-dev.17 → 1.8.0-dev.18

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 (101) hide show
  1. package/dist/{App-CRmKXhRV.js → App-Djr9dJ9q.js} +9 -9
  2. package/dist/{ApprovalView-tDkNN-Cd.js → ApprovalView-VIVSr66P.js} +9 -9
  3. package/dist/{BindingsDialog-DrB0U9F6.js → BindingsDialog-NKiZKKA1.js} +2 -2
  4. package/dist/{BindingsPicker-tjjgijNe.js → BindingsPicker-WLdfNtim.js} +2 -2
  5. package/dist/{BindingsTable-D7EGgWxE.js → BindingsTable-DGikPjdP.js} +10 -10
  6. package/dist/{BulkReceiveRequestPage-B7GEE9qI.js → BulkReceiveRequestPage-GmZ7yxnK.js} +21 -21
  7. package/dist/{ChangeLocationComponent.vue_vue_type_script_setup_true_lang-B4j6Acmo.js → ChangeLocationComponent.vue_vue_type_script_setup_true_lang-6n-R2gAL.js} +1 -1
  8. package/dist/{ClosingDraftView-DH0eBMZ8.js → ClosingDraftView-Biir_xEx.js} +19 -19
  9. package/dist/{ClosingHistoryView-FmdYCiLI.js → ClosingHistoryView-ZMXQesn4.js} +7 -7
  10. package/dist/{ClosingTemplateView-BGmFG2-y.js → ClosingTemplateView-B-c3FkLX.js} +18 -18
  11. package/dist/{CustomPrintTemplatePreview.vue_vue_type_script_setup_true_lang-DHboInU_.js → CustomPrintTemplatePreview.vue_vue_type_script_setup_true_lang-D2bp6pW-.js} +1 -1
  12. package/dist/{DefaultView-CsNlHUlf.js → DefaultView-D_Jhtw_c.js} +2 -2
  13. package/dist/{DeliveryOrderPrintPreview-CMe2DpP1.js → DeliveryOrderPrintPreview-D5-9lzBd.js} +9 -9
  14. package/dist/{EmailDialog.vue_vue_type_script_setup_true_lang-Yen9u78U.js → EmailDialog.vue_vue_type_script_setup_true_lang-DEqUAhaS.js} +23 -23
  15. package/dist/{FeatureCapabilityBadge.vue_vue_type_script_setup_true_lang-BJy8_H2s.js → FeatureCapabilityBadge.vue_vue_type_script_setup_true_lang-CCzJ6Awz.js} +1 -1
  16. package/dist/{FeatureCapabilityGate-DN8b1697.js → FeatureCapabilityGate-iW8fvX19.js} +28 -28
  17. package/dist/{FeaturePageGate.vue_vue_type_script_setup_true_lang-DmNFZYam.js → FeaturePageGate.vue_vue_type_script_setup_true_lang-f3Y9lCSv.js} +1 -1
  18. package/dist/{FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-2zOATqzb.js → FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-1mVLSzDy.js} +1 -1
  19. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CVBUkN02.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-D6jnR8Rx.js} +2 -2
  20. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BuE-1qd6.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-tMoK_Ce8.js} +2 -2
  21. package/dist/{FmMultiselectDialog-C3B8pd2Z.js → FmMultiselectDialog-B8P_qEAQ.js} +2 -2
  22. package/dist/{FmMultiselectDialog-LI5ekHzQ.js → FmMultiselectDialog-DP480e0e.js} +2 -2
  23. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-DQZ7aJGJ.js → FmUnitInput.vue_vue_type_script_setup_true_lang-D7pb8F_A.js} +5 -5
  24. package/dist/{ImportView-DYoeJLdr.js → ImportView-BISXn7Th.js} +6 -6
  25. package/dist/{IngredientsView-u3KHfALO.js → IngredientsView-C3LrzIuS.js} +15 -15
  26. package/dist/{IntegrationExplorerView-Bl0Z8sxM.js → IntegrationExplorerView-B_4Af6OW.js} +6 -6
  27. package/dist/{IntegrationPlatformView-CybBB3RA.js → IntegrationPlatformView-CQUi7sRi.js} +2 -2
  28. package/dist/{IntegrationView-Dxy7QhCp.js → IntegrationView-CYkZq_tq.js} +14 -14
  29. package/dist/{InventoryBindingForm-DyUvyOsa.js → InventoryBindingForm-D2s_z-6Q.js} +1 -1
  30. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-Dmch1sfA.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-DXsyVclI.js} +4 -4
  31. package/dist/{InventoryBindingSummary-DwY3vUf_.js → InventoryBindingSummary-BOBGDwSm.js} +1 -1
  32. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-B2UtnJtf.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-gAd41m7W.js} +2 -2
  33. package/dist/{ProductionRunDetailPage-Cdi4hv3E.js → ProductionRunDetailPage-COncuigP.js} +4 -4
  34. package/dist/{ProductionRunLifecycleDialogs.vue_vue_type_script_setup_true_lang-D5jlF5x4.js → ProductionRunLifecycleDialogs.vue_vue_type_script_setup_true_lang-B3PSF7-H.js} +8 -8
  35. package/dist/{ProductionRunPage-RcbHy0Mj.js → ProductionRunPage-RUkgXlmL.js} +4 -4
  36. package/dist/{PublishView-CyJ_rE-5.js → PublishView-B0QVNasT.js} +3 -3
  37. package/dist/{PurchaseOrderPrintPreview-ZlbV3YfE.js → PurchaseOrderPrintPreview-CbjbKRS2.js} +13 -13
  38. package/dist/{ReceiveRequestView-BKz8N6yK.js → ReceiveRequestView-DAiOgbUO.js} +13 -13
  39. package/dist/{RecipeView-D3IEyQoK.js → RecipeView-B-Qr9p-i.js} +15 -15
  40. package/dist/{SettingsView-A0eozTq3.js → SettingsView-BnWul5uf.js} +7 -7
  41. package/dist/StockView-raj4WifG.js +2756 -0
  42. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-CD11VzXa.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-CYLgevQO.js} +1 -1
  43. package/dist/{SupplierView-Cg60vwsj.js → SupplierView-CxAwhXEg.js} +13 -13
  44. package/dist/{SurchargeView-Dxvg-RnC.js → SurchargeView-B7R7_JVv.js} +7 -7
  45. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-DDLGEaa2.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-CrYxhm0y.js} +2 -2
  46. package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-DfYoaT5a.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-BSglNZaK.js} +1 -1
  47. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-D3wClK8t.js → TransferDetails.vue_vue_type_script_setup_true_lang-CoOidQMw.js} +809 -788
  48. package/dist/{TransferTemplateView-DfCJzLHt.js → TransferTemplateView-BXu5OhXF.js} +19 -19
  49. package/dist/{UnitCostHistoryView-BkNnwNUc.js → UnitCostHistoryView-BAfxgkjF.js} +4 -4
  50. package/dist/{UnitDisplayControl.vue_vue_type_script_setup_true_lang-Clufqvr_.js → UnitDisplayControl.vue_vue_type_script_setup_true_lang-DTS06g9i.js} +4 -4
  51. package/dist/{UnitView-D_agG3Kd.js → UnitView-BnCe1kBW.js} +7 -7
  52. package/dist/{WarehouseView-DE_CaJCb.js → WarehouseView-D3y9EDWW.js} +8 -8
  53. package/dist/{WastageTemplateView-r3b6angy.js → WastageTemplateView-BShli8bj.js} +15 -15
  54. package/dist/{app-CLTXsVH_.js → app-FPg0KzwG.js} +23668 -25024
  55. package/dist/app.d.ts +1 -0
  56. package/dist/app.js +1 -1
  57. package/dist/{closing-template-yP6QT_6M.js → closing-template-Db-KNAjB.js} +1 -1
  58. package/dist/components/FeatureCapabilityGate.vue.d.ts +1 -0
  59. package/dist/{date2-9jq_OKuv.js → date2-YICloR2o.js} +1 -1
  60. package/dist/{dayjs.min-CAxu5-hQ.js → dayjs.min-CefWSTKK.js} +1 -1
  61. package/dist/{decimal-BhGvDuWQ.js → decimal-CBsXxlpr.js} +2 -2
  62. package/dist/defineDeepModel-DdUeiux0.js +19 -0
  63. package/dist/{duplicate-template-X72Zob-u.js → duplicate-template-BvMZ2ilL.js} +1 -1
  64. package/dist/{feature-CC2pF6VK.js → feature-HJuftceg.js} +2 -2
  65. package/dist/{format-time-from-id-DhZOfLN4.js → format-time-from-id-BUJJn9WM.js} +1 -1
  66. package/dist/{format-unit-display-BalKqHYj.js → format-unit-display-vkauUh5a.js} +12 -12
  67. package/dist/{id-to-date-Cb9v4BtX.js → id-to-date-BFOeIS4x.js} +1 -1
  68. package/dist/{import-export.helper-9D5DLoaq.js → import-export.helper-C48DsrFq.js} +5 -5
  69. package/dist/{index-CnjRz458.js → index--e5sOJ5N.js} +3 -3
  70. package/dist/{index-B0T8iGU6.js → index-4EWcUZB2.js} +1 -1
  71. package/dist/{index-DqV626Os.js → index-COy6Gu_M.js} +1 -1
  72. package/dist/{lz-string-CK_kK0b8.js → lz-string-CX9VutYB.js} +1 -1
  73. package/dist/{netsuite-Czq6x14E.js → netsuite-BOb6Ek6I.js} +247 -262
  74. package/dist/{netsuite-explorer-BugWV6N7.js → netsuite-explorer-Czbq3dDh.js} +1 -1
  75. package/dist/{predefined-templates-D5qjNE4o.js → predefined-templates-Cb97vyso.js} +1 -1
  76. package/dist/{purchase-order-template-Bc0QP-bq.js → purchase-order-template-CBjU0dUO.js} +1 -1
  77. package/dist/{recalculationUtils-CJknKvb-.js → recalculationUtils-CyoKTNie.js} +1 -1
  78. package/dist/{row-action.enum-Cz1k6Kht.js → row-action.enum-DoY1An1e.js} +1 -1
  79. package/dist/{rules-BQscySfb.js → rules-C23j4F0_.js} +3 -3
  80. package/dist/{stock--68mu-M1.js → stock-CN-acijK.js} +1 -1
  81. package/dist/stock-DClY4hP_.js +78 -0
  82. package/dist/style.css +1 -1
  83. package/dist/{supplier-U06ZrnoC.js → supplier-OCIcWTkA.js} +2 -2
  84. package/dist/{surcharge-B5DGPlf5.js → surcharge-CCqME8iu.js} +1 -1
  85. package/dist/tsconfig.app.tsbuildinfo +1 -1
  86. package/dist/{uom-rules-DfBYytl6.js → uom-rules-DyRkdoii.js} +1 -1
  87. package/dist/{use-ingredient-select-dialog-BRTxaEaQ.js → use-ingredient-select-dialog-B9SD-Gfg.js} +2 -2
  88. package/dist/{use-inventory-binding-dialog-DQDv8yOS.js → use-inventory-binding-dialog-Dx8nYVH0.js} +2 -2
  89. package/dist/{use-template-enabled-locations-DzQVNhev.js → use-template-enabled-locations-C7vIH0p-.js} +2 -2
  90. package/dist/{use-transfer-locations-CGvKssyQ.js → use-transfer-locations-DfZI178Y.js} +2 -2
  91. package/dist/{useHrmPermission-BkOtYcLu.js → useHrmPermission-BF87diqS.js} +1 -1
  92. package/dist/{useNavigationMenu-korDNdFf.js → useNavigationMenu-hmVbINp6.js} +4 -4
  93. package/dist/{useSseClient-BjoRcYKu.js → useSseClient-D-dJYaOl.js} +1 -1
  94. package/dist/views/stock/components/StockRecordCard.vue.d.ts +16 -2
  95. package/dist/{vue-hPU91AHR.js → vue-_3HY6f-w.js} +2 -2
  96. package/dist/{vue-i18n-VFYpKHHB.js → vue-i18n-B8eq3KRC.js} +1 -1
  97. package/dist/{xlsx.util-VlHt05TU.js → xlsx.util-BbyZEE1S.js} +2 -2
  98. package/package.json +5 -5
  99. package/dist/StockView-DrxkHTH4.js +0 -2651
  100. package/dist/defineDeepModel-Czbczabc.js +0 -19
  101. package/dist/stock-DCz3ZTmd.js +0 -74
@@ -1,2651 +0,0 @@
1
- import { defineComponent as ve, createElementBlock as K, openBlock as V, createElementVNode as e, createVNode as k, toDisplayString as p, unref as l, ref as O, h as be, computed as T, watch as Fe, resolveComponent as C, createBlock as J, isRef as Te, withCtx as M, Fragment as le, renderList as fe, createCommentVNode as ne, normalizeClass as Ee, reactive as pt, mergeModels as tt, useModel as $t, onMounted as We, createTextVNode as me, normalizeStyle as yt, watchEffect as jt, renderSlot as ot, onUnmounted as Vt, Teleport as Bt, normalizeProps as nt, mergeProps as Le } from "vue";
2
- import { u as Ct, _ as Dt } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-DpwneGOV.js";
3
- import { u as xe, c as Pe, a as Ue, F as st, v as Mt, s as Y, E as re, t as It, d as Et, B as Ht, h as Be, i as at, e as rt, M as ge, O as Ce } from "./app-CLTXsVH_.js";
4
- import { u as Re } from "./stock-DCz3ZTmd.js";
5
- import { c as Tt } from "./component-BmLAdDiY.js";
6
- import { _ as _t, o as Pt } from "./UnitDisplayControl.vue_vue_type_script_setup_true_lang-Clufqvr_.js";
7
- import { _ as Ge, S as Ye, g as kt, a as Ut } from "./SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-CD11VzXa.js";
8
- import { _ as Rt } from "./FeatureCapabilityBadge.vue_vue_type_script_setup_true_lang-BJy8_H2s.js";
9
- import { useI18n as pe, useCoreStore as Ke } from "@feedmepos/mf-common";
10
- import { u as ht, i as He } from "./id-to-date-Cb9v4BtX.js";
11
- import { useSnackbar as Se, useDialog as Ne, useProxiedModel as Oe, useBreakpoints as Nt } from "@feedmepos/ui-library";
12
- import { defineStore as Ot } from "pinia";
13
- import { F as qe } from "./FmAdminBadge-DlplQOHb.js";
14
- import { g as $e, a as he, h as Lt, t as je, I as lt, f as Xe, A as Yt, M as zt, i as Gt, j as it, k as bt, l as Je, R as Wt, d as Me, m as Kt } from "./rules-BQscySfb.js";
15
- import { u as we } from "./stock--68mu-M1.js";
16
- import { u as qt } from "./use-inventory-binding-dialog-DQDv8yOS.js";
17
- import { a as gt } from "./FmMultiselectDialog-LI5ekHzQ.js";
18
- import { d as ke } from "./dayjs.min-CAxu5-hQ.js";
19
- import { _ as Xt } from "./NumberPrecisionInput.vue_vue_type_script_setup_true_lang-B2UtnJtf.js";
20
- import { g as Jt } from "./decimal-BhGvDuWQ.js";
21
- import { b as Qt, d as Zt, f as xt, t as ut, a as ct, p as eo, n as to, c as oo } from "./date2-9jq_OKuv.js";
22
- import { i as no } from "./FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-2zOATqzb.js";
23
- import { _ as so } from "./empty-placeholder-B0QU467o.js";
24
- import { F as St } from "./FeatureCapabilityGate-DN8b1697.js";
25
- import "./feature-CC2pF6VK.js";
26
- import { u as wt } from "./useHrmPermission-BkOtYcLu.js";
27
- import { F as dt } from "./index-eGvSlWMU.js";
28
- import { _ as ao } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-gJQQKKAC.js";
29
- import { _ as ro } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BuE-1qd6.js";
30
- import { u as lo } from "./useSseClient-BjoRcYKu.js";
31
- import { u as io } from "./netsuite-Czq6x14E.js";
32
- import { P as uo, J as co } from "./app-C39bYJmq.js";
33
- var Ie = /* @__PURE__ */ ((A) => (A.History = "History", A.Convert = "Convert", A.Adjust = "Adjust", A))(Ie || {});
34
- const mo = [
35
- {
36
- translationKey: "inventory.stock.action.history",
37
- color: "text-neutral-700",
38
- value: "History"
39
- /* History */
40
- }
41
- ], fo = [
42
- {
43
- translationKey: "inventory.stock.action.history",
44
- color: "text-neutral-700",
45
- value: "History"
46
- /* History */
47
- },
48
- {
49
- translationKey: "inventory.stock.action.convert",
50
- color: "text-neutral-700",
51
- value: "Convert"
52
- /* Convert */
53
- },
54
- {
55
- translationKey: "inventory.stock.action.adjust",
56
- color: "text-neutral-700",
57
- value: "Adjust"
58
- /* Adjust */
59
- }
60
- ], vo = { class: "flex items-center gap-8" }, po = { class: "whitespace-nowrap" }, yo = /* @__PURE__ */ ve({
61
- __name: "StockHeaderPreview",
62
- setup(A) {
63
- const { t: d } = pe();
64
- return (b, _) => (V(), K("div", vo, [
65
- e("div", po, p(l(d)("inventory.stock.prediction.daysRemaining")), 1),
66
- k(Rt, {
67
- tier: "standard",
68
- category: "beta"
69
- })
70
- ]));
71
- }
72
- }), At = Ot("stockActions", () => {
73
- const A = O(!1), d = xe(), b = Re(), _ = ht(), S = Se(), j = Ne(), { t: i } = pe();
74
- async function m() {
75
- if (d._currentLocation) {
76
- A.value = !0;
77
- try {
78
- await b.readStockBalance(), await b.readProductBalance(), await _.readStockEstimateBalance();
79
- } catch {
80
- S.open({
81
- title: i("inventory.stock.error.title"),
82
- message: i("inventory.stock.error.message"),
83
- type: "error"
84
- });
85
- } finally {
86
- A.value = !1;
87
- }
88
- }
89
- }
90
- const B = O();
91
- async function z(h) {
92
- var $, P, G;
93
- if (!!!((P = ($ = h.convert) == null ? void 0 : $.inventoryBindings) != null && P.length)) {
94
- j.open({
95
- title: i("inventory.stock.error.convert.title"),
96
- message: i("inventory.stock.error.convert.message")
97
- });
98
- return;
99
- }
100
- const a = {
101
- maxCount: ((G = b.productBalance.find(({ id: E }) => E === h._id)) == null ? void 0 : G.count) || 0,
102
- sku: h,
103
- show: !0,
104
- "onUpdate:show"(E) {
105
- B.value.show = E;
106
- },
107
- onSubmitted() {
108
- m();
109
- }
110
- };
111
- B.value = a;
112
- }
113
- const F = O();
114
- async function v(h) {
115
- const o = {
116
- stock: h,
117
- show: !0,
118
- "onUpdate:show"(t) {
119
- F.value.show = t;
120
- },
121
- onSubmitted() {
122
- m();
123
- }
124
- };
125
- F.value = o;
126
- }
127
- const r = O();
128
- async function x(h) {
129
- const o = {
130
- sku: h,
131
- show: !0,
132
- "onUpdate:show"(t) {
133
- r.value.show = t;
134
- }
135
- };
136
- r.value = o;
137
- }
138
- function w(h, o) {
139
- const t = Pe(o);
140
- switch (h) {
141
- case Ie.History:
142
- x(t);
143
- return;
144
- case Ie.Convert:
145
- z(t);
146
- return;
147
- case Ie.Adjust:
148
- v(t);
149
- return;
150
- }
151
- }
152
- return {
153
- fetchStockBalance: m,
154
- onActionMenu: w,
155
- stockHistoryProps: r,
156
- showSkuHistory: x,
157
- convertSkuDialogProps: B,
158
- adjustSkuDialogProps: F
159
- };
160
- });
161
- function _o() {
162
- var j;
163
- const A = xe(), d = At(), b = Ke(), { t: _ } = pe();
164
- return {
165
- columnDefs: [
166
- {
167
- accessorKey: "code",
168
- header: () => _("inventory.stock.code"),
169
- enableSorting: !0,
170
- size: 300
171
- },
172
- {
173
- accessorKey: "name",
174
- header: () => _("inventory.stock.product"),
175
- enableSorting: !0,
176
- size: "auto"
177
- },
178
- {
179
- id: "UOM",
180
- header: () => _("inventory.stock.balance"),
181
- cell(i) {
182
- const m = i.row.original, B = {
183
- unit: m.unit,
184
- sku: m,
185
- amount: m.balance,
186
- defaultTrackingMeasurement: m.trackingMeasurement ?? void 0
187
- };
188
- return be(_t, B);
189
- },
190
- size: 180
191
- },
192
- ...(j = b.sessionUser.value) != null && j.role.isAdmin ? [
193
- {
194
- accessorKey: "isInactive",
195
- header: () => be(qe, {}, () => `${_("inventory.ingredient.status.title")}`),
196
- cell(i) {
197
- const m = i.row.original.isInactive;
198
- return be(
199
- "span",
200
- {
201
- class: [
202
- "inline-block px-3 py-1 rounded-full text-xs font-semibold",
203
- m ? "bg-red-100 text-red-700" : "bg-green-100 text-green-700"
204
- ].join(" ")
205
- },
206
- _(m ? "inventory.ingredient.status.inactive" : "inventory.ingredient.status.active")
207
- );
208
- },
209
- enableSorting: !0
210
- }
211
- ] : [],
212
- {
213
- accessorKey: "day",
214
- id: "expireDate",
215
- header: () => be(yo),
216
- enableSorting: !0,
217
- sortUndefined: "last",
218
- cell(i) {
219
- var x, w;
220
- const m = i.row.original.day, B = i.row.original.operator, z = (x = i.row.original.thresholds) == null ? void 0 : x.low, F = (w = i.row.original.thresholds) == null ? void 0 : w.mid;
221
- if (typeof m != "number" || typeof z != "number" || typeof F != "number")
222
- return be(Ge, {
223
- days: m,
224
- operator: B
225
- });
226
- const v = m <= z ? Ye.low : m <= F ? Ye.mid : Ye.high;
227
- return be(Ge, {
228
- days: m,
229
- level: v
230
- });
231
- },
232
- size: 200
233
- },
234
- {
235
- id: "action",
236
- cell(i) {
237
- var m;
238
- return Tt(
239
- ((m = A._currentLocation) == null ? void 0 : m.type) === "restaurant" ? mo : fo,
240
- (B) => d.onActionMenu(B, i.row.original)
241
- );
242
- },
243
- enableSorting: !1,
244
- size: 40,
245
- meta: {
246
- cellClass: "",
247
- headerClass: ""
248
- }
249
- }
250
- ]
251
- };
252
- }
253
- const ko = {
254
- context: null,
255
- error: null,
256
- isRequired(A = "This field is required") {
257
- return `${this.context ?? ""}`.length === 0 && (this.error = A), this;
258
- },
259
- isString(A = "Must be a valid string") {
260
- return this.error ? this : (typeof this.context != "string" && (this.error ?? (this.error = A)), this);
261
- },
262
- toInt() {
263
- return this.error ? this : (this.context = +this.context, this);
264
- },
265
- isInteger(A = "Must be an integer") {
266
- return this.error ? this : (this.toInt(), isNaN(this.context) && (this.error = A), this);
267
- },
268
- min(A, d) {
269
- if (this.error) return this;
270
- try {
271
- typeof this.context == "number" ? +this.context < A && (this.error = d ?? `Must be at least ${A}`) : Object.prototype.hasOwnProperty.call(this.context, "length") ? +this.context.length < A && (this.error = d ?? `Must be at least ${A}`) : this.error = "Length cannot be determined";
272
- } catch {
273
- this.error = "Length cannot be determined";
274
- }
275
- return this;
276
- },
277
- max(A, d) {
278
- if (this.error) return this;
279
- try {
280
- typeof this.context == "number" ? +this.context > A && (this.error = d ?? `Must be at most ${A}`) : "length" in this.context ? +this.context.length > A && (this.error = d ?? `Must be at most ${A}`) : this.error = "Length cannot be determined";
281
- } catch {
282
- this.error = "Length cannot be determined";
283
- }
284
- return this;
285
- }
286
- };
287
- function mt(A) {
288
- return { ...ko, context: A };
289
- }
290
- const ho = { class: "flex items-center" }, bo = { class: "fm-typo-en-title-md-800" }, go = { class: "flex flex-col gap-24 w-full" }, xo = { class: "flex flex-col gap-8" }, So = { class: "fm-typo-en-body-lg-600" }, wo = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary flex-grow" }, Ao = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-error" }, Fo = { class: "flex flex-col p-16 gap-8" }, $o = { class: "flex flex-col gap-4" }, jo = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary bg-fm-color-neutral-gray-100 border-b py-12 px-16" }, Vo = { class: "grid grid-cols-[auto_100px_100px_48px] xs:grid-cols-[auto_80px_120px_48px] gap-8 px-8 items-center" }, Bo = { class: "xs:col-span-3" }, Co = { class: "flex gap-8" }, Do = /* @__PURE__ */ ve({
291
- __name: "ConvertSkuDialog",
292
- props: {
293
- sku: {},
294
- maxCount: {},
295
- show: { type: Boolean }
296
- },
297
- emits: ["update:show", "submitted"],
298
- setup(A, { expose: d, emit: b }) {
299
- const _ = A, S = b, j = qt(), i = Ue(), m = we(), B = Se(), { t: z } = pe(), F = O(0), v = O(null), r = T(() => i.skus), x = T(
300
- () => {
301
- var y, n;
302
- return (((n = (y = _.sku) == null ? void 0 : y.convert) == null ? void 0 : n.inventoryBindings) ?? []).filter(
303
- (u) => u.type === st.enum.SKU
304
- );
305
- }
306
- ), w = T({
307
- get() {
308
- return !!v.value;
309
- },
310
- set(y) {
311
- y ? v.value = Pe(x.value) : (v.value = null, o.value = {}, F.value = Math.min(F.value, _.maxCount ?? 0));
312
- }
313
- }), h = O(!1);
314
- Fe([() => _.show], ([y]) => {
315
- y && (F.value = 0);
316
- });
317
- const o = O({});
318
- function t(y) {
319
- return String(y ?? "").trim().length === 0;
320
- }
321
- function a(y) {
322
- if (t(y)) return "Required";
323
- const n = lt()(String(y));
324
- return n !== !0 ? n : Number(y) >= 0 || "Must be zero or greater";
325
- }
326
- function $(y) {
327
- const n = { ...o.value };
328
- delete n[y], o.value = n;
329
- }
330
- function P() {
331
- if (v.value && (Object.keys(o.value).length > 0 || v.value.some((y) => y.amount.amount < 0))) {
332
- B.open({
333
- title: "Invalid amount",
334
- message: "Please correct the highlighted ingredient amounts.",
335
- type: "error"
336
- });
337
- return;
338
- }
339
- H(_.sku, je(F.value), v.value);
340
- }
341
- function G(y) {
342
- if (v.value)
343
- return !0;
344
- const n = mt(y).isInteger().max(_.maxCount ?? 0).error ?? "";
345
- return n || !0;
346
- }
347
- function E(y) {
348
- var c;
349
- const n = (c = _.sku.convert) != null && c.measurement ? _.sku.unit.measurements.find((g) => {
350
- var R;
351
- return g.id === ((R = _.sku.convert) == null ? void 0 : R.measurement);
352
- }) ?? null : null, u = $e(_.sku.unit, n), f = Gt(+y);
353
- return mt(f).isInteger().max(u).error ? "Precision cannot be more than " + u : !0;
354
- }
355
- const U = T(
356
- () => {
357
- var y, n;
358
- return (y = _.sku.convert) != null && y.measurement ? (n = _.sku.unit.measurements.find((u) => {
359
- var f;
360
- return u.id === ((f = _.sku.convert) == null ? void 0 : f.measurement);
361
- })) == null ? void 0 : n.abbrev : _.sku.unit.abbrev;
362
- }
363
- ), q = T(() => {
364
- var f, s;
365
- const n = Mt({
366
- bindings: ((f = _.sku.convert) == null ? void 0 : f.inventoryBindings) ?? [],
367
- skus: i.skus,
368
- skuGroups: [],
369
- recipes: i.recipes
370
- }).inventoryBindings.filter((c) => "success" in c && c.success).map((c) => c).map((c) => c.binding);
371
- return (s = v.value ?? n) == null ? void 0 : s.map((c) => {
372
- var Q, ie, oe, de, se;
373
- const g = i.skus.find((_e) => _e._id === c.id), R = ((Q = c.measurement) == null ? void 0 : Q.abbrev) ?? ((ie = g == null ? void 0 : g.unit) == null ? void 0 : ie.abbrev), Z = (oe = _.sku.convert) != null && oe.measurement ? _.sku.unit.measurements.find((_e) => {
374
- var Ae;
375
- return _e.id === ((Ae = _.sku.convert) == null ? void 0 : Ae.measurement);
376
- }) ?? null : null, ee = $e(_.sku.unit, Z), D = E(`${F.value}`) === !0 ? he(
377
- Lt(
378
- c.amount,
379
- je(+F.value, ee)
380
- ),
381
- !1
382
- ) : "0", W = (se = (de = v.value) == null ? void 0 : de.find((_e) => _e.id === (g == null ? void 0 : g._id))) == null ? void 0 : se.amount, N = W ? he(W, !1) : null;
383
- return {
384
- sku: g,
385
- convertAmount: N ?? D,
386
- abbrev: R
387
- };
388
- });
389
- }), I = O();
390
- d({
391
- validateInputs: () => {
392
- var y, n;
393
- (n = (y = I.value) == null ? void 0 : y.validateInputs) == null || n.call(y);
394
- },
395
- resetInputsValidation: () => {
396
- var y, n;
397
- (n = (y = I.value) == null ? void 0 : y.resetInputsValidation) == null || n.call(y);
398
- },
399
- resetInputs: () => {
400
- var y, n;
401
- (n = (y = I.value) == null ? void 0 : y.resetInputs) == null || n.call(y);
402
- }
403
- });
404
- const L = Oe(_, "show");
405
- async function H(y, n, u) {
406
- h.value = !0;
407
- try {
408
- await m.convertSku({
409
- conversions: [
410
- {
411
- doc: y,
412
- amount: n,
413
- overrides: u == null ? void 0 : u.map((f) => ({
414
- ...f,
415
- amount: {
416
- ...f.amount,
417
- amount: -1 * Math.abs(f.amount.amount)
418
- // ensure truly negative
419
- }
420
- }))
421
- }
422
- ]
423
- }), S("update:show", !1), S("submitted");
424
- } catch (f) {
425
- B.open({
426
- title: "Something went wrong",
427
- message: `Cannot convert ${y.name}. Please try again.`,
428
- type: "error"
429
- }), console.error("error at converting stock amount", y, n, f);
430
- } finally {
431
- h.value = !1;
432
- }
433
- }
434
- function X(y, n, u) {
435
- if (a(n) !== !0) {
436
- o.value = { ...o.value, [y]: n };
437
- return;
438
- }
439
- $(y);
440
- const f = +n;
441
- v.value = u.map((s) => (s.id !== y || (s.amount = Y.fromNumber(f)), s));
442
- }
443
- function te(y) {
444
- const n = r.value.find((u) => u._id === y);
445
- return n ? kt(n.unit, !0) : [];
446
- }
447
- function ue(y, n) {
448
- const u = te(y), f = u.find((s) => s.value === n) ?? u.find((s) => s.value === null);
449
- return f ? {
450
- ...f,
451
- label: f.abbrev
452
- } : null;
453
- }
454
- function ce(y, n, u) {
455
- let f;
456
- if (n === null)
457
- f = u.map((s) => (s.id !== y || (s.measurement = null), s)) ?? [];
458
- else {
459
- const s = r.value.find((c) => c._id === y);
460
- f = u.map((c) => {
461
- var g, R;
462
- return c.id !== y || (c.measurement = (R = (g = s == null ? void 0 : s.unit) == null ? void 0 : g.measurements) == null ? void 0 : R.find((Z) => Z.id === n)), c;
463
- }) ?? [];
464
- }
465
- v.value = f;
466
- }
467
- function ae(y, n) {
468
- const u = n.filter((f) => f.id !== y);
469
- $(y), v.value = u;
470
- }
471
- function ye() {
472
- const y = (v.value ?? []).map((n) => ({
473
- ...n,
474
- type: st.enum.SKU
475
- }));
476
- j.promptIngredientsBinding(
477
- y,
478
- (n) => v.value = n,
479
- _.sku._id
480
- );
481
- }
482
- return Fe(
483
- () => _.show,
484
- (y) => {
485
- y || (v.value = null, o.value = {}, F.value = 0);
486
- }
487
- ), (y, n) => {
488
- const u = C("FmTextField"), f = C("FmForm"), s = C("FmCard"), c = C("FmSwitch"), g = C("FmFormGroup"), R = C("FmSelect"), Z = C("FmButton"), ee = C("FmSideSheet");
489
- return V(), J(ee, {
490
- "dismiss-away": "",
491
- modelValue: l(L),
492
- "onUpdate:modelValue": n[3] || (n[3] = (D) => Te(L) ? L.value = D : null),
493
- "max-width": 500
494
- }, {
495
- "side-sheet-header": M(() => [
496
- e("div", ho, [
497
- e("div", bo, p(l(z)("inventory.stock.convert.title", { name: y.sku.name })), 1)
498
- ])
499
- ]),
500
- default: M(() => [
501
- e("div", go, [
502
- k(f, {
503
- ref_key: "formRef",
504
- ref: I,
505
- onValidationSuccess: P
506
- }, {
507
- default: M(() => [
508
- k(u, {
509
- disabled: h.value,
510
- "model-value": F.value,
511
- "onUpdate:modelValue": n[0] || (n[0] = (D) => F.value = D),
512
- label: l(z)("inventory.stock.convert.amount"),
513
- rules: [l(lt)(), G, E, l(Xe)(0)],
514
- "append-text": U.value,
515
- "helper-text": v.value ? void 0 : `Max ${y.maxCount} ${U.value}`
516
- }, null, 8, ["disabled", "model-value", "label", "rules", "append-text", "helper-text"])
517
- ]),
518
- _: 1
519
- }, 512),
520
- k(s, {
521
- variant: "outlined",
522
- class: "p-16"
523
- }, {
524
- default: M(() => [
525
- e("div", xo, [
526
- e("div", So, p(l(z)("inventory.stock.convert.deductionSummary")), 1),
527
- (V(!0), K(le, null, fe(q.value, (D) => {
528
- var W, N;
529
- return V(), K("div", {
530
- key: (W = D.sku) == null ? void 0 : W._id,
531
- class: "flex items-center"
532
- }, [
533
- e("div", wo, p((N = D.sku) == null ? void 0 : N.name), 1),
534
- e("div", Ao, " -" + p(D.convertAmount) + " " + p(D.abbrev), 1)
535
- ]);
536
- }), 128))
537
- ])
538
- ]),
539
- _: 1
540
- }),
541
- k(s, { variant: "outlined" }, {
542
- default: M(() => [
543
- e("div", Fo, [
544
- k(c, {
545
- value: "",
546
- modelValue: w.value,
547
- "onUpdate:modelValue": n[1] || (n[1] = (D) => w.value = D),
548
- label: l(z)("inventory.stock.convert.overrideDeduction"),
549
- "label-placement": "right"
550
- }, null, 8, ["modelValue", "label"]),
551
- w.value ? (V(), K(le, { key: 0 }, [
552
- k(g, {
553
- modelValue: v.value,
554
- rules: [l(Yt)(1, "Must have at least one ingredient binding")]
555
- }, null, 8, ["modelValue", "rules"]),
556
- e("div", $o, [
557
- e("div", jo, p(l(z)("inventory.stock.convert.ingredients")), 1),
558
- (V(!0), K(le, null, fe(v.value, (D) => (V(), J(g, {
559
- key: D.id,
560
- disabled: h.value,
561
- modelValue: o.value[D.id] ?? +l(he)(D.amount ?? { amount: 1, precision: 0 }),
562
- rules: [
563
- a,
564
- l(zt)(
565
- r.value.find((W) => W._id === D.id).unit,
566
- D.measurement
567
- )
568
- ]
569
- }, {
570
- default: M(({ invalid: W }) => {
571
- var N, Q, ie;
572
- return [
573
- e("div", Vo, [
574
- e("div", Bo, p((N = r.value.find((oe) => oe._id === D.id)) == null ? void 0 : N.name), 1),
575
- k(u, {
576
- class: "xs:col-span-2",
577
- disabled: h.value,
578
- modelValue: o.value[D.id] ?? +l(he)(
579
- D.amount ?? { amount: 1, precision: 0 }
580
- ),
581
- "onUpdate:modelValue": (oe) => X(D.id, oe, v.value ?? []),
582
- invalid: W
583
- }, null, 8, ["disabled", "modelValue", "onUpdate:modelValue", "invalid"]),
584
- k(R, {
585
- disabled: h.value,
586
- class: "translate-y-[2px]",
587
- items: te(D.id),
588
- "model-value": (ie = ue(D.id, (Q = D.measurement) == null ? void 0 : Q.id)) == null ? void 0 : ie.value,
589
- "onUpdate:modelValue": (oe) => ce(D.id, oe, v.value ?? []),
590
- invalid: W
591
- }, {
592
- "helper-text": M(() => n[4] || (n[4] = [])),
593
- _: 2
594
- }, 1032, ["disabled", "items", "model-value", "onUpdate:modelValue", "invalid"]),
595
- k(Z, {
596
- disabled: h.value,
597
- type: "button",
598
- variant: "tertiary",
599
- icon: "delete",
600
- onClick: (oe) => ae(D.id, v.value ?? [])
601
- }, null, 8, ["disabled", "onClick"])
602
- ])
603
- ];
604
- }),
605
- _: 2
606
- }, 1032, ["disabled", "modelValue", "rules"]))), 128))
607
- ]),
608
- e("div", null, [
609
- k(Z, {
610
- icon: "link",
611
- label: l(z)("inventory.stock.convert.linkIngredient"),
612
- variant: "plain",
613
- onClick: ye
614
- }, null, 8, ["label"])
615
- ])
616
- ], 64)) : ne("", !0)
617
- ])
618
- ]),
619
- _: 1
620
- })
621
- ])
622
- ]),
623
- "side-sheet-footer": M(() => [
624
- e("div", Co, [
625
- k(Z, {
626
- loading: h.value,
627
- label: l(z)("inventory.stock.convert.convertButton"),
628
- onClick: n[2] || (n[2] = (D) => {
629
- var W, N;
630
- return (N = (W = I.value) == null ? void 0 : W.validateInputs) == null ? void 0 : N.call(W);
631
- })
632
- }, null, 8, ["loading", "label"])
633
- ])
634
- ]),
635
- _: 1
636
- }, 8, ["modelValue"]);
637
- };
638
- }
639
- });
640
- function De(A, d) {
641
- const b = je(A, d);
642
- return { ...b, amount: -b.amount };
643
- }
644
- function ft(A, d) {
645
- return je(Math.abs(A), d);
646
- }
647
- const ze = {
648
- [re.enum.DAMAGE]: {
649
- label: "Damage",
650
- toAdjustmentAmount: De
651
- },
652
- [re.enum.WASTAGE]: {
653
- label: "Wastage",
654
- toAdjustmentAmount: De
655
- },
656
- [re.enum.THEFT]: {
657
- label: "Theft",
658
- toAdjustmentAmount: De
659
- },
660
- [re.enum.LOSE]: {
661
- label: "Lose",
662
- toAdjustmentAmount: De
663
- },
664
- [re.enum.EXTRA]: {
665
- label: "Extra",
666
- toAdjustmentAmount: ft
667
- },
668
- [re.enum.PURCHASE]: {
669
- label: "Purchase",
670
- toAdjustmentAmount: ft
671
- }
672
- }, Mo = { class: "col-span-2 flex" }, Io = { class: "flex-1" }, Eo = { class: "fm-typo-en-body-lg-600" }, Ho = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, To = { class: "col-span-2 flex flex-col gap-4" }, Po = { class: "flex gap-4 text-fm-color-typo-primary fm-typo-en-body-lg-600" }, Uo = {
673
- key: 0,
674
- class: "fm-typo-en-body-md-400 text-fm-color-typo-warning"
675
- }, Ft = /* @__PURE__ */ ve({
676
- __name: "AdjustedItemForm",
677
- props: {
678
- modelValue: {},
679
- disabled: { type: Boolean },
680
- isBackdate: { type: Boolean }
681
- },
682
- emits: ["update:modelValue", "click:delete"],
683
- setup(A, { emit: d }) {
684
- const b = A, _ = d, { t: S } = pe(), j = Re(), i = T(
685
- () => Object.keys(ze).map((t) => ({
686
- label: It(t),
687
- value: t
688
- }))
689
- ), m = T(() => kt(b.modelValue.doc.unit, !0)), B = T({
690
- get() {
691
- return b.modelValue.type ?? re.enum.PURCHASE;
692
- },
693
- set(t) {
694
- const a = {
695
- ...b.modelValue
696
- };
697
- a.type = t;
698
- const $ = it(b.modelValue.amount);
699
- a.amount = ze[a.type].toAdjustmentAmount(
700
- +he($),
701
- $.precision
702
- ), _("update:modelValue", a);
703
- }
704
- }), z = T({
705
- get() {
706
- const t = it(b.modelValue.amount);
707
- return +he(t);
708
- },
709
- set(t) {
710
- const a = {
711
- ...b.modelValue
712
- }, $ = Y.fromNumber(t);
713
- a.amount = ze[B.value].toAdjustmentAmount(
714
- t,
715
- $.precision
716
- ), _("update:modelValue", a);
717
- }
718
- }), F = T({
719
- get() {
720
- var t;
721
- return ((t = b.modelValue.measurement) == null ? void 0 : t.id) ?? null;
722
- },
723
- set(t) {
724
- var $, P;
725
- const a = {
726
- ...b.modelValue
727
- };
728
- a.measurement = ((P = ($ = b.modelValue.doc.unit) == null ? void 0 : $.measurements) == null ? void 0 : P.find((G) => G.id === t)) ?? null, _("update:modelValue", a);
729
- }
730
- }), v = T({
731
- get() {
732
- return b.modelValue.remark ?? "";
733
- },
734
- set(t) {
735
- const a = {
736
- ...b.modelValue
737
- };
738
- a.remark = t, _("update:modelValue", a);
739
- }
740
- }), r = T(() => {
741
- var a;
742
- const t = (a = j.stockBalance.skus) == null ? void 0 : a.find(($) => $.id === b.modelValue.doc._id);
743
- return (t == null ? void 0 : t.balance) ?? { amount: 0, precision: 0 };
744
- }), x = T(() => {
745
- const t = b.modelValue.amount, a = b.modelValue.measurement;
746
- return a ? bt(t, a.conversion) : t;
747
- }), w = T(
748
- () => b.isBackdate ? r.value : Je(r.value, x.value)
749
- ), h = T(
750
- () => Jt(w.value, b.modelValue.doc.unit)
751
- ), o = T(
752
- () => !b.isBackdate && x.value.amount < 0
753
- );
754
- return (t, a) => {
755
- const $ = C("FmButton"), P = C("FmSelect"), G = C("FmTextarea"), E = C("FmCard");
756
- return V(), J(E, {
757
- variant: "outlined",
758
- class: "grid grid-cols-2 gap-8 p-16"
759
- }, {
760
- default: M(() => [
761
- e("div", Mo, [
762
- e("div", Io, [
763
- e("div", Eo, p(t.modelValue.doc.name), 1),
764
- e("div", Ho, p(t.modelValue.doc.code), 1)
765
- ]),
766
- k($, {
767
- variant: "tertiary",
768
- "prepend-icon": "delete",
769
- onClick: a[0] || (a[0] = (U) => _("click:delete"))
770
- })
771
- ]),
772
- k(P, {
773
- disabled: t.disabled,
774
- class: "col-span-2",
775
- label: "Type",
776
- items: i.value,
777
- modelValue: B.value,
778
- "onUpdate:modelValue": a[1] || (a[1] = (U) => B.value = U),
779
- rules: [l(Wt)()],
780
- "label-mark": "required"
781
- }, null, 8, ["disabled", "items", "modelValue", "rules"]),
782
- k(Xt, {
783
- disabled: t.disabled,
784
- label: "Amount",
785
- step: +l(he)({
786
- amount: 1,
787
- precision: l($e)(t.modelValue.doc.unit, t.modelValue.measurement)
788
- }),
789
- modelValue: z.value,
790
- "onUpdate:modelValue": a[2] || (a[2] = (U) => z.value = U),
791
- rules: [l(Xe)(0)]
792
- }, null, 8, ["disabled", "step", "modelValue", "rules"]),
793
- k(P, {
794
- disabled: t.disabled,
795
- label: "Unit",
796
- items: m.value,
797
- modelValue: F.value,
798
- "onUpdate:modelValue": a[3] || (a[3] = (U) => F.value = U)
799
- }, null, 8, ["disabled", "items", "modelValue"]),
800
- k(G, {
801
- class: "col-span-2",
802
- disabled: t.disabled,
803
- label: "Remark",
804
- modelValue: v.value,
805
- "onUpdate:modelValue": a[4] || (a[4] = (U) => v.value = U),
806
- "label-mark": "optional"
807
- }, null, 8, ["disabled", "modelValue"]),
808
- e("div", To, [
809
- e("div", Po, p(l(S)("inventory.stock.stock_adjustment.stockAfter")), 1),
810
- e("div", {
811
- class: Ee(["fm-typo-en-body-lg-600", o.value ? "text-red-700" : "text-green-700"])
812
- }, p(h.value), 3),
813
- t.isBackdate ? (V(), K("div", Uo, p(l(S)("inventory.stock.stock_adjustment.backdatePreviewWarning")), 1)) : ne("", !0)
814
- ])
815
- ]),
816
- _: 1
817
- });
818
- };
819
- }
820
- }), Ro = { class: "flex items-center" }, No = { class: "fm-typo-en-title-md-800" }, Oo = { class: "flex items-center" }, Lo = { class: "fm-typo-en-title-sm-800 flex-1" }, Yo = { class: "flex gap-8" }, zo = /* @__PURE__ */ ve({
821
- __name: "AdjustSkuDialog",
822
- props: {
823
- stock: {},
824
- show: { type: Boolean }
825
- },
826
- emits: ["update:show", "submitted"],
827
- setup(A, { expose: d, emit: b }) {
828
- const _ = A, S = b, j = Ue(), i = Ne(), m = we(), B = Se(), z = O(!1), { t: F } = pe();
829
- function v() {
830
- h(Pe(w));
831
- }
832
- const r = O();
833
- d({
834
- validateInputs: () => {
835
- var a, $;
836
- ($ = (a = r.value) == null ? void 0 : a.validateInputs) == null || $.call(a);
837
- },
838
- resetInputsValidation: () => {
839
- var a, $;
840
- ($ = (a = r.value) == null ? void 0 : a.resetInputsValidation) == null || $.call(a);
841
- },
842
- resetInputs: () => {
843
- var a, $;
844
- ($ = (a = r.value) == null ? void 0 : a.resetInputs) == null || $.call(a);
845
- }
846
- });
847
- const x = Oe(_, "show"), w = pt({
848
- remark: "",
849
- adjustments: [
850
- {
851
- id: `sku_${(/* @__PURE__ */ new Date()).toISOString()}_${Math.random().toString(16).slice(2, 8)}`,
852
- type: re.enum.PURCHASE,
853
- doc: _.stock,
854
- measurement: null,
855
- remark: "",
856
- amount: Y.fromNumber(1)
857
- }
858
- ]
859
- });
860
- Fe([() => _.show], ([a]) => {
861
- a && (w.remark = "", w.adjustments = [
862
- {
863
- id: `sku_${(/* @__PURE__ */ new Date()).toISOString()}_${Math.random().toString(16).slice(2, 8)}`,
864
- type: re.enum.PURCHASE,
865
- doc: _.stock,
866
- measurement: null,
867
- remark: "",
868
- amount: Y.fromNumber(1)
869
- }
870
- ]);
871
- });
872
- async function h(a) {
873
- z.value = !0;
874
- try {
875
- await m.adjustSku({
876
- remark: a.remark,
877
- adjustments: a.adjustments.map(({ doc: $, remark: P, type: G, amount: E, measurement: U }) => ({
878
- id: $._id,
879
- amount: E,
880
- measurement: U,
881
- remark: P,
882
- doc: $,
883
- type: G
884
- }))
885
- }), S("update:show", !1), S("submitted");
886
- } catch ($) {
887
- B.open({
888
- title: F("inventory.stock.adjust.error.title"),
889
- message: F("inventory.stock.adjust.error.message"),
890
- type: "error"
891
- }), console.log("error on adjust ingredients", a, $);
892
- } finally {
893
- z.value = !1;
894
- }
895
- }
896
- function o() {
897
- const a = j.skus.map((P) => ({
898
- label: P.name,
899
- sublabel: P.code,
900
- value: P._id
901
- })), $ = a.filter((P) => w.adjustments.find((G) => G.doc._id === P.value)).map((P) => P.value);
902
- i.open({
903
- title: "Select ingredients",
904
- contentComponent: gt,
905
- contentComponentProps: {
906
- items: a,
907
- modelValue: $
908
- },
909
- overlay: !0,
910
- closeButton: !0,
911
- dismissAway: !0,
912
- primaryActions: {
913
- text: "Confirm",
914
- close: !0
915
- },
916
- secondaryActions: {
917
- text: "Close",
918
- close: !0,
919
- variant: "tertiary"
920
- }
921
- }).onPrimary((P) => {
922
- w.adjustments = P.map(
923
- (G) => w.adjustments.find((E) => E.doc._id === G) ?? {
924
- id: `sku_${(/* @__PURE__ */ new Date()).toISOString()}_${Math.random().toString(16).slice(2, 8)}`,
925
- type: re.enum.PURCHASE,
926
- doc: j.skus.find((E) => E._id === G),
927
- measurement: null,
928
- remark: "",
929
- amount: Y.fromNumber(1)
930
- }
931
- );
932
- });
933
- }
934
- function t(a) {
935
- w.adjustments.splice(a, 1);
936
- }
937
- return (a, $) => {
938
- const P = C("FmTextarea"), G = C("FmButton"), E = C("FmForm"), U = C("FmSideSheet");
939
- return V(), J(U, {
940
- modelValue: l(x),
941
- "onUpdate:modelValue": $[2] || ($[2] = (q) => Te(x) ? x.value = q : null),
942
- "dismiss-away": "",
943
- "max-width": 500
944
- }, {
945
- "side-sheet-header": M(() => [
946
- e("div", Ro, [
947
- e("div", No, p(l(F)("inventory.stock.adjust.title")), 1)
948
- ])
949
- ]),
950
- default: M(() => [
951
- k(E, {
952
- class: "w-full flex flex-col gap-12",
953
- ref_key: "formRef",
954
- ref: r,
955
- onValidationSuccess: v
956
- }, {
957
- default: M(() => [
958
- k(P, {
959
- label: l(F)("inventory.stock.adjust.remark"),
960
- modelValue: w.remark,
961
- "onUpdate:modelValue": $[0] || ($[0] = (q) => w.remark = q)
962
- }, null, 8, ["label", "modelValue"]),
963
- e("div", Oo, [
964
- e("div", Lo, p(l(F)("inventory.stock.adjust.adjustedItems")), 1),
965
- k(G, {
966
- "prepend-icon": "add",
967
- variant: "tertiary",
968
- size: "md",
969
- onClick: o
970
- })
971
- ]),
972
- (V(!0), K(le, null, fe(w.adjustments, (q, I) => (V(), J(Ft, {
973
- key: q.id,
974
- modelValue: w.adjustments[I],
975
- "onUpdate:modelValue": (L) => w.adjustments[I] = L,
976
- "onClick:delete": (L) => t(I)
977
- }, null, 8, ["modelValue", "onUpdate:modelValue", "onClick:delete"]))), 128))
978
- ]),
979
- _: 1
980
- }, 512)
981
- ]),
982
- "side-sheet-footer": M(() => [
983
- e("div", Yo, [
984
- k(G, {
985
- label: l(F)("inventory.stock.adjust.adjustButton"),
986
- loading: z.value,
987
- onClick: $[1] || ($[1] = (q) => {
988
- var I, L;
989
- return (L = (I = r.value) == null ? void 0 : I.validateInputs) == null ? void 0 : L.call(I);
990
- })
991
- }, null, 8, ["label", "loading"])
992
- ])
993
- ]),
994
- _: 1
995
- }, 8, ["modelValue"]);
996
- };
997
- }
998
- }), Go = { class: "flex items-center w-full gap-8" }, Wo = { class: "fm-typo-en-title-md-800 flex-1" }, Ko = {
999
- key: 0,
1000
- class: "flex flex-col gap-4"
1001
- }, qo = { class: "fm-typo-en-body-md-600" }, Xo = { class: "flex gap-8 items-start" }, Jo = { class: "flex-1 min-w-0" }, Qo = { class: "flex-1 min-w-0" }, Zo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, en = { class: "flex items-center" }, tn = { class: "fm-typo-en-title-sm-800 flex-1" }, on = { class: "flex gap-8" }, vt = 14, nn = /* @__PURE__ */ ve({
1002
- __name: "StockAdjustmentSideSheet",
1003
- props: {
1004
- show: { type: Boolean }
1005
- },
1006
- emits: ["update:show", "submitted"],
1007
- setup(A, { emit: d }) {
1008
- const b = A, _ = d, { t: S } = pe(), j = Ue(), i = we(), m = Ne(), B = Se(), z = Oe(b, "show"), F = O(!1), v = pt({
1009
- remark: "",
1010
- effectiveAt: /* @__PURE__ */ new Date(),
1011
- adjustments: []
1012
- }), r = O(!1), x = O(ke().format("YYYY-MM-DD")), w = O(ke().format("HH:mm")), h = O();
1013
- Fe([x, w], () => {
1014
- if (x.value && w.value) {
1015
- const L = ke(`${x.value} ${w.value}`, "YYYY-MM-DD HH:mm");
1016
- L.isValid() && (v.effectiveAt = L.toDate());
1017
- }
1018
- });
1019
- const o = T(() => `${x.value} ${w.value}`);
1020
- function t() {
1021
- if (!r.value) return !0;
1022
- const L = ke(`${x.value} ${w.value}`, "YYYY-MM-DD HH:mm");
1023
- if (!L.isValid()) return S("inventory.stock.stock_adjustment.invalidDateTime");
1024
- const H = ke();
1025
- if (L.isAfter(H))
1026
- return S("inventory.stock.stock_adjustment.futureDateNotAllowed");
1027
- const X = H.subtract(vt, "day");
1028
- return L.isBefore(X) ? S("inventory.stock.stock_adjustment.backdateLimitError", { days: vt }) : !0;
1029
- }
1030
- const a = T(() => [() => t()]), $ = T(() => v.adjustments.length === 0 || t() !== !0);
1031
- function P() {
1032
- v.remark = "", v.effectiveAt = /* @__PURE__ */ new Date(), v.adjustments = [], r.value = !1, x.value = ke(v.effectiveAt).format("YYYY-MM-DD"), w.value = ke(v.effectiveAt).format("HH:mm");
1033
- }
1034
- function G() {
1035
- P();
1036
- }
1037
- const E = T(() => {
1038
- const L = {};
1039
- return j.skus.forEach((H) => {
1040
- L[H._id] = H;
1041
- }), L;
1042
- });
1043
- function U() {
1044
- const L = j.skus.map((X) => ({
1045
- label: X.name,
1046
- sublabel: X.code,
1047
- value: X._id
1048
- })), H = v.adjustments.map((X) => X.doc._id);
1049
- m.open({
1050
- title: S("inventory.stock.adjust.selectIngredients"),
1051
- contentComponent: gt,
1052
- contentComponentProps: {
1053
- items: L,
1054
- modelValue: H,
1055
- virtualScroll: !0
1056
- },
1057
- overlay: !0,
1058
- closeButton: !0,
1059
- dismissAway: !0,
1060
- primaryActions: {
1061
- text: S("common.confirm"),
1062
- close: !0
1063
- },
1064
- secondaryActions: {
1065
- text: S("common.close"),
1066
- close: !0,
1067
- variant: "tertiary"
1068
- }
1069
- }).onPrimary((X) => {
1070
- v.adjustments = X.map(
1071
- (te) => v.adjustments.find((ue) => ue.doc._id === te) ?? {
1072
- id: "",
1073
- type: re.enum.PURCHASE,
1074
- doc: E.value[te],
1075
- measurement: null,
1076
- remark: "",
1077
- amount: Y.fromNumber(1)
1078
- }
1079
- );
1080
- });
1081
- }
1082
- function q(L) {
1083
- v.adjustments.splice(L, 1);
1084
- }
1085
- async function I() {
1086
- if (v.adjustments.length === 0) {
1087
- B.open({
1088
- title: S("inventory.stock.error.title"),
1089
- message: S("inventory.stock.stock_adjustment.noAdjustments"),
1090
- type: "warning"
1091
- });
1092
- return;
1093
- }
1094
- F.value = !0;
1095
- try {
1096
- const L = v.adjustments.map(
1097
- ({ doc: X, remark: te, type: ue, amount: ce, measurement: ae }) => ({
1098
- id: X._id,
1099
- amount: ce,
1100
- measurement: ae,
1101
- remark: te,
1102
- doc: X,
1103
- type: ue
1104
- })
1105
- ), H = {
1106
- remark: v.remark,
1107
- adjustments: L,
1108
- ...r.value ? { effectiveAt: v.effectiveAt.toISOString() } : {}
1109
- };
1110
- await i.adjustSku(Pe(H)), _("submitted"), _("update:show", !1);
1111
- } catch (L) {
1112
- B.open({
1113
- title: S("inventory.stock.adjust.error.title"),
1114
- message: S("inventory.stock.adjust.error.message"),
1115
- type: "error"
1116
- }), console.error("error on stock adjustment", L);
1117
- } finally {
1118
- F.value = !1;
1119
- }
1120
- }
1121
- return (L, H) => {
1122
- const X = C("FmTextarea"), te = C("FmSwitch"), ue = C("FmDatePicker"), ce = C("FmTimePicker"), ae = C("FmFormGroup"), ye = C("FmButton"), y = C("FmForm"), n = C("FmSideSheet");
1123
- return V(), J(n, {
1124
- modelValue: l(z),
1125
- "onUpdate:modelValue": H[6] || (H[6] = (u) => Te(z) ? z.value = u : null),
1126
- "dismiss-away": "",
1127
- "max-width": 560,
1128
- onAfterEnter: G
1129
- }, {
1130
- "side-sheet-header": M(() => [
1131
- e("div", Go, [
1132
- e("div", Wo, p(l(S)("inventory.stock.stock_adjustment.title")), 1)
1133
- ])
1134
- ]),
1135
- default: M(() => [
1136
- k(y, {
1137
- class: "flex flex-col gap-16",
1138
- ref_key: "formRef",
1139
- ref: h,
1140
- onValidationSuccess: I
1141
- }, {
1142
- default: M(() => [
1143
- k(X, {
1144
- label: l(S)("inventory.stock.adjust.remark"),
1145
- modelValue: v.remark,
1146
- "onUpdate:modelValue": H[0] || (H[0] = (u) => v.remark = u),
1147
- "label-mark": "optional"
1148
- }, null, 8, ["label", "modelValue"]),
1149
- k(te, {
1150
- value: "",
1151
- "model-value": r.value,
1152
- "onUpdate:modelValue": H[1] || (H[1] = (u) => r.value = u),
1153
- label: l(S)("inventory.stock.stock_adjustment.backdateLabel"),
1154
- sublabel: l(S)("inventory.stock.stock_adjustment.backdateSublabel"),
1155
- labelPlacement: "right"
1156
- }, null, 8, ["model-value", "label", "sublabel"]),
1157
- r.value ? (V(), K("div", Ko, [
1158
- e("label", qo, p(l(S)("inventory.stock.stock_adjustment.effectiveAt")), 1),
1159
- e("div", Xo, [
1160
- e("div", Jo, [
1161
- k(ue, {
1162
- class: "w-full",
1163
- modelValue: x.value,
1164
- "onUpdate:modelValue": H[2] || (H[2] = (u) => x.value = u),
1165
- clearable: !1
1166
- }, null, 8, ["modelValue"])
1167
- ]),
1168
- e("div", Qo, [
1169
- k(ce, {
1170
- class: "w-full",
1171
- modelValue: w.value,
1172
- "onUpdate:modelValue": H[3] || (H[3] = (u) => w.value = u),
1173
- format: "HH:mm"
1174
- }, null, 8, ["modelValue"])
1175
- ])
1176
- ]),
1177
- k(ae, {
1178
- "model-value": o.value,
1179
- rules: a.value
1180
- }, null, 8, ["model-value", "rules"]),
1181
- e("div", Zo, p(l(S)("inventory.stock.stock_adjustment.immediateHint")), 1)
1182
- ])) : ne("", !0),
1183
- e("div", en, [
1184
- e("div", tn, p(l(S)("inventory.stock.adjust.adjustedItems")), 1),
1185
- k(ye, {
1186
- "prepend-icon": "add",
1187
- variant: "tertiary",
1188
- size: "md",
1189
- onClick: U
1190
- })
1191
- ]),
1192
- (V(!0), K(le, null, fe(v.adjustments, (u, f) => (V(), J(Ft, {
1193
- key: u.doc._id,
1194
- modelValue: v.adjustments[f],
1195
- "onUpdate:modelValue": (s) => v.adjustments[f] = s,
1196
- "is-backdate": r.value,
1197
- "onClick:delete": (s) => q(f)
1198
- }, null, 8, ["modelValue", "onUpdate:modelValue", "is-backdate", "onClick:delete"]))), 128))
1199
- ]),
1200
- _: 1
1201
- }, 512)
1202
- ]),
1203
- "side-sheet-footer": M(() => [
1204
- e("div", on, [
1205
- k(ye, {
1206
- label: l(S)("common.confirm"),
1207
- loading: F.value,
1208
- disabled: $.value,
1209
- onClick: H[4] || (H[4] = (u) => {
1210
- var f, s;
1211
- return (s = (f = h.value) == null ? void 0 : f.validateInputs) == null ? void 0 : s.call(f);
1212
- })
1213
- }, null, 8, ["label", "loading", "disabled"]),
1214
- k(ye, {
1215
- label: l(S)("common.close"),
1216
- variant: "tertiary",
1217
- onClick: H[5] || (H[5] = (u) => _("update:show", !1))
1218
- }, null, 8, ["label"])
1219
- ])
1220
- ]),
1221
- _: 1
1222
- }, 8, ["modelValue"]);
1223
- };
1224
- }
1225
- }), sn = Et((A, d) => ({
1226
- // TODO: remove once latest inventory backend has been push
1227
- async findBillsByBusinessId(b, _, S) {
1228
- const j = `${A.businessesBackendUrl}/${b}/reports/find-many`, i = {
1229
- // type: TYPE.bill,
1230
- type: "bill",
1231
- restaurantIds: _,
1232
- ids: S
1233
- };
1234
- return await d.post(j, i);
1235
- },
1236
- async findBillsById(b) {
1237
- const S = xe().currentLocationDBName, j = `${A.inventoryBackendUrl}/${S}/bill/search`, i = {
1238
- ids: b
1239
- };
1240
- return await d.post(j, i);
1241
- }
1242
- })), an = {
1243
- key: 0,
1244
- class: "flex justify-center items-center h-32"
1245
- }, rn = { class: "mb-3" }, ln = { class: "flex flex-col gap-8" }, un = { class: "flex flex-col text-fm-color-typo-primary mb-3 text-center" }, cn = { class: "text-fm-color-neutral-gray-400 fm-typo-en-body-sm-600" }, dn = { class: "flex flex-col gap-4 text-fm-color-typo-primary mb-3" }, mn = { class: "flex flex-col gap-4 text-fm-color-typo-primary mb-3" }, fn = { class: "flex flex-col gap-4 text-fm-color-typo-primary mb-3" }, vn = { class: "flex flex-col w-full px-2" }, pn = { class: "flex gap-2" }, yn = /* @__PURE__ */ ve({
1246
- __name: "AmendAdjustmentForm",
1247
- props: /* @__PURE__ */ tt({
1248
- adjustmentId: {}
1249
- }, {
1250
- modelValue: {},
1251
- modelModifiers: {}
1252
- }),
1253
- emits: /* @__PURE__ */ tt(["refreshHistory"], ["update:modelValue"]),
1254
- setup(A, { emit: d }) {
1255
- const b = A, _ = d, S = we(), j = $t(A, "modelValue"), i = O(!1), m = O(!1), B = O(!1), z = O({
1256
- _id: `inventoryAdjustment_${(/* @__PURE__ */ new Date()).toISOString()}_XXXXX`,
1257
- skus: []
1258
- }), F = O();
1259
- We(async () => {
1260
- i.value = !0;
1261
- const o = await S.readSingleAdjustment(b.adjustmentId);
1262
- if (!o) throw new Error("Adjustment not found");
1263
- z.value = o, i.value = !1;
1264
- });
1265
- async function v() {
1266
- var t, a;
1267
- if ((a = (t = F == null ? void 0 : F.value) == null ? void 0 : t.validateInputs) == null || a.call(t), !m.value) return;
1268
- const o = {};
1269
- Object.keys(j.value || {}).forEach(($) => {
1270
- var P;
1271
- Object.keys(((P = j.value) == null ? void 0 : P[$]) || {}).forEach((G) => {
1272
- var U, q;
1273
- const E = (q = (U = j.value) == null ? void 0 : U[$]) == null ? void 0 : q[Number(G)];
1274
- E && x(E.amount) > 0 && (o[$] || (o[$] = []), o[$].push(E));
1275
- });
1276
- }), await S.revertWastageAdjustment({
1277
- targetWastageAdjustmentId: b.adjustmentId,
1278
- amountsGoingToAdjust: o
1279
- }), _("refreshHistory"), B.value = !1, j.value = {};
1280
- }
1281
- function r(o) {
1282
- const { skuId: t, idx: a, unit: $, measurement: P } = o;
1283
- return T({
1284
- get: () => {
1285
- var U, q, I;
1286
- const G = (I = (q = (U = j.value) == null ? void 0 : U[t]) == null ? void 0 : q[a]) == null ? void 0 : I.amount;
1287
- return G ? Number(Y.toFormatString({ value: G })) : 0;
1288
- },
1289
- set: (G) => {
1290
- const E = G ?? 0;
1291
- j.value || (j.value = {});
1292
- const U = { ...j.value };
1293
- U[t] || (U[t] = {});
1294
- const q = $e($);
1295
- let I;
1296
- try {
1297
- I = Y.fromNumber(E);
1298
- } catch (L) {
1299
- if (!Number.isFinite(E)) throw L;
1300
- const H = je(E, q, !0);
1301
- I = Y.fromNumber(H.amount / 10 ** q);
1302
- }
1303
- U[t][a] = {
1304
- amount: Y.convertPrecision({
1305
- value: I,
1306
- precision: q
1307
- }),
1308
- type: re.Enum.WASTAGE,
1309
- measurement: P
1310
- }, j.value = U;
1311
- }
1312
- });
1313
- }
1314
- function x(o, t = !0) {
1315
- const a = Number(Y.toFormatString({ value: o }));
1316
- return t ? Math.abs(a) : a;
1317
- }
1318
- function w(o, t) {
1319
- return t.measurement ? t.measurement.abbrev : o.sku.unit.abbrev;
1320
- }
1321
- function h(o, t) {
1322
- if (t.amount === 0) return "N/A";
1323
- const a = Y.add([o, t]);
1324
- return a ? Y.toFormatString({ value: a }) : "N/A";
1325
- }
1326
- return (o, t) => {
1327
- const a = C("FmIcon"), $ = C("FmStepperField"), P = C("FmCard"), G = C("FmForm"), E = C("FmSpacer"), U = C("FmButton"), q = C("FmDialog");
1328
- return V(), J(q, {
1329
- modelValue: B.value,
1330
- "onUpdate:modelValue": t[4] || (t[4] = (I) => B.value = I),
1331
- overlay: !0
1332
- }, {
1333
- "dialog-button": M(() => [
1334
- k(qe, null, {
1335
- default: M(() => [
1336
- e("button", {
1337
- onClick: t[0] || (t[0] = (I) => B.value = !0),
1338
- class: "rounded-md hover:bg-gray-100 transition-colors"
1339
- }, [
1340
- k(a, {
1341
- name: "edit",
1342
- size: "sm"
1343
- })
1344
- ])
1345
- ]),
1346
- _: 1
1347
- })
1348
- ]),
1349
- "dialog-header": M(() => t[5] || (t[5] = [
1350
- e("div", null, "Amend Adjustment", -1)
1351
- ])),
1352
- "dialog-footer": M(() => [
1353
- e("div", vn, [
1354
- t[13] || (t[13] = e("span", { class: "text-fm-color-system-warning-400 fm-typo-en-body-sm-400" }, "1. New adjustment EXTRA will be created for each reversal", -1)),
1355
- e("div", pn, [
1356
- k(E),
1357
- k(U, {
1358
- class: "sm:w-full xs:w-full",
1359
- label: "Close",
1360
- size: "md",
1361
- variant: "tertiary",
1362
- onClick: t[3] || (t[3] = (I) => B.value = !1)
1363
- }),
1364
- k(U, {
1365
- class: "sm:w-full xs:w-full",
1366
- label: "Submit",
1367
- size: "md",
1368
- variant: "primary",
1369
- onClick: v
1370
- })
1371
- ])
1372
- ])
1373
- ]),
1374
- default: M(() => [
1375
- i.value ? (V(), K("div", an)) : (V(), J(G, {
1376
- key: 1,
1377
- ref_key: "formRef",
1378
- ref: F,
1379
- onValidationFailed: t[1] || (t[1] = () => {
1380
- m.value = !1;
1381
- }),
1382
- onValidationSuccess: t[2] || (t[2] = () => {
1383
- m.value = !0;
1384
- }),
1385
- blameFormChildOnValidationFailed: ""
1386
- }, {
1387
- default: M(() => [
1388
- e("p", rn, [
1389
- t[6] || (t[6] = e("b", null, "Date:", -1)),
1390
- t[7] || (t[7] = e("br", null, null, -1)),
1391
- me(" " + p(l(Qt)(l(Ht)(z.value._id))), 1)
1392
- ]),
1393
- e("div", ln, [
1394
- (V(!0), K(le, null, fe(z.value.skus, (I, L) => (V(), K(le, { key: L }, [
1395
- (V(!0), K(le, null, fe(I.amounts, (H, X) => (V(), J(P, {
1396
- key: X,
1397
- variant: "outlined",
1398
- class: "p-2"
1399
- }, {
1400
- default: M(() => [
1401
- e("div", un, [
1402
- e("span", cn, p(I.sku.code), 1),
1403
- e("span", null, p(I.sku.name), 1)
1404
- ]),
1405
- t[12] || (t[12] = e("hr", { class: "m-2" }, null, -1)),
1406
- e("div", dn, [
1407
- t[8] || (t[8] = e("span", { class: "fm-typo-en-body-lg-600" }, "Adjustment type:", -1)),
1408
- e("span", null, p(H.type), 1)
1409
- ]),
1410
- e("div", mn, [
1411
- t[9] || (t[9] = e("span", { class: "fm-typo-en-body-lg-600" }, "Current amount:", -1)),
1412
- e("span", null, p(l(Y).toFormatString({ value: H.amount })) + " " + p(w(I, H)), 1)
1413
- ]),
1414
- k($, {
1415
- "max-fraction-digits": l($e)(I.sku.unit),
1416
- "model-value": r({
1417
- skuId: I.sku._id,
1418
- idx: X,
1419
- unit: I.sku.unit
1420
- }).value,
1421
- "onUpdate:modelValue": (te) => r({
1422
- skuId: I.sku._id,
1423
- idx: X,
1424
- unit: I.sku.unit
1425
- }).value = te,
1426
- class: "mb-3",
1427
- label: "Adjust Amount (Leave 0 to skip)",
1428
- "helper-text": `Max: ${x(H.amount)}`,
1429
- "append-text": w(I, H),
1430
- rules: [
1431
- (te) => te <= x(H.amount) || `Cannot be more than ${x(H.amount)}`,
1432
- (te) => l(Xe)(-1)(te ?? 0)
1433
- ]
1434
- }, null, 8, ["max-fraction-digits", "model-value", "onUpdate:modelValue", "helper-text", "append-text", "rules"]),
1435
- e("div", fn, [
1436
- t[10] || (t[10] = e("span", { class: "fm-typo-en-body-lg-600" }, "Amount after amend:", -1)),
1437
- t[11] || (t[11] = e("span", { class: "text-fm-color-system-warning-400 fm-typo-en-body-sm-400" }, "* It's an estimate for your reference, as it didn't include all the reversals related to this adjustment", -1)),
1438
- me(" " + p(h(
1439
- H.amount,
1440
- l(Y).fromNumber(
1441
- r({
1442
- skuId: I.sku._id,
1443
- idx: X,
1444
- unit: I.sku.unit
1445
- }).value
1446
- )
1447
- )) + " " + p(w(I, H)), 1)
1448
- ])
1449
- ]),
1450
- _: 2
1451
- }, 1024))), 128))
1452
- ], 64))), 128))
1453
- ])
1454
- ]),
1455
- _: 1
1456
- }, 512))
1457
- ]),
1458
- _: 1
1459
- }, 8, ["modelValue"]);
1460
- };
1461
- }
1462
- }), _n = { class: "p-16" }, kn = { class: "fm-typo-en-body-md-600 flex-grow" }, hn = { class: "flex-grow text-fm-color-typo-secondary" }, bn = {
1463
- key: 0,
1464
- class: "my-5"
1465
- }, gn = { class: "shrink-0 whitespace-nowrap text-neutral-400" }, xn = { class: "flex-grow min-w-0" }, Sn = { class: "flex flex-wrap items-center gap-x-1 min-w-0 break-words" }, wn = { class: "flex flex-col gap-1" }, An = {
1466
- key: 1,
1467
- class: "t-system text-fsecondary"
1468
- }, Fn = {
1469
- key: 2,
1470
- class: "text-xs text-gray-400"
1471
- }, $n = { key: 3 }, jn = { key: 4 }, Vn = { class: "inline-flex items-center gap-0.5 text-fm-color-typo-secondary" }, Bn = {
1472
- key: 6,
1473
- class: "inline-flex items-center rounded-md bg-yellow-400/10 px-2 text-xs font-medium text-yellow-500 inset-ring inset-ring-yellow-400/20"
1474
- }, Cn = { class: "shrink-0 whitespace-nowrap text-fm-color-typo-secondary" }, Dn = /* @__PURE__ */ ve({
1475
- __name: "StockRecordCard",
1476
- props: {
1477
- record: {},
1478
- sku: {},
1479
- bills: { default: () => [] },
1480
- unitCostHistory: { default: () => [] },
1481
- costMechanism: { default: "adjustment" }
1482
- },
1483
- setup(A) {
1484
- const d = A;
1485
- function b(F, v) {
1486
- if (d.costMechanism === "adjustment")
1487
- return null;
1488
- const r = d.unitCostHistory.filter(
1489
- (h) => h.mechanism === d.costMechanism && h.skuId === d.sku._id
1490
- );
1491
- if (r.length === 0) return null;
1492
- const x = r.find((h) => {
1493
- const o = h.meta;
1494
- return (o == null ? void 0 : o.adjustmentId) === F;
1495
- });
1496
- if (x) return x.cost;
1497
- const w = [...r].filter((h) => new Date(h.snapshotAt) <= new Date(v)).sort((h, o) => new Date(o.snapshotAt).getTime() - new Date(h.snapshotAt).getTime());
1498
- return w.length > 0 ? w[0].cost : null;
1499
- }
1500
- const _ = O(!1), S = O(), j = O(null), i = T(() => j.value === null ? "unset" : _.value ? `${j.value}px` : "0px");
1501
- We(() => {
1502
- var F;
1503
- j.value = ((F = S.value) == null ? void 0 : F.scrollHeight) || 0;
1504
- });
1505
- const m = T(() => {
1506
- var h;
1507
- const F = d.record.adjustments, v = d.sku, r = {}, w = F.flatMap((o) => {
1508
- var t;
1509
- return ((t = o.skus) == null ? void 0 : t.filter((a) => a.sku._id === v._id)) ?? [];
1510
- }).flatMap((o) => o.amounts);
1511
- for (const o of w) {
1512
- const t = o.measurement ? bt(o.measurement.conversion, o.amount) : o.amount;
1513
- r[h = o.type] ?? (r[h] = { amount: 0, precision: 0 }), r[o.type] = Je(t, r[o.type]);
1514
- }
1515
- return Object.entries(r).reduce(
1516
- (o, [t, a]) => (o[t] = /// comment, because without it formatter makes code uglier
1517
- `${Y.toFormatString({
1518
- value: a,
1519
- precision: 4
1520
- })} ${v.unit.abbrev}`, o),
1521
- {}
1522
- );
1523
- }), { t: B } = pe(), z = T(() => d.record.adjustmentsByTime.map(({ date: F, adjustments: v }) => ({
1524
- time: Zt(new Date(F)),
1525
- adjustments: v.flatMap(
1526
- (r) => {
1527
- var x, w;
1528
- return ((w = (x = r.skus) == null ? void 0 : x.map) == null ? void 0 : w.call(x, (h) => {
1529
- var o, t;
1530
- return {
1531
- ...h,
1532
- ref: r.ref,
1533
- reason: r.reason,
1534
- adjustmentRemark: r.remark,
1535
- backdateFrom: r.effectiveAt != null ? He(r._id) : null,
1536
- toBalance: (t = (o = r.skus) == null ? void 0 : o[0]) == null ? void 0 : t.toBalance,
1537
- adjustmentId: r._id,
1538
- adjustmentTime: r.effectiveAt ?? He(r._id),
1539
- createdBy: r.createdBy
1540
- };
1541
- })) ?? [];
1542
- }
1543
- ).flatMap((r) => {
1544
- var t;
1545
- const x = (t = d.bills.find((a) => a._id === r.ref)) == null ? void 0 : t.seqNumber, w = x ? B("inventory.stock.record.bill", [x]) : "", h = r.adjustmentTime ?? (/* @__PURE__ */ new Date()).toISOString(), o = b(r.adjustmentId, h);
1546
- return (r.amounts || []).filter((a) => a != null).map((a) => {
1547
- var G;
1548
- let $ = a.cost;
1549
- if (o) {
1550
- const E = Y.fromDinero(o), U = a.amount, q = a.measurement ? Y.multiply([U, a.measurement.conversion]) : U;
1551
- $ = {
1552
- ...Y.multiply([
1553
- E,
1554
- q
1555
- ]),
1556
- currency: o.currency
1557
- };
1558
- }
1559
- let P = "";
1560
- return w ? P = a.remark || "" : P = [r.adjustmentRemark, a.remark].filter((U) => U).join("/"), {
1561
- amount: `${Y.toFormatString({ value: a.amount, precision: 4 })} ${((G = a.measurement) == null ? void 0 : G.abbrev) ?? r.sku.unit.abbrev}`,
1562
- backdateFrom: r.backdateFrom,
1563
- name: a.type,
1564
- billRemark: w,
1565
- remark: P,
1566
- reason: r.reason || "",
1567
- cost: $,
1568
- toBalance: Y.toFormatString({
1569
- value: r.toBalance ?? Y.fromNumber(0),
1570
- precision: 4
1571
- }),
1572
- baseUnit: r.sku.unit.abbrev,
1573
- adjustmentId: r.adjustmentId,
1574
- createdBy: r.createdBy
1575
- };
1576
- });
1577
- })
1578
- })));
1579
- return (F, v) => {
1580
- const r = C("FmIcon"), x = C("FmTooltip"), w = C("FmCard");
1581
- return V(), J(w, { variant: "outlined" }, {
1582
- default: M(() => [
1583
- e("div", _n, [
1584
- e("div", {
1585
- class: "flex items-center cursor-pointer mb-1",
1586
- onClick: v[0] || (v[0] = (h) => _.value = !_.value)
1587
- }, [
1588
- e("div", kn, p(F.record.date), 1),
1589
- k(r, {
1590
- name: _.value ? "expand_more" : "expand_less",
1591
- color: "#777777",
1592
- size: "md"
1593
- }, null, 8, ["name"])
1594
- ]),
1595
- (V(!0), K(le, null, fe(m.value, (h, o) => (V(), K("div", {
1596
- key: o,
1597
- class: "flex flex-row py-1",
1598
- style: { "font-size": "0.8rem" }
1599
- }, [
1600
- e("div", hn, p(l(B)(`inventory.inventoryAdjustment.type.${o}`)), 1),
1601
- e("div", {
1602
- class: Ee({
1603
- "text-fm-color-typo-error": h.startsWith("-"),
1604
- "text-fm-color-typo-success": !h.startsWith("-"),
1605
- "ml-auto": !0
1606
- })
1607
- }, p(h), 3)
1608
- ]))), 128)),
1609
- e("div", {
1610
- ref_key: "detailRef",
1611
- ref: S,
1612
- style: yt({
1613
- fontSize: "0.8rem",
1614
- maxHeight: i.value,
1615
- overflow: "hidden",
1616
- transition: "max-height 0.2s ease-out"
1617
- })
1618
- }, [
1619
- z.value.length ? (V(), K("hr", bn)) : ne("", !0),
1620
- (V(!0), K(le, null, fe(z.value, (h) => (V(), K("div", {
1621
- key: h.time,
1622
- class: "flex gap-1 w-full"
1623
- }, [
1624
- e("div", gn, p(h.time), 1),
1625
- e("div", xn, [
1626
- (V(!0), K(le, null, fe(h.adjustments, (o) => {
1627
- var t;
1628
- return V(), K("div", {
1629
- key: o.name,
1630
- class: "flex gap-1"
1631
- }, [
1632
- e("div", Sn, [
1633
- me(p(l(B)(`inventory.inventoryAdjustment.type.${o.name}`)) + " ", 1),
1634
- o.backdateFrom ? (V(), J(x, {
1635
- key: 0,
1636
- variant: "plain",
1637
- placement: "top",
1638
- "z-index": 50
1639
- }, {
1640
- content: M(() => [
1641
- e("div", wn, p(l(B)("inventory.stock.record.backdate", [
1642
- l(xt)(new Date(o.backdateFrom))
1643
- ])), 1)
1644
- ]),
1645
- default: M(() => [
1646
- k(r, {
1647
- name: "info",
1648
- size: "sm",
1649
- color: "primary"
1650
- })
1651
- ]),
1652
- _: 2
1653
- }, 1024)) : ne("", !0),
1654
- o.billRemark ? (V(), K("span", An, " # " + p(o.billRemark), 1)) : ne("", !0),
1655
- o.billRemark && o.remark ? (V(), K("span", Fn, " (" + p(o.remark) + ") ", 1)) : ne("", !0),
1656
- !o.billRemark && o.reason ? (V(), K("span", $n, " (" + p(o.reason) + ") ", 1)) : ne("", !0),
1657
- !o.billRemark && o.remark ? (V(), K("span", jn, " # " + p(o.remark), 1)) : ne("", !0),
1658
- (t = o.createdBy) != null && t.name ? (V(), J(x, {
1659
- key: 5,
1660
- variant: "plain",
1661
- placement: "top",
1662
- "z-index": 50
1663
- }, {
1664
- content: M(() => [
1665
- me(p(l(B)("inventory.stock.record.createdBy", [o.createdBy.name])), 1)
1666
- ]),
1667
- default: M(() => [
1668
- e("span", Vn, [
1669
- k(r, {
1670
- name: "person",
1671
- size: "sm",
1672
- color: "primary"
1673
- }),
1674
- me(" " + p(o.createdBy.name), 1)
1675
- ])
1676
- ]),
1677
- _: 2
1678
- }, 1024)) : ne("", !0),
1679
- o.name === l(re).Enum.CLOSING ? (V(), K("span", Bn, " Actual Balance: " + p(o.toBalance) + " " + p(o.baseUnit), 1)) : ne("", !0)
1680
- ]),
1681
- e("div", {
1682
- class: Ee({
1683
- "text-fm-color-typo-error": o.amount.startsWith("-"),
1684
- "text-fm-color-typo-success": !o.amount.startsWith("-"),
1685
- "ml-auto shrink-0 whitespace-nowrap": !0
1686
- })
1687
- }, p(o.amount), 3),
1688
- o.name === l(re).Enum.WASTAGE ? (V(), J(yn, {
1689
- key: 0,
1690
- adjustmentId: o.adjustmentId,
1691
- onRefreshHistory: v[1] || (v[1] = (a) => F.$emit("refreshHistory"))
1692
- }, null, 8, ["adjustmentId"])) : ne("", !0),
1693
- o.cost ? (V(), J(St, {
1694
- key: 1,
1695
- "feature-key": "total-cost",
1696
- compact: ""
1697
- }, {
1698
- default: M(() => [
1699
- e("div", Cn, " (" + p(l(Me)(o.cost, !1, o.cost.precision)) + ") ", 1)
1700
- ]),
1701
- _: 2
1702
- }, 1024)) : ne("", !0)
1703
- ]);
1704
- }), 128))
1705
- ])
1706
- ]))), 128))
1707
- ], 4)
1708
- ])
1709
- ]),
1710
- _: 1
1711
- });
1712
- };
1713
- }
1714
- });
1715
- function Mn(A, d) {
1716
- var j;
1717
- const b = Object.keys(re.enum).reduce(
1718
- (i, m) => (i[m] = { amount: 0, precision: 0 }, i),
1719
- {}
1720
- );
1721
- if (!d)
1722
- return Object.entries(b).reduce(
1723
- (i, [m]) => (i[m] = Y.fromNumber(0), i),
1724
- {}
1725
- );
1726
- const S = A.flatMap((i) => {
1727
- var m;
1728
- return ((m = i.skus) == null ? void 0 : m.filter((B) => B.sku._id === d._id)) ?? [];
1729
- }).flatMap((i) => i.amounts);
1730
- for (const i of S) {
1731
- const m = i.measurement ? Y.multiply([i.measurement.conversion, i.amount]) : i.amount;
1732
- b[j = i.type] ?? (b[j] = { amount: 0, precision: 0 }), b[i.type] = Y.add([m, b[i.type]]);
1733
- }
1734
- return Object.entries(b).reduce(
1735
- (i, [m, B]) => {
1736
- const z = {
1737
- ...B,
1738
- amount: Math.abs(B.amount)
1739
- };
1740
- return i[m] = /// comment, because without it formatter makes code uglier
1741
- `${Y.toFormatString({
1742
- value: z,
1743
- precision: 4
1744
- })} ${d.unit.abbrev}`, i;
1745
- },
1746
- {}
1747
- );
1748
- }
1749
- function In(A, d) {
1750
- if (!d)
1751
- return null;
1752
- let b = null;
1753
- const S = A.flatMap((j) => {
1754
- var i;
1755
- return ((i = j.skus) == null ? void 0 : i.filter((m) => m.sku._id === d._id)) ?? [];
1756
- }).flatMap((j) => {
1757
- var i;
1758
- return !j.history || ((i = j.history) == null ? void 0 : i.length) === 0 ? [] : j.history[0];
1759
- });
1760
- for (const j of S) {
1761
- const i = j.amounts;
1762
- for (const m of i) {
1763
- if (m.type !== re.Enum.SALES)
1764
- continue;
1765
- const B = m.measurement ? Y.multiply([m.measurement.conversion, m.amount]) : m.amount;
1766
- b ?? (b = Y.fromNumber(0)), b = Y.add([b, B]);
1767
- }
1768
- }
1769
- return b != null ? (b.amount = Math.abs(b.amount), `${Y.toFormatString({
1770
- value: b,
1771
- precision: 4
1772
- })} ${d.unit.abbrev}`) : null;
1773
- }
1774
- const En = { class: "flex items-center w-full fm-typo-en-title-md-800" }, Hn = { class: "flex-1 line-clamp-2" }, Tn = { class: "flex flex-col gap-32 w-full h-full" }, Pn = { class: "flex items-center relative gap-4" }, Un = { class: "flex-1" }, Rn = {
1775
- key: 0,
1776
- class: "flex-1 flex flex-col items-center gap-16"
1777
- }, Nn = { class: "fm-typo-en-body-lg-400 translate-x-4" }, On = {
1778
- key: 1,
1779
- class: "flex flex-col gap-12"
1780
- }, Ln = { class: "pb-16" }, Yn = { class: "fm-typo-cn-body-lg-600" }, zn = {
1781
- class: "grid gap-12 fm-typo-en-body-md-400",
1782
- style: { "grid-template-columns": "auto auto auto", "grid-auto-rows": "1fr" }
1783
- }, Gn = { class: "flex flex-col gap-1" }, Wn = { class: "text-fm-color-typo-secondary" }, Kn = { class: "font-bold" }, qn = { class: "flex flex-col gap-1" }, Xn = { class: "text-fm-color-typo-secondary flex" }, Jn = { class: "font-bold" }, Qn = { class: "flex flex-col gap-1" }, Zn = { class: "text-fm-color-typo-secondary" }, es = { class: "font-bold" }, ts = { class: "flex flex-col gap-1" }, os = { class: "text-fm-color-typo-secondary" }, ns = { class: "font-bold" }, ss = { class: "flex flex-col gap-1" }, as = { class: "text-fm-color-typo-secondary" }, rs = { class: "font-bold" }, ls = { class: "flex flex-col gap-1" }, is = { class: "text-fm-color-typo-secondary" }, us = { class: "font-bold" }, cs = { class: "flex flex-col gap-1" }, ds = { class: "text-fm-color-typo-secondary" }, ms = { class: "font-bold" }, fs = { class: "flex flex-col gap-1" }, vs = { class: "text-fm-color-typo-secondary" }, ps = { class: "font-bold" }, ys = { class: "flex flex-col gap-1" }, _s = { class: "text-fm-color-typo-secondary" }, ks = { class: "font-bold" }, hs = { class: "flex flex-col gap-8" }, bs = { class: "flex" }, gs = { class: "flex-1 flex flex-col gap-1" }, xs = { class: "flex items-center gap-8" }, Ss = { class: "flex gap-1 items-center text-fm-color-typo-secondary" }, ws = { class: "font-bold" }, As = { class: "flex-1 flex flex-col gap-1" }, Fs = { class: "flex items-center gap-8" }, $s = { class: "flex gap-1 items-center text-fm-color-typo-secondary" }, js = { class: "flex flex-col gap-1" }, Vs = { class: "font-bold" }, Bs = {
1784
- key: 2,
1785
- class: "flex-1 flex flex-col items-center gap-8"
1786
- }, Cs = ["src"], Ds = { class: "font-bold text-lg" }, Ms = { class: "text-xs text-neutral-400 text-center" }, Is = /* @__PURE__ */ ve({
1787
- __name: "StockHistory",
1788
- props: {
1789
- sku: {},
1790
- show: { type: Boolean }
1791
- },
1792
- emits: ["update:show"],
1793
- setup(A) {
1794
- const d = Ke(), b = Re(), _ = we(), S = sn(), j = xe(), { t: i } = pe(), m = A, B = O(!1), z = Se(), F = O("adjustment"), v = O([
1795
- { label: "Adjustment (Default)", value: "adjustment" }
1796
- ]), r = O([]), x = O(no(0));
1797
- async function w() {
1798
- B.value = !0;
1799
- try {
1800
- await P(), await b.readStockBalance();
1801
- } catch (n) {
1802
- z.open({
1803
- title: "Something went wrong",
1804
- message: "Cannot fetch stock history. Please try again.",
1805
- type: "error"
1806
- }), console.log("failed at fetching item adjustment history", m.sku, x, n);
1807
- } finally {
1808
- B.value = !1;
1809
- }
1810
- }
1811
- We(() => {
1812
- w();
1813
- }), Fe([() => x.value, () => m.sku], () => {
1814
- w();
1815
- });
1816
- const h = O([]), o = O([]), t = O(new Array());
1817
- function a(n, u) {
1818
- return u === "day" ? oo(n) : xt(n);
1819
- }
1820
- function $(n, u) {
1821
- const f = n.reduce(
1822
- (s, c) => {
1823
- const g = c.effectiveAt ?? He(c._id);
1824
- if (!g)
1825
- return s;
1826
- const R = a(new Date(g), u);
1827
- return s[R] ?? (s[R] = []), s[R].push(c), s;
1828
- },
1829
- {}
1830
- );
1831
- return Object.keys(f).map((s) => ({
1832
- date: s,
1833
- adjustments: f[s]
1834
- }));
1835
- }
1836
- async function P() {
1837
- let n = await _.readStockAdjustment(
1838
- m.sku._id,
1839
- ut(new Date(x.value.startDate)).toISOString(),
1840
- ct(new Date(x.value.endDate)).toISOString()
1841
- );
1842
- h.value = n;
1843
- const u = n.filter(({ ref: f }) => f == null ? void 0 : f.startsWith("bill_")).map(({ ref: f }) => f);
1844
- await G(u), o.value = $(n, "day").map(({ date: f, adjustments: s }) => ({
1845
- date: f,
1846
- adjustments: s,
1847
- adjustmentsByTime: $(s, "minute")
1848
- }));
1849
- try {
1850
- const f = await _.readUnitCostHistory(
1851
- m.sku._id,
1852
- ut(new Date(x.value.startDate)).toISOString(),
1853
- ct(new Date(x.value.endDate)).toISOString()
1854
- );
1855
- r.value = f;
1856
- const s = /* @__PURE__ */ new Set();
1857
- f.forEach((g) => {
1858
- s.add(g.mechanism);
1859
- });
1860
- const c = [{ label: "Default", value: "adjustment" }];
1861
- s.has(ge.Enum.weightedAverage) && c.push({
1862
- label: "Weighted Average (Beta)",
1863
- value: ge.Enum.weightedAverage
1864
- }), s.has(ge.Enum.netsuite) && c.push({ label: "NetSuite (Beta)", value: ge.Enum.netsuite }), s.has(ge.Enum["netsuite-average"]) && c.push({
1865
- label: "NetSuite Average (Beta)",
1866
- value: ge.Enum["netsuite-average"]
1867
- }), v.value = c, !s.has(F.value) && F.value !== "adjustment" && (F.value = "adjustment");
1868
- } catch (f) {
1869
- console.error("Failed to fetch unit cost history:", f);
1870
- }
1871
- }
1872
- async function G(n) {
1873
- n.length && (t.value = await S.findBillsById(n).catch((u) => {
1874
- var c;
1875
- console.error("Error on using latest bill API, retrying using legacy api", u);
1876
- const f = ((c = d.currentBusiness.value) == null ? void 0 : c._id) ?? "", s = j.currentLocation.doc._id;
1877
- return S.findBillsByBusinessId(f, [s], n);
1878
- }));
1879
- }
1880
- const E = T(() => {
1881
- const n = h.value, u = m.sku;
1882
- return Mn(n, u);
1883
- }), U = T(() => {
1884
- const n = h.value, u = m.sku;
1885
- return In(n, u);
1886
- }), q = T(() => {
1887
- const n = [...h.value].computeFirst((f) => {
1888
- var c, g;
1889
- const s = (g = (c = f.skus) == null ? void 0 : c.find) == null ? void 0 : g.call(c, (R) => R.sku._id === m.sku._id);
1890
- return s == null ? void 0 : s.fromBalance;
1891
- }) ?? {
1892
- amount: 0,
1893
- precision: 0
1894
- }, u = m.sku;
1895
- return u ? `${Y.toFormatString({
1896
- value: n,
1897
- precision: 4
1898
- })} ${u.unit.abbrev}` : "";
1899
- }), I = T(() => {
1900
- const n = [...h.value].reverse().computeFirst((f) => {
1901
- var c, g;
1902
- const s = (g = (c = f.skus) == null ? void 0 : c.find) == null ? void 0 : g.call(c, (R) => R.sku._id === m.sku._id);
1903
- return s == null ? void 0 : s.toBalance;
1904
- }) ?? {
1905
- amount: 0,
1906
- precision: 0
1907
- }, u = m.sku;
1908
- return u ? `${Y.toFormatString({ value: n, precision: 4 })} ${u.unit.abbrev}` : "";
1909
- }), L = T(() => {
1910
- var f;
1911
- const u = h.value.flatMap((s) => {
1912
- var c;
1913
- return ((c = s.skus) == null ? void 0 : c.flatMap((g) => g.amounts)) ?? [];
1914
- }).filter((s) => s.amount.amount < 0).reduce(
1915
- (s, c) => {
1916
- const g = c.cost;
1917
- if (!g) return s;
1918
- const R = {
1919
- ...Kt(s, Math.max(s.precision, g.precision)),
1920
- currency: g.currency
1921
- };
1922
- return {
1923
- ...Je(R, g),
1924
- currency: s.currency
1925
- };
1926
- },
1927
- {
1928
- amount: 0,
1929
- precision: 0,
1930
- currency: Be((f = d.currentCountry) == null ? void 0 : f.value)
1931
- }
1932
- );
1933
- return Me(u, !1, u.precision);
1934
- });
1935
- function H() {
1936
- const { startDate: n, endDate: u } = eo(x.value);
1937
- n !== null && u !== null && (x.value = {
1938
- startDate: n,
1939
- endDate: u
1940
- });
1941
- }
1942
- const X = T(() => i("inventory.ingredient.valuationMethod.WAVG"));
1943
- function te(n, u) {
1944
- if (F.value === "adjustment")
1945
- return null;
1946
- const f = r.value.filter(
1947
- (g) => g.mechanism === F.value && g.skuId === m.sku._id
1948
- );
1949
- if (f.length === 0) return null;
1950
- const s = f.find((g) => {
1951
- const R = g.meta;
1952
- return (R == null ? void 0 : R.adjustmentId) === n;
1953
- });
1954
- if (s) return s.cost;
1955
- const c = [...f].filter((g) => new Date(g.snapshotAt) <= new Date(u)).sort((g, R) => new Date(R.snapshotAt).getTime() - new Date(g.snapshotAt).getTime());
1956
- return c.length > 0 ? c[0].cost : null;
1957
- }
1958
- const ue = T(() => {
1959
- var s, c, g, R, Z, ee;
1960
- const n = [...h.value].reverse().find((D) => {
1961
- var W, N;
1962
- return (N = (W = D.skus) == null ? void 0 : W.find) == null ? void 0 : N.call(W, (Q) => Q.sku._id === m.sku._id);
1963
- });
1964
- if (!n) return "No data";
1965
- const u = (s = n.skus) == null ? void 0 : s.find((D) => D.sku._id === m.sku._id);
1966
- if (!u) return "No data";
1967
- const f = u.toBalance;
1968
- if (F.value === "adjustment") {
1969
- const D = [...u.amounts].reverse()[0], W = {
1970
- amount: ((c = D.cost) == null ? void 0 : c.amount) ?? 0,
1971
- precision: ((g = D.cost) == null ? void 0 : g.precision) ?? 0
1972
- }, N = D.amount, Q = N.amount == 0 ? Y.fromNumber(0) : Y.divide([W, N]);
1973
- return {
1974
- ...Y.multiply([Q, f]),
1975
- currency: ((R = D.cost) == null ? void 0 : R.currency) || Be(((Z = d.currentCountry) == null ? void 0 : Z.value) ?? at)
1976
- };
1977
- } else {
1978
- const D = n.effectiveAt ?? He(n._id), W = te(
1979
- n._id,
1980
- D ?? (/* @__PURE__ */ new Date()).toISOString()
1981
- );
1982
- if (!W) return "No data";
1983
- const N = Y.fromDinero(W);
1984
- return {
1985
- ...Y.multiply([N, f]),
1986
- currency: W.currency || Be(((ee = d.currentCountry) == null ? void 0 : ee.value) ?? at)
1987
- };
1988
- }
1989
- }), ce = T(() => {
1990
- var f;
1991
- const n = [...h.value].reverse().computeFirst((s) => {
1992
- var g, R;
1993
- const c = (R = (g = s.skus) == null ? void 0 : g.find) == null ? void 0 : R.call(g, (Z) => Z.sku._id === m.sku._id);
1994
- return c == null ? void 0 : c.toCostBalances;
1995
- });
1996
- return !n || n.some((s) => s.cost == null) ? "No data" : {
1997
- ...n.reduce((s, c) => Y.add([s, Y.fromDinero(c.cost)]), {
1998
- amount: 0,
1999
- precision: 0
2000
- }),
2001
- currency: Be((f = d.currentCountry) == null ? void 0 : f.value)
2002
- };
2003
- }), ae = T(() => m.sku.valuation === rt.Enum.FIFO ? ce.value : ue.value);
2004
- function ye() {
2005
- const { startDate: n, endDate: u } = to(x.value);
2006
- n !== null && u !== null && (x.value = {
2007
- startDate: n,
2008
- endDate: u
2009
- });
2010
- }
2011
- const y = Oe(m, "show");
2012
- return (n, u) => {
2013
- const f = C("FmButton"), s = C("FmField"), c = C("FmDateRangePicker"), g = C("FmSpacer"), R = C("FmCircularProgress"), Z = C("FmIcon"), ee = C("FmTooltip"), D = C("FmMenuDivider"), W = C("FmChip"), N = C("FmSelect"), Q = C("FmCardSection"), ie = C("FmCard"), oe = C("FmSideSheet");
2014
- return V(), J(oe, {
2015
- "dismiss-away": "",
2016
- modelValue: l(y),
2017
- "onUpdate:modelValue": u[5] || (u[5] = (de) => Te(y) ? y.value = de : null),
2018
- "close-button": !1,
2019
- "max-width": 800
2020
- }, {
2021
- "side-sheet-header": M(() => [
2022
- e("div", En, [
2023
- e("div", Hn, p(l(i)("inventory.stock.history.title", [n.sku.name])), 1),
2024
- k(f, {
2025
- variant: "tertiary",
2026
- "prepend-icon": "close",
2027
- onClick: u[0] || (u[0] = (de) => y.value = !1)
2028
- })
2029
- ])
2030
- ]),
2031
- default: M(() => {
2032
- var de;
2033
- return [
2034
- e("div", Tn, [
2035
- e("div", Pn, [
2036
- e("div", Un, [
2037
- k(c, {
2038
- modelValue: x.value,
2039
- "onUpdate:modelValue": u[1] || (u[1] = (se) => x.value = se),
2040
- "show-predefined-range": "",
2041
- "start-label": "",
2042
- "end-label": "",
2043
- "z-index": 50
2044
- }, {
2045
- "trigger-button": M(({ opened: se }) => [
2046
- k(s, {
2047
- "prepend-icon": "calendar_month",
2048
- focused: se
2049
- }, {
2050
- default: M(() => [
2051
- me(p(x.value.startDate) + " - " + p(x.value.endDate), 1)
2052
- ]),
2053
- _: 2
2054
- }, 1032, ["focused"])
2055
- ]),
2056
- _: 1
2057
- }, 8, ["modelValue"])
2058
- ]),
2059
- k(f, {
2060
- variant: "tertiary",
2061
- onClick: u[2] || (u[2] = (se) => H()),
2062
- "prepend-icon": "navigate_before"
2063
- }),
2064
- k(f, {
2065
- variant: "tertiary",
2066
- onClick: u[3] || (u[3] = (se) => ye()),
2067
- "prepend-icon": "navigate_next"
2068
- })
2069
- ]),
2070
- B.value ? (V(), K("div", Rn, [
2071
- k(g),
2072
- k(R, { size: "xl" }),
2073
- e("div", Nn, p(l(i)("inventory.stock.history.loading")), 1),
2074
- k(g),
2075
- k(g)
2076
- ])) : o.value && ((de = o.value) == null ? void 0 : de.length) > 0 ? (V(), K("div", On, [
2077
- k(ie, { variant: "outlined" }, {
2078
- default: M(() => [
2079
- k(Q, { class: "flex flex-col gap-4" }, {
2080
- default: M(() => [
2081
- e("div", Ln, [
2082
- e("div", Yn, p(l(i)("inventory.stock.history.summary.title")), 1)
2083
- ]),
2084
- e("div", zn, [
2085
- e("div", Gn, [
2086
- e("div", Wn, p(l(i)("inventory.stock.history.summary.totalPurchase")), 1),
2087
- e("div", Kn, p(E.value.PURCHASE), 1)
2088
- ]),
2089
- e("div", qn, [
2090
- e("div", Xn, [
2091
- me(p(l(i)("inventory.stock.history.summary.totalSales")) + "  ", 1),
2092
- U.value != null ? (V(), J(ee, {
2093
- key: 0,
2094
- variant: "plain",
2095
- placement: "top",
2096
- content: `Before: ${U.value}`,
2097
- "z-index": 50
2098
- }, {
2099
- default: M(() => [
2100
- k(Z, {
2101
- name: "warning",
2102
- size: "sm"
2103
- })
2104
- ]),
2105
- _: 1
2106
- }, 8, ["content"])) : ne("", !0)
2107
- ]),
2108
- e("div", Jn, p(E.value.SALES), 1)
2109
- ]),
2110
- e("div", Qn, [
2111
- e("div", Zn, p(l(i)("inventory.stock.history.summary.totalLose")), 1),
2112
- e("div", es, p(E.value.LOSE), 1)
2113
- ]),
2114
- e("div", ts, [
2115
- e("div", os, p(l(i)("inventory.stock.history.summary.totalRequest")), 1),
2116
- e("div", ns, p(E.value.REQUEST), 1)
2117
- ]),
2118
- e("div", ss, [
2119
- e("div", as, p(l(i)("inventory.stock.history.summary.totalReceive")), 1),
2120
- e("div", rs, p(E.value.RECEIVE), 1)
2121
- ]),
2122
- e("div", ls, [
2123
- e("div", is, p(l(i)("inventory.stock.history.summary.totalConvert")), 1),
2124
- e("div", us, p(E.value.CONVERT), 1)
2125
- ]),
2126
- e("div", cs, [
2127
- e("div", ds, p(l(i)("inventory.stock.history.summary.totalDamage")), 1),
2128
- e("div", ms, p(E.value.DAMAGE), 1)
2129
- ]),
2130
- e("div", fs, [
2131
- e("div", vs, p(l(i)("inventory.stock.history.summary.openingBalance")), 1),
2132
- e("div", ps, p(q.value), 1)
2133
- ]),
2134
- e("div", ys, [
2135
- e("div", _s, p(l(i)("inventory.stock.history.summary.lastStockBalance")), 1),
2136
- e("div", ks, p(I.value), 1)
2137
- ])
2138
- ]),
2139
- k(St, { "feature-key": "total-cost" }, {
2140
- default: M(() => [
2141
- e("div", hs, [
2142
- k(D, { class: "w-full" }),
2143
- e("div", bs, [
2144
- e("div", gs, [
2145
- e("div", xs, [
2146
- e("div", Ss, [
2147
- me(p(l(i)("inventory.stock.history.estimatedValue")) + " ", 1),
2148
- k(ee, {
2149
- variant: "plain",
2150
- placement: "top",
2151
- content: `[${X.value}] ${l(i)("inventory.stock.history.estimatedValueTooltip")}`,
2152
- "z-index": 50
2153
- }, {
2154
- default: M(() => [
2155
- k(Z, {
2156
- name: "help",
2157
- size: "sm"
2158
- })
2159
- ]),
2160
- _: 1
2161
- }, 8, ["content"])
2162
- ])
2163
- ]),
2164
- e("div", ws, [
2165
- n.sku.valuation === l(rt).Enum.FIFO ? (V(), K(le, { key: 0 }, [
2166
- k(W, {
2167
- label: "FIFO",
2168
- compact: ""
2169
- }),
2170
- me(" " + p(typeof ae.value != "string" ? l(Me)(
2171
- ae.value,
2172
- !1,
2173
- ae.value.precision
2174
- ) : ae.value), 1)
2175
- ], 64)) : (V(), K(le, { key: 1 }, [
2176
- me(p(typeof ae.value != "string" ? l(Me)(
2177
- ae.value,
2178
- !1,
2179
- ae.value.precision
2180
- ) : ae.value), 1)
2181
- ], 64))
2182
- ]),
2183
- k(N, {
2184
- modelValue: F.value,
2185
- "onUpdate:modelValue": u[4] || (u[4] = (se) => F.value = se),
2186
- items: v.value,
2187
- compact: "",
2188
- size: "sm",
2189
- style: { width: "200px" }
2190
- }, null, 8, ["modelValue", "items"])
2191
- ]),
2192
- e("div", As, [
2193
- e("div", Fs, [
2194
- e("div", $s, [
2195
- me(p(l(i)("inventory.stock.history.costSold")) + " ", 1),
2196
- k(ee, {
2197
- variant: "plain",
2198
- placement: "top",
2199
- "z-index": 50
2200
- }, {
2201
- content: M(() => [
2202
- e("div", js, p(l(i)("inventory.stock.history.costSoldTooltip")), 1)
2203
- ]),
2204
- default: M(() => [
2205
- k(Z, {
2206
- name: "help",
2207
- size: "sm"
2208
- })
2209
- ]),
2210
- _: 1
2211
- })
2212
- ])
2213
- ]),
2214
- e("div", Vs, p(L.value), 1)
2215
- ])
2216
- ])
2217
- ])
2218
- ]),
2219
- _: 1
2220
- })
2221
- ]),
2222
- _: 1
2223
- })
2224
- ]),
2225
- _: 1
2226
- }),
2227
- u[6] || (u[6] = e("div", null, null, -1)),
2228
- (V(!0), K(le, null, fe(o.value, (se) => (V(), K(le, {
2229
- key: se.date
2230
- }, [
2231
- n.sku ? (V(), J(Dn, {
2232
- key: 0,
2233
- record: se,
2234
- sku: n.sku,
2235
- bills: t.value,
2236
- "unit-cost-history": r.value,
2237
- "cost-mechanism": F.value,
2238
- onRefreshHistory: w
2239
- }, null, 8, ["record", "sku", "bills", "unit-cost-history", "cost-mechanism"])) : ne("", !0)
2240
- ], 64))), 128))
2241
- ])) : (V(), K("div", Bs, [
2242
- k(g),
2243
- e("div", null, [
2244
- e("img", {
2245
- src: l(so),
2246
- alt: "List is empty"
2247
- }, null, 8, Cs)
2248
- ]),
2249
- e("div", Ds, p(l(i)("inventory.stock.history.noRecords")), 1),
2250
- e("div", Ms, p(l(i)("inventory.stock.history.changeDateRange")), 1),
2251
- k(g),
2252
- k(g)
2253
- ]))
2254
- ])
2255
- ];
2256
- }),
2257
- _: 1
2258
- }, 8, ["modelValue"]);
2259
- };
2260
- }
2261
- }), Es = /* @__PURE__ */ ve({
2262
- __name: "HrmPermissionGuard",
2263
- props: {
2264
- permission: { default: void 0 },
2265
- permissions: { default: void 0 },
2266
- mode: { default: "all" }
2267
- },
2268
- setup(A) {
2269
- const d = A, b = T(() => {
2270
- const S = [];
2271
- return d.permission && S.push(d.permission), d.permissions && S.push(...d.permissions), S;
2272
- });
2273
- jt(() => {
2274
- });
2275
- const { hasPermission: _ } = wt(b, () => d.mode);
2276
- return (S, j) => l(_) ? ot(S.$slots, "default", { key: 0 }) : ot(S.$slots, "fallback", { key: 1 });
2277
- }
2278
- });
2279
- function Hs(A) {
2280
- const d = lo(), b = xe(), _ = O(!1), S = O(null), j = O(null);
2281
- let i = null, m = !1, B = !1;
2282
- function z() {
2283
- if (B) return;
2284
- const r = b.currentLocationDBName;
2285
- if (!r) return;
2286
- B = !0;
2287
- const x = {
2288
- type: "refresh-balance",
2289
- params: { locationId: r }
2290
- }, { unsubscribe: w, initialState: h } = d.subscribe(
2291
- x,
2292
- F
2293
- );
2294
- i = w, h.then((o) => {
2295
- o != null && o.initialState && F(o.initialState);
2296
- }).catch((o) => {
2297
- console.error("Failed to fetch refresh-balance initial state", o);
2298
- });
2299
- }
2300
- async function F(r) {
2301
- var x, w, h;
2302
- if (!(!B || !r)) {
2303
- if (S.value = r, r.completedAt && (j.value = r.completedAt), r.message === "processing" || !r.completedAt && !r.message) {
2304
- m = !0, _.value = !0;
2305
- return;
2306
- }
2307
- if (r.message === "completed" || r.completedAt) {
2308
- if (!m) return;
2309
- v();
2310
- try {
2311
- await A.onCompleted();
2312
- } catch (o) {
2313
- console.error("Failed to reload after refresh", o);
2314
- }
2315
- return;
2316
- }
2317
- if (r.message === "error" || (x = r.message) != null && x.startsWith("error:")) {
2318
- console.log("Stock balance refresh error:", r.message);
2319
- const o = (w = r.message) != null && w.startsWith("error:") ? r.message.slice(6).trim() : "Failed to refresh stock balance.";
2320
- v(), await ((h = A.onError) == null ? void 0 : h.call(A, o));
2321
- }
2322
- }
2323
- }
2324
- function v() {
2325
- i && (i(), i = null), B = !1, m = !1, _.value = !1, S.value = null;
2326
- }
2327
- return Vt(() => {
2328
- v();
2329
- }), {
2330
- refreshing: _,
2331
- refreshStatus: S,
2332
- lastCompletedAt: j,
2333
- startListening: z,
2334
- stopListening: v
2335
- };
2336
- }
2337
- const Ts = {
2338
- key: 0,
2339
- class: "flex items-center gap-1"
2340
- }, Ps = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Us = { class: "flex flex-col gap-8" }, Rs = { class: "flex flex-col" }, Ns = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Os = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary line-clamp-1" }, ga = /* @__PURE__ */ ve({
2341
- __name: "StockView",
2342
- setup(A) {
2343
- const { t: d } = pe(), b = Ue(), _ = xe(), S = Re(), j = At(), i = we(), m = ht(), B = io(), { columnDefs: z } = _o(), F = Ke(), { hasPermission: v } = wt(
2344
- T(() => [
2345
- {
2346
- action: Ce.Action.manage,
2347
- subject: Ce.Subject.Business.inventory_stockAdjustment
2348
- }
2349
- ])
2350
- ), r = T(
2351
- () => {
2352
- var s;
2353
- return v.value || ((s = F.sessionUser.value) == null ? void 0 : s.role.isAdmin);
2354
- }
2355
- ), x = Ne(), w = Se();
2356
- _.watchLocation(q);
2357
- const h = T(
2358
- () => new Set(B.getAvailableItems(B.businessSubsidiaryId))
2359
- ), o = O(!1), t = O(!1), { refreshing: a, lastCompletedAt: $, startListening: P, stopListening: G } = Hs({
2360
- onCompleted: async () => {
2361
- await q(), t.value = !1, w.open({
2362
- title: "Balance refreshed",
2363
- message: "Stock balance has been recalculated.",
2364
- type: "success"
2365
- });
2366
- },
2367
- onError: (s) => {
2368
- t.value = !1, console.log("Error refreshing stock balance", s), w.open({
2369
- title: d("inventory.common.refreshFailed"),
2370
- message: s || d("inventory.stock.stock_balance.refreshBalanceError"),
2371
- type: "error"
2372
- });
2373
- }
2374
- }), E = T(() => a.value || t.value);
2375
- async function U() {
2376
- P();
2377
- const s = d("inventory.stock.stock_balance.refreshBalanceDescription"), c = $.value ? `${s}
2378
-
2379
- Last refreshed: ${new Date($.value).toLocaleString()}` : s;
2380
- x.open({
2381
- title: d("inventory.stock.stock_balance.refreshBalance"),
2382
- message: c,
2383
- closeButton: !0,
2384
- primaryActions: {
2385
- text: d("common.confirm"),
2386
- close: !1,
2387
- isLoading: E,
2388
- disabled: E
2389
- },
2390
- secondaryActions: {
2391
- text: d("common.close"),
2392
- close: !0,
2393
- variant: "tertiary",
2394
- disabled: E
2395
- }
2396
- }).onPrimary(async () => {
2397
- if (!t.value) {
2398
- t.value = !0;
2399
- try {
2400
- await i.recalculation.refreshCurrentBalances();
2401
- } catch (g) {
2402
- console.log("Failed to queue refresh balan22ce", typeof g);
2403
- const R = typeof g == "object" ? JSON.stringify(g) : String(g);
2404
- console.log("Error details:", R), t.value = !1, w.open({
2405
- title: d("inventory.common.refreshFailed"),
2406
- message: (g instanceof Error ? g.message : null) ?? d("inventory.stock.stock_balance.refreshBalanceError"),
2407
- type: "error"
2408
- });
2409
- }
2410
- }
2411
- }).onClose(() => {
2412
- t.value = !1, G();
2413
- });
2414
- }
2415
- async function q() {
2416
- if (_._currentLocation) {
2417
- o.value = !0;
2418
- try {
2419
- await S.readStockBalance(), await S.readProductBalance(), await m.readStockEstimateBalance();
2420
- } catch (s) {
2421
- w.open({
2422
- title: d("inventory.stock.error.title"),
2423
- message: d("inventory.stock.error.message"),
2424
- type: "error"
2425
- }), console.error("error on fetch stock balance", s);
2426
- } finally {
2427
- o.value = !1;
2428
- }
2429
- }
2430
- }
2431
- const I = T(() => [
2432
- {
2433
- type: "string",
2434
- key: "status",
2435
- entity: "sku",
2436
- values: ["Active", "Inactive"]
2437
- }
2438
- ]), L = O({
2439
- logic: "AND",
2440
- rules: [
2441
- {
2442
- property: "status",
2443
- operator: "$in",
2444
- value: ["Active"],
2445
- type: "string"
2446
- }
2447
- ]
2448
- }), H = T(() => {
2449
- var g, R, Z;
2450
- const s = L.value ? uo.build(L.value) : null, c = [];
2451
- for (const ee of b.skus) {
2452
- let D = !0;
2453
- if (B.isEnabled && te.value && h.value && D && (D = h.value.has(ee._id)), s && D && (D = co(
2454
- {
2455
- status: ee.isInactive ? "Inactive" : "Active"
2456
- },
2457
- s
2458
- )), D) {
2459
- const W = ee.trackingMeasurement;
2460
- let N = (R = (g = S.stockBalance.skus) == null ? void 0 : g.find(
2461
- (oe) => oe.id === ee._id
2462
- )) == null ? void 0 : R.balance, Q = m.inventoryForecast.skus.find(
2463
- (oe) => oe.id === ee._id
2464
- );
2465
- const ie = {
2466
- ...ee,
2467
- balance: N ?? {
2468
- amount: 0,
2469
- precision: 0
2470
- },
2471
- operator: Q == null ? void 0 : Q.operator,
2472
- day: (Q == null ? void 0 : Q.depletionDays) ?? void 0,
2473
- trackingUnitAbbrev: W ? ((Z = ee.unit.measurements.find((oe) => oe.id === W)) == null ? void 0 : Z.abbrev) ?? "" : ee.unit.abbrev
2474
- };
2475
- c.push(ie);
2476
- }
2477
- }
2478
- return c;
2479
- }), X = O(""), te = O(!0), { breakpoints: ue } = Nt(), ce = T(() => ue.value.xs || ue.value.sm), ae = T(() => ce.value ? 10 : 20), ye = Ct(), y = T(() => {
2480
- const s = [
2481
- {
2482
- label: d("inventory.stock.stock_balance.refreshBalance"),
2483
- value: "refresh-balance",
2484
- isPrimary: !0,
2485
- prependIcon: "calculate"
2486
- },
2487
- {
2488
- label: d("inventory.common.refresh"),
2489
- value: "refresh"
2490
- },
2491
- {
2492
- label: d("inventory.common.export"),
2493
- value: "export"
2494
- }
2495
- ];
2496
- return r.value && s.push({
2497
- label: d("inventory.stock.stock_adjustment.title"),
2498
- value: "stockAdjustment"
2499
- }), s;
2500
- }), n = O(!1);
2501
- function u() {
2502
- n.value = !0;
2503
- }
2504
- function f(s) {
2505
- switch (s) {
2506
- case "refresh-balance":
2507
- return U();
2508
- case "refresh":
2509
- return q();
2510
- case "export":
2511
- return Pt(H.value);
2512
- case "stockAdjustment":
2513
- return u();
2514
- }
2515
- }
2516
- return (s, c) => {
2517
- const g = C("FmSwitch"), R = C("FmTable");
2518
- return V(), J(Dt, {
2519
- title: l(d)("inventory.stock.title"),
2520
- actions: y.value,
2521
- "onClick:action": f
2522
- }, {
2523
- default: M(() => {
2524
- var Z, ee, D, W;
2525
- return [
2526
- e("div", {
2527
- class: Ee([
2528
- "flex flex-col gap-8 max-h-full",
2529
- {
2530
- "p-0": ce.value,
2531
- "px-24 ": !ce.value
2532
- }
2533
- ])
2534
- }, [
2535
- k(ro, {
2536
- searchable: "",
2537
- "change-location": "",
2538
- search: X.value,
2539
- "onUpdate:search": c[1] || (c[1] = (N) => X.value = N),
2540
- "hide-filter-options": !0,
2541
- filterable: "",
2542
- "filter-attributes": I.value,
2543
- filter: L.value,
2544
- "onUpdate:filter": c[2] || (c[2] = (N) => L.value = N)
2545
- }, {
2546
- default: M(() => [
2547
- l(B).isEnabled ? (V(), K("div", Ts, [
2548
- e("span", Ps, p(l(d)("inventory.integration.netsuite.subsidiaryHierarchy.filtering")), 1),
2549
- k(Ut),
2550
- k(qe, null, {
2551
- default: M(() => [
2552
- k(g, {
2553
- modelValue: te.value,
2554
- "onUpdate:modelValue": c[0] || (c[0] = (N) => te.value = N)
2555
- }, null, 8, ["modelValue"])
2556
- ]),
2557
- _: 1
2558
- })
2559
- ])) : ne("", !0)
2560
- ]),
2561
- _: 1
2562
- }, 8, ["search", "filter-attributes", "filter"]),
2563
- (V(), J(R, {
2564
- style: yt(l(ye).tableHeight),
2565
- "column-defs": l(z),
2566
- "row-data": H.value,
2567
- "search-value": X.value,
2568
- loading: o.value || l(a) || !l(_)._currentLocation,
2569
- key: (Z = l(_)._currentLocation) == null ? void 0 : Z.dbName,
2570
- onRowClick: c[3] || (c[3] = (N) => l(j).showSkuHistory(N.original)),
2571
- "page-size": ae.value
2572
- }, {
2573
- "list-row": M((N) => [
2574
- k(ao, {
2575
- row: N,
2576
- onRowClick: l(j).showSkuHistory
2577
- }, {
2578
- default: M((Q) => {
2579
- var ie, oe, de, se, _e, Ae, Qe, Ze, Ve, et;
2580
- return [
2581
- e("div", Us, [
2582
- e("div", Rs, [
2583
- e("div", Ns, [
2584
- k(l(dt), {
2585
- render: (de = (oe = (ie = Q.code) == null ? void 0 : ie.column) == null ? void 0 : oe.columnDef) == null ? void 0 : de.cell,
2586
- props: (_e = (se = Q.code) == null ? void 0 : se.getContext) == null ? void 0 : _e.call(se)
2587
- }, null, 8, ["render", "props"])
2588
- ]),
2589
- e("div", Os, [
2590
- k(l(dt), {
2591
- render: (Ze = (Qe = (Ae = Q.name) == null ? void 0 : Ae.column) == null ? void 0 : Qe.columnDef) == null ? void 0 : Ze.cell,
2592
- props: (et = (Ve = Q.name) == null ? void 0 : Ve.getContext) == null ? void 0 : et.call(Ve)
2593
- }, null, 8, ["render", "props"])
2594
- ])
2595
- ]),
2596
- e("div", null, [
2597
- k(Ge, {
2598
- days: N.original.day
2599
- }, null, 8, ["days"])
2600
- ]),
2601
- e("div", null, [
2602
- k(_t, {
2603
- class: "xs:w-[160px]",
2604
- unit: N.original.unit,
2605
- sku: N.original,
2606
- amount: N.original.balance,
2607
- "default-tracking-measurement": N.original.trackingMeasurement ?? void 0
2608
- }, null, 8, ["unit", "sku", "amount", "default-tracking-measurement"])
2609
- ])
2610
- ])
2611
- ];
2612
- }),
2613
- _: 2
2614
- }, 1032, ["row", "onRowClick"])
2615
- ]),
2616
- _: 1
2617
- }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
2618
- ], 2),
2619
- (V(), J(Bt, { to: "body" }, [
2620
- (ee = l(j).stockHistoryProps) != null && ee.sku ? (V(), J(Is, nt(Le({ key: 0 }, l(j).stockHistoryProps)), null, 16)) : ne("", !0),
2621
- (D = l(j).convertSkuDialogProps) != null && D.sku ? (V(), J(Do, nt(Le({ key: 1 }, l(j).convertSkuDialogProps)), null, 16)) : ne("", !0),
2622
- (W = l(j).adjustSkuDialogProps) != null && W.stock ? (V(), J(zo, Le({ key: 2 }, l(j).adjustSkuDialogProps, {
2623
- onSubmitted: c[4] || (c[4] = (N) => q())
2624
- }), null, 16)) : ne("", !0),
2625
- k(Es, {
2626
- permission: {
2627
- action: l(Ce).Action.manage,
2628
- subject: l(Ce).Subject.Business.inventory_stockAdjustment
2629
- }
2630
- }, {
2631
- default: M(() => [
2632
- n.value ? (V(), J(nn, {
2633
- key: 0,
2634
- show: n.value,
2635
- "onUpdate:show": c[5] || (c[5] = (N) => n.value = N),
2636
- onSubmitted: c[6] || (c[6] = (N) => q())
2637
- }, null, 8, ["show"])) : ne("", !0)
2638
- ]),
2639
- _: 1
2640
- }, 8, ["permission"])
2641
- ]))
2642
- ];
2643
- }),
2644
- _: 1
2645
- }, 8, ["title", "actions"]);
2646
- };
2647
- }
2648
- });
2649
- export {
2650
- ga as default
2651
- };