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