@feedmepos/mf-inventory-portal 0.0.22-dev.4 → 0.0.22-dev.40

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