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