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