@feedmepos/mf-inventory-portal 0.0.19-dev.15 → 0.0.19-dev.17
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-CRHU3Bv0.js → ApprovalView-YVJ8rI2M.js} +5 -5
- package/dist/{BindingsDialog-ChIRg0d3.js → BindingsDialog-C7ZO5bXe.js} +9 -9
- package/dist/{BindingsPicker-BJAbeiDf.js → BindingsPicker-BDsVbM3L.js} +1 -1
- package/dist/{BindingsTable-5MxWD_qa.js → BindingsTable-BiVQ4mvK.js} +1 -1
- package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-vuSl8LVG.js +308 -0
- package/dist/{IngredientsView-qXrDtzSK.js → IngredientsView-CKDZsR2e.js} +5 -5
- package/dist/{IntegrationView-D6yFqod1.js → IntegrationView-DQZeJKul.js} +2 -2
- package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DGurlvYg.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DDcFEUcz.js} +1 -1
- package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-2Ady4pB4.js → PremiumBadge.vue_vue_type_script_setup_true_lang-6plo8rnV.js} +1 -1
- package/dist/{PurchaseOrderPrintPreview-BWwjMRqb.js → PurchaseOrderPrintPreview-Df-gYZFA.js} +1 -1
- package/dist/{ReceiveRequestView-C94SWDaj.js → ReceiveRequestView-CxW1ONAk.js} +8 -8
- package/dist/{RecipeView-CG9H_ZOo.js → RecipeView-B8eIaR2f.js} +4 -4
- package/dist/{StockView-BdXGfDNl.js → StockView-CqgqPyvI.js} +8 -8
- package/dist/SupplierView-CPHQT1Hn.js +817 -0
- package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-DktBkwCx.js → TransferDetails.vue_vue_type_script_setup_true_lang-CBmoU3pN.js} +4 -4
- package/dist/TransferDialog.vue_vue_type_script_setup_true_lang-DV6IxKMM.js +1435 -0
- package/dist/TransferTemplateView-BR2-tTiQ.js +1290 -0
- package/dist/{UnitView-Dx2vWJXi.js → UnitView-vUCf46QM.js} +5 -5
- package/dist/{WarehouseView-UkmUZnqH.js → WarehouseView-B3D5kkAU.js} +3 -3
- package/dist/api/purchase-order-template.d.ts +4 -0
- package/dist/api/supplier.d.ts +6 -4
- package/dist/{app-BLzTa0Ut.js → app-Ds9lsiAo.js} +5542 -5522
- package/dist/app.js +1 -1
- package/dist/{array-AvWd53LI.js → array-ClJzD_Lt.js} +3 -3
- package/dist/components/ChangeLocationComponent.vue.d.ts +14 -11
- package/dist/components/FmInventoryTableToolbar.vue.d.ts +0 -2
- package/dist/components/FmMultiselectDialogProps.d.ts +1 -0
- package/dist/{decimal-DLYVb_I_.js → decimal-BZJuYjv-.js} +1 -1
- package/dist/format-unit-display-Dw4iQUDG.js +707 -0
- package/dist/{id-to-date-CKplrnj_.js → id-to-date-CLG4t5Zp.js} +1 -1
- package/dist/layout/SingleColumnLayout.vue.d.ts +1 -0
- package/dist/{layout-B9sdKjL9.js → layout-b03Lvqhx.js} +1 -1
- package/dist/stores/feature.d.ts +1 -0
- package/dist/stores/location.d.ts +1 -0
- package/dist/stores/supplier.d.ts +9 -9
- package/dist/supplier-C9OQNEl0.js +69 -0
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/dist/views/supplier/components/SupplierDialogProps.d.ts +0 -1
- package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +583 -1
- package/dist/{xlsx-C3AV6UrJ.js → xlsx-B5RUBjKV.js} +1209 -1209
- package/dist/{xlsx.util-slrhXhsk.js → xlsx.util-H2UkpLte.js} +4 -4
- package/package.json +3 -3
- package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-D0j4VOis.js +0 -306
- package/dist/SupplierView-ClL2oc8K.js +0 -813
- package/dist/TransferDialog.vue_vue_type_script_setup_true_lang-BE95F9r1.js +0 -1437
- package/dist/TransferTemplateView-BXrNS8pg.js +0 -1279
- package/dist/format-unit-display-D_Z4TNZd.js +0 -668
- package/dist/supplier-BZ6HZcYB.js +0 -60
|
@@ -0,0 +1,707 @@
|
|
|
1
|
+
import { n as G, j as $, ag as P, a7 as se, c as E, S as ce, y as le, a8 as ue, J as ie, K as de, ah as me, ad as pe, w as fe, b as ve, a as he } from "./app-Ds9lsiAo.js";
|
|
2
|
+
import { ref as b, computed as L, h as ge, defineComponent as ye, onMounted as be, resolveComponent as q, openBlock as k, createElementBlock as K, createElementVNode as N, createVNode as x, createCommentVNode as we, createBlock as z } from "vue";
|
|
3
|
+
import { i as Te } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-vuSl8LVG.js";
|
|
4
|
+
import { F as R, D as H, R as B } from "./row-action.enum-PMKMRrZR.js";
|
|
5
|
+
import { useDialog as J, useSnackbar as Q, FmButtonVariant as Y, components as Se } from "@feedmepos/ui-library";
|
|
6
|
+
import { c as Pe } from "./layout-b03Lvqhx.js";
|
|
7
|
+
import { useCoreStore as M, useI18n as Ae } from "@feedmepos/mf-common";
|
|
8
|
+
import { defineStore as De } from "pinia";
|
|
9
|
+
import { useRouter as $e } from "vue-router";
|
|
10
|
+
const Ce = G((e, n) => {
|
|
11
|
+
const o = $();
|
|
12
|
+
return {
|
|
13
|
+
async readRequests(t) {
|
|
14
|
+
const r = t ?? o.currentLocationDBName, a = `${e.inventoryBackendUrl}/${r}/purchase-request`;
|
|
15
|
+
return await n.get(a);
|
|
16
|
+
},
|
|
17
|
+
async getPurchaseOrders({
|
|
18
|
+
start: t,
|
|
19
|
+
end: r
|
|
20
|
+
}) {
|
|
21
|
+
const a = o.currentLocationDBName, l = `${e.inventoryBackendUrl}/${a}/purchase-order`;
|
|
22
|
+
return await n.get(`${l}?start=${t}&end=${r}`);
|
|
23
|
+
},
|
|
24
|
+
async getPurchaseOrderById(t) {
|
|
25
|
+
const r = o.currentLocationDBName, a = `${e.inventoryBackendUrl}/${r}/purchase-order`;
|
|
26
|
+
return await n.get(`${a}/${t}`);
|
|
27
|
+
},
|
|
28
|
+
async processPurchaseOrder(t, r) {
|
|
29
|
+
const a = o.currentLocationDBName, l = r || a, i = `${e.inventoryBackendUrl}/${l}/purchase-order/run-operation`;
|
|
30
|
+
return await n.put(i, t);
|
|
31
|
+
},
|
|
32
|
+
async createPurchaseOrder(t) {
|
|
33
|
+
const r = o.currentLocationDBName, a = `${e.inventoryBackendUrl}/${r}/purchase-order`;
|
|
34
|
+
return await n.post(a, t);
|
|
35
|
+
},
|
|
36
|
+
async updatePurchaseOrder(t) {
|
|
37
|
+
const r = o.currentLocationDBName, a = `${e.inventoryBackendUrl}/${r}/purchase-order`;
|
|
38
|
+
return await n.put(a, t);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}), _e = {
|
|
42
|
+
[P.enum.confirmDraft]: {
|
|
43
|
+
primaryActions: {
|
|
44
|
+
text: "Confirm draft",
|
|
45
|
+
close: !0
|
|
46
|
+
},
|
|
47
|
+
title: "Confirm draft?",
|
|
48
|
+
message: "Purchase order cannot be changed after confirm draft.",
|
|
49
|
+
successMessage: "Purchase order draft has been confirmed"
|
|
50
|
+
},
|
|
51
|
+
[P.enum.cancelDraft]: {
|
|
52
|
+
primaryActions: {
|
|
53
|
+
text: "Cancel draft",
|
|
54
|
+
close: !0,
|
|
55
|
+
variant: "destructive"
|
|
56
|
+
},
|
|
57
|
+
title: "Cancel draft?",
|
|
58
|
+
message: "Purchase order cannot be changed after cancelled draft.",
|
|
59
|
+
successMessage: "Purchase order draft has been cancelled"
|
|
60
|
+
},
|
|
61
|
+
[P.enum.submitRequest]: {
|
|
62
|
+
primaryActions: {
|
|
63
|
+
text: "Submit request",
|
|
64
|
+
close: !0
|
|
65
|
+
},
|
|
66
|
+
title: "Confirm draft?",
|
|
67
|
+
message: "Purchase order cannot be changed after confirm draft.",
|
|
68
|
+
successMessage: "Purchase order draft has been submitted"
|
|
69
|
+
},
|
|
70
|
+
[P.enum.completeReceive]: {
|
|
71
|
+
primaryActions: {
|
|
72
|
+
text: "Mark received",
|
|
73
|
+
close: !0
|
|
74
|
+
},
|
|
75
|
+
title: "Mark as received",
|
|
76
|
+
message: "Purchase order cannot be changed after it has complete receiving.",
|
|
77
|
+
successMessage: "Purchase order has been marked as received"
|
|
78
|
+
},
|
|
79
|
+
[P.enum.approveRequest]: {
|
|
80
|
+
primaryActions: {
|
|
81
|
+
text: "Approve request",
|
|
82
|
+
close: !0
|
|
83
|
+
},
|
|
84
|
+
title: "Approve request?",
|
|
85
|
+
message: "Purchase order will be approved.",
|
|
86
|
+
successMessage: "Purchase order has been approved"
|
|
87
|
+
},
|
|
88
|
+
[P.enum.rejectRequest]: {
|
|
89
|
+
primaryActions: {
|
|
90
|
+
text: "Reject request",
|
|
91
|
+
close: !0,
|
|
92
|
+
variant: "destructive"
|
|
93
|
+
},
|
|
94
|
+
title: "Reject request?",
|
|
95
|
+
message: "Purchase order will be rejected.",
|
|
96
|
+
successMessage: "Purchase order has been rejected"
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
function Ne(e) {
|
|
100
|
+
const n = Z(e);
|
|
101
|
+
return n === null ? "" : se(n);
|
|
102
|
+
}
|
|
103
|
+
function Z(e) {
|
|
104
|
+
const n = e.match(/\w+_(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z).*/);
|
|
105
|
+
if (!n) return null;
|
|
106
|
+
const o = /* @__PURE__ */ new Date(`${n[1]}`);
|
|
107
|
+
return isNaN(o.getTime()) ? null : o;
|
|
108
|
+
}
|
|
109
|
+
const X = G((e, n) => {
|
|
110
|
+
function o() {
|
|
111
|
+
var p;
|
|
112
|
+
const t = M(), r = $(), a = r.businessLevel, l = `business_${((p = t.currentBusiness.value) == null ? void 0 : p._id) ?? ""}`, i = r.currentLocation.dbName;
|
|
113
|
+
return a ? l : i;
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
async getTemplate(t) {
|
|
117
|
+
const r = o(), a = `${e.inventoryBackendUrl}/${r}/purchase-order-template/${t}`;
|
|
118
|
+
return n.get(a);
|
|
119
|
+
},
|
|
120
|
+
async getLocationTemplate(t) {
|
|
121
|
+
const a = $().currentLocation.dbName, l = `${e.inventoryBackendUrl}/${a}/purchase-order-template/${t}`;
|
|
122
|
+
return n.get(l);
|
|
123
|
+
},
|
|
124
|
+
async getBusinessTemplate(t) {
|
|
125
|
+
var i;
|
|
126
|
+
const a = `business_${((i = M().currentBusiness.value) == null ? void 0 : i._id) ?? ""}`, l = `${e.inventoryBackendUrl}/${a}/purchase-order-template/${t}`;
|
|
127
|
+
return n.get(l);
|
|
128
|
+
},
|
|
129
|
+
async readTemplates() {
|
|
130
|
+
const t = o(), r = `${e.inventoryBackendUrl}/${t}/purchase-order-template`;
|
|
131
|
+
return n.get(r);
|
|
132
|
+
},
|
|
133
|
+
async readLocationTemplates() {
|
|
134
|
+
const r = $().currentLocation.dbName, a = `${e.inventoryBackendUrl}/${r}/purchase-order-template`;
|
|
135
|
+
return n.get(a);
|
|
136
|
+
},
|
|
137
|
+
async readBusinessTemplates() {
|
|
138
|
+
var l;
|
|
139
|
+
const r = `business_${((l = M().currentBusiness.value) == null ? void 0 : l._id) ?? ""}`, a = `${e.inventoryBackendUrl}/${r}/purchase-order-template`;
|
|
140
|
+
return n.get(a);
|
|
141
|
+
},
|
|
142
|
+
async createTemplate(t) {
|
|
143
|
+
const r = o(), a = `${e.inventoryBackendUrl}/${r}/purchase-order-template`;
|
|
144
|
+
return n.post(a, t);
|
|
145
|
+
},
|
|
146
|
+
async updateTemplate(t) {
|
|
147
|
+
const r = o(), a = `${e.inventoryBackendUrl}/${r}/purchase-order-template`;
|
|
148
|
+
return n.put(a, t);
|
|
149
|
+
},
|
|
150
|
+
async deleteTemplate(t) {
|
|
151
|
+
const r = o(), a = `${e.inventoryBackendUrl}/${r}/purchase-order-template`;
|
|
152
|
+
return n.delete(a, { _id: t._id, _rev: t._rev });
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
}), Be = De("transferTemplateActions", () => {
|
|
156
|
+
const e = Fe("receive/request"), n = J(), o = Q(), t = X(), r = b({});
|
|
157
|
+
function a() {
|
|
158
|
+
r.value = {
|
|
159
|
+
mode: R.CREATE,
|
|
160
|
+
show: !0,
|
|
161
|
+
"onUpdate:show"(d) {
|
|
162
|
+
r.value.show = d;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
function l(d) {
|
|
167
|
+
r.value = {
|
|
168
|
+
mode: R.UPDATE,
|
|
169
|
+
modelValue: d,
|
|
170
|
+
show: !0,
|
|
171
|
+
"onUpdate:show"(f) {
|
|
172
|
+
r.value.show = f;
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function i(d, f, y) {
|
|
177
|
+
n.open({
|
|
178
|
+
title: `Confirm deleting template ${d.name}?`,
|
|
179
|
+
message: "Deleted template can no longer be retrieved",
|
|
180
|
+
primaryActions: {
|
|
181
|
+
text: "Delete",
|
|
182
|
+
variant: Y.Destructive,
|
|
183
|
+
close: !0
|
|
184
|
+
},
|
|
185
|
+
secondaryActions: {
|
|
186
|
+
text: "Cancel",
|
|
187
|
+
variant: Y.Plain,
|
|
188
|
+
close: !0
|
|
189
|
+
}
|
|
190
|
+
}).onPrimary(async () => {
|
|
191
|
+
o.open({
|
|
192
|
+
title: `Deleting ${d.name}`,
|
|
193
|
+
type: "info"
|
|
194
|
+
});
|
|
195
|
+
try {
|
|
196
|
+
f.value = !0;
|
|
197
|
+
const [T] = await Promise.allSettled([
|
|
198
|
+
t.deleteTemplate(d),
|
|
199
|
+
new Promise((u) => setTimeout(u, 1e3))
|
|
200
|
+
]);
|
|
201
|
+
if (T.status === "rejected") throw T.reason;
|
|
202
|
+
o.open({
|
|
203
|
+
title: `Deleted ${d.name}`,
|
|
204
|
+
type: "success"
|
|
205
|
+
});
|
|
206
|
+
} catch (T) {
|
|
207
|
+
o.open({
|
|
208
|
+
title: `Unable to delete ${d.name}`,
|
|
209
|
+
message: `See error from server: ${T}`,
|
|
210
|
+
type: "error"
|
|
211
|
+
}), console.error("error on deleting purchase order template", T);
|
|
212
|
+
} finally {
|
|
213
|
+
f.value = !1, y();
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
const p = b({});
|
|
218
|
+
function w(d) {
|
|
219
|
+
p.value = {
|
|
220
|
+
template: d,
|
|
221
|
+
show: !0,
|
|
222
|
+
"onUpdate:show"(f) {
|
|
223
|
+
p.value.show = f;
|
|
224
|
+
},
|
|
225
|
+
"onAction:edit"() {
|
|
226
|
+
p.value.show = !1, l(E(d));
|
|
227
|
+
},
|
|
228
|
+
"onAction:use"() {
|
|
229
|
+
p.value.show = !1, S(E(d));
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
function S(d) {
|
|
234
|
+
e.promptCreateTransferDialog({
|
|
235
|
+
...d.purchaseOrder,
|
|
236
|
+
template: d._id
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
return {
|
|
240
|
+
createTemplate: a,
|
|
241
|
+
viewTemplate: w,
|
|
242
|
+
updateTemplate: l,
|
|
243
|
+
deleteTemplate: i,
|
|
244
|
+
useTemplate: S,
|
|
245
|
+
templateDialogProps: r,
|
|
246
|
+
templateDetailsProps: p,
|
|
247
|
+
transferFormDialogProps: e.transferDialogProps
|
|
248
|
+
};
|
|
249
|
+
});
|
|
250
|
+
var V = /* @__PURE__ */ ((e) => (e.PURCHASE = "PURCHASE", e.TRANSFER = "TRANSFER", e))(V || {});
|
|
251
|
+
function I(e) {
|
|
252
|
+
var o;
|
|
253
|
+
return ((o = e == null ? void 0 : e.supplier) == null ? void 0 : o.internal) ? V.TRANSFER : V.PURCHASE;
|
|
254
|
+
}
|
|
255
|
+
const W = "use";
|
|
256
|
+
function Ue() {
|
|
257
|
+
const { t: e } = Ae(), { viewTemplate: n, updateTemplate: o, deleteTemplate: t, useTemplate: r } = Be(), a = b(new Array()), l = b(new Array()), i = b(!1), p = $(), w = X();
|
|
258
|
+
async function S() {
|
|
259
|
+
if (a.value = [], l.value = [], !!p._currentLocation) {
|
|
260
|
+
i.value = !0;
|
|
261
|
+
try {
|
|
262
|
+
const [u, m] = await Promise.all([
|
|
263
|
+
w.readLocationTemplates(),
|
|
264
|
+
w.readBusinessTemplates(),
|
|
265
|
+
new Promise((v) => setTimeout(v, 1e3))
|
|
266
|
+
]);
|
|
267
|
+
a.value = u, l.value = m;
|
|
268
|
+
} catch (u) {
|
|
269
|
+
console.log("Something went wrong when fetching templates:", u);
|
|
270
|
+
} finally {
|
|
271
|
+
i.value = !1;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
async function d(u) {
|
|
276
|
+
if (!a.value.find((m) => m._id) && p._currentLocation) {
|
|
277
|
+
i.value = !0;
|
|
278
|
+
try {
|
|
279
|
+
const [m] = await Promise.all([
|
|
280
|
+
w.getTemplate(u).catch((v) => {
|
|
281
|
+
if (v instanceof ce && v.errorResponse.statusCode === 404)
|
|
282
|
+
return w.getBusinessTemplate(u);
|
|
283
|
+
throw v;
|
|
284
|
+
}),
|
|
285
|
+
new Promise((v) => setTimeout(v, 1e3))
|
|
286
|
+
]);
|
|
287
|
+
a.value = [m];
|
|
288
|
+
} catch (m) {
|
|
289
|
+
console.log("Something went wrong when fetching templates:", m);
|
|
290
|
+
} finally {
|
|
291
|
+
i.value = !1;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
function f(u, m) {
|
|
296
|
+
switch (m = E(m), u) {
|
|
297
|
+
case W:
|
|
298
|
+
return r(m);
|
|
299
|
+
case B.Details:
|
|
300
|
+
return n(m);
|
|
301
|
+
case B.Edit:
|
|
302
|
+
return o(m);
|
|
303
|
+
case B.Delete:
|
|
304
|
+
return t(m, i, S);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
const y = [
|
|
308
|
+
{
|
|
309
|
+
id: "_id",
|
|
310
|
+
accessorKey: "_id",
|
|
311
|
+
header: () => e("inventory.transfer.table.createdAt"),
|
|
312
|
+
cell(u) {
|
|
313
|
+
return Ne(`${u.getValue()}`);
|
|
314
|
+
},
|
|
315
|
+
enableSorting: !0
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
id: "name",
|
|
319
|
+
accessorKey: "name",
|
|
320
|
+
header: () => e("inventory.transfer.table.name"),
|
|
321
|
+
enableSorting: !0,
|
|
322
|
+
size: 200
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
id: "supplier",
|
|
326
|
+
accessorKey: "purchaseOrder.supplier.name",
|
|
327
|
+
header: () => e("inventory.transfer.table.transferFrom"),
|
|
328
|
+
enableSorting: !0,
|
|
329
|
+
size: 200
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
id: "type",
|
|
333
|
+
header: () => e("inventory.transfer.receiveRequest.details.type.title"),
|
|
334
|
+
enableSorting: !0,
|
|
335
|
+
sortingFn(u, m) {
|
|
336
|
+
const v = I(u.original.purchaseOrder), _ = I(m.original.purchaseOrder);
|
|
337
|
+
return v.localeCompare(_);
|
|
338
|
+
},
|
|
339
|
+
size: 200,
|
|
340
|
+
cell(u) {
|
|
341
|
+
const m = I(u.row.original.purchaseOrder), v = e(
|
|
342
|
+
`inventory.transfer.receiveRequest.details.type.${m.toLocaleLowerCase()}`
|
|
343
|
+
);
|
|
344
|
+
return ge(Se.FmChip, {
|
|
345
|
+
label: v,
|
|
346
|
+
class: "fm-chip-transfer-info",
|
|
347
|
+
compact: !0
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
id: "noOfItems",
|
|
353
|
+
accessorKey: "purchaseOrder.items.length",
|
|
354
|
+
header: () => e("inventory.transfer.table.noOfItems"),
|
|
355
|
+
enableSorting: !1,
|
|
356
|
+
meta: {
|
|
357
|
+
width: "10rem",
|
|
358
|
+
textAlign: "right"
|
|
359
|
+
}
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
id: "ref",
|
|
363
|
+
accessorKey: "purchaseOrder.ref",
|
|
364
|
+
header: () => e("inventory.transfer.table.reference"),
|
|
365
|
+
enableSorting: !1,
|
|
366
|
+
size: "auto"
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
id: "action",
|
|
370
|
+
cell(u) {
|
|
371
|
+
const m = u.row.original, v = [
|
|
372
|
+
{
|
|
373
|
+
translationKey: "inventory.transfer.template.use",
|
|
374
|
+
value: W,
|
|
375
|
+
color: "text-fm-color-typo-primary"
|
|
376
|
+
},
|
|
377
|
+
H[B.Edit],
|
|
378
|
+
H[B.Delete]
|
|
379
|
+
];
|
|
380
|
+
return Pe(v, (_) => f(_, m));
|
|
381
|
+
},
|
|
382
|
+
enableSorting: !1,
|
|
383
|
+
size: 40,
|
|
384
|
+
meta: {
|
|
385
|
+
cellClass: "",
|
|
386
|
+
headerClass: ""
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
], T = L(() => [...a.value, ...l.value]);
|
|
390
|
+
return {
|
|
391
|
+
columnDefs: y,
|
|
392
|
+
locationTemplates: a,
|
|
393
|
+
businessTemplates: l,
|
|
394
|
+
templates: T,
|
|
395
|
+
loading: i,
|
|
396
|
+
fetchTemplates: S,
|
|
397
|
+
loadTemplate: d
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
const Oe = { class: "flex flex-col bg-white p-16 fm-corner-radius-lg gap-16" }, ke = {
|
|
401
|
+
key: 0,
|
|
402
|
+
class: "flex gap-8 fm-typo-en-body-md-400 text-fm-color-typo-warning"
|
|
403
|
+
}, Ee = { class: "flex gap-12" }, Le = /* @__PURE__ */ ye({
|
|
404
|
+
__name: "SelectTemplateDialog",
|
|
405
|
+
emits: ["close", "update:modelValue"],
|
|
406
|
+
setup(e, { emit: n }) {
|
|
407
|
+
const o = n, t = b(), r = Ue(), a = $e();
|
|
408
|
+
be(() => {
|
|
409
|
+
r.fetchTemplates();
|
|
410
|
+
});
|
|
411
|
+
const l = L(() => r.loading.value), i = L(
|
|
412
|
+
() => r.templates.value.map((f) => ({
|
|
413
|
+
label: f.name,
|
|
414
|
+
value: f._id
|
|
415
|
+
}))
|
|
416
|
+
);
|
|
417
|
+
function p() {
|
|
418
|
+
o("close"), a.push({ name: ue.TRANSFER_TEMPLATE });
|
|
419
|
+
}
|
|
420
|
+
function w() {
|
|
421
|
+
o("close");
|
|
422
|
+
}
|
|
423
|
+
function S([f]) {
|
|
424
|
+
t.value = f;
|
|
425
|
+
}
|
|
426
|
+
function d() {
|
|
427
|
+
o("update:modelValue", t.value), w();
|
|
428
|
+
}
|
|
429
|
+
return (f, y) => {
|
|
430
|
+
const T = q("FmIcon"), u = q("FmButton");
|
|
431
|
+
return k(), K("div", Oe, [
|
|
432
|
+
y[2] || (y[2] = N("div", { class: "h-32 text-fm-color-typo-primary fm-typo-en-title-md-600" }, "Select one template", -1)),
|
|
433
|
+
x(le, {
|
|
434
|
+
"model-value": [t.value],
|
|
435
|
+
"onUpdate:modelValue": S,
|
|
436
|
+
items: i.value,
|
|
437
|
+
loading: l.value,
|
|
438
|
+
"no-shadow": "",
|
|
439
|
+
"single-select": ""
|
|
440
|
+
}, null, 8, ["model-value", "items", "loading"]),
|
|
441
|
+
!l.value && !i.value.length ? (k(), K("div", ke, [
|
|
442
|
+
N("div", null, [
|
|
443
|
+
x(T, {
|
|
444
|
+
name: "warning",
|
|
445
|
+
size: "sm"
|
|
446
|
+
})
|
|
447
|
+
]),
|
|
448
|
+
y[0] || (y[0] = N("div", null, "You have not configured any templates", -1))
|
|
449
|
+
])) : we("", !0),
|
|
450
|
+
N("div", Ee, [
|
|
451
|
+
y[1] || (y[1] = N("div", { class: "flex-1" }, null, -1)),
|
|
452
|
+
!l.value && !i.value.length ? (k(), z(u, {
|
|
453
|
+
key: 0,
|
|
454
|
+
label: "Create template",
|
|
455
|
+
"prepend-icon": "add",
|
|
456
|
+
onClick: p
|
|
457
|
+
})) : (k(), z(u, {
|
|
458
|
+
key: 1,
|
|
459
|
+
loading: l.value,
|
|
460
|
+
disabled: !t.value,
|
|
461
|
+
label: "Use template",
|
|
462
|
+
onClick: d
|
|
463
|
+
}, null, 8, ["loading", "disabled"])),
|
|
464
|
+
x(u, {
|
|
465
|
+
label: "Close",
|
|
466
|
+
variant: "tertiary",
|
|
467
|
+
onClick: w
|
|
468
|
+
})
|
|
469
|
+
])
|
|
470
|
+
]);
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
});
|
|
474
|
+
function Re() {
|
|
475
|
+
let e = () => {
|
|
476
|
+
}, n = (t) => Promise.reject(t);
|
|
477
|
+
const o = new Promise((t, r) => {
|
|
478
|
+
e = t, n = r;
|
|
479
|
+
});
|
|
480
|
+
return Object.defineProperty(o, "resolve", {
|
|
481
|
+
get() {
|
|
482
|
+
return e;
|
|
483
|
+
}
|
|
484
|
+
}), Object.defineProperty(o, "reject", {
|
|
485
|
+
get() {
|
|
486
|
+
return n;
|
|
487
|
+
}
|
|
488
|
+
}), o;
|
|
489
|
+
}
|
|
490
|
+
function Fe(e, n) {
|
|
491
|
+
const o = J(), t = $(), r = ve(), a = b(!1), l = Q(), i = Ce(), p = b(new Array()), w = b(
|
|
492
|
+
n != null && n.startDate && (n != null && n.endDate) ? n : Te()
|
|
493
|
+
), S = L(() => {
|
|
494
|
+
const c = new Date(w.value.startDate), s = new Date(w.value.endDate);
|
|
495
|
+
return {
|
|
496
|
+
start: ie(c).toISOString(),
|
|
497
|
+
end: de(s).toISOString()
|
|
498
|
+
};
|
|
499
|
+
}), d = b(new Array()), f = me(), y = b(null);
|
|
500
|
+
function T() {
|
|
501
|
+
const c = Re();
|
|
502
|
+
let s;
|
|
503
|
+
return o.open({
|
|
504
|
+
title: "Select one template",
|
|
505
|
+
dialogComponent: Le,
|
|
506
|
+
dialogComponentProps: {
|
|
507
|
+
onClose() {
|
|
508
|
+
o.close(), c.resolve(s);
|
|
509
|
+
},
|
|
510
|
+
"onUpdate:modelValue"(h) {
|
|
511
|
+
s = h;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}), c;
|
|
515
|
+
}
|
|
516
|
+
const u = b();
|
|
517
|
+
async function m(c) {
|
|
518
|
+
let s;
|
|
519
|
+
if (r.mustUsePoTemplate && !(c != null && c.template) && (s = await T(), !s))
|
|
520
|
+
return;
|
|
521
|
+
const h = {
|
|
522
|
+
mode: R.CREATE,
|
|
523
|
+
modelValue: c || void 0,
|
|
524
|
+
show: !0,
|
|
525
|
+
"onUpdate:show"(g) {
|
|
526
|
+
u.value.show = g;
|
|
527
|
+
},
|
|
528
|
+
templateId: s,
|
|
529
|
+
lastClosingDate: y.value
|
|
530
|
+
};
|
|
531
|
+
u.value = h;
|
|
532
|
+
}
|
|
533
|
+
function v(c) {
|
|
534
|
+
const s = {
|
|
535
|
+
mode: R.UPDATE,
|
|
536
|
+
modelValue: E(c),
|
|
537
|
+
show: !0,
|
|
538
|
+
"onUpdate:show"(h) {
|
|
539
|
+
u.value.show = h;
|
|
540
|
+
},
|
|
541
|
+
lastClosingDate: y.value
|
|
542
|
+
};
|
|
543
|
+
u.value = s;
|
|
544
|
+
}
|
|
545
|
+
async function _() {
|
|
546
|
+
p.value = [], a.value = !0;
|
|
547
|
+
try {
|
|
548
|
+
p.value = await i.getPurchaseOrders(S.value).then((h) => h.sort((g, A) => A._id.localeCompare(g._id)));
|
|
549
|
+
const c = await f.readLastClosing(!0), s = c == null ? void 0 : c._id;
|
|
550
|
+
s && (y.value = Z(s));
|
|
551
|
+
} catch {
|
|
552
|
+
l.open({
|
|
553
|
+
title: "Something went wrong",
|
|
554
|
+
message: "Error at fetching purchase orders",
|
|
555
|
+
type: "error"
|
|
556
|
+
});
|
|
557
|
+
} finally {
|
|
558
|
+
a.value = !1;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
async function ee() {
|
|
562
|
+
d.value = [], a.value = !0;
|
|
563
|
+
try {
|
|
564
|
+
d.value = await i.readRequests();
|
|
565
|
+
} catch {
|
|
566
|
+
l.open({
|
|
567
|
+
title: "Something went wrong",
|
|
568
|
+
message: "Error at fetching purchase requests",
|
|
569
|
+
type: "error"
|
|
570
|
+
});
|
|
571
|
+
} finally {
|
|
572
|
+
a.value = !1;
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
function U() {
|
|
576
|
+
switch (e) {
|
|
577
|
+
case "receive/request":
|
|
578
|
+
return _();
|
|
579
|
+
case "approval":
|
|
580
|
+
return ee();
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
function te(c, s) {
|
|
584
|
+
w.value = {
|
|
585
|
+
startDate: c,
|
|
586
|
+
endDate: s
|
|
587
|
+
}, U();
|
|
588
|
+
}
|
|
589
|
+
t.watchLocation(async (c) => {
|
|
590
|
+
if (!c) {
|
|
591
|
+
p.value = [];
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
await U();
|
|
595
|
+
});
|
|
596
|
+
const C = b(), j = b(Math.random().toString());
|
|
597
|
+
async function re(c, s) {
|
|
598
|
+
var D, O;
|
|
599
|
+
const h = Math.random().toString();
|
|
600
|
+
j.value = h;
|
|
601
|
+
const g = e === "receive/request" ? t.currentLocation : s == null ? void 0 : s.to, A = {
|
|
602
|
+
purchaseOrder: c,
|
|
603
|
+
transferTo: g == null ? void 0 : g.name,
|
|
604
|
+
transferToDbName: g == null ? void 0 : g.dbName,
|
|
605
|
+
show: !0,
|
|
606
|
+
canResubmit: !1,
|
|
607
|
+
canApprove: e === "approval",
|
|
608
|
+
"onUpdate:show"(F) {
|
|
609
|
+
C.value.show = F;
|
|
610
|
+
}
|
|
611
|
+
};
|
|
612
|
+
if (C.value = A, !(s || c.status !== pe.enum.REQUESTING)) {
|
|
613
|
+
try {
|
|
614
|
+
s = (await i.readRequests(
|
|
615
|
+
`${c.supplier.internal}_${c.supplier._id}`
|
|
616
|
+
)).find((oe) => oe.purchaseOrderId === c._id);
|
|
617
|
+
} catch {
|
|
618
|
+
console.error("Error at fetching po request to check");
|
|
619
|
+
}
|
|
620
|
+
h === j.value && (C.value.canResubmit = !s, C.value.transferTo = (D = s == null ? void 0 : s.to) == null ? void 0 : D.name, C.value.transferToDbName = (O = s == null ? void 0 : s.to) == null ? void 0 : O.dbName);
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
async function ae(c, s, h, g) {
|
|
624
|
+
a.value = !0;
|
|
625
|
+
try {
|
|
626
|
+
await i.processPurchaseOrder(
|
|
627
|
+
{
|
|
628
|
+
operation: s,
|
|
629
|
+
doc: c,
|
|
630
|
+
options: (
|
|
631
|
+
// auto receive for supplier to warehouse
|
|
632
|
+
(s === P.enum.confirmDraft || // auto receive for warehouse to warehouse
|
|
633
|
+
s === P.enum.completeReceive) && r.autoReceiveWarehouse ? {
|
|
634
|
+
autoReceive: !0
|
|
635
|
+
} : void 0
|
|
636
|
+
)
|
|
637
|
+
},
|
|
638
|
+
g
|
|
639
|
+
), await new Promise((O) => setTimeout(O, 1e3));
|
|
640
|
+
const D = $().currentLocationDBName.startsWith("restaurant_");
|
|
641
|
+
s === P.enum.confirmDraft && c.effectiveAt && D ? l.open({
|
|
642
|
+
title: "Success",
|
|
643
|
+
message: `${h}. The backdate will be reflected once your POS has received this change.`,
|
|
644
|
+
type: "success"
|
|
645
|
+
}) : l.open({
|
|
646
|
+
title: "Success",
|
|
647
|
+
message: h,
|
|
648
|
+
type: "success"
|
|
649
|
+
});
|
|
650
|
+
} catch (A) {
|
|
651
|
+
l.open({
|
|
652
|
+
title: "Something went wrong",
|
|
653
|
+
message: "Please try again.",
|
|
654
|
+
type: "error"
|
|
655
|
+
}), console.error("Error when submitting PO operation", s, c, A);
|
|
656
|
+
} finally {
|
|
657
|
+
a.value = !1, U();
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
async function ne(c, s, h) {
|
|
661
|
+
const g = _e[s];
|
|
662
|
+
if (!g) {
|
|
663
|
+
l.open({
|
|
664
|
+
title: "Something went wrong",
|
|
665
|
+
message: `Cannot process order: ${fe(s)}`,
|
|
666
|
+
type: "error"
|
|
667
|
+
});
|
|
668
|
+
return;
|
|
669
|
+
}
|
|
670
|
+
const { successMessage: A, ...D } = g;
|
|
671
|
+
o.open({
|
|
672
|
+
title: D.title,
|
|
673
|
+
message: D.message,
|
|
674
|
+
primaryActions: D.primaryActions
|
|
675
|
+
}).onPrimary(() => {
|
|
676
|
+
ae(c, s, A, h);
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
return {
|
|
680
|
+
purchaseOrders: p,
|
|
681
|
+
purchaseRequests: d,
|
|
682
|
+
updateDateRange: te,
|
|
683
|
+
fetchData: U,
|
|
684
|
+
loading: a,
|
|
685
|
+
transferDialogProps: u,
|
|
686
|
+
promptCreateTransferDialog: m,
|
|
687
|
+
promptUpdateTransferDialog: v,
|
|
688
|
+
transferDetailsProps: C,
|
|
689
|
+
promptShowTransferDetails: re,
|
|
690
|
+
submitAction: ne
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
function Ye(e, n, o) {
|
|
694
|
+
const t = (o == null ? void 0 : o.abbrev) ?? n.abbrev;
|
|
695
|
+
return `${he(e, !1)} ${t}`;
|
|
696
|
+
}
|
|
697
|
+
export {
|
|
698
|
+
V as P,
|
|
699
|
+
X as a,
|
|
700
|
+
Ye as b,
|
|
701
|
+
Be as c,
|
|
702
|
+
Ue as d,
|
|
703
|
+
Ce as e,
|
|
704
|
+
Ne as f,
|
|
705
|
+
_e as g,
|
|
706
|
+
Fe as u
|
|
707
|
+
};
|
|
@@ -7,6 +7,7 @@ export interface SingleColumnLayoutProps {
|
|
|
7
7
|
showBackButton?: boolean;
|
|
8
8
|
defaultPadding?: boolean;
|
|
9
9
|
breadcrumbs?: Breadcrumbs[];
|
|
10
|
+
usingBusinessHelperText?: string;
|
|
10
11
|
}
|
|
11
12
|
export interface SingleColumnLayoutEvents {
|
|
12
13
|
(event: 'click:action', actionName: string): void;
|