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