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