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