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