@feedmepos/mf-inventory-portal 0.0.19-dev.1 → 0.0.19-dev.2
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/{ApprovalView-BTZwnKLf.js → ApprovalView-DU7oB2Zk.js} +42 -39
- package/dist/{BindingsDialog-DpC48bqK.js → BindingsDialog-BgfV0G46.js} +2 -2
- package/dist/{BindingsPicker-BU52g6zk.js → BindingsPicker-tUI5WYBk.js} +2 -2
- package/dist/{BindingsTable-aIuFdScv.js → BindingsTable-8G-Nc4pC.js} +18 -17
- package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DaHXKF1s.js +273 -0
- package/dist/{FmMultiselectDialog.vue_vue_type_script_setup_true_lang-n09XXJZK.js → FmMultiselectDialog.vue_vue_type_script_setup_true_lang-CxOk5ule.js} +2 -2
- package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-B-19iYaK.js → FmUnitInput.vue_vue_type_script_setup_true_lang-D-vJDMKb.js} +3 -3
- package/dist/IngredientsView-CAh7D4tL.js +1760 -0
- package/dist/{IntegrationView-Dn_qL_vC.js → IntegrationView-Bf7yHuS8.js} +3 -3
- package/dist/InventoryBindingForm.vue_vue_type_script_setup_true_lang-BdVrpR9J.js +277 -0
- package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BuyM580N.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BKlWhMnB.js} +1 -1
- package/dist/{PurchaseOrderPrintPreview-EeKhENYH.js → PurchaseOrderPrintPreview-YFcOtdfJ.js} +1 -1
- package/dist/ReceiveRequestView-bIXyVVX9.js +1401 -0
- package/dist/RecipeView-BD0mvxCg.js +575 -0
- package/dist/StockForecast.vue_vue_type_style_index_0_lang-KLXSWvo5.js +59 -0
- package/dist/StockView-BCq37bGl.js +1865 -0
- package/dist/SupplierView-BiSqTXnz.js +804 -0
- package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-CvbKNb0C.js +1033 -0
- package/dist/UnitView-DSdn__9m.js +643 -0
- package/dist/WarehouseView-B8UxxAL6.js +1051 -0
- package/dist/api/bill.d.ts +2 -2
- package/dist/app-RVyC2D4O.js +43892 -0
- package/dist/app.d.ts +1002 -0
- package/dist/app.js +4 -3
- package/dist/components/FmDroppableField.vue.d.ts +1 -1
- package/dist/{date2-Cvp5iJkI.js → date2-C2PfOqbB.js} +1 -1
- package/dist/{dayjs.min-D1_pOsO7.js → dayjs.min-0pzT_dbr.js} +1 -1
- package/dist/{decimal-BAZuuTcd.js → decimal-BtIn4K57.js} +1 -1
- package/dist/{fuzzy-0roCBvgC.js → fuzzy-yzIM5KUK.js} +1 -1
- package/dist/{index-B_aEOJsR.js → index-l87_vggM.js} +1 -1
- package/dist/{layout-BnTfCS_X.js → layout-ITqYtCVu.js} +1 -1
- package/dist/{number-DLj3W3RW.js → number-B5d98l0m.js} +1 -1
- package/dist/router/name.d.ts +2 -1
- package/dist/{rules-CCmXA0Yi.js → rules-CCwuHe8Y.js} +2 -2
- package/dist/{stock-estimate-CL4HShG8.js → stock-estimate-C4PL0Fcz.js} +2 -2
- package/dist/style.css +1 -1
- package/dist/{supplier-CjAH8O1y.js → supplier-CA0OR3DU.js} +1 -1
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/dist/{use-inventory-binding-dialog-GkJOzE6V.js → use-inventory-binding-dialog-CTriImiV.js} +2 -2
- package/dist/views/receive-request/components/transfer-form/SparkIcon.vue.d.ts +1 -1
- package/dist/views/stock/components/StockRecordCard.vue.d.ts +1 -1
- package/dist/views/stock/components/dialog/AdjustedItemForm.vue.d.ts +2 -2
- package/dist/views/stock/helper/compute-summary-total.d.ts +2 -2
- package/dist/{xlsx-vUzm_udV.js → xlsx-DAVatAlv.js} +660 -660
- package/dist/xlsx.util-BsZI2tNE.js +109 -0
- package/package.json +6 -5
- package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DjgmtvXU.js +0 -268
- package/dist/IngredientsView-DMyEGdik.js +0 -1767
- package/dist/InventoryBindingForm.vue_vue_type_script_setup_true_lang-DGTLUrb9.js +0 -276
- package/dist/ReceiveRequestView-BOdgbFFM.js +0 -1394
- package/dist/RecipeView-B1aNLDIK.js +0 -573
- package/dist/StockForecast.vue_vue_type_style_index_0_lang-B5EK101t.js +0 -58
- package/dist/StockView-C_Ur_jTg.js +0 -1862
- package/dist/SupplierView-CXfOoHTr.js +0 -796
- package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-kjV5Eazv.js +0 -1028
- package/dist/UnitView-DHXfAsnq.js +0 -635
- package/dist/WarehouseView-DMwbxs1q.js +0 -1043
- package/dist/app-BkcO8oNJ.js +0 -66113
- package/dist/xlsx.util-B_bqymTM.js +0 -107
|
@@ -0,0 +1,1401 @@
|
|
|
1
|
+
import { defineComponent as Pe, openBlock as v, createElementBlock as T, createElementVNode as l, Fragment as Re, renderList as Xe, toDisplayString as J, unref as r, mergeModels as Mt, reactive as ta, computed as R, onMounted as Ot, useModel as aa, watch as be, ref as L, resolveComponent as S, createBlock as K, withCtx as U, createVNode as i, createCommentVNode as H, normalizeClass as Be, normalizeStyle as jt, resolveDynamicComponent as sa, h as I, isRef as oa, Teleport as la, mergeProps as It } from "vue";
|
|
2
|
+
import { I as ot, d as ge, p as he, q as na, f as nt, a as Kt, C as lt, u as ra, r as Ze, t as ua } from "./app-RVyC2D4O.js";
|
|
3
|
+
import { i as qt, _ as ia, a as ca } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DaHXKF1s.js";
|
|
4
|
+
import { u as Gt, p as da, P as F, a as ma, b as pa, _ as fa, g as va } from "./TransferDetails.vue_vue_type_script_setup_true_lang-CvbKNb0C.js";
|
|
5
|
+
import { i as Wt, a as j, t as _a, c as ya } from "./number-B5d98l0m.js";
|
|
6
|
+
import { _ as ga, u as ha, i as ba, e as Ca } from "./stock-estimate-C4PL0Fcz.js";
|
|
7
|
+
import { d as Nt } from "./dayjs.min-0pzT_dbr.js";
|
|
8
|
+
import { useDialog as xa, useSnackbar as rt, components as oe, useProxiedModel as ka, useBreakpoints as wa } from "@feedmepos/ui-library";
|
|
9
|
+
import { R as Ht, F as Ve } from "./row-action.enum-BwQbURNh.js";
|
|
10
|
+
import { useCoreStore as Da, useI18n as Sa } from "@feedmepos/mf-common";
|
|
11
|
+
import { _ as Fa } from "./FmMultiselectDialog.vue_vue_type_script_setup_true_lang-CxOk5ule.js";
|
|
12
|
+
import { F as X, _ as Bt, u as Ta } from "./layout-ITqYtCVu.js";
|
|
13
|
+
import { R as Qe, B as Va, A as Ra, a as Pa, M as Aa } from "./rules-CCwuHe8Y.js";
|
|
14
|
+
import { c as Je, g as Ua, d as $a, a as Lt } from "./date2-C2PfOqbB.js";
|
|
15
|
+
import { u as Zt } from "./supplier-CA0OR3DU.js";
|
|
16
|
+
import { _ as Ea } from "./PreviewBadge.vue_vue_type_script_setup_true_lang-BvadeWUz.js";
|
|
17
|
+
import { F as Ma, i as Oa } from "./index-l87_vggM.js";
|
|
18
|
+
import { _ as Ia, F as qa } from "./FmUnitInput.vue_vue_type_script_setup_true_lang-D-vJDMKb.js";
|
|
19
|
+
import "./array-AvWd53LI.js";
|
|
20
|
+
const Na = {
|
|
21
|
+
width: "24",
|
|
22
|
+
height: "24",
|
|
23
|
+
viewBox: "0 0 24 24",
|
|
24
|
+
fill: "none",
|
|
25
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
26
|
+
}, Ha = ["fill"], La = ["fill"], za = ["stroke"], Ya = ["stroke"], ja = /* @__PURE__ */ Pe({
|
|
27
|
+
__name: "SparkIcon",
|
|
28
|
+
props: {
|
|
29
|
+
size: {
|
|
30
|
+
type: Number,
|
|
31
|
+
default: 24
|
|
32
|
+
},
|
|
33
|
+
color: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: "#c7c7cc"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
setup(G) {
|
|
39
|
+
return (W, te) => (v(), T("svg", Na, [
|
|
40
|
+
l("path", {
|
|
41
|
+
d: "M7.6 7.6C8.17076 6.94229 8.5 5.5 8.5 5.5C8.5 5.5 8.81356 6.87361 9.35714 7.5C9.92948 8.15953 11.5 8.5 11.5 8.5C11.5 8.5 9.92948 8.69761 9.35714 9.35714C8.81356 9.98354 8.5 11.5 8.5 11.5C8.5 11.5 8.32076 10.1888 7.75 9.59091C7.14905 8.96136 5.5 8.5 5.5 8.5C5.5 8.5 6.99905 8.29251 7.6 7.6Z",
|
|
42
|
+
fill: G.color
|
|
43
|
+
}, null, 8, Ha),
|
|
44
|
+
l("path", {
|
|
45
|
+
d: "M12.2 12.2C13.3415 10.8846 14 8 14 8C14 8 14.6271 10.7472 15.7143 12C16.859 13.3191 20 14 20 14C20 14 16.859 14.3952 15.7143 15.7143C14.6271 16.9671 14 20 14 20C14 20 13.6415 17.3777 12.5 16.1818C11.2981 14.9227 8 14 8 14C8 14 10.9981 13.585 12.2 12.2Z",
|
|
46
|
+
fill: G.color
|
|
47
|
+
}, null, 8, La),
|
|
48
|
+
l("path", {
|
|
49
|
+
d: "M7.6 7.6C8.17076 6.94229 8.5 5.5 8.5 5.5C8.5 5.5 8.81356 6.87361 9.35714 7.5C9.92948 8.15953 11.5 8.5 11.5 8.5C11.5 8.5 9.92948 8.69761 9.35714 9.35714C8.81356 9.98354 8.5 11.5 8.5 11.5C8.5 11.5 8.32076 10.1888 7.75 9.59091C7.14905 8.96136 5.5 8.5 5.5 8.5C5.5 8.5 6.99905 8.29251 7.6 7.6Z",
|
|
50
|
+
stroke: G.color,
|
|
51
|
+
"stroke-width": "1.5",
|
|
52
|
+
"stroke-linecap": "round",
|
|
53
|
+
"stroke-linejoin": "round"
|
|
54
|
+
}, null, 8, za),
|
|
55
|
+
l("path", {
|
|
56
|
+
d: "M12.2 12.2C13.3415 10.8846 14 8 14 8C14 8 14.6271 10.7472 15.7143 12C16.859 13.3191 20 14 20 14C20 14 16.859 14.3952 15.7143 15.7143C14.6271 16.9671 14 20 14 20C14 20 13.6415 17.3777 12.5 16.1818C11.2981 14.9227 8 14 8 14C8 14 10.9981 13.585 12.2 12.2Z",
|
|
57
|
+
stroke: G.color,
|
|
58
|
+
"stroke-width": "1.5",
|
|
59
|
+
"stroke-linecap": "round",
|
|
60
|
+
"stroke-linejoin": "round"
|
|
61
|
+
}, null, 8, Ya)
|
|
62
|
+
]));
|
|
63
|
+
}
|
|
64
|
+
}), Ka = { class: "flex flex-col gap-8 px-16 xs:px-4 sm:px-4 py-4 items-center" }, Ga = { class: "fm-typo-en-body-lg-600 xs:fm-typo-en-body-md-600 mr-auto xs:w-full" }, Wa = { class: "w-[450px] xs:w-full flex" }, Ba = { class: "fm-typo-en-body-md-400 whitespace-nowrap" }, Za = /* @__PURE__ */ l("span", { class: "text-fm-color-typo-secondary" }, "/", -1), Qa = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Ja = /* @__PURE__ */ l("span", null, /* @__PURE__ */ J(" "), -1), zt = /* @__PURE__ */ Pe({
|
|
65
|
+
__name: "SupplierPriceHistory",
|
|
66
|
+
props: {
|
|
67
|
+
prices: {}
|
|
68
|
+
},
|
|
69
|
+
setup(G) {
|
|
70
|
+
const W = Zt();
|
|
71
|
+
function te(k) {
|
|
72
|
+
return W.suppliers.find((M) => M._id === k);
|
|
73
|
+
}
|
|
74
|
+
return (k, M) => (v(), T("div", Ka, [
|
|
75
|
+
(v(!0), T(Re, null, Xe(Object.keys(k.prices), (P) => {
|
|
76
|
+
var q;
|
|
77
|
+
return v(), T("div", {
|
|
78
|
+
key: P,
|
|
79
|
+
class: "flex items-center gap-12 xs:gap-4 xs:flex-wrap w-full"
|
|
80
|
+
}, [
|
|
81
|
+
l("div", Ga, J((q = te(P)) == null ? void 0 : q.name), 1),
|
|
82
|
+
l("div", Wa, [
|
|
83
|
+
(v(!0), T(Re, null, Xe(k.prices[P].slice(0, 3), (y) => {
|
|
84
|
+
var h;
|
|
85
|
+
return v(), T("div", {
|
|
86
|
+
key: y.date,
|
|
87
|
+
class: "flex flex-col w-[150px] xs:flex-1 text-ellipsis cursor-pointer"
|
|
88
|
+
}, [
|
|
89
|
+
l("div", Ba, [
|
|
90
|
+
l("span", null, J(y.totalCost ? r(Wt)(y.totalCost) : "No data"), 1),
|
|
91
|
+
Za,
|
|
92
|
+
l("span", null, J(r(j)(y.totalUnit, !1)), 1),
|
|
93
|
+
l("span", null, J(((h = y.measurement) == null ? void 0 : h.abbrev) ?? y.unit.abbrev), 1)
|
|
94
|
+
]),
|
|
95
|
+
l("div", Qa, [
|
|
96
|
+
l("span", null, "(#" + J(y.seqNumber) + ")", 1),
|
|
97
|
+
Ja,
|
|
98
|
+
l("span", null, J(r(Je)(new Date(y.date))), 1)
|
|
99
|
+
])
|
|
100
|
+
]);
|
|
101
|
+
}), 128))
|
|
102
|
+
])
|
|
103
|
+
]);
|
|
104
|
+
}), 128))
|
|
105
|
+
]));
|
|
106
|
+
}
|
|
107
|
+
}), Xa = { class: "flex flex-col w-full gap-40" }, es = { class: "flex flex-col gap-8" }, ts = /* @__PURE__ */ l("div", { class: "fm-typo-en-title-sm-800" }, "Transfer details", -1), as = { class: "flex items-center gap-8" }, ss = /* @__PURE__ */ l("div", null, null, -1), os = { class: "flex flex-col gap-4" }, ls = {
|
|
108
|
+
key: 0,
|
|
109
|
+
class: "p-16 border border-fm-color-neutral-gray-300 fm-corner-radius-md flex flex-col"
|
|
110
|
+
}, ns = { class: "flex xs:flex-col sm:flex-col" }, rs = /* @__PURE__ */ l("div", { class: "xs:hidden sm:hidden h-48 lg:w-16 md:w-16" }, null, -1), us = {
|
|
111
|
+
key: 0,
|
|
112
|
+
class: "flex-1 flex gap-8 h-48 xs:flex-col xs:pt-16 sm:flex-col sm:pt-16"
|
|
113
|
+
}, is = { class: "flex-1" }, cs = { class: "flex-1" }, ds = {
|
|
114
|
+
key: 1,
|
|
115
|
+
class: "flex items-center gap-4"
|
|
116
|
+
}, ms = /* @__PURE__ */ l("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary translate-y-[1px]" }, " Cannot backdate without an initial closing made to the system. ", -1), ps = { class: "flex flex-col gap-8" }, fs = { class: "flex items-center xs:flex-col xs:gap-4" }, vs = /* @__PURE__ */ l("div", { class: "xs:w-full flex-1 fm-typo-en-title-sm-800" }, "Transfer items", -1), _s = {
|
|
117
|
+
key: 0,
|
|
118
|
+
class: "xs:w-full"
|
|
119
|
+
}, ys = { class: "flex gap-2" }, gs = ["disabled"], hs = { class: "w-[343px] px-24 py-16 rounded-lg shadow-light-300 flex flex-col gap-[20px]" }, bs = { class: "flex items-center" }, Cs = /* @__PURE__ */ l("p", { class: "flex-1 fm-typo-en-title-sm-800" }, "Forecast stock", -1), xs = { class: "flex items-start gap-8" }, ks = /* @__PURE__ */ l("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Selecting forecast stock will replace your current item selection. ", -1), ws = { class: "flex gap-1" }, Ds = /* @__PURE__ */ l("div", { class: "grow" }, null, -1), Ss = { key: 0 }, Fs = { class: "fm-typo-body-md-400 line-clamp-2 w-full" }, Ts = { key: 0 }, Vs = ["colspan"], Rs = { class: "flex flex-col gap-4" }, Ps = { class: "flex items-center" }, As = { class: "flex-1" }, Us = { class: "grid grid-cols-2 gap-4" }, $s = { class: "flex flex-col" }, Es = { class: "flex flex-col" }, Ms = { class: "flex flex-col" }, Os = { class: "h-24" }, Is = {
|
|
120
|
+
key: 0,
|
|
121
|
+
class: "flex flex-col",
|
|
122
|
+
"data-cy": "fm-table-list-view-cost-label"
|
|
123
|
+
}, qs = {
|
|
124
|
+
key: 0,
|
|
125
|
+
class: "flex gap-4 text-fm-color-typo-primary fm-typo-en-body-lg-600"
|
|
126
|
+
}, Ns = /* @__PURE__ */ Pe({
|
|
127
|
+
__name: "TransferForm",
|
|
128
|
+
props: /* @__PURE__ */ Mt({
|
|
129
|
+
modelValue: {},
|
|
130
|
+
disabled: { type: Boolean },
|
|
131
|
+
suppliers: { default: () => [] },
|
|
132
|
+
skus: { default: () => [] },
|
|
133
|
+
lastClosingDate: {}
|
|
134
|
+
}, {
|
|
135
|
+
modelValue: {
|
|
136
|
+
default: {
|
|
137
|
+
ref: "",
|
|
138
|
+
supplier: null
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
modelModifiers: {}
|
|
142
|
+
}),
|
|
143
|
+
emits: /* @__PURE__ */ Mt(["validation-success"], ["update:modelValue"]),
|
|
144
|
+
setup(G, { expose: W, emit: te }) {
|
|
145
|
+
const k = nt(), M = ha(), P = Da(), q = Gt(), y = Kt(), h = ta({}), _ = G;
|
|
146
|
+
function le(e) {
|
|
147
|
+
return Object.prototype.hasOwnProperty.call(e, "_rev") && Object.prototype.hasOwnProperty.call(e, "status");
|
|
148
|
+
}
|
|
149
|
+
const w = R(() => !le(_.modelValue) || _.modelValue.status === "DRAFT");
|
|
150
|
+
Ot(() => {
|
|
151
|
+
const e = _.modelValue;
|
|
152
|
+
if (le(e))
|
|
153
|
+
for (const t of e.items) {
|
|
154
|
+
const a = N(t), n = t.totalCost ?? Ma.reset();
|
|
155
|
+
a ? h[t.sku._id] = a.amount !== n.amount || a.precision !== n.precision : h[t.sku._id] = !0;
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
const z = R(() => {
|
|
159
|
+
var a;
|
|
160
|
+
if (w.value)
|
|
161
|
+
return !0;
|
|
162
|
+
const e = _.lastClosingDate, t = (a = _.modelValue) != null && a._id ? da(_.modelValue._id) : null;
|
|
163
|
+
return !e || !t ? !1 : t.getTime() > e.getTime();
|
|
164
|
+
}), $ = te, d = aa(G, "modelValue"), B = R({
|
|
165
|
+
get() {
|
|
166
|
+
var e;
|
|
167
|
+
return ((e = d.value) == null ? void 0 : e.remark) ?? "";
|
|
168
|
+
},
|
|
169
|
+
set(e) {
|
|
170
|
+
d.value.remark = e;
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
be([() => _.suppliers], () => {
|
|
174
|
+
if (o.value === F.PURCHASE) {
|
|
175
|
+
d.value.supplier = _.suppliers[0];
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
const E = R(() => _.disabled), ne = R(() => d.value.items ?? []), de = (e) => {
|
|
180
|
+
const { name: t, address: a, regNo: n, phoneNo: s } = e.doc.profile;
|
|
181
|
+
return {
|
|
182
|
+
_id: e.doc._id,
|
|
183
|
+
internal: e.type === ot.restaurant ? he.enum.restaurant : he.enum.warehouse,
|
|
184
|
+
name: t,
|
|
185
|
+
registrationNumber: n,
|
|
186
|
+
address: a,
|
|
187
|
+
contactName: t,
|
|
188
|
+
phoneNumber: s,
|
|
189
|
+
disabled: !e.acceptRequest || e.dbName === k.currentLocation.dbName
|
|
190
|
+
};
|
|
191
|
+
}, A = [
|
|
192
|
+
{
|
|
193
|
+
label: "Purchase",
|
|
194
|
+
value: F.PURCHASE
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
label: "Transfer",
|
|
198
|
+
value: F.TRANSFER
|
|
199
|
+
}
|
|
200
|
+
], o = L(F.PURCHASE), p = R(() => {
|
|
201
|
+
var t;
|
|
202
|
+
const e = ((t = k._currentLocation) == null ? void 0 : t.type) === ot.warehouse;
|
|
203
|
+
return k.locations.filter((a) => {
|
|
204
|
+
var s;
|
|
205
|
+
return !(a.dbName === ((s = k._currentLocation) == null ? void 0 : s.dbName)) && (!e || a.type === ot.warehouse) && a.acceptRequest;
|
|
206
|
+
});
|
|
207
|
+
}), C = R(() => o.value === F.PURCHASE ? _.suppliers.map((e) => ({
|
|
208
|
+
label: e.name,
|
|
209
|
+
value: e._id,
|
|
210
|
+
disabled: !1
|
|
211
|
+
})) : p.value.map(de).map((e) => ({
|
|
212
|
+
label: e.disabled ? `${e.name} (Upgrade POS)` : e.name,
|
|
213
|
+
value: e._id,
|
|
214
|
+
disabled: e.disabled
|
|
215
|
+
}))), b = R({
|
|
216
|
+
get() {
|
|
217
|
+
var e;
|
|
218
|
+
return ((e = d.value.supplier) == null ? void 0 : e._id) ?? null;
|
|
219
|
+
},
|
|
220
|
+
set(e) {
|
|
221
|
+
if (o.value === F.PURCHASE) {
|
|
222
|
+
d.value.supplier = _.suppliers.find((a) => a._id === e) ?? null, d.value.items && (d.value.items = d.value.items.map((a) => ({
|
|
223
|
+
...a,
|
|
224
|
+
totalCost: N(a)
|
|
225
|
+
})));
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
const t = k.locations.find((a) => a.doc._id === e);
|
|
229
|
+
t ? d.value.supplier = de(t) : d.value.supplier = null;
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
function D(e) {
|
|
233
|
+
switch (e) {
|
|
234
|
+
case lt.MY:
|
|
235
|
+
return "MYR";
|
|
236
|
+
case lt.SG:
|
|
237
|
+
return "SGD";
|
|
238
|
+
case lt.ID:
|
|
239
|
+
return "IDR";
|
|
240
|
+
default:
|
|
241
|
+
return "MYR";
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
function N(e) {
|
|
245
|
+
var Y, Z, ue, Ne, He, Le;
|
|
246
|
+
if (h[e.sku._id])
|
|
247
|
+
return e.totalCost;
|
|
248
|
+
const t = e.measurement, a = (Ne = (ue = (Z = (Y = _.modelValue) == null ? void 0 : Y.supplier) == null ? void 0 : Z.supplyItems) == null ? void 0 : ue.find(
|
|
249
|
+
(De) => De.skuId === e.sku._id
|
|
250
|
+
)) == null ? void 0 : Ne.defaultCost, n = e.sku.defaultCost, s = a ?? n, c = s == null ? void 0 : s.costPerUnit, u = c ? s != null && s.measurement ? +j(c) / +j(s == null ? void 0 : s.measurement.conversion) : +j(c) : void 0, f = u ? t ? u * +j(t.conversion) : u : void 0, x = f ? +j(e.quantity) * f : void 0;
|
|
251
|
+
return x ? {
|
|
252
|
+
..._a(x ?? 0, 2),
|
|
253
|
+
currency: D(((He = P.currentCountry) == null ? void 0 : He.value) ?? ge)
|
|
254
|
+
} : {
|
|
255
|
+
amount: 1,
|
|
256
|
+
precision: 0,
|
|
257
|
+
currency: D(((Le = P.currentCountry) == null ? void 0 : Le.value) ?? ge)
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
function me(e) {
|
|
261
|
+
var t;
|
|
262
|
+
o.value = e, b.value = ((t = C.value.find((a) => !a.disabled)) == null ? void 0 : t.value) ?? null, e === F.PURCHASE && y.enableTotalCost && (d.value.items = d.value.items.map((a) => {
|
|
263
|
+
const n = N(a);
|
|
264
|
+
return {
|
|
265
|
+
...a,
|
|
266
|
+
totalCost: n
|
|
267
|
+
};
|
|
268
|
+
}));
|
|
269
|
+
}
|
|
270
|
+
be([() => _.modelValue], ([e]) => {
|
|
271
|
+
var t, a, n;
|
|
272
|
+
((t = e == null ? void 0 : e.supplier) == null ? void 0 : t.internal) === he.enum.restaurant || ((a = e == null ? void 0 : e.supplier) == null ? void 0 : a.internal) === he.enum.warehouse ? o.value = F.TRANSFER : o.value = F.PURCHASE, b.value = ((n = C.value.find((s) => {
|
|
273
|
+
var c, u;
|
|
274
|
+
return s.value === ((u = (c = _.modelValue) == null ? void 0 : c.supplier) == null ? void 0 : u._id);
|
|
275
|
+
})) == null ? void 0 : n.value) ?? null;
|
|
276
|
+
}), Ot(() => {
|
|
277
|
+
var e, t, a, n, s, c, u;
|
|
278
|
+
((t = (e = _.modelValue) == null ? void 0 : e.supplier) == null ? void 0 : t.internal) === he.enum.restaurant || ((n = (a = _.modelValue) == null ? void 0 : a.supplier) == null ? void 0 : n.internal) === he.enum.warehouse ? o.value = F.TRANSFER : o.value = F.PURCHASE, b.value = (s = _.modelValue) != null && s.supplier ? ((c = C.value.find((f) => {
|
|
279
|
+
var x, V;
|
|
280
|
+
return f.value === ((V = (x = _.modelValue) == null ? void 0 : x.supplier) == null ? void 0 : V._id);
|
|
281
|
+
})) == null ? void 0 : c.value) ?? null : ((u = C.value.find((f) => !f.disabled)) == null ? void 0 : u.value) ?? null;
|
|
282
|
+
});
|
|
283
|
+
const pe = xa(), ee = L(7), ae = L(!1), Ce = rt();
|
|
284
|
+
async function Ae() {
|
|
285
|
+
if (ee.value < 1)
|
|
286
|
+
return;
|
|
287
|
+
ae.value = !1, await M.readPurchaseOrder(ee.value);
|
|
288
|
+
const e = {
|
|
289
|
+
...d.value
|
|
290
|
+
}, t = [];
|
|
291
|
+
if (M.purchaseOrderForecast.skus.length <= 0) {
|
|
292
|
+
Ce.open({ message: "There is no forecast at the moment.", type: "info" });
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
e.items = M.purchaseOrderForecast.skus.reduce((a, n) => {
|
|
296
|
+
const s = _.skus.find((f) => f._id === n.id);
|
|
297
|
+
if (a.find((f) => f.sku._id === n.id) || !s)
|
|
298
|
+
return a;
|
|
299
|
+
const u = {
|
|
300
|
+
sku: s,
|
|
301
|
+
code: s.code,
|
|
302
|
+
name: s.name,
|
|
303
|
+
quantity: {
|
|
304
|
+
amount: n.amount,
|
|
305
|
+
precision: 0
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
return a.push(u), a;
|
|
309
|
+
}, t), d.value = e;
|
|
310
|
+
}
|
|
311
|
+
function fe(e) {
|
|
312
|
+
var c, u, f, x, V, Y;
|
|
313
|
+
const t = (x = (f = (u = (c = _.modelValue) == null ? void 0 : c.supplier) == null ? void 0 : u.supplyItems) == null ? void 0 : f.find(
|
|
314
|
+
(Z) => Z.skuId === e.sku._id
|
|
315
|
+
)) == null ? void 0 : x.defaultCost, a = e.sku.defaultCost, n = ((V = t == null ? void 0 : t.costPerUnit) == null ? void 0 : V.amount) ?? 0, s = ((Y = a == null ? void 0 : a.costPerUnit) == null ? void 0 : Y.amount) ?? 0;
|
|
316
|
+
return n || s;
|
|
317
|
+
}
|
|
318
|
+
function ve() {
|
|
319
|
+
const e = _.skus.map((a) => ({
|
|
320
|
+
label: a.name,
|
|
321
|
+
sublabel: a.code,
|
|
322
|
+
value: a
|
|
323
|
+
})), t = e.filter((a) => {
|
|
324
|
+
var n;
|
|
325
|
+
return (n = d.value.items) == null ? void 0 : n.find((s) => s.sku._id === a.value._id);
|
|
326
|
+
}).map((a) => a.value);
|
|
327
|
+
pe.open({
|
|
328
|
+
title: "Select item",
|
|
329
|
+
closeButton: !0,
|
|
330
|
+
contentComponent: Fa,
|
|
331
|
+
contentComponentProps: {
|
|
332
|
+
modelValue: t,
|
|
333
|
+
items: e
|
|
334
|
+
},
|
|
335
|
+
primaryActions: {
|
|
336
|
+
text: "Confirm",
|
|
337
|
+
close: !0
|
|
338
|
+
},
|
|
339
|
+
secondaryActions: {
|
|
340
|
+
text: "Close",
|
|
341
|
+
close: !0,
|
|
342
|
+
variant: "tertiary"
|
|
343
|
+
}
|
|
344
|
+
}).onPrimary((a) => {
|
|
345
|
+
const n = {
|
|
346
|
+
...d.value
|
|
347
|
+
}, s = n.items ?? [], c = a.map((u) => {
|
|
348
|
+
const f = s.find((V) => V.sku._id === u._id);
|
|
349
|
+
if (f)
|
|
350
|
+
return f;
|
|
351
|
+
const x = {
|
|
352
|
+
sku: u,
|
|
353
|
+
code: u.code,
|
|
354
|
+
name: u.name,
|
|
355
|
+
quantity: {
|
|
356
|
+
amount: 1,
|
|
357
|
+
precision: 0
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
return o.value === F.PURCHASE && y.enableTotalCost && (fe(x) ? x.totalCost = N(x) : (h[x.sku._id] = !0, x.totalCost = null)), x;
|
|
361
|
+
});
|
|
362
|
+
c.sort((u, f) => u.sku.code.localeCompare(f.sku.code)), n.items = c, d.value = n;
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
function Ue(e, t) {
|
|
366
|
+
var a;
|
|
367
|
+
if (e === Ht.Delete) {
|
|
368
|
+
const n = ((a = d.value) == null ? void 0 : a.items) ?? [];
|
|
369
|
+
d.value.items = n.filter((s) => s.sku._id !== t);
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
function $e(e, t) {
|
|
374
|
+
var n;
|
|
375
|
+
const a = ((n = d.value) == null ? void 0 : n.items) ?? [];
|
|
376
|
+
d.value.items = a.map((s) => s.sku._id !== e ? s : t ? (s.measurement = t, y.enableTotalCost && (s.totalCost = N(s)), s) : (delete s.measurement, s.totalCost = N(s), s));
|
|
377
|
+
}
|
|
378
|
+
function Ee(e, t) {
|
|
379
|
+
const a = d.value, n = a.items ?? [];
|
|
380
|
+
a.items = n.map((s) => (s.sku._id !== e || (s.code = t), s));
|
|
381
|
+
}
|
|
382
|
+
function Me(e, t) {
|
|
383
|
+
const a = d.value, n = a.items ?? [];
|
|
384
|
+
a.items = n.map((s) => (s.sku._id !== e || (s.name = t), s));
|
|
385
|
+
}
|
|
386
|
+
function _e(e, t) {
|
|
387
|
+
const a = d.value, n = a.items ?? [];
|
|
388
|
+
a.items = n.map((s) => (s.sku._id !== e || (s.quantity = t, y.enableTotalCost && (s.totalCost = N(s))), s));
|
|
389
|
+
}
|
|
390
|
+
function Oe(e, t) {
|
|
391
|
+
const a = +t, n = d.value, s = n.items ?? [];
|
|
392
|
+
t.length > 0 && isFinite(a) ? n.items = s.map((c) => {
|
|
393
|
+
var u;
|
|
394
|
+
return c.sku._id !== e || (c.totalCost = {
|
|
395
|
+
...ya(a),
|
|
396
|
+
currency: D(((u = P.currentCountry) == null ? void 0 : u.value) ?? ge)
|
|
397
|
+
}), c;
|
|
398
|
+
}) : n.items = s.map((c) => {
|
|
399
|
+
var u;
|
|
400
|
+
return c.sku._id !== e || (c.totalCost = {
|
|
401
|
+
amount: 0,
|
|
402
|
+
precision: 0,
|
|
403
|
+
currency: D(((u = P.currentCountry) == null ? void 0 : u.value) ?? ge)
|
|
404
|
+
}), c;
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
const xe = [
|
|
408
|
+
{
|
|
409
|
+
header: "Code",
|
|
410
|
+
accessorKey: "code",
|
|
411
|
+
size: 96,
|
|
412
|
+
cell(e) {
|
|
413
|
+
const t = e.row.original;
|
|
414
|
+
return w.value ? I(oe.FmTextField, {
|
|
415
|
+
modelValue: t.code,
|
|
416
|
+
"onUpdate:modelValue": (a) => {
|
|
417
|
+
Ee(t.sku._id, a);
|
|
418
|
+
},
|
|
419
|
+
rules: [Qe()],
|
|
420
|
+
labelMark: "required"
|
|
421
|
+
}) : t.code;
|
|
422
|
+
},
|
|
423
|
+
enableSorting: !1
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
id: "Name",
|
|
427
|
+
header: "Name",
|
|
428
|
+
minSize: 300,
|
|
429
|
+
cell(e) {
|
|
430
|
+
const t = e.row.original;
|
|
431
|
+
return w.value ? I(oe.FmTextField, {
|
|
432
|
+
modelValue: t.name,
|
|
433
|
+
"onUpdate:modelValue": (a) => {
|
|
434
|
+
Me(t.sku._id, a);
|
|
435
|
+
},
|
|
436
|
+
rules: [Qe()],
|
|
437
|
+
labelMark: "required"
|
|
438
|
+
}) : t.name;
|
|
439
|
+
},
|
|
440
|
+
enableSorting: !1
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
id: "Amount",
|
|
444
|
+
header: "Amount",
|
|
445
|
+
minSize: 300,
|
|
446
|
+
cell(e) {
|
|
447
|
+
var n, s, c, u;
|
|
448
|
+
const t = e.row.original, a = (c = (s = (n = d.value) == null ? void 0 : n.items) == null ? void 0 : s.find) == null ? void 0 : c.call(s, (f) => f.sku._id === t.sku._id);
|
|
449
|
+
return a ? w.value ? I(Ia, {
|
|
450
|
+
style: {
|
|
451
|
+
flex: "1 1 0%"
|
|
452
|
+
},
|
|
453
|
+
modelValue: {
|
|
454
|
+
amount: a.quantity ?? { amount: 1, precision: 0 },
|
|
455
|
+
measurement: a.measurement ?? null
|
|
456
|
+
},
|
|
457
|
+
key: a.sku._id,
|
|
458
|
+
unit: a.sku.unit,
|
|
459
|
+
"onUpdate:modelValue": (f) => {
|
|
460
|
+
_e(t.sku._id, f.amount), $e(t.sku._id, f.measurement);
|
|
461
|
+
},
|
|
462
|
+
rules: [qa(0)],
|
|
463
|
+
applyDefaultRules: !0
|
|
464
|
+
}) : `${j(a.quantity ?? { amount: 1, precision: 0 })} ${((u = a.measurement) == null ? void 0 : u.abbrev) ?? a.sku.unit.abbrev}` : null;
|
|
465
|
+
},
|
|
466
|
+
enableSorting: !1
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
id: "Cost",
|
|
470
|
+
header: () => {
|
|
471
|
+
var e, t;
|
|
472
|
+
return I(
|
|
473
|
+
Ea,
|
|
474
|
+
{
|
|
475
|
+
zIndex: 50,
|
|
476
|
+
class: "whitespace-nowrap"
|
|
477
|
+
},
|
|
478
|
+
[
|
|
479
|
+
`Total cost (${D(((e = P.currentCountry) == null ? void 0 : e.value) ?? ge) === "MYR" ? "RM" : D(((t = P.currentCountry) == null ? void 0 : t.value) ?? ge)})`
|
|
480
|
+
]
|
|
481
|
+
);
|
|
482
|
+
},
|
|
483
|
+
size: 180,
|
|
484
|
+
cell(e) {
|
|
485
|
+
var n, s, c;
|
|
486
|
+
const t = e.row.original, a = (c = (s = (n = d.value) == null ? void 0 : n.items) == null ? void 0 : s.find) == null ? void 0 : c.call(s, (u) => u.sku._id === t.sku._id);
|
|
487
|
+
return z.value ? h[(a == null ? void 0 : a.sku._id) ?? ""] || a && !fe(a) ? I(
|
|
488
|
+
oe.FmTextField,
|
|
489
|
+
{
|
|
490
|
+
style: {
|
|
491
|
+
flex: "1 1 0%"
|
|
492
|
+
},
|
|
493
|
+
modelValue: a != null && a.totalCost ? +j(a == null ? void 0 : a.totalCost) : "",
|
|
494
|
+
"onUpdate:modelValue": (u) => {
|
|
495
|
+
Oe(t.sku._id, u);
|
|
496
|
+
},
|
|
497
|
+
rules: [Pa(0), Aa(2)]
|
|
498
|
+
},
|
|
499
|
+
a && fe(a) ? {
|
|
500
|
+
append: I(oe.FmButton, {
|
|
501
|
+
prependIcon: "close",
|
|
502
|
+
variant: "tertiary",
|
|
503
|
+
onClick: () => {
|
|
504
|
+
var f;
|
|
505
|
+
h[(a == null ? void 0 : a.sku._id) ?? ""] = !1;
|
|
506
|
+
const u = ((f = d.value) == null ? void 0 : f.items) ?? [];
|
|
507
|
+
d.value.items = u.map((x) => (y.enableTotalCost && (x.totalCost = N(x)), x));
|
|
508
|
+
}
|
|
509
|
+
})
|
|
510
|
+
} : {}
|
|
511
|
+
) : I(
|
|
512
|
+
"div",
|
|
513
|
+
{
|
|
514
|
+
class: "flex items-center gap-4"
|
|
515
|
+
},
|
|
516
|
+
[
|
|
517
|
+
I(oe.FmButton, {
|
|
518
|
+
prependIcon: "edit",
|
|
519
|
+
variant: "tertiary",
|
|
520
|
+
onClick: () => {
|
|
521
|
+
h[(a == null ? void 0 : a.sku._id) ?? ""] = !0;
|
|
522
|
+
}
|
|
523
|
+
}),
|
|
524
|
+
I(
|
|
525
|
+
"div",
|
|
526
|
+
{
|
|
527
|
+
class: "text-fm-color-typo-primary fm-typo-en-body-lg-400"
|
|
528
|
+
},
|
|
529
|
+
j((a == null ? void 0 : a.totalCost) ?? { amount: 1, precision: 0 })
|
|
530
|
+
)
|
|
531
|
+
]
|
|
532
|
+
) : I(
|
|
533
|
+
"div",
|
|
534
|
+
{
|
|
535
|
+
style: {
|
|
536
|
+
display: "flex",
|
|
537
|
+
alignItems: "center",
|
|
538
|
+
gap: "4px"
|
|
539
|
+
}
|
|
540
|
+
},
|
|
541
|
+
[
|
|
542
|
+
I(
|
|
543
|
+
"div",
|
|
544
|
+
a != null && a.totalCost ? +j((a == null ? void 0 : a.totalCost) ?? { amount: 1, precision: 0 }) : "0.00"
|
|
545
|
+
),
|
|
546
|
+
I(
|
|
547
|
+
oe.FmTooltip,
|
|
548
|
+
{
|
|
549
|
+
content: _.lastClosingDate ? `Last closing was already done at ${Je(_.lastClosingDate)} ${Lt(_.lastClosingDate)}. You may no longer change total cost of this purchase order.` : "You may only change the total cost if you have done a closing with recent costing feature.",
|
|
550
|
+
placement: "left",
|
|
551
|
+
zIndex: 50
|
|
552
|
+
},
|
|
553
|
+
[
|
|
554
|
+
I(oe.FmIcon, {
|
|
555
|
+
name: "info",
|
|
556
|
+
size: "sm",
|
|
557
|
+
color: "typo-secondary"
|
|
558
|
+
})
|
|
559
|
+
]
|
|
560
|
+
)
|
|
561
|
+
]
|
|
562
|
+
);
|
|
563
|
+
},
|
|
564
|
+
enableSorting: !1
|
|
565
|
+
},
|
|
566
|
+
{
|
|
567
|
+
id: "Delete",
|
|
568
|
+
header: "",
|
|
569
|
+
cell(e) {
|
|
570
|
+
return I(oe.FmButton, {
|
|
571
|
+
class: "delete-button",
|
|
572
|
+
type: "button",
|
|
573
|
+
icon: "delete",
|
|
574
|
+
variant: "tertiary",
|
|
575
|
+
size: "md",
|
|
576
|
+
onClick: () => {
|
|
577
|
+
Ue(Ht.Delete, e.row.original.sku._id);
|
|
578
|
+
}
|
|
579
|
+
});
|
|
580
|
+
},
|
|
581
|
+
enableSorting: !1,
|
|
582
|
+
size: 40,
|
|
583
|
+
meta: {
|
|
584
|
+
cellClass: "",
|
|
585
|
+
headerClass: ""
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
], ke = R(
|
|
589
|
+
() => w.value ? xe : xe.filter((e) => e.id !== "Delete")
|
|
590
|
+
), ye = R(() => o.value === F.PURCHASE && y.enableTotalCost ? ke.value : ke.value.filter((e) => e.id !== "Cost")), re = L();
|
|
591
|
+
W({
|
|
592
|
+
validateInputs: () => {
|
|
593
|
+
var e, t;
|
|
594
|
+
(t = (e = re.value) == null ? void 0 : e.validateInputs) == null || t.call(e);
|
|
595
|
+
},
|
|
596
|
+
resetInputsValidation: () => {
|
|
597
|
+
var e, t;
|
|
598
|
+
(t = (e = re.value) == null ? void 0 : e.resetInputsValidation) == null || t.call(e);
|
|
599
|
+
},
|
|
600
|
+
resetInputs: () => {
|
|
601
|
+
var e, t;
|
|
602
|
+
(t = (e = re.value) == null ? void 0 : e.resetInputs) == null || t.call(e);
|
|
603
|
+
}
|
|
604
|
+
});
|
|
605
|
+
const se = L(!1);
|
|
606
|
+
be(se, (e) => {
|
|
607
|
+
e && (Ie.value = !0, Qt().finally(() => {
|
|
608
|
+
Ie.value = !1;
|
|
609
|
+
}));
|
|
610
|
+
});
|
|
611
|
+
async function Qt() {
|
|
612
|
+
try {
|
|
613
|
+
const { startDate: e, endDate: t } = Ua(6), s = (await q.getPurchaseOrders({ start: e, end: t })).filter(
|
|
614
|
+
(c) => {
|
|
615
|
+
var u, f;
|
|
616
|
+
return c.status === na.enum.COMPLETE && ((u = c.supplier) == null ? void 0 : u.internal) !== "warehouse" && ((f = c.supplier) == null ? void 0 : f.internal) !== "restaurant";
|
|
617
|
+
}
|
|
618
|
+
).reduce((c, u) => {
|
|
619
|
+
const f = new Date(Oa(u._id)), x = u.supplier._id;
|
|
620
|
+
for (const V of u.items) {
|
|
621
|
+
if (!V.totalCost) continue;
|
|
622
|
+
const Y = c[V.sku._id] ?? {}, Z = Y[x] ?? [];
|
|
623
|
+
Z.push({
|
|
624
|
+
date: f.toISOString(),
|
|
625
|
+
totalUnit: V.quantity,
|
|
626
|
+
totalCost: V.totalCost,
|
|
627
|
+
unit: V.sku.unit,
|
|
628
|
+
measurement: V.measurement,
|
|
629
|
+
seqNumber: u.seqNumber
|
|
630
|
+
}), Y[x] = Z, c[V.sku._id] = Y;
|
|
631
|
+
}
|
|
632
|
+
return c;
|
|
633
|
+
}, {});
|
|
634
|
+
we.value = s;
|
|
635
|
+
} catch {
|
|
636
|
+
Ce.open({
|
|
637
|
+
title: "Something went wrong",
|
|
638
|
+
message: "Cannot retrieve supplier purchase history. Please try again."
|
|
639
|
+
}), se.value = !1;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
const Ie = L(!1), we = L({});
|
|
643
|
+
function qe(e) {
|
|
644
|
+
return e.column.columnDef.meta;
|
|
645
|
+
}
|
|
646
|
+
const O = R({
|
|
647
|
+
get() {
|
|
648
|
+
var e, t;
|
|
649
|
+
return (e = _.modelValue) != null && e.effectiveAt ? new Date((t = _.modelValue) == null ? void 0 : t.effectiveAt) : null;
|
|
650
|
+
},
|
|
651
|
+
set(e) {
|
|
652
|
+
d.value.effectiveAt = (e == null ? void 0 : e.toISOString()) ?? null;
|
|
653
|
+
}
|
|
654
|
+
}), tt = R({
|
|
655
|
+
get() {
|
|
656
|
+
return !!O.value;
|
|
657
|
+
},
|
|
658
|
+
set(e) {
|
|
659
|
+
e ? O.value = /* @__PURE__ */ new Date() : O.value = null;
|
|
660
|
+
}
|
|
661
|
+
}), at = R({
|
|
662
|
+
get() {
|
|
663
|
+
return O.value === null ? "" : Je(O.value);
|
|
664
|
+
},
|
|
665
|
+
set(e) {
|
|
666
|
+
e ? O.value = /* @__PURE__ */ new Date(`${e} ${st.value}`) : O.value = null;
|
|
667
|
+
}
|
|
668
|
+
}), st = R({
|
|
669
|
+
get() {
|
|
670
|
+
return O.value === null ? "" : $a(O.value);
|
|
671
|
+
},
|
|
672
|
+
set(e) {
|
|
673
|
+
e ? O.value = /* @__PURE__ */ new Date(`${at.value} ${e}`) : O.value = null;
|
|
674
|
+
}
|
|
675
|
+
}), ut = R(() => {
|
|
676
|
+
var e;
|
|
677
|
+
return (e = k._currentLocation) == null ? void 0 : e.dbName.startsWith("restaurant");
|
|
678
|
+
});
|
|
679
|
+
return (e, t) => {
|
|
680
|
+
const a = S("FmChip"), n = S("FmSelect"), s = S("FmMenuItem"), c = S("FmTextField"), u = S("FmTextarea"), f = S("FmSwitch"), x = S("FmDatePicker"), V = S("FmTimePicker"), Y = S("FmFormGroup"), Z = S("FmIcon"), ue = S("FmButton"), Ne = S("FmCard"), He = S("FmStepperField"), Le = S("FmPopover"), De = S("FmLabel"), Jt = S("FmSpacer"), Xt = S("FmTable"), ea = S("FmForm");
|
|
681
|
+
return v(), K(ea, {
|
|
682
|
+
ref_key: "formRef",
|
|
683
|
+
ref: re,
|
|
684
|
+
onReset: t[14] || (t[14] = (ze) => o.value = r(F).PURCHASE),
|
|
685
|
+
onValidationSuccess: t[15] || (t[15] = (ze) => $("validation-success")),
|
|
686
|
+
disabled: E.value
|
|
687
|
+
}, {
|
|
688
|
+
default: U(() => {
|
|
689
|
+
var ze, it, ct, dt;
|
|
690
|
+
return [
|
|
691
|
+
l("div", Xa, [
|
|
692
|
+
l("div", es, [
|
|
693
|
+
ts,
|
|
694
|
+
l("div", as, [
|
|
695
|
+
i(a, {
|
|
696
|
+
label: r(k).currentLocation.name,
|
|
697
|
+
icon: "storefront",
|
|
698
|
+
compact: ""
|
|
699
|
+
}, null, 8, ["label"]),
|
|
700
|
+
(it = (ze = r(P).currentRestaurant) == null ? void 0 : ze.value) != null && it.posVersion ? (v(), K(a, {
|
|
701
|
+
key: 0,
|
|
702
|
+
label: `POS v${(dt = (ct = r(P).currentRestaurant) == null ? void 0 : ct.value) == null ? void 0 : dt.posVersion}`,
|
|
703
|
+
icon: "point_of_sale",
|
|
704
|
+
compact: ""
|
|
705
|
+
}, null, 8, ["label"])) : H("", !0),
|
|
706
|
+
e.lastClosingDate ? (v(), K(a, {
|
|
707
|
+
key: 1,
|
|
708
|
+
label: `Last closing: ${r(Je)(e.lastClosingDate)} ${r(Lt)(e.lastClosingDate)}`,
|
|
709
|
+
icon: "calendar_month",
|
|
710
|
+
compact: ""
|
|
711
|
+
}, null, 8, ["label"])) : H("", !0)
|
|
712
|
+
]),
|
|
713
|
+
ss,
|
|
714
|
+
l("div", os, [
|
|
715
|
+
i(n, {
|
|
716
|
+
items: A,
|
|
717
|
+
rules: [r(Qe)()],
|
|
718
|
+
"label-mark": "required",
|
|
719
|
+
label: "Transfer type",
|
|
720
|
+
"model-value": o.value,
|
|
721
|
+
"onUpdate:modelValue": t[0] || (t[0] = (m) => me(m)),
|
|
722
|
+
disabled: E.value || !w.value,
|
|
723
|
+
"data-cy": "fm-select-transaction-type"
|
|
724
|
+
}, null, 8, ["rules", "model-value", "disabled"]),
|
|
725
|
+
i(n, {
|
|
726
|
+
label: o.value === r(F).PURCHASE ? "Supplier" : "Transfer From",
|
|
727
|
+
items: C.value,
|
|
728
|
+
modelValue: b.value,
|
|
729
|
+
"onUpdate:modelValue": t[1] || (t[1] = (m) => b.value = m),
|
|
730
|
+
disabled: E.value || !w.value,
|
|
731
|
+
rules: [r(Qe)()],
|
|
732
|
+
"label-mark": "required"
|
|
733
|
+
}, {
|
|
734
|
+
"menu-wrapper": U(({ handleItemChange: m }) => [
|
|
735
|
+
(v(!0), T(Re, null, Xe(C.value, (g) => (v(), K(s, {
|
|
736
|
+
key: g.value,
|
|
737
|
+
"model-value": g.value === b.value,
|
|
738
|
+
disabled: g.disabled,
|
|
739
|
+
label: g.label,
|
|
740
|
+
"onUpdate:modelValue": (ie) => m(ie, g)
|
|
741
|
+
}, null, 8, ["model-value", "disabled", "label", "onUpdate:modelValue"]))), 128))
|
|
742
|
+
]),
|
|
743
|
+
_: 1
|
|
744
|
+
}, 8, ["label", "items", "modelValue", "disabled", "rules"]),
|
|
745
|
+
i(c, {
|
|
746
|
+
label: "Reference",
|
|
747
|
+
modelValue: d.value.ref,
|
|
748
|
+
"onUpdate:modelValue": t[2] || (t[2] = (m) => d.value.ref = m),
|
|
749
|
+
"label-mark": "optional",
|
|
750
|
+
disabled: E.value || !w.value
|
|
751
|
+
}, null, 8, ["modelValue", "disabled"]),
|
|
752
|
+
i(u, {
|
|
753
|
+
label: "Remark",
|
|
754
|
+
modelValue: B.value,
|
|
755
|
+
"onUpdate:modelValue": t[3] || (t[3] = (m) => B.value = m),
|
|
756
|
+
"label-mark": "optional",
|
|
757
|
+
"max-length": 240,
|
|
758
|
+
disabled: E.value || !w.value,
|
|
759
|
+
"show-word-count": ""
|
|
760
|
+
}, null, 8, ["modelValue", "disabled"]),
|
|
761
|
+
r(y).enableBackdatePo ? (v(), T("div", ls, [
|
|
762
|
+
l("div", ns, [
|
|
763
|
+
i(f, {
|
|
764
|
+
modelValue: tt.value,
|
|
765
|
+
"onUpdate:modelValue": t[4] || (t[4] = (m) => tt.value = m),
|
|
766
|
+
label: "Backdate transfer",
|
|
767
|
+
sublabel: "Apply transfer to older date",
|
|
768
|
+
"label-placement": "right",
|
|
769
|
+
disabled: E.value || !w.value || ut.value && !e.lastClosingDate
|
|
770
|
+
}, null, 8, ["modelValue", "disabled"]),
|
|
771
|
+
rs,
|
|
772
|
+
tt.value ? (v(), T("div", us, [
|
|
773
|
+
l("div", is, [
|
|
774
|
+
i(x, {
|
|
775
|
+
modelValue: at.value,
|
|
776
|
+
"onUpdate:modelValue": t[5] || (t[5] = (m) => at.value = m)
|
|
777
|
+
}, null, 8, ["modelValue"])
|
|
778
|
+
]),
|
|
779
|
+
l("div", cs, [
|
|
780
|
+
i(V, {
|
|
781
|
+
modelValue: st.value,
|
|
782
|
+
"onUpdate:modelValue": t[6] || (t[6] = (m) => st.value = m)
|
|
783
|
+
}, null, 8, ["modelValue"])
|
|
784
|
+
])
|
|
785
|
+
])) : H("", !0)
|
|
786
|
+
]),
|
|
787
|
+
O.value ? (v(), K(Y, {
|
|
788
|
+
key: 0,
|
|
789
|
+
modelValue: O.value,
|
|
790
|
+
"onUpdate:modelValue": t[7] || (t[7] = (m) => O.value = m),
|
|
791
|
+
rules: [r(Va)(new Date(e.lastClosingDate), /* @__PURE__ */ new Date())]
|
|
792
|
+
}, null, 8, ["modelValue", "rules"])) : H("", !0),
|
|
793
|
+
ut.value && !e.lastClosingDate ? (v(), T("div", ds, [
|
|
794
|
+
i(Z, {
|
|
795
|
+
name: "error",
|
|
796
|
+
size: "sm",
|
|
797
|
+
class: "text-fm-color-typo-warning"
|
|
798
|
+
}),
|
|
799
|
+
ms
|
|
800
|
+
])) : H("", !0)
|
|
801
|
+
])) : H("", !0)
|
|
802
|
+
])
|
|
803
|
+
]),
|
|
804
|
+
l("div", ps, [
|
|
805
|
+
i(Y, {
|
|
806
|
+
"model-value": d.value.items,
|
|
807
|
+
rules: [
|
|
808
|
+
function(g) {
|
|
809
|
+
return g && g.length > 0 || "Must have at least one item!";
|
|
810
|
+
}
|
|
811
|
+
]
|
|
812
|
+
}, {
|
|
813
|
+
default: U(() => {
|
|
814
|
+
var m;
|
|
815
|
+
return [
|
|
816
|
+
l("div", fs, [
|
|
817
|
+
vs,
|
|
818
|
+
o.value === r(F).PURCHASE && w.value && r(y).enableTotalCost ? (v(), T("div", _s, [
|
|
819
|
+
i(f, {
|
|
820
|
+
label: Ie.value ? "Fetching data..." : "Compare price history",
|
|
821
|
+
"prepend-icon": "compare_arrows",
|
|
822
|
+
"label-placement": "right",
|
|
823
|
+
"model-value": se.value,
|
|
824
|
+
"onUpdate:modelValue": t[8] || (t[8] = (g) => se.value = g),
|
|
825
|
+
disabled: Ie.value || !((m = d.value) != null && m.items) || d.value.items.length === 0
|
|
826
|
+
}, null, 8, ["label", "model-value", "disabled"])
|
|
827
|
+
])) : H("", !0)
|
|
828
|
+
])
|
|
829
|
+
];
|
|
830
|
+
}),
|
|
831
|
+
_: 1
|
|
832
|
+
}, 8, ["model-value", "rules"]),
|
|
833
|
+
l("div", ys, [
|
|
834
|
+
i(ue, {
|
|
835
|
+
disabled: E.value || !w.value,
|
|
836
|
+
label: "Add Item",
|
|
837
|
+
"prepend-icon": "add",
|
|
838
|
+
variant: "plain",
|
|
839
|
+
class: "border-2 rounded-lg border-fm-color-primary",
|
|
840
|
+
onClick: t[9] || (t[9] = (m) => ve()),
|
|
841
|
+
size: "md"
|
|
842
|
+
}, null, 8, ["disabled"]),
|
|
843
|
+
i(Le, {
|
|
844
|
+
disabled: E.value || !w.value,
|
|
845
|
+
class: "flex",
|
|
846
|
+
"show-popover": ae.value,
|
|
847
|
+
onPopoverChanged: t[13] || (t[13] = (m) => ae.value = m)
|
|
848
|
+
}, {
|
|
849
|
+
"popover-button": U(() => [
|
|
850
|
+
i(Ne, {
|
|
851
|
+
class: Be([
|
|
852
|
+
"flex justify-center items-center gap-[8px] border-2 py-1 px-12 rounded-lg cursor-not-allowed",
|
|
853
|
+
E.value || !w.value ? " border-fm-color-neutral-gray-200" : "border-fm-color-primary"
|
|
854
|
+
]),
|
|
855
|
+
variant: "flat"
|
|
856
|
+
}, {
|
|
857
|
+
default: U(() => [
|
|
858
|
+
i(ja, {
|
|
859
|
+
size: 24,
|
|
860
|
+
color: E.value || !w.value ? "#c7c7cc" : "#ff7823"
|
|
861
|
+
}, null, 8, ["color"]),
|
|
862
|
+
l("button", {
|
|
863
|
+
type: "button",
|
|
864
|
+
disabled: E.value,
|
|
865
|
+
class: Be([
|
|
866
|
+
"fm-typo-cn-body-lg-600",
|
|
867
|
+
E.value || !w.value ? " text-fm-color-neutral-gray-200 cursor-not-allowed" : "text-fm-color-primary"
|
|
868
|
+
])
|
|
869
|
+
}, " Forecast stock ", 10, gs)
|
|
870
|
+
]),
|
|
871
|
+
_: 1
|
|
872
|
+
}, 8, ["class"])
|
|
873
|
+
]),
|
|
874
|
+
default: U(() => [
|
|
875
|
+
l("div", hs, [
|
|
876
|
+
l("div", bs, [
|
|
877
|
+
i(ga, { "z-index": 99 }, {
|
|
878
|
+
default: U(() => [
|
|
879
|
+
Cs
|
|
880
|
+
]),
|
|
881
|
+
_: 1
|
|
882
|
+
}),
|
|
883
|
+
i(ue, {
|
|
884
|
+
icon: "close",
|
|
885
|
+
size: "md",
|
|
886
|
+
variant: "tertiary",
|
|
887
|
+
onClick: t[10] || (t[10] = (m) => ae.value = !1)
|
|
888
|
+
})
|
|
889
|
+
]),
|
|
890
|
+
i(He, {
|
|
891
|
+
modelValue: ee.value,
|
|
892
|
+
"onUpdate:modelValue": t[11] || (t[11] = (m) => ee.value = m),
|
|
893
|
+
label: "Enter day to forecast stock",
|
|
894
|
+
rules: [r(Ra)(1)]
|
|
895
|
+
}, {
|
|
896
|
+
"helper-text": U(() => [
|
|
897
|
+
l("div", xs, [
|
|
898
|
+
i(Z, {
|
|
899
|
+
name: "warning",
|
|
900
|
+
size: "sm",
|
|
901
|
+
class: "text-fm-color-system-warning-300"
|
|
902
|
+
}),
|
|
903
|
+
ks
|
|
904
|
+
])
|
|
905
|
+
]),
|
|
906
|
+
_: 1
|
|
907
|
+
}, 8, ["modelValue", "rules"]),
|
|
908
|
+
l("div", ws, [
|
|
909
|
+
Ds,
|
|
910
|
+
i(ue, {
|
|
911
|
+
label: "Cancel",
|
|
912
|
+
variant: "tertiary",
|
|
913
|
+
onClick: t[12] || (t[12] = (m) => ae.value = !1)
|
|
914
|
+
}),
|
|
915
|
+
i(ue, {
|
|
916
|
+
label: "Generate",
|
|
917
|
+
onClick: Ae
|
|
918
|
+
})
|
|
919
|
+
])
|
|
920
|
+
])
|
|
921
|
+
]),
|
|
922
|
+
_: 1
|
|
923
|
+
}, 8, ["disabled", "show-popover"])
|
|
924
|
+
]),
|
|
925
|
+
ne.value.length ? (v(), T("div", Ss, [
|
|
926
|
+
(v(), K(Xt, {
|
|
927
|
+
"row-data": ne.value,
|
|
928
|
+
"column-defs": ye.value,
|
|
929
|
+
key: o.value,
|
|
930
|
+
"data-cy": "fm-table-transfer-items",
|
|
931
|
+
"hide-footer": "",
|
|
932
|
+
"page-size": ne.value.length
|
|
933
|
+
}, {
|
|
934
|
+
"table-row": U((m) => {
|
|
935
|
+
var g, ie;
|
|
936
|
+
return [
|
|
937
|
+
l("tr", {
|
|
938
|
+
class: Be(["border-b border-fm-color-neutral-gray-100 hover:bg-fm-color-opacity-sm", {
|
|
939
|
+
"bg-fm-color-neutral-gray-100": m.getIsSelected()
|
|
940
|
+
}])
|
|
941
|
+
}, [
|
|
942
|
+
(v(!0), T(Re, null, Xe(m.getVisibleCells(), (Q) => {
|
|
943
|
+
var Se, ce, Fe, Te;
|
|
944
|
+
return v(), T("td", {
|
|
945
|
+
key: Q.id,
|
|
946
|
+
class: Be([
|
|
947
|
+
"h-[52px] px-16 text-fm-color-typo-primary",
|
|
948
|
+
((Se = qe(Q)) == null ? void 0 : Se.cellClass) ?? "px-16"
|
|
949
|
+
]),
|
|
950
|
+
style: jt({
|
|
951
|
+
width: (ce = qe(Q)) == null ? void 0 : ce.width,
|
|
952
|
+
maxWidth: (Fe = qe(Q)) == null ? void 0 : Fe.maxWidth,
|
|
953
|
+
textAlign: ((Te = qe(Q)) == null ? void 0 : Te.textAlign) ?? "left"
|
|
954
|
+
})
|
|
955
|
+
}, [
|
|
956
|
+
l("span", Fs, [
|
|
957
|
+
i(r(X), {
|
|
958
|
+
render: Q.column.columnDef.cell,
|
|
959
|
+
props: Q.getContext()
|
|
960
|
+
}, null, 8, ["render", "props"])
|
|
961
|
+
])
|
|
962
|
+
], 6);
|
|
963
|
+
}), 128))
|
|
964
|
+
], 2),
|
|
965
|
+
o.value === r(F).PURCHASE && se.value && Object.keys(we.value[(g = m.original.sku) == null ? void 0 : g._id] ?? {}).length > 0 ? (v(), T("tr", Ts, [
|
|
966
|
+
l("td", {
|
|
967
|
+
colspan: m.getVisibleCells().length
|
|
968
|
+
}, [
|
|
969
|
+
i(zt, {
|
|
970
|
+
prices: we.value[(ie = m.original.sku) == null ? void 0 : ie._id]
|
|
971
|
+
}, null, 8, ["prices"])
|
|
972
|
+
], 8, Vs)
|
|
973
|
+
])) : H("", !0)
|
|
974
|
+
];
|
|
975
|
+
}),
|
|
976
|
+
"list-row": U((m) => [
|
|
977
|
+
i(Bt, { row: m }, {
|
|
978
|
+
default: U((g) => {
|
|
979
|
+
var ie, Q, Se, ce, Fe, Te, mt, pt, Ye, ft, vt, _t, yt, je, gt, ht, bt, Ct, Ke, xt, kt, wt, Dt, St, Ft, Ge, Tt, Vt, Rt, Pt, At, We, Ut, $t, Et;
|
|
980
|
+
return [
|
|
981
|
+
l("div", Rs, [
|
|
982
|
+
l("div", Ps, [
|
|
983
|
+
l("div", As, J(m.original.sku.name), 1),
|
|
984
|
+
l("div", null, [
|
|
985
|
+
i(r(X), {
|
|
986
|
+
render: (Se = (Q = (ie = g.Delete) == null ? void 0 : ie.column) == null ? void 0 : Q.columnDef) == null ? void 0 : Se.cell,
|
|
987
|
+
props: (Fe = (ce = g.Delete) == null ? void 0 : ce.getContext) == null ? void 0 : Fe.call(ce)
|
|
988
|
+
}, null, 8, ["render", "props"])
|
|
989
|
+
])
|
|
990
|
+
]),
|
|
991
|
+
l("div", Us, [
|
|
992
|
+
l("div", $s, [
|
|
993
|
+
i(De, { label: "Code" }),
|
|
994
|
+
i(r(X), {
|
|
995
|
+
render: (pt = (mt = (Te = g.code) == null ? void 0 : Te.column) == null ? void 0 : mt.columnDef) == null ? void 0 : pt.cell,
|
|
996
|
+
props: (ft = (Ye = g.code) == null ? void 0 : Ye.getContext) == null ? void 0 : ft.call(Ye)
|
|
997
|
+
}, null, 8, ["render", "props"])
|
|
998
|
+
]),
|
|
999
|
+
l("div", Es, [
|
|
1000
|
+
i(De, { label: "Name" }),
|
|
1001
|
+
i(r(X), {
|
|
1002
|
+
render: (yt = (_t = (vt = g.Name) == null ? void 0 : vt.column) == null ? void 0 : _t.columnDef) == null ? void 0 : yt.cell,
|
|
1003
|
+
props: (gt = (je = g.Name) == null ? void 0 : je.getContext) == null ? void 0 : gt.call(je)
|
|
1004
|
+
}, null, 8, ["render", "props"])
|
|
1005
|
+
]),
|
|
1006
|
+
l("div", Ms, [
|
|
1007
|
+
l("div", Os, [
|
|
1008
|
+
i(De, { label: "Amount" })
|
|
1009
|
+
]),
|
|
1010
|
+
i(r(X), {
|
|
1011
|
+
render: (Ct = (bt = (ht = g.Amount) == null ? void 0 : ht.column) == null ? void 0 : bt.columnDef) == null ? void 0 : Ct.cell,
|
|
1012
|
+
props: (xt = (Ke = g.Amount) == null ? void 0 : Ke.getContext) == null ? void 0 : xt.call(Ke)
|
|
1013
|
+
}, null, 8, ["render", "props"])
|
|
1014
|
+
]),
|
|
1015
|
+
o.value === r(F).PURCHASE && g.Cost ? (v(), T("div", Is, [
|
|
1016
|
+
typeof ((Dt = (wt = (kt = g.Cost) == null ? void 0 : kt.column) == null ? void 0 : wt.columnDef) == null ? void 0 : Dt.header) == "function" ? (v(), T("div", qs, [
|
|
1017
|
+
(v(), K(sa(
|
|
1018
|
+
(Vt = (Ft = (St = g.Cost) == null ? void 0 : St.column) == null ? void 0 : Ft.columnDef) == null ? void 0 : Vt.header(
|
|
1019
|
+
(Tt = (Ge = g.Cost) == null ? void 0 : Ge.getContext) == null ? void 0 : Tt.call(Ge)
|
|
1020
|
+
)
|
|
1021
|
+
)))
|
|
1022
|
+
])) : H("", !0),
|
|
1023
|
+
i(r(X), {
|
|
1024
|
+
render: (At = (Pt = (Rt = g.Cost) == null ? void 0 : Rt.column) == null ? void 0 : Pt.columnDef) == null ? void 0 : At.cell,
|
|
1025
|
+
props: (Ut = (We = g.Cost) == null ? void 0 : We.getContext) == null ? void 0 : Ut.call(We)
|
|
1026
|
+
}, null, 8, ["render", "props"])
|
|
1027
|
+
])) : H("", !0)
|
|
1028
|
+
]),
|
|
1029
|
+
o.value === r(F).PURCHASE && se.value && Object.keys(we.value[($t = m.original.sku) == null ? void 0 : $t._id] ?? {}).length > 0 ? (v(), T(Re, { key: 0 }, [
|
|
1030
|
+
i(Jt, { class: "h-8" }),
|
|
1031
|
+
i(zt, {
|
|
1032
|
+
prices: we.value[(Et = m.original.sku) == null ? void 0 : Et._id]
|
|
1033
|
+
}, null, 8, ["prices"])
|
|
1034
|
+
], 64)) : H("", !0)
|
|
1035
|
+
])
|
|
1036
|
+
];
|
|
1037
|
+
}),
|
|
1038
|
+
_: 2
|
|
1039
|
+
}, 1032, ["row"])
|
|
1040
|
+
]),
|
|
1041
|
+
_: 1
|
|
1042
|
+
}, 8, ["row-data", "column-defs", "page-size"]))
|
|
1043
|
+
])) : H("", !0)
|
|
1044
|
+
])
|
|
1045
|
+
])
|
|
1046
|
+
];
|
|
1047
|
+
}),
|
|
1048
|
+
_: 1
|
|
1049
|
+
}, 8, ["disabled"]);
|
|
1050
|
+
};
|
|
1051
|
+
}
|
|
1052
|
+
}), Hs = { class: "flex items-center" }, Ls = { class: "fm-typo-en-title-md-800" }, zs = { class: "flex gap-4" }, Ys = /* @__PURE__ */ Pe({
|
|
1053
|
+
__name: "TransferDialog",
|
|
1054
|
+
props: {
|
|
1055
|
+
mode: {},
|
|
1056
|
+
modelValue: {},
|
|
1057
|
+
show: { type: Boolean },
|
|
1058
|
+
lastClosingDate: {}
|
|
1059
|
+
},
|
|
1060
|
+
emits: ["update:show", "submitted"],
|
|
1061
|
+
setup(G, { expose: W, emit: te }) {
|
|
1062
|
+
const k = G, M = te, P = Gt(), q = rt(), y = Zt(), h = ra(), _ = nt();
|
|
1063
|
+
async function le(o) {
|
|
1064
|
+
if (o) {
|
|
1065
|
+
$.value = !0;
|
|
1066
|
+
try {
|
|
1067
|
+
await y.readSuppliers(), $.value = !1;
|
|
1068
|
+
} catch {
|
|
1069
|
+
q.open({
|
|
1070
|
+
title: "Unable to fetch list of suppliers",
|
|
1071
|
+
message: "Try to refresh page to retry operation",
|
|
1072
|
+
type: "error"
|
|
1073
|
+
});
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
_.watchLocation(le);
|
|
1078
|
+
const w = ka(k, "show"), z = L(k.modelValue ?? {});
|
|
1079
|
+
be([() => k.modelValue], () => {
|
|
1080
|
+
z.value = k.modelValue ?? {};
|
|
1081
|
+
});
|
|
1082
|
+
const $ = L(!1), d = R(() => {
|
|
1083
|
+
switch (k.mode) {
|
|
1084
|
+
case Ve.CREATE:
|
|
1085
|
+
return "Add transfer";
|
|
1086
|
+
case Ve.READ:
|
|
1087
|
+
return "View transfer";
|
|
1088
|
+
case Ve.UPDATE:
|
|
1089
|
+
return "Edit transfer";
|
|
1090
|
+
}
|
|
1091
|
+
return "";
|
|
1092
|
+
}), B = L();
|
|
1093
|
+
W({
|
|
1094
|
+
validateInputs: () => {
|
|
1095
|
+
var o, p;
|
|
1096
|
+
(p = (o = B.value) == null ? void 0 : o.validateInputs) == null || p.call(o);
|
|
1097
|
+
},
|
|
1098
|
+
resetInputsValidation: () => {
|
|
1099
|
+
var o, p;
|
|
1100
|
+
(p = (o = B.value) == null ? void 0 : o.resetInputsValidation) == null || p.call(o);
|
|
1101
|
+
},
|
|
1102
|
+
resetInputs: () => {
|
|
1103
|
+
var o, p;
|
|
1104
|
+
(p = (o = B.value) == null ? void 0 : o.resetInputs) == null || p.call(o);
|
|
1105
|
+
}
|
|
1106
|
+
});
|
|
1107
|
+
async function E() {
|
|
1108
|
+
const o = z.value;
|
|
1109
|
+
$.value = !0, (o.supplier.internal === "warehouse" || o.supplier.internal === "restaurant") && (o.items = o.items.map(({ totalCost: p, ...C }) => C));
|
|
1110
|
+
try {
|
|
1111
|
+
await P.createPurchaseOrder(o), await new Promise((p) => setTimeout(p, 1e3)), q.open({
|
|
1112
|
+
title: "Created",
|
|
1113
|
+
message: "Your transfer draft has been created!",
|
|
1114
|
+
type: "success"
|
|
1115
|
+
}), M("update:show", !1), M("submitted");
|
|
1116
|
+
} catch (p) {
|
|
1117
|
+
q.open({
|
|
1118
|
+
title: "Cannot create purchase order",
|
|
1119
|
+
message: "Report to system administrator for troubleshooting.",
|
|
1120
|
+
type: "error"
|
|
1121
|
+
}), console.error("Error in creating purchase order", p);
|
|
1122
|
+
} finally {
|
|
1123
|
+
$.value = !1;
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
async function ne() {
|
|
1127
|
+
const o = z.value;
|
|
1128
|
+
$.value = !0, (o.supplier.internal === "warehouse" || o.supplier.internal === "restaurant") && (o.items = o.items.map(({ totalCost: p, ...C }) => C));
|
|
1129
|
+
try {
|
|
1130
|
+
await P.updatePurchaseOrder(o), await new Promise((p) => setTimeout(p, 1e3)), q.open({
|
|
1131
|
+
title: "Updated",
|
|
1132
|
+
message: "Your transfer draft has been updated!",
|
|
1133
|
+
type: "success"
|
|
1134
|
+
}), M("update:show", !1), M("submitted");
|
|
1135
|
+
} catch (p) {
|
|
1136
|
+
q.open({
|
|
1137
|
+
title: "Cannot update purchase order",
|
|
1138
|
+
message: "Report to system administrator for troubleshooting.",
|
|
1139
|
+
type: "error"
|
|
1140
|
+
}), console.error("Error in updating purchase order", p);
|
|
1141
|
+
} finally {
|
|
1142
|
+
$.value = !1;
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
function de() {
|
|
1146
|
+
switch (k.mode) {
|
|
1147
|
+
case Ve.CREATE:
|
|
1148
|
+
return E();
|
|
1149
|
+
case Ve.UPDATE:
|
|
1150
|
+
return ne();
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
function A() {
|
|
1154
|
+
var o, p;
|
|
1155
|
+
(p = (o = B.value) == null ? void 0 : o.validateInputs) == null || p.call(o);
|
|
1156
|
+
}
|
|
1157
|
+
return (o, p) => {
|
|
1158
|
+
const C = S("FmButton"), b = S("FmSideSheet");
|
|
1159
|
+
return v(), K(b, {
|
|
1160
|
+
modelValue: r(w),
|
|
1161
|
+
"onUpdate:modelValue": p[2] || (p[2] = (D) => oa(w) ? w.value = D : null),
|
|
1162
|
+
"dismiss-away": "",
|
|
1163
|
+
"close-button": "",
|
|
1164
|
+
"max-width": 900
|
|
1165
|
+
}, {
|
|
1166
|
+
"side-sheet-header": U(() => [
|
|
1167
|
+
l("div", Hs, [
|
|
1168
|
+
l("div", Ls, J(d.value), 1)
|
|
1169
|
+
])
|
|
1170
|
+
]),
|
|
1171
|
+
default: U(() => [
|
|
1172
|
+
(v(), K(Ns, {
|
|
1173
|
+
class: "w-full",
|
|
1174
|
+
ref_key: "formRef",
|
|
1175
|
+
ref: B,
|
|
1176
|
+
onValidationSuccess: de,
|
|
1177
|
+
modelValue: z.value,
|
|
1178
|
+
"onUpdate:modelValue": p[0] || (p[0] = (D) => z.value = D),
|
|
1179
|
+
disabled: $.value,
|
|
1180
|
+
suppliers: r(y).suppliers,
|
|
1181
|
+
skus: r(h).skus,
|
|
1182
|
+
key: z.value._id ?? "",
|
|
1183
|
+
"last-closing-date": o.lastClosingDate
|
|
1184
|
+
}, null, 8, ["modelValue", "disabled", "suppliers", "skus", "last-closing-date"]))
|
|
1185
|
+
]),
|
|
1186
|
+
"side-sheet-footer": U(() => [
|
|
1187
|
+
l("div", zs, [
|
|
1188
|
+
i(C, {
|
|
1189
|
+
loading: $.value,
|
|
1190
|
+
label: "Save",
|
|
1191
|
+
onClick: A
|
|
1192
|
+
}, null, 8, ["loading"]),
|
|
1193
|
+
i(C, {
|
|
1194
|
+
disabled: $.value,
|
|
1195
|
+
variant: "tertiary",
|
|
1196
|
+
label: "Close",
|
|
1197
|
+
onClick: p[1] || (p[1] = (D) => M("update:show", !1))
|
|
1198
|
+
}, null, 8, ["disabled"])
|
|
1199
|
+
])
|
|
1200
|
+
]),
|
|
1201
|
+
_: 1
|
|
1202
|
+
}, 8, ["modelValue"]);
|
|
1203
|
+
};
|
|
1204
|
+
}
|
|
1205
|
+
}), js = { class: "px-24 xs:p-0 sm:p-0 flex flex-col gap-8 max-h-full" }, Ks = { class: "flex flex-col py-8" }, Gs = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ws = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary line-clamp-1" }, Bs = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary line-clamp-1" }, Zs = {
|
|
1206
|
+
key: 0,
|
|
1207
|
+
class: "fm-typo-en-body-md-400 text-fm-color-typo-primary line-clamp-1"
|
|
1208
|
+
}, Qs = { class: "pt-8" }, Yt = "ReceiveRequestViewSearchCriteria", go = /* @__PURE__ */ Pe({
|
|
1209
|
+
__name: "ReceiveRequestView",
|
|
1210
|
+
setup(G) {
|
|
1211
|
+
const { t: W } = Sa(), te = rt();
|
|
1212
|
+
Ze.object({
|
|
1213
|
+
name: Ze.string().optional().nullable(),
|
|
1214
|
+
startDate: Ze.string().optional().nullable(),
|
|
1215
|
+
endDate: Ze.string().optional().nullable()
|
|
1216
|
+
});
|
|
1217
|
+
const k = ua(), M = Kt();
|
|
1218
|
+
function P() {
|
|
1219
|
+
const A = {
|
|
1220
|
+
name: "",
|
|
1221
|
+
...qt()
|
|
1222
|
+
}, o = k.getItem(Yt);
|
|
1223
|
+
if (!o)
|
|
1224
|
+
return A;
|
|
1225
|
+
try {
|
|
1226
|
+
return JSON.parse(o);
|
|
1227
|
+
} catch {
|
|
1228
|
+
return A;
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
function q() {
|
|
1232
|
+
k.setItem(Yt, JSON.stringify(y.value));
|
|
1233
|
+
}
|
|
1234
|
+
const y = L(P()), h = ma("receive/request", y.value), { columnDefs: _ } = pa("receive/request", h), le = nt();
|
|
1235
|
+
async function w() {
|
|
1236
|
+
const A = `inventory-record_${Nt(y.value.startDate).format("DD-MM-YYYY_HH-mm")}-${Nt(y.value.endDate).format("DD-MM-YYYY_HH-mm")}.xlsx`, o = h.purchaseOrders.value.flatMap(
|
|
1237
|
+
(C) => C.items.map((b) => {
|
|
1238
|
+
const D = new Date(ba(C._id) ?? ""), N = C.effectiveAt ? new Date(C.effectiveAt) : void 0, me = j(
|
|
1239
|
+
va(b.sku, C.deliveryOrder || [])
|
|
1240
|
+
), pe = j(b.quantity);
|
|
1241
|
+
return {
|
|
1242
|
+
"SKU code": b.code,
|
|
1243
|
+
"SKU name": b.name,
|
|
1244
|
+
"PO #": C.seqNumber,
|
|
1245
|
+
"Effective at": N,
|
|
1246
|
+
Date: D,
|
|
1247
|
+
Status: C.status,
|
|
1248
|
+
Reference: C.ref ?? "",
|
|
1249
|
+
"Received quantity": me,
|
|
1250
|
+
"Ordered quantity": pe,
|
|
1251
|
+
Unit: b.sku.unit.abbrev,
|
|
1252
|
+
"Total cost": b.totalCost ? Wt(b.totalCost) : null
|
|
1253
|
+
};
|
|
1254
|
+
})
|
|
1255
|
+
), p = [
|
|
1256
|
+
"SKU code",
|
|
1257
|
+
"SKU name",
|
|
1258
|
+
"PO #",
|
|
1259
|
+
"Date",
|
|
1260
|
+
"Status",
|
|
1261
|
+
"Reference",
|
|
1262
|
+
"Received quantity",
|
|
1263
|
+
"Ordered quantity",
|
|
1264
|
+
"Unit"
|
|
1265
|
+
];
|
|
1266
|
+
M.enableBackdatePo && p.insert("Effective at", 4), M.enableTotalCost && p.push("Total cost"), await Ca(
|
|
1267
|
+
[
|
|
1268
|
+
{
|
|
1269
|
+
name: "purchases",
|
|
1270
|
+
data: o,
|
|
1271
|
+
columns: p
|
|
1272
|
+
}
|
|
1273
|
+
],
|
|
1274
|
+
A
|
|
1275
|
+
), te.open({
|
|
1276
|
+
title: W("inventory.transfer.receiveRequest.export.success"),
|
|
1277
|
+
message: W("inventory.transfer.receiveRequest.export.message", [A]),
|
|
1278
|
+
type: "success"
|
|
1279
|
+
});
|
|
1280
|
+
}
|
|
1281
|
+
const z = L(qt()), $ = L("");
|
|
1282
|
+
be([() => z.value], ([A]) => {
|
|
1283
|
+
!A.startDate || !A.endDate || (y.value.startDate = A.startDate, y.value.endDate = A.endDate, h.updateDateRange(
|
|
1284
|
+
y.value.startDate,
|
|
1285
|
+
y.value.endDate
|
|
1286
|
+
), q());
|
|
1287
|
+
}), be([() => $.value], () => {
|
|
1288
|
+
q();
|
|
1289
|
+
});
|
|
1290
|
+
function d(A) {
|
|
1291
|
+
A === "create" && h.promptCreateTransferDialog();
|
|
1292
|
+
}
|
|
1293
|
+
const { breakpoints: B } = wa(), E = R(() => B.value.xs || B.value.sm ? 10 : 20), ne = Ta(), de = R(() => [
|
|
1294
|
+
{
|
|
1295
|
+
icon: "refresh",
|
|
1296
|
+
onClick: h.fetchData
|
|
1297
|
+
},
|
|
1298
|
+
{
|
|
1299
|
+
icon: "ios_share",
|
|
1300
|
+
onClick: w
|
|
1301
|
+
}
|
|
1302
|
+
]);
|
|
1303
|
+
return (A, o) => {
|
|
1304
|
+
const p = S("FmTable");
|
|
1305
|
+
return v(), K(ia, {
|
|
1306
|
+
title: r(W)("inventory.transfer.receiveRequest.title2"),
|
|
1307
|
+
actions: [
|
|
1308
|
+
{
|
|
1309
|
+
label: r(W)("inventory.transfer.receiveRequest.actions.create"),
|
|
1310
|
+
value: "create",
|
|
1311
|
+
isPrimary: !0,
|
|
1312
|
+
prependIcon: "add"
|
|
1313
|
+
}
|
|
1314
|
+
],
|
|
1315
|
+
"onClick:action": d
|
|
1316
|
+
}, {
|
|
1317
|
+
default: U(() => {
|
|
1318
|
+
var C;
|
|
1319
|
+
return [
|
|
1320
|
+
l("div", js, [
|
|
1321
|
+
i(ca, {
|
|
1322
|
+
"date-range-query": "",
|
|
1323
|
+
"date-range": z.value,
|
|
1324
|
+
"onUpdate:dateRange": o[0] || (o[0] = (b) => z.value = b),
|
|
1325
|
+
searchable: "",
|
|
1326
|
+
"change-location": "",
|
|
1327
|
+
search: $.value,
|
|
1328
|
+
"onUpdate:search": o[1] || (o[1] = (b) => $.value = b),
|
|
1329
|
+
actions: de.value
|
|
1330
|
+
}, null, 8, ["date-range", "search", "actions"]),
|
|
1331
|
+
(v(), K(p, {
|
|
1332
|
+
style: jt(r(ne).tableHeight),
|
|
1333
|
+
"column-defs": r(_),
|
|
1334
|
+
"row-data": r(h).purchaseOrders.value,
|
|
1335
|
+
"search-value": $.value,
|
|
1336
|
+
loading: !r(le)._currentLocation || r(h).loading.value,
|
|
1337
|
+
onRowClick: o[2] || (o[2] = (b) => r(h).promptShowTransferDetails(b.original)),
|
|
1338
|
+
key: (C = r(le)._currentLocation) == null ? void 0 : C.dbName,
|
|
1339
|
+
"page-size": E.value
|
|
1340
|
+
}, {
|
|
1341
|
+
"list-row": U((b) => [
|
|
1342
|
+
i(Bt, {
|
|
1343
|
+
row: b,
|
|
1344
|
+
onRowClick: r(h).promptShowTransferDetails
|
|
1345
|
+
}, {
|
|
1346
|
+
default: U((D) => {
|
|
1347
|
+
var N, me, pe, ee, ae, Ce, Ae, fe, ve, Ue, $e, Ee, Me, _e, Oe, et, xe, ke, ye, re;
|
|
1348
|
+
return [
|
|
1349
|
+
l("div", Ks, [
|
|
1350
|
+
l("div", Gs, [
|
|
1351
|
+
i(r(X), {
|
|
1352
|
+
render: (pe = (me = (N = D._id) == null ? void 0 : N.column) == null ? void 0 : me.columnDef) == null ? void 0 : pe.cell,
|
|
1353
|
+
props: (ae = (ee = D._id) == null ? void 0 : ee.getContext) == null ? void 0 : ae.call(ee)
|
|
1354
|
+
}, null, 8, ["render", "props"])
|
|
1355
|
+
]),
|
|
1356
|
+
l("div", Ws, [
|
|
1357
|
+
i(r(X), {
|
|
1358
|
+
render: (fe = (Ae = (Ce = D.supplier_name) == null ? void 0 : Ce.column) == null ? void 0 : Ae.columnDef) == null ? void 0 : fe.cell,
|
|
1359
|
+
props: (Ue = (ve = D.supplier_name) == null ? void 0 : ve.getContext) == null ? void 0 : Ue.call(ve)
|
|
1360
|
+
}, null, 8, ["render", "props"])
|
|
1361
|
+
]),
|
|
1362
|
+
l("div", Bs, J(b.original.items.map((se) => `${se.name}`).join(", ")), 1),
|
|
1363
|
+
b.original.ref ? (v(), T("div", Zs, [
|
|
1364
|
+
i(r(X), {
|
|
1365
|
+
render: (Me = (Ee = ($e = D.ref) == null ? void 0 : $e.column) == null ? void 0 : Ee.columnDef) == null ? void 0 : Me.cell,
|
|
1366
|
+
props: (Oe = (_e = D.ref) == null ? void 0 : _e.getContext) == null ? void 0 : Oe.call(_e)
|
|
1367
|
+
}, null, 8, ["render", "props"])
|
|
1368
|
+
])) : H("", !0),
|
|
1369
|
+
l("div", Qs, [
|
|
1370
|
+
i(r(X), {
|
|
1371
|
+
render: (ke = (xe = (et = D.status) == null ? void 0 : et.column) == null ? void 0 : xe.columnDef) == null ? void 0 : ke.cell,
|
|
1372
|
+
props: (re = (ye = D.status) == null ? void 0 : ye.getContext) == null ? void 0 : re.call(ye)
|
|
1373
|
+
}, null, 8, ["render", "props"])
|
|
1374
|
+
])
|
|
1375
|
+
])
|
|
1376
|
+
];
|
|
1377
|
+
}),
|
|
1378
|
+
_: 2
|
|
1379
|
+
}, 1032, ["row", "onRowClick"])
|
|
1380
|
+
]),
|
|
1381
|
+
_: 1
|
|
1382
|
+
}, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
|
|
1383
|
+
]),
|
|
1384
|
+
(v(), K(la, { to: "body" }, [
|
|
1385
|
+
i(Ys, It(r(h).transferDialogProps.value, {
|
|
1386
|
+
onSubmitted: r(h).fetchData
|
|
1387
|
+
}), null, 16, ["onSubmitted"]),
|
|
1388
|
+
i(fa, It(r(h).transferDetailsProps.value, {
|
|
1389
|
+
onSubmitted: r(h).fetchData
|
|
1390
|
+
}), null, 16, ["onSubmitted"])
|
|
1391
|
+
]))
|
|
1392
|
+
];
|
|
1393
|
+
}),
|
|
1394
|
+
_: 1
|
|
1395
|
+
}, 8, ["title", "actions"]);
|
|
1396
|
+
};
|
|
1397
|
+
}
|
|
1398
|
+
});
|
|
1399
|
+
export {
|
|
1400
|
+
go as default
|
|
1401
|
+
};
|