@feedmepos/mf-inventory-portal 1.2.1 → 1.2.2-5.dev-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/dist/App-DMkUg806.js +297 -0
  2. package/dist/{ApprovalView-DwRrbVDo.js → ApprovalView-DWJh2K6W.js} +65 -64
  3. package/dist/{BindingsDialog-DUVKv10-.js → BindingsDialog-EmHCvqJI.js} +2 -2
  4. package/dist/{BindingsPicker-Daib_iq4.js → BindingsPicker-h_9jm1s0.js} +3 -3
  5. package/dist/{BindingsTable-Bv9UmcJP.js → BindingsTable-BAVWGUoa.js} +1 -1
  6. package/dist/ClosingDraftView-Du4kOwIg.js +1899 -0
  7. package/dist/ClosingHistoryView-DuW2Vtrs.js +355 -0
  8. package/dist/ClosingTemplateView-CfPY8R5M.js +2001 -0
  9. package/dist/{DeliveryOrderPrintPreview-DZPcRAja.js → DeliveryOrderPrintPreview-C6Cj8mOp.js} +9 -9
  10. package/dist/FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-WWIrybw_.js +230 -0
  11. package/dist/{FmMultiselectDialog-CZmwOkrb.js → FmMultiselectDialog-BzWrQOS4.js} +1 -1
  12. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-C-2V2bGc.js → FmUnitInput.vue_vue_type_script_setup_true_lang-DwqVRUFz.js} +36 -36
  13. package/dist/ImportView-lKlYeLay.js +1291 -0
  14. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-BGnoF1Zz.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-_2WZMZU2.js} +5 -5
  15. package/dist/{IngredientGroupView-CAVYpEj3.js → IngredientGroupView-CrmwR2Xt.js} +34 -35
  16. package/dist/IngredientsView-1bAsyz-b.js +2254 -0
  17. package/dist/{IntegrationView-DdLFyZ4H.js → IntegrationView-D16qeEc_.js} +1773 -1635
  18. package/dist/{InventoryBindingForm-C7BdEDtM.js → InventoryBindingForm-BRwOXV_P.js} +1 -1
  19. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-B7DND2dQ.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-NDbtbtqK.js} +28 -28
  20. package/dist/{InventoryBindingSummary-IZ7F-Lti.js → InventoryBindingSummary-DKM2gX8_.js} +1 -1
  21. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-sgqVSlUB.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CdaiYTdf.js} +4 -4
  22. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-DeF32bHu.js → PremiumBadge.vue_vue_type_script_setup_true_lang-B0OKeK5O.js} +7 -7
  23. package/dist/{PublishView-DkgfYneI.js → PublishView-D0NnU22l.js} +73 -63
  24. package/dist/{PurchaseOrderPrintPreview-CltLC4o4.js → PurchaseOrderPrintPreview-BmuwNbeL.js} +4 -4
  25. package/dist/{ReceiveRequestView-Dj7ji0DY.js → ReceiveRequestView-j79m7TKk.js} +343 -333
  26. package/dist/RecipeView-D_fNQQ-C.js +636 -0
  27. package/dist/StockView-DX_xeFBT.js +2385 -0
  28. package/dist/SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-Bg49isUy.js +172 -0
  29. package/dist/{SupplierView-DE_M_9kd.js → SupplierView-DuFTqbOg.js} +1193 -1073
  30. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-c428GXwc.js +3233 -0
  31. package/dist/{TransferTemplateView-gWGBCF3u.js → TransferTemplateView-Ccsfcetz.js} +104 -103
  32. package/dist/UnitView-BklpNsFN.js +674 -0
  33. package/dist/WarehouseView-BrURbU67.js +1066 -0
  34. package/dist/api/adjustment-template.d.ts +1 -0
  35. package/dist/api/bill.d.ts +140 -2
  36. package/dist/api/closing-template.d.ts +1 -0
  37. package/dist/api/closing.d.ts +1 -0
  38. package/dist/api/inventory.d.ts +405 -0
  39. package/dist/api/netsuite.d.ts +5 -1
  40. package/dist/api/purchase-order-template.d.ts +1 -0
  41. package/dist/api/purchase-order.d.ts +3 -0
  42. package/dist/api/shipment.d.ts +11 -0
  43. package/dist/api/stock.d.ts +2 -44
  44. package/dist/api/warehouse.d.ts +3 -1
  45. package/dist/{app-CruHLH1e.js → app-a9r50k3U.js} +68551 -67573
  46. package/dist/app.d.ts +643 -15
  47. package/dist/app.js +6 -6
  48. package/dist/components/FmAdminBadge.vue.d.ts +1 -4
  49. package/dist/components/FmEnhancedSelect.vue.d.ts +30 -0
  50. package/dist/components/FmInventoryTableToolbar.vue.d.ts +16 -2
  51. package/dist/components/FmLockableField.vue.d.ts +3 -0
  52. package/dist/components/netsuite/ItemSubsidiaryTreeDialog.vue.d.ts +16 -0
  53. package/dist/components/netsuite/SubsidiaryTreeDialog.vue.d.ts +2 -0
  54. package/dist/composable/defineApi.d.ts +1 -1
  55. package/dist/composable/useIframe.d.ts +2 -2
  56. package/dist/{decimal-izbvCC1j.js → decimal-AusUnA1W.js} +1 -1
  57. package/dist/{format-unit-display-4SAdfyZB.js → format-unit-display-BqkHL-ph.js} +397 -429
  58. package/dist/helper/array.d.ts +1 -0
  59. package/dist/helper/core/country/utils.d.ts +3 -4
  60. package/dist/helper/country.d.ts +6 -255
  61. package/dist/helper/number.d.ts +1 -0
  62. package/dist/import-export.helper-PIyNeHfa.js +238 -0
  63. package/dist/{index-B6GGthLw.js → index-CjxirPvn.js} +283 -268
  64. package/dist/{index-CnQloOEo.js → index-Dj9-pdT9.js} +1 -1
  65. package/dist/layout/SingleColumnLayout.vue.d.ts +6 -3
  66. package/dist/purchase-order-template-CQikvY1p.js +41 -0
  67. package/dist/router/name.d.ts +2 -0
  68. package/dist/stock-CDZ2uWSF.js +83 -0
  69. package/dist/stock-Dw908dIC.js +74 -0
  70. package/dist/stores/feature.d.ts +12 -0
  71. package/dist/stores/integration/netsuite.d.ts +42 -0
  72. package/dist/stores/inventory.d.ts +28 -199
  73. package/dist/stores/location.d.ts +331 -1
  74. package/dist/stores/supplier.d.ts +96 -0
  75. package/dist/stores/warehouse.d.ts +4 -0
  76. package/dist/style.css +1 -1
  77. package/dist/{supplier-CTVE1lHO.js → supplier-BPPBUudN.js} +1 -1
  78. package/dist/tsconfig.app.tsbuildinfo +1 -1
  79. package/dist/{use-ingredient-select-dialog-CM80TfX0.js → use-ingredient-select-dialog-C_fSKN3_.js} +5 -5
  80. package/dist/{use-inventory-binding-dialog-D_omdhgn.js → use-inventory-binding-dialog-ClAkJ864.js} +8 -8
  81. package/dist/views/adjustment-template/wastage-template/actions.d.ts +60 -0
  82. package/dist/views/adjustment-template/wastage-template/table.d.ts +60 -0
  83. package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftDialog.vue.d.ts +56 -0
  84. package/dist/views/closing-draft/composables/use-closing-draft-actions.d.ts +3 -3
  85. package/dist/views/closing-draft/composables/use-closing-draft-table.d.ts +468 -0
  86. package/dist/views/closing-draft/helpers/export-draft.helper.d.ts +9 -2
  87. package/dist/views/closing-history/ClosingHistoryView.vue.d.ts +2 -0
  88. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +4 -1
  89. package/dist/views/closing-template/helpers/import-export.helper.d.ts +5 -0
  90. package/dist/views/import/ImportView.vue.d.ts +3 -0
  91. package/dist/views/import/components/ImportDialog.vue.d.ts +2 -0
  92. package/dist/views/import/helper/import-export.helper.d.ts +4 -0
  93. package/dist/views/ingredients/components/ingredient-dialog/IngredientDialogProps.d.ts +1 -1
  94. package/dist/views/ingredients/components/ingredient-form/IngredientForm.vue.d.ts +181 -12
  95. package/dist/views/ingredients/components/ingredient-form/IngredientFormProps.d.ts +6 -0
  96. package/dist/views/ingredients/helper/import-export.helper.d.ts +4 -1
  97. package/dist/views/integration/components/netsuite/business/BusinessNetSuiteSideSheet.vue.d.ts +2 -0
  98. package/dist/views/receive-request/components/delivery-order-form/CreateForm.vue.d.ts +16 -0
  99. package/dist/views/receive-request/components/delivery-order-form/CreateFormProps.d.ts +4 -0
  100. package/dist/views/receive-request/components/delivery-order-form/EditForm.vue.d.ts +16 -0
  101. package/dist/views/receive-request/components/delivery-order-form/EditFormProps.d.ts +4 -0
  102. package/dist/views/receive-request/components/delivery-order-form/SystemTrailDialog.vue.d.ts +21 -0
  103. package/dist/views/receive-request/components/netsuite/NetSuiteTransactionChangeLog.vue.d.ts +15 -0
  104. package/dist/views/receive-request/components/transfer-details/TransferDetailsProps.d.ts +1 -0
  105. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +420 -2
  106. package/dist/views/receive-request/composables/use-process-purchase-order.d.ts +99 -0
  107. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +644 -13
  108. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +711 -14
  109. package/dist/views/recipe/RecipeView.vue.d.ts +1 -0
  110. package/dist/views/recipe/components/import-recipes/ImportRecipeItem.vue.d.ts +16 -0
  111. package/dist/views/recipe/components/import-recipes/ImportRecipes.vue.d.ts +2 -0
  112. package/dist/views/recipe/helper/import-recipe.d.ts +48 -0
  113. package/dist/views/stock/components/StockRecordCard.vue.d.ts +70 -1
  114. package/dist/views/stock/components/dialog/RecalculationDialog.vue.d.ts +11 -0
  115. package/dist/views/stock/components/dialog/RecalculationDialogProps.d.ts +3 -0
  116. package/dist/views/stock/components/dialog/StockAdjustmentSideSheet.vue.d.ts +20 -0
  117. package/dist/views/supplier/components/SupplierForm.vue.d.ts +8 -0
  118. package/dist/views/supplier/components/SupplierSupplyItemField.vue.d.ts +3 -0
  119. package/dist/views/supplier/composables/use-supplier-table.d.ts +4 -0
  120. package/dist/views/transfer-template/components/transfer-template-dialog/TransferTemplateDialog.vue.d.ts +8 -0
  121. package/dist/views/transfer-template/components/transfer-template-form/components/NetSuiteCustomCodeSelection.vue.d.ts +2 -0
  122. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-locations.d.ts +16 -0
  123. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +48 -0
  124. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +48 -0
  125. package/dist/views/unit/UnitView.vue.d.ts +1 -0
  126. package/dist/views/unit/components/import-units/ImportUnitItem.vue.d.ts +12 -0
  127. package/dist/views/unit/components/import-units/ImportUnitItemProps.d.ts +6 -0
  128. package/dist/views/unit/components/import-units/ImportUnits.vue.d.ts +9 -0
  129. package/dist/views/unit/components/import-units/ImportUnitsProps.d.ts +5 -0
  130. package/dist/views/unit/helper/import-export.helper.d.ts +40 -0
  131. package/dist/views/warehouse/components/WarehouseForm.vue.d.ts +8 -0
  132. package/package.json +3 -3
  133. package/dist/App-BqaRC0Sb.js +0 -276
  134. package/dist/ClosingDraftView-sJ_zRPeo.js +0 -1687
  135. package/dist/ClosingTemplateView-cNgXHq1r.js +0 -1908
  136. package/dist/FmAdminBadge-oCnz8SW6.js +0 -34
  137. package/dist/FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-BKR8C4p_.js +0 -224
  138. package/dist/IngredientsView-CHHeAJH_.js +0 -1858
  139. package/dist/RecipeView-BukmKdVG.js +0 -621
  140. package/dist/StockForecast.vue_vue_type_style_index_0_lang-KLXSWvo5.js +0 -59
  141. package/dist/StockView-wxRCw_w-.js +0 -2087
  142. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-eqUOnJoM.js +0 -2336
  143. package/dist/UnitView-BgwDmGZo.js +0 -667
  144. package/dist/WarehouseView-BdccenhO.js +0 -1034
  145. package/dist/array-Ca8T3f_G.js +0 -44
  146. package/dist/helper/core/country/codes.d.ts +0 -255
  147. package/dist/stock-BJP5BB5b.js +0 -146
@@ -1,2087 +0,0 @@
1
- import { defineComponent as ce, ref as N, computed as R, resolveComponent as D, openBlock as F, createBlock as L, withCtx as I, createElementVNode as e, normalizeClass as ge, toDisplayString as _, createVNode as x, createElementBlock as O, Fragment as ne, renderList as le, unref as r, h as he, watch as xe, isRef as Ue, createCommentVNode as se, reactive as it, mergeModels as Ye, useModel as ut, onMounted as Ee, createTextVNode as ue, normalizeStyle as Ze, Teleport as ct, normalizeProps as Ae, mergeProps as Ve } from "vue";
2
- import { u as pe, W as dt, f as He, h as mt, a as Pe, F as Ge, X as pt, Y as Ie, j as me, P as ft, t as Se, V as Fe, A as vt, M as yt, T as ve, Z as _t, $ as oe, a0 as ht, a1 as We, m as kt, a2 as bt, a3 as gt, a4 as xt, a5 as St, a6 as Ce, a7 as Ft, a8 as et, Q as X, a9 as wt, s as tt, aa as ke, ab as $t, ac as At, o as Be, l as Ke, p as Vt, c as Ct, ad as Bt, ae as Mt, af as Dt, ag as jt, ah as It, B as Tt, _ as Ut, C as Et, E as Ht, G as qe } from "./app-CruHLH1e.js";
3
- import { u as Re, a as ye } from "./stock-BJP5BB5b.js";
4
- import { g as we } from "./decimal-izbvCC1j.js";
5
- import { e as Pt, u as nt, i as ot, _ as Xe } from "./PremiumBadge.vue_vue_type_script_setup_true_lang-DeF32bHu.js";
6
- import { _ as Te, S as Me, g as st } from "./StockForecast.vue_vue_type_style_index_0_lang-KLXSWvo5.js";
7
- import { _ as Rt } from "./PreviewBadge.vue_vue_type_script_setup_true_lang-CRZiQHjx.js";
8
- import { useI18n as de, useCoreStore as at } from "@feedmepos/mf-common";
9
- import { useSnackbar as _e, useDialog as Oe, useProxiedModel as Ne, useBreakpoints as Ot } from "@feedmepos/ui-library";
10
- import { defineStore as Nt } from "pinia";
11
- import { u as Lt } from "./use-inventory-binding-dialog-D_omdhgn.js";
12
- import { _ as zt } from "./NumberPrecisionInput.vue_vue_type_script_setup_true_lang-sgqVSlUB.js";
13
- import { E as Yt } from "./empty-placeholder-wf6-BWE8.js";
14
- import { F as Gt } from "./FmAdminBadge-oCnz8SW6.js";
15
- import "./array-Ca8T3f_G.js";
16
- var be = /* @__PURE__ */ ((v) => (v.History = "History", v.Convert = "Convert", v.Adjust = "Adjust", v))(be || {});
17
- const Wt = [
18
- {
19
- translationKey: "inventory.stock.action.history",
20
- color: "text-neutral-700",
21
- value: "History"
22
- /* History */
23
- }
24
- ], Kt = [
25
- {
26
- translationKey: "inventory.stock.action.history",
27
- color: "text-neutral-700",
28
- value: "History"
29
- /* History */
30
- },
31
- {
32
- translationKey: "inventory.stock.action.convert",
33
- color: "text-neutral-700",
34
- value: "Convert"
35
- /* Convert */
36
- },
37
- {
38
- translationKey: "inventory.stock.action.adjust",
39
- color: "text-neutral-700",
40
- value: "Adjust"
41
- /* Adjust */
42
- }
43
- ];
44
- async function qt(v) {
45
- const u = `${(pe().currentLocation.name || "").replace(
46
- / /g,
47
- "_"
48
- )}_${dt().format("DD_MM_YYYY_HHmm")}.xlsx`;
49
- await Pt(
50
- [
51
- {
52
- name: "stock",
53
- data: v,
54
- columns: [
55
- {
56
- name: "Code",
57
- selector: "code"
58
- },
59
- {
60
- name: "Name",
61
- selector: "name"
62
- },
63
- {
64
- name: "Balance",
65
- selector: (o) => {
66
- const A = $e(o, o.unit);
67
- return A.type === "unit" ? we(o.balance, o.unit, null, !1) : we(o.balance, o.unit, A.measurement, !1);
68
- }
69
- },
70
- {
71
- name: "Unit",
72
- selector: (o) => {
73
- var p;
74
- const A = $e(o, o.unit);
75
- return A.type === "unit" ? o.unit.abbrev : ((p = o.unit.measurements.find((l) => l.id === A.measurement)) == null ? void 0 : p.abbrev) || "";
76
- }
77
- }
78
- ]
79
- }
80
- ],
81
- u
82
- );
83
- }
84
- function $e(v, g) {
85
- const u = localStorage.getItem(`uom:${v._id}`);
86
- return u ? u === g._id ? {
87
- type: "unit"
88
- } : g.measurements.find((o) => o.id === u) ? {
89
- type: "measurement",
90
- measurement: u
91
- } : {
92
- type: "unit"
93
- } : v.trackingMeasurement && g.measurements.find((o) => o.id === v.trackingMeasurement) ? {
94
- type: "measurement",
95
- measurement: v.trackingMeasurement
96
- } : {
97
- type: "unit"
98
- };
99
- }
100
- const Xt = { class: "fm-typo-en-body-md-400 flex-grow" }, rt = /* @__PURE__ */ ce({
101
- __name: "UnitDisplayControl",
102
- props: {
103
- unit: {},
104
- sku: {},
105
- amount: {},
106
- defaultTrackingMeasurement: {}
107
- },
108
- setup(v) {
109
- function g($) {
110
- return `uom:${$._id}`;
111
- }
112
- function u($) {
113
- const i = g(o.sku);
114
- $ ? localStorage.setItem(i, $) : localStorage.setItem(i, o.unit._id), A.value = $e(o.sku, o.unit);
115
- }
116
- const o = v, A = N($e(o.sku, o.unit)), p = R(() => {
117
- const { measurements: $ } = o.unit;
118
- return [
119
- {
120
- label: `${we(o.amount, o.unit)}`,
121
- value: null
122
- },
123
- ...$.map(({ id: i }) => ({
124
- label: `${we(o.amount, o.unit, i)}`,
125
- value: i
126
- }))
127
- ];
128
- });
129
- function l({ value: $ }) {
130
- return r(A).type === "unit" ? $ === null : $ === r(A).measurement;
131
- }
132
- const f = R(
133
- () => {
134
- var $;
135
- return (($ = p.value.find((i) => l(i))) == null ? void 0 : $.label) ?? "";
136
- }
137
- ), B = N(!1);
138
- return ($, i) => {
139
- const s = D("FmIcon"), V = D("FmMenuItem"), k = D("FmMenu");
140
- return F(), L(k, {
141
- "stop-click-propagation": "",
142
- onMenuChanged: i[0] || (i[0] = (S) => B.value = S)
143
- }, {
144
- "menu-button": I(() => [
145
- e("button", {
146
- type: "button",
147
- class: ge([
148
- "w-full text-left flex items-center gap-8 cursor-pointer fm-corner-radius-sm px-8 py-4 border bg-white",
149
- B.value ? "border-fm-color-primary" : "border-fm-color-neutral-gray-100"
150
- ])
151
- }, [
152
- e("div", Xt, _(f.value), 1),
153
- x(s, {
154
- class: "text-fm-color-neutral-gray-400",
155
- name: "expand_more"
156
- })
157
- ], 2)
158
- ]),
159
- default: I(() => [
160
- (F(!0), O(ne, null, le(p.value, (S) => (F(), L(V, {
161
- key: S.value ?? 0,
162
- label: S.label,
163
- "model-value": l(S),
164
- onClick: (M) => u(S.value)
165
- }, null, 8, ["label", "model-value", "onClick"]))), 128))
166
- ]),
167
- _: 1
168
- });
169
- };
170
- }
171
- }), Qt = { class: "whitespace-nowrap" }, Jt = /* @__PURE__ */ ce({
172
- __name: "StockHeaderPreview",
173
- setup(v) {
174
- const { t: g } = de();
175
- return (u, o) => (F(), L(Rt, null, {
176
- default: I(() => [
177
- e("div", Qt, _(r(g)("inventory.stock.prediction.daysRemaining")), 1)
178
- ]),
179
- _: 1
180
- }));
181
- }
182
- }), lt = Nt("stockActions", () => {
183
- const v = N(!1), g = pe(), u = Re(), o = nt(), A = _e(), p = Oe(), { t: l } = de();
184
- async function f() {
185
- if (g._currentLocation) {
186
- v.value = !0;
187
- try {
188
- await u.readStockBalance(), await u.readProductBalance(), await o.readStockEstimateBalance();
189
- } catch {
190
- A.open({
191
- title: l("inventory.stock.error.title"),
192
- message: l("inventory.stock.error.message"),
193
- type: "error"
194
- });
195
- } finally {
196
- v.value = !1;
197
- }
198
- }
199
- }
200
- const B = N();
201
- async function $(M) {
202
- var w, j, P;
203
- if (!!!((j = (w = M.convert) == null ? void 0 : w.inventoryBindings) != null && j.length)) {
204
- p.open({
205
- title: l("inventory.stock.error.convert.title"),
206
- message: l("inventory.stock.error.convert.message")
207
- });
208
- return;
209
- }
210
- const y = {
211
- maxCount: ((P = u.productBalance.find(({ id: T }) => T === M._id)) == null ? void 0 : P.count) || 0,
212
- sku: M,
213
- show: !0,
214
- "onUpdate:show"(T) {
215
- B.value.show = T;
216
- },
217
- onSubmitted() {
218
- f();
219
- }
220
- };
221
- B.value = y;
222
- }
223
- const i = N();
224
- async function s(M) {
225
- const h = {
226
- stock: M,
227
- show: !0,
228
- "onUpdate:show"(t) {
229
- i.value.show = t;
230
- },
231
- onSubmitted() {
232
- f();
233
- }
234
- };
235
- i.value = h;
236
- }
237
- const V = N();
238
- async function k(M) {
239
- const h = {
240
- sku: M,
241
- show: !0,
242
- "onUpdate:show"(t) {
243
- V.value.show = t;
244
- }
245
- };
246
- V.value = h;
247
- }
248
- function S(M, h) {
249
- const t = He(h);
250
- switch (M) {
251
- case be.History:
252
- k(t);
253
- return;
254
- case be.Convert:
255
- $(t);
256
- return;
257
- case be.Adjust:
258
- s(t);
259
- return;
260
- }
261
- }
262
- return {
263
- fetchStockBalance: f,
264
- onActionMenu: S,
265
- stockHistoryProps: V,
266
- showSkuHistory: k,
267
- convertSkuDialogProps: B,
268
- adjustSkuDialogProps: i
269
- };
270
- });
271
- function Zt() {
272
- const v = pe(), g = lt(), { t: u } = de();
273
- return {
274
- columnDefs: [
275
- {
276
- accessorKey: "code",
277
- header: () => u("inventory.stock.code"),
278
- enableSorting: !0,
279
- size: 300
280
- },
281
- {
282
- accessorKey: "name",
283
- header: () => u("inventory.stock.product"),
284
- enableSorting: !0,
285
- size: "auto"
286
- },
287
- {
288
- id: "UOM",
289
- header: () => u("inventory.stock.balance"),
290
- cell(A) {
291
- const p = A.row.original, l = {
292
- unit: p.unit,
293
- sku: p,
294
- amount: p.balance,
295
- defaultTrackingMeasurement: p.trackingMeasurement ?? void 0
296
- };
297
- return he(rt, l);
298
- },
299
- size: 180
300
- },
301
- {
302
- accessorKey: "day",
303
- id: "expireDate",
304
- header: () => he(Jt),
305
- enableSorting: !0,
306
- sortUndefined: "last",
307
- cell(A) {
308
- var i, s;
309
- const p = A.row.original.day, l = (i = A.row.original.thresholds) == null ? void 0 : i.low, f = (s = A.row.original.thresholds) == null ? void 0 : s.mid;
310
- if (typeof p != "number" || typeof l != "number" || typeof f != "number")
311
- return he(Te, {
312
- days: p
313
- });
314
- const B = p <= l ? Me.low : p <= f ? Me.mid : Me.high;
315
- return he(Te, {
316
- days: p,
317
- level: B
318
- });
319
- },
320
- size: 200
321
- },
322
- {
323
- id: "action",
324
- cell(A) {
325
- var p;
326
- return mt(
327
- ((p = v._currentLocation) == null ? void 0 : p.type) === "restaurant" ? Wt : Kt,
328
- (l) => g.onActionMenu(l, A.row.original)
329
- );
330
- },
331
- enableSorting: !1,
332
- size: 40,
333
- meta: {
334
- cellClass: "",
335
- headerClass: ""
336
- }
337
- }
338
- ]
339
- };
340
- }
341
- const en = {
342
- context: null,
343
- error: null,
344
- isRequired(v = "This field is required") {
345
- return `${this.context ?? ""}`.length === 0 && (this.error = v), this;
346
- },
347
- isString(v = "Must be a valid string") {
348
- return this.error ? this : (typeof this.context != "string" && (this.error ?? (this.error = v)), this);
349
- },
350
- toInt() {
351
- return this.error ? this : (this.context = +this.context, this);
352
- },
353
- isInteger(v = "Must be an integer") {
354
- return this.error ? this : (this.toInt(), isNaN(this.context) && (this.error = v), this);
355
- },
356
- min(v, g) {
357
- if (this.error) return this;
358
- try {
359
- typeof this.context == "number" ? +this.context < v && (this.error = g ?? `Must be at least ${v}`) : Object.prototype.hasOwnProperty.call(this.context, "length") ? +this.context.length < v && (this.error = g ?? `Must be at least ${v}`) : this.error = "Length cannot be determined";
360
- } catch {
361
- this.error = "Length cannot be determined";
362
- }
363
- return this;
364
- },
365
- max(v, g) {
366
- if (this.error) return this;
367
- try {
368
- typeof this.context == "number" ? +this.context > v && (this.error = g ?? `Must be at most ${v}`) : "length" in this.context ? +this.context.length > v && (this.error = g ?? `Must be at most ${v}`) : this.error = "Length cannot be determined";
369
- } catch {
370
- this.error = "Length cannot be determined";
371
- }
372
- return this;
373
- }
374
- };
375
- function Qe(v) {
376
- return { ...en, context: v };
377
- }
378
- const tn = { class: "flex items-center" }, nn = { class: "fm-typo-en-title-md-800" }, on = { class: "flex flex-col gap-24 w-full" }, sn = { class: "flex flex-col gap-8" }, an = { class: "fm-typo-en-body-lg-600" }, rn = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary flex-grow" }, ln = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-error" }, un = { class: "flex flex-col p-16 gap-8" }, cn = { class: "flex flex-col gap-4" }, dn = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary bg-fm-color-neutral-gray-100 border-b py-12 px-16" }, mn = { class: "grid grid-cols-[auto_100px_100px_48px] xs:grid-cols-[auto_80px_120px_48px] gap-8 px-8 items-center" }, pn = { class: "xs:col-span-3" }, fn = { class: "flex gap-8" }, vn = /* @__PURE__ */ ce({
379
- __name: "ConvertSkuDialog",
380
- props: {
381
- sku: {},
382
- maxCount: {},
383
- show: { type: Boolean }
384
- },
385
- emits: ["update:show", "submitted"],
386
- setup(v, { expose: g, emit: u }) {
387
- const o = v, A = u, p = Lt(), l = Pe(), f = ye(), B = _e(), { t: $ } = de(), i = N(0), s = N(null), V = R(() => l.skus), k = R(
388
- () => {
389
- var d, n;
390
- return (((n = (d = o.sku) == null ? void 0 : d.convert) == null ? void 0 : n.inventoryBindings) ?? []).filter(
391
- (a) => a.type === Ge.enum.SKU
392
- );
393
- }
394
- ), S = R({
395
- get() {
396
- return !!s.value;
397
- },
398
- set(d) {
399
- d ? s.value = He(k.value) : (s.value = null, i.value = Math.min(i.value, o.maxCount ?? 0));
400
- }
401
- }), M = N(!1);
402
- xe([() => o.show], ([d]) => {
403
- d && (i.value = 0);
404
- });
405
- function h() {
406
- Y(o.sku, Se(i.value), s.value);
407
- }
408
- function t(d) {
409
- if (s.value)
410
- return !0;
411
- const n = Qe(d).isInteger().max(o.maxCount ?? 0).error ?? "";
412
- return n || !0;
413
- }
414
- function y(d) {
415
- var m;
416
- const n = (m = o.sku.convert) != null && m.measurement ? o.sku.unit.measurements.find((C) => {
417
- var H;
418
- return C.id === ((H = o.sku.convert) == null ? void 0 : H.measurement);
419
- }) ?? null : null, a = Ie(o.sku.unit, n), b = _t(+d);
420
- return Qe(b).isInteger().max(a).error ? "Precision cannot be more than " + a : !0;
421
- }
422
- const w = R(
423
- () => {
424
- var d, n;
425
- return (d = o.sku.convert) != null && d.measurement ? (n = o.sku.unit.measurements.find((a) => {
426
- var b;
427
- return a.id === ((b = o.sku.convert) == null ? void 0 : b.measurement);
428
- })) == null ? void 0 : n.abbrev : o.sku.unit.abbrev;
429
- }
430
- ), j = R(() => {
431
- var b, c;
432
- const n = pt({
433
- bindings: ((b = o.sku.convert) == null ? void 0 : b.inventoryBindings) ?? [],
434
- skus: l.skus,
435
- skuGroups: l.skuGroups,
436
- recipes: l.recipes
437
- }).inventoryBindings.filter((m) => "success" in m && m.success).map((m) => m).map((m) => m.binding);
438
- return (c = s.value ?? n) == null ? void 0 : c.map((m) => {
439
- var re, ie, te, ae, Le;
440
- const C = l.skus.find((fe) => fe._id === m.id), H = ((re = m.measurement) == null ? void 0 : re.abbrev) ?? ((ie = C == null ? void 0 : C.unit) == null ? void 0 : ie.abbrev), K = (te = o.sku.convert) != null && te.measurement ? o.sku.unit.measurements.find((fe) => {
441
- var ze;
442
- return fe.id === ((ze = o.sku.convert) == null ? void 0 : ze.measurement);
443
- }) ?? null : null, ee = Ie(o.sku.unit, K), E = y(`${i.value}`) === !0 ? me(
444
- ft(
445
- m.amount,
446
- Se(+i.value, ee)
447
- ),
448
- !1
449
- ) : "0", q = (Le = (ae = s.value) == null ? void 0 : ae.find((fe) => fe.id === (C == null ? void 0 : C._id))) == null ? void 0 : Le.amount, J = q ? me(q, !1) : null;
450
- return {
451
- sku: C,
452
- convertAmount: J ?? E,
453
- abbrev: H
454
- };
455
- });
456
- }), P = N();
457
- g({
458
- validateInputs: () => {
459
- var d, n;
460
- (n = (d = P.value) == null ? void 0 : d.validateInputs) == null || n.call(d);
461
- },
462
- resetInputsValidation: () => {
463
- var d, n;
464
- (n = (d = P.value) == null ? void 0 : d.resetInputsValidation) == null || n.call(d);
465
- },
466
- resetInputs: () => {
467
- var d, n;
468
- (n = (d = P.value) == null ? void 0 : d.resetInputs) == null || n.call(d);
469
- }
470
- });
471
- const T = Ne(o, "show");
472
- async function Y(d, n, a) {
473
- M.value = !0;
474
- try {
475
- await f.convertSku({
476
- conversions: [
477
- {
478
- doc: d,
479
- amount: n,
480
- overrides: a == null ? void 0 : a.map((b) => ({
481
- ...b,
482
- amount: {
483
- ...b.amount,
484
- amount: -1 * Math.abs(b.amount.amount)
485
- // ensure truly negative
486
- }
487
- }))
488
- }
489
- ]
490
- }), A("update:show", !1), A("submitted");
491
- } catch (b) {
492
- B.open({
493
- title: "Something went wrong",
494
- message: `Cannot convert ${d.name}. Please try again.`,
495
- type: "error"
496
- }), console.error("error at converting stock amount", d, n, b);
497
- } finally {
498
- M.value = !1;
499
- }
500
- }
501
- function W(d, n, a) {
502
- const b = +n;
503
- let c = a;
504
- n.length > 0 && isFinite(b) ? c = a.map((m) => (m.id !== d || (m.amount = ve(b)), m)) : c = a.map((m) => (m.id !== d || (m.amount = { amount: 0, precision: 0 }), m)), s.value = c;
505
- }
506
- function U(d) {
507
- const n = V.value.find((a) => a._id === d);
508
- return n ? st(n.unit, !0) : [];
509
- }
510
- function Z(d, n) {
511
- const a = U(d), b = a.find((c) => c.value === n) ?? a.find((c) => c.value === null);
512
- return b ? {
513
- ...b,
514
- label: b.abbrev
515
- } : null;
516
- }
517
- function z(d, n, a) {
518
- let b;
519
- if (n === null)
520
- b = a.map((c) => (c.id !== d || (c.measurement = null), c)) ?? [];
521
- else {
522
- const c = V.value.find((m) => m._id === d);
523
- b = a.map((m) => {
524
- var C, H;
525
- return m.id !== d || (m.measurement = (H = (C = c == null ? void 0 : c.unit) == null ? void 0 : C.measurements) == null ? void 0 : H.find((K) => K.id === n)), m;
526
- }) ?? [];
527
- }
528
- s.value = b;
529
- }
530
- function Q(d, n) {
531
- const a = n.filter((b) => b.id !== d);
532
- s.value = a;
533
- }
534
- function G() {
535
- const d = (s.value ?? []).map((n) => ({
536
- ...n,
537
- type: Ge.enum.SKU
538
- }));
539
- p.promptIngredientsBinding(
540
- d,
541
- (n) => s.value = n,
542
- o.sku._id
543
- );
544
- }
545
- return xe(
546
- () => o.show,
547
- (d) => {
548
- d || (s.value = null, i.value = 0);
549
- }
550
- ), (d, n) => {
551
- const a = D("FmTextField"), b = D("FmForm"), c = D("FmCard"), m = D("FmSwitch"), C = D("FmFormGroup"), H = D("FmSelect"), K = D("FmButton"), ee = D("FmSideSheet");
552
- return F(), L(ee, {
553
- "dismiss-away": "",
554
- modelValue: r(T),
555
- "onUpdate:modelValue": n[3] || (n[3] = (E) => Ue(T) ? T.value = E : null),
556
- "max-width": 500
557
- }, {
558
- "side-sheet-header": I(() => [
559
- e("div", tn, [
560
- e("div", nn, _(r($)("inventory.stock.convert.title", { name: d.sku.name })), 1)
561
- ])
562
- ]),
563
- default: I(() => [
564
- e("div", on, [
565
- x(b, {
566
- ref_key: "formRef",
567
- ref: P,
568
- onValidationSuccess: h
569
- }, {
570
- default: I(() => [
571
- x(a, {
572
- disabled: M.value,
573
- "model-value": i.value,
574
- "onUpdate:modelValue": n[0] || (n[0] = (E) => i.value = E),
575
- label: r($)("inventory.stock.convert.amount"),
576
- rules: [t, y, r(Fe)(0)],
577
- "append-text": w.value,
578
- "helper-text": s.value ? void 0 : `Max ${d.maxCount} ${w.value}`
579
- }, null, 8, ["disabled", "model-value", "label", "rules", "append-text", "helper-text"])
580
- ]),
581
- _: 1
582
- }, 512),
583
- x(c, {
584
- variant: "outlined",
585
- class: "p-16"
586
- }, {
587
- default: I(() => [
588
- e("div", sn, [
589
- e("div", an, _(r($)("inventory.stock.convert.deductionSummary")), 1),
590
- (F(!0), O(ne, null, le(j.value, (E) => {
591
- var q, J;
592
- return F(), O("div", {
593
- key: (q = E.sku) == null ? void 0 : q._id,
594
- class: "flex items-center"
595
- }, [
596
- e("div", rn, _((J = E.sku) == null ? void 0 : J.name), 1),
597
- e("div", ln, " -" + _(E.convertAmount) + " " + _(E.abbrev), 1)
598
- ]);
599
- }), 128))
600
- ])
601
- ]),
602
- _: 1
603
- }),
604
- x(c, { variant: "outlined" }, {
605
- default: I(() => [
606
- e("div", un, [
607
- x(m, {
608
- value: "",
609
- modelValue: S.value,
610
- "onUpdate:modelValue": n[1] || (n[1] = (E) => S.value = E),
611
- label: r($)("inventory.stock.convert.overrideDeduction"),
612
- "label-placement": "right"
613
- }, null, 8, ["modelValue", "label"]),
614
- S.value ? (F(), O(ne, { key: 0 }, [
615
- x(C, {
616
- modelValue: s.value,
617
- rules: [r(vt)(1, "Must have at least one ingredient binding")]
618
- }, null, 8, ["modelValue", "rules"]),
619
- e("div", cn, [
620
- e("div", dn, _(r($)("inventory.stock.convert.ingredients")), 1),
621
- (F(!0), O(ne, null, le(s.value, (E) => (F(), L(C, {
622
- key: E.id,
623
- disabled: M.value,
624
- modelValue: +r(me)(E.amount ?? { amount: 1, precision: 0 }),
625
- rules: [
626
- r(yt)(
627
- V.value.find((q) => q._id === E.id).unit,
628
- E.measurement
629
- ),
630
- r(Fe)(0)
631
- ]
632
- }, {
633
- default: I(({ invalid: q }) => {
634
- var J, re, ie;
635
- return [
636
- e("div", mn, [
637
- e("div", pn, _((J = V.value.find((te) => te._id === E.id)) == null ? void 0 : J.name), 1),
638
- x(a, {
639
- class: "xs:col-span-2",
640
- disabled: M.value,
641
- modelValue: +r(me)(
642
- E.amount ?? { amount: 1, precision: 0 }
643
- ),
644
- "onUpdate:modelValue": (te) => W(E.id, te, s.value ?? []),
645
- invalid: q
646
- }, null, 8, ["disabled", "modelValue", "onUpdate:modelValue", "invalid"]),
647
- x(H, {
648
- disabled: M.value,
649
- class: "translate-y-[2px]",
650
- items: U(E.id),
651
- "model-value": (ie = Z(E.id, (re = E.measurement) == null ? void 0 : re.id)) == null ? void 0 : ie.value,
652
- "onUpdate:modelValue": (te) => z(E.id, te, s.value ?? []),
653
- invalid: q
654
- }, {
655
- "helper-text": I(() => n[4] || (n[4] = [])),
656
- _: 2
657
- }, 1032, ["disabled", "items", "model-value", "onUpdate:modelValue", "invalid"]),
658
- x(K, {
659
- disabled: M.value,
660
- type: "button",
661
- variant: "tertiary",
662
- icon: "delete",
663
- onClick: (te) => Q(E.id, s.value ?? [])
664
- }, null, 8, ["disabled", "onClick"])
665
- ])
666
- ];
667
- }),
668
- _: 2
669
- }, 1032, ["disabled", "modelValue", "rules"]))), 128))
670
- ]),
671
- e("div", null, [
672
- x(K, {
673
- icon: "link",
674
- label: r($)("inventory.stock.convert.linkIngredient"),
675
- variant: "plain",
676
- onClick: G
677
- }, null, 8, ["label"])
678
- ])
679
- ], 64)) : se("", !0)
680
- ])
681
- ]),
682
- _: 1
683
- })
684
- ])
685
- ]),
686
- "side-sheet-footer": I(() => [
687
- e("div", fn, [
688
- x(K, {
689
- loading: M.value,
690
- label: r($)("inventory.stock.convert.convertButton"),
691
- onClick: n[2] || (n[2] = (E) => {
692
- var q, J;
693
- return (J = (q = P.value) == null ? void 0 : q.validateInputs) == null ? void 0 : J.call(q);
694
- })
695
- }, null, 8, ["loading", "label"])
696
- ])
697
- ]),
698
- _: 1
699
- }, 8, ["modelValue"]);
700
- };
701
- }
702
- });
703
- function De(v, g) {
704
- const u = Se(v, g);
705
- return { ...u, amount: -u.amount };
706
- }
707
- function Je(v, g) {
708
- return Se(Math.abs(v), g);
709
- }
710
- const je = {
711
- [oe.enum.DAMAGE]: {
712
- label: "Waste",
713
- toAdjustmentAmount: De
714
- },
715
- [oe.enum.THEFT]: {
716
- label: "Theft",
717
- toAdjustmentAmount: De
718
- },
719
- [oe.enum.LOSE]: {
720
- label: "Lose",
721
- toAdjustmentAmount: De
722
- },
723
- [oe.enum.EXTRA]: {
724
- label: "Extra",
725
- toAdjustmentAmount: Je
726
- },
727
- [oe.enum.PURCHASE]: {
728
- label: "Purchase",
729
- toAdjustmentAmount: Je
730
- }
731
- }, yn = { class: "col-span-2 flex" }, _n = { class: "fm-typo-en-body-lg-600 flex-1" }, hn = /* @__PURE__ */ ce({
732
- __name: "AdjustedItemForm",
733
- props: {
734
- modelValue: {},
735
- disabled: { type: Boolean }
736
- },
737
- emits: ["update:modelValue", "click:delete"],
738
- setup(v, { emit: g }) {
739
- const u = v, o = g, A = R(
740
- () => Object.keys(je).map((i) => ({
741
- label: ht(i),
742
- value: i
743
- }))
744
- ), p = R(() => st(u.modelValue.doc.unit, !0)), l = R({
745
- get() {
746
- return u.modelValue.type ?? oe.enum.PURCHASE;
747
- },
748
- set(i) {
749
- const s = {
750
- ...u.modelValue
751
- };
752
- s.type = i;
753
- const V = We(u.modelValue.amount);
754
- s.amount = je[s.type].toAdjustmentAmount(
755
- +me(V),
756
- V.precision
757
- ), o("update:modelValue", s);
758
- }
759
- }), f = R({
760
- get() {
761
- const i = We(u.modelValue.amount);
762
- return +me(i);
763
- },
764
- set(i) {
765
- const s = {
766
- ...u.modelValue
767
- }, V = ve(i);
768
- s.amount = je[l.value].toAdjustmentAmount(
769
- i,
770
- V.precision
771
- ), o("update:modelValue", s);
772
- }
773
- }), B = R({
774
- get() {
775
- var i;
776
- return ((i = u.modelValue.measurement) == null ? void 0 : i.id) ?? null;
777
- },
778
- set(i) {
779
- var V, k;
780
- const s = {
781
- ...u.modelValue
782
- };
783
- s.measurement = ((k = (V = u.modelValue.doc.unit) == null ? void 0 : V.measurements) == null ? void 0 : k.find((S) => S.id === i)) ?? null, o("update:modelValue", s);
784
- }
785
- }), $ = R({
786
- get() {
787
- return u.modelValue.remark ?? "";
788
- },
789
- set(i) {
790
- const s = {
791
- ...u.modelValue
792
- };
793
- s.remark = i, o("update:modelValue", s);
794
- }
795
- });
796
- return (i, s) => {
797
- const V = D("FmButton"), k = D("FmSelect"), S = D("FmTextarea"), M = D("FmCard");
798
- return F(), L(M, {
799
- variant: "outlined",
800
- class: "grid grid-cols-2 gap-8 p-16"
801
- }, {
802
- default: I(() => [
803
- e("div", yn, [
804
- e("div", _n, _(i.modelValue.doc.name), 1),
805
- x(V, {
806
- variant: "tertiary",
807
- "prepend-icon": "delete",
808
- onClick: s[0] || (s[0] = (h) => o("click:delete"))
809
- })
810
- ]),
811
- x(k, {
812
- disabled: i.disabled,
813
- class: "col-span-2",
814
- label: "Type",
815
- items: A.value,
816
- modelValue: l.value,
817
- "onUpdate:modelValue": s[1] || (s[1] = (h) => l.value = h),
818
- rules: [r(kt)()],
819
- "label-mark": "required"
820
- }, null, 8, ["disabled", "items", "modelValue", "rules"]),
821
- x(zt, {
822
- disabled: i.disabled,
823
- label: "Amount",
824
- step: +r(me)({
825
- amount: 1,
826
- precision: r(Ie)(i.modelValue.doc.unit, i.modelValue.measurement)
827
- }),
828
- modelValue: f.value,
829
- "onUpdate:modelValue": s[2] || (s[2] = (h) => f.value = h),
830
- rules: [r(Fe)(0)]
831
- }, null, 8, ["disabled", "step", "modelValue", "rules"]),
832
- x(k, {
833
- disabled: i.disabled,
834
- label: "Unit",
835
- items: p.value,
836
- modelValue: B.value,
837
- "onUpdate:modelValue": s[3] || (s[3] = (h) => B.value = h)
838
- }, null, 8, ["disabled", "items", "modelValue"]),
839
- x(S, {
840
- class: "col-span-2",
841
- disabled: i.disabled,
842
- label: "Remark",
843
- modelValue: $.value,
844
- "onUpdate:modelValue": s[4] || (s[4] = (h) => $.value = h),
845
- "label-mark": "optional"
846
- }, null, 8, ["disabled", "modelValue"])
847
- ]),
848
- _: 1
849
- });
850
- };
851
- }
852
- }), kn = { class: "flex items-center" }, bn = { class: "fm-typo-en-title-md-800" }, gn = { class: "flex items-center" }, xn = { class: "fm-typo-en-title-sm-800 flex-1" }, Sn = { class: "flex gap-8" }, Fn = /* @__PURE__ */ ce({
853
- __name: "AdjustSkuDialog",
854
- props: {
855
- stock: {},
856
- show: { type: Boolean }
857
- },
858
- emits: ["update:show", "submitted"],
859
- setup(v, { expose: g, emit: u }) {
860
- const o = v, A = u, p = Pe(), l = Oe(), f = ye(), B = _e(), $ = N(!1), { t: i } = de();
861
- function s() {
862
- M(He(S));
863
- }
864
- const V = N();
865
- g({
866
- validateInputs: () => {
867
- var y, w;
868
- (w = (y = V.value) == null ? void 0 : y.validateInputs) == null || w.call(y);
869
- },
870
- resetInputsValidation: () => {
871
- var y, w;
872
- (w = (y = V.value) == null ? void 0 : y.resetInputsValidation) == null || w.call(y);
873
- },
874
- resetInputs: () => {
875
- var y, w;
876
- (w = (y = V.value) == null ? void 0 : y.resetInputs) == null || w.call(y);
877
- }
878
- });
879
- const k = Ne(o, "show"), S = it({
880
- remark: "",
881
- adjustments: [
882
- {
883
- id: `sku_${(/* @__PURE__ */ new Date()).toISOString()}_${Math.random().toString(16).slice(2, 8)}`,
884
- type: oe.enum.PURCHASE,
885
- doc: o.stock,
886
- measurement: null,
887
- remark: "",
888
- amount: ve(1)
889
- }
890
- ]
891
- });
892
- xe([() => o.show], ([y]) => {
893
- y && (S.remark = "", S.adjustments = [
894
- {
895
- id: `sku_${(/* @__PURE__ */ new Date()).toISOString()}_${Math.random().toString(16).slice(2, 8)}`,
896
- type: oe.enum.PURCHASE,
897
- doc: o.stock,
898
- measurement: null,
899
- remark: "",
900
- amount: ve(1)
901
- }
902
- ]);
903
- });
904
- async function M(y) {
905
- $.value = !0;
906
- try {
907
- await f.adjustSku({
908
- remark: y.remark,
909
- adjustments: y.adjustments.map(({ doc: w, remark: j, type: P, amount: T, measurement: Y }) => ({
910
- id: w._id,
911
- amount: T,
912
- measurement: Y,
913
- remark: j,
914
- doc: w,
915
- type: P
916
- }))
917
- }), A("update:show", !1), A("submitted");
918
- } catch (w) {
919
- B.open({
920
- title: i("inventory.stock.adjust.error.title"),
921
- message: i("inventory.stock.adjust.error.message"),
922
- type: "error"
923
- }), console.log("error on adjust ingredients", y, w);
924
- } finally {
925
- $.value = !1;
926
- }
927
- }
928
- function h() {
929
- const y = p.skus.map((j) => ({
930
- label: j.name,
931
- sublabel: j.code,
932
- value: j._id
933
- })), w = y.filter((j) => S.adjustments.find((P) => P.doc._id === j.value)).map((j) => j.value);
934
- l.open({
935
- title: "Select ingredients",
936
- contentComponent: bt,
937
- contentComponentProps: {
938
- items: y,
939
- modelValue: w
940
- },
941
- overlay: !0,
942
- closeButton: !0,
943
- dismissAway: !0,
944
- primaryActions: {
945
- text: "Confirm",
946
- close: !0
947
- },
948
- secondaryActions: {
949
- text: "Close",
950
- close: !0,
951
- variant: "tertiary"
952
- }
953
- }).onPrimary((j) => {
954
- S.adjustments = j.map(
955
- (P) => S.adjustments.find((T) => T.doc._id === P) ?? {
956
- id: `sku_${(/* @__PURE__ */ new Date()).toISOString()}_${Math.random().toString(16).slice(2, 8)}`,
957
- type: oe.enum.PURCHASE,
958
- doc: p.skus.find((T) => T._id === P),
959
- measurement: null,
960
- remark: "",
961
- amount: ve(1)
962
- }
963
- );
964
- });
965
- }
966
- function t(y) {
967
- S.adjustments.splice(y, 1);
968
- }
969
- return (y, w) => {
970
- const j = D("FmTextarea"), P = D("FmButton"), T = D("FmForm"), Y = D("FmSideSheet");
971
- return F(), L(Y, {
972
- modelValue: r(k),
973
- "onUpdate:modelValue": w[2] || (w[2] = (W) => Ue(k) ? k.value = W : null),
974
- "dismiss-away": "",
975
- "max-width": 500
976
- }, {
977
- "side-sheet-header": I(() => [
978
- e("div", kn, [
979
- e("div", bn, _(r(i)("inventory.stock.adjust.title")), 1)
980
- ])
981
- ]),
982
- default: I(() => [
983
- x(T, {
984
- class: "w-full flex flex-col gap-12",
985
- ref_key: "formRef",
986
- ref: V,
987
- onValidationSuccess: s
988
- }, {
989
- default: I(() => [
990
- x(j, {
991
- label: r(i)("inventory.stock.adjust.remark"),
992
- modelValue: S.remark,
993
- "onUpdate:modelValue": w[0] || (w[0] = (W) => S.remark = W)
994
- }, null, 8, ["label", "modelValue"]),
995
- e("div", gn, [
996
- e("div", xn, _(r(i)("inventory.stock.adjust.adjustedItems")), 1),
997
- x(P, {
998
- "prepend-icon": "add",
999
- variant: "tertiary",
1000
- size: "md",
1001
- onClick: h
1002
- })
1003
- ]),
1004
- (F(!0), O(ne, null, le(S.adjustments, (W, U) => (F(), L(hn, {
1005
- key: W.id,
1006
- modelValue: S.adjustments[U],
1007
- "onUpdate:modelValue": (Z) => S.adjustments[U] = Z,
1008
- "onClick:delete": (Z) => t(U)
1009
- }, null, 8, ["modelValue", "onUpdate:modelValue", "onClick:delete"]))), 128))
1010
- ]),
1011
- _: 1
1012
- }, 512)
1013
- ]),
1014
- "side-sheet-footer": I(() => [
1015
- e("div", Sn, [
1016
- x(P, {
1017
- label: r(i)("inventory.stock.adjust.adjustButton"),
1018
- loading: $.value,
1019
- onClick: w[1] || (w[1] = (W) => {
1020
- var U, Z;
1021
- return (Z = (U = V.value) == null ? void 0 : U.validateInputs) == null ? void 0 : Z.call(U);
1022
- })
1023
- }, null, 8, ["label", "loading"])
1024
- ])
1025
- ]),
1026
- _: 1
1027
- }, 8, ["modelValue"]);
1028
- };
1029
- }
1030
- }), wn = gt((v, g) => ({
1031
- // TODO: remove once latest inventory backend has been push
1032
- async findBillsByBusinessId(u, o, A) {
1033
- const p = `${v.businessesBackendUrl}/${u}/reports/find-many`, l = {
1034
- // type: TYPE.bill,
1035
- type: "bill",
1036
- restaurantIds: o,
1037
- ids: A
1038
- };
1039
- return await g.post(p, l);
1040
- },
1041
- async findBillsById(u) {
1042
- const A = pe().currentLocationDBName, p = `${v.inventoryBackendUrl}/${A}/bill/search`, l = {
1043
- ids: u
1044
- };
1045
- return await g.post(p, l);
1046
- }
1047
- })), $n = {
1048
- key: 0,
1049
- class: "flex justify-center items-center h-32"
1050
- }, An = { class: "mb-3" }, Vn = { class: "flex flex-col gap-8" }, Cn = { class: "flex flex-col text-fm-color-typo-primary mb-3 text-center" }, Bn = { 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" }, Dn = { class: "flex flex-col gap-4 text-fm-color-typo-primary mb-3" }, jn = { class: "flex flex-col gap-4 text-fm-color-typo-primary mb-3" }, In = { class: "flex flex-col w-full px-2" }, Tn = { class: "flex gap-2" }, Un = /* @__PURE__ */ ce({
1051
- __name: "AmendAdjustmentForm",
1052
- props: /* @__PURE__ */ Ye({
1053
- adjustmentId: {}
1054
- }, {
1055
- modelValue: {},
1056
- modelModifiers: {}
1057
- }),
1058
- emits: /* @__PURE__ */ Ye(["refreshHistory"], ["update:modelValue"]),
1059
- setup(v, { emit: g }) {
1060
- const u = v, o = g, A = ye(), p = ut(v, "modelValue"), l = N(!1), f = N(!1), B = N(!1), $ = N({
1061
- _id: `inventoryAdjustment_${(/* @__PURE__ */ new Date()).toISOString()}_XXXXX`,
1062
- skus: []
1063
- }), i = N();
1064
- Ee(async () => {
1065
- l.value = !0;
1066
- const h = await A.readSingleAdjustment(u.adjustmentId);
1067
- if (!h) throw new Error("Adjustment not found");
1068
- $.value = h, l.value = !1;
1069
- });
1070
- async function s() {
1071
- var t, y;
1072
- if ((y = (t = i == null ? void 0 : i.value) == null ? void 0 : t.validateInputs) == null || y.call(t), !f.value) return;
1073
- const h = {};
1074
- Object.keys(p.value || {}).forEach((w) => {
1075
- var j;
1076
- Object.keys(((j = p.value) == null ? void 0 : j[w]) || {}).forEach((P) => {
1077
- var Y, W;
1078
- const T = (W = (Y = p.value) == null ? void 0 : Y[w]) == null ? void 0 : W[Number(P)];
1079
- T && k(T.amount) > 0 && (h[w] || (h[w] = []), h[w].push(T));
1080
- });
1081
- }), await A.revertWastageAdjustment({
1082
- targetWastageAdjustmentId: u.adjustmentId,
1083
- amountsGoingToAdjust: h
1084
- }), o("refreshHistory"), B.value = !1, p.value = {};
1085
- }
1086
- function V(h, t, y) {
1087
- return R({
1088
- get: () => {
1089
- var j, P, T;
1090
- const w = (T = (P = (j = p.value) == null ? void 0 : j[h]) == null ? void 0 : P[t]) == null ? void 0 : T.amount;
1091
- return w ? k(w, !0) : 0;
1092
- },
1093
- set: (w) => {
1094
- p.value || (p.value = {});
1095
- const j = { ...p.value };
1096
- j[h] || (j[h] = {}), j[h][t] = {
1097
- amount: Ce.fromNumber(w),
1098
- type: oe.Enum.WASTAGE,
1099
- measurement: y
1100
- }, p.value = j;
1101
- }
1102
- });
1103
- }
1104
- function k(h, t = !0) {
1105
- const y = Number(Ce.toFormatString({ value: h }));
1106
- return t ? Math.abs(y) : y;
1107
- }
1108
- function S(h, t) {
1109
- return t.measurement ? t.measurement.abbrev : h.sku.unit.abbrev;
1110
- }
1111
- function M(h, t) {
1112
- return t === 0 ? "N/A" : (h + t).toString();
1113
- }
1114
- return (h, t) => {
1115
- const y = D("FmIcon"), w = D("FmStepperField"), j = D("FmCard"), P = D("FmForm"), T = D("FmSpacer"), Y = D("FmButton"), W = D("FmDialog");
1116
- return F(), L(W, {
1117
- modelValue: B.value,
1118
- "onUpdate:modelValue": t[4] || (t[4] = (U) => B.value = U),
1119
- overlay: !0
1120
- }, {
1121
- "dialog-button": I(() => [
1122
- e("button", {
1123
- onClick: t[0] || (t[0] = (U) => B.value = !0),
1124
- class: "rounded-md hover:bg-gray-100 transition-colors"
1125
- }, [
1126
- x(Gt, null, {
1127
- default: I(() => [
1128
- x(y, {
1129
- name: "edit",
1130
- size: "sm"
1131
- })
1132
- ]),
1133
- _: 1
1134
- })
1135
- ])
1136
- ]),
1137
- "dialog-header": I(() => t[5] || (t[5] = [
1138
- e("div", null, "Amend Adjustment", -1)
1139
- ])),
1140
- "dialog-footer": I(() => [
1141
- e("div", In, [
1142
- 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)),
1143
- e("div", Tn, [
1144
- x(T),
1145
- x(Y, {
1146
- class: "sm:w-full xs:w-full",
1147
- label: "Close",
1148
- size: "md",
1149
- variant: "tertiary",
1150
- onClick: t[3] || (t[3] = (U) => B.value = !1)
1151
- }),
1152
- x(Y, {
1153
- class: "sm:w-full xs:w-full",
1154
- label: "Submit",
1155
- size: "md",
1156
- variant: "primary",
1157
- onClick: s
1158
- })
1159
- ])
1160
- ])
1161
- ]),
1162
- default: I(() => [
1163
- l.value ? (F(), O("div", $n)) : (F(), L(P, {
1164
- key: 1,
1165
- ref_key: "formRef",
1166
- ref: i,
1167
- onValidationFailed: t[1] || (t[1] = () => {
1168
- f.value = !1;
1169
- }),
1170
- onValidationSuccess: t[2] || (t[2] = () => {
1171
- f.value = !0;
1172
- }),
1173
- blameFormChildOnValidationFailed: ""
1174
- }, {
1175
- default: I(() => [
1176
- e("p", An, [
1177
- t[6] || (t[6] = e("b", null, "Date:", -1)),
1178
- t[7] || (t[7] = e("br", null, null, -1)),
1179
- ue(" " + _(r(xt)(r(St)($.value._id))), 1)
1180
- ]),
1181
- e("div", Vn, [
1182
- (F(!0), O(ne, null, le($.value.skus, (U, Z) => (F(), O(ne, { key: Z }, [
1183
- (F(!0), O(ne, null, le(U.amounts, (z, Q) => (F(), L(j, {
1184
- key: Q,
1185
- variant: "outlined",
1186
- class: "p-2"
1187
- }, {
1188
- default: I(() => [
1189
- e("div", Cn, [
1190
- e("span", Bn, _(U.sku.code), 1),
1191
- e("span", null, _(U.sku.name), 1)
1192
- ]),
1193
- t[12] || (t[12] = e("hr", { class: "m-2" }, null, -1)),
1194
- e("div", Mn, [
1195
- t[8] || (t[8] = e("span", { class: "fm-typo-en-body-lg-600" }, "Adjustment type:", -1)),
1196
- e("span", null, _(z.type), 1)
1197
- ]),
1198
- e("div", Dn, [
1199
- t[9] || (t[9] = e("span", { class: "fm-typo-en-body-lg-600" }, "Current amount:", -1)),
1200
- e("span", null, _(r(Ce).toFormatString({ value: z.amount })) + " " + _(S(U, z)), 1)
1201
- ]),
1202
- x(w, {
1203
- "model-value": V(U.sku._id, Q).value,
1204
- "onUpdate:modelValue": (G) => V(U.sku._id, Q).value = G,
1205
- class: "mb-3",
1206
- label: "Adjust Amount (Leave 0 to skip)",
1207
- "helper-text": `Max: ${k(z.amount)}`,
1208
- "append-text": S(U, z),
1209
- rules: [
1210
- (G) => G <= k(z.amount) || `Cannot be more than ${k(z.amount)}`,
1211
- r(Fe)(-1)
1212
- ]
1213
- }, null, 8, ["model-value", "onUpdate:modelValue", "helper-text", "append-text", "rules"]),
1214
- e("div", jn, [
1215
- t[10] || (t[10] = e("span", { class: "fm-typo-en-body-lg-600" }, "Amount after amend:", -1)),
1216
- 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)),
1217
- ue(" " + _(M(
1218
- k(z.amount, !1),
1219
- V(U.sku._id, Q).value
1220
- )) + " " + _(S(U, z)), 1)
1221
- ])
1222
- ]),
1223
- _: 2
1224
- }, 1024))), 128))
1225
- ], 64))), 128))
1226
- ])
1227
- ]),
1228
- _: 1
1229
- }, 512))
1230
- ]),
1231
- _: 1
1232
- }, 8, ["modelValue"]);
1233
- };
1234
- }
1235
- }), En = { class: "p-16" }, Hn = { class: "fm-typo-en-body-md-600 flex-grow" }, Pn = { class: "flex-grow text-fm-color-typo-secondary" }, Rn = {
1236
- key: 0,
1237
- class: "my-5"
1238
- }, On = { class: "text-neutral-400" }, Nn = { class: "flex-grow" }, Ln = { class: "flex gap-1" }, zn = { class: "flex flex-col gap-1" }, Yn = {
1239
- key: 1,
1240
- class: "t-system text-fsecondary"
1241
- }, Gn = {
1242
- key: 2,
1243
- 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"
1244
- }, Wn = {
1245
- key: 1,
1246
- class: "shrink-0 text-fm-color-typo-secondary"
1247
- }, Kn = /* @__PURE__ */ ce({
1248
- __name: "StockRecordCard",
1249
- props: {
1250
- record: {},
1251
- sku: {},
1252
- bills: { default: () => [] }
1253
- },
1254
- emits: ["refreshHistory"],
1255
- setup(v, { emit: g }) {
1256
- const u = v, o = N(!1), A = at(), p = N(), l = N(null), f = R(() => l.value === null ? "unset" : o.value ? `${l.value}px` : "0px");
1257
- Ee(() => {
1258
- var s;
1259
- l.value = ((s = p.value) == null ? void 0 : s.scrollHeight) || 0;
1260
- });
1261
- const B = R(() => {
1262
- var h;
1263
- const s = u.record.adjustments, V = u.sku, k = {}, M = s.flatMap((t) => {
1264
- var y;
1265
- return ((y = t.skus) == null ? void 0 : y.filter((w) => w.sku._id === V._id)) ?? [];
1266
- }).flatMap((t) => t.amounts);
1267
- for (const t of M) {
1268
- const y = t.measurement ? Ft(t.measurement.conversion, t.amount) : t.amount;
1269
- k[h = t.type] ?? (k[h] = { amount: 0, precision: 0 }), k[t.type] = et(y, k[t.type]);
1270
- }
1271
- return Object.entries(k).reduce(
1272
- (t, [y, w]) => (t[y] = /// comment, because without it formatter makes code uglier
1273
- `${X.toFormatString({
1274
- value: w,
1275
- precision: 4
1276
- })} ${V.unit.abbrev}`, t),
1277
- {}
1278
- );
1279
- }), { t: $ } = de(), i = R(() => u.record.adjustmentsByTime.map(({ date: s, adjustments: V }) => ({
1280
- time: wt(new Date(s)),
1281
- adjustments: V.flatMap(
1282
- (k) => {
1283
- var S, M;
1284
- return ((M = (S = k.skus) == null ? void 0 : S.map) == null ? void 0 : M.call(S, (h) => {
1285
- var t, y;
1286
- return {
1287
- ...h,
1288
- ref: k.ref,
1289
- backdateFrom: k.effectiveAt != null ? ot(k._id) : null,
1290
- toBalance: (y = (t = k.skus) == null ? void 0 : t[0]) == null ? void 0 : y.toBalance,
1291
- adjustmentId: k._id
1292
- };
1293
- })) ?? [];
1294
- }
1295
- ).flatMap((k) => {
1296
- var h;
1297
- const S = (h = u.bills.find((t) => t._id === k.ref)) == null ? void 0 : h.seqNumber, M = S ? $("inventory.stock.record.bill", [S]) : "";
1298
- return k.amounts.map((t) => {
1299
- var y;
1300
- return {
1301
- amount: `${X.toFormatString({ value: t.amount, precision: 4 })} ${((y = t.measurement) == null ? void 0 : y.abbrev) ?? k.sku.unit.abbrev}`,
1302
- backdateFrom: k.backdateFrom,
1303
- name: t.type,
1304
- remark: t.remark || M || "",
1305
- cost: t.cost,
1306
- toBalance: X.toFormatString({
1307
- value: k.toBalance ?? X.fromNumber(0),
1308
- precision: 4
1309
- }),
1310
- baseUnit: k.sku.unit.abbrev,
1311
- adjustmentId: k.adjustmentId
1312
- };
1313
- });
1314
- })
1315
- })));
1316
- return (s, V) => {
1317
- const k = D("FmIcon"), S = D("FmTooltip"), M = D("FmCard");
1318
- return F(), L(M, { variant: "outlined" }, {
1319
- default: I(() => [
1320
- e("div", En, [
1321
- e("div", {
1322
- class: "flex items-center cursor-pointer mb-1",
1323
- onClick: V[0] || (V[0] = (h) => o.value = !o.value)
1324
- }, [
1325
- e("div", Hn, _(s.record.date), 1),
1326
- x(k, {
1327
- name: o.value ? "expand_more" : "expand_less",
1328
- color: "#777777",
1329
- size: "md"
1330
- }, null, 8, ["name"])
1331
- ]),
1332
- (F(!0), O(ne, null, le(B.value, (h, t) => (F(), O("div", {
1333
- key: t,
1334
- class: "flex flex-row py-1",
1335
- style: { "font-size": "0.8rem" }
1336
- }, [
1337
- e("div", Pn, _(r($)(`inventory.inventoryAdjustment.type.${t}`)), 1),
1338
- e("div", {
1339
- class: ge({
1340
- "text-fm-color-typo-error": h.startsWith("-"),
1341
- "text-fm-color-typo-success": !h.startsWith("-"),
1342
- "ml-auto": !0
1343
- })
1344
- }, _(h), 3)
1345
- ]))), 128)),
1346
- e("div", {
1347
- ref_key: "detailRef",
1348
- ref: p,
1349
- style: Ze({
1350
- fontSize: "0.8rem",
1351
- maxHeight: f.value,
1352
- overflow: "hidden",
1353
- transition: "max-height 0.2s ease-out"
1354
- })
1355
- }, [
1356
- i.value.length ? (F(), O("hr", Rn)) : se("", !0),
1357
- (F(!0), O(ne, null, le(i.value, (h) => (F(), O("div", {
1358
- key: h.time,
1359
- class: "flex gap-1 w-full"
1360
- }, [
1361
- e("div", On, _(h.time), 1),
1362
- e("div", Nn, [
1363
- (F(!0), O(ne, null, le(h.adjustments, (t) => {
1364
- var y;
1365
- return F(), O("div", {
1366
- key: t.name,
1367
- class: "flex gap-1"
1368
- }, [
1369
- e("div", Ln, [
1370
- ue(_(r($)(`inventory.inventoryAdjustment.type.${t.name}`)) + " ", 1),
1371
- t.backdateFrom ? (F(), L(S, {
1372
- key: 0,
1373
- variant: "plain",
1374
- placement: "top",
1375
- "z-index": 50
1376
- }, {
1377
- content: I(() => [
1378
- e("div", zn, _(r($)("inventory.stock.record.backdate", [
1379
- r(tt)(new Date(t.backdateFrom))
1380
- ])), 1)
1381
- ]),
1382
- default: I(() => [
1383
- x(k, {
1384
- name: "info",
1385
- size: "sm",
1386
- color: "primary"
1387
- })
1388
- ]),
1389
- _: 2
1390
- }, 1024)) : se("", !0),
1391
- t.remark ? (F(), O("span", Yn, " # " + _(t.remark), 1)) : se("", !0),
1392
- t.name === r(oe).Enum.CLOSING ? (F(), O("span", Gn, " Actual Balance: " + _(t.toBalance) + " " + _(t.baseUnit), 1)) : se("", !0)
1393
- ]),
1394
- e("div", {
1395
- class: ge({
1396
- "text-fm-color-typo-error": t.amount.startsWith("-"),
1397
- "text-fm-color-typo-success": !t.amount.startsWith("-"),
1398
- "ml-auto": !0
1399
- })
1400
- }, _(t.amount), 3),
1401
- t.name === r(oe).Enum.WASTAGE && ((y = r(A).sessionUser.value) != null && y.role.isAdmin) ? (F(), L(Un, {
1402
- key: 0,
1403
- adjustmentId: t.adjustmentId,
1404
- onRefreshHistory: V[1] || (V[1] = (w) => s.$emit("refreshHistory"))
1405
- }, null, 8, ["adjustmentId"])) : se("", !0),
1406
- t.cost ? (F(), O("div", Wn, " (" + _(r(ke)(t.cost, !1, t.cost.precision)) + ") ", 1)) : se("", !0)
1407
- ]);
1408
- }), 128))
1409
- ])
1410
- ]))), 128))
1411
- ], 4)
1412
- ])
1413
- ]),
1414
- _: 1
1415
- });
1416
- };
1417
- }
1418
- });
1419
- function qn(v, g) {
1420
- var p;
1421
- const u = Object.keys(oe.enum).reduce(
1422
- (l, f) => (l[f] = { amount: 0, precision: 0 }, l),
1423
- {}
1424
- );
1425
- if (!g)
1426
- return Object.entries(u).reduce(
1427
- (l, [f]) => (l[f] = X.fromNumber(0), l),
1428
- {}
1429
- );
1430
- const A = v.flatMap((l) => {
1431
- var f;
1432
- return ((f = l.skus) == null ? void 0 : f.filter((B) => B.sku._id === g._id)) ?? [];
1433
- }).flatMap((l) => l.amounts);
1434
- for (const l of A) {
1435
- const f = l.measurement ? X.multiply([l.measurement.conversion, l.amount]) : l.amount;
1436
- u[p = l.type] ?? (u[p] = { amount: 0, precision: 0 }), u[l.type] = X.add([f, u[l.type]]);
1437
- }
1438
- return Object.entries(u).reduce(
1439
- (l, [f, B]) => {
1440
- const $ = {
1441
- ...B,
1442
- amount: Math.abs(B.amount)
1443
- };
1444
- return l[f] = /// comment, because without it formatter makes code uglier
1445
- `${X.toFormatString({
1446
- value: $,
1447
- precision: 4
1448
- })} ${g.unit.abbrev}`, l;
1449
- },
1450
- {}
1451
- );
1452
- }
1453
- function Xn(v, g) {
1454
- if (!g)
1455
- return null;
1456
- let u = null;
1457
- const A = v.flatMap((p) => {
1458
- var l;
1459
- return ((l = p.skus) == null ? void 0 : l.filter((f) => f.sku._id === g._id)) ?? [];
1460
- }).flatMap((p) => {
1461
- var l;
1462
- return !p.history || ((l = p.history) == null ? void 0 : l.length) === 0 ? [] : p.history[0];
1463
- });
1464
- for (const p of A) {
1465
- const l = p.amounts;
1466
- for (const f of l) {
1467
- if (f.type !== oe.Enum.SALES)
1468
- continue;
1469
- const B = f.measurement ? X.multiply([f.measurement.conversion, f.amount]) : f.amount;
1470
- u ?? (u = X.fromNumber(0)), u = X.add([u, B]);
1471
- }
1472
- }
1473
- return u != null ? (u.amount = Math.abs(u.amount), `${X.toFormatString({
1474
- value: u,
1475
- precision: 4
1476
- })} ${g.unit.abbrev}`) : null;
1477
- }
1478
- const Qn = { class: "flex items-center w-full fm-typo-en-title-md-800" }, Jn = { class: "flex-1 line-clamp-2" }, Zn = { class: "flex flex-col gap-32 w-full h-full" }, eo = { class: "flex items-center relative gap-4" }, to = { class: "flex-1" }, no = {
1479
- key: 0,
1480
- class: "flex-1 flex flex-col items-center gap-16"
1481
- }, oo = { class: "fm-typo-en-body-lg-400 translate-x-4" }, so = {
1482
- key: 1,
1483
- class: "flex flex-col gap-12"
1484
- }, ao = { class: "pb-16" }, ro = { class: "fm-typo-cn-body-lg-600" }, lo = {
1485
- class: "grid gap-12 fm-typo-en-body-md-400",
1486
- style: { "grid-template-columns": "auto auto auto", "grid-auto-rows": "1fr" }
1487
- }, io = { class: "flex flex-col gap-1" }, uo = { class: "text-fm-color-typo-secondary" }, co = { class: "font-bold" }, mo = { class: "flex flex-col gap-1" }, po = { class: "text-fm-color-typo-secondary flex" }, fo = { class: "font-bold" }, vo = { class: "flex flex-col gap-1" }, yo = { class: "text-fm-color-typo-secondary" }, _o = { class: "font-bold" }, ho = { class: "flex flex-col gap-1" }, ko = { class: "text-fm-color-typo-secondary" }, bo = { class: "font-bold" }, go = { class: "flex flex-col gap-1" }, xo = { class: "text-fm-color-typo-secondary" }, So = { class: "font-bold" }, Fo = { class: "flex flex-col gap-1" }, wo = { class: "text-fm-color-typo-secondary" }, $o = { class: "font-bold" }, Ao = { class: "flex flex-col gap-1" }, Vo = { class: "text-fm-color-typo-secondary" }, Co = { class: "font-bold" }, Bo = { class: "flex flex-col gap-1" }, Mo = { class: "text-fm-color-typo-secondary" }, Do = { class: "font-bold" }, jo = { class: "flex flex-col gap-1" }, Io = { class: "text-fm-color-typo-secondary" }, To = { class: "font-bold" }, Uo = {
1488
- key: 0,
1489
- class: "flex flex-col gap-8"
1490
- }, Eo = { class: "flex" }, Ho = { class: "flex-1 flex flex-col gap-1" }, Po = { class: "flex gap-1 items-center text-fm-color-typo-secondary" }, Ro = { class: "font-bold" }, Oo = { class: "flex-1 flex flex-col gap-1" }, No = { class: "flex gap-1 items-center text-fm-color-typo-secondary" }, Lo = { class: "flex flex-col gap-1" }, zo = { class: "font-bold" }, Yo = {
1491
- key: 2,
1492
- class: "flex-1 flex flex-col items-center gap-8"
1493
- }, Go = ["src"], Wo = { class: "font-bold text-lg" }, Ko = { class: "text-xs text-neutral-400 text-center" }, qo = /* @__PURE__ */ ce({
1494
- __name: "StockHistory",
1495
- props: {
1496
- sku: {},
1497
- show: { type: Boolean }
1498
- },
1499
- emits: ["update:show"],
1500
- setup(v) {
1501
- const g = at(), u = Re(), o = ye(), A = wn(), p = pe(), l = Ct(), { t: f } = de(), B = v, $ = N(!1), i = _e(), s = N($t(0));
1502
- async function V() {
1503
- $.value = !0;
1504
- try {
1505
- await y(), await u.readStockBalance();
1506
- } catch (n) {
1507
- i.open({
1508
- title: "Something went wrong",
1509
- message: "Cannot fetch stock history. Please try again.",
1510
- type: "error"
1511
- }), console.log("failed at fetching item adjustment history", B.sku, s, n);
1512
- } finally {
1513
- $.value = !1;
1514
- }
1515
- }
1516
- Ee(() => {
1517
- V();
1518
- }), xe([() => s.value, () => B.sku], () => {
1519
- V();
1520
- });
1521
- const k = N([]), S = N([]), M = N(new Array());
1522
- function h(n, a) {
1523
- return a === "day" ? It(n) : tt(n);
1524
- }
1525
- function t(n, a) {
1526
- const b = n.reduce(
1527
- (c, m) => {
1528
- const C = m.effectiveAt ?? ot(m._id);
1529
- if (!C)
1530
- return c;
1531
- const H = h(new Date(C), a);
1532
- return c[H] ?? (c[H] = []), c[H].push(m), c;
1533
- },
1534
- {}
1535
- );
1536
- return Object.keys(b).map((c) => ({
1537
- date: c,
1538
- adjustments: b[c]
1539
- }));
1540
- }
1541
- async function y() {
1542
- let n = await o.readStockAdjustment(
1543
- B.sku._id,
1544
- Bt(new Date(s.value.startDate)).toISOString(),
1545
- Mt(new Date(s.value.endDate)).toISOString()
1546
- );
1547
- k.value = n;
1548
- const a = n.filter(({ ref: b }) => b == null ? void 0 : b.startsWith("bill_")).map(({ ref: b }) => b);
1549
- await w(a), S.value = t(n, "day").map(({ date: b, adjustments: c }) => ({
1550
- date: b,
1551
- adjustments: c,
1552
- adjustmentsByTime: t(c, "minute")
1553
- }));
1554
- }
1555
- async function w(n) {
1556
- n.length && (M.value = await A.findBillsById(n).catch((a) => {
1557
- var m;
1558
- console.error("Error on using latest bill API, retrying using legacy api", a);
1559
- const b = ((m = g.currentBusiness.value) == null ? void 0 : m._id) ?? "", c = p.currentLocation.doc._id;
1560
- return A.findBillsByBusinessId(b, [c], n);
1561
- }));
1562
- }
1563
- const j = R(() => {
1564
- const n = k.value, a = B.sku;
1565
- return qn(n, a);
1566
- }), P = R(() => {
1567
- const n = k.value, a = B.sku;
1568
- return Xn(n, a);
1569
- }), T = R(() => {
1570
- const n = [...k.value].computeFirst((b) => {
1571
- var m, C;
1572
- const c = (C = (m = b.skus) == null ? void 0 : m.find) == null ? void 0 : C.call(m, (H) => H.sku._id === B.sku._id);
1573
- return c == null ? void 0 : c.fromBalance;
1574
- }) ?? {
1575
- amount: 0,
1576
- precision: 0
1577
- }, a = B.sku;
1578
- return a ? `${X.toFormatString({
1579
- value: n,
1580
- precision: 4
1581
- })} ${a.unit.abbrev}` : "";
1582
- }), Y = R(() => {
1583
- const n = [...k.value].reverse().computeFirst((b) => {
1584
- var m, C;
1585
- const c = (C = (m = b.skus) == null ? void 0 : m.find) == null ? void 0 : C.call(m, (H) => H.sku._id === B.sku._id);
1586
- return c == null ? void 0 : c.toBalance;
1587
- }) ?? {
1588
- amount: 0,
1589
- precision: 0
1590
- }, a = B.sku;
1591
- return a ? `${X.toFormatString({ value: n, precision: 4 })} ${a.unit.abbrev}` : "";
1592
- }), W = R(() => {
1593
- var b;
1594
- const a = k.value.flatMap((c) => {
1595
- var m;
1596
- return ((m = c.skus) == null ? void 0 : m.flatMap((C) => C.amounts)) ?? [];
1597
- }).filter((c) => c.amount.amount < 0).reduce(
1598
- (c, m) => {
1599
- const C = m.cost;
1600
- if (!C) return c;
1601
- const H = {
1602
- ...At(c, Math.max(c.precision, C.precision)),
1603
- currency: C.currency
1604
- };
1605
- return {
1606
- ...et(H, C),
1607
- currency: c.currency
1608
- };
1609
- },
1610
- {
1611
- amount: 0,
1612
- precision: 0,
1613
- currency: Be((b = g.currentCountry) == null ? void 0 : b.value)
1614
- }
1615
- );
1616
- return ke(a, !1, a.precision);
1617
- });
1618
- function U() {
1619
- const { startDate: n, endDate: a } = Dt(s.value);
1620
- n !== null && a !== null && (s.value = {
1621
- startDate: n,
1622
- endDate: a
1623
- });
1624
- }
1625
- const Z = R(() => B.sku.valuation === Ke.Enum.FIFO ? f("inventory.ingredient.valuationMethod.FIFO") : f("inventory.ingredient.valuationMethod.WAVG")), z = R(() => {
1626
- var H, K, ee, E;
1627
- const n = [...k.value].reverse().computeFirst((q) => {
1628
- var J, re;
1629
- return (re = (J = q.skus) == null ? void 0 : J.find) == null ? void 0 : re.call(J, (ie) => ie.sku._id === B.sku._id);
1630
- });
1631
- if (!n) return "No data";
1632
- const a = [...n.amounts].reverse()[0], b = {
1633
- amount: ((H = a.cost) == null ? void 0 : H.amount) ?? 0,
1634
- precision: ((K = a.cost) == null ? void 0 : K.precision) ?? 0
1635
- }, c = a.amount, m = c.amount == 0 ? X.fromNumber(0) : X.divide([b, c]);
1636
- return {
1637
- ...X.multiply([m, c]),
1638
- currency: ((ee = a.cost) == null ? void 0 : ee.currency) || Be(((E = g.currentCountry) == null ? void 0 : E.value) ?? Vt)
1639
- };
1640
- }), Q = R(() => {
1641
- var b;
1642
- const n = [...k.value].reverse().computeFirst((c) => {
1643
- var C, H;
1644
- const m = (H = (C = c.skus) == null ? void 0 : C.find) == null ? void 0 : H.call(C, (K) => K.sku._id === B.sku._id);
1645
- return m == null ? void 0 : m.toCostBalances;
1646
- });
1647
- return n ? {
1648
- ...n.reduce((c, m) => X.add([c, X.fromDinero(m.cost)]), {
1649
- amount: 0,
1650
- precision: 0
1651
- }),
1652
- currency: Be((b = g.currentCountry) == null ? void 0 : b.value)
1653
- } : "No data";
1654
- });
1655
- function G() {
1656
- const { startDate: n, endDate: a } = jt(s.value);
1657
- n !== null && a !== null && (s.value = {
1658
- startDate: n,
1659
- endDate: a
1660
- });
1661
- }
1662
- const d = Ne(B, "show");
1663
- return (n, a) => {
1664
- const b = D("FmButton"), c = D("FmField"), m = D("FmDateRangePicker"), C = D("FmSpacer"), H = D("FmCircularProgress"), K = D("FmIcon"), ee = D("FmTooltip"), E = D("FmMenuDivider"), q = D("FmChip"), J = D("FmCardSection"), re = D("FmCard"), ie = D("FmSideSheet");
1665
- return F(), L(ie, {
1666
- "dismiss-away": "",
1667
- modelValue: r(d),
1668
- "onUpdate:modelValue": a[4] || (a[4] = (te) => Ue(d) ? d.value = te : null),
1669
- "close-button": !1,
1670
- "max-width": 560
1671
- }, {
1672
- "side-sheet-header": I(() => [
1673
- e("div", Qn, [
1674
- e("div", Jn, _(r(f)("inventory.stock.history.title", [n.sku.name])), 1),
1675
- x(b, {
1676
- variant: "tertiary",
1677
- "prepend-icon": "close",
1678
- onClick: a[0] || (a[0] = (te) => d.value = !1)
1679
- })
1680
- ])
1681
- ]),
1682
- default: I(() => {
1683
- var te;
1684
- return [
1685
- e("div", Zn, [
1686
- e("div", eo, [
1687
- e("div", to, [
1688
- x(m, {
1689
- modelValue: s.value,
1690
- "onUpdate:modelValue": a[1] || (a[1] = (ae) => s.value = ae),
1691
- "show-predefined-range": "",
1692
- "start-label": "",
1693
- "end-label": "",
1694
- "z-index": 50
1695
- }, {
1696
- "trigger-button": I(({ opened: ae }) => [
1697
- x(c, {
1698
- "prepend-icon": "calendar_month",
1699
- focused: ae
1700
- }, {
1701
- default: I(() => [
1702
- ue(_(s.value.startDate) + " - " + _(s.value.endDate), 1)
1703
- ]),
1704
- _: 2
1705
- }, 1032, ["focused"])
1706
- ]),
1707
- _: 1
1708
- }, 8, ["modelValue"])
1709
- ]),
1710
- x(b, {
1711
- variant: "tertiary",
1712
- onClick: a[2] || (a[2] = (ae) => U()),
1713
- "prepend-icon": "navigate_before"
1714
- }),
1715
- x(b, {
1716
- variant: "tertiary",
1717
- onClick: a[3] || (a[3] = (ae) => G()),
1718
- "prepend-icon": "navigate_next"
1719
- })
1720
- ]),
1721
- $.value ? (F(), O("div", no, [
1722
- x(C),
1723
- x(H, { size: "xl" }),
1724
- e("div", oo, _(r(f)("inventory.stock.history.loading")), 1),
1725
- x(C),
1726
- x(C)
1727
- ])) : S.value && ((te = S.value) == null ? void 0 : te.length) > 0 ? (F(), O("div", so, [
1728
- x(re, { variant: "outlined" }, {
1729
- default: I(() => [
1730
- x(J, { class: "flex flex-col gap-4" }, {
1731
- default: I(() => [
1732
- e("div", ao, [
1733
- e("div", ro, _(r(f)("inventory.stock.history.summary.title")), 1)
1734
- ]),
1735
- e("div", lo, [
1736
- e("div", io, [
1737
- e("div", uo, _(r(f)("inventory.stock.history.summary.totalPurchase")), 1),
1738
- e("div", co, _(j.value.PURCHASE), 1)
1739
- ]),
1740
- e("div", mo, [
1741
- e("div", po, [
1742
- ue(_(r(f)("inventory.stock.history.summary.totalSales")) + "  ", 1),
1743
- P.value != null ? (F(), L(ee, {
1744
- key: 0,
1745
- variant: "plain",
1746
- placement: "top",
1747
- content: `Before: ${P.value}`,
1748
- "z-index": 50
1749
- }, {
1750
- default: I(() => [
1751
- x(K, {
1752
- name: "warning",
1753
- size: "sm"
1754
- })
1755
- ]),
1756
- _: 1
1757
- }, 8, ["content"])) : se("", !0)
1758
- ]),
1759
- e("div", fo, _(j.value.SALES), 1)
1760
- ]),
1761
- e("div", vo, [
1762
- e("div", yo, _(r(f)("inventory.stock.history.summary.totalLose")), 1),
1763
- e("div", _o, _(j.value.LOSE), 1)
1764
- ]),
1765
- e("div", ho, [
1766
- e("div", ko, _(r(f)("inventory.stock.history.summary.totalRequest")), 1),
1767
- e("div", bo, _(j.value.REQUEST), 1)
1768
- ]),
1769
- e("div", go, [
1770
- e("div", xo, _(r(f)("inventory.stock.history.summary.totalReceive")), 1),
1771
- e("div", So, _(j.value.RECEIVE), 1)
1772
- ]),
1773
- e("div", Fo, [
1774
- e("div", wo, _(r(f)("inventory.stock.history.summary.totalConvert")), 1),
1775
- e("div", $o, _(j.value.CONVERT), 1)
1776
- ]),
1777
- e("div", Ao, [
1778
- e("div", Vo, _(r(f)("inventory.stock.history.summary.totalDamage")), 1),
1779
- e("div", Co, _(j.value.DAMAGE), 1)
1780
- ]),
1781
- e("div", Bo, [
1782
- e("div", Mo, _(r(f)("inventory.stock.history.summary.openingBalance")), 1),
1783
- e("div", Do, _(T.value), 1)
1784
- ]),
1785
- e("div", jo, [
1786
- e("div", Io, _(r(f)("inventory.stock.history.summary.lastStockBalance")), 1),
1787
- e("div", To, _(Y.value), 1)
1788
- ])
1789
- ]),
1790
- r(l).enableTotalCost ? (F(), O("div", Uo, [
1791
- x(E, { class: "w-full" }),
1792
- e("div", Eo, [
1793
- e("div", Ho, [
1794
- x(Xe, { "z-index": 50 }, {
1795
- default: I(() => [
1796
- e("div", Po, [
1797
- ue(_(r(f)("inventory.stock.history.estimatedValue")) + " ", 1),
1798
- x(ee, {
1799
- variant: "plain",
1800
- placement: "top",
1801
- content: `[${Z.value}] ${r(f)("inventory.stock.history.estimatedValueTooltip")}`,
1802
- "z-index": 50
1803
- }, {
1804
- default: I(() => [
1805
- x(K, {
1806
- name: "help",
1807
- size: "sm"
1808
- })
1809
- ]),
1810
- _: 1
1811
- }, 8, ["content"])
1812
- ])
1813
- ]),
1814
- _: 1
1815
- }),
1816
- e("div", Ro, [
1817
- n.sku.valuation === r(Ke).Enum.FIFO ? (F(), O(ne, { key: 0 }, [
1818
- x(q, {
1819
- label: "FIFO",
1820
- compact: ""
1821
- }),
1822
- ue(" " + _(typeof Q.value != "string" ? r(ke)(
1823
- Q.value,
1824
- !1,
1825
- Q.value.precision
1826
- ) : Q.value), 1)
1827
- ], 64)) : (F(), O(ne, { key: 1 }, [
1828
- ue(_(typeof z.value != "string" ? r(ke)(
1829
- z.value,
1830
- !1,
1831
- z.value.precision
1832
- ) : z.value), 1)
1833
- ], 64))
1834
- ])
1835
- ]),
1836
- e("div", Oo, [
1837
- x(Xe, { "z-index": 50 }, {
1838
- default: I(() => [
1839
- e("div", No, [
1840
- ue(_(r(f)("inventory.stock.history.costSold")) + " ", 1),
1841
- x(ee, {
1842
- variant: "plain",
1843
- placement: "top",
1844
- "z-index": 50
1845
- }, {
1846
- content: I(() => [
1847
- e("div", Lo, _(r(f)("inventory.stock.history.costSoldTooltip")), 1)
1848
- ]),
1849
- default: I(() => [
1850
- x(K, {
1851
- name: "help",
1852
- size: "sm"
1853
- })
1854
- ]),
1855
- _: 1
1856
- })
1857
- ])
1858
- ]),
1859
- _: 1
1860
- }),
1861
- e("div", zo, _(W.value), 1)
1862
- ])
1863
- ])
1864
- ])) : se("", !0)
1865
- ]),
1866
- _: 1
1867
- })
1868
- ]),
1869
- _: 1
1870
- }),
1871
- a[5] || (a[5] = e("div", null, null, -1)),
1872
- (F(!0), O(ne, null, le(S.value, (ae) => (F(), O(ne, {
1873
- key: ae.date
1874
- }, [
1875
- n.sku ? (F(), L(Kn, {
1876
- key: 0,
1877
- record: ae,
1878
- sku: n.sku,
1879
- bills: M.value,
1880
- onRefreshHistory: V
1881
- }, null, 8, ["record", "sku", "bills"])) : se("", !0)
1882
- ], 64))), 128))
1883
- ])) : (F(), O("div", Yo, [
1884
- x(C),
1885
- e("div", null, [
1886
- e("img", {
1887
- src: r(Yt),
1888
- alt: "List is empty"
1889
- }, null, 8, Go)
1890
- ]),
1891
- e("div", Wo, _(r(f)("inventory.stock.history.noRecords")), 1),
1892
- e("div", Ko, _(r(f)("inventory.stock.history.changeDateRange")), 1),
1893
- x(C),
1894
- x(C)
1895
- ]))
1896
- ])
1897
- ];
1898
- }),
1899
- _: 1
1900
- }, 8, ["modelValue"]);
1901
- };
1902
- }
1903
- }), Xo = { class: "flex flex-col gap-8" }, Qo = { class: "flex flex-col" }, Jo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Zo = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary line-clamp-1" }, vs = /* @__PURE__ */ ce({
1904
- __name: "StockView",
1905
- setup(v) {
1906
- const { t: g } = de(), u = Pe(), o = pe(), A = Re(), p = lt(), l = ye(), f = nt(), { columnDefs: B } = Zt(), $ = Oe();
1907
- o.watchLocation(k);
1908
- const i = N(!1), s = _e();
1909
- async function V() {
1910
- $.open({
1911
- title: g("inventory.stock.stock_balance.refreshBalance"),
1912
- message: g("inventory.stock.stock_balance.refreshBalanceDescription"),
1913
- closeButton: !0,
1914
- primaryActions: {
1915
- text: g("common.confirm"),
1916
- close: !0
1917
- },
1918
- secondaryActions: {
1919
- text: g("common.close"),
1920
- close: !0,
1921
- variant: "tertiary"
1922
- }
1923
- }).onPrimary(async () => {
1924
- await l.recalculation.refreshCurrentBalances(), s.open({
1925
- title: "Refresh Stock Balance",
1926
- message: "Stock balance refresh has been queued. This may take a moment to complete.",
1927
- type: "success"
1928
- });
1929
- });
1930
- }
1931
- async function k() {
1932
- if (o._currentLocation) {
1933
- i.value = !0;
1934
- try {
1935
- await A.readStockBalance(), await A.readProductBalance(), await f.readStockEstimateBalance();
1936
- } catch (T) {
1937
- s.open({
1938
- title: g("inventory.stock.error.title"),
1939
- message: g("inventory.stock.error.message"),
1940
- type: "error"
1941
- }), console.error("error on fetch stock balance", T);
1942
- } finally {
1943
- i.value = !1;
1944
- }
1945
- }
1946
- }
1947
- const S = R(
1948
- () => u.skus.map((T) => {
1949
- var z, Q, G;
1950
- const Y = T.trackingMeasurement;
1951
- let W = (Q = (z = A.stockBalance.skus) == null ? void 0 : z.find(
1952
- (d) => d.id === T._id
1953
- )) == null ? void 0 : Q.balance, U = f.inventoryForecast.skus.find(
1954
- (d) => d.id === T._id
1955
- );
1956
- return {
1957
- ...T,
1958
- balance: W ?? {
1959
- amount: 0,
1960
- precision: 0
1961
- },
1962
- day: (U == null ? void 0 : U.depletionDays) ?? void 0,
1963
- trackingUnitAbbrev: Y ? ((G = T.unit.measurements.find((d) => d.id === Y)) == null ? void 0 : G.abbrev) ?? "" : T.unit.abbrev
1964
- };
1965
- })
1966
- ), M = N(""), { breakpoints: h } = Ot(), t = R(() => h.value.xs || h.value.sm), y = R(() => t.value ? 10 : 20), w = Tt(), j = R(() => [
1967
- {
1968
- label: g("inventory.stock.stock_balance.refreshBalance"),
1969
- value: "refresh-balance",
1970
- isPrimary: !0,
1971
- prependIcon: "calculate"
1972
- },
1973
- {
1974
- label: g("inventory.common.refresh"),
1975
- value: "refresh"
1976
- },
1977
- {
1978
- label: g("inventory.common.export"),
1979
- value: "export"
1980
- }
1981
- ]);
1982
- function P(T) {
1983
- switch (T) {
1984
- case "refresh-balance":
1985
- return V();
1986
- case "refresh":
1987
- return k();
1988
- case "export":
1989
- return qt(S.value);
1990
- }
1991
- }
1992
- return (T, Y) => {
1993
- const W = D("FmTable");
1994
- return F(), L(Ut, {
1995
- title: r(g)("inventory.stock.title"),
1996
- actions: j.value,
1997
- "onClick:action": P
1998
- }, {
1999
- default: I(() => {
2000
- var U, Z, z, Q;
2001
- return [
2002
- e("div", {
2003
- class: ge([
2004
- "flex flex-col gap-8 max-h-full",
2005
- {
2006
- "p-0": t.value,
2007
- "px-24 ": !t.value
2008
- }
2009
- ])
2010
- }, [
2011
- x(Et, {
2012
- searchable: "",
2013
- "change-location": "",
2014
- search: M.value,
2015
- "onUpdate:search": Y[0] || (Y[0] = (G) => M.value = G)
2016
- }, null, 8, ["search"]),
2017
- (F(), L(W, {
2018
- style: Ze(r(w).tableHeight),
2019
- "column-defs": r(B),
2020
- "row-data": S.value,
2021
- "search-value": M.value,
2022
- loading: i.value || !r(o)._currentLocation,
2023
- key: (U = r(o)._currentLocation) == null ? void 0 : U.dbName,
2024
- onRowClick: Y[1] || (Y[1] = (G) => r(p).showSkuHistory(G.original)),
2025
- "page-size": y.value
2026
- }, {
2027
- "list-row": I((G) => [
2028
- x(Ht, {
2029
- row: G,
2030
- onRowClick: r(p).showSkuHistory
2031
- }, {
2032
- default: I((d) => {
2033
- var n, a, b, c, m, C, H, K, ee, E;
2034
- return [
2035
- e("div", Xo, [
2036
- e("div", Qo, [
2037
- e("div", Jo, [
2038
- x(r(qe), {
2039
- render: (b = (a = (n = d.code) == null ? void 0 : n.column) == null ? void 0 : a.columnDef) == null ? void 0 : b.cell,
2040
- props: (m = (c = d.code) == null ? void 0 : c.getContext) == null ? void 0 : m.call(c)
2041
- }, null, 8, ["render", "props"])
2042
- ]),
2043
- e("div", Zo, [
2044
- x(r(qe), {
2045
- render: (K = (H = (C = d.name) == null ? void 0 : C.column) == null ? void 0 : H.columnDef) == null ? void 0 : K.cell,
2046
- props: (E = (ee = d.name) == null ? void 0 : ee.getContext) == null ? void 0 : E.call(ee)
2047
- }, null, 8, ["render", "props"])
2048
- ])
2049
- ]),
2050
- e("div", null, [
2051
- x(Te, {
2052
- days: G.original.day
2053
- }, null, 8, ["days"])
2054
- ]),
2055
- e("div", null, [
2056
- x(rt, {
2057
- class: "xs:w-[160px]",
2058
- unit: G.original.unit,
2059
- sku: G.original,
2060
- amount: G.original.balance,
2061
- "default-tracking-measurement": G.original.trackingMeasurement ?? void 0
2062
- }, null, 8, ["unit", "sku", "amount", "default-tracking-measurement"])
2063
- ])
2064
- ])
2065
- ];
2066
- }),
2067
- _: 2
2068
- }, 1032, ["row", "onRowClick"])
2069
- ]),
2070
- _: 1
2071
- }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
2072
- ], 2),
2073
- (F(), L(ct, { to: "body" }, [
2074
- (Z = r(p).stockHistoryProps) != null && Z.sku ? (F(), L(qo, Ae(Ve({ key: 0 }, r(p).stockHistoryProps)), null, 16)) : se("", !0),
2075
- (z = r(p).convertSkuDialogProps) != null && z.sku ? (F(), L(vn, Ae(Ve({ key: 1 }, r(p).convertSkuDialogProps)), null, 16)) : se("", !0),
2076
- (Q = r(p).adjustSkuDialogProps) != null && Q.stock ? (F(), L(Fn, Ae(Ve({ key: 2 }, r(p).adjustSkuDialogProps)), null, 16)) : se("", !0)
2077
- ]))
2078
- ];
2079
- }),
2080
- _: 1
2081
- }, 8, ["title", "actions"]);
2082
- };
2083
- }
2084
- });
2085
- export {
2086
- vs as default
2087
- };