@feedmepos/mf-inventory-portal 1.8.0-dev.6 → 1.8.0-dev.8

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