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