@feedmepos/mf-inventory-portal 1.5.0 → 1.5.2-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-D56G3kPH.js → App-DYOb7uJv.js} +4 -4
- package/dist/{ApprovalView-jCA1FvSS.js → ApprovalView-DRBS-RE3.js} +7 -7
- package/dist/{BindingsDialog-aTTSnlPM.js → BindingsDialog-DFBuiKjI.js} +2 -2
- package/dist/{BindingsPicker-BbFVGwmp.js → BindingsPicker-BSt1KP3v.js} +2 -2
- package/dist/{BindingsTable-5pmkxqhC.js → BindingsTable-DbfWpchk.js} +3 -3
- package/dist/ClosingDraftView-CzAV6Ak-.js +3202 -0
- package/dist/{ClosingHistoryView-o4wJAJJT.js → ClosingHistoryView-B2m1mFVb.js} +5 -5
- package/dist/{ClosingTemplateView-Cbg1Uwjx.js → ClosingTemplateView-CPoNLI4K.js} +14 -14
- package/dist/{DefaultView-A3gYMt2N.js → DefaultView-Dr7NC5pE.js} +2 -2
- package/dist/{DeliveryOrderPrintPreview-DHFMoSS6.js → DeliveryOrderPrintPreview-CSJ3EbkI.js} +2 -2
- package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CtFewq-W.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-BxCzBq7X.js} +2 -2
- package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-j3aDZ2cT.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DhFYEJSi.js} +2 -2
- package/dist/{FmMultiselectDialog-D-38fV59.js → FmMultiselectDialog-CK4OxOcC.js} +2 -2
- package/dist/{FmMultiselectDialog-DHiMw0t6.js → FmMultiselectDialog-Dc9XTsJp.js} +1 -1
- package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-Mic67Qjt.js → FmUnitInput.vue_vue_type_script_setup_true_lang-Cf3ZVYFG.js} +4 -4
- package/dist/{ImportView-Ck8rnxyR.js → ImportView-D19TZvnF.js} +6 -6
- package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-BBfMiiPT.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-BLS6Nv_u.js} +1 -1
- package/dist/{IngredientGroupView-B4ylskyw.js → IngredientGroupView-BArstaQe.js} +5 -5
- package/dist/{IngredientsView-DsCfOh07.js → IngredientsView-KOpZ2hFt.js} +15 -15
- package/dist/{IntegrationExplorerView-C1Ld_qxp.js → IntegrationExplorerView-Sw7DUhV4.js} +5 -5
- package/dist/{IntegrationView-BJmmPrHP.js → IntegrationView-D4T29bFi.js} +13 -13
- package/dist/{InventoryBindingForm-b8OONqJs.js → InventoryBindingForm-CZa1x5z5.js} +1 -1
- package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-D8wXZyxi.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-ByLQyONl.js} +5 -5
- package/dist/{InventoryBindingSummary-TiO1vsiR.js → InventoryBindingSummary-DAy_XvKk.js} +1 -1
- package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-C50b1vbd.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CCjud7QA.js} +1 -1
- package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-D5Oc4Mz8.js → PremiumBadge.vue_vue_type_script_setup_true_lang-DI4Z24d2.js} +1 -1
- package/dist/{PublishView-Cl9ZSgZr.js → PublishView-8SaK6fyS.js} +3 -3
- package/dist/{PurchaseOrderPrintPreview-DtMuOktc.js → PurchaseOrderPrintPreview-B2UholCw.js} +2 -2
- package/dist/{ReceiveRequestView-zfdKN3Gl.js → ReceiveRequestView-jKp1PH1p.js} +25 -25
- package/dist/{RecipeView-CX4paowp.js → RecipeView-B-_V8Hl0.js} +17 -17
- package/dist/{SettingsView-DYIXmmYj.js → SettingsView-DoKpbHug.js} +4 -4
- package/dist/StockView-BtlUbkCk.js +2573 -0
- package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-C-OhTH0B.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-y0pbttbS.js} +1 -1
- package/dist/{SupplierView-Cpv2OECi.js → SupplierView-B4xKWE8v.js} +12 -12
- package/dist/{SurchargeView-pjPgcNoS.js → SurchargeView-B_3TwBUc.js} +6 -6
- package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-qJoe3Rw5.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-BW6VWRLA.js} +2 -2
- package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-BKLYNLrJ.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-atJQ2x6h.js} +1 -1
- package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-DtY8MWv5.js → TransferDetails.vue_vue_type_script_setup_true_lang-yt-idxfW.js} +21 -21
- package/dist/{TransferTemplateView-Btxrrwm5.js → TransferTemplateView-Df5vRxcF.js} +18 -18
- package/dist/{UnitCostHistoryView-CdfBkfuD.js → UnitCostHistoryView-VD8C3tW0.js} +4 -4
- package/dist/{UnitDisplayControl.vue_vue_type_script_setup_true_lang-IYlWKszA.js → UnitDisplayControl.vue_vue_type_script_setup_true_lang-BZ9doLmV.js} +4 -4
- package/dist/{UnitView-CuklnpEd.js → UnitView-CXOAeVfR.js} +7 -7
- package/dist/{WarehouseView-BigoM5Fc.js → WarehouseView-Cqq49OjI.js} +5 -5
- package/dist/{WastageTemplateView-BweDS-9M.js → WastageTemplateView-BTzJB_Un.js} +14 -14
- package/dist/{app-Bpb4394e.js → app-Dgp7U3Bu.js} +2667 -2637
- package/dist/app.d.ts +4 -4
- package/dist/app.js +1 -1
- package/dist/{closing-template-ar_kUs4X.js → closing-template-CDO4H1ec.js} +1 -1
- package/dist/{date2-DpnYOzUg.js → date2-Co4esyS0.js} +1 -1
- package/dist/{dayjs.min-D5mIeZ1x.js → dayjs.min-fDFTQLDV.js} +1 -1
- package/dist/{decimal-C219qGO5.js → decimal-CAoqWZAo.js} +2 -2
- package/dist/{defineDeepModel-BF0Cvhza.js → defineDeepModel-Bu3A8_gN.js} +1 -1
- package/dist/{duplicate-template-ct64aRN_.js → duplicate-template-DFYzr9yc.js} +1 -1
- package/dist/{export-Dgopr7wH.js → export-SbWbn-Q1.js} +2 -2
- package/dist/{feature-Cz6F0_cm.js → feature-CiFq5nzV.js} +2 -2
- package/dist/{format-time-from-id-BvLCC6cK.js → format-time-from-id-CewwXLFE.js} +1 -1
- package/dist/{format-unit-display-CR_I8nfG.js → format-unit-display-CjSRi94f.js} +11 -11
- package/dist/{import-export.helper-BnI8EiMF.js → import-export.helper-BTmjUBR4.js} +6 -6
- package/dist/{index-CH0wxGs4.js → index-B2NWsBtj.js} +1 -1
- package/dist/{index-BJexyEQI.js → index-DMx7gikW.js} +3 -3
- package/dist/{index-gmzPcOZI.js → index-Ds1sxRgy.js} +1 -1
- package/dist/{inventory-core-dart.default-DanfWZQm.js → inventory-core-dart.default-CTfsXlyP.js} +1 -1
- package/dist/{lodash-TzWV2CbR.js → lodash-BoYjh2w1.js} +1 -1
- package/dist/{lz-string-UCgR6_DC.js → lz-string-DFsbzXIB.js} +1 -1
- package/dist/{netsuite-BGUUAOqe.js → netsuite-DWa9K-3f.js} +3 -3
- package/dist/{number-BVg7EKPV.js → number-Dr63YrYs.js} +3 -3
- package/dist/{predefined-templates-BAEoCP7i.js → predefined-templates-CjGGmE-S.js} +1 -1
- package/dist/{purchase-order-template-BBNXnta7.js → purchase-order-template-e6v2iw1L.js} +1 -1
- package/dist/{recalculationUtils-CbjBkJQt.js → recalculationUtils-CATRgU8s.js} +1 -1
- package/dist/{rules-CoimOM7X.js → rules-o0HyoFZS.js} +2 -2
- package/dist/{stock-DWkfMCtv.js → stock-CiQJys85.js} +1 -1
- package/dist/style.css +1 -1
- package/dist/{supplier-Bu6V24R6.js → supplier-l7eN_Q6M.js} +2 -2
- package/dist/{surcharge-aw55KM3G.js → surcharge-C66q09ht.js} +1 -1
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/dist/{use-ingredient-select-dialog-WYM92c37.js → use-ingredient-select-dialog-C5hAoyG7.js} +2 -2
- package/dist/{use-inventory-binding-dialog-zJqVnpvd.js → use-inventory-binding-dialog-IYVfWMn0.js} +2 -2
- package/dist/{use-template-enabled-locations-Puw8RG4I.js → use-template-enabled-locations-DH9oAsU9.js} +2 -2
- package/dist/{use-transfer-locations-B0o32Kyf.js → use-transfer-locations-C0qBfWjj.js} +2 -2
- package/dist/{useHrmPermission-DEaN-y77.js → useHrmPermission-O6wgWbn6.js} +1 -1
- package/dist/{useNavigationMenu-C1H2mTfQ.js → useNavigationMenu-CSQM3o-a.js} +2 -2
- package/dist/useSseClient-V3x2n4_X.js +524 -0
- package/dist/views/stock/composables/use-stock-refresh-balance.d.ts +32 -0
- package/dist/{vue-i18n-C4H80O5H.js → vue-i18n-B_D296iV.js} +348 -348
- package/dist/{xlsx-Byegf6ga.js → xlsx-z39dJT1l.js} +184 -184
- package/dist/{xlsx.util-BPV2vsSD.js → xlsx.util-BT9LSxGd.js} +3 -3
- package/package.json +3 -3
- package/dist/ClosingDraftView-yD8jHAQU.js +0 -3649
- package/dist/StockView-BqUBjCSD.js +0 -2484
- package/dist/stock-Dvcz34IY.js +0 -75
|
@@ -0,0 +1,2573 @@
|
|
|
1
|
+
import { defineComponent as ve, openBlock as V, createBlock as ne, withCtx as M, createElementVNode as e, toDisplayString as v, unref as s, ref as Y, h as be, computed as T, watch as Fe, resolveComponent as B, isRef as Ee, createVNode as _, createElementBlock as q, Fragment as ue, renderList as fe, createCommentVNode as se, normalizeClass as He, reactive as _t, mergeModels as nt, useModel as jt, onMounted as qe, createTextVNode as ye, normalizeStyle as kt, watchEffect as Vt, renderSlot as st, onUnmounted as Ct, Teleport as Dt, normalizeProps as at, mergeProps as ze } from "vue";
|
|
2
|
+
import { u as Bt, _ as Mt } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-sUxHOj47.js";
|
|
3
|
+
import { u as Se, c as Re, a as Ne, F as lt, t as It, D as ie, s as Ht, m as Tt, B as Pt, w as oe, f as Ce, h as rt, d as it, J as ge, K as De } from "./app-Dgp7U3Bu.js";
|
|
4
|
+
import { u as Oe, a as Ut } from "./useSseClient-V3x2n4_X.js";
|
|
5
|
+
import { c as Et } from "./component-kqxARxvM.js";
|
|
6
|
+
import { _ as ht, o as Rt } from "./UnitDisplayControl.vue_vue_type_script_setup_true_lang-BZ9doLmV.js";
|
|
7
|
+
import { _ as Ke, S as Ge, g as bt, a as Nt } from "./SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-y0pbttbS.js";
|
|
8
|
+
import { _ as Ot } from "./PreviewBadge.vue_vue_type_script_setup_true_lang-CRZiQHjx.js";
|
|
9
|
+
import { useI18n as pe, useCoreStore as Xe } from "@feedmepos/mf-common";
|
|
10
|
+
import { u as gt, i as Te, _ as ut } from "./PremiumBadge.vue_vue_type_script_setup_true_lang-DI4Z24d2.js";
|
|
11
|
+
import { useSnackbar as we, useDialog as Le, useProxiedModel as Ye, useBreakpoints as Lt } from "@feedmepos/ui-library";
|
|
12
|
+
import { defineStore as Yt } from "pinia";
|
|
13
|
+
import { F as Je } from "./FmAdminBadge-DjnBAgyv.js";
|
|
14
|
+
import { g as $e, a as he, e as zt, t as Pe, c as xe, f as Gt, h as ct, i as xt, j as Qe, d as Me, k as Wt } from "./number-Dr63YrYs.js";
|
|
15
|
+
import { u as Ae } from "./stock-CiQJys85.js";
|
|
16
|
+
import { c as Ue, A as Kt, M as qt, R as Xt } from "./rules-o0HyoFZS.js";
|
|
17
|
+
import { u as Jt } from "./use-inventory-binding-dialog-IYVfWMn0.js";
|
|
18
|
+
import { a as St } from "./FmMultiselectDialog-CK4OxOcC.js";
|
|
19
|
+
import { d as ke } from "./dayjs.min-fDFTQLDV.js";
|
|
20
|
+
import { _ as Qt } from "./NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CCjud7QA.js";
|
|
21
|
+
import { g as Zt } from "./decimal-CAoqWZAo.js";
|
|
22
|
+
import { a as eo, c as to, f as wt, t as dt, d as mt, p as oo, n as no, b as so } from "./date2-Co4esyS0.js";
|
|
23
|
+
import { i as ao, _ as lo } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DhFYEJSi.js";
|
|
24
|
+
import { _ as ro } from "./empty-placeholder-B0QU467o.js";
|
|
25
|
+
import { F as _e } from "./inventory-core-dart.default-CTfsXlyP.js";
|
|
26
|
+
import { u as io } from "./feature-CiFq5nzV.js";
|
|
27
|
+
import { u as At } from "./useHrmPermission-O6wgWbn6.js";
|
|
28
|
+
import { _ as uo, F as ft } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-Ca_eYa8-.js";
|
|
29
|
+
import { u as co } from "./netsuite-DWa9K-3f.js";
|
|
30
|
+
import { P as mo, J as fo } from "./app-DiX-EfV6.js";
|
|
31
|
+
var Ie = /* @__PURE__ */ ((w) => (w.History = "History", w.Convert = "Convert", w.Adjust = "Adjust", w))(Ie || {});
|
|
32
|
+
const vo = [
|
|
33
|
+
{
|
|
34
|
+
translationKey: "inventory.stock.action.history",
|
|
35
|
+
color: "text-neutral-700",
|
|
36
|
+
value: "History"
|
|
37
|
+
/* History */
|
|
38
|
+
}
|
|
39
|
+
], po = [
|
|
40
|
+
{
|
|
41
|
+
translationKey: "inventory.stock.action.history",
|
|
42
|
+
color: "text-neutral-700",
|
|
43
|
+
value: "History"
|
|
44
|
+
/* History */
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
translationKey: "inventory.stock.action.convert",
|
|
48
|
+
color: "text-neutral-700",
|
|
49
|
+
value: "Convert"
|
|
50
|
+
/* Convert */
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
translationKey: "inventory.stock.action.adjust",
|
|
54
|
+
color: "text-neutral-700",
|
|
55
|
+
value: "Adjust"
|
|
56
|
+
/* Adjust */
|
|
57
|
+
}
|
|
58
|
+
], yo = { class: "whitespace-nowrap" }, _o = /* @__PURE__ */ ve({
|
|
59
|
+
__name: "StockHeaderPreview",
|
|
60
|
+
setup(w) {
|
|
61
|
+
const { t: m } = pe();
|
|
62
|
+
return (k, p) => (V(), ne(Ot, null, {
|
|
63
|
+
default: M(() => [
|
|
64
|
+
e("div", yo, v(s(m)("inventory.stock.prediction.daysRemaining")), 1)
|
|
65
|
+
]),
|
|
66
|
+
_: 1
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
}), Ft = Yt("stockActions", () => {
|
|
70
|
+
const w = Y(!1), m = Se(), k = Oe(), p = gt(), x = we(), j = Le(), { t: u } = pe();
|
|
71
|
+
async function l() {
|
|
72
|
+
if (m._currentLocation) {
|
|
73
|
+
w.value = !0;
|
|
74
|
+
try {
|
|
75
|
+
await k.readStockBalance(), await k.readProductBalance(), await p.readStockEstimateBalance();
|
|
76
|
+
} catch {
|
|
77
|
+
x.open({
|
|
78
|
+
title: u("inventory.stock.error.title"),
|
|
79
|
+
message: u("inventory.stock.error.message"),
|
|
80
|
+
type: "error"
|
|
81
|
+
});
|
|
82
|
+
} finally {
|
|
83
|
+
w.value = !1;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const b = Y();
|
|
88
|
+
async function R(S) {
|
|
89
|
+
var $, P, N;
|
|
90
|
+
if (!!!((P = ($ = S.convert) == null ? void 0 : $.inventoryBindings) != null && P.length)) {
|
|
91
|
+
j.open({
|
|
92
|
+
title: u("inventory.stock.error.convert.title"),
|
|
93
|
+
message: u("inventory.stock.error.convert.message")
|
|
94
|
+
});
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const n = {
|
|
98
|
+
maxCount: ((N = k.productBalance.find(({ id: O }) => O === S._id)) == null ? void 0 : N.count) || 0,
|
|
99
|
+
sku: S,
|
|
100
|
+
show: !0,
|
|
101
|
+
"onUpdate:show"(O) {
|
|
102
|
+
b.value.show = O;
|
|
103
|
+
},
|
|
104
|
+
onSubmitted() {
|
|
105
|
+
l();
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
b.value = n;
|
|
109
|
+
}
|
|
110
|
+
const C = Y();
|
|
111
|
+
async function r(S) {
|
|
112
|
+
const o = {
|
|
113
|
+
stock: S,
|
|
114
|
+
show: !0,
|
|
115
|
+
"onUpdate:show"(t) {
|
|
116
|
+
C.value.show = t;
|
|
117
|
+
},
|
|
118
|
+
onSubmitted() {
|
|
119
|
+
l();
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
C.value = o;
|
|
123
|
+
}
|
|
124
|
+
const a = Y();
|
|
125
|
+
async function D(S) {
|
|
126
|
+
const o = {
|
|
127
|
+
sku: S,
|
|
128
|
+
show: !0,
|
|
129
|
+
"onUpdate:show"(t) {
|
|
130
|
+
a.value.show = t;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
a.value = o;
|
|
134
|
+
}
|
|
135
|
+
function c(S, o) {
|
|
136
|
+
const t = Re(o);
|
|
137
|
+
switch (S) {
|
|
138
|
+
case Ie.History:
|
|
139
|
+
D(t);
|
|
140
|
+
return;
|
|
141
|
+
case Ie.Convert:
|
|
142
|
+
R(t);
|
|
143
|
+
return;
|
|
144
|
+
case Ie.Adjust:
|
|
145
|
+
r(t);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
fetchStockBalance: l,
|
|
151
|
+
onActionMenu: c,
|
|
152
|
+
stockHistoryProps: a,
|
|
153
|
+
showSkuHistory: D,
|
|
154
|
+
convertSkuDialogProps: b,
|
|
155
|
+
adjustSkuDialogProps: C
|
|
156
|
+
};
|
|
157
|
+
});
|
|
158
|
+
function ko() {
|
|
159
|
+
var j;
|
|
160
|
+
const w = Se(), m = Ft(), k = Xe(), { t: p } = pe();
|
|
161
|
+
return {
|
|
162
|
+
columnDefs: [
|
|
163
|
+
{
|
|
164
|
+
accessorKey: "code",
|
|
165
|
+
header: () => p("inventory.stock.code"),
|
|
166
|
+
enableSorting: !0,
|
|
167
|
+
size: 300
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
accessorKey: "name",
|
|
171
|
+
header: () => p("inventory.stock.product"),
|
|
172
|
+
enableSorting: !0,
|
|
173
|
+
size: "auto"
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
id: "UOM",
|
|
177
|
+
header: () => p("inventory.stock.balance"),
|
|
178
|
+
cell(u) {
|
|
179
|
+
const l = u.row.original, b = {
|
|
180
|
+
unit: l.unit,
|
|
181
|
+
sku: l,
|
|
182
|
+
amount: l.balance,
|
|
183
|
+
defaultTrackingMeasurement: l.trackingMeasurement ?? void 0
|
|
184
|
+
};
|
|
185
|
+
return be(ht, b);
|
|
186
|
+
},
|
|
187
|
+
size: 180
|
|
188
|
+
},
|
|
189
|
+
...(j = k.sessionUser.value) != null && j.role.isAdmin ? [
|
|
190
|
+
{
|
|
191
|
+
accessorKey: "isInactive",
|
|
192
|
+
header: () => be(Je, {}, () => `${p("inventory.ingredient.status.title")}`),
|
|
193
|
+
cell(u) {
|
|
194
|
+
const l = u.row.original.isInactive;
|
|
195
|
+
return be(
|
|
196
|
+
"span",
|
|
197
|
+
{
|
|
198
|
+
class: [
|
|
199
|
+
"inline-block px-3 py-1 rounded-full text-xs font-semibold",
|
|
200
|
+
l ? "bg-red-100 text-red-700" : "bg-green-100 text-green-700"
|
|
201
|
+
].join(" ")
|
|
202
|
+
},
|
|
203
|
+
p(l ? "inventory.ingredient.status.inactive" : "inventory.ingredient.status.active")
|
|
204
|
+
);
|
|
205
|
+
},
|
|
206
|
+
enableSorting: !0
|
|
207
|
+
}
|
|
208
|
+
] : [],
|
|
209
|
+
{
|
|
210
|
+
accessorKey: "day",
|
|
211
|
+
id: "expireDate",
|
|
212
|
+
header: () => be(_o),
|
|
213
|
+
enableSorting: !0,
|
|
214
|
+
sortUndefined: "last",
|
|
215
|
+
cell(u) {
|
|
216
|
+
var D, c;
|
|
217
|
+
const l = u.row.original.day, b = u.row.original.operator, R = (D = u.row.original.thresholds) == null ? void 0 : D.low, C = (c = u.row.original.thresholds) == null ? void 0 : c.mid;
|
|
218
|
+
if (typeof l != "number" || typeof R != "number" || typeof C != "number")
|
|
219
|
+
return be(Ke, {
|
|
220
|
+
days: l,
|
|
221
|
+
operator: b
|
|
222
|
+
});
|
|
223
|
+
const r = l <= R ? Ge.low : l <= C ? Ge.mid : Ge.high;
|
|
224
|
+
return be(Ke, {
|
|
225
|
+
days: l,
|
|
226
|
+
level: r
|
|
227
|
+
});
|
|
228
|
+
},
|
|
229
|
+
size: 200
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
id: "action",
|
|
233
|
+
cell(u) {
|
|
234
|
+
var l;
|
|
235
|
+
return Et(
|
|
236
|
+
((l = w._currentLocation) == null ? void 0 : l.type) === "restaurant" ? vo : po,
|
|
237
|
+
(b) => m.onActionMenu(b, u.row.original)
|
|
238
|
+
);
|
|
239
|
+
},
|
|
240
|
+
enableSorting: !1,
|
|
241
|
+
size: 40,
|
|
242
|
+
meta: {
|
|
243
|
+
cellClass: "",
|
|
244
|
+
headerClass: ""
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
]
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
const ho = {
|
|
251
|
+
context: null,
|
|
252
|
+
error: null,
|
|
253
|
+
isRequired(w = "This field is required") {
|
|
254
|
+
return `${this.context ?? ""}`.length === 0 && (this.error = w), this;
|
|
255
|
+
},
|
|
256
|
+
isString(w = "Must be a valid string") {
|
|
257
|
+
return this.error ? this : (typeof this.context != "string" && (this.error ?? (this.error = w)), this);
|
|
258
|
+
},
|
|
259
|
+
toInt() {
|
|
260
|
+
return this.error ? this : (this.context = +this.context, this);
|
|
261
|
+
},
|
|
262
|
+
isInteger(w = "Must be an integer") {
|
|
263
|
+
return this.error ? this : (this.toInt(), isNaN(this.context) && (this.error = w), this);
|
|
264
|
+
},
|
|
265
|
+
min(w, m) {
|
|
266
|
+
if (this.error) return this;
|
|
267
|
+
try {
|
|
268
|
+
typeof this.context == "number" ? +this.context < w && (this.error = m ?? `Must be at least ${w}`) : Object.prototype.hasOwnProperty.call(this.context, "length") ? +this.context.length < w && (this.error = m ?? `Must be at least ${w}`) : this.error = "Length cannot be determined";
|
|
269
|
+
} catch {
|
|
270
|
+
this.error = "Length cannot be determined";
|
|
271
|
+
}
|
|
272
|
+
return this;
|
|
273
|
+
},
|
|
274
|
+
max(w, m) {
|
|
275
|
+
if (this.error) return this;
|
|
276
|
+
try {
|
|
277
|
+
typeof this.context == "number" ? +this.context > w && (this.error = m ?? `Must be at most ${w}`) : "length" in this.context ? +this.context.length > w && (this.error = m ?? `Must be at most ${w}`) : this.error = "Length cannot be determined";
|
|
278
|
+
} catch {
|
|
279
|
+
this.error = "Length cannot be determined";
|
|
280
|
+
}
|
|
281
|
+
return this;
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
function vt(w) {
|
|
285
|
+
return { ...ho, context: w };
|
|
286
|
+
}
|
|
287
|
+
const bo = { class: "flex items-center" }, go = { class: "fm-typo-en-title-md-800" }, xo = { class: "flex flex-col gap-24 w-full" }, So = { class: "flex flex-col gap-8" }, wo = { class: "fm-typo-en-body-lg-600" }, Ao = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary flex-grow" }, Fo = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-error" }, $o = { class: "flex flex-col p-16 gap-8" }, jo = { class: "flex flex-col gap-4" }, Vo = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary bg-fm-color-neutral-gray-100 border-b py-12 px-16" }, Co = { class: "grid grid-cols-[auto_100px_100px_48px] xs:grid-cols-[auto_80px_120px_48px] gap-8 px-8 items-center" }, Do = { class: "xs:col-span-3" }, Bo = { class: "flex gap-8" }, Mo = /* @__PURE__ */ ve({
|
|
288
|
+
__name: "ConvertSkuDialog",
|
|
289
|
+
props: {
|
|
290
|
+
sku: {},
|
|
291
|
+
maxCount: {},
|
|
292
|
+
show: { type: Boolean }
|
|
293
|
+
},
|
|
294
|
+
emits: ["update:show", "submitted"],
|
|
295
|
+
setup(w, { expose: m, emit: k }) {
|
|
296
|
+
const p = w, x = k, j = Jt(), u = Ne(), l = Ae(), b = we(), { t: R } = pe(), C = Y(0), r = Y(null), a = T(() => u.skus), D = T(
|
|
297
|
+
() => {
|
|
298
|
+
var g, A;
|
|
299
|
+
return (((A = (g = p.sku) == null ? void 0 : g.convert) == null ? void 0 : A.inventoryBindings) ?? []).filter(
|
|
300
|
+
(G) => G.type === lt.enum.SKU
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
), c = T({
|
|
304
|
+
get() {
|
|
305
|
+
return !!r.value;
|
|
306
|
+
},
|
|
307
|
+
set(g) {
|
|
308
|
+
g ? r.value = Re(D.value) : (r.value = null, C.value = Math.min(C.value, p.maxCount ?? 0));
|
|
309
|
+
}
|
|
310
|
+
}), S = Y(!1);
|
|
311
|
+
Fe([() => p.show], ([g]) => {
|
|
312
|
+
g && (C.value = 0);
|
|
313
|
+
});
|
|
314
|
+
function o() {
|
|
315
|
+
L(p.sku, Pe(C.value), r.value);
|
|
316
|
+
}
|
|
317
|
+
function t(g) {
|
|
318
|
+
if (r.value)
|
|
319
|
+
return !0;
|
|
320
|
+
const A = vt(g).isInteger().max(p.maxCount ?? 0).error ?? "";
|
|
321
|
+
return A || !0;
|
|
322
|
+
}
|
|
323
|
+
function n(g) {
|
|
324
|
+
var I;
|
|
325
|
+
const A = (I = p.sku.convert) != null && I.measurement ? p.sku.unit.measurements.find((i) => {
|
|
326
|
+
var h;
|
|
327
|
+
return i.id === ((h = p.sku.convert) == null ? void 0 : h.measurement);
|
|
328
|
+
}) ?? null : null, G = $e(p.sku.unit, A), H = Gt(+g);
|
|
329
|
+
return vt(H).isInteger().max(G).error ? "Precision cannot be more than " + G : !0;
|
|
330
|
+
}
|
|
331
|
+
const $ = T(
|
|
332
|
+
() => {
|
|
333
|
+
var g, A;
|
|
334
|
+
return (g = p.sku.convert) != null && g.measurement ? (A = p.sku.unit.measurements.find((G) => {
|
|
335
|
+
var H;
|
|
336
|
+
return G.id === ((H = p.sku.convert) == null ? void 0 : H.measurement);
|
|
337
|
+
})) == null ? void 0 : A.abbrev : p.sku.unit.abbrev;
|
|
338
|
+
}
|
|
339
|
+
), P = T(() => {
|
|
340
|
+
var H, J;
|
|
341
|
+
const A = It({
|
|
342
|
+
bindings: ((H = p.sku.convert) == null ? void 0 : H.inventoryBindings) ?? [],
|
|
343
|
+
skus: u.skus,
|
|
344
|
+
skuGroups: u.skuGroups,
|
|
345
|
+
recipes: u.recipes
|
|
346
|
+
}).inventoryBindings.filter((I) => "success" in I && I.success).map((I) => I).map((I) => I.binding);
|
|
347
|
+
return (J = r.value ?? A) == null ? void 0 : J.map((I) => {
|
|
348
|
+
var ee, ae, Q, W, te;
|
|
349
|
+
const i = u.skus.find((re) => re._id === I.id), h = ((ee = I.measurement) == null ? void 0 : ee.abbrev) ?? ((ae = i == null ? void 0 : i.unit) == null ? void 0 : ae.abbrev), y = (Q = p.sku.convert) != null && Q.measurement ? p.sku.unit.measurements.find((re) => {
|
|
350
|
+
var ce;
|
|
351
|
+
return re.id === ((ce = p.sku.convert) == null ? void 0 : ce.measurement);
|
|
352
|
+
}) ?? null : null, f = $e(p.sku.unit, y), d = n(`${C.value}`) === !0 ? he(
|
|
353
|
+
zt(
|
|
354
|
+
I.amount,
|
|
355
|
+
Pe(+C.value, f)
|
|
356
|
+
),
|
|
357
|
+
!1
|
|
358
|
+
) : "0", F = (te = (W = r.value) == null ? void 0 : W.find((re) => re.id === (i == null ? void 0 : i._id))) == null ? void 0 : te.amount, E = F ? he(F, !1) : null;
|
|
359
|
+
return {
|
|
360
|
+
sku: i,
|
|
361
|
+
convertAmount: E ?? d,
|
|
362
|
+
abbrev: h
|
|
363
|
+
};
|
|
364
|
+
});
|
|
365
|
+
}), N = Y();
|
|
366
|
+
m({
|
|
367
|
+
validateInputs: () => {
|
|
368
|
+
var g, A;
|
|
369
|
+
(A = (g = N.value) == null ? void 0 : g.validateInputs) == null || A.call(g);
|
|
370
|
+
},
|
|
371
|
+
resetInputsValidation: () => {
|
|
372
|
+
var g, A;
|
|
373
|
+
(A = (g = N.value) == null ? void 0 : g.resetInputsValidation) == null || A.call(g);
|
|
374
|
+
},
|
|
375
|
+
resetInputs: () => {
|
|
376
|
+
var g, A;
|
|
377
|
+
(A = (g = N.value) == null ? void 0 : g.resetInputs) == null || A.call(g);
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
const O = Ye(p, "show");
|
|
381
|
+
async function L(g, A, G) {
|
|
382
|
+
S.value = !0;
|
|
383
|
+
try {
|
|
384
|
+
await l.convertSku({
|
|
385
|
+
conversions: [
|
|
386
|
+
{
|
|
387
|
+
doc: g,
|
|
388
|
+
amount: A,
|
|
389
|
+
overrides: G == null ? void 0 : G.map((H) => ({
|
|
390
|
+
...H,
|
|
391
|
+
amount: {
|
|
392
|
+
...H.amount,
|
|
393
|
+
amount: -1 * Math.abs(H.amount.amount)
|
|
394
|
+
// ensure truly negative
|
|
395
|
+
}
|
|
396
|
+
}))
|
|
397
|
+
}
|
|
398
|
+
]
|
|
399
|
+
}), x("update:show", !1), x("submitted");
|
|
400
|
+
} catch (H) {
|
|
401
|
+
b.open({
|
|
402
|
+
title: "Something went wrong",
|
|
403
|
+
message: `Cannot convert ${g.name}. Please try again.`,
|
|
404
|
+
type: "error"
|
|
405
|
+
}), console.error("error at converting stock amount", g, A, H);
|
|
406
|
+
} finally {
|
|
407
|
+
S.value = !1;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
function X(g, A, G) {
|
|
411
|
+
const H = +A;
|
|
412
|
+
let J = G;
|
|
413
|
+
A.length > 0 && isFinite(H) ? J = G.map((I) => (I.id !== g || (I.amount = xe(H)), I)) : J = G.map((I) => (I.id !== g || (I.amount = { amount: 0, precision: 0 }), I)), r.value = J;
|
|
414
|
+
}
|
|
415
|
+
function z(g) {
|
|
416
|
+
const A = a.value.find((G) => G._id === g);
|
|
417
|
+
return A ? bt(A.unit, !0) : [];
|
|
418
|
+
}
|
|
419
|
+
function K(g, A) {
|
|
420
|
+
const G = z(g), H = G.find((J) => J.value === A) ?? G.find((J) => J.value === null);
|
|
421
|
+
return H ? {
|
|
422
|
+
...H,
|
|
423
|
+
label: H.abbrev
|
|
424
|
+
} : null;
|
|
425
|
+
}
|
|
426
|
+
function U(g, A, G) {
|
|
427
|
+
let H;
|
|
428
|
+
if (A === null)
|
|
429
|
+
H = G.map((J) => (J.id !== g || (J.measurement = null), J)) ?? [];
|
|
430
|
+
else {
|
|
431
|
+
const J = a.value.find((I) => I._id === g);
|
|
432
|
+
H = G.map((I) => {
|
|
433
|
+
var i, h;
|
|
434
|
+
return I.id !== g || (I.measurement = (h = (i = J == null ? void 0 : J.unit) == null ? void 0 : i.measurements) == null ? void 0 : h.find((y) => y.id === A)), I;
|
|
435
|
+
}) ?? [];
|
|
436
|
+
}
|
|
437
|
+
r.value = H;
|
|
438
|
+
}
|
|
439
|
+
function Z(g, A) {
|
|
440
|
+
const G = A.filter((H) => H.id !== g);
|
|
441
|
+
r.value = G;
|
|
442
|
+
}
|
|
443
|
+
function le() {
|
|
444
|
+
const g = (r.value ?? []).map((A) => ({
|
|
445
|
+
...A,
|
|
446
|
+
type: lt.enum.SKU
|
|
447
|
+
}));
|
|
448
|
+
j.promptIngredientsBinding(
|
|
449
|
+
g,
|
|
450
|
+
(A) => r.value = A,
|
|
451
|
+
p.sku._id
|
|
452
|
+
);
|
|
453
|
+
}
|
|
454
|
+
return Fe(
|
|
455
|
+
() => p.show,
|
|
456
|
+
(g) => {
|
|
457
|
+
g || (r.value = null, C.value = 0);
|
|
458
|
+
}
|
|
459
|
+
), (g, A) => {
|
|
460
|
+
const G = B("FmTextField"), H = B("FmForm"), J = B("FmCard"), I = B("FmSwitch"), i = B("FmFormGroup"), h = B("FmSelect"), y = B("FmButton"), f = B("FmSideSheet");
|
|
461
|
+
return V(), ne(f, {
|
|
462
|
+
"dismiss-away": "",
|
|
463
|
+
modelValue: s(O),
|
|
464
|
+
"onUpdate:modelValue": A[3] || (A[3] = (d) => Ee(O) ? O.value = d : null),
|
|
465
|
+
"max-width": 500
|
|
466
|
+
}, {
|
|
467
|
+
"side-sheet-header": M(() => [
|
|
468
|
+
e("div", bo, [
|
|
469
|
+
e("div", go, v(s(R)("inventory.stock.convert.title", { name: g.sku.name })), 1)
|
|
470
|
+
])
|
|
471
|
+
]),
|
|
472
|
+
default: M(() => [
|
|
473
|
+
e("div", xo, [
|
|
474
|
+
_(H, {
|
|
475
|
+
ref_key: "formRef",
|
|
476
|
+
ref: N,
|
|
477
|
+
onValidationSuccess: o
|
|
478
|
+
}, {
|
|
479
|
+
default: M(() => [
|
|
480
|
+
_(G, {
|
|
481
|
+
disabled: S.value,
|
|
482
|
+
"model-value": C.value,
|
|
483
|
+
"onUpdate:modelValue": A[0] || (A[0] = (d) => C.value = d),
|
|
484
|
+
label: s(R)("inventory.stock.convert.amount"),
|
|
485
|
+
rules: [t, n, s(Ue)(0)],
|
|
486
|
+
"append-text": $.value,
|
|
487
|
+
"helper-text": r.value ? void 0 : `Max ${g.maxCount} ${$.value}`
|
|
488
|
+
}, null, 8, ["disabled", "model-value", "label", "rules", "append-text", "helper-text"])
|
|
489
|
+
]),
|
|
490
|
+
_: 1
|
|
491
|
+
}, 512),
|
|
492
|
+
_(J, {
|
|
493
|
+
variant: "outlined",
|
|
494
|
+
class: "p-16"
|
|
495
|
+
}, {
|
|
496
|
+
default: M(() => [
|
|
497
|
+
e("div", So, [
|
|
498
|
+
e("div", wo, v(s(R)("inventory.stock.convert.deductionSummary")), 1),
|
|
499
|
+
(V(!0), q(ue, null, fe(P.value, (d) => {
|
|
500
|
+
var F, E;
|
|
501
|
+
return V(), q("div", {
|
|
502
|
+
key: (F = d.sku) == null ? void 0 : F._id,
|
|
503
|
+
class: "flex items-center"
|
|
504
|
+
}, [
|
|
505
|
+
e("div", Ao, v((E = d.sku) == null ? void 0 : E.name), 1),
|
|
506
|
+
e("div", Fo, " -" + v(d.convertAmount) + " " + v(d.abbrev), 1)
|
|
507
|
+
]);
|
|
508
|
+
}), 128))
|
|
509
|
+
])
|
|
510
|
+
]),
|
|
511
|
+
_: 1
|
|
512
|
+
}),
|
|
513
|
+
_(J, { variant: "outlined" }, {
|
|
514
|
+
default: M(() => [
|
|
515
|
+
e("div", $o, [
|
|
516
|
+
_(I, {
|
|
517
|
+
value: "",
|
|
518
|
+
modelValue: c.value,
|
|
519
|
+
"onUpdate:modelValue": A[1] || (A[1] = (d) => c.value = d),
|
|
520
|
+
label: s(R)("inventory.stock.convert.overrideDeduction"),
|
|
521
|
+
"label-placement": "right"
|
|
522
|
+
}, null, 8, ["modelValue", "label"]),
|
|
523
|
+
c.value ? (V(), q(ue, { key: 0 }, [
|
|
524
|
+
_(i, {
|
|
525
|
+
modelValue: r.value,
|
|
526
|
+
rules: [s(Kt)(1, "Must have at least one ingredient binding")]
|
|
527
|
+
}, null, 8, ["modelValue", "rules"]),
|
|
528
|
+
e("div", jo, [
|
|
529
|
+
e("div", Vo, v(s(R)("inventory.stock.convert.ingredients")), 1),
|
|
530
|
+
(V(!0), q(ue, null, fe(r.value, (d) => (V(), ne(i, {
|
|
531
|
+
key: d.id,
|
|
532
|
+
disabled: S.value,
|
|
533
|
+
modelValue: +s(he)(d.amount ?? { amount: 1, precision: 0 }),
|
|
534
|
+
rules: [
|
|
535
|
+
s(qt)(
|
|
536
|
+
a.value.find((F) => F._id === d.id).unit,
|
|
537
|
+
d.measurement
|
|
538
|
+
),
|
|
539
|
+
s(Ue)(0)
|
|
540
|
+
]
|
|
541
|
+
}, {
|
|
542
|
+
default: M(({ invalid: F }) => {
|
|
543
|
+
var E, ee, ae;
|
|
544
|
+
return [
|
|
545
|
+
e("div", Co, [
|
|
546
|
+
e("div", Do, v((E = a.value.find((Q) => Q._id === d.id)) == null ? void 0 : E.name), 1),
|
|
547
|
+
_(G, {
|
|
548
|
+
class: "xs:col-span-2",
|
|
549
|
+
disabled: S.value,
|
|
550
|
+
modelValue: +s(he)(
|
|
551
|
+
d.amount ?? { amount: 1, precision: 0 }
|
|
552
|
+
),
|
|
553
|
+
"onUpdate:modelValue": (Q) => X(d.id, Q, r.value ?? []),
|
|
554
|
+
invalid: F
|
|
555
|
+
}, null, 8, ["disabled", "modelValue", "onUpdate:modelValue", "invalid"]),
|
|
556
|
+
_(h, {
|
|
557
|
+
disabled: S.value,
|
|
558
|
+
class: "translate-y-[2px]",
|
|
559
|
+
items: z(d.id),
|
|
560
|
+
"model-value": (ae = K(d.id, (ee = d.measurement) == null ? void 0 : ee.id)) == null ? void 0 : ae.value,
|
|
561
|
+
"onUpdate:modelValue": (Q) => U(d.id, Q, r.value ?? []),
|
|
562
|
+
invalid: F
|
|
563
|
+
}, {
|
|
564
|
+
"helper-text": M(() => A[4] || (A[4] = [])),
|
|
565
|
+
_: 2
|
|
566
|
+
}, 1032, ["disabled", "items", "model-value", "onUpdate:modelValue", "invalid"]),
|
|
567
|
+
_(y, {
|
|
568
|
+
disabled: S.value,
|
|
569
|
+
type: "button",
|
|
570
|
+
variant: "tertiary",
|
|
571
|
+
icon: "delete",
|
|
572
|
+
onClick: (Q) => Z(d.id, r.value ?? [])
|
|
573
|
+
}, null, 8, ["disabled", "onClick"])
|
|
574
|
+
])
|
|
575
|
+
];
|
|
576
|
+
}),
|
|
577
|
+
_: 2
|
|
578
|
+
}, 1032, ["disabled", "modelValue", "rules"]))), 128))
|
|
579
|
+
]),
|
|
580
|
+
e("div", null, [
|
|
581
|
+
_(y, {
|
|
582
|
+
icon: "link",
|
|
583
|
+
label: s(R)("inventory.stock.convert.linkIngredient"),
|
|
584
|
+
variant: "plain",
|
|
585
|
+
onClick: le
|
|
586
|
+
}, null, 8, ["label"])
|
|
587
|
+
])
|
|
588
|
+
], 64)) : se("", !0)
|
|
589
|
+
])
|
|
590
|
+
]),
|
|
591
|
+
_: 1
|
|
592
|
+
})
|
|
593
|
+
])
|
|
594
|
+
]),
|
|
595
|
+
"side-sheet-footer": M(() => [
|
|
596
|
+
e("div", Bo, [
|
|
597
|
+
_(y, {
|
|
598
|
+
loading: S.value,
|
|
599
|
+
label: s(R)("inventory.stock.convert.convertButton"),
|
|
600
|
+
onClick: A[2] || (A[2] = (d) => {
|
|
601
|
+
var F, E;
|
|
602
|
+
return (E = (F = N.value) == null ? void 0 : F.validateInputs) == null ? void 0 : E.call(F);
|
|
603
|
+
})
|
|
604
|
+
}, null, 8, ["loading", "label"])
|
|
605
|
+
])
|
|
606
|
+
]),
|
|
607
|
+
_: 1
|
|
608
|
+
}, 8, ["modelValue"]);
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
});
|
|
612
|
+
function Be(w, m) {
|
|
613
|
+
const k = Pe(w, m);
|
|
614
|
+
return { ...k, amount: -k.amount };
|
|
615
|
+
}
|
|
616
|
+
function pt(w, m) {
|
|
617
|
+
return Pe(Math.abs(w), m);
|
|
618
|
+
}
|
|
619
|
+
const We = {
|
|
620
|
+
[ie.enum.DAMAGE]: {
|
|
621
|
+
label: "Damage",
|
|
622
|
+
toAdjustmentAmount: Be
|
|
623
|
+
},
|
|
624
|
+
[ie.enum.WASTAGE]: {
|
|
625
|
+
label: "Wastage",
|
|
626
|
+
toAdjustmentAmount: Be
|
|
627
|
+
},
|
|
628
|
+
[ie.enum.THEFT]: {
|
|
629
|
+
label: "Theft",
|
|
630
|
+
toAdjustmentAmount: Be
|
|
631
|
+
},
|
|
632
|
+
[ie.enum.LOSE]: {
|
|
633
|
+
label: "Lose",
|
|
634
|
+
toAdjustmentAmount: Be
|
|
635
|
+
},
|
|
636
|
+
[ie.enum.EXTRA]: {
|
|
637
|
+
label: "Extra",
|
|
638
|
+
toAdjustmentAmount: pt
|
|
639
|
+
},
|
|
640
|
+
[ie.enum.PURCHASE]: {
|
|
641
|
+
label: "Purchase",
|
|
642
|
+
toAdjustmentAmount: pt
|
|
643
|
+
}
|
|
644
|
+
}, Io = { class: "col-span-2 flex" }, Ho = { class: "flex-1" }, To = { class: "fm-typo-en-body-lg-600" }, Po = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Uo = { class: "col-span-2 flex flex-col gap-4" }, Eo = { class: "flex gap-4 text-fm-color-typo-primary fm-typo-en-body-lg-600" }, Ro = {
|
|
645
|
+
key: 0,
|
|
646
|
+
class: "fm-typo-en-body-md-400 text-fm-color-typo-warning"
|
|
647
|
+
}, $t = /* @__PURE__ */ ve({
|
|
648
|
+
__name: "AdjustedItemForm",
|
|
649
|
+
props: {
|
|
650
|
+
modelValue: {},
|
|
651
|
+
disabled: { type: Boolean },
|
|
652
|
+
isBackdate: { type: Boolean }
|
|
653
|
+
},
|
|
654
|
+
emits: ["update:modelValue", "click:delete"],
|
|
655
|
+
setup(w, { emit: m }) {
|
|
656
|
+
const k = w, p = m, { t: x } = pe(), j = Oe(), u = T(
|
|
657
|
+
() => Object.keys(We).map((t) => ({
|
|
658
|
+
label: Ht(t),
|
|
659
|
+
value: t
|
|
660
|
+
}))
|
|
661
|
+
), l = T(() => bt(k.modelValue.doc.unit, !0)), b = T({
|
|
662
|
+
get() {
|
|
663
|
+
return k.modelValue.type ?? ie.enum.PURCHASE;
|
|
664
|
+
},
|
|
665
|
+
set(t) {
|
|
666
|
+
const n = {
|
|
667
|
+
...k.modelValue
|
|
668
|
+
};
|
|
669
|
+
n.type = t;
|
|
670
|
+
const $ = ct(k.modelValue.amount);
|
|
671
|
+
n.amount = We[n.type].toAdjustmentAmount(
|
|
672
|
+
+he($),
|
|
673
|
+
$.precision
|
|
674
|
+
), p("update:modelValue", n);
|
|
675
|
+
}
|
|
676
|
+
}), R = T({
|
|
677
|
+
get() {
|
|
678
|
+
const t = ct(k.modelValue.amount);
|
|
679
|
+
return +he(t);
|
|
680
|
+
},
|
|
681
|
+
set(t) {
|
|
682
|
+
const n = {
|
|
683
|
+
...k.modelValue
|
|
684
|
+
}, $ = xe(t);
|
|
685
|
+
n.amount = We[b.value].toAdjustmentAmount(
|
|
686
|
+
t,
|
|
687
|
+
$.precision
|
|
688
|
+
), p("update:modelValue", n);
|
|
689
|
+
}
|
|
690
|
+
}), C = T({
|
|
691
|
+
get() {
|
|
692
|
+
var t;
|
|
693
|
+
return ((t = k.modelValue.measurement) == null ? void 0 : t.id) ?? null;
|
|
694
|
+
},
|
|
695
|
+
set(t) {
|
|
696
|
+
var $, P;
|
|
697
|
+
const n = {
|
|
698
|
+
...k.modelValue
|
|
699
|
+
};
|
|
700
|
+
n.measurement = ((P = ($ = k.modelValue.doc.unit) == null ? void 0 : $.measurements) == null ? void 0 : P.find((N) => N.id === t)) ?? null, p("update:modelValue", n);
|
|
701
|
+
}
|
|
702
|
+
}), r = T({
|
|
703
|
+
get() {
|
|
704
|
+
return k.modelValue.remark ?? "";
|
|
705
|
+
},
|
|
706
|
+
set(t) {
|
|
707
|
+
const n = {
|
|
708
|
+
...k.modelValue
|
|
709
|
+
};
|
|
710
|
+
n.remark = t, p("update:modelValue", n);
|
|
711
|
+
}
|
|
712
|
+
}), a = T(() => {
|
|
713
|
+
var n;
|
|
714
|
+
const t = (n = j.stockBalance.skus) == null ? void 0 : n.find(($) => $.id === k.modelValue.doc._id);
|
|
715
|
+
return (t == null ? void 0 : t.balance) ?? { amount: 0, precision: 0 };
|
|
716
|
+
}), D = T(() => {
|
|
717
|
+
const t = k.modelValue.amount, n = k.modelValue.measurement;
|
|
718
|
+
return n ? xt(t, n.conversion) : t;
|
|
719
|
+
}), c = T(
|
|
720
|
+
() => k.isBackdate ? a.value : Qe(a.value, D.value)
|
|
721
|
+
), S = T(
|
|
722
|
+
() => Zt(c.value, k.modelValue.doc.unit)
|
|
723
|
+
), o = T(
|
|
724
|
+
() => !k.isBackdate && D.value.amount < 0
|
|
725
|
+
);
|
|
726
|
+
return (t, n) => {
|
|
727
|
+
const $ = B("FmButton"), P = B("FmSelect"), N = B("FmTextarea"), O = B("FmCard");
|
|
728
|
+
return V(), ne(O, {
|
|
729
|
+
variant: "outlined",
|
|
730
|
+
class: "grid grid-cols-2 gap-8 p-16"
|
|
731
|
+
}, {
|
|
732
|
+
default: M(() => [
|
|
733
|
+
e("div", Io, [
|
|
734
|
+
e("div", Ho, [
|
|
735
|
+
e("div", To, v(t.modelValue.doc.name), 1),
|
|
736
|
+
e("div", Po, v(t.modelValue.doc.code), 1)
|
|
737
|
+
]),
|
|
738
|
+
_($, {
|
|
739
|
+
variant: "tertiary",
|
|
740
|
+
"prepend-icon": "delete",
|
|
741
|
+
onClick: n[0] || (n[0] = (L) => p("click:delete"))
|
|
742
|
+
})
|
|
743
|
+
]),
|
|
744
|
+
_(P, {
|
|
745
|
+
disabled: t.disabled,
|
|
746
|
+
class: "col-span-2",
|
|
747
|
+
label: "Type",
|
|
748
|
+
items: u.value,
|
|
749
|
+
modelValue: b.value,
|
|
750
|
+
"onUpdate:modelValue": n[1] || (n[1] = (L) => b.value = L),
|
|
751
|
+
rules: [s(Xt)()],
|
|
752
|
+
"label-mark": "required"
|
|
753
|
+
}, null, 8, ["disabled", "items", "modelValue", "rules"]),
|
|
754
|
+
_(Qt, {
|
|
755
|
+
disabled: t.disabled,
|
|
756
|
+
label: "Amount",
|
|
757
|
+
step: +s(he)({
|
|
758
|
+
amount: 1,
|
|
759
|
+
precision: s($e)(t.modelValue.doc.unit, t.modelValue.measurement)
|
|
760
|
+
}),
|
|
761
|
+
modelValue: R.value,
|
|
762
|
+
"onUpdate:modelValue": n[2] || (n[2] = (L) => R.value = L),
|
|
763
|
+
rules: [s(Ue)(0)]
|
|
764
|
+
}, null, 8, ["disabled", "step", "modelValue", "rules"]),
|
|
765
|
+
_(P, {
|
|
766
|
+
disabled: t.disabled,
|
|
767
|
+
label: "Unit",
|
|
768
|
+
items: l.value,
|
|
769
|
+
modelValue: C.value,
|
|
770
|
+
"onUpdate:modelValue": n[3] || (n[3] = (L) => C.value = L)
|
|
771
|
+
}, null, 8, ["disabled", "items", "modelValue"]),
|
|
772
|
+
_(N, {
|
|
773
|
+
class: "col-span-2",
|
|
774
|
+
disabled: t.disabled,
|
|
775
|
+
label: "Remark",
|
|
776
|
+
modelValue: r.value,
|
|
777
|
+
"onUpdate:modelValue": n[4] || (n[4] = (L) => r.value = L),
|
|
778
|
+
"label-mark": "optional"
|
|
779
|
+
}, null, 8, ["disabled", "modelValue"]),
|
|
780
|
+
e("div", Uo, [
|
|
781
|
+
e("div", Eo, v(s(x)("inventory.stock.stock_adjustment.stockAfter")), 1),
|
|
782
|
+
e("div", {
|
|
783
|
+
class: He(["fm-typo-en-body-lg-600", o.value ? "text-red-700" : "text-green-700"])
|
|
784
|
+
}, v(S.value), 3),
|
|
785
|
+
t.isBackdate ? (V(), q("div", Ro, v(s(x)("inventory.stock.stock_adjustment.backdatePreviewWarning")), 1)) : se("", !0)
|
|
786
|
+
])
|
|
787
|
+
]),
|
|
788
|
+
_: 1
|
|
789
|
+
});
|
|
790
|
+
};
|
|
791
|
+
}
|
|
792
|
+
}), No = { class: "flex items-center" }, Oo = { class: "fm-typo-en-title-md-800" }, Lo = { class: "flex items-center" }, Yo = { class: "fm-typo-en-title-sm-800 flex-1" }, zo = { class: "flex gap-8" }, Go = /* @__PURE__ */ ve({
|
|
793
|
+
__name: "AdjustSkuDialog",
|
|
794
|
+
props: {
|
|
795
|
+
stock: {},
|
|
796
|
+
show: { type: Boolean }
|
|
797
|
+
},
|
|
798
|
+
emits: ["update:show", "submitted"],
|
|
799
|
+
setup(w, { expose: m, emit: k }) {
|
|
800
|
+
const p = w, x = k, j = Ne(), u = Le(), l = Ae(), b = we(), R = Y(!1), { t: C } = pe();
|
|
801
|
+
function r() {
|
|
802
|
+
S(Re(c));
|
|
803
|
+
}
|
|
804
|
+
const a = Y();
|
|
805
|
+
m({
|
|
806
|
+
validateInputs: () => {
|
|
807
|
+
var n, $;
|
|
808
|
+
($ = (n = a.value) == null ? void 0 : n.validateInputs) == null || $.call(n);
|
|
809
|
+
},
|
|
810
|
+
resetInputsValidation: () => {
|
|
811
|
+
var n, $;
|
|
812
|
+
($ = (n = a.value) == null ? void 0 : n.resetInputsValidation) == null || $.call(n);
|
|
813
|
+
},
|
|
814
|
+
resetInputs: () => {
|
|
815
|
+
var n, $;
|
|
816
|
+
($ = (n = a.value) == null ? void 0 : n.resetInputs) == null || $.call(n);
|
|
817
|
+
}
|
|
818
|
+
});
|
|
819
|
+
const D = Ye(p, "show"), c = _t({
|
|
820
|
+
remark: "",
|
|
821
|
+
adjustments: [
|
|
822
|
+
{
|
|
823
|
+
id: `sku_${(/* @__PURE__ */ new Date()).toISOString()}_${Math.random().toString(16).slice(2, 8)}`,
|
|
824
|
+
type: ie.enum.PURCHASE,
|
|
825
|
+
doc: p.stock,
|
|
826
|
+
measurement: null,
|
|
827
|
+
remark: "",
|
|
828
|
+
amount: xe(1)
|
|
829
|
+
}
|
|
830
|
+
]
|
|
831
|
+
});
|
|
832
|
+
Fe([() => p.show], ([n]) => {
|
|
833
|
+
n && (c.remark = "", c.adjustments = [
|
|
834
|
+
{
|
|
835
|
+
id: `sku_${(/* @__PURE__ */ new Date()).toISOString()}_${Math.random().toString(16).slice(2, 8)}`,
|
|
836
|
+
type: ie.enum.PURCHASE,
|
|
837
|
+
doc: p.stock,
|
|
838
|
+
measurement: null,
|
|
839
|
+
remark: "",
|
|
840
|
+
amount: xe(1)
|
|
841
|
+
}
|
|
842
|
+
]);
|
|
843
|
+
});
|
|
844
|
+
async function S(n) {
|
|
845
|
+
R.value = !0;
|
|
846
|
+
try {
|
|
847
|
+
await l.adjustSku({
|
|
848
|
+
remark: n.remark,
|
|
849
|
+
adjustments: n.adjustments.map(({ doc: $, remark: P, type: N, amount: O, measurement: L }) => ({
|
|
850
|
+
id: $._id,
|
|
851
|
+
amount: O,
|
|
852
|
+
measurement: L,
|
|
853
|
+
remark: P,
|
|
854
|
+
doc: $,
|
|
855
|
+
type: N
|
|
856
|
+
}))
|
|
857
|
+
}), x("update:show", !1), x("submitted");
|
|
858
|
+
} catch ($) {
|
|
859
|
+
b.open({
|
|
860
|
+
title: C("inventory.stock.adjust.error.title"),
|
|
861
|
+
message: C("inventory.stock.adjust.error.message"),
|
|
862
|
+
type: "error"
|
|
863
|
+
}), console.log("error on adjust ingredients", n, $);
|
|
864
|
+
} finally {
|
|
865
|
+
R.value = !1;
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
function o() {
|
|
869
|
+
const n = j.skus.map((P) => ({
|
|
870
|
+
label: P.name,
|
|
871
|
+
sublabel: P.code,
|
|
872
|
+
value: P._id
|
|
873
|
+
})), $ = n.filter((P) => c.adjustments.find((N) => N.doc._id === P.value)).map((P) => P.value);
|
|
874
|
+
u.open({
|
|
875
|
+
title: "Select ingredients",
|
|
876
|
+
contentComponent: St,
|
|
877
|
+
contentComponentProps: {
|
|
878
|
+
items: n,
|
|
879
|
+
modelValue: $
|
|
880
|
+
},
|
|
881
|
+
overlay: !0,
|
|
882
|
+
closeButton: !0,
|
|
883
|
+
dismissAway: !0,
|
|
884
|
+
primaryActions: {
|
|
885
|
+
text: "Confirm",
|
|
886
|
+
close: !0
|
|
887
|
+
},
|
|
888
|
+
secondaryActions: {
|
|
889
|
+
text: "Close",
|
|
890
|
+
close: !0,
|
|
891
|
+
variant: "tertiary"
|
|
892
|
+
}
|
|
893
|
+
}).onPrimary((P) => {
|
|
894
|
+
c.adjustments = P.map(
|
|
895
|
+
(N) => c.adjustments.find((O) => O.doc._id === N) ?? {
|
|
896
|
+
id: `sku_${(/* @__PURE__ */ new Date()).toISOString()}_${Math.random().toString(16).slice(2, 8)}`,
|
|
897
|
+
type: ie.enum.PURCHASE,
|
|
898
|
+
doc: j.skus.find((O) => O._id === N),
|
|
899
|
+
measurement: null,
|
|
900
|
+
remark: "",
|
|
901
|
+
amount: xe(1)
|
|
902
|
+
}
|
|
903
|
+
);
|
|
904
|
+
});
|
|
905
|
+
}
|
|
906
|
+
function t(n) {
|
|
907
|
+
c.adjustments.splice(n, 1);
|
|
908
|
+
}
|
|
909
|
+
return (n, $) => {
|
|
910
|
+
const P = B("FmTextarea"), N = B("FmButton"), O = B("FmForm"), L = B("FmSideSheet");
|
|
911
|
+
return V(), ne(L, {
|
|
912
|
+
modelValue: s(D),
|
|
913
|
+
"onUpdate:modelValue": $[2] || ($[2] = (X) => Ee(D) ? D.value = X : null),
|
|
914
|
+
"dismiss-away": "",
|
|
915
|
+
"max-width": 500
|
|
916
|
+
}, {
|
|
917
|
+
"side-sheet-header": M(() => [
|
|
918
|
+
e("div", No, [
|
|
919
|
+
e("div", Oo, v(s(C)("inventory.stock.adjust.title")), 1)
|
|
920
|
+
])
|
|
921
|
+
]),
|
|
922
|
+
default: M(() => [
|
|
923
|
+
_(O, {
|
|
924
|
+
class: "w-full flex flex-col gap-12",
|
|
925
|
+
ref_key: "formRef",
|
|
926
|
+
ref: a,
|
|
927
|
+
onValidationSuccess: r
|
|
928
|
+
}, {
|
|
929
|
+
default: M(() => [
|
|
930
|
+
_(P, {
|
|
931
|
+
label: s(C)("inventory.stock.adjust.remark"),
|
|
932
|
+
modelValue: c.remark,
|
|
933
|
+
"onUpdate:modelValue": $[0] || ($[0] = (X) => c.remark = X)
|
|
934
|
+
}, null, 8, ["label", "modelValue"]),
|
|
935
|
+
e("div", Lo, [
|
|
936
|
+
e("div", Yo, v(s(C)("inventory.stock.adjust.adjustedItems")), 1),
|
|
937
|
+
_(N, {
|
|
938
|
+
"prepend-icon": "add",
|
|
939
|
+
variant: "tertiary",
|
|
940
|
+
size: "md",
|
|
941
|
+
onClick: o
|
|
942
|
+
})
|
|
943
|
+
]),
|
|
944
|
+
(V(!0), q(ue, null, fe(c.adjustments, (X, z) => (V(), ne($t, {
|
|
945
|
+
key: X.id,
|
|
946
|
+
modelValue: c.adjustments[z],
|
|
947
|
+
"onUpdate:modelValue": (K) => c.adjustments[z] = K,
|
|
948
|
+
"onClick:delete": (K) => t(z)
|
|
949
|
+
}, null, 8, ["modelValue", "onUpdate:modelValue", "onClick:delete"]))), 128))
|
|
950
|
+
]),
|
|
951
|
+
_: 1
|
|
952
|
+
}, 512)
|
|
953
|
+
]),
|
|
954
|
+
"side-sheet-footer": M(() => [
|
|
955
|
+
e("div", zo, [
|
|
956
|
+
_(N, {
|
|
957
|
+
label: s(C)("inventory.stock.adjust.adjustButton"),
|
|
958
|
+
loading: R.value,
|
|
959
|
+
onClick: $[1] || ($[1] = (X) => {
|
|
960
|
+
var z, K;
|
|
961
|
+
return (K = (z = a.value) == null ? void 0 : z.validateInputs) == null ? void 0 : K.call(z);
|
|
962
|
+
})
|
|
963
|
+
}, null, 8, ["label", "loading"])
|
|
964
|
+
])
|
|
965
|
+
]),
|
|
966
|
+
_: 1
|
|
967
|
+
}, 8, ["modelValue"]);
|
|
968
|
+
};
|
|
969
|
+
}
|
|
970
|
+
}), Wo = { class: "flex items-center w-full gap-8" }, Ko = { class: "fm-typo-en-title-md-800 flex-1" }, qo = {
|
|
971
|
+
key: 0,
|
|
972
|
+
class: "flex flex-col gap-4"
|
|
973
|
+
}, Xo = { class: "fm-typo-en-body-md-600" }, Jo = { class: "flex gap-8 items-start" }, Qo = { class: "flex-1 min-w-0" }, Zo = { class: "flex-1 min-w-0" }, en = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, tn = { class: "flex items-center" }, on = { class: "fm-typo-en-title-sm-800 flex-1" }, nn = { class: "flex gap-8" }, yt = 14, sn = /* @__PURE__ */ ve({
|
|
974
|
+
__name: "StockAdjustmentSideSheet",
|
|
975
|
+
props: {
|
|
976
|
+
show: { type: Boolean }
|
|
977
|
+
},
|
|
978
|
+
emits: ["update:show", "submitted"],
|
|
979
|
+
setup(w, { emit: m }) {
|
|
980
|
+
const k = w, p = m, { t: x } = pe(), j = Ne(), u = Ae(), l = Le(), b = we(), R = Ye(k, "show"), C = Y(!1), r = _t({
|
|
981
|
+
remark: "",
|
|
982
|
+
effectiveAt: /* @__PURE__ */ new Date(),
|
|
983
|
+
adjustments: []
|
|
984
|
+
}), a = Y(!1), D = Y(ke().format("YYYY-MM-DD")), c = Y(ke().format("HH:mm")), S = Y();
|
|
985
|
+
Fe([D, c], () => {
|
|
986
|
+
if (D.value && c.value) {
|
|
987
|
+
const K = ke(`${D.value} ${c.value}`, "YYYY-MM-DD HH:mm");
|
|
988
|
+
K.isValid() && (r.effectiveAt = K.toDate());
|
|
989
|
+
}
|
|
990
|
+
});
|
|
991
|
+
const o = T(() => `${D.value} ${c.value}`);
|
|
992
|
+
function t() {
|
|
993
|
+
if (!a.value) return !0;
|
|
994
|
+
const K = ke(`${D.value} ${c.value}`, "YYYY-MM-DD HH:mm");
|
|
995
|
+
if (!K.isValid()) return x("inventory.stock.stock_adjustment.invalidDateTime");
|
|
996
|
+
const U = ke();
|
|
997
|
+
if (K.isAfter(U))
|
|
998
|
+
return x("inventory.stock.stock_adjustment.futureDateNotAllowed");
|
|
999
|
+
const Z = U.subtract(yt, "day");
|
|
1000
|
+
return K.isBefore(Z) ? x("inventory.stock.stock_adjustment.backdateLimitError", { days: yt }) : !0;
|
|
1001
|
+
}
|
|
1002
|
+
const n = T(() => [() => t()]), $ = T(() => r.adjustments.length === 0 || t() !== !0);
|
|
1003
|
+
function P() {
|
|
1004
|
+
r.remark = "", r.effectiveAt = /* @__PURE__ */ new Date(), r.adjustments = [], a.value = !1, D.value = ke(r.effectiveAt).format("YYYY-MM-DD"), c.value = ke(r.effectiveAt).format("HH:mm");
|
|
1005
|
+
}
|
|
1006
|
+
function N() {
|
|
1007
|
+
P();
|
|
1008
|
+
}
|
|
1009
|
+
const O = T(() => {
|
|
1010
|
+
const K = {};
|
|
1011
|
+
return j.skus.forEach((U) => {
|
|
1012
|
+
K[U._id] = U;
|
|
1013
|
+
}), K;
|
|
1014
|
+
});
|
|
1015
|
+
function L() {
|
|
1016
|
+
const K = j.skus.map((Z) => ({
|
|
1017
|
+
label: Z.name,
|
|
1018
|
+
sublabel: Z.code,
|
|
1019
|
+
value: Z._id
|
|
1020
|
+
})), U = r.adjustments.map((Z) => Z.doc._id);
|
|
1021
|
+
l.open({
|
|
1022
|
+
title: x("inventory.stock.adjust.selectIngredients"),
|
|
1023
|
+
contentComponent: St,
|
|
1024
|
+
contentComponentProps: {
|
|
1025
|
+
items: K,
|
|
1026
|
+
modelValue: U,
|
|
1027
|
+
virtualScroll: !0
|
|
1028
|
+
},
|
|
1029
|
+
overlay: !0,
|
|
1030
|
+
closeButton: !0,
|
|
1031
|
+
dismissAway: !0,
|
|
1032
|
+
primaryActions: {
|
|
1033
|
+
text: x("common.confirm"),
|
|
1034
|
+
close: !0
|
|
1035
|
+
},
|
|
1036
|
+
secondaryActions: {
|
|
1037
|
+
text: x("common.close"),
|
|
1038
|
+
close: !0,
|
|
1039
|
+
variant: "tertiary"
|
|
1040
|
+
}
|
|
1041
|
+
}).onPrimary((Z) => {
|
|
1042
|
+
r.adjustments = Z.map(
|
|
1043
|
+
(le) => r.adjustments.find((g) => g.doc._id === le) ?? {
|
|
1044
|
+
id: "",
|
|
1045
|
+
type: ie.enum.PURCHASE,
|
|
1046
|
+
doc: O.value[le],
|
|
1047
|
+
measurement: null,
|
|
1048
|
+
remark: "",
|
|
1049
|
+
amount: xe(1)
|
|
1050
|
+
}
|
|
1051
|
+
);
|
|
1052
|
+
});
|
|
1053
|
+
}
|
|
1054
|
+
function X(K) {
|
|
1055
|
+
r.adjustments.splice(K, 1);
|
|
1056
|
+
}
|
|
1057
|
+
async function z() {
|
|
1058
|
+
if (r.adjustments.length === 0) {
|
|
1059
|
+
b.open({
|
|
1060
|
+
title: x("inventory.stock.error.title"),
|
|
1061
|
+
message: x("inventory.stock.stock_adjustment.noAdjustments"),
|
|
1062
|
+
type: "warning"
|
|
1063
|
+
});
|
|
1064
|
+
return;
|
|
1065
|
+
}
|
|
1066
|
+
C.value = !0;
|
|
1067
|
+
try {
|
|
1068
|
+
const K = r.adjustments.map(
|
|
1069
|
+
({ doc: Z, remark: le, type: g, amount: A, measurement: G }) => ({
|
|
1070
|
+
id: Z._id,
|
|
1071
|
+
amount: A,
|
|
1072
|
+
measurement: G,
|
|
1073
|
+
remark: le,
|
|
1074
|
+
doc: Z,
|
|
1075
|
+
type: g
|
|
1076
|
+
})
|
|
1077
|
+
), U = {
|
|
1078
|
+
remark: r.remark,
|
|
1079
|
+
adjustments: K,
|
|
1080
|
+
...a.value ? { effectiveAt: r.effectiveAt.toISOString() } : {}
|
|
1081
|
+
};
|
|
1082
|
+
await u.adjustSku(Re(U)), p("submitted"), p("update:show", !1);
|
|
1083
|
+
} catch (K) {
|
|
1084
|
+
b.open({
|
|
1085
|
+
title: x("inventory.stock.adjust.error.title"),
|
|
1086
|
+
message: x("inventory.stock.adjust.error.message"),
|
|
1087
|
+
type: "error"
|
|
1088
|
+
}), console.error("error on stock adjustment", K);
|
|
1089
|
+
} finally {
|
|
1090
|
+
C.value = !1;
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
return (K, U) => {
|
|
1094
|
+
const Z = B("FmTextarea"), le = B("FmSwitch"), g = B("FmDatePicker"), A = B("FmTimePicker"), G = B("FmFormGroup"), H = B("FmButton"), J = B("FmForm"), I = B("FmSideSheet");
|
|
1095
|
+
return V(), ne(I, {
|
|
1096
|
+
modelValue: s(R),
|
|
1097
|
+
"onUpdate:modelValue": U[6] || (U[6] = (i) => Ee(R) ? R.value = i : null),
|
|
1098
|
+
"dismiss-away": "",
|
|
1099
|
+
"max-width": 560,
|
|
1100
|
+
onAfterEnter: N
|
|
1101
|
+
}, {
|
|
1102
|
+
"side-sheet-header": M(() => [
|
|
1103
|
+
e("div", Wo, [
|
|
1104
|
+
e("div", Ko, v(s(x)("inventory.stock.stock_adjustment.title")), 1)
|
|
1105
|
+
])
|
|
1106
|
+
]),
|
|
1107
|
+
default: M(() => [
|
|
1108
|
+
_(J, {
|
|
1109
|
+
class: "flex flex-col gap-16",
|
|
1110
|
+
ref_key: "formRef",
|
|
1111
|
+
ref: S,
|
|
1112
|
+
onValidationSuccess: z
|
|
1113
|
+
}, {
|
|
1114
|
+
default: M(() => [
|
|
1115
|
+
_(Z, {
|
|
1116
|
+
label: s(x)("inventory.stock.adjust.remark"),
|
|
1117
|
+
modelValue: r.remark,
|
|
1118
|
+
"onUpdate:modelValue": U[0] || (U[0] = (i) => r.remark = i),
|
|
1119
|
+
"label-mark": "optional"
|
|
1120
|
+
}, null, 8, ["label", "modelValue"]),
|
|
1121
|
+
_(le, {
|
|
1122
|
+
value: "",
|
|
1123
|
+
"model-value": a.value,
|
|
1124
|
+
"onUpdate:modelValue": U[1] || (U[1] = (i) => a.value = i),
|
|
1125
|
+
label: s(x)("inventory.stock.stock_adjustment.backdateLabel"),
|
|
1126
|
+
sublabel: s(x)("inventory.stock.stock_adjustment.backdateSublabel"),
|
|
1127
|
+
labelPlacement: "right"
|
|
1128
|
+
}, null, 8, ["model-value", "label", "sublabel"]),
|
|
1129
|
+
a.value ? (V(), q("div", qo, [
|
|
1130
|
+
e("label", Xo, v(s(x)("inventory.stock.stock_adjustment.effectiveAt")), 1),
|
|
1131
|
+
e("div", Jo, [
|
|
1132
|
+
e("div", Qo, [
|
|
1133
|
+
_(g, {
|
|
1134
|
+
class: "w-full",
|
|
1135
|
+
modelValue: D.value,
|
|
1136
|
+
"onUpdate:modelValue": U[2] || (U[2] = (i) => D.value = i),
|
|
1137
|
+
clearable: !1
|
|
1138
|
+
}, null, 8, ["modelValue"])
|
|
1139
|
+
]),
|
|
1140
|
+
e("div", Zo, [
|
|
1141
|
+
_(A, {
|
|
1142
|
+
class: "w-full",
|
|
1143
|
+
modelValue: c.value,
|
|
1144
|
+
"onUpdate:modelValue": U[3] || (U[3] = (i) => c.value = i),
|
|
1145
|
+
format: "HH:mm"
|
|
1146
|
+
}, null, 8, ["modelValue"])
|
|
1147
|
+
])
|
|
1148
|
+
]),
|
|
1149
|
+
_(G, {
|
|
1150
|
+
"model-value": o.value,
|
|
1151
|
+
rules: n.value
|
|
1152
|
+
}, null, 8, ["model-value", "rules"]),
|
|
1153
|
+
e("div", en, v(s(x)("inventory.stock.stock_adjustment.immediateHint")), 1)
|
|
1154
|
+
])) : se("", !0),
|
|
1155
|
+
e("div", tn, [
|
|
1156
|
+
e("div", on, v(s(x)("inventory.stock.adjust.adjustedItems")), 1),
|
|
1157
|
+
_(H, {
|
|
1158
|
+
"prepend-icon": "add",
|
|
1159
|
+
variant: "tertiary",
|
|
1160
|
+
size: "md",
|
|
1161
|
+
onClick: L
|
|
1162
|
+
})
|
|
1163
|
+
]),
|
|
1164
|
+
(V(!0), q(ue, null, fe(r.adjustments, (i, h) => (V(), ne($t, {
|
|
1165
|
+
key: i.doc._id,
|
|
1166
|
+
modelValue: r.adjustments[h],
|
|
1167
|
+
"onUpdate:modelValue": (y) => r.adjustments[h] = y,
|
|
1168
|
+
"is-backdate": a.value,
|
|
1169
|
+
"onClick:delete": (y) => X(h)
|
|
1170
|
+
}, null, 8, ["modelValue", "onUpdate:modelValue", "is-backdate", "onClick:delete"]))), 128))
|
|
1171
|
+
]),
|
|
1172
|
+
_: 1
|
|
1173
|
+
}, 512)
|
|
1174
|
+
]),
|
|
1175
|
+
"side-sheet-footer": M(() => [
|
|
1176
|
+
e("div", nn, [
|
|
1177
|
+
_(H, {
|
|
1178
|
+
label: s(x)("common.confirm"),
|
|
1179
|
+
loading: C.value,
|
|
1180
|
+
disabled: $.value,
|
|
1181
|
+
onClick: U[4] || (U[4] = (i) => {
|
|
1182
|
+
var h, y;
|
|
1183
|
+
return (y = (h = S.value) == null ? void 0 : h.validateInputs) == null ? void 0 : y.call(h);
|
|
1184
|
+
})
|
|
1185
|
+
}, null, 8, ["label", "loading", "disabled"]),
|
|
1186
|
+
_(H, {
|
|
1187
|
+
label: s(x)("common.close"),
|
|
1188
|
+
variant: "tertiary",
|
|
1189
|
+
onClick: U[5] || (U[5] = (i) => p("update:show", !1))
|
|
1190
|
+
}, null, 8, ["label"])
|
|
1191
|
+
])
|
|
1192
|
+
]),
|
|
1193
|
+
_: 1
|
|
1194
|
+
}, 8, ["modelValue"]);
|
|
1195
|
+
};
|
|
1196
|
+
}
|
|
1197
|
+
}), an = Tt((w, m) => ({
|
|
1198
|
+
// TODO: remove once latest inventory backend has been push
|
|
1199
|
+
async findBillsByBusinessId(k, p, x) {
|
|
1200
|
+
const j = `${w.businessesBackendUrl}/${k}/reports/find-many`, u = {
|
|
1201
|
+
// type: TYPE.bill,
|
|
1202
|
+
type: "bill",
|
|
1203
|
+
restaurantIds: p,
|
|
1204
|
+
ids: x
|
|
1205
|
+
};
|
|
1206
|
+
return await m.post(j, u);
|
|
1207
|
+
},
|
|
1208
|
+
async findBillsById(k) {
|
|
1209
|
+
const x = Se().currentLocationDBName, j = `${w.inventoryBackendUrl}/${x}/bill/search`, u = {
|
|
1210
|
+
ids: k
|
|
1211
|
+
};
|
|
1212
|
+
return await m.post(j, u);
|
|
1213
|
+
}
|
|
1214
|
+
})), ln = {
|
|
1215
|
+
key: 0,
|
|
1216
|
+
class: "flex justify-center items-center h-32"
|
|
1217
|
+
}, rn = { class: "mb-3" }, un = { class: "flex flex-col gap-8" }, cn = { class: "flex flex-col text-fm-color-typo-primary mb-3 text-center" }, dn = { class: "text-fm-color-neutral-gray-400 fm-typo-en-body-sm-600" }, mn = { class: "flex flex-col gap-4 text-fm-color-typo-primary mb-3" }, fn = { class: "flex flex-col gap-4 text-fm-color-typo-primary mb-3" }, vn = { class: "flex flex-col gap-4 text-fm-color-typo-primary mb-3" }, pn = { class: "flex flex-col w-full px-2" }, yn = { class: "flex gap-2" }, _n = /* @__PURE__ */ ve({
|
|
1218
|
+
__name: "AmendAdjustmentForm",
|
|
1219
|
+
props: /* @__PURE__ */ nt({
|
|
1220
|
+
adjustmentId: {}
|
|
1221
|
+
}, {
|
|
1222
|
+
modelValue: {},
|
|
1223
|
+
modelModifiers: {}
|
|
1224
|
+
}),
|
|
1225
|
+
emits: /* @__PURE__ */ nt(["refreshHistory"], ["update:modelValue"]),
|
|
1226
|
+
setup(w, { emit: m }) {
|
|
1227
|
+
const k = w, p = m, x = Ae(), j = jt(w, "modelValue"), u = Y(!1), l = Y(!1), b = Y(!1), R = Y({
|
|
1228
|
+
_id: `inventoryAdjustment_${(/* @__PURE__ */ new Date()).toISOString()}_XXXXX`,
|
|
1229
|
+
skus: []
|
|
1230
|
+
}), C = Y();
|
|
1231
|
+
qe(async () => {
|
|
1232
|
+
u.value = !0;
|
|
1233
|
+
const o = await x.readSingleAdjustment(k.adjustmentId);
|
|
1234
|
+
if (!o) throw new Error("Adjustment not found");
|
|
1235
|
+
R.value = o, u.value = !1;
|
|
1236
|
+
});
|
|
1237
|
+
async function r() {
|
|
1238
|
+
var t, n;
|
|
1239
|
+
if ((n = (t = C == null ? void 0 : C.value) == null ? void 0 : t.validateInputs) == null || n.call(t), !l.value) return;
|
|
1240
|
+
const o = {};
|
|
1241
|
+
Object.keys(j.value || {}).forEach(($) => {
|
|
1242
|
+
var P;
|
|
1243
|
+
Object.keys(((P = j.value) == null ? void 0 : P[$]) || {}).forEach((N) => {
|
|
1244
|
+
var L, X;
|
|
1245
|
+
const O = (X = (L = j.value) == null ? void 0 : L[$]) == null ? void 0 : X[Number(N)];
|
|
1246
|
+
O && D(O.amount) > 0 && (o[$] || (o[$] = []), o[$].push(O));
|
|
1247
|
+
});
|
|
1248
|
+
}), await x.revertWastageAdjustment({
|
|
1249
|
+
targetWastageAdjustmentId: k.adjustmentId,
|
|
1250
|
+
amountsGoingToAdjust: o
|
|
1251
|
+
}), p("refreshHistory"), b.value = !1, j.value = {};
|
|
1252
|
+
}
|
|
1253
|
+
function a(o) {
|
|
1254
|
+
const { skuId: t, idx: n, unit: $, measurement: P } = o;
|
|
1255
|
+
return T({
|
|
1256
|
+
get: () => {
|
|
1257
|
+
var L, X, z;
|
|
1258
|
+
const N = (z = (X = (L = j.value) == null ? void 0 : L[t]) == null ? void 0 : X[n]) == null ? void 0 : z.amount;
|
|
1259
|
+
return N ? Number(_e.toFormatString({ value: N })) : 0;
|
|
1260
|
+
},
|
|
1261
|
+
set: (N) => {
|
|
1262
|
+
j.value || (j.value = {});
|
|
1263
|
+
const O = { ...j.value };
|
|
1264
|
+
O[t] || (O[t] = {}), O[t][n] = {
|
|
1265
|
+
amount: _e.convertPrecision({
|
|
1266
|
+
value: _e.fromNumber(N),
|
|
1267
|
+
precision: $e($)
|
|
1268
|
+
}),
|
|
1269
|
+
type: ie.Enum.WASTAGE,
|
|
1270
|
+
measurement: P
|
|
1271
|
+
}, j.value = O;
|
|
1272
|
+
}
|
|
1273
|
+
});
|
|
1274
|
+
}
|
|
1275
|
+
function D(o, t = !0) {
|
|
1276
|
+
const n = Number(_e.toFormatString({ value: o }));
|
|
1277
|
+
return t ? Math.abs(n) : n;
|
|
1278
|
+
}
|
|
1279
|
+
function c(o, t) {
|
|
1280
|
+
return t.measurement ? t.measurement.abbrev : o.sku.unit.abbrev;
|
|
1281
|
+
}
|
|
1282
|
+
function S(o, t) {
|
|
1283
|
+
if (t.amount === 0) return "N/A";
|
|
1284
|
+
const n = _e.add([o, t]);
|
|
1285
|
+
return n ? _e.toFormatString({ value: n }) : "N/A";
|
|
1286
|
+
}
|
|
1287
|
+
return (o, t) => {
|
|
1288
|
+
const n = B("FmIcon"), $ = B("FmStepperField"), P = B("FmCard"), N = B("FmForm"), O = B("FmSpacer"), L = B("FmButton"), X = B("FmDialog");
|
|
1289
|
+
return V(), ne(X, {
|
|
1290
|
+
modelValue: b.value,
|
|
1291
|
+
"onUpdate:modelValue": t[4] || (t[4] = (z) => b.value = z),
|
|
1292
|
+
overlay: !0
|
|
1293
|
+
}, {
|
|
1294
|
+
"dialog-button": M(() => [
|
|
1295
|
+
_(Je, null, {
|
|
1296
|
+
default: M(() => [
|
|
1297
|
+
e("button", {
|
|
1298
|
+
onClick: t[0] || (t[0] = (z) => b.value = !0),
|
|
1299
|
+
class: "rounded-md hover:bg-gray-100 transition-colors"
|
|
1300
|
+
}, [
|
|
1301
|
+
_(n, {
|
|
1302
|
+
name: "edit",
|
|
1303
|
+
size: "sm"
|
|
1304
|
+
})
|
|
1305
|
+
])
|
|
1306
|
+
]),
|
|
1307
|
+
_: 1
|
|
1308
|
+
})
|
|
1309
|
+
]),
|
|
1310
|
+
"dialog-header": M(() => t[5] || (t[5] = [
|
|
1311
|
+
e("div", null, "Amend Adjustment", -1)
|
|
1312
|
+
])),
|
|
1313
|
+
"dialog-footer": M(() => [
|
|
1314
|
+
e("div", pn, [
|
|
1315
|
+
t[13] || (t[13] = e("span", { class: "text-fm-color-system-warning-400 fm-typo-en-body-sm-400" }, "1. New adjustment EXTRA will be created for each reversal", -1)),
|
|
1316
|
+
e("div", yn, [
|
|
1317
|
+
_(O),
|
|
1318
|
+
_(L, {
|
|
1319
|
+
class: "sm:w-full xs:w-full",
|
|
1320
|
+
label: "Close",
|
|
1321
|
+
size: "md",
|
|
1322
|
+
variant: "tertiary",
|
|
1323
|
+
onClick: t[3] || (t[3] = (z) => b.value = !1)
|
|
1324
|
+
}),
|
|
1325
|
+
_(L, {
|
|
1326
|
+
class: "sm:w-full xs:w-full",
|
|
1327
|
+
label: "Submit",
|
|
1328
|
+
size: "md",
|
|
1329
|
+
variant: "primary",
|
|
1330
|
+
onClick: r
|
|
1331
|
+
})
|
|
1332
|
+
])
|
|
1333
|
+
])
|
|
1334
|
+
]),
|
|
1335
|
+
default: M(() => [
|
|
1336
|
+
u.value ? (V(), q("div", ln)) : (V(), ne(N, {
|
|
1337
|
+
key: 1,
|
|
1338
|
+
ref_key: "formRef",
|
|
1339
|
+
ref: C,
|
|
1340
|
+
onValidationFailed: t[1] || (t[1] = () => {
|
|
1341
|
+
l.value = !1;
|
|
1342
|
+
}),
|
|
1343
|
+
onValidationSuccess: t[2] || (t[2] = () => {
|
|
1344
|
+
l.value = !0;
|
|
1345
|
+
}),
|
|
1346
|
+
blameFormChildOnValidationFailed: ""
|
|
1347
|
+
}, {
|
|
1348
|
+
default: M(() => [
|
|
1349
|
+
e("p", rn, [
|
|
1350
|
+
t[6] || (t[6] = e("b", null, "Date:", -1)),
|
|
1351
|
+
t[7] || (t[7] = e("br", null, null, -1)),
|
|
1352
|
+
ye(" " + v(s(eo)(s(Pt)(R.value._id))), 1)
|
|
1353
|
+
]),
|
|
1354
|
+
e("div", un, [
|
|
1355
|
+
(V(!0), q(ue, null, fe(R.value.skus, (z, K) => (V(), q(ue, { key: K }, [
|
|
1356
|
+
(V(!0), q(ue, null, fe(z.amounts, (U, Z) => (V(), ne(P, {
|
|
1357
|
+
key: Z,
|
|
1358
|
+
variant: "outlined",
|
|
1359
|
+
class: "p-2"
|
|
1360
|
+
}, {
|
|
1361
|
+
default: M(() => [
|
|
1362
|
+
e("div", cn, [
|
|
1363
|
+
e("span", dn, v(z.sku.code), 1),
|
|
1364
|
+
e("span", null, v(z.sku.name), 1)
|
|
1365
|
+
]),
|
|
1366
|
+
t[12] || (t[12] = e("hr", { class: "m-2" }, null, -1)),
|
|
1367
|
+
e("div", mn, [
|
|
1368
|
+
t[8] || (t[8] = e("span", { class: "fm-typo-en-body-lg-600" }, "Adjustment type:", -1)),
|
|
1369
|
+
e("span", null, v(U.type), 1)
|
|
1370
|
+
]),
|
|
1371
|
+
e("div", fn, [
|
|
1372
|
+
t[9] || (t[9] = e("span", { class: "fm-typo-en-body-lg-600" }, "Current amount:", -1)),
|
|
1373
|
+
e("span", null, v(s(_e).toFormatString({ value: U.amount })) + " " + v(c(z, U)), 1)
|
|
1374
|
+
]),
|
|
1375
|
+
_($, {
|
|
1376
|
+
"max-fraction-digits": s($e)(z.sku.unit),
|
|
1377
|
+
"model-value": a({
|
|
1378
|
+
skuId: z.sku._id,
|
|
1379
|
+
idx: Z,
|
|
1380
|
+
unit: z.sku.unit
|
|
1381
|
+
}).value,
|
|
1382
|
+
"onUpdate:modelValue": (le) => a({
|
|
1383
|
+
skuId: z.sku._id,
|
|
1384
|
+
idx: Z,
|
|
1385
|
+
unit: z.sku.unit
|
|
1386
|
+
}).value = le,
|
|
1387
|
+
class: "mb-3",
|
|
1388
|
+
label: "Adjust Amount (Leave 0 to skip)",
|
|
1389
|
+
"helper-text": `Max: ${D(U.amount)}`,
|
|
1390
|
+
"append-text": c(z, U),
|
|
1391
|
+
rules: [
|
|
1392
|
+
(le) => le <= D(U.amount) || `Cannot be more than ${D(U.amount)}`,
|
|
1393
|
+
s(Ue)(-1)
|
|
1394
|
+
]
|
|
1395
|
+
}, null, 8, ["max-fraction-digits", "model-value", "onUpdate:modelValue", "helper-text", "append-text", "rules"]),
|
|
1396
|
+
e("div", vn, [
|
|
1397
|
+
t[10] || (t[10] = e("span", { class: "fm-typo-en-body-lg-600" }, "Amount after amend:", -1)),
|
|
1398
|
+
t[11] || (t[11] = e("span", { class: "text-fm-color-system-warning-400 fm-typo-en-body-sm-400" }, "* It's an estimate for your reference, as it didn't include all the reversals related to this adjustment", -1)),
|
|
1399
|
+
ye(" " + v(S(
|
|
1400
|
+
U.amount,
|
|
1401
|
+
s(_e).fromNumber(
|
|
1402
|
+
a({
|
|
1403
|
+
skuId: z.sku._id,
|
|
1404
|
+
idx: Z,
|
|
1405
|
+
unit: z.sku.unit
|
|
1406
|
+
}).value
|
|
1407
|
+
)
|
|
1408
|
+
)) + " " + v(c(z, U)), 1)
|
|
1409
|
+
])
|
|
1410
|
+
]),
|
|
1411
|
+
_: 2
|
|
1412
|
+
}, 1024))), 128))
|
|
1413
|
+
], 64))), 128))
|
|
1414
|
+
])
|
|
1415
|
+
]),
|
|
1416
|
+
_: 1
|
|
1417
|
+
}, 512))
|
|
1418
|
+
]),
|
|
1419
|
+
_: 1
|
|
1420
|
+
}, 8, ["modelValue"]);
|
|
1421
|
+
};
|
|
1422
|
+
}
|
|
1423
|
+
}), kn = { class: "p-16" }, hn = { class: "fm-typo-en-body-md-600 flex-grow" }, bn = { class: "flex-grow text-fm-color-typo-secondary" }, gn = {
|
|
1424
|
+
key: 0,
|
|
1425
|
+
class: "my-5"
|
|
1426
|
+
}, xn = { class: "text-neutral-400" }, Sn = { class: "flex-grow" }, wn = { class: "flex gap-1" }, An = { class: "flex flex-col gap-1" }, Fn = {
|
|
1427
|
+
key: 1,
|
|
1428
|
+
class: "t-system text-fsecondary"
|
|
1429
|
+
}, $n = {
|
|
1430
|
+
key: 2,
|
|
1431
|
+
class: "text-xs text-gray-400"
|
|
1432
|
+
}, jn = { key: 3 }, Vn = { key: 4 }, Cn = {
|
|
1433
|
+
key: 5,
|
|
1434
|
+
class: "inline-flex items-center rounded-md bg-yellow-400/10 px-2 text-xs font-medium text-yellow-500 inset-ring inset-ring-yellow-400/20"
|
|
1435
|
+
}, Dn = {
|
|
1436
|
+
key: 1,
|
|
1437
|
+
class: "shrink-0 text-fm-color-typo-secondary"
|
|
1438
|
+
}, Bn = /* @__PURE__ */ ve({
|
|
1439
|
+
__name: "StockRecordCard",
|
|
1440
|
+
props: {
|
|
1441
|
+
record: {},
|
|
1442
|
+
sku: {},
|
|
1443
|
+
bills: { default: () => [] },
|
|
1444
|
+
unitCostHistory: { default: () => [] },
|
|
1445
|
+
costMechanism: { default: "adjustment" }
|
|
1446
|
+
},
|
|
1447
|
+
setup(w) {
|
|
1448
|
+
const m = w;
|
|
1449
|
+
function k(C, r) {
|
|
1450
|
+
if (m.costMechanism === "adjustment")
|
|
1451
|
+
return null;
|
|
1452
|
+
const a = m.unitCostHistory.filter(
|
|
1453
|
+
(S) => S.mechanism === m.costMechanism && S.skuId === m.sku._id
|
|
1454
|
+
);
|
|
1455
|
+
if (a.length === 0) return null;
|
|
1456
|
+
const D = a.find((S) => {
|
|
1457
|
+
const o = S.meta;
|
|
1458
|
+
return (o == null ? void 0 : o.adjustmentId) === C;
|
|
1459
|
+
});
|
|
1460
|
+
if (D) return D.cost;
|
|
1461
|
+
const c = [...a].filter((S) => new Date(S.snapshotAt) <= new Date(r)).sort((S, o) => new Date(o.snapshotAt).getTime() - new Date(S.snapshotAt).getTime());
|
|
1462
|
+
return c.length > 0 ? c[0].cost : null;
|
|
1463
|
+
}
|
|
1464
|
+
const p = Y(!1), x = Y(), j = Y(null), u = T(() => j.value === null ? "unset" : p.value ? `${j.value}px` : "0px");
|
|
1465
|
+
qe(() => {
|
|
1466
|
+
var C;
|
|
1467
|
+
j.value = ((C = x.value) == null ? void 0 : C.scrollHeight) || 0;
|
|
1468
|
+
});
|
|
1469
|
+
const l = T(() => {
|
|
1470
|
+
var S;
|
|
1471
|
+
const C = m.record.adjustments, r = m.sku, a = {}, c = C.flatMap((o) => {
|
|
1472
|
+
var t;
|
|
1473
|
+
return ((t = o.skus) == null ? void 0 : t.filter((n) => n.sku._id === r._id)) ?? [];
|
|
1474
|
+
}).flatMap((o) => o.amounts);
|
|
1475
|
+
for (const o of c) {
|
|
1476
|
+
const t = o.measurement ? xt(o.measurement.conversion, o.amount) : o.amount;
|
|
1477
|
+
a[S = o.type] ?? (a[S] = { amount: 0, precision: 0 }), a[o.type] = Qe(t, a[o.type]);
|
|
1478
|
+
}
|
|
1479
|
+
return Object.entries(a).reduce(
|
|
1480
|
+
(o, [t, n]) => (o[t] = /// comment, because without it formatter makes code uglier
|
|
1481
|
+
`${oe.toFormatString({
|
|
1482
|
+
value: n,
|
|
1483
|
+
precision: 4
|
|
1484
|
+
})} ${r.unit.abbrev}`, o),
|
|
1485
|
+
{}
|
|
1486
|
+
);
|
|
1487
|
+
}), { t: b } = pe(), R = T(() => m.record.adjustmentsByTime.map(({ date: C, adjustments: r }) => ({
|
|
1488
|
+
time: to(new Date(C)),
|
|
1489
|
+
adjustments: r.flatMap(
|
|
1490
|
+
(a) => {
|
|
1491
|
+
var D, c;
|
|
1492
|
+
return ((c = (D = a.skus) == null ? void 0 : D.map) == null ? void 0 : c.call(D, (S) => {
|
|
1493
|
+
var o, t;
|
|
1494
|
+
return {
|
|
1495
|
+
...S,
|
|
1496
|
+
ref: a.ref,
|
|
1497
|
+
reason: a.reason,
|
|
1498
|
+
adjustmentRemark: a.remark,
|
|
1499
|
+
backdateFrom: a.effectiveAt != null ? Te(a._id) : null,
|
|
1500
|
+
toBalance: (t = (o = a.skus) == null ? void 0 : o[0]) == null ? void 0 : t.toBalance,
|
|
1501
|
+
adjustmentId: a._id,
|
|
1502
|
+
adjustmentTime: a.effectiveAt ?? Te(a._id)
|
|
1503
|
+
};
|
|
1504
|
+
})) ?? [];
|
|
1505
|
+
}
|
|
1506
|
+
).flatMap((a) => {
|
|
1507
|
+
var t;
|
|
1508
|
+
const D = (t = m.bills.find((n) => n._id === a.ref)) == null ? void 0 : t.seqNumber, c = D ? b("inventory.stock.record.bill", [D]) : "", S = a.adjustmentTime ?? (/* @__PURE__ */ new Date()).toISOString(), o = k(a.adjustmentId, S);
|
|
1509
|
+
return (a.amounts || []).filter((n) => n != null).map((n) => {
|
|
1510
|
+
var N;
|
|
1511
|
+
let $ = n.cost;
|
|
1512
|
+
if (o) {
|
|
1513
|
+
const O = oe.fromDinero(o), L = n.amount, X = n.measurement ? oe.multiply([L, n.measurement.conversion]) : L;
|
|
1514
|
+
$ = {
|
|
1515
|
+
...oe.multiply([
|
|
1516
|
+
O,
|
|
1517
|
+
X
|
|
1518
|
+
]),
|
|
1519
|
+
currency: o.currency
|
|
1520
|
+
};
|
|
1521
|
+
}
|
|
1522
|
+
let P = "";
|
|
1523
|
+
return c ? P = n.remark || "" : P = [a.adjustmentRemark, n.remark].filter((L) => L).join("/"), {
|
|
1524
|
+
amount: `${oe.toFormatString({ value: n.amount, precision: 4 })} ${((N = n.measurement) == null ? void 0 : N.abbrev) ?? a.sku.unit.abbrev}`,
|
|
1525
|
+
backdateFrom: a.backdateFrom,
|
|
1526
|
+
name: n.type,
|
|
1527
|
+
billRemark: c,
|
|
1528
|
+
remark: P,
|
|
1529
|
+
reason: a.reason || "",
|
|
1530
|
+
cost: $,
|
|
1531
|
+
toBalance: oe.toFormatString({
|
|
1532
|
+
value: a.toBalance ?? oe.fromNumber(0),
|
|
1533
|
+
precision: 4
|
|
1534
|
+
}),
|
|
1535
|
+
baseUnit: a.sku.unit.abbrev,
|
|
1536
|
+
adjustmentId: a.adjustmentId
|
|
1537
|
+
};
|
|
1538
|
+
});
|
|
1539
|
+
})
|
|
1540
|
+
})));
|
|
1541
|
+
return (C, r) => {
|
|
1542
|
+
const a = B("FmIcon"), D = B("FmTooltip"), c = B("FmCard");
|
|
1543
|
+
return V(), ne(c, { variant: "outlined" }, {
|
|
1544
|
+
default: M(() => [
|
|
1545
|
+
e("div", kn, [
|
|
1546
|
+
e("div", {
|
|
1547
|
+
class: "flex items-center cursor-pointer mb-1",
|
|
1548
|
+
onClick: r[0] || (r[0] = (S) => p.value = !p.value)
|
|
1549
|
+
}, [
|
|
1550
|
+
e("div", hn, v(C.record.date), 1),
|
|
1551
|
+
_(a, {
|
|
1552
|
+
name: p.value ? "expand_more" : "expand_less",
|
|
1553
|
+
color: "#777777",
|
|
1554
|
+
size: "md"
|
|
1555
|
+
}, null, 8, ["name"])
|
|
1556
|
+
]),
|
|
1557
|
+
(V(!0), q(ue, null, fe(l.value, (S, o) => (V(), q("div", {
|
|
1558
|
+
key: o,
|
|
1559
|
+
class: "flex flex-row py-1",
|
|
1560
|
+
style: { "font-size": "0.8rem" }
|
|
1561
|
+
}, [
|
|
1562
|
+
e("div", bn, v(s(b)(`inventory.inventoryAdjustment.type.${o}`)), 1),
|
|
1563
|
+
e("div", {
|
|
1564
|
+
class: He({
|
|
1565
|
+
"text-fm-color-typo-error": S.startsWith("-"),
|
|
1566
|
+
"text-fm-color-typo-success": !S.startsWith("-"),
|
|
1567
|
+
"ml-auto": !0
|
|
1568
|
+
})
|
|
1569
|
+
}, v(S), 3)
|
|
1570
|
+
]))), 128)),
|
|
1571
|
+
e("div", {
|
|
1572
|
+
ref_key: "detailRef",
|
|
1573
|
+
ref: x,
|
|
1574
|
+
style: kt({
|
|
1575
|
+
fontSize: "0.8rem",
|
|
1576
|
+
maxHeight: u.value,
|
|
1577
|
+
overflow: "hidden",
|
|
1578
|
+
transition: "max-height 0.2s ease-out"
|
|
1579
|
+
})
|
|
1580
|
+
}, [
|
|
1581
|
+
R.value.length ? (V(), q("hr", gn)) : se("", !0),
|
|
1582
|
+
(V(!0), q(ue, null, fe(R.value, (S) => (V(), q("div", {
|
|
1583
|
+
key: S.time,
|
|
1584
|
+
class: "flex gap-1 w-full"
|
|
1585
|
+
}, [
|
|
1586
|
+
e("div", xn, v(S.time), 1),
|
|
1587
|
+
e("div", Sn, [
|
|
1588
|
+
(V(!0), q(ue, null, fe(S.adjustments, (o) => (V(), q("div", {
|
|
1589
|
+
key: o.name,
|
|
1590
|
+
class: "flex gap-1"
|
|
1591
|
+
}, [
|
|
1592
|
+
e("div", wn, [
|
|
1593
|
+
ye(v(s(b)(`inventory.inventoryAdjustment.type.${o.name}`)) + " ", 1),
|
|
1594
|
+
o.backdateFrom ? (V(), ne(D, {
|
|
1595
|
+
key: 0,
|
|
1596
|
+
variant: "plain",
|
|
1597
|
+
placement: "top",
|
|
1598
|
+
"z-index": 50
|
|
1599
|
+
}, {
|
|
1600
|
+
content: M(() => [
|
|
1601
|
+
e("div", An, v(s(b)("inventory.stock.record.backdate", [
|
|
1602
|
+
s(wt)(new Date(o.backdateFrom))
|
|
1603
|
+
])), 1)
|
|
1604
|
+
]),
|
|
1605
|
+
default: M(() => [
|
|
1606
|
+
_(a, {
|
|
1607
|
+
name: "info",
|
|
1608
|
+
size: "sm",
|
|
1609
|
+
color: "primary"
|
|
1610
|
+
})
|
|
1611
|
+
]),
|
|
1612
|
+
_: 2
|
|
1613
|
+
}, 1024)) : se("", !0),
|
|
1614
|
+
o.billRemark ? (V(), q("span", Fn, " # " + v(o.billRemark), 1)) : se("", !0),
|
|
1615
|
+
o.billRemark && o.remark ? (V(), q("span", $n, " (" + v(o.remark) + ") ", 1)) : se("", !0),
|
|
1616
|
+
!o.billRemark && o.reason ? (V(), q("span", jn, " (" + v(o.reason) + ") ", 1)) : se("", !0),
|
|
1617
|
+
!o.billRemark && o.remark ? (V(), q("span", Vn, " # " + v(o.remark), 1)) : se("", !0),
|
|
1618
|
+
o.name === s(ie).Enum.CLOSING ? (V(), q("span", Cn, " Actual Balance: " + v(o.toBalance) + " " + v(o.baseUnit), 1)) : se("", !0)
|
|
1619
|
+
]),
|
|
1620
|
+
e("div", {
|
|
1621
|
+
class: He({
|
|
1622
|
+
"text-fm-color-typo-error": o.amount.startsWith("-"),
|
|
1623
|
+
"text-fm-color-typo-success": !o.amount.startsWith("-"),
|
|
1624
|
+
"ml-auto": !0
|
|
1625
|
+
})
|
|
1626
|
+
}, v(o.amount), 3),
|
|
1627
|
+
o.name === s(ie).Enum.WASTAGE ? (V(), ne(_n, {
|
|
1628
|
+
key: 0,
|
|
1629
|
+
adjustmentId: o.adjustmentId,
|
|
1630
|
+
onRefreshHistory: r[1] || (r[1] = (t) => C.$emit("refreshHistory"))
|
|
1631
|
+
}, null, 8, ["adjustmentId"])) : se("", !0),
|
|
1632
|
+
o.cost ? (V(), q("div", Dn, " (" + v(s(Me)(o.cost, !1, o.cost.precision)) + ") ", 1)) : se("", !0)
|
|
1633
|
+
]))), 128))
|
|
1634
|
+
])
|
|
1635
|
+
]))), 128))
|
|
1636
|
+
], 4)
|
|
1637
|
+
])
|
|
1638
|
+
]),
|
|
1639
|
+
_: 1
|
|
1640
|
+
});
|
|
1641
|
+
};
|
|
1642
|
+
}
|
|
1643
|
+
});
|
|
1644
|
+
function Mn(w, m) {
|
|
1645
|
+
var j;
|
|
1646
|
+
const k = Object.keys(ie.enum).reduce(
|
|
1647
|
+
(u, l) => (u[l] = { amount: 0, precision: 0 }, u),
|
|
1648
|
+
{}
|
|
1649
|
+
);
|
|
1650
|
+
if (!m)
|
|
1651
|
+
return Object.entries(k).reduce(
|
|
1652
|
+
(u, [l]) => (u[l] = oe.fromNumber(0), u),
|
|
1653
|
+
{}
|
|
1654
|
+
);
|
|
1655
|
+
const x = w.flatMap((u) => {
|
|
1656
|
+
var l;
|
|
1657
|
+
return ((l = u.skus) == null ? void 0 : l.filter((b) => b.sku._id === m._id)) ?? [];
|
|
1658
|
+
}).flatMap((u) => u.amounts);
|
|
1659
|
+
for (const u of x) {
|
|
1660
|
+
const l = u.measurement ? oe.multiply([u.measurement.conversion, u.amount]) : u.amount;
|
|
1661
|
+
k[j = u.type] ?? (k[j] = { amount: 0, precision: 0 }), k[u.type] = oe.add([l, k[u.type]]);
|
|
1662
|
+
}
|
|
1663
|
+
return Object.entries(k).reduce(
|
|
1664
|
+
(u, [l, b]) => {
|
|
1665
|
+
const R = {
|
|
1666
|
+
...b,
|
|
1667
|
+
amount: Math.abs(b.amount)
|
|
1668
|
+
};
|
|
1669
|
+
return u[l] = /// comment, because without it formatter makes code uglier
|
|
1670
|
+
`${oe.toFormatString({
|
|
1671
|
+
value: R,
|
|
1672
|
+
precision: 4
|
|
1673
|
+
})} ${m.unit.abbrev}`, u;
|
|
1674
|
+
},
|
|
1675
|
+
{}
|
|
1676
|
+
);
|
|
1677
|
+
}
|
|
1678
|
+
function In(w, m) {
|
|
1679
|
+
if (!m)
|
|
1680
|
+
return null;
|
|
1681
|
+
let k = null;
|
|
1682
|
+
const x = w.flatMap((j) => {
|
|
1683
|
+
var u;
|
|
1684
|
+
return ((u = j.skus) == null ? void 0 : u.filter((l) => l.sku._id === m._id)) ?? [];
|
|
1685
|
+
}).flatMap((j) => {
|
|
1686
|
+
var u;
|
|
1687
|
+
return !j.history || ((u = j.history) == null ? void 0 : u.length) === 0 ? [] : j.history[0];
|
|
1688
|
+
});
|
|
1689
|
+
for (const j of x) {
|
|
1690
|
+
const u = j.amounts;
|
|
1691
|
+
for (const l of u) {
|
|
1692
|
+
if (l.type !== ie.Enum.SALES)
|
|
1693
|
+
continue;
|
|
1694
|
+
const b = l.measurement ? oe.multiply([l.measurement.conversion, l.amount]) : l.amount;
|
|
1695
|
+
k ?? (k = oe.fromNumber(0)), k = oe.add([k, b]);
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
return k != null ? (k.amount = Math.abs(k.amount), `${oe.toFormatString({
|
|
1699
|
+
value: k,
|
|
1700
|
+
precision: 4
|
|
1701
|
+
})} ${m.unit.abbrev}`) : null;
|
|
1702
|
+
}
|
|
1703
|
+
const Hn = { class: "flex items-center w-full fm-typo-en-title-md-800" }, Tn = { class: "flex-1 line-clamp-2" }, Pn = { class: "flex flex-col gap-32 w-full h-full" }, Un = { class: "flex items-center relative gap-4" }, En = { class: "flex-1" }, Rn = {
|
|
1704
|
+
key: 0,
|
|
1705
|
+
class: "flex-1 flex flex-col items-center gap-16"
|
|
1706
|
+
}, Nn = { class: "fm-typo-en-body-lg-400 translate-x-4" }, On = {
|
|
1707
|
+
key: 1,
|
|
1708
|
+
class: "flex flex-col gap-12"
|
|
1709
|
+
}, Ln = { class: "pb-16" }, Yn = { class: "fm-typo-cn-body-lg-600" }, zn = {
|
|
1710
|
+
class: "grid gap-12 fm-typo-en-body-md-400",
|
|
1711
|
+
style: { "grid-template-columns": "auto auto auto", "grid-auto-rows": "1fr" }
|
|
1712
|
+
}, Gn = { class: "flex flex-col gap-1" }, Wn = { class: "text-fm-color-typo-secondary" }, Kn = { class: "font-bold" }, qn = { class: "flex flex-col gap-1" }, Xn = { class: "text-fm-color-typo-secondary flex" }, Jn = { class: "font-bold" }, Qn = { class: "flex flex-col gap-1" }, Zn = { class: "text-fm-color-typo-secondary" }, es = { class: "font-bold" }, ts = { class: "flex flex-col gap-1" }, os = { class: "text-fm-color-typo-secondary" }, ns = { class: "font-bold" }, ss = { class: "flex flex-col gap-1" }, as = { class: "text-fm-color-typo-secondary" }, ls = { class: "font-bold" }, rs = { class: "flex flex-col gap-1" }, is = { class: "text-fm-color-typo-secondary" }, us = { class: "font-bold" }, cs = { class: "flex flex-col gap-1" }, ds = { class: "text-fm-color-typo-secondary" }, ms = { class: "font-bold" }, fs = { class: "flex flex-col gap-1" }, vs = { class: "text-fm-color-typo-secondary" }, ps = { class: "font-bold" }, ys = { class: "flex flex-col gap-1" }, _s = { class: "text-fm-color-typo-secondary" }, ks = { class: "font-bold" }, hs = {
|
|
1713
|
+
key: 0,
|
|
1714
|
+
class: "flex flex-col gap-8"
|
|
1715
|
+
}, bs = { class: "flex" }, gs = { class: "flex-1 flex flex-col gap-1" }, xs = { class: "flex gap-1 items-center text-fm-color-typo-secondary" }, Ss = { class: "font-bold" }, ws = { class: "flex-1 flex flex-col gap-1" }, As = { class: "flex gap-1 items-center text-fm-color-typo-secondary" }, Fs = { class: "flex flex-col gap-1" }, $s = { class: "font-bold" }, js = {
|
|
1716
|
+
key: 2,
|
|
1717
|
+
class: "flex-1 flex flex-col items-center gap-8"
|
|
1718
|
+
}, Vs = ["src"], Cs = { class: "font-bold text-lg" }, Ds = { class: "text-xs text-neutral-400 text-center" }, Bs = /* @__PURE__ */ ve({
|
|
1719
|
+
__name: "StockHistory",
|
|
1720
|
+
props: {
|
|
1721
|
+
sku: {},
|
|
1722
|
+
show: { type: Boolean }
|
|
1723
|
+
},
|
|
1724
|
+
emits: ["update:show"],
|
|
1725
|
+
setup(w) {
|
|
1726
|
+
const m = Xe(), k = Oe(), p = Ae(), x = an(), j = Se(), u = io(), { t: l } = pe(), b = w, R = Y(!1), C = we(), r = Y("adjustment"), a = Y([
|
|
1727
|
+
{ label: "Adjustment (Default)", value: "adjustment" }
|
|
1728
|
+
]), D = Y([]), c = Y(ao(0));
|
|
1729
|
+
async function S() {
|
|
1730
|
+
R.value = !0;
|
|
1731
|
+
try {
|
|
1732
|
+
await N(), await k.readStockBalance();
|
|
1733
|
+
} catch (i) {
|
|
1734
|
+
C.open({
|
|
1735
|
+
title: "Something went wrong",
|
|
1736
|
+
message: "Cannot fetch stock history. Please try again.",
|
|
1737
|
+
type: "error"
|
|
1738
|
+
}), console.log("failed at fetching item adjustment history", b.sku, c, i);
|
|
1739
|
+
} finally {
|
|
1740
|
+
R.value = !1;
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
qe(() => {
|
|
1744
|
+
S();
|
|
1745
|
+
}), Fe([() => c.value, () => b.sku], () => {
|
|
1746
|
+
S();
|
|
1747
|
+
});
|
|
1748
|
+
const o = Y([]), t = Y([]), n = Y(new Array());
|
|
1749
|
+
function $(i, h) {
|
|
1750
|
+
return h === "day" ? so(i) : wt(i);
|
|
1751
|
+
}
|
|
1752
|
+
function P(i, h) {
|
|
1753
|
+
const y = i.reduce(
|
|
1754
|
+
(f, d) => {
|
|
1755
|
+
const F = d.effectiveAt ?? Te(d._id);
|
|
1756
|
+
if (!F)
|
|
1757
|
+
return f;
|
|
1758
|
+
const E = $(new Date(F), h);
|
|
1759
|
+
return f[E] ?? (f[E] = []), f[E].push(d), f;
|
|
1760
|
+
},
|
|
1761
|
+
{}
|
|
1762
|
+
);
|
|
1763
|
+
return Object.keys(y).map((f) => ({
|
|
1764
|
+
date: f,
|
|
1765
|
+
adjustments: y[f]
|
|
1766
|
+
}));
|
|
1767
|
+
}
|
|
1768
|
+
async function N() {
|
|
1769
|
+
let i = await p.readStockAdjustment(
|
|
1770
|
+
b.sku._id,
|
|
1771
|
+
dt(new Date(c.value.startDate)).toISOString(),
|
|
1772
|
+
mt(new Date(c.value.endDate)).toISOString()
|
|
1773
|
+
);
|
|
1774
|
+
o.value = i;
|
|
1775
|
+
const h = i.filter(({ ref: y }) => y == null ? void 0 : y.startsWith("bill_")).map(({ ref: y }) => y);
|
|
1776
|
+
await O(h), t.value = P(i, "day").map(({ date: y, adjustments: f }) => ({
|
|
1777
|
+
date: y,
|
|
1778
|
+
adjustments: f,
|
|
1779
|
+
adjustmentsByTime: P(f, "minute")
|
|
1780
|
+
}));
|
|
1781
|
+
try {
|
|
1782
|
+
const y = await p.readUnitCostHistory(
|
|
1783
|
+
b.sku._id,
|
|
1784
|
+
dt(new Date(c.value.startDate)).toISOString(),
|
|
1785
|
+
mt(new Date(c.value.endDate)).toISOString()
|
|
1786
|
+
);
|
|
1787
|
+
D.value = y;
|
|
1788
|
+
const f = /* @__PURE__ */ new Set();
|
|
1789
|
+
y.forEach((F) => {
|
|
1790
|
+
f.add(F.mechanism);
|
|
1791
|
+
});
|
|
1792
|
+
const d = [{ label: "Default", value: "adjustment" }];
|
|
1793
|
+
f.has(ge.Enum.weightedAverage) && d.push({
|
|
1794
|
+
label: "Weighted Average (Beta)",
|
|
1795
|
+
value: ge.Enum.weightedAverage
|
|
1796
|
+
}), f.has(ge.Enum.netsuite) && d.push({ label: "NetSuite (Beta)", value: ge.Enum.netsuite }), f.has(ge.Enum["netsuite-average"]) && d.push({
|
|
1797
|
+
label: "NetSuite Average (Beta)",
|
|
1798
|
+
value: ge.Enum["netsuite-average"]
|
|
1799
|
+
}), a.value = d, !f.has(r.value) && r.value !== "adjustment" && (r.value = "adjustment");
|
|
1800
|
+
} catch (y) {
|
|
1801
|
+
console.error("Failed to fetch unit cost history:", y);
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
async function O(i) {
|
|
1805
|
+
i.length && (n.value = await x.findBillsById(i).catch((h) => {
|
|
1806
|
+
var d;
|
|
1807
|
+
console.error("Error on using latest bill API, retrying using legacy api", h);
|
|
1808
|
+
const y = ((d = m.currentBusiness.value) == null ? void 0 : d._id) ?? "", f = j.currentLocation.doc._id;
|
|
1809
|
+
return x.findBillsByBusinessId(y, [f], i);
|
|
1810
|
+
}));
|
|
1811
|
+
}
|
|
1812
|
+
const L = T(() => {
|
|
1813
|
+
const i = o.value, h = b.sku;
|
|
1814
|
+
return Mn(i, h);
|
|
1815
|
+
}), X = T(() => {
|
|
1816
|
+
const i = o.value, h = b.sku;
|
|
1817
|
+
return In(i, h);
|
|
1818
|
+
}), z = T(() => {
|
|
1819
|
+
const i = [...o.value].computeFirst((y) => {
|
|
1820
|
+
var d, F;
|
|
1821
|
+
const f = (F = (d = y.skus) == null ? void 0 : d.find) == null ? void 0 : F.call(d, (E) => E.sku._id === b.sku._id);
|
|
1822
|
+
return f == null ? void 0 : f.fromBalance;
|
|
1823
|
+
}) ?? {
|
|
1824
|
+
amount: 0,
|
|
1825
|
+
precision: 0
|
|
1826
|
+
}, h = b.sku;
|
|
1827
|
+
return h ? `${oe.toFormatString({
|
|
1828
|
+
value: i,
|
|
1829
|
+
precision: 4
|
|
1830
|
+
})} ${h.unit.abbrev}` : "";
|
|
1831
|
+
}), K = T(() => {
|
|
1832
|
+
const i = [...o.value].reverse().computeFirst((y) => {
|
|
1833
|
+
var d, F;
|
|
1834
|
+
const f = (F = (d = y.skus) == null ? void 0 : d.find) == null ? void 0 : F.call(d, (E) => E.sku._id === b.sku._id);
|
|
1835
|
+
return f == null ? void 0 : f.toBalance;
|
|
1836
|
+
}) ?? {
|
|
1837
|
+
amount: 0,
|
|
1838
|
+
precision: 0
|
|
1839
|
+
}, h = b.sku;
|
|
1840
|
+
return h ? `${oe.toFormatString({ value: i, precision: 4 })} ${h.unit.abbrev}` : "";
|
|
1841
|
+
}), U = T(() => {
|
|
1842
|
+
var y;
|
|
1843
|
+
const h = o.value.flatMap((f) => {
|
|
1844
|
+
var d;
|
|
1845
|
+
return ((d = f.skus) == null ? void 0 : d.flatMap((F) => F.amounts)) ?? [];
|
|
1846
|
+
}).filter((f) => f.amount.amount < 0).reduce(
|
|
1847
|
+
(f, d) => {
|
|
1848
|
+
const F = d.cost;
|
|
1849
|
+
if (!F) return f;
|
|
1850
|
+
const E = {
|
|
1851
|
+
...Wt(f, Math.max(f.precision, F.precision)),
|
|
1852
|
+
currency: F.currency
|
|
1853
|
+
};
|
|
1854
|
+
return {
|
|
1855
|
+
...Qe(E, F),
|
|
1856
|
+
currency: f.currency
|
|
1857
|
+
};
|
|
1858
|
+
},
|
|
1859
|
+
{
|
|
1860
|
+
amount: 0,
|
|
1861
|
+
precision: 0,
|
|
1862
|
+
currency: Ce((y = m.currentCountry) == null ? void 0 : y.value)
|
|
1863
|
+
}
|
|
1864
|
+
);
|
|
1865
|
+
return Me(h, !1, h.precision);
|
|
1866
|
+
});
|
|
1867
|
+
function Z() {
|
|
1868
|
+
const { startDate: i, endDate: h } = oo(c.value);
|
|
1869
|
+
i !== null && h !== null && (c.value = {
|
|
1870
|
+
startDate: i,
|
|
1871
|
+
endDate: h
|
|
1872
|
+
});
|
|
1873
|
+
}
|
|
1874
|
+
const le = T(() => l("inventory.ingredient.valuationMethod.WAVG"));
|
|
1875
|
+
function g(i, h) {
|
|
1876
|
+
if (r.value === "adjustment")
|
|
1877
|
+
return null;
|
|
1878
|
+
const y = D.value.filter(
|
|
1879
|
+
(F) => F.mechanism === r.value && F.skuId === b.sku._id
|
|
1880
|
+
);
|
|
1881
|
+
if (y.length === 0) return null;
|
|
1882
|
+
const f = y.find((F) => {
|
|
1883
|
+
const E = F.meta;
|
|
1884
|
+
return (E == null ? void 0 : E.adjustmentId) === i;
|
|
1885
|
+
});
|
|
1886
|
+
if (f) return f.cost;
|
|
1887
|
+
const d = [...y].filter((F) => new Date(F.snapshotAt) <= new Date(h)).sort((F, E) => new Date(E.snapshotAt).getTime() - new Date(F.snapshotAt).getTime());
|
|
1888
|
+
return d.length > 0 ? d[0].cost : null;
|
|
1889
|
+
}
|
|
1890
|
+
const A = T(() => {
|
|
1891
|
+
var f, d, F, E, ee, ae;
|
|
1892
|
+
const i = [...o.value].reverse().find((Q) => {
|
|
1893
|
+
var W, te;
|
|
1894
|
+
return (te = (W = Q.skus) == null ? void 0 : W.find) == null ? void 0 : te.call(W, (re) => re.sku._id === b.sku._id);
|
|
1895
|
+
});
|
|
1896
|
+
if (!i) return "No data";
|
|
1897
|
+
const h = (f = i.skus) == null ? void 0 : f.find((Q) => Q.sku._id === b.sku._id);
|
|
1898
|
+
if (!h) return "No data";
|
|
1899
|
+
const y = h.toBalance;
|
|
1900
|
+
if (r.value === "adjustment") {
|
|
1901
|
+
const Q = [...h.amounts].reverse()[0], W = {
|
|
1902
|
+
amount: ((d = Q.cost) == null ? void 0 : d.amount) ?? 0,
|
|
1903
|
+
precision: ((F = Q.cost) == null ? void 0 : F.precision) ?? 0
|
|
1904
|
+
}, te = Q.amount, re = te.amount == 0 ? oe.fromNumber(0) : oe.divide([W, te]);
|
|
1905
|
+
return {
|
|
1906
|
+
...oe.multiply([re, y]),
|
|
1907
|
+
currency: ((E = Q.cost) == null ? void 0 : E.currency) || Ce(((ee = m.currentCountry) == null ? void 0 : ee.value) ?? rt)
|
|
1908
|
+
};
|
|
1909
|
+
} else {
|
|
1910
|
+
const Q = i.effectiveAt ?? Te(i._id), W = g(
|
|
1911
|
+
i._id,
|
|
1912
|
+
Q ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
1913
|
+
);
|
|
1914
|
+
if (!W) return "No data";
|
|
1915
|
+
const te = oe.fromDinero(W);
|
|
1916
|
+
return {
|
|
1917
|
+
...oe.multiply([te, y]),
|
|
1918
|
+
currency: W.currency || Ce(((ae = m.currentCountry) == null ? void 0 : ae.value) ?? rt)
|
|
1919
|
+
};
|
|
1920
|
+
}
|
|
1921
|
+
}), G = T(() => {
|
|
1922
|
+
var y;
|
|
1923
|
+
const i = [...o.value].reverse().computeFirst((f) => {
|
|
1924
|
+
var F, E;
|
|
1925
|
+
const d = (E = (F = f.skus) == null ? void 0 : F.find) == null ? void 0 : E.call(F, (ee) => ee.sku._id === b.sku._id);
|
|
1926
|
+
return d == null ? void 0 : d.toCostBalances;
|
|
1927
|
+
});
|
|
1928
|
+
return i ? {
|
|
1929
|
+
...i.reduce((f, d) => oe.add([f, oe.fromDinero(d.cost)]), {
|
|
1930
|
+
amount: 0,
|
|
1931
|
+
precision: 0
|
|
1932
|
+
}),
|
|
1933
|
+
currency: Ce((y = m.currentCountry) == null ? void 0 : y.value)
|
|
1934
|
+
} : "No data";
|
|
1935
|
+
}), H = T(() => b.sku.valuation === it.Enum.FIFO ? G.value : A.value);
|
|
1936
|
+
function J() {
|
|
1937
|
+
const { startDate: i, endDate: h } = no(c.value);
|
|
1938
|
+
i !== null && h !== null && (c.value = {
|
|
1939
|
+
startDate: i,
|
|
1940
|
+
endDate: h
|
|
1941
|
+
});
|
|
1942
|
+
}
|
|
1943
|
+
const I = Ye(b, "show");
|
|
1944
|
+
return (i, h) => {
|
|
1945
|
+
const y = B("FmButton"), f = B("FmField"), d = B("FmDateRangePicker"), F = B("FmSpacer"), E = B("FmCircularProgress"), ee = B("FmIcon"), ae = B("FmTooltip"), Q = B("FmMenuDivider"), W = B("FmChip"), te = B("FmSelect"), re = B("FmCardSection"), ce = B("FmCard"), je = B("FmSideSheet");
|
|
1946
|
+
return V(), ne(je, {
|
|
1947
|
+
"dismiss-away": "",
|
|
1948
|
+
modelValue: s(I),
|
|
1949
|
+
"onUpdate:modelValue": h[5] || (h[5] = (me) => Ee(I) ? I.value = me : null),
|
|
1950
|
+
"close-button": !1,
|
|
1951
|
+
"max-width": 560
|
|
1952
|
+
}, {
|
|
1953
|
+
"side-sheet-header": M(() => [
|
|
1954
|
+
e("div", Hn, [
|
|
1955
|
+
e("div", Tn, v(s(l)("inventory.stock.history.title", [i.sku.name])), 1),
|
|
1956
|
+
_(y, {
|
|
1957
|
+
variant: "tertiary",
|
|
1958
|
+
"prepend-icon": "close",
|
|
1959
|
+
onClick: h[0] || (h[0] = (me) => I.value = !1)
|
|
1960
|
+
})
|
|
1961
|
+
])
|
|
1962
|
+
]),
|
|
1963
|
+
default: M(() => {
|
|
1964
|
+
var me;
|
|
1965
|
+
return [
|
|
1966
|
+
e("div", Pn, [
|
|
1967
|
+
e("div", Un, [
|
|
1968
|
+
e("div", En, [
|
|
1969
|
+
_(d, {
|
|
1970
|
+
modelValue: c.value,
|
|
1971
|
+
"onUpdate:modelValue": h[1] || (h[1] = (de) => c.value = de),
|
|
1972
|
+
"show-predefined-range": "",
|
|
1973
|
+
"start-label": "",
|
|
1974
|
+
"end-label": "",
|
|
1975
|
+
"z-index": 50
|
|
1976
|
+
}, {
|
|
1977
|
+
"trigger-button": M(({ opened: de }) => [
|
|
1978
|
+
_(f, {
|
|
1979
|
+
"prepend-icon": "calendar_month",
|
|
1980
|
+
focused: de
|
|
1981
|
+
}, {
|
|
1982
|
+
default: M(() => [
|
|
1983
|
+
ye(v(c.value.startDate) + " - " + v(c.value.endDate), 1)
|
|
1984
|
+
]),
|
|
1985
|
+
_: 2
|
|
1986
|
+
}, 1032, ["focused"])
|
|
1987
|
+
]),
|
|
1988
|
+
_: 1
|
|
1989
|
+
}, 8, ["modelValue"])
|
|
1990
|
+
]),
|
|
1991
|
+
_(y, {
|
|
1992
|
+
variant: "tertiary",
|
|
1993
|
+
onClick: h[2] || (h[2] = (de) => Z()),
|
|
1994
|
+
"prepend-icon": "navigate_before"
|
|
1995
|
+
}),
|
|
1996
|
+
_(y, {
|
|
1997
|
+
variant: "tertiary",
|
|
1998
|
+
onClick: h[3] || (h[3] = (de) => J()),
|
|
1999
|
+
"prepend-icon": "navigate_next"
|
|
2000
|
+
})
|
|
2001
|
+
]),
|
|
2002
|
+
R.value ? (V(), q("div", Rn, [
|
|
2003
|
+
_(F),
|
|
2004
|
+
_(E, { size: "xl" }),
|
|
2005
|
+
e("div", Nn, v(s(l)("inventory.stock.history.loading")), 1),
|
|
2006
|
+
_(F),
|
|
2007
|
+
_(F)
|
|
2008
|
+
])) : t.value && ((me = t.value) == null ? void 0 : me.length) > 0 ? (V(), q("div", On, [
|
|
2009
|
+
_(ce, { variant: "outlined" }, {
|
|
2010
|
+
default: M(() => [
|
|
2011
|
+
_(re, { class: "flex flex-col gap-4" }, {
|
|
2012
|
+
default: M(() => [
|
|
2013
|
+
e("div", Ln, [
|
|
2014
|
+
e("div", Yn, v(s(l)("inventory.stock.history.summary.title")), 1)
|
|
2015
|
+
]),
|
|
2016
|
+
e("div", zn, [
|
|
2017
|
+
e("div", Gn, [
|
|
2018
|
+
e("div", Wn, v(s(l)("inventory.stock.history.summary.totalPurchase")), 1),
|
|
2019
|
+
e("div", Kn, v(L.value.PURCHASE), 1)
|
|
2020
|
+
]),
|
|
2021
|
+
e("div", qn, [
|
|
2022
|
+
e("div", Xn, [
|
|
2023
|
+
ye(v(s(l)("inventory.stock.history.summary.totalSales")) + " ", 1),
|
|
2024
|
+
X.value != null ? (V(), ne(ae, {
|
|
2025
|
+
key: 0,
|
|
2026
|
+
variant: "plain",
|
|
2027
|
+
placement: "top",
|
|
2028
|
+
content: `Before: ${X.value}`,
|
|
2029
|
+
"z-index": 50
|
|
2030
|
+
}, {
|
|
2031
|
+
default: M(() => [
|
|
2032
|
+
_(ee, {
|
|
2033
|
+
name: "warning",
|
|
2034
|
+
size: "sm"
|
|
2035
|
+
})
|
|
2036
|
+
]),
|
|
2037
|
+
_: 1
|
|
2038
|
+
}, 8, ["content"])) : se("", !0)
|
|
2039
|
+
]),
|
|
2040
|
+
e("div", Jn, v(L.value.SALES), 1)
|
|
2041
|
+
]),
|
|
2042
|
+
e("div", Qn, [
|
|
2043
|
+
e("div", Zn, v(s(l)("inventory.stock.history.summary.totalLose")), 1),
|
|
2044
|
+
e("div", es, v(L.value.LOSE), 1)
|
|
2045
|
+
]),
|
|
2046
|
+
e("div", ts, [
|
|
2047
|
+
e("div", os, v(s(l)("inventory.stock.history.summary.totalRequest")), 1),
|
|
2048
|
+
e("div", ns, v(L.value.REQUEST), 1)
|
|
2049
|
+
]),
|
|
2050
|
+
e("div", ss, [
|
|
2051
|
+
e("div", as, v(s(l)("inventory.stock.history.summary.totalReceive")), 1),
|
|
2052
|
+
e("div", ls, v(L.value.RECEIVE), 1)
|
|
2053
|
+
]),
|
|
2054
|
+
e("div", rs, [
|
|
2055
|
+
e("div", is, v(s(l)("inventory.stock.history.summary.totalConvert")), 1),
|
|
2056
|
+
e("div", us, v(L.value.CONVERT), 1)
|
|
2057
|
+
]),
|
|
2058
|
+
e("div", cs, [
|
|
2059
|
+
e("div", ds, v(s(l)("inventory.stock.history.summary.totalDamage")), 1),
|
|
2060
|
+
e("div", ms, v(L.value.DAMAGE), 1)
|
|
2061
|
+
]),
|
|
2062
|
+
e("div", fs, [
|
|
2063
|
+
e("div", vs, v(s(l)("inventory.stock.history.summary.openingBalance")), 1),
|
|
2064
|
+
e("div", ps, v(z.value), 1)
|
|
2065
|
+
]),
|
|
2066
|
+
e("div", ys, [
|
|
2067
|
+
e("div", _s, v(s(l)("inventory.stock.history.summary.lastStockBalance")), 1),
|
|
2068
|
+
e("div", ks, v(K.value), 1)
|
|
2069
|
+
])
|
|
2070
|
+
]),
|
|
2071
|
+
s(u).enableTotalCost ? (V(), q("div", hs, [
|
|
2072
|
+
_(Q, { class: "w-full" }),
|
|
2073
|
+
e("div", bs, [
|
|
2074
|
+
e("div", gs, [
|
|
2075
|
+
_(ut, { "z-index": 50 }, {
|
|
2076
|
+
default: M(() => [
|
|
2077
|
+
e("div", xs, [
|
|
2078
|
+
ye(v(s(l)("inventory.stock.history.estimatedValue")) + " ", 1),
|
|
2079
|
+
_(ae, {
|
|
2080
|
+
variant: "plain",
|
|
2081
|
+
placement: "top",
|
|
2082
|
+
content: `[${le.value}] ${s(l)("inventory.stock.history.estimatedValueTooltip")}`,
|
|
2083
|
+
"z-index": 50
|
|
2084
|
+
}, {
|
|
2085
|
+
default: M(() => [
|
|
2086
|
+
_(ee, {
|
|
2087
|
+
name: "help",
|
|
2088
|
+
size: "sm"
|
|
2089
|
+
})
|
|
2090
|
+
]),
|
|
2091
|
+
_: 1
|
|
2092
|
+
}, 8, ["content"])
|
|
2093
|
+
])
|
|
2094
|
+
]),
|
|
2095
|
+
_: 1
|
|
2096
|
+
}),
|
|
2097
|
+
e("div", Ss, [
|
|
2098
|
+
i.sku.valuation === s(it).Enum.FIFO ? (V(), q(ue, { key: 0 }, [
|
|
2099
|
+
_(W, {
|
|
2100
|
+
label: "FIFO",
|
|
2101
|
+
compact: ""
|
|
2102
|
+
}),
|
|
2103
|
+
ye(" " + v(typeof H.value != "string" ? s(Me)(
|
|
2104
|
+
H.value,
|
|
2105
|
+
!1,
|
|
2106
|
+
H.value.precision
|
|
2107
|
+
) : H.value), 1)
|
|
2108
|
+
], 64)) : (V(), q(ue, { key: 1 }, [
|
|
2109
|
+
ye(v(typeof H.value != "string" ? s(Me)(
|
|
2110
|
+
H.value,
|
|
2111
|
+
!1,
|
|
2112
|
+
H.value.precision
|
|
2113
|
+
) : H.value), 1)
|
|
2114
|
+
], 64))
|
|
2115
|
+
]),
|
|
2116
|
+
_(te, {
|
|
2117
|
+
modelValue: r.value,
|
|
2118
|
+
"onUpdate:modelValue": h[4] || (h[4] = (de) => r.value = de),
|
|
2119
|
+
items: a.value,
|
|
2120
|
+
compact: "",
|
|
2121
|
+
size: "sm",
|
|
2122
|
+
style: { width: "200px" }
|
|
2123
|
+
}, null, 8, ["modelValue", "items"])
|
|
2124
|
+
]),
|
|
2125
|
+
e("div", ws, [
|
|
2126
|
+
_(ut, { "z-index": 50 }, {
|
|
2127
|
+
default: M(() => [
|
|
2128
|
+
e("div", As, [
|
|
2129
|
+
ye(v(s(l)("inventory.stock.history.costSold")) + " ", 1),
|
|
2130
|
+
_(ae, {
|
|
2131
|
+
variant: "plain",
|
|
2132
|
+
placement: "top",
|
|
2133
|
+
"z-index": 50
|
|
2134
|
+
}, {
|
|
2135
|
+
content: M(() => [
|
|
2136
|
+
e("div", Fs, v(s(l)("inventory.stock.history.costSoldTooltip")), 1)
|
|
2137
|
+
]),
|
|
2138
|
+
default: M(() => [
|
|
2139
|
+
_(ee, {
|
|
2140
|
+
name: "help",
|
|
2141
|
+
size: "sm"
|
|
2142
|
+
})
|
|
2143
|
+
]),
|
|
2144
|
+
_: 1
|
|
2145
|
+
})
|
|
2146
|
+
])
|
|
2147
|
+
]),
|
|
2148
|
+
_: 1
|
|
2149
|
+
}),
|
|
2150
|
+
e("div", $s, v(U.value), 1)
|
|
2151
|
+
])
|
|
2152
|
+
])
|
|
2153
|
+
])) : se("", !0)
|
|
2154
|
+
]),
|
|
2155
|
+
_: 1
|
|
2156
|
+
})
|
|
2157
|
+
]),
|
|
2158
|
+
_: 1
|
|
2159
|
+
}),
|
|
2160
|
+
h[6] || (h[6] = e("div", null, null, -1)),
|
|
2161
|
+
(V(!0), q(ue, null, fe(t.value, (de) => (V(), q(ue, {
|
|
2162
|
+
key: de.date
|
|
2163
|
+
}, [
|
|
2164
|
+
i.sku ? (V(), ne(Bn, {
|
|
2165
|
+
key: 0,
|
|
2166
|
+
record: de,
|
|
2167
|
+
sku: i.sku,
|
|
2168
|
+
bills: n.value,
|
|
2169
|
+
"unit-cost-history": D.value,
|
|
2170
|
+
"cost-mechanism": r.value,
|
|
2171
|
+
onRefreshHistory: S
|
|
2172
|
+
}, null, 8, ["record", "sku", "bills", "unit-cost-history", "cost-mechanism"])) : se("", !0)
|
|
2173
|
+
], 64))), 128))
|
|
2174
|
+
])) : (V(), q("div", js, [
|
|
2175
|
+
_(F),
|
|
2176
|
+
e("div", null, [
|
|
2177
|
+
e("img", {
|
|
2178
|
+
src: s(ro),
|
|
2179
|
+
alt: "List is empty"
|
|
2180
|
+
}, null, 8, Vs)
|
|
2181
|
+
]),
|
|
2182
|
+
e("div", Cs, v(s(l)("inventory.stock.history.noRecords")), 1),
|
|
2183
|
+
e("div", Ds, v(s(l)("inventory.stock.history.changeDateRange")), 1),
|
|
2184
|
+
_(F),
|
|
2185
|
+
_(F)
|
|
2186
|
+
]))
|
|
2187
|
+
])
|
|
2188
|
+
];
|
|
2189
|
+
}),
|
|
2190
|
+
_: 1
|
|
2191
|
+
}, 8, ["modelValue"]);
|
|
2192
|
+
};
|
|
2193
|
+
}
|
|
2194
|
+
}), Ms = /* @__PURE__ */ ve({
|
|
2195
|
+
__name: "HrmPermissionGuard",
|
|
2196
|
+
props: {
|
|
2197
|
+
permission: { default: void 0 },
|
|
2198
|
+
permissions: { default: void 0 },
|
|
2199
|
+
mode: { default: "all" }
|
|
2200
|
+
},
|
|
2201
|
+
setup(w) {
|
|
2202
|
+
const m = w, k = T(() => {
|
|
2203
|
+
const x = [];
|
|
2204
|
+
return m.permission && x.push(m.permission), m.permissions && x.push(...m.permissions), x;
|
|
2205
|
+
});
|
|
2206
|
+
Vt(() => {
|
|
2207
|
+
});
|
|
2208
|
+
const { hasPermission: p } = At(k, () => m.mode);
|
|
2209
|
+
return (x, j) => s(p) ? st(x.$slots, "default", { key: 0 }) : st(x.$slots, "fallback", { key: 1 });
|
|
2210
|
+
}
|
|
2211
|
+
});
|
|
2212
|
+
function Is(w) {
|
|
2213
|
+
const m = Ut(), k = Se(), p = Y(!1), x = Y(null), j = Y(null);
|
|
2214
|
+
let u = null, l = !1, b = !1;
|
|
2215
|
+
function R() {
|
|
2216
|
+
if (b) return;
|
|
2217
|
+
const a = k.currentLocationDBName;
|
|
2218
|
+
if (!a) return;
|
|
2219
|
+
b = !0;
|
|
2220
|
+
const D = {
|
|
2221
|
+
type: "refresh-balance",
|
|
2222
|
+
params: { locationId: a }
|
|
2223
|
+
}, { unsubscribe: c, initialState: S } = m.subscribe(
|
|
2224
|
+
D,
|
|
2225
|
+
C
|
|
2226
|
+
);
|
|
2227
|
+
u = c, S.then((o) => {
|
|
2228
|
+
o != null && o.initialState && C(o.initialState);
|
|
2229
|
+
}).catch((o) => {
|
|
2230
|
+
console.error("Failed to fetch refresh-balance initial state", o);
|
|
2231
|
+
});
|
|
2232
|
+
}
|
|
2233
|
+
async function C(a) {
|
|
2234
|
+
var D;
|
|
2235
|
+
if (!(!b || !a)) {
|
|
2236
|
+
if (x.value = a, a.completedAt && (j.value = a.completedAt), a.message === "processing" || !a.completedAt && !a.message) {
|
|
2237
|
+
l = !0, p.value = !0;
|
|
2238
|
+
return;
|
|
2239
|
+
}
|
|
2240
|
+
if (a.message === "completed" || a.completedAt) {
|
|
2241
|
+
if (!l) return;
|
|
2242
|
+
r();
|
|
2243
|
+
try {
|
|
2244
|
+
await w.onCompleted();
|
|
2245
|
+
} catch (c) {
|
|
2246
|
+
console.error("Failed to reload after refresh", c);
|
|
2247
|
+
}
|
|
2248
|
+
return;
|
|
2249
|
+
}
|
|
2250
|
+
if (a.message === "error") {
|
|
2251
|
+
const c = a.error ?? "Failed to refresh stock balance.";
|
|
2252
|
+
r(), await ((D = w.onError) == null ? void 0 : D.call(w, c));
|
|
2253
|
+
}
|
|
2254
|
+
}
|
|
2255
|
+
}
|
|
2256
|
+
function r() {
|
|
2257
|
+
u && (u(), u = null), b = !1, l = !1, p.value = !1, x.value = null;
|
|
2258
|
+
}
|
|
2259
|
+
return Ct(() => {
|
|
2260
|
+
r();
|
|
2261
|
+
}), {
|
|
2262
|
+
refreshing: p,
|
|
2263
|
+
refreshStatus: x,
|
|
2264
|
+
lastCompletedAt: j,
|
|
2265
|
+
startListening: R,
|
|
2266
|
+
stopListening: r
|
|
2267
|
+
};
|
|
2268
|
+
}
|
|
2269
|
+
const Hs = {
|
|
2270
|
+
key: 0,
|
|
2271
|
+
class: "flex items-center gap-1"
|
|
2272
|
+
}, Ts = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ps = { class: "flex flex-col gap-8" }, Us = { class: "flex flex-col" }, Es = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Rs = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary line-clamp-1" }, _a = /* @__PURE__ */ ve({
|
|
2273
|
+
__name: "StockView",
|
|
2274
|
+
setup(w) {
|
|
2275
|
+
const { t: m } = pe(), k = Ne(), p = Se(), x = Oe(), j = Ft(), u = Ae(), l = gt(), b = co(), { columnDefs: R } = ko(), C = Xe(), { hasPermission: r } = At(
|
|
2276
|
+
T(() => [{ action: De.Action.manage, subject: De.Subject.Business.inventory_stockAdjustment }])
|
|
2277
|
+
), a = T(
|
|
2278
|
+
() => {
|
|
2279
|
+
var y;
|
|
2280
|
+
return r.value || ((y = C.sessionUser.value) == null ? void 0 : y.role.isAdmin);
|
|
2281
|
+
}
|
|
2282
|
+
), D = Le(), c = we();
|
|
2283
|
+
p.watchLocation(X);
|
|
2284
|
+
const S = T(
|
|
2285
|
+
() => new Set(b.getAvailableItems(b.businessSubsidiaryId))
|
|
2286
|
+
), o = Y(!1), t = Y(!1), { refreshing: n, lastCompletedAt: $, startListening: P, stopListening: N } = Is({
|
|
2287
|
+
onCompleted: async () => {
|
|
2288
|
+
await X(), t.value = !1, c.open({
|
|
2289
|
+
title: "Balance refreshed",
|
|
2290
|
+
message: "Stock balance has been recalculated.",
|
|
2291
|
+
type: "success"
|
|
2292
|
+
});
|
|
2293
|
+
},
|
|
2294
|
+
onError: (y) => {
|
|
2295
|
+
t.value = !1, c.open({
|
|
2296
|
+
title: "Refresh failed",
|
|
2297
|
+
message: y,
|
|
2298
|
+
type: "error"
|
|
2299
|
+
});
|
|
2300
|
+
}
|
|
2301
|
+
}), O = T(() => n.value || t.value);
|
|
2302
|
+
async function L() {
|
|
2303
|
+
P();
|
|
2304
|
+
const y = m("inventory.stock.stock_balance.refreshBalanceDescription"), f = $.value ? `${y}
|
|
2305
|
+
|
|
2306
|
+
Last refreshed: ${new Date($.value).toLocaleString()}` : y;
|
|
2307
|
+
D.open({
|
|
2308
|
+
title: m("inventory.stock.stock_balance.refreshBalance"),
|
|
2309
|
+
message: f,
|
|
2310
|
+
closeButton: !0,
|
|
2311
|
+
primaryActions: {
|
|
2312
|
+
text: m("common.confirm"),
|
|
2313
|
+
close: !1,
|
|
2314
|
+
isLoading: O,
|
|
2315
|
+
disabled: O
|
|
2316
|
+
},
|
|
2317
|
+
secondaryActions: {
|
|
2318
|
+
text: m("common.close"),
|
|
2319
|
+
close: !0,
|
|
2320
|
+
variant: "tertiary",
|
|
2321
|
+
disabled: O
|
|
2322
|
+
}
|
|
2323
|
+
}).onPrimary(async () => {
|
|
2324
|
+
if (!t.value) {
|
|
2325
|
+
t.value = !0;
|
|
2326
|
+
try {
|
|
2327
|
+
await u.recalculation.refreshCurrentBalances();
|
|
2328
|
+
} catch (d) {
|
|
2329
|
+
console.error("Failed to queue refresh balance", d), t.value = !1, c.open({
|
|
2330
|
+
title: "Refresh failed",
|
|
2331
|
+
message: "Failed to queue stock balance refresh. Please try again.",
|
|
2332
|
+
type: "error"
|
|
2333
|
+
});
|
|
2334
|
+
}
|
|
2335
|
+
}
|
|
2336
|
+
}).onClose(() => {
|
|
2337
|
+
t.value = !1, N();
|
|
2338
|
+
});
|
|
2339
|
+
}
|
|
2340
|
+
async function X() {
|
|
2341
|
+
if (p._currentLocation) {
|
|
2342
|
+
o.value = !0;
|
|
2343
|
+
try {
|
|
2344
|
+
await x.readStockBalance(), await x.readProductBalance(), await l.readStockEstimateBalance();
|
|
2345
|
+
} catch (y) {
|
|
2346
|
+
c.open({
|
|
2347
|
+
title: m("inventory.stock.error.title"),
|
|
2348
|
+
message: m("inventory.stock.error.message"),
|
|
2349
|
+
type: "error"
|
|
2350
|
+
}), console.error("error on fetch stock balance", y);
|
|
2351
|
+
} finally {
|
|
2352
|
+
o.value = !1;
|
|
2353
|
+
}
|
|
2354
|
+
}
|
|
2355
|
+
}
|
|
2356
|
+
const z = T(() => [
|
|
2357
|
+
{
|
|
2358
|
+
type: "string",
|
|
2359
|
+
key: "status",
|
|
2360
|
+
entity: "sku",
|
|
2361
|
+
values: ["Active", "Inactive"]
|
|
2362
|
+
}
|
|
2363
|
+
]), K = Y({
|
|
2364
|
+
logic: "AND",
|
|
2365
|
+
rules: [
|
|
2366
|
+
{
|
|
2367
|
+
property: "status",
|
|
2368
|
+
operator: "$in",
|
|
2369
|
+
value: ["Active"],
|
|
2370
|
+
type: "string"
|
|
2371
|
+
}
|
|
2372
|
+
]
|
|
2373
|
+
}), U = T(() => {
|
|
2374
|
+
var d, F, E;
|
|
2375
|
+
const y = K.value ? mo.build(K.value) : null, f = [];
|
|
2376
|
+
for (const ee of k.skus) {
|
|
2377
|
+
let ae = !0;
|
|
2378
|
+
if (b.isEnabled && le.value && S.value && ae && (ae = S.value.has(ee._id)), y && ae && (ae = fo(
|
|
2379
|
+
{
|
|
2380
|
+
status: ee.isInactive ? "Inactive" : "Active"
|
|
2381
|
+
},
|
|
2382
|
+
y
|
|
2383
|
+
)), ae) {
|
|
2384
|
+
const Q = ee.trackingMeasurement;
|
|
2385
|
+
let W = (F = (d = x.stockBalance.skus) == null ? void 0 : d.find(
|
|
2386
|
+
(ce) => ce.id === ee._id
|
|
2387
|
+
)) == null ? void 0 : F.balance, te = l.inventoryForecast.skus.find(
|
|
2388
|
+
(ce) => ce.id === ee._id
|
|
2389
|
+
);
|
|
2390
|
+
const re = {
|
|
2391
|
+
...ee,
|
|
2392
|
+
balance: W ?? {
|
|
2393
|
+
amount: 0,
|
|
2394
|
+
precision: 0
|
|
2395
|
+
},
|
|
2396
|
+
operator: te == null ? void 0 : te.operator,
|
|
2397
|
+
day: (te == null ? void 0 : te.depletionDays) ?? void 0,
|
|
2398
|
+
trackingUnitAbbrev: Q ? ((E = ee.unit.measurements.find((ce) => ce.id === Q)) == null ? void 0 : E.abbrev) ?? "" : ee.unit.abbrev
|
|
2399
|
+
};
|
|
2400
|
+
f.push(re);
|
|
2401
|
+
}
|
|
2402
|
+
}
|
|
2403
|
+
return f;
|
|
2404
|
+
}), Z = Y(""), le = Y(!0), { breakpoints: g } = Lt(), A = T(() => g.value.xs || g.value.sm), G = T(() => A.value ? 10 : 20), H = Bt(), J = T(() => {
|
|
2405
|
+
const y = [
|
|
2406
|
+
{
|
|
2407
|
+
label: m("inventory.stock.stock_balance.refreshBalance"),
|
|
2408
|
+
value: "refresh-balance",
|
|
2409
|
+
isPrimary: !0,
|
|
2410
|
+
prependIcon: "calculate"
|
|
2411
|
+
},
|
|
2412
|
+
{
|
|
2413
|
+
label: m("inventory.common.refresh"),
|
|
2414
|
+
value: "refresh"
|
|
2415
|
+
},
|
|
2416
|
+
{
|
|
2417
|
+
label: m("inventory.common.export"),
|
|
2418
|
+
value: "export"
|
|
2419
|
+
}
|
|
2420
|
+
];
|
|
2421
|
+
return a.value && y.push({
|
|
2422
|
+
label: m("inventory.stock.stock_adjustment.title"),
|
|
2423
|
+
value: "stockAdjustment"
|
|
2424
|
+
}), y;
|
|
2425
|
+
}), I = Y(!1);
|
|
2426
|
+
function i() {
|
|
2427
|
+
I.value = !0;
|
|
2428
|
+
}
|
|
2429
|
+
function h(y) {
|
|
2430
|
+
switch (y) {
|
|
2431
|
+
case "refresh-balance":
|
|
2432
|
+
return L();
|
|
2433
|
+
case "refresh":
|
|
2434
|
+
return X();
|
|
2435
|
+
case "export":
|
|
2436
|
+
return Rt(U.value);
|
|
2437
|
+
case "stockAdjustment":
|
|
2438
|
+
return i();
|
|
2439
|
+
}
|
|
2440
|
+
}
|
|
2441
|
+
return (y, f) => {
|
|
2442
|
+
const d = B("FmSwitch"), F = B("FmTable");
|
|
2443
|
+
return V(), ne(Mt, {
|
|
2444
|
+
title: s(m)("inventory.stock.title"),
|
|
2445
|
+
actions: J.value,
|
|
2446
|
+
"onClick:action": h
|
|
2447
|
+
}, {
|
|
2448
|
+
default: M(() => {
|
|
2449
|
+
var E, ee, ae, Q;
|
|
2450
|
+
return [
|
|
2451
|
+
e("div", {
|
|
2452
|
+
class: He([
|
|
2453
|
+
"flex flex-col gap-8 max-h-full",
|
|
2454
|
+
{
|
|
2455
|
+
"p-0": A.value,
|
|
2456
|
+
"px-24 ": !A.value
|
|
2457
|
+
}
|
|
2458
|
+
])
|
|
2459
|
+
}, [
|
|
2460
|
+
_(lo, {
|
|
2461
|
+
searchable: "",
|
|
2462
|
+
"change-location": "",
|
|
2463
|
+
search: Z.value,
|
|
2464
|
+
"onUpdate:search": f[1] || (f[1] = (W) => Z.value = W),
|
|
2465
|
+
"hide-filter-options": !0,
|
|
2466
|
+
filterable: "",
|
|
2467
|
+
"filter-attributes": z.value,
|
|
2468
|
+
filter: K.value,
|
|
2469
|
+
"onUpdate:filter": f[2] || (f[2] = (W) => K.value = W)
|
|
2470
|
+
}, {
|
|
2471
|
+
default: M(() => [
|
|
2472
|
+
s(b).isEnabled ? (V(), q("div", Hs, [
|
|
2473
|
+
e("span", Ts, v(s(m)("inventory.integration.netsuite.subsidiaryHierarchy.filtering")), 1),
|
|
2474
|
+
_(Nt),
|
|
2475
|
+
_(Je, null, {
|
|
2476
|
+
default: M(() => [
|
|
2477
|
+
_(d, {
|
|
2478
|
+
modelValue: le.value,
|
|
2479
|
+
"onUpdate:modelValue": f[0] || (f[0] = (W) => le.value = W)
|
|
2480
|
+
}, null, 8, ["modelValue"])
|
|
2481
|
+
]),
|
|
2482
|
+
_: 1
|
|
2483
|
+
})
|
|
2484
|
+
])) : se("", !0)
|
|
2485
|
+
]),
|
|
2486
|
+
_: 1
|
|
2487
|
+
}, 8, ["search", "filter-attributes", "filter"]),
|
|
2488
|
+
(V(), ne(F, {
|
|
2489
|
+
style: kt(s(H).tableHeight),
|
|
2490
|
+
"column-defs": s(R),
|
|
2491
|
+
"row-data": U.value,
|
|
2492
|
+
"search-value": Z.value,
|
|
2493
|
+
loading: o.value || s(n) || !s(p)._currentLocation,
|
|
2494
|
+
key: (E = s(p)._currentLocation) == null ? void 0 : E.dbName,
|
|
2495
|
+
onRowClick: f[3] || (f[3] = (W) => s(j).showSkuHistory(W.original)),
|
|
2496
|
+
"page-size": G.value
|
|
2497
|
+
}, {
|
|
2498
|
+
"list-row": M((W) => [
|
|
2499
|
+
_(uo, {
|
|
2500
|
+
row: W,
|
|
2501
|
+
onRowClick: s(j).showSkuHistory
|
|
2502
|
+
}, {
|
|
2503
|
+
default: M((te) => {
|
|
2504
|
+
var re, ce, je, me, de, Ze, et, tt, Ve, ot;
|
|
2505
|
+
return [
|
|
2506
|
+
e("div", Ps, [
|
|
2507
|
+
e("div", Us, [
|
|
2508
|
+
e("div", Es, [
|
|
2509
|
+
_(s(ft), {
|
|
2510
|
+
render: (je = (ce = (re = te.code) == null ? void 0 : re.column) == null ? void 0 : ce.columnDef) == null ? void 0 : je.cell,
|
|
2511
|
+
props: (de = (me = te.code) == null ? void 0 : me.getContext) == null ? void 0 : de.call(me)
|
|
2512
|
+
}, null, 8, ["render", "props"])
|
|
2513
|
+
]),
|
|
2514
|
+
e("div", Rs, [
|
|
2515
|
+
_(s(ft), {
|
|
2516
|
+
render: (tt = (et = (Ze = te.name) == null ? void 0 : Ze.column) == null ? void 0 : et.columnDef) == null ? void 0 : tt.cell,
|
|
2517
|
+
props: (ot = (Ve = te.name) == null ? void 0 : Ve.getContext) == null ? void 0 : ot.call(Ve)
|
|
2518
|
+
}, null, 8, ["render", "props"])
|
|
2519
|
+
])
|
|
2520
|
+
]),
|
|
2521
|
+
e("div", null, [
|
|
2522
|
+
_(Ke, {
|
|
2523
|
+
days: W.original.day
|
|
2524
|
+
}, null, 8, ["days"])
|
|
2525
|
+
]),
|
|
2526
|
+
e("div", null, [
|
|
2527
|
+
_(ht, {
|
|
2528
|
+
class: "xs:w-[160px]",
|
|
2529
|
+
unit: W.original.unit,
|
|
2530
|
+
sku: W.original,
|
|
2531
|
+
amount: W.original.balance,
|
|
2532
|
+
"default-tracking-measurement": W.original.trackingMeasurement ?? void 0
|
|
2533
|
+
}, null, 8, ["unit", "sku", "amount", "default-tracking-measurement"])
|
|
2534
|
+
])
|
|
2535
|
+
])
|
|
2536
|
+
];
|
|
2537
|
+
}),
|
|
2538
|
+
_: 2
|
|
2539
|
+
}, 1032, ["row", "onRowClick"])
|
|
2540
|
+
]),
|
|
2541
|
+
_: 1
|
|
2542
|
+
}, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
|
|
2543
|
+
], 2),
|
|
2544
|
+
(V(), ne(Dt, { to: "body" }, [
|
|
2545
|
+
(ee = s(j).stockHistoryProps) != null && ee.sku ? (V(), ne(Bs, at(ze({ key: 0 }, s(j).stockHistoryProps)), null, 16)) : se("", !0),
|
|
2546
|
+
(ae = s(j).convertSkuDialogProps) != null && ae.sku ? (V(), ne(Mo, at(ze({ key: 1 }, s(j).convertSkuDialogProps)), null, 16)) : se("", !0),
|
|
2547
|
+
(Q = s(j).adjustSkuDialogProps) != null && Q.stock ? (V(), ne(Go, ze({ key: 2 }, s(j).adjustSkuDialogProps, {
|
|
2548
|
+
onSubmitted: f[4] || (f[4] = (W) => X())
|
|
2549
|
+
}), null, 16)) : se("", !0),
|
|
2550
|
+
_(Ms, {
|
|
2551
|
+
permission: { action: s(De).Action.manage, subject: s(De).Subject.Business.inventory_stockAdjustment }
|
|
2552
|
+
}, {
|
|
2553
|
+
default: M(() => [
|
|
2554
|
+
I.value ? (V(), ne(sn, {
|
|
2555
|
+
key: 0,
|
|
2556
|
+
show: I.value,
|
|
2557
|
+
"onUpdate:show": f[5] || (f[5] = (W) => I.value = W),
|
|
2558
|
+
onSubmitted: f[6] || (f[6] = (W) => X())
|
|
2559
|
+
}, null, 8, ["show"])) : se("", !0)
|
|
2560
|
+
]),
|
|
2561
|
+
_: 1
|
|
2562
|
+
}, 8, ["permission"])
|
|
2563
|
+
]))
|
|
2564
|
+
];
|
|
2565
|
+
}),
|
|
2566
|
+
_: 1
|
|
2567
|
+
}, 8, ["title", "actions"]);
|
|
2568
|
+
};
|
|
2569
|
+
}
|
|
2570
|
+
});
|
|
2571
|
+
export {
|
|
2572
|
+
_a as default
|
|
2573
|
+
};
|