@feedmepos/mf-inventory-portal 0.0.19-dev.6 → 0.0.19-dev.9
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-CzKLgsJ9.js → ApprovalView-Bcxk6B7K.js} +5 -5
- package/dist/{BindingsDialog-D7CWodmi.js → BindingsDialog-XDkcjW_c.js} +6 -6
- package/dist/{BindingsPicker-Dxavpg09.js → BindingsPicker-CgbiqX72.js} +6 -6
- package/dist/{BindingsTable-BQEyLG4F.js → BindingsTable-xNXNsBAd.js} +1 -1
- package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-4EAZjYHf.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DFPkUHl-.js} +1 -1
- package/dist/{IngredientsView-DLeVfaAy.js → IngredientsView-DD7ns3mP.js} +4 -4
- package/dist/{IntegrationView-CZTl4lcU.js → IntegrationView-CErHEVAO.js} +2 -2
- package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CEhOhALE.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-XXoPyhlc.js} +1 -1
- package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-CCD2yMHJ.js → PremiumBadge.vue_vue_type_script_setup_true_lang-BpyUheXn.js} +1 -1
- package/dist/{PurchaseOrderPrintPreview-pVhvi2XF.js → PurchaseOrderPrintPreview-L_iaaURb.js} +1 -1
- package/dist/{ReceiveRequestView-CzsOfdV4.js → ReceiveRequestView-BKbeFDxm.js} +7 -7
- package/dist/{RecipeView-DsTG2guX.js → RecipeView-Drp4l4gL.js} +4 -4
- package/dist/{StockView-ruZ30kOE.js → StockView-Cj6fErwD.js} +7 -7
- package/dist/{SupplierView-BT9IfLzB.js → SupplierView-EFsHWet-.js} +4 -4
- package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-BUArpD4v.js → TransferDetails.vue_vue_type_script_setup_true_lang-kM5fyqq6.js} +4 -4
- package/dist/TransferDialog.vue_vue_type_script_setup_true_lang-CyFMCmXw.js +1605 -0
- package/dist/TransferTemplateView-Cymhrayh.js +933 -0
- package/dist/{UnitView-sSGMkQo5.js → UnitView-C_tAxIpq.js} +5 -5
- package/dist/{WarehouseView-B2ueU0Oq.js → WarehouseView-BAqVtbD6.js} +3 -3
- package/dist/{app-D8_IIKxj.js → app-CeUU5Gd8.js} +139 -138
- package/dist/app.d.ts +3 -1
- package/dist/app.js +1 -1
- package/dist/{decimal-BbpHeqMX.js → decimal-D3KXLC4T.js} +1 -1
- package/dist/{id-to-date-DNUSJ_a1.js → id-to-date-Cj02m808.js} +1 -1
- package/dist/{layout-D-dTwEwF.js → layout-2zzAZIVO.js} +1 -1
- package/dist/{purchase-order-transaction-type-M-fz1Vrz.js → purchase-order-transaction-type-Dz0YF5qh.js} +3 -4
- package/dist/style.css +1 -1
- package/dist/{supplier-tz4ui5Tz.js → supplier-mDVKd7Ge.js} +1 -1
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/dist/views/receive-request/components/transfer-form/TransferForm2.vue.d.ts +16 -0
- package/dist/views/receive-request/components/transfer-form/TransferFormProps.d.ts +1 -1
- package/dist/views/receive-request/components/transfer-form/components/ForecastStock.vue.d.ts +187 -0
- package/dist/views/receive-request/components/transfer-form/components/TransferItem.vue.d.ts +23 -0
- package/dist/views/receive-request/components/transfer-form/components/TransferItemTable.vue.d.ts +21 -0
- package/dist/views/receive-request/components/transfer-form/composables/use-backdate-po.d.ts +9 -0
- package/dist/views/receive-request/components/transfer-form/composables/use-compare-price.d.ts +6 -0
- package/dist/views/receive-request/components/transfer-form/composables/use-transfer-items.d.ts +111 -0
- package/dist/views/receive-request/helper/get-transfer-type.d.ts +2 -0
- package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.d.ts +1 -1
- package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +1 -0
- package/dist/{xlsx-CjvXXGPi.js → xlsx-B-2KyDJq.js} +1 -1
- package/dist/{xlsx.util-CTgyjOr7.js → xlsx.util-D6EzRE71.js} +2 -2
- package/package.json +3 -3
- package/dist/TransferDialog.vue_vue_type_script_setup_true_lang-DqaAbttB.js +0 -1269
- package/dist/TransferTemplateView-CXafUQyI.js +0 -1130
|
@@ -0,0 +1,1605 @@
|
|
|
1
|
+
import { reactive as Be, onMounted as Ue, computed as F, h as V, getCurrentInstance as $e, watch as fe, defineComponent as oe, openBlock as T, createElementBlock as $, Fragment as ue, renderList as ge, createElementVNode as u, toDisplayString as M, unref as n, resolveComponent as P, createVNode as C, withCtx as D, createCommentVNode as z, ref as B, createBlock as E, normalizeClass as Ae, normalizeStyle as Ge, isRef as re } from "vue";
|
|
2
|
+
import { useBreakpoints as Je, components as X, FmButtonVariant as Ce, useSnackbar as ye, useDialog as Oe, useProxiedModel as Xe } from "@feedmepos/ui-library";
|
|
3
|
+
import { F as te, D as De, R as ie } from "./row-action.enum-7jVyol1k.js";
|
|
4
|
+
import { P as x, u as et, f as tt, a as Ee } from "./purchase-order-transaction-type-Dz0YF5qh.js";
|
|
5
|
+
import { a as j, t as ot, a2 as ke, D as st, b as Me, R as Ie, $ as at, a0 as nt, r as rt, G as Le, l as lt, A as Te, M as it, a3 as Ne, c as qe, a5 as ut, O as xe, P as we, a6 as ct, j as K, a7 as dt, u as Se, n as pt, a8 as mt, a9 as ft, aa as yt, E as vt, ab as ht, y as _t } from "./app-CeUU5Gd8.js";
|
|
6
|
+
import { _ as He, u as bt } from "./PremiumBadge.vue_vue_type_script_setup_true_lang-BpyUheXn.js";
|
|
7
|
+
import { useI18n as ce } from "@feedmepos/mf-common";
|
|
8
|
+
import "vue-router";
|
|
9
|
+
import { u as ve } from "./supplier-mDVKd7Ge.js";
|
|
10
|
+
import { F as le, c as gt, _ as Ct } from "./layout-2zzAZIVO.js";
|
|
11
|
+
import { _ as kt } from "./PreviewBadge.vue_vue_type_script_setup_true_lang-CRZiQHjx.js";
|
|
12
|
+
import { defineStore as wt } from "pinia";
|
|
13
|
+
function ee(t, d, s, e) {
|
|
14
|
+
var b, f, i;
|
|
15
|
+
if (e != null && e.manualTotalCost)
|
|
16
|
+
return e == null ? void 0 : e.manualTotalCost;
|
|
17
|
+
const l = (i = (f = (b = e == null ? void 0 : e.supplier) == null ? void 0 : b.supplyItems) == null ? void 0 : f.find(
|
|
18
|
+
(y) => y.skuId === t._id
|
|
19
|
+
)) == null ? void 0 : i.defaultCost, m = t.defaultCost, p = l ?? m, k = p == null ? void 0 : p.costPerUnit, v = k ? p != null && p.measurement ? +j(k) / +j(p == null ? void 0 : p.measurement.conversion) : +j(k) : void 0, o = v ? s ? v * +j(s.conversion) : v : void 0, a = o ? +j(d) * o : void 0;
|
|
20
|
+
return a ? {
|
|
21
|
+
...ot(a ?? 0, 2),
|
|
22
|
+
currency: ke()
|
|
23
|
+
} : {
|
|
24
|
+
amount: 1,
|
|
25
|
+
precision: 0,
|
|
26
|
+
currency: ke()
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
var R = /* @__PURE__ */ ((t) => (t.Code = "Code", t.Name = "Name", t.Amount = "Amount", t.Cost = "Cost", t.Delete = "Delete", t))(R || {});
|
|
30
|
+
const Tt = () => {
|
|
31
|
+
const { t } = ce();
|
|
32
|
+
return V(
|
|
33
|
+
He,
|
|
34
|
+
{
|
|
35
|
+
zIndex: 50,
|
|
36
|
+
class: "whitespace-nowrap"
|
|
37
|
+
},
|
|
38
|
+
t("inventory.transfer.form.items.table.Cost", [Ne()])
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
function xt(t) {
|
|
42
|
+
const { t: d } = ce(), s = Be({}), { breakpoints: e } = Je(), l = Me();
|
|
43
|
+
Ue(() => {
|
|
44
|
+
for (const v of t.items) {
|
|
45
|
+
if (!v.totalCost)
|
|
46
|
+
continue;
|
|
47
|
+
const o = ee(v.sku, v.quantity, v.measurement, {
|
|
48
|
+
supplier: t.supplier
|
|
49
|
+
}), a = v.totalCost ?? st.reset();
|
|
50
|
+
o ? s[v.sku._id] = o.amount !== a.amount || o.precision !== a.precision : s[v.sku._id] = !0;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
function m(v) {
|
|
54
|
+
var a, r;
|
|
55
|
+
return !!(v.defaultCost ?? ((r = (a = t.supplier) == null ? void 0 : a.supplyItems) == null ? void 0 : r.find((b) => b.skuId === v._id)));
|
|
56
|
+
}
|
|
57
|
+
const p = [
|
|
58
|
+
{
|
|
59
|
+
id: "Code",
|
|
60
|
+
header: () => d("inventory.transfer.form.items.table.Code"),
|
|
61
|
+
accessorKey: "code",
|
|
62
|
+
size: 96,
|
|
63
|
+
cell(v) {
|
|
64
|
+
const o = v.row.original;
|
|
65
|
+
return V(X.FmTextField, {
|
|
66
|
+
modelValue: o.code,
|
|
67
|
+
"onUpdate:modelValue": (a) => {
|
|
68
|
+
t.updateItem({
|
|
69
|
+
...o,
|
|
70
|
+
code: a
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
key: o.sku._id,
|
|
74
|
+
rules: [Ie()],
|
|
75
|
+
labelMark: "required"
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
enableSorting: !1
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
id: "Name",
|
|
82
|
+
header: () => d("inventory.transfer.form.items.table.Name"),
|
|
83
|
+
minSize: 300,
|
|
84
|
+
cell(v) {
|
|
85
|
+
const o = v.row.original;
|
|
86
|
+
return V(X.FmTextField, {
|
|
87
|
+
modelValue: o.name,
|
|
88
|
+
"onUpdate:modelValue": (a) => {
|
|
89
|
+
t.updateItem({
|
|
90
|
+
...o,
|
|
91
|
+
name: a
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
key: o.sku._id,
|
|
95
|
+
rules: [Ie()],
|
|
96
|
+
labelMark: "required"
|
|
97
|
+
});
|
|
98
|
+
},
|
|
99
|
+
enableSorting: !1
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
id: "Amount",
|
|
103
|
+
header: () => d("inventory.transfer.form.items.table.Amount"),
|
|
104
|
+
minSize: 200,
|
|
105
|
+
cell(v) {
|
|
106
|
+
const o = v.row.original;
|
|
107
|
+
return V(at, {
|
|
108
|
+
style: {
|
|
109
|
+
flex: "1 1 0%"
|
|
110
|
+
},
|
|
111
|
+
modelValue: {
|
|
112
|
+
amount: o.quantity ?? { amount: 1, precision: 0 },
|
|
113
|
+
measurement: o.measurement ?? null
|
|
114
|
+
},
|
|
115
|
+
key: o.sku._id,
|
|
116
|
+
unit: o.sku.unit,
|
|
117
|
+
"onUpdate:modelValue": (a) => {
|
|
118
|
+
const r = {
|
|
119
|
+
...o,
|
|
120
|
+
quantity: a.amount,
|
|
121
|
+
measurement: a.measurement
|
|
122
|
+
};
|
|
123
|
+
l.enableTotalCost && (r.totalCost = ee(o.sku, o.quantity, o.measurement, {
|
|
124
|
+
supplier: t.supplier,
|
|
125
|
+
// NOTE: set undefined here if `manualTotalCost[row.sku._id] = false`, so that the function
|
|
126
|
+
// will return the auto calculated default cost instead of the manual total cost
|
|
127
|
+
manualTotalCost: s[o.sku._id] ? r.totalCost : void 0
|
|
128
|
+
})), t.updateItem(r);
|
|
129
|
+
},
|
|
130
|
+
stepper: o.quantityStep,
|
|
131
|
+
disableUnit: !!t.template,
|
|
132
|
+
rules: [
|
|
133
|
+
nt(
|
|
134
|
+
+j(
|
|
135
|
+
o.minimumQuantity ?? {
|
|
136
|
+
amount: 1,
|
|
137
|
+
precision: rt(o.sku.unit, o.measurement)
|
|
138
|
+
}
|
|
139
|
+
)
|
|
140
|
+
)
|
|
141
|
+
],
|
|
142
|
+
applyDefaultRules: !0
|
|
143
|
+
});
|
|
144
|
+
},
|
|
145
|
+
enableSorting: !1
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
id: "Cost",
|
|
149
|
+
header: Tt,
|
|
150
|
+
size: 180,
|
|
151
|
+
cell(v) {
|
|
152
|
+
const o = v.row.original, a = m(o.sku), r = e.value.xs || e.value.sm;
|
|
153
|
+
return !s[o.sku._id] && a ? V(
|
|
154
|
+
"div",
|
|
155
|
+
{
|
|
156
|
+
class: "flex gap-4 fm-typo-en-body-md-400 items-center",
|
|
157
|
+
key: o.sku._id
|
|
158
|
+
},
|
|
159
|
+
[
|
|
160
|
+
V(X.FmButton, {
|
|
161
|
+
prependIcon: "edit",
|
|
162
|
+
variant: Ce.Tertiary,
|
|
163
|
+
onClick() {
|
|
164
|
+
t.updateItem({
|
|
165
|
+
...o,
|
|
166
|
+
totalCost: ee(o.sku, o.quantity, o.measurement, {
|
|
167
|
+
supplier: t.supplier
|
|
168
|
+
})
|
|
169
|
+
}), s[o.sku._id] = !0;
|
|
170
|
+
}
|
|
171
|
+
}),
|
|
172
|
+
V(
|
|
173
|
+
"div",
|
|
174
|
+
{
|
|
175
|
+
class: "flex flex-col"
|
|
176
|
+
},
|
|
177
|
+
[
|
|
178
|
+
V(
|
|
179
|
+
"span",
|
|
180
|
+
r ? Le(
|
|
181
|
+
ee(o.sku, o.quantity, o.measurement, {
|
|
182
|
+
supplier: t.supplier
|
|
183
|
+
})
|
|
184
|
+
) : j(
|
|
185
|
+
ee(o.sku, o.quantity, o.measurement, {
|
|
186
|
+
supplier: t.supplier
|
|
187
|
+
})
|
|
188
|
+
)
|
|
189
|
+
),
|
|
190
|
+
V(
|
|
191
|
+
"span",
|
|
192
|
+
{
|
|
193
|
+
class: "fm-typo-en-body-sm-400 text-fm-color-neutral-gray-400"
|
|
194
|
+
},
|
|
195
|
+
"Auto-calculated"
|
|
196
|
+
)
|
|
197
|
+
]
|
|
198
|
+
)
|
|
199
|
+
]
|
|
200
|
+
) : V(
|
|
201
|
+
X.FmTextField,
|
|
202
|
+
{
|
|
203
|
+
modelValue: j(o.totalCost ?? { amount: 0, precision: 0 }),
|
|
204
|
+
key: o.sku._id,
|
|
205
|
+
"onUpdate:modelValue": (b) => {
|
|
206
|
+
t.updateItem({
|
|
207
|
+
...o,
|
|
208
|
+
totalCost: {
|
|
209
|
+
...lt(+b),
|
|
210
|
+
currency: ke()
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
},
|
|
214
|
+
rules: [Te(0), it(2)]
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
prepend() {
|
|
218
|
+
return r ? V("div", { class: "text-fm-typo-en-body-lg-400" }, Ne()) : null;
|
|
219
|
+
},
|
|
220
|
+
append() {
|
|
221
|
+
return a ? V(X.FmButton, {
|
|
222
|
+
prependIcon: "close",
|
|
223
|
+
variant: "tertiary",
|
|
224
|
+
onClick() {
|
|
225
|
+
t.updateItem({
|
|
226
|
+
...o,
|
|
227
|
+
// NOTE: different from PO template, if a default cost is reenabled,
|
|
228
|
+
// the total cost will automatically assigned
|
|
229
|
+
totalCost: ee(o.sku, o.quantity, o.measurement, {
|
|
230
|
+
supplier: t.supplier
|
|
231
|
+
})
|
|
232
|
+
}), s[o.sku._id] = !1;
|
|
233
|
+
}
|
|
234
|
+
}) : null;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
);
|
|
238
|
+
},
|
|
239
|
+
enableSorting: !1
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
id: "Delete",
|
|
243
|
+
header: "",
|
|
244
|
+
cell(v) {
|
|
245
|
+
const o = v.row.original;
|
|
246
|
+
return V(X.FmButton, {
|
|
247
|
+
key: o.sku._id,
|
|
248
|
+
class: "delete-button",
|
|
249
|
+
type: "button",
|
|
250
|
+
icon: "delete",
|
|
251
|
+
variant: "tertiary",
|
|
252
|
+
size: "md",
|
|
253
|
+
onClick: () => {
|
|
254
|
+
t.deleteItem(o);
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
},
|
|
258
|
+
enableSorting: !1,
|
|
259
|
+
size: 40,
|
|
260
|
+
meta: {
|
|
261
|
+
cellClass: "",
|
|
262
|
+
headerClass: ""
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
];
|
|
266
|
+
return {
|
|
267
|
+
columnDefs: F(() => l.enableTotalCost && t.transferType === x.PURCHASE ? p : p.filter(
|
|
268
|
+
(v) => v.id !== "Cost"
|
|
269
|
+
/* Cost */
|
|
270
|
+
))
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
function St(t = "modelValue") {
|
|
274
|
+
var m, p;
|
|
275
|
+
const d = ((m = $e()) == null ? void 0 : m.props) ?? {}, s = ((p = $e()) == null ? void 0 : p.emit) ?? (() => {
|
|
276
|
+
}), e = Be(qe(d[t])), l = `update:${ut(t)}`;
|
|
277
|
+
return fe(e, (k) => {
|
|
278
|
+
s(l, k);
|
|
279
|
+
}), e;
|
|
280
|
+
}
|
|
281
|
+
const Pt = { class: "flex flex-col gap-8 px-16 xs:px-4 sm:px-4 py-4 items-center" }, Ft = { class: "fm-typo-en-body-lg-600 xs:fm-typo-en-body-md-600 mr-auto xs:w-full" }, $t = { class: "w-[450px] xs:w-full flex" }, At = { class: "fm-typo-en-body-md-400 whitespace-nowrap" }, Dt = /* @__PURE__ */ u("span", { class: "text-fm-color-typo-secondary" }, "/", -1), It = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Vt = /* @__PURE__ */ u("span", null, /* @__PURE__ */ M(" "), -1), ze = /* @__PURE__ */ oe({
|
|
282
|
+
__name: "SupplierPriceHistory",
|
|
283
|
+
props: {
|
|
284
|
+
prices: {}
|
|
285
|
+
},
|
|
286
|
+
setup(t) {
|
|
287
|
+
const d = ve();
|
|
288
|
+
function s(e) {
|
|
289
|
+
return d.suppliers.find((l) => l._id === e);
|
|
290
|
+
}
|
|
291
|
+
return (e, l) => (T(), $("div", Pt, [
|
|
292
|
+
(T(!0), $(ue, null, ge(Object.keys(e.prices), (m) => {
|
|
293
|
+
var p;
|
|
294
|
+
return T(), $("div", {
|
|
295
|
+
key: m,
|
|
296
|
+
class: "flex items-center gap-12 xs:gap-4 xs:flex-wrap w-full"
|
|
297
|
+
}, [
|
|
298
|
+
u("div", Ft, M((p = s(m)) == null ? void 0 : p.name), 1),
|
|
299
|
+
u("div", $t, [
|
|
300
|
+
(T(!0), $(ue, null, ge(e.prices[m].slice(0, 3), (k) => {
|
|
301
|
+
var v;
|
|
302
|
+
return T(), $("div", {
|
|
303
|
+
key: k.date,
|
|
304
|
+
class: "flex flex-col w-[150px] xs:flex-1 text-ellipsis cursor-pointer"
|
|
305
|
+
}, [
|
|
306
|
+
u("div", At, [
|
|
307
|
+
u("span", null, M(k.totalCost ? n(Le)(k.totalCost) : "No data"), 1),
|
|
308
|
+
Dt,
|
|
309
|
+
u("span", null, M(n(j)(k.totalUnit, !1)), 1),
|
|
310
|
+
u("span", null, M(((v = k.measurement) == null ? void 0 : v.abbrev) ?? k.unit.abbrev), 1)
|
|
311
|
+
]),
|
|
312
|
+
u("div", It, [
|
|
313
|
+
u("span", null, "(#" + M(k.seqNumber) + ")", 1),
|
|
314
|
+
Vt,
|
|
315
|
+
u("span", null, M(n(xe)(new Date(k.date))), 1)
|
|
316
|
+
])
|
|
317
|
+
]);
|
|
318
|
+
}), 128))
|
|
319
|
+
])
|
|
320
|
+
]);
|
|
321
|
+
}), 128))
|
|
322
|
+
]));
|
|
323
|
+
}
|
|
324
|
+
}), Rt = { class: "flex flex-col gap-8 py-16" }, Bt = { class: "flex items-center" }, Ut = { class: "flex-1 flex gap-1 items-center" }, Ot = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Et = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Mt = { class: "flex gap-8 w-full" }, Lt = { class: "flex-1 flex flex-col gap-4" }, Nt = /* @__PURE__ */ u("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1), qt = { class: "flex-1 flex flex-col gap-4" }, Ht = /* @__PURE__ */ u("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1), zt = { class: "flex gap-8 w-full" }, jt = { class: "flex-1 flex flex-col gap-4" }, Kt = /* @__PURE__ */ u("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1), Yt = { class: "flex-1 flex flex-col gap-4" }, Wt = /* @__PURE__ */ u("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1), Zt = /* @__PURE__ */ oe({
|
|
325
|
+
__name: "TransferItem",
|
|
326
|
+
props: {
|
|
327
|
+
cellByColId: {},
|
|
328
|
+
comparePriceBySku: {},
|
|
329
|
+
showComparePrice: { type: Boolean },
|
|
330
|
+
row: {}
|
|
331
|
+
},
|
|
332
|
+
setup(t) {
|
|
333
|
+
const { t: d } = ce();
|
|
334
|
+
return (s, e) => {
|
|
335
|
+
var p, k, v, o, a, r, b, f, i, y, S, I, Z, O, L, Y, N, h, g, U, q, H, de, se, he, c, _;
|
|
336
|
+
const l = P("FmLabel"), m = P("FmSpacer");
|
|
337
|
+
return T(), $("div", Rt, [
|
|
338
|
+
u("div", Bt, [
|
|
339
|
+
u("div", Ut, [
|
|
340
|
+
u("span", Ot, " (" + M(s.row.original.sku.code) + ") ", 1),
|
|
341
|
+
u("span", Et, M(s.row.original.sku.name), 1)
|
|
342
|
+
]),
|
|
343
|
+
u("div", null, [
|
|
344
|
+
C(n(le), {
|
|
345
|
+
render: (v = (k = (p = s.cellByColId.Delete) == null ? void 0 : p.column) == null ? void 0 : k.columnDef) == null ? void 0 : v.cell,
|
|
346
|
+
props: (a = (o = s.cellByColId.Delete) == null ? void 0 : o.getContext) == null ? void 0 : a.call(o)
|
|
347
|
+
}, null, 8, ["render", "props"])
|
|
348
|
+
])
|
|
349
|
+
]),
|
|
350
|
+
u("div", Mt, [
|
|
351
|
+
u("div", Lt, [
|
|
352
|
+
C(l, {
|
|
353
|
+
label: n(d)(`inventory.transfer.form.items.table.${n(R).Code}`)
|
|
354
|
+
}, null, 8, ["label"]),
|
|
355
|
+
C(n(le), {
|
|
356
|
+
render: (f = (b = (r = s.cellByColId[n(R).Code]) == null ? void 0 : r.column) == null ? void 0 : b.columnDef) == null ? void 0 : f.cell,
|
|
357
|
+
props: (y = (i = s.cellByColId[n(R).Code]) == null ? void 0 : i.getContext) == null ? void 0 : y.call(i)
|
|
358
|
+
}, null, 8, ["render", "props"]),
|
|
359
|
+
Nt
|
|
360
|
+
]),
|
|
361
|
+
u("div", qt, [
|
|
362
|
+
C(l, {
|
|
363
|
+
label: n(d)(`inventory.transfer.form.items.table.${n(R).Name}`)
|
|
364
|
+
}, null, 8, ["label"]),
|
|
365
|
+
C(n(le), {
|
|
366
|
+
render: (Z = (I = (S = s.cellByColId[n(R).Name]) == null ? void 0 : S.column) == null ? void 0 : I.columnDef) == null ? void 0 : Z.cell,
|
|
367
|
+
props: (L = (O = s.cellByColId[n(R).Name]) == null ? void 0 : O.getContext) == null ? void 0 : L.call(O)
|
|
368
|
+
}, null, 8, ["render", "props"]),
|
|
369
|
+
Ht
|
|
370
|
+
])
|
|
371
|
+
]),
|
|
372
|
+
u("div", zt, [
|
|
373
|
+
u("div", jt, [
|
|
374
|
+
C(l, {
|
|
375
|
+
label: n(d)(`inventory.transfer.form.items.table.${n(R).Amount}`)
|
|
376
|
+
}, null, 8, ["label"]),
|
|
377
|
+
C(n(le), {
|
|
378
|
+
render: (h = (N = (Y = s.cellByColId[n(R).Amount]) == null ? void 0 : Y.column) == null ? void 0 : N.columnDef) == null ? void 0 : h.cell,
|
|
379
|
+
props: (U = (g = s.cellByColId[n(R).Amount]) == null ? void 0 : g.getContext) == null ? void 0 : U.call(g)
|
|
380
|
+
}, null, 8, ["render", "props"]),
|
|
381
|
+
Kt
|
|
382
|
+
]),
|
|
383
|
+
u("div", Yt, [
|
|
384
|
+
C(He, { "z-index": 50 }, {
|
|
385
|
+
default: D(() => [
|
|
386
|
+
C(l, {
|
|
387
|
+
label: n(d)(`inventory.transfer.form.items.table.${n(R).Cost}2`)
|
|
388
|
+
}, null, 8, ["label"])
|
|
389
|
+
]),
|
|
390
|
+
_: 1
|
|
391
|
+
}),
|
|
392
|
+
C(n(le), {
|
|
393
|
+
render: (de = (H = (q = s.cellByColId[n(R).Cost]) == null ? void 0 : q.column) == null ? void 0 : H.columnDef) == null ? void 0 : de.cell,
|
|
394
|
+
props: (he = (se = s.cellByColId[n(R).Cost]) == null ? void 0 : se.getContext) == null ? void 0 : he.call(se)
|
|
395
|
+
}, null, 8, ["render", "props"]),
|
|
396
|
+
Wt
|
|
397
|
+
])
|
|
398
|
+
]),
|
|
399
|
+
s.showComparePrice && Object.keys(s.comparePriceBySku[(c = s.row.original.sku) == null ? void 0 : c._id] ?? {}).length > 0 ? (T(), $(ue, { key: 0 }, [
|
|
400
|
+
C(m, { class: "h-8" }),
|
|
401
|
+
C(ze, {
|
|
402
|
+
prices: s.comparePriceBySku[(_ = s.row.original.sku) == null ? void 0 : _._id]
|
|
403
|
+
}, null, 8, ["prices"])
|
|
404
|
+
], 64)) : z("", !0)
|
|
405
|
+
]);
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
function pe(t) {
|
|
410
|
+
return ct.parse(t);
|
|
411
|
+
}
|
|
412
|
+
function me(t) {
|
|
413
|
+
return {
|
|
414
|
+
_id: t.doc._id,
|
|
415
|
+
internal: t.type,
|
|
416
|
+
contactName: t.doc.profile.name,
|
|
417
|
+
name: t.doc.profile.name,
|
|
418
|
+
email: t.doc.profile.email,
|
|
419
|
+
phoneNumber: t.doc.profile.phoneNo,
|
|
420
|
+
registrationNumber: t.doc.profile.regNo,
|
|
421
|
+
address: t.doc.profile.address
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
function Qt(t, d) {
|
|
425
|
+
const s = ve(), e = K();
|
|
426
|
+
e.watchLocation(async () => {
|
|
427
|
+
await s.readSuppliers();
|
|
428
|
+
const a = t();
|
|
429
|
+
if (a.supplier._id) return;
|
|
430
|
+
const r = s.suppliers[0], b = e.locations[0];
|
|
431
|
+
d({
|
|
432
|
+
...a,
|
|
433
|
+
supplier: r ? pe(r) : b ? me(b) : a.supplier
|
|
434
|
+
});
|
|
435
|
+
});
|
|
436
|
+
const l = F(
|
|
437
|
+
() => {
|
|
438
|
+
var a, r;
|
|
439
|
+
return typeof ((r = (a = t()) == null ? void 0 : a.supplier) == null ? void 0 : r.internal) == "string" ? x.TRANSFER : x.PURCHASE;
|
|
440
|
+
}
|
|
441
|
+
), m = F({
|
|
442
|
+
get() {
|
|
443
|
+
var a, r;
|
|
444
|
+
return (r = (a = t()) == null ? void 0 : a.supplier) == null ? void 0 : r._id;
|
|
445
|
+
},
|
|
446
|
+
set(a) {
|
|
447
|
+
const r = t() ?? {};
|
|
448
|
+
if (l.value === x.PURCHASE) {
|
|
449
|
+
const i = s.suppliers.find((y) => y._id === a);
|
|
450
|
+
d({
|
|
451
|
+
...r,
|
|
452
|
+
supplier: i ? pe(i) : r.supplier
|
|
453
|
+
});
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
const f = e.locations.find((i) => i.doc._id === a);
|
|
457
|
+
d({
|
|
458
|
+
...r,
|
|
459
|
+
supplier: f ? me(f) : r.supplier
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
}), p = F(() => s.suppliers.map(pe)), k = F(() => {
|
|
463
|
+
var r;
|
|
464
|
+
const a = ((r = e._currentLocation) == null ? void 0 : r.type) === we.warehouse;
|
|
465
|
+
return e.locations.filter((b) => {
|
|
466
|
+
var i;
|
|
467
|
+
return !(b.dbName === ((i = e._currentLocation) == null ? void 0 : i.dbName)) && (!a || b.type === we.warehouse) && b.acceptRequest;
|
|
468
|
+
}).map(me);
|
|
469
|
+
}), v = F(() => l.value === x.PURCHASE ? p.value.map((r) => ({
|
|
470
|
+
label: r.name,
|
|
471
|
+
value: r._id
|
|
472
|
+
})) : k.value.map((r) => ({
|
|
473
|
+
label: r.name,
|
|
474
|
+
sublabel: r.internal ? `${r.internal}` : void 0,
|
|
475
|
+
value: r._id
|
|
476
|
+
}))), o = F(() => {
|
|
477
|
+
var f, i;
|
|
478
|
+
const a = (i = (f = t()) == null ? void 0 : f.supplier) == null ? void 0 : i._id;
|
|
479
|
+
if (l.value === x.PURCHASE) {
|
|
480
|
+
const y = s.suppliers.find((S) => S._id === a);
|
|
481
|
+
return y ? pe(y) : null;
|
|
482
|
+
}
|
|
483
|
+
const b = e.locations.find((y) => y.doc._id);
|
|
484
|
+
return b ? me(b) : null;
|
|
485
|
+
});
|
|
486
|
+
return {
|
|
487
|
+
transferLocationModel: m,
|
|
488
|
+
transferLocationOptions: v,
|
|
489
|
+
locationOptionsTypePurchase: p,
|
|
490
|
+
locationOptionsTypeTransfer: k,
|
|
491
|
+
selectedLocation: o
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
function Gt(t) {
|
|
495
|
+
const d = F({
|
|
496
|
+
get() {
|
|
497
|
+
const m = t.getEffectiveAt();
|
|
498
|
+
return m ? new Date(m) : null;
|
|
499
|
+
},
|
|
500
|
+
set(m) {
|
|
501
|
+
t.setEffectiveAt((m == null ? void 0 : m.toISOString()) ?? null);
|
|
502
|
+
}
|
|
503
|
+
}), s = F({
|
|
504
|
+
get() {
|
|
505
|
+
return !!d.value;
|
|
506
|
+
},
|
|
507
|
+
set(m) {
|
|
508
|
+
m ? d.value = /* @__PURE__ */ new Date() : d.value = null;
|
|
509
|
+
}
|
|
510
|
+
}), e = F({
|
|
511
|
+
get() {
|
|
512
|
+
return d.value === null ? "" : xe(d.value);
|
|
513
|
+
},
|
|
514
|
+
set(m) {
|
|
515
|
+
m ? d.value = /* @__PURE__ */ new Date(`${m} ${l.value}`) : d.value = null;
|
|
516
|
+
}
|
|
517
|
+
}), l = F({
|
|
518
|
+
get() {
|
|
519
|
+
return d.value === null ? "" : dt(d.value);
|
|
520
|
+
},
|
|
521
|
+
set(m) {
|
|
522
|
+
m ? d.value = /* @__PURE__ */ new Date(`${e.value} ${m}`) : d.value = null;
|
|
523
|
+
}
|
|
524
|
+
});
|
|
525
|
+
return {
|
|
526
|
+
backdatePo: d,
|
|
527
|
+
backdateSwitch: s,
|
|
528
|
+
backdateModel: e,
|
|
529
|
+
backdateTimeModel: l
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
const Jt = {
|
|
533
|
+
width: "24",
|
|
534
|
+
height: "24",
|
|
535
|
+
viewBox: "0 0 24 24",
|
|
536
|
+
fill: "none",
|
|
537
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
538
|
+
}, Xt = ["fill"], eo = ["fill"], to = ["stroke"], oo = ["stroke"], so = /* @__PURE__ */ oe({
|
|
539
|
+
__name: "SparkIcon",
|
|
540
|
+
props: {
|
|
541
|
+
size: {
|
|
542
|
+
type: Number,
|
|
543
|
+
default: 24
|
|
544
|
+
},
|
|
545
|
+
color: {
|
|
546
|
+
type: String,
|
|
547
|
+
default: "#c7c7cc"
|
|
548
|
+
}
|
|
549
|
+
},
|
|
550
|
+
setup(t) {
|
|
551
|
+
return (d, s) => (T(), $("svg", Jt, [
|
|
552
|
+
u("path", {
|
|
553
|
+
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",
|
|
554
|
+
fill: t.color
|
|
555
|
+
}, null, 8, Xt),
|
|
556
|
+
u("path", {
|
|
557
|
+
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",
|
|
558
|
+
fill: t.color
|
|
559
|
+
}, null, 8, eo),
|
|
560
|
+
u("path", {
|
|
561
|
+
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",
|
|
562
|
+
stroke: t.color,
|
|
563
|
+
"stroke-width": "1.5",
|
|
564
|
+
"stroke-linecap": "round",
|
|
565
|
+
"stroke-linejoin": "round"
|
|
566
|
+
}, null, 8, to),
|
|
567
|
+
u("path", {
|
|
568
|
+
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",
|
|
569
|
+
stroke: t.color,
|
|
570
|
+
"stroke-width": "1.5",
|
|
571
|
+
"stroke-linecap": "round",
|
|
572
|
+
"stroke-linejoin": "round"
|
|
573
|
+
}, null, 8, oo)
|
|
574
|
+
]));
|
|
575
|
+
}
|
|
576
|
+
}), ao = { class: "flex gap-8 items-center" }, no = /* @__PURE__ */ u("div", { class: "fm-typo-en-body-lg-600 line-clamp-1" }, "Forecast stock", -1), ro = { class: "w-[343px] px-24 py-16 rounded-lg shadow-light-300 flex flex-col gap-[20px]" }, lo = { class: "flex items-center w-full" }, io = { class: "flex-1" }, uo = /* @__PURE__ */ u("p", { class: "fm-typo-en-title-sm-800" }, "Forecast stock", -1), co = { class: "flex items-start gap-8" }, po = /* @__PURE__ */ u("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Selecting forecast stock will replace your current item selection. ", -1), mo = { class: "flex gap-1" }, fo = /* @__PURE__ */ u("div", { class: "grow" }, null, -1), Ve = /* @__PURE__ */ oe({
|
|
577
|
+
__name: "ForecastStock",
|
|
578
|
+
props: {
|
|
579
|
+
disabled: { type: Boolean }
|
|
580
|
+
},
|
|
581
|
+
emits: ["update:poItems"],
|
|
582
|
+
setup(t, { emit: d }) {
|
|
583
|
+
const s = d, e = B(!1), l = B(7), m = bt(), p = ye(), k = Se();
|
|
584
|
+
async function v() {
|
|
585
|
+
if (l.value < 1)
|
|
586
|
+
return;
|
|
587
|
+
e.value = !1, await m.readPurchaseOrder(l.value);
|
|
588
|
+
const o = [];
|
|
589
|
+
if (m.purchaseOrderForecast.skus.length <= 0) {
|
|
590
|
+
p.open({ message: "There is no forecast at the moment.", type: "info" });
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
const a = m.purchaseOrderForecast.skus.reduce((r, b) => {
|
|
594
|
+
const f = k.skus.find((S) => S._id === b.id);
|
|
595
|
+
if (r.find((S) => S.sku._id === b.id) || !f)
|
|
596
|
+
return r;
|
|
597
|
+
const y = {
|
|
598
|
+
sku: f,
|
|
599
|
+
code: f.code,
|
|
600
|
+
name: f.name,
|
|
601
|
+
quantity: {
|
|
602
|
+
amount: b.amount,
|
|
603
|
+
precision: 0
|
|
604
|
+
}
|
|
605
|
+
};
|
|
606
|
+
return r.push(y), r;
|
|
607
|
+
}, o);
|
|
608
|
+
s("update:poItems", a);
|
|
609
|
+
}
|
|
610
|
+
return (o, a) => {
|
|
611
|
+
const r = P("FmButton"), b = P("FmIcon"), f = P("FmStepperField"), i = P("FmPopover");
|
|
612
|
+
return T(), E(i, {
|
|
613
|
+
disabled: o.disabled,
|
|
614
|
+
class: "flex",
|
|
615
|
+
"show-popover": e.value,
|
|
616
|
+
onPopoverChanged: a[3] || (a[3] = (y) => e.value = y)
|
|
617
|
+
}, {
|
|
618
|
+
"popover-button": D(() => [
|
|
619
|
+
C(r, {
|
|
620
|
+
label: "unused",
|
|
621
|
+
variant: "secondary",
|
|
622
|
+
"text-color": o.disabled ? "disabled" : "primary",
|
|
623
|
+
"bg-color": "transparent",
|
|
624
|
+
"border-color": o.disabled ? "disabled" : "primary",
|
|
625
|
+
disabled: o.disabled
|
|
626
|
+
}, {
|
|
627
|
+
default: D(() => [
|
|
628
|
+
u("div", ao, [
|
|
629
|
+
C(so, {
|
|
630
|
+
size: 24,
|
|
631
|
+
color: o.disabled ? "#c7c7cc" : "#ff7823"
|
|
632
|
+
}, null, 8, ["color"]),
|
|
633
|
+
no
|
|
634
|
+
])
|
|
635
|
+
]),
|
|
636
|
+
_: 1
|
|
637
|
+
}, 8, ["text-color", "border-color", "disabled"])
|
|
638
|
+
]),
|
|
639
|
+
default: D(() => [
|
|
640
|
+
u("div", ro, [
|
|
641
|
+
u("div", lo, [
|
|
642
|
+
u("div", io, [
|
|
643
|
+
C(kt, { "z-index": 99 }, {
|
|
644
|
+
default: D(() => [
|
|
645
|
+
uo
|
|
646
|
+
]),
|
|
647
|
+
_: 1
|
|
648
|
+
})
|
|
649
|
+
]),
|
|
650
|
+
C(r, {
|
|
651
|
+
icon: "close",
|
|
652
|
+
size: "md",
|
|
653
|
+
variant: "tertiary",
|
|
654
|
+
onClick: a[0] || (a[0] = (y) => e.value = !1)
|
|
655
|
+
})
|
|
656
|
+
]),
|
|
657
|
+
C(f, {
|
|
658
|
+
modelValue: l.value,
|
|
659
|
+
"onUpdate:modelValue": a[1] || (a[1] = (y) => l.value = y),
|
|
660
|
+
label: "Enter day to forecast stock",
|
|
661
|
+
rules: [n(Te)(1)]
|
|
662
|
+
}, {
|
|
663
|
+
"helper-text": D(() => [
|
|
664
|
+
u("div", co, [
|
|
665
|
+
C(b, {
|
|
666
|
+
name: "warning",
|
|
667
|
+
size: "sm",
|
|
668
|
+
class: "text-fm-color-system-warning-300"
|
|
669
|
+
}),
|
|
670
|
+
po
|
|
671
|
+
])
|
|
672
|
+
]),
|
|
673
|
+
_: 1
|
|
674
|
+
}, 8, ["modelValue", "rules"]),
|
|
675
|
+
u("div", mo, [
|
|
676
|
+
fo,
|
|
677
|
+
C(r, {
|
|
678
|
+
label: "Cancel",
|
|
679
|
+
variant: "tertiary",
|
|
680
|
+
onClick: a[2] || (a[2] = (y) => e.value = !1)
|
|
681
|
+
}),
|
|
682
|
+
C(r, {
|
|
683
|
+
label: "Generate",
|
|
684
|
+
onClick: v
|
|
685
|
+
})
|
|
686
|
+
])
|
|
687
|
+
])
|
|
688
|
+
]),
|
|
689
|
+
_: 1
|
|
690
|
+
}, 8, ["disabled", "show-popover"]);
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
}), je = pt((t, d) => ({
|
|
694
|
+
async getTemplate(s) {
|
|
695
|
+
const e = K(), l = `${t.inventoryBackendUrl}/${e.currentLocationDBName}/purchase-order-template/${s}`;
|
|
696
|
+
return d.get(l);
|
|
697
|
+
},
|
|
698
|
+
async readTemplates() {
|
|
699
|
+
const s = K(), e = `${t.inventoryBackendUrl}/${s.currentLocationDBName}/purchase-order-template`;
|
|
700
|
+
return d.get(e);
|
|
701
|
+
},
|
|
702
|
+
async createTemplate(s) {
|
|
703
|
+
const e = K(), l = `${t.inventoryBackendUrl}/${e.currentLocationDBName}/purchase-order-template`;
|
|
704
|
+
return d.post(l, s);
|
|
705
|
+
},
|
|
706
|
+
async updateTemplate(s) {
|
|
707
|
+
const e = K(), l = `${t.inventoryBackendUrl}/${e.currentLocationDBName}/purchase-order-template`;
|
|
708
|
+
return d.post(l, s);
|
|
709
|
+
},
|
|
710
|
+
async deleteTemplate(s) {
|
|
711
|
+
const e = K(), l = `${t.inventoryBackendUrl}/${e.currentLocationDBName}/purchase-order-template`;
|
|
712
|
+
return d.delete(l, { _id: s._id, _rev: s._rev });
|
|
713
|
+
}
|
|
714
|
+
})), yo = wt("transferTemplateActions", () => {
|
|
715
|
+
const t = et("receive/request"), d = Oe(), s = ye(), e = je(), l = B({});
|
|
716
|
+
function m() {
|
|
717
|
+
l.value = {
|
|
718
|
+
mode: te.CREATE,
|
|
719
|
+
show: !0,
|
|
720
|
+
"onUpdate:show"(a) {
|
|
721
|
+
l.value.show = a;
|
|
722
|
+
}
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
function p(a) {
|
|
726
|
+
l.value = {
|
|
727
|
+
mode: te.UPDATE,
|
|
728
|
+
modelValue: a,
|
|
729
|
+
show: !0,
|
|
730
|
+
"onUpdate:show"(r) {
|
|
731
|
+
l.value.show = r;
|
|
732
|
+
}
|
|
733
|
+
};
|
|
734
|
+
}
|
|
735
|
+
function k(a, r, b) {
|
|
736
|
+
d.open({
|
|
737
|
+
title: `Confirm deleting template ${a.name}?`,
|
|
738
|
+
message: "Deleted template can no longer be retrieved",
|
|
739
|
+
primaryActions: {
|
|
740
|
+
text: "Delete",
|
|
741
|
+
variant: Ce.Destructive,
|
|
742
|
+
close: !0
|
|
743
|
+
},
|
|
744
|
+
secondaryActions: {
|
|
745
|
+
text: "Cancel",
|
|
746
|
+
variant: Ce.Plain,
|
|
747
|
+
close: !0
|
|
748
|
+
}
|
|
749
|
+
}).onPrimary(async () => {
|
|
750
|
+
s.open({
|
|
751
|
+
title: `Deleting ${a.name}`,
|
|
752
|
+
type: "info"
|
|
753
|
+
});
|
|
754
|
+
try {
|
|
755
|
+
r.value = !0;
|
|
756
|
+
const [f] = await Promise.allSettled([
|
|
757
|
+
e.deleteTemplate(a),
|
|
758
|
+
new Promise((i) => setTimeout(i, 1e3))
|
|
759
|
+
]);
|
|
760
|
+
if (f.status === "rejected") throw f.reason;
|
|
761
|
+
s.open({
|
|
762
|
+
title: `Deleted ${a.name}`,
|
|
763
|
+
type: "success"
|
|
764
|
+
});
|
|
765
|
+
} catch (f) {
|
|
766
|
+
s.open({
|
|
767
|
+
title: `Unable to delete ${a.name}`,
|
|
768
|
+
message: `See error from server: ${f}`,
|
|
769
|
+
type: "error"
|
|
770
|
+
}), console.error("error on deleting purchase order template", f);
|
|
771
|
+
} finally {
|
|
772
|
+
r.value = !1, b();
|
|
773
|
+
}
|
|
774
|
+
});
|
|
775
|
+
}
|
|
776
|
+
function v(a) {
|
|
777
|
+
}
|
|
778
|
+
function o(a) {
|
|
779
|
+
t.promptCreateTransferDialog({
|
|
780
|
+
...a.purchaseOrder,
|
|
781
|
+
template: a._id
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
return {
|
|
785
|
+
createTemplate: m,
|
|
786
|
+
viewTemplate: v,
|
|
787
|
+
updateTemplate: p,
|
|
788
|
+
deleteTemplate: k,
|
|
789
|
+
useTemplate: o,
|
|
790
|
+
templateDialogProps: l,
|
|
791
|
+
transferFormDialogProps: t.transferDialogProps
|
|
792
|
+
};
|
|
793
|
+
});
|
|
794
|
+
function be(t) {
|
|
795
|
+
var s;
|
|
796
|
+
return ((s = t == null ? void 0 : t.supplier) == null ? void 0 : s.internal) ? x.TRANSFER : x.PURCHASE;
|
|
797
|
+
}
|
|
798
|
+
const Re = "use";
|
|
799
|
+
function vo() {
|
|
800
|
+
const { t } = ce(), { viewTemplate: d, updateTemplate: s, deleteTemplate: e, useTemplate: l } = yo(), m = B(new Array()), p = B(!1), k = K(), v = je();
|
|
801
|
+
async function o() {
|
|
802
|
+
if (m.value = [], !!k._currentLocation) {
|
|
803
|
+
p.value = !0;
|
|
804
|
+
try {
|
|
805
|
+
const [f] = await Promise.all([
|
|
806
|
+
v.readTemplates(),
|
|
807
|
+
new Promise((i) => setTimeout(i, 1e3))
|
|
808
|
+
]);
|
|
809
|
+
m.value = f;
|
|
810
|
+
} catch (f) {
|
|
811
|
+
console.log("Something went wrong when fetching templates:", f);
|
|
812
|
+
} finally {
|
|
813
|
+
p.value = !1;
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
async function a(f) {
|
|
818
|
+
if (!m.value.find((i) => i._id) && k._currentLocation) {
|
|
819
|
+
p.value = !0;
|
|
820
|
+
try {
|
|
821
|
+
const [i] = await Promise.all([
|
|
822
|
+
v.getTemplate(f),
|
|
823
|
+
new Promise((y) => setTimeout(y, 1e3))
|
|
824
|
+
]);
|
|
825
|
+
m.value = [i];
|
|
826
|
+
} catch (i) {
|
|
827
|
+
console.log("Something went wrong when fetching templates:", i);
|
|
828
|
+
} finally {
|
|
829
|
+
p.value = !1;
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
function r(f, i) {
|
|
834
|
+
switch (i = qe(i), f) {
|
|
835
|
+
case Re:
|
|
836
|
+
return l(i);
|
|
837
|
+
case ie.Details:
|
|
838
|
+
return d(i);
|
|
839
|
+
case ie.Edit:
|
|
840
|
+
return s(i);
|
|
841
|
+
case ie.Delete:
|
|
842
|
+
return e(i, p, o);
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
return { columnDefs: [
|
|
846
|
+
{
|
|
847
|
+
id: "_id",
|
|
848
|
+
accessorKey: "_id",
|
|
849
|
+
header: () => t("inventory.transfer.table.createdAt"),
|
|
850
|
+
cell(f) {
|
|
851
|
+
return tt(`${f.getValue()}`);
|
|
852
|
+
},
|
|
853
|
+
enableSorting: !0
|
|
854
|
+
},
|
|
855
|
+
{
|
|
856
|
+
id: "name",
|
|
857
|
+
accessorKey: "name",
|
|
858
|
+
header: () => t("inventory.transfer.table.name"),
|
|
859
|
+
enableSorting: !0,
|
|
860
|
+
size: 200
|
|
861
|
+
},
|
|
862
|
+
{
|
|
863
|
+
id: "supplier",
|
|
864
|
+
accessorKey: "purchaseOrder.supplier.name",
|
|
865
|
+
header: () => t("inventory.transfer.table.transferFrom"),
|
|
866
|
+
enableSorting: !0,
|
|
867
|
+
size: 200
|
|
868
|
+
},
|
|
869
|
+
{
|
|
870
|
+
id: "type",
|
|
871
|
+
header: () => t("inventory.transfer.receiveRequest.details.type.title"),
|
|
872
|
+
enableSorting: !0,
|
|
873
|
+
sortingFn(f, i) {
|
|
874
|
+
const y = be(f.original.purchaseOrder), S = be(i.original.purchaseOrder);
|
|
875
|
+
return y.localeCompare(S);
|
|
876
|
+
},
|
|
877
|
+
size: 200,
|
|
878
|
+
cell(f) {
|
|
879
|
+
const i = be(f.row.original.purchaseOrder), y = t(
|
|
880
|
+
`inventory.transfer.receiveRequest.details.type.${i.toLocaleLowerCase()}`
|
|
881
|
+
);
|
|
882
|
+
return V(X.FmChip, {
|
|
883
|
+
label: y,
|
|
884
|
+
class: "fm-chip-transfer-info",
|
|
885
|
+
compact: !0
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
},
|
|
889
|
+
{
|
|
890
|
+
id: "noOfItems",
|
|
891
|
+
accessorKey: "purchaseOrder.items.length",
|
|
892
|
+
header: () => t("inventory.transfer.table.noOfItems"),
|
|
893
|
+
enableSorting: !1,
|
|
894
|
+
meta: {
|
|
895
|
+
width: "10rem",
|
|
896
|
+
textAlign: "right"
|
|
897
|
+
}
|
|
898
|
+
},
|
|
899
|
+
{
|
|
900
|
+
id: "ref",
|
|
901
|
+
accessorKey: "purchaseOrder.ref",
|
|
902
|
+
header: () => t("inventory.transfer.table.reference"),
|
|
903
|
+
enableSorting: !1,
|
|
904
|
+
size: "auto"
|
|
905
|
+
},
|
|
906
|
+
{
|
|
907
|
+
id: "action",
|
|
908
|
+
cell(f) {
|
|
909
|
+
const i = f.row.original, y = [
|
|
910
|
+
{
|
|
911
|
+
label: t("inventory.transfer.template.use"),
|
|
912
|
+
value: Re,
|
|
913
|
+
color: "text-fm-color-typo-primary"
|
|
914
|
+
},
|
|
915
|
+
De[ie.Edit],
|
|
916
|
+
De[ie.Delete]
|
|
917
|
+
];
|
|
918
|
+
return gt(y, (S) => r(S, i));
|
|
919
|
+
},
|
|
920
|
+
enableSorting: !1,
|
|
921
|
+
size: 40,
|
|
922
|
+
meta: {
|
|
923
|
+
cellClass: "",
|
|
924
|
+
headerClass: ""
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
], templates: m, loading: p, fetchTemplates: o, loadTemplate: a };
|
|
928
|
+
}
|
|
929
|
+
function ho() {
|
|
930
|
+
const t = ye(), d = Ee(), s = B(!1);
|
|
931
|
+
fe(s, (p) => {
|
|
932
|
+
p && (l.value = !0, e().finally(() => {
|
|
933
|
+
l.value = !1;
|
|
934
|
+
}));
|
|
935
|
+
});
|
|
936
|
+
async function e() {
|
|
937
|
+
try {
|
|
938
|
+
const { startDate: p, endDate: k } = mt(6), a = (await d.getPurchaseOrders({ start: p, end: k })).filter(
|
|
939
|
+
(r) => {
|
|
940
|
+
var b, f;
|
|
941
|
+
return r.status === ft.enum.COMPLETE && ((b = r.supplier) == null ? void 0 : b.internal) !== "warehouse" && ((f = r.supplier) == null ? void 0 : f.internal) !== "restaurant";
|
|
942
|
+
}
|
|
943
|
+
).reduce((r, b) => {
|
|
944
|
+
const f = new Date(yt(b._id)), i = b.supplier._id;
|
|
945
|
+
for (const y of b.items) {
|
|
946
|
+
if (!y.totalCost) continue;
|
|
947
|
+
const S = r[y.sku._id] ?? {}, I = S[i] ?? [];
|
|
948
|
+
I.push({
|
|
949
|
+
date: f.toISOString(),
|
|
950
|
+
totalUnit: y.quantity,
|
|
951
|
+
totalCost: y.totalCost,
|
|
952
|
+
unit: y.sku.unit,
|
|
953
|
+
measurement: y.measurement,
|
|
954
|
+
seqNumber: b.seqNumber
|
|
955
|
+
}), S[i] = I, r[y.sku._id] = S;
|
|
956
|
+
}
|
|
957
|
+
return r;
|
|
958
|
+
}, {});
|
|
959
|
+
m.value = a;
|
|
960
|
+
} catch {
|
|
961
|
+
t.open({
|
|
962
|
+
title: "Something went wrong",
|
|
963
|
+
message: "Cannot retrieve supplier purchase history. Please try again."
|
|
964
|
+
}), s.value = !1;
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
const l = B(!1), m = B({});
|
|
968
|
+
return {
|
|
969
|
+
comparePricesToggle: s,
|
|
970
|
+
comparePriceFetching: l,
|
|
971
|
+
comparePriceBySku: m
|
|
972
|
+
};
|
|
973
|
+
}
|
|
974
|
+
const _o = { class: "fm-typo-body-md-400 line-clamp-2 w-full" }, bo = { key: 0 }, go = ["colspan"], Co = /* @__PURE__ */ oe({
|
|
975
|
+
__name: "TransferItemTable",
|
|
976
|
+
props: {
|
|
977
|
+
row: {},
|
|
978
|
+
comparePriceBySku: {},
|
|
979
|
+
showComparePrice: { type: Boolean }
|
|
980
|
+
},
|
|
981
|
+
setup(t) {
|
|
982
|
+
function d(s) {
|
|
983
|
+
return s.column.columnDef.meta;
|
|
984
|
+
}
|
|
985
|
+
return (s, e) => {
|
|
986
|
+
var l, m;
|
|
987
|
+
return T(), $(ue, null, [
|
|
988
|
+
u("tr", {
|
|
989
|
+
class: Ae(["border-b border-fm-color-neutral-gray-100 hover:bg-fm-color-opacity-sm", {
|
|
990
|
+
"bg-fm-color-neutral-gray-100": s.row.getIsSelected()
|
|
991
|
+
}])
|
|
992
|
+
}, [
|
|
993
|
+
(T(!0), $(ue, null, ge(s.row.getVisibleCells(), (p) => {
|
|
994
|
+
var k, v, o, a;
|
|
995
|
+
return T(), $("td", {
|
|
996
|
+
key: p.id,
|
|
997
|
+
class: Ae([
|
|
998
|
+
"h-[52px] px-16 text-fm-color-typo-primary",
|
|
999
|
+
((k = d(p)) == null ? void 0 : k.cellClass) ?? "px-16"
|
|
1000
|
+
]),
|
|
1001
|
+
style: Ge({
|
|
1002
|
+
width: (v = d(p)) == null ? void 0 : v.width,
|
|
1003
|
+
maxWidth: (o = d(p)) == null ? void 0 : o.maxWidth,
|
|
1004
|
+
textAlign: ((a = d(p)) == null ? void 0 : a.textAlign) ?? "left"
|
|
1005
|
+
})
|
|
1006
|
+
}, [
|
|
1007
|
+
u("span", _o, [
|
|
1008
|
+
C(n(le), {
|
|
1009
|
+
render: p.column.columnDef.cell,
|
|
1010
|
+
props: p.getContext()
|
|
1011
|
+
}, null, 8, ["render", "props"])
|
|
1012
|
+
])
|
|
1013
|
+
], 6);
|
|
1014
|
+
}), 128))
|
|
1015
|
+
], 2),
|
|
1016
|
+
s.showComparePrice && Object.keys(s.comparePriceBySku[(l = s.row.original.sku) == null ? void 0 : l._id] ?? {}).length > 0 ? (T(), $("tr", bo, [
|
|
1017
|
+
u("td", {
|
|
1018
|
+
colspan: s.row.getVisibleCells().length
|
|
1019
|
+
}, [
|
|
1020
|
+
C(ze, {
|
|
1021
|
+
prices: s.comparePriceBySku[(m = s.row.original.sku) == null ? void 0 : m._id]
|
|
1022
|
+
}, null, 8, ["prices"])
|
|
1023
|
+
], 8, go)
|
|
1024
|
+
])) : z("", !0)
|
|
1025
|
+
], 64);
|
|
1026
|
+
};
|
|
1027
|
+
}
|
|
1028
|
+
}), ko = { class: "flex flex-col gap-4" }, wo = { class: "flex items-center gap-8 overflow-x-auto pb-12" }, To = { class: "flex flex-col gap-16" }, xo = { class: "flex flex-col gap-24" }, So = {
|
|
1029
|
+
key: 0,
|
|
1030
|
+
class: "p-16 border border-fm-color-neutral-gray-300 fm-corner-radius-md flex flex-col"
|
|
1031
|
+
}, Po = { class: "flex xs:flex-col sm:flex-col" }, Fo = /* @__PURE__ */ u("div", { class: "xs:hidden sm:hidden h-48 lg:w-16 md:w-16" }, null, -1), $o = {
|
|
1032
|
+
key: 0,
|
|
1033
|
+
class: "flex-1 flex gap-8 h-48 xs:flex-col xs:pt-16 sm:flex-col sm:pt-16"
|
|
1034
|
+
}, Ao = { class: "flex-1" }, Do = { class: "flex-1" }, Io = {
|
|
1035
|
+
key: 1,
|
|
1036
|
+
class: "flex items-center gap-4"
|
|
1037
|
+
}, Vo = /* @__PURE__ */ u("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), Ro = { class: "flex flex-col gap-16" }, Bo = { class: "flex sm:flex-col xs:flex-col gap-16 items-center xs:items-start sm:items-start" }, Uo = /* @__PURE__ */ u("div", { class: "flex-1 gap-8 fm-typo-en-title-sm-800" }, "Transfer items", -1), Oo = { class: "flex gap-8" }, Eo = /* @__PURE__ */ u("div", null, "Forecast is not available on transfer document created from a template.", -1), Mo = {
|
|
1038
|
+
key: 0,
|
|
1039
|
+
class: "xs:w-full"
|
|
1040
|
+
}, Lo = /* @__PURE__ */ oe({
|
|
1041
|
+
__name: "TransferForm2",
|
|
1042
|
+
props: {
|
|
1043
|
+
modelValue: {},
|
|
1044
|
+
disabled: { type: Boolean },
|
|
1045
|
+
suppliers: {},
|
|
1046
|
+
skus: {},
|
|
1047
|
+
lastClosingDate: {}
|
|
1048
|
+
},
|
|
1049
|
+
setup(t, { expose: d }) {
|
|
1050
|
+
const s = t, e = St(), { t: l } = ce(), m = K(), p = Se(), k = ve(), v = Me(), o = vo(), a = F(
|
|
1051
|
+
() => o.templates.value.find((c) => c._id === e.template)
|
|
1052
|
+
), r = F(() => e.status === "DRAFT" || !e._rev);
|
|
1053
|
+
Ue(() => {
|
|
1054
|
+
e.template && o.loadTemplate(e.template);
|
|
1055
|
+
});
|
|
1056
|
+
const b = F(
|
|
1057
|
+
() => m.currentLocation.type === we.restaurant
|
|
1058
|
+
);
|
|
1059
|
+
fe(
|
|
1060
|
+
() => s.modelValue,
|
|
1061
|
+
(c) => {
|
|
1062
|
+
console.log("TransferForm.model", c);
|
|
1063
|
+
}
|
|
1064
|
+
), m.watchLocation(async () => {
|
|
1065
|
+
location && (e.supplier || (e.supplier = k.suppliers.find((c) => c) ?? e.supplier));
|
|
1066
|
+
});
|
|
1067
|
+
const f = Oe(), i = Qt(
|
|
1068
|
+
() => e,
|
|
1069
|
+
(c) => {
|
|
1070
|
+
Object.assign(e, c);
|
|
1071
|
+
}
|
|
1072
|
+
), y = F({
|
|
1073
|
+
get() {
|
|
1074
|
+
var c;
|
|
1075
|
+
return typeof ((c = e == null ? void 0 : e.supplier) == null ? void 0 : c.internal) == "string" ? x.TRANSFER : x.PURCHASE;
|
|
1076
|
+
},
|
|
1077
|
+
set(c) {
|
|
1078
|
+
var A;
|
|
1079
|
+
const _ = typeof ((A = e == null ? void 0 : e.supplier) == null ? void 0 : A.internal) == "string" ? x.TRANSFER : x.PURCHASE;
|
|
1080
|
+
c !== _ && (e.supplier = c === x.PURCHASE ? i.locationOptionsTypePurchase.value[0] : i.locationOptionsTypeTransfer.value[0]);
|
|
1081
|
+
}
|
|
1082
|
+
}), S = F(() => i.transferLocationOptions.value), I = F({
|
|
1083
|
+
get() {
|
|
1084
|
+
return e.supplier._id;
|
|
1085
|
+
},
|
|
1086
|
+
set(c) {
|
|
1087
|
+
i.transferLocationModel.value = c;
|
|
1088
|
+
}
|
|
1089
|
+
}), Z = F({
|
|
1090
|
+
get() {
|
|
1091
|
+
return e.remark ?? void 0;
|
|
1092
|
+
},
|
|
1093
|
+
set(c) {
|
|
1094
|
+
e.remark = c;
|
|
1095
|
+
}
|
|
1096
|
+
}), { backdatePo: O, backdateSwitch: L, backdateModel: Y, backdateTimeModel: N } = Gt({
|
|
1097
|
+
getEffectiveAt() {
|
|
1098
|
+
return e.effectiveAt;
|
|
1099
|
+
},
|
|
1100
|
+
setEffectiveAt(c) {
|
|
1101
|
+
e.effectiveAt = c;
|
|
1102
|
+
}
|
|
1103
|
+
}), { comparePricesToggle: h, comparePriceFetching: g, comparePriceBySku: U } = ho(), q = B();
|
|
1104
|
+
d({
|
|
1105
|
+
validateInputs: () => {
|
|
1106
|
+
var c, _;
|
|
1107
|
+
(_ = (c = q.value) == null ? void 0 : c.validateInputs) == null || _.call(c);
|
|
1108
|
+
},
|
|
1109
|
+
resetInputsValidation: () => {
|
|
1110
|
+
var c, _;
|
|
1111
|
+
(_ = (c = q.value) == null ? void 0 : c.resetInputsValidation) == null || _.call(c);
|
|
1112
|
+
},
|
|
1113
|
+
resetInputs: () => {
|
|
1114
|
+
var c, _;
|
|
1115
|
+
(_ = (c = q.value) == null ? void 0 : c.resetInputs) == null || _.call(c);
|
|
1116
|
+
}
|
|
1117
|
+
});
|
|
1118
|
+
const H = xt({
|
|
1119
|
+
updateItem: (c) => {
|
|
1120
|
+
e.items = e.items.map((_) => _.sku._id !== c.sku._id ? _ : c);
|
|
1121
|
+
},
|
|
1122
|
+
deleteItem: (c) => {
|
|
1123
|
+
e.items = e.items.filter((_) => _.sku._id !== c.sku._id);
|
|
1124
|
+
},
|
|
1125
|
+
get supplier() {
|
|
1126
|
+
return e.supplier;
|
|
1127
|
+
},
|
|
1128
|
+
get items() {
|
|
1129
|
+
return e.items;
|
|
1130
|
+
},
|
|
1131
|
+
get transferType() {
|
|
1132
|
+
return y.value;
|
|
1133
|
+
},
|
|
1134
|
+
get template() {
|
|
1135
|
+
return a.value;
|
|
1136
|
+
}
|
|
1137
|
+
}), de = F(() => H.columnDefs.value);
|
|
1138
|
+
function se() {
|
|
1139
|
+
const c = p.skus.map((A) => ({
|
|
1140
|
+
label: A.name,
|
|
1141
|
+
sublabel: A.code,
|
|
1142
|
+
value: A
|
|
1143
|
+
})), _ = c.filter((A) => {
|
|
1144
|
+
var Q;
|
|
1145
|
+
return (Q = e.items) == null ? void 0 : Q.find((ae) => ae.sku._id === A.value._id);
|
|
1146
|
+
}).map((A) => A.value);
|
|
1147
|
+
f.open({
|
|
1148
|
+
title: "Select item",
|
|
1149
|
+
closeButton: !0,
|
|
1150
|
+
contentComponent: _t,
|
|
1151
|
+
contentComponentProps: {
|
|
1152
|
+
modelValue: _,
|
|
1153
|
+
items: c
|
|
1154
|
+
},
|
|
1155
|
+
primaryActions: {
|
|
1156
|
+
text: "Confirm",
|
|
1157
|
+
close: !0
|
|
1158
|
+
},
|
|
1159
|
+
secondaryActions: {
|
|
1160
|
+
text: "Close",
|
|
1161
|
+
close: !0,
|
|
1162
|
+
variant: "tertiary"
|
|
1163
|
+
}
|
|
1164
|
+
}).onPrimary((A) => {
|
|
1165
|
+
const Q = e.items ?? [], ae = A.map((W) => {
|
|
1166
|
+
const G = Q.find((_e) => _e.sku._id === W._id);
|
|
1167
|
+
if (G)
|
|
1168
|
+
return G;
|
|
1169
|
+
const J = {
|
|
1170
|
+
sku: W,
|
|
1171
|
+
code: W.code,
|
|
1172
|
+
name: W.name,
|
|
1173
|
+
quantity: {
|
|
1174
|
+
amount: 1,
|
|
1175
|
+
precision: 0
|
|
1176
|
+
}
|
|
1177
|
+
};
|
|
1178
|
+
return y.value == x.PURCHASE && (J.totalCost = ee(
|
|
1179
|
+
J.sku,
|
|
1180
|
+
J.quantity,
|
|
1181
|
+
J.measurement,
|
|
1182
|
+
{
|
|
1183
|
+
supplier: e.supplier
|
|
1184
|
+
}
|
|
1185
|
+
)), J;
|
|
1186
|
+
});
|
|
1187
|
+
ae.sort((W, G) => W.sku.code.localeCompare(G.sku.code)), e.items = ae;
|
|
1188
|
+
});
|
|
1189
|
+
}
|
|
1190
|
+
function he(c) {
|
|
1191
|
+
return c;
|
|
1192
|
+
}
|
|
1193
|
+
return (c, _) => {
|
|
1194
|
+
const A = P("FmChip"), Q = P("FmSelect"), ae = P("FmTextField"), W = P("FmTextarea"), G = P("FmSwitch"), J = P("FmDatePicker"), _e = P("FmTimePicker"), Pe = P("FmFormGroup"), Ke = P("FmIcon"), Ye = P("FmButton"), We = P("FmTooltip"), Ze = P("FmTable"), Qe = P("FmForm");
|
|
1195
|
+
return T(), $("div", ko, [
|
|
1196
|
+
u("div", wo, [
|
|
1197
|
+
a.value ? (T(), E(A, {
|
|
1198
|
+
key: 0,
|
|
1199
|
+
label: `Template: ${a.value.name}`,
|
|
1200
|
+
icon: "summarize",
|
|
1201
|
+
compact: ""
|
|
1202
|
+
}, null, 8, ["label"])) : z("", !0),
|
|
1203
|
+
C(A, {
|
|
1204
|
+
label: n(m).currentLocation.name,
|
|
1205
|
+
icon: "storefront",
|
|
1206
|
+
compact: ""
|
|
1207
|
+
}, null, 8, ["label"]),
|
|
1208
|
+
c.lastClosingDate ? (T(), E(A, {
|
|
1209
|
+
key: 1,
|
|
1210
|
+
label: `Last closing: ${n(xe)(c.lastClosingDate)} ${n(vt)(c.lastClosingDate)}`,
|
|
1211
|
+
icon: "calendar_month",
|
|
1212
|
+
compact: ""
|
|
1213
|
+
}, null, 8, ["label"])) : z("", !0)
|
|
1214
|
+
]),
|
|
1215
|
+
C(Qe, {
|
|
1216
|
+
ref_key: "formRef",
|
|
1217
|
+
ref: q,
|
|
1218
|
+
class: "flex flex-col gap-32",
|
|
1219
|
+
disabled: c.disabled
|
|
1220
|
+
}, {
|
|
1221
|
+
default: D(() => {
|
|
1222
|
+
var Fe;
|
|
1223
|
+
return [
|
|
1224
|
+
u("div", To, [
|
|
1225
|
+
u("div", xo, [
|
|
1226
|
+
C(Q, {
|
|
1227
|
+
label: n(l)("inventory.transfer.form.type.title"),
|
|
1228
|
+
"model-value": y.value,
|
|
1229
|
+
"onUpdate:modelValue": _[0] || (_[0] = (w) => y.value = w),
|
|
1230
|
+
items: [
|
|
1231
|
+
{
|
|
1232
|
+
label: n(l)(
|
|
1233
|
+
`inventory.transfer.form.type.${n(x).PURCHASE.toLocaleLowerCase()}`
|
|
1234
|
+
),
|
|
1235
|
+
value: n(x).PURCHASE,
|
|
1236
|
+
disabled: !n(i).locationOptionsTypePurchase.value.length,
|
|
1237
|
+
sublabel: n(i).locationOptionsTypePurchase.value.length ? void 0 : "No supplier available"
|
|
1238
|
+
},
|
|
1239
|
+
{
|
|
1240
|
+
label: n(l)(
|
|
1241
|
+
`inventory.transfer.form.type.${n(x).TRANSFER.toLocaleLowerCase()}`
|
|
1242
|
+
),
|
|
1243
|
+
value: n(x).TRANSFER,
|
|
1244
|
+
disabled: !n(i).locationOptionsTypeTransfer.value.length,
|
|
1245
|
+
sublabel: n(i).locationOptionsTypeTransfer.value.length ? void 0 : "No location available"
|
|
1246
|
+
}
|
|
1247
|
+
],
|
|
1248
|
+
rules: [n(Te)(1)(S.value)]
|
|
1249
|
+
}, null, 8, ["label", "model-value", "items", "rules"]),
|
|
1250
|
+
C(Q, {
|
|
1251
|
+
label: y.value === n(x).PURCHASE ? "Purchase from" : "Transfer from",
|
|
1252
|
+
modelValue: I.value,
|
|
1253
|
+
"onUpdate:modelValue": _[1] || (_[1] = (w) => I.value = w),
|
|
1254
|
+
items: S.value
|
|
1255
|
+
}, null, 8, ["label", "modelValue", "items"]),
|
|
1256
|
+
C(ae, {
|
|
1257
|
+
label: "Reference",
|
|
1258
|
+
"label-mark": "optional",
|
|
1259
|
+
modelValue: n(e).ref,
|
|
1260
|
+
"onUpdate:modelValue": _[2] || (_[2] = (w) => n(e).ref = w)
|
|
1261
|
+
}, null, 8, ["modelValue"]),
|
|
1262
|
+
C(W, {
|
|
1263
|
+
label: "Remark",
|
|
1264
|
+
"label-mark": "optional",
|
|
1265
|
+
"max-length": 240,
|
|
1266
|
+
modelValue: Z.value,
|
|
1267
|
+
"onUpdate:modelValue": _[3] || (_[3] = (w) => Z.value = w)
|
|
1268
|
+
}, null, 8, ["modelValue"]),
|
|
1269
|
+
n(v).enableBackdatePo ? (T(), $("div", So, [
|
|
1270
|
+
u("div", Po, [
|
|
1271
|
+
C(G, {
|
|
1272
|
+
modelValue: n(L),
|
|
1273
|
+
"onUpdate:modelValue": _[4] || (_[4] = (w) => re(L) ? L.value = w : null),
|
|
1274
|
+
label: "Backdate transfer",
|
|
1275
|
+
sublabel: "Apply transfer to older date",
|
|
1276
|
+
"label-placement": "right",
|
|
1277
|
+
disabled: b.value && !c.lastClosingDate
|
|
1278
|
+
}, null, 8, ["modelValue", "disabled"]),
|
|
1279
|
+
Fo,
|
|
1280
|
+
n(L) ? (T(), $("div", $o, [
|
|
1281
|
+
u("div", Ao, [
|
|
1282
|
+
C(J, {
|
|
1283
|
+
modelValue: n(Y),
|
|
1284
|
+
"onUpdate:modelValue": _[5] || (_[5] = (w) => re(Y) ? Y.value = w : null)
|
|
1285
|
+
}, null, 8, ["modelValue"])
|
|
1286
|
+
]),
|
|
1287
|
+
u("div", Do, [
|
|
1288
|
+
C(_e, {
|
|
1289
|
+
modelValue: n(N),
|
|
1290
|
+
"onUpdate:modelValue": _[6] || (_[6] = (w) => re(N) ? N.value = w : null)
|
|
1291
|
+
}, null, 8, ["modelValue"])
|
|
1292
|
+
])
|
|
1293
|
+
])) : z("", !0)
|
|
1294
|
+
]),
|
|
1295
|
+
n(O) ? (T(), E(Pe, {
|
|
1296
|
+
key: 0,
|
|
1297
|
+
modelValue: n(O),
|
|
1298
|
+
"onUpdate:modelValue": _[7] || (_[7] = (w) => re(O) ? O.value = w : null),
|
|
1299
|
+
rules: [n(ht)(new Date(c.lastClosingDate), /* @__PURE__ */ new Date())]
|
|
1300
|
+
}, null, 8, ["modelValue", "rules"])) : z("", !0),
|
|
1301
|
+
b.value && !c.lastClosingDate ? (T(), $("div", Io, [
|
|
1302
|
+
C(Ke, {
|
|
1303
|
+
name: "error",
|
|
1304
|
+
size: "sm",
|
|
1305
|
+
class: "text-fm-color-typo-warning"
|
|
1306
|
+
}),
|
|
1307
|
+
Vo
|
|
1308
|
+
])) : z("", !0)
|
|
1309
|
+
])) : z("", !0)
|
|
1310
|
+
])
|
|
1311
|
+
]),
|
|
1312
|
+
u("div", Ro, [
|
|
1313
|
+
C(Pe, {
|
|
1314
|
+
"model-value": n(e).items,
|
|
1315
|
+
rules: [
|
|
1316
|
+
function(ne) {
|
|
1317
|
+
return ne && ne.length > 0 || "Must have at least one item!";
|
|
1318
|
+
}
|
|
1319
|
+
]
|
|
1320
|
+
}, null, 8, ["model-value", "rules"]),
|
|
1321
|
+
u("div", Bo, [
|
|
1322
|
+
Uo,
|
|
1323
|
+
u("div", Oo, [
|
|
1324
|
+
C(Ye, {
|
|
1325
|
+
disabled: c.disabled,
|
|
1326
|
+
label: "Add Item",
|
|
1327
|
+
"prepend-icon": "add",
|
|
1328
|
+
variant: "secondary",
|
|
1329
|
+
"text-color": "primary",
|
|
1330
|
+
"bg-color": "transparent",
|
|
1331
|
+
"border-color": "primary",
|
|
1332
|
+
onClick: _[8] || (_[8] = (w) => se()),
|
|
1333
|
+
size: "md"
|
|
1334
|
+
}, null, 8, ["disabled"]),
|
|
1335
|
+
n(e).template ? (T(), E(We, {
|
|
1336
|
+
key: 0,
|
|
1337
|
+
"z-index": 50
|
|
1338
|
+
}, {
|
|
1339
|
+
content: D(() => [
|
|
1340
|
+
Eo
|
|
1341
|
+
]),
|
|
1342
|
+
default: D(() => [
|
|
1343
|
+
C(Ve, {
|
|
1344
|
+
"onUpdate:poItems": _[9] || (_[9] = (w) => n(e).items = w),
|
|
1345
|
+
disabled: ""
|
|
1346
|
+
})
|
|
1347
|
+
]),
|
|
1348
|
+
_: 1
|
|
1349
|
+
})) : (T(), E(Ve, {
|
|
1350
|
+
key: 1,
|
|
1351
|
+
"onUpdate:poItems": _[10] || (_[10] = (w) => n(e).items = w),
|
|
1352
|
+
disabled: c.disabled || !!n(e).template
|
|
1353
|
+
}, null, 8, ["disabled"]))
|
|
1354
|
+
])
|
|
1355
|
+
]),
|
|
1356
|
+
y.value === n(x).PURCHASE && r.value && n(v).enableTotalCost && ((Fe = c.modelValue) != null && Fe.items.length) ? (T(), $("div", Mo, [
|
|
1357
|
+
C(G, {
|
|
1358
|
+
label: n(g) ? "Fetching data..." : "Compare price history",
|
|
1359
|
+
"prepend-icon": "compare_arrows",
|
|
1360
|
+
"label-placement": "right",
|
|
1361
|
+
"model-value": n(h),
|
|
1362
|
+
"onUpdate:modelValue": _[11] || (_[11] = (w) => re(h) ? h.value = w : null),
|
|
1363
|
+
disabled: n(g)
|
|
1364
|
+
}, null, 8, ["label", "model-value", "disabled"])
|
|
1365
|
+
])) : z("", !0),
|
|
1366
|
+
(T(), E(Ze, {
|
|
1367
|
+
"column-defs": de.value,
|
|
1368
|
+
"row-data": n(e).items,
|
|
1369
|
+
key: n(e).items.map((w) => w.sku._id).join("."),
|
|
1370
|
+
"hide-footer": ""
|
|
1371
|
+
}, {
|
|
1372
|
+
"table-row": D((w) => [
|
|
1373
|
+
C(Co, {
|
|
1374
|
+
"compare-price-by-sku": n(U),
|
|
1375
|
+
"show-compare-price": y.value === n(x).PURCHASE && n(h),
|
|
1376
|
+
row: w
|
|
1377
|
+
}, null, 8, ["compare-price-by-sku", "show-compare-price", "row"])
|
|
1378
|
+
]),
|
|
1379
|
+
"list-row": D((w) => [
|
|
1380
|
+
(T(), E(Ct, {
|
|
1381
|
+
row: w,
|
|
1382
|
+
key: n(e).items.map((ne) => ne.sku._id).join(".")
|
|
1383
|
+
}, {
|
|
1384
|
+
default: D((ne) => [
|
|
1385
|
+
C(Zt, {
|
|
1386
|
+
"compare-price-by-sku": n(U),
|
|
1387
|
+
"show-compare-price": y.value === n(x).PURCHASE && n(h),
|
|
1388
|
+
row: w,
|
|
1389
|
+
"cell-by-col-id": ne
|
|
1390
|
+
}, null, 8, ["compare-price-by-sku", "show-compare-price", "row", "cell-by-col-id"])
|
|
1391
|
+
]),
|
|
1392
|
+
_: 2
|
|
1393
|
+
}, 1032, ["row"]))
|
|
1394
|
+
]),
|
|
1395
|
+
_: 1
|
|
1396
|
+
}, 8, ["column-defs", "row-data"]))
|
|
1397
|
+
])
|
|
1398
|
+
];
|
|
1399
|
+
}),
|
|
1400
|
+
_: 1
|
|
1401
|
+
}, 8, ["disabled"])
|
|
1402
|
+
]);
|
|
1403
|
+
};
|
|
1404
|
+
}
|
|
1405
|
+
}), No = { class: "flex items-center" }, qo = { class: "fm-typo-en-title-md-800" }, Ho = { class: "flex gap-4" }, os = /* @__PURE__ */ oe({
|
|
1406
|
+
__name: "TransferDialog",
|
|
1407
|
+
props: {
|
|
1408
|
+
mode: {},
|
|
1409
|
+
modelValue: {},
|
|
1410
|
+
template: {},
|
|
1411
|
+
show: { type: Boolean },
|
|
1412
|
+
lastClosingDate: {}
|
|
1413
|
+
},
|
|
1414
|
+
emits: ["update:show", "submitted"],
|
|
1415
|
+
setup(t, { expose: d, emit: s }) {
|
|
1416
|
+
var N;
|
|
1417
|
+
const e = t, l = s, m = Ee(), p = ye(), k = ve(), v = Se(), o = K();
|
|
1418
|
+
async function a(h) {
|
|
1419
|
+
if (h) {
|
|
1420
|
+
y.value = !0;
|
|
1421
|
+
try {
|
|
1422
|
+
await k.readSuppliers(), y.value = !1;
|
|
1423
|
+
} catch {
|
|
1424
|
+
p.open({
|
|
1425
|
+
title: "Unable to fetch list of suppliers",
|
|
1426
|
+
message: "Try to refresh page to retry operation",
|
|
1427
|
+
type: "error"
|
|
1428
|
+
});
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
o.watchLocation(a);
|
|
1433
|
+
function r() {
|
|
1434
|
+
return {
|
|
1435
|
+
remark: void 0,
|
|
1436
|
+
ref: void 0,
|
|
1437
|
+
stockSnapshotId: void 0,
|
|
1438
|
+
effectiveAt: void 0,
|
|
1439
|
+
items: [],
|
|
1440
|
+
supplier: {
|
|
1441
|
+
_rev: void 0,
|
|
1442
|
+
email: void 0,
|
|
1443
|
+
internal: void 0,
|
|
1444
|
+
contactName: void 0,
|
|
1445
|
+
phoneNumber: void 0,
|
|
1446
|
+
registrationNumber: void 0,
|
|
1447
|
+
supplyItems: void 0,
|
|
1448
|
+
_id: "",
|
|
1449
|
+
name: "",
|
|
1450
|
+
address: {
|
|
1451
|
+
line2: void 0,
|
|
1452
|
+
line1: "",
|
|
1453
|
+
state: "",
|
|
1454
|
+
city: "",
|
|
1455
|
+
postcode: "",
|
|
1456
|
+
country: ""
|
|
1457
|
+
}
|
|
1458
|
+
},
|
|
1459
|
+
status: "DRAFT",
|
|
1460
|
+
_id: "",
|
|
1461
|
+
seqNumber: 0,
|
|
1462
|
+
deliveryOrder: []
|
|
1463
|
+
};
|
|
1464
|
+
}
|
|
1465
|
+
const b = Xe(e, "show"), f = B(e.modelValue ?? r()), i = B(((N = e.modelValue) == null ? void 0 : N._id) ?? `${Math.random()}`);
|
|
1466
|
+
fe(
|
|
1467
|
+
() => e.show,
|
|
1468
|
+
(h) => {
|
|
1469
|
+
var g;
|
|
1470
|
+
h && (f.value = e.modelValue ?? r(), i.value = ((g = e.modelValue) == null ? void 0 : g._id) ?? `${Math.random()}`);
|
|
1471
|
+
}
|
|
1472
|
+
);
|
|
1473
|
+
const y = B(!1), S = F(() => {
|
|
1474
|
+
switch (e.mode) {
|
|
1475
|
+
case te.CREATE:
|
|
1476
|
+
return "Add transfer";
|
|
1477
|
+
case te.READ:
|
|
1478
|
+
return "View transfer";
|
|
1479
|
+
case te.UPDATE:
|
|
1480
|
+
return "Edit transfer";
|
|
1481
|
+
}
|
|
1482
|
+
return "";
|
|
1483
|
+
}), I = B();
|
|
1484
|
+
d({
|
|
1485
|
+
validateInputs: () => {
|
|
1486
|
+
var h, g;
|
|
1487
|
+
(g = (h = I.value) == null ? void 0 : h.validateInputs) == null || g.call(h);
|
|
1488
|
+
},
|
|
1489
|
+
resetInputsValidation: () => {
|
|
1490
|
+
var h, g;
|
|
1491
|
+
(g = (h = I.value) == null ? void 0 : h.resetInputsValidation) == null || g.call(h);
|
|
1492
|
+
},
|
|
1493
|
+
resetInputs: () => {
|
|
1494
|
+
var h, g;
|
|
1495
|
+
(g = (h = I.value) == null ? void 0 : h.resetInputs) == null || g.call(h);
|
|
1496
|
+
}
|
|
1497
|
+
});
|
|
1498
|
+
async function Z() {
|
|
1499
|
+
const h = f.value;
|
|
1500
|
+
y.value = !0, (h.supplier.internal === "warehouse" || h.supplier.internal === "restaurant") && (h.items = h.items.map(({ totalCost: g, ...U }) => U));
|
|
1501
|
+
try {
|
|
1502
|
+
await m.createPurchaseOrder(h), await new Promise((g) => setTimeout(g, 1e3)), p.open({
|
|
1503
|
+
title: "Created",
|
|
1504
|
+
message: "Your transfer draft has been created!",
|
|
1505
|
+
type: "success"
|
|
1506
|
+
}), l("update:show", !1), l("submitted");
|
|
1507
|
+
} catch (g) {
|
|
1508
|
+
p.open({
|
|
1509
|
+
title: "Cannot create purchase order",
|
|
1510
|
+
message: "Report to system administrator for troubleshooting.",
|
|
1511
|
+
type: "error"
|
|
1512
|
+
}), console.error("Error in creating purchase order", g);
|
|
1513
|
+
} finally {
|
|
1514
|
+
y.value = !1;
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
async function O() {
|
|
1518
|
+
const h = f.value;
|
|
1519
|
+
y.value = !0, (h.supplier.internal === "warehouse" || h.supplier.internal === "restaurant") && (h.items = h.items.map(({ totalCost: g, ...U }) => U));
|
|
1520
|
+
try {
|
|
1521
|
+
await m.updatePurchaseOrder(h), await new Promise((g) => setTimeout(g, 1e3)), p.open({
|
|
1522
|
+
title: "Updated",
|
|
1523
|
+
message: "Your transfer draft has been updated!",
|
|
1524
|
+
type: "success"
|
|
1525
|
+
}), l("update:show", !1), l("submitted");
|
|
1526
|
+
} catch (g) {
|
|
1527
|
+
p.open({
|
|
1528
|
+
title: "Cannot update purchase order",
|
|
1529
|
+
message: "Report to system administrator for troubleshooting.",
|
|
1530
|
+
type: "error"
|
|
1531
|
+
}), console.error("Error in updating purchase order", g);
|
|
1532
|
+
} finally {
|
|
1533
|
+
y.value = !1;
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
function L() {
|
|
1537
|
+
switch (e.mode) {
|
|
1538
|
+
case te.CREATE:
|
|
1539
|
+
return Z();
|
|
1540
|
+
case te.UPDATE:
|
|
1541
|
+
return O();
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
function Y() {
|
|
1545
|
+
var h, g;
|
|
1546
|
+
(g = (h = I.value) == null ? void 0 : h.validateInputs) == null || g.call(h);
|
|
1547
|
+
}
|
|
1548
|
+
return (h, g) => {
|
|
1549
|
+
const U = P("FmButton"), q = P("FmSideSheet");
|
|
1550
|
+
return T(), E(q, {
|
|
1551
|
+
modelValue: n(b),
|
|
1552
|
+
"onUpdate:modelValue": g[2] || (g[2] = (H) => re(b) ? b.value = H : null),
|
|
1553
|
+
"dismiss-away": "",
|
|
1554
|
+
"close-button": "",
|
|
1555
|
+
"max-width": 900
|
|
1556
|
+
}, {
|
|
1557
|
+
"side-sheet-header": D(() => [
|
|
1558
|
+
u("div", No, [
|
|
1559
|
+
u("div", qo, M(S.value), 1)
|
|
1560
|
+
])
|
|
1561
|
+
]),
|
|
1562
|
+
default: D(() => [
|
|
1563
|
+
(T(), E(Lo, {
|
|
1564
|
+
class: "w-full",
|
|
1565
|
+
ref_key: "formRef",
|
|
1566
|
+
ref: I,
|
|
1567
|
+
onValidationSuccess: L,
|
|
1568
|
+
modelValue: f.value,
|
|
1569
|
+
"onUpdate:modelValue": g[0] || (g[0] = (H) => f.value = H),
|
|
1570
|
+
disabled: y.value,
|
|
1571
|
+
suppliers: n(k).suppliers,
|
|
1572
|
+
skus: n(v).skus,
|
|
1573
|
+
key: i.value,
|
|
1574
|
+
"last-closing-date": h.lastClosingDate
|
|
1575
|
+
}, null, 8, ["modelValue", "disabled", "suppliers", "skus", "last-closing-date"]))
|
|
1576
|
+
]),
|
|
1577
|
+
"side-sheet-footer": D(() => [
|
|
1578
|
+
u("div", Ho, [
|
|
1579
|
+
C(U, {
|
|
1580
|
+
loading: y.value,
|
|
1581
|
+
label: "Save",
|
|
1582
|
+
onClick: Y
|
|
1583
|
+
}, null, 8, ["loading"]),
|
|
1584
|
+
C(U, {
|
|
1585
|
+
disabled: y.value,
|
|
1586
|
+
variant: "tertiary",
|
|
1587
|
+
label: "Close",
|
|
1588
|
+
onClick: g[1] || (g[1] = (H) => l("update:show", !1))
|
|
1589
|
+
}, null, 8, ["disabled"])
|
|
1590
|
+
])
|
|
1591
|
+
]),
|
|
1592
|
+
_: 1
|
|
1593
|
+
}, 8, ["modelValue"]);
|
|
1594
|
+
};
|
|
1595
|
+
}
|
|
1596
|
+
});
|
|
1597
|
+
export {
|
|
1598
|
+
os as _,
|
|
1599
|
+
je as a,
|
|
1600
|
+
yo as b,
|
|
1601
|
+
ee as c,
|
|
1602
|
+
St as d,
|
|
1603
|
+
vo as e,
|
|
1604
|
+
Qt as u
|
|
1605
|
+
};
|