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