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