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