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