@feedmepos/mf-inventory-portal 0.0.22-dev.2 → 0.0.22-dev.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/App.vue.d.ts +2 -0
- package/dist/{ApprovalView-D7WEr35k.js → ApprovalView-CCYykhrK.js} +14 -14
- package/dist/{BindingsDialog-C-3uO6pD.js → BindingsDialog-33VV_AST.js} +1 -1
- package/dist/{BindingsPicker-B3tGisCE.js → BindingsPicker-BKu4vN8J.js} +8 -8
- package/dist/{BindingsTable-CPtiH3vj.js → BindingsTable-Dd0h5gDf.js} +1 -1
- package/dist/ClosingTemplateView-BhevjTLl.js +1067 -0
- package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-ohHZLOuR.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-3gp56NNJ.js} +14 -16
- package/dist/{IngredientsView-D-EKGLq9.js → IngredientsView-DckIH9eR.js} +5 -6
- package/dist/{IntegrationView-BVAO_vch.js → IntegrationView-BqQ4jRIp.js} +2 -2
- package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CJYmB7Ct.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-Vi0q_bDz.js} +1 -1
- package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-BxkM-SOw.js → PremiumBadge.vue_vue_type_script_setup_true_lang-BIL8LWRz.js} +1 -1
- package/dist/{PurchaseOrderPrintPreview-CP-mK62z.js → PurchaseOrderPrintPreview-Ct7daTTa.js} +1 -1
- package/dist/{ReceiveRequestView-x8WTvuDk.js → ReceiveRequestView-B4wHTogG.js} +25 -26
- package/dist/RecipeView-DuE4cXLz.js +590 -0
- package/dist/Standalone.vue.d.ts +2 -0
- package/dist/{StockView-SyWxT4Ee.js → StockView-Bn9v2Ix8.js} +602 -585
- package/dist/{SupplierView-a0HAZJau.js → SupplierView-C8rqHSOV.js} +37 -37
- package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-CStnY5Zh.js +851 -0
- package/dist/TransferDialog.vue_vue_type_script_setup_true_lang-DRKiv_t8.js +1511 -0
- package/dist/TransferTemplateView-RM6Y-WL4.js +1209 -0
- package/dist/{UnitView-B3c7W5lw.js → UnitView-BXISVrop.js} +4 -4
- package/dist/{WarehouseView-DDV-yslF.js → WarehouseView-B055eB90.js} +18 -18
- package/dist/api/closing-template.d.ts +14 -0
- package/dist/api/inventory.d.ts +5 -7
- package/dist/api/netsuite.d.ts +46 -0
- package/dist/api/purchase-order-template.d.ts +0 -4
- package/dist/{app-DURkcZal.js → app-9algzyce.js} +16045 -15403
- package/dist/app.d.ts +6 -0
- package/dist/app.js +2 -2
- package/dist/components/FmMinMaxInputRules.d.ts +2 -0
- package/dist/components/FmUnitInputRules.d.ts +2 -0
- package/dist/{decimal-BGJlFDm8.js → decimal-CMuMGm4y.js} +1 -1
- package/dist/{defineDeepModel-pATZSiCT.js → defineDeepModel-CjPowyho.js} +1 -1
- package/dist/extensions/promises.d.ts +14 -0
- package/dist/{format-time-from-id-BCAuJEq2.js → format-time-from-id-DNKcbBFm.js} +1 -1
- package/dist/helper/date2.d.ts +1 -0
- package/dist/helper/rules.d.ts +7 -0
- package/dist/helper/rules.spec.d.ts +1 -0
- package/dist/{id-to-date-CVHmTOJk.js → id-to-date-C6W4aVdr.js} +1 -1
- package/dist/purchase-order-transaction-type-CscRvNAR.js +680 -0
- package/dist/stores/api.d.ts +1 -0
- package/dist/stores/feature.d.ts +0 -1
- package/dist/stores/helper/core-store-proxy.d.ts +3 -0
- package/dist/stores/helper/generate-backend-urls.d.ts +1 -0
- package/dist/stores/inventory.d.ts +7 -0
- package/dist/stores/location.d.ts +24 -42
- package/dist/stores/netsuite.d.ts +56 -0
- package/dist/stores/route.d.ts +0 -5
- package/dist/stores/warehouse.d.ts +4 -7
- package/dist/style.css +1 -1
- package/dist/{supplier-DmBbGAwf.js → supplier-BiCX3dpL.js} +1 -1
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/dist/use-template-enabled-locations-2-Dtg2qOTm.js +85 -0
- package/dist/views/closing-template/components/closing-template-publish/ClosingTemplatePublish.vue.d.ts +6 -0
- package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +276 -84
- package/dist/views/closing-template/composables/use-closing-template-table.d.ts +341 -85
- package/dist/views/receive-request/components/transfer-details/TransferDetailsProps.d.ts +1 -0
- package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +916 -0
- package/dist/views/receive-request/components/transfer-form/TransferFormProps.d.ts +1 -0
- package/dist/views/receive-request/composables/use-receive-request-form.d.ts +788 -152
- package/dist/views/receive-request/composables/use-receive-request-table.d.ts +800 -164
- package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations-2.d.ts +13 -0
- package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations.d.ts +4 -7
- package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-locations.d.ts +2 -2
- package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +1285 -109
- package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +399 -993
- package/dist/views/transfer-template/helpers/remove-deleted-skus.helper.d.ts +345 -0
- package/dist/views/warehouse/components/WarehouseForm.vue.d.ts +8 -14
- package/dist/{xlsx-1DLm6bBD.js → xlsx-fKJqx2Qc.js} +1 -1
- package/dist/{xlsx.util-DLtch7r5.js → xlsx.util-LOnzE3KS.js} +2 -2
- package/package.json +5 -5
- package/dist/ClosingTemplateView-Df0lgpjS.js +0 -928
- package/dist/RecipeView-BysIWI1W.js +0 -581
- package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-ckp8gcT_.js +0 -740
- package/dist/TransferDialog.vue_vue_type_script_setup_true_lang-BSvpuWY9.js +0 -1409
- package/dist/TransferTemplateView-BGi6zd6d.js +0 -1350
- package/dist/array-ClJzD_Lt.js +0 -30
- package/dist/layout/InventoryLayout.vue.d.ts +0 -2
- package/dist/layout/layout-routes.d.ts +0 -6
- package/dist/purchase-order-transaction-type-DvSpCSXr.js +0 -712
- package/dist/use-template-enabled-locations-BiuOdu1M.js +0 -57
|
@@ -0,0 +1,680 @@
|
|
|
1
|
+
import { o as G, j as C, am as S, c as O, u as Q, z as ne, aa as se, K as ce, L as le, an as ie, ag as ue, x as de, b as me, a as pe } from "./app-9algzyce.js";
|
|
2
|
+
import { ref as y, h as I, defineComponent as fe, onMounted as he, computed as R, resolveComponent as j, openBlock as E, createElementBlock as z, createElementVNode as $, createVNode as L, createCommentVNode as ve, createBlock as K } from "vue";
|
|
3
|
+
import { i as ge } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-3gp56NNJ.js";
|
|
4
|
+
import { F as B, D as M, R as _ } from "./row-action.enum-PMKMRrZR.js";
|
|
5
|
+
import { useDialog as Y, useSnackbar as J, FmButtonVariant as q, components as H } from "@feedmepos/ui-library";
|
|
6
|
+
import { f as ye, p as be } from "./format-time-from-id-DNKcbBFm.js";
|
|
7
|
+
import { c as we } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-DlNJ6kRg.js";
|
|
8
|
+
import { useCoreStore as Te, useI18n as Se } from "@feedmepos/mf-common";
|
|
9
|
+
import { defineStore as De } from "pinia";
|
|
10
|
+
import { useRouter as Pe } from "vue-router";
|
|
11
|
+
const Ae = G((o, l) => {
|
|
12
|
+
const n = C();
|
|
13
|
+
return {
|
|
14
|
+
async readRequests(e) {
|
|
15
|
+
const t = e ?? n.currentLocationDBName, r = `${o.inventoryBackendUrl}/${t}/purchase-request`;
|
|
16
|
+
return await l.get(r);
|
|
17
|
+
},
|
|
18
|
+
async getPurchaseOrders({
|
|
19
|
+
start: e,
|
|
20
|
+
end: t
|
|
21
|
+
}) {
|
|
22
|
+
const r = n.currentLocationDBName, d = `${o.inventoryBackendUrl}/${r}/purchase-order`;
|
|
23
|
+
return await l.get(`${d}?start=${e}&end=${t}`);
|
|
24
|
+
},
|
|
25
|
+
async getPurchaseOrderById(e) {
|
|
26
|
+
const t = n.currentLocationDBName, r = `${o.inventoryBackendUrl}/${t}/purchase-order`;
|
|
27
|
+
return await l.get(`${r}/${e}`);
|
|
28
|
+
},
|
|
29
|
+
async processPurchaseOrder(e, t) {
|
|
30
|
+
const r = n.currentLocationDBName, d = t || r, f = `${o.inventoryBackendUrl}/${d}/purchase-order/run-operation`;
|
|
31
|
+
return await l.put(f, e);
|
|
32
|
+
},
|
|
33
|
+
async createPurchaseOrder(e) {
|
|
34
|
+
const t = n.currentLocationDBName, r = `${o.inventoryBackendUrl}/${t}/purchase-order`;
|
|
35
|
+
return await l.post(r, e);
|
|
36
|
+
},
|
|
37
|
+
async updatePurchaseOrder(e) {
|
|
38
|
+
const t = n.currentLocationDBName, r = `${o.inventoryBackendUrl}/${t}/purchase-order`;
|
|
39
|
+
return await l.put(r, e);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}), _e = {
|
|
43
|
+
[S.enum.confirmDraft]: {
|
|
44
|
+
primaryActions: {
|
|
45
|
+
text: "Confirm draft",
|
|
46
|
+
close: !0
|
|
47
|
+
},
|
|
48
|
+
title: "Confirm draft?",
|
|
49
|
+
message: "Purchase order cannot be changed after confirm draft.",
|
|
50
|
+
successMessage: "Purchase order draft has been confirmed"
|
|
51
|
+
},
|
|
52
|
+
[S.enum.cancelDraft]: {
|
|
53
|
+
primaryActions: {
|
|
54
|
+
text: "Cancel draft",
|
|
55
|
+
close: !0,
|
|
56
|
+
variant: "destructive"
|
|
57
|
+
},
|
|
58
|
+
title: "Cancel draft?",
|
|
59
|
+
message: "Purchase order cannot be changed after cancelled draft.",
|
|
60
|
+
successMessage: "Purchase order draft has been cancelled"
|
|
61
|
+
},
|
|
62
|
+
[S.enum.submitRequest]: {
|
|
63
|
+
primaryActions: {
|
|
64
|
+
text: "Submit request",
|
|
65
|
+
close: !0
|
|
66
|
+
},
|
|
67
|
+
title: "Confirm draft?",
|
|
68
|
+
message: "Purchase order cannot be changed after confirm draft.",
|
|
69
|
+
successMessage: "Purchase order draft has been submitted"
|
|
70
|
+
},
|
|
71
|
+
[S.enum.completeReceive]: {
|
|
72
|
+
primaryActions: {
|
|
73
|
+
text: "Mark received",
|
|
74
|
+
close: !0
|
|
75
|
+
},
|
|
76
|
+
title: "Mark as received",
|
|
77
|
+
message: "Purchase order cannot be changed after it has complete receiving.",
|
|
78
|
+
successMessage: "Purchase order has been marked as received"
|
|
79
|
+
},
|
|
80
|
+
[S.enum.approveRequest]: {
|
|
81
|
+
primaryActions: {
|
|
82
|
+
text: "Approve request",
|
|
83
|
+
close: !0
|
|
84
|
+
},
|
|
85
|
+
title: "Approve request?",
|
|
86
|
+
message: "Purchase order will be approved.",
|
|
87
|
+
successMessage: "Purchase order has been approved"
|
|
88
|
+
},
|
|
89
|
+
[S.enum.rejectRequest]: {
|
|
90
|
+
primaryActions: {
|
|
91
|
+
text: "Reject request",
|
|
92
|
+
close: !0,
|
|
93
|
+
variant: "destructive"
|
|
94
|
+
},
|
|
95
|
+
title: "Reject request?",
|
|
96
|
+
message: "Purchase order will be rejected.",
|
|
97
|
+
successMessage: "Purchase order has been rejected"
|
|
98
|
+
}
|
|
99
|
+
}, X = G((o, l) => {
|
|
100
|
+
function n() {
|
|
101
|
+
var r;
|
|
102
|
+
return `business_${((r = Te().currentBusiness.value) == null ? void 0 : r._id) ?? ""}`;
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
async getTemplate(e) {
|
|
106
|
+
const t = n(), r = `${o.inventoryBackendUrl}/${t}/purchase-order-template/${e}`;
|
|
107
|
+
return l.get(r);
|
|
108
|
+
},
|
|
109
|
+
async readTemplates() {
|
|
110
|
+
const e = n(), t = `${o.inventoryBackendUrl}/${e}/purchase-order-template`;
|
|
111
|
+
return l.get(t);
|
|
112
|
+
},
|
|
113
|
+
async createTemplate(e) {
|
|
114
|
+
const t = n(), r = `${o.inventoryBackendUrl}/${t}/purchase-order-template`;
|
|
115
|
+
return l.post(r, e);
|
|
116
|
+
},
|
|
117
|
+
async updateTemplate(e) {
|
|
118
|
+
const t = n(), r = `${o.inventoryBackendUrl}/${t}/purchase-order-template`;
|
|
119
|
+
return l.put(r, e);
|
|
120
|
+
},
|
|
121
|
+
async deleteTemplate(e) {
|
|
122
|
+
const t = n(), r = `${o.inventoryBackendUrl}/${t}/purchase-order-template`;
|
|
123
|
+
return l.delete(r, { _id: e._id, _rev: e._rev });
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}), Ce = De("transferTemplateActions", () => {
|
|
127
|
+
const o = xe("receive/request"), l = Y(), n = J(), e = X(), t = y({});
|
|
128
|
+
function r() {
|
|
129
|
+
t.value = {
|
|
130
|
+
mode: B.CREATE,
|
|
131
|
+
show: !0,
|
|
132
|
+
"onUpdate:show"(u) {
|
|
133
|
+
t.value.show = u;
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function d(u) {
|
|
138
|
+
t.value = {
|
|
139
|
+
mode: B.UPDATE,
|
|
140
|
+
modelValue: u,
|
|
141
|
+
show: !0,
|
|
142
|
+
"onUpdate:show"(g) {
|
|
143
|
+
t.value.show = g;
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function f(u, g, m) {
|
|
148
|
+
l.open({
|
|
149
|
+
title: `Confirm deleting template ${u.name}?`,
|
|
150
|
+
message: "Deleted template can no longer be retrieved",
|
|
151
|
+
primaryActions: {
|
|
152
|
+
text: "Delete",
|
|
153
|
+
variant: q.Destructive,
|
|
154
|
+
close: !0
|
|
155
|
+
},
|
|
156
|
+
secondaryActions: {
|
|
157
|
+
text: "Cancel",
|
|
158
|
+
variant: q.Plain,
|
|
159
|
+
close: !0
|
|
160
|
+
}
|
|
161
|
+
}).onPrimary(async () => {
|
|
162
|
+
n.open({
|
|
163
|
+
title: `Deleting ${u.name}`,
|
|
164
|
+
type: "info"
|
|
165
|
+
});
|
|
166
|
+
try {
|
|
167
|
+
g.value = !0;
|
|
168
|
+
const [s] = await Promise.allSettled([
|
|
169
|
+
e.deleteTemplate(u),
|
|
170
|
+
new Promise((i) => setTimeout(i, 1e3))
|
|
171
|
+
]);
|
|
172
|
+
if (s.status === "rejected") throw s.reason;
|
|
173
|
+
n.open({
|
|
174
|
+
title: `Deleted ${u.name}`,
|
|
175
|
+
type: "success"
|
|
176
|
+
});
|
|
177
|
+
} catch (s) {
|
|
178
|
+
n.open({
|
|
179
|
+
title: `Unable to delete ${u.name}`,
|
|
180
|
+
message: `See error from server: ${s}`,
|
|
181
|
+
type: "error"
|
|
182
|
+
}), console.error("error on deleting purchase order template", s);
|
|
183
|
+
} finally {
|
|
184
|
+
g.value = !1, m();
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
const p = y({});
|
|
189
|
+
function T(u) {
|
|
190
|
+
p.value = {
|
|
191
|
+
template: u,
|
|
192
|
+
show: !0,
|
|
193
|
+
"onUpdate:show"(g) {
|
|
194
|
+
p.value.show = g;
|
|
195
|
+
},
|
|
196
|
+
"onAction:edit"() {
|
|
197
|
+
p.value.show = !1, d(O(u));
|
|
198
|
+
},
|
|
199
|
+
"onAction:use"(g) {
|
|
200
|
+
const m = C(), s = m.locations.find((i) => i.doc._id === g);
|
|
201
|
+
m.selectLocation(s), p.value.show = !1, b(O(u));
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
function b(u) {
|
|
206
|
+
o.promptCreateTransferDialog({
|
|
207
|
+
...u.purchaseOrder,
|
|
208
|
+
template: u._id
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
return {
|
|
212
|
+
createTemplate: r,
|
|
213
|
+
viewTemplate: T,
|
|
214
|
+
updateTemplate: d,
|
|
215
|
+
deleteTemplate: f,
|
|
216
|
+
useTemplate: b,
|
|
217
|
+
templateDialogProps: t,
|
|
218
|
+
templateDetailsProps: p,
|
|
219
|
+
transferFormDialogProps: o.transferDialogProps
|
|
220
|
+
};
|
|
221
|
+
});
|
|
222
|
+
function W(o) {
|
|
223
|
+
const { skuById: l } = Q(), n = O(o);
|
|
224
|
+
return n.purchaseOrder.items = o.purchaseOrder.items.filter((e) => l[e.sku._id]), n;
|
|
225
|
+
}
|
|
226
|
+
const $e = "use";
|
|
227
|
+
function Ne() {
|
|
228
|
+
const { t: o } = Se(), { viewTemplate: l, updateTemplate: n, deleteTemplate: e, useTemplate: t } = Ce(), r = y(new Array()), d = y(!1), f = C(), p = X(), T = Q();
|
|
229
|
+
async function b() {
|
|
230
|
+
if (r.value = [], !!f._currentLocation) {
|
|
231
|
+
d.value = !0;
|
|
232
|
+
try {
|
|
233
|
+
const [s] = await Promise.all([
|
|
234
|
+
p.readTemplates(),
|
|
235
|
+
T.readInventory()
|
|
236
|
+
]).delayed(1e3);
|
|
237
|
+
r.value = s.map(W);
|
|
238
|
+
} catch (s) {
|
|
239
|
+
console.log("Something went wrong when fetching templates:", s);
|
|
240
|
+
} finally {
|
|
241
|
+
d.value = !1;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
async function u(s) {
|
|
246
|
+
if (!r.value.find((i) => i._id) && f._currentLocation) {
|
|
247
|
+
d.value = !0;
|
|
248
|
+
try {
|
|
249
|
+
r.value = [
|
|
250
|
+
await p.getTemplate(s).then(W).delayed(1e3)
|
|
251
|
+
];
|
|
252
|
+
} catch (i) {
|
|
253
|
+
console.log("Something went wrong when fetching templates:", i);
|
|
254
|
+
} finally {
|
|
255
|
+
d.value = !1;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
function g(s, i) {
|
|
260
|
+
switch (i = O(i), s) {
|
|
261
|
+
case $e:
|
|
262
|
+
return t(i);
|
|
263
|
+
case _.Details:
|
|
264
|
+
return l(i);
|
|
265
|
+
case _.Edit:
|
|
266
|
+
return n(i);
|
|
267
|
+
case _.Delete:
|
|
268
|
+
return e(i, d, b);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return {
|
|
272
|
+
columnDefs: [
|
|
273
|
+
{
|
|
274
|
+
id: "_id",
|
|
275
|
+
accessorKey: "_id",
|
|
276
|
+
header: () => o("inventory.transfer.table.createdAt"),
|
|
277
|
+
cell(s) {
|
|
278
|
+
return ye(`${s.getValue()}`);
|
|
279
|
+
},
|
|
280
|
+
enableSorting: !0
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
id: "name",
|
|
284
|
+
accessorKey: "name",
|
|
285
|
+
header: () => o("inventory.transfer.table.name"),
|
|
286
|
+
enableSorting: !0,
|
|
287
|
+
size: 200
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
id: "noOfItems",
|
|
291
|
+
accessorKey: "purchaseOrder.items.length",
|
|
292
|
+
header: () => o("inventory.transfer.table.noOfItems"),
|
|
293
|
+
enableSorting: !1,
|
|
294
|
+
meta: {
|
|
295
|
+
width: "10rem",
|
|
296
|
+
textAlign: "right"
|
|
297
|
+
},
|
|
298
|
+
cell(s) {
|
|
299
|
+
const i = Number(s.getValue()) || 0;
|
|
300
|
+
return i === 0 ? I("div", { class: "flex justify-end gap-4 items-center" }, [
|
|
301
|
+
I(
|
|
302
|
+
H.FmTooltip,
|
|
303
|
+
{},
|
|
304
|
+
{
|
|
305
|
+
content() {
|
|
306
|
+
return "The template is invalid due to deleted ingredients. Please update this template.";
|
|
307
|
+
},
|
|
308
|
+
default() {
|
|
309
|
+
return I(H.FmIcon, {
|
|
310
|
+
name: "error",
|
|
311
|
+
color: "system-error-300",
|
|
312
|
+
size: "sm"
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
),
|
|
317
|
+
i
|
|
318
|
+
]) : i;
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
id: "enabledLocations",
|
|
323
|
+
accessorKey: "purchaseOrder.locations.length",
|
|
324
|
+
header: () => "Enabled outlets",
|
|
325
|
+
cell(s) {
|
|
326
|
+
var w;
|
|
327
|
+
const i = (w = s.row.original.locations) == null ? void 0 : w.length;
|
|
328
|
+
return i ? `${i}` : "All";
|
|
329
|
+
},
|
|
330
|
+
enableSorting: !1,
|
|
331
|
+
meta: {
|
|
332
|
+
width: "10rem",
|
|
333
|
+
textAlign: "right"
|
|
334
|
+
}
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
id: "ref",
|
|
338
|
+
accessorKey: "purchaseOrder.ref",
|
|
339
|
+
header: () => o("inventory.transfer.table.reference"),
|
|
340
|
+
enableSorting: !1,
|
|
341
|
+
size: "auto"
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
id: "action",
|
|
345
|
+
cell(s) {
|
|
346
|
+
const i = s.row.original, w = [
|
|
347
|
+
M[_.Details],
|
|
348
|
+
M[_.Edit],
|
|
349
|
+
M[_.Delete]
|
|
350
|
+
];
|
|
351
|
+
return we(w, (x) => g(x, i));
|
|
352
|
+
},
|
|
353
|
+
enableSorting: !1,
|
|
354
|
+
size: 40,
|
|
355
|
+
meta: {
|
|
356
|
+
cellClass: "",
|
|
357
|
+
headerClass: ""
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
],
|
|
361
|
+
templates: r,
|
|
362
|
+
loading: d,
|
|
363
|
+
fetchTemplates: b,
|
|
364
|
+
loadTemplate: u
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
const Oe = { class: "flex flex-col bg-white p-16 fm-corner-radius-lg gap-16" }, Ue = {
|
|
368
|
+
key: 0,
|
|
369
|
+
class: "flex gap-8 fm-typo-en-body-md-400 text-fm-color-typo-warning"
|
|
370
|
+
}, ke = { class: "flex gap-12" }, Ee = /* @__PURE__ */ fe({
|
|
371
|
+
__name: "SelectTemplateDialog",
|
|
372
|
+
emits: ["close", "update:modelValue"],
|
|
373
|
+
setup(o, { emit: l }) {
|
|
374
|
+
const n = l, e = y(), t = Ne(), r = Pe(), d = C();
|
|
375
|
+
he(() => {
|
|
376
|
+
t.fetchTemplates();
|
|
377
|
+
});
|
|
378
|
+
const f = R(() => t.loading.value), p = R(
|
|
379
|
+
() => t.templates.value.filter(
|
|
380
|
+
(m) => !m.locations || m.locations.find((s) => s.doc._id === d.currentLocation.doc._id)
|
|
381
|
+
).filter((m) => {
|
|
382
|
+
var s;
|
|
383
|
+
return ((s = m.purchaseOrder.supplier) == null ? void 0 : s._id) !== d.currentLocation.doc._id;
|
|
384
|
+
}).map((m) => ({
|
|
385
|
+
label: m.name,
|
|
386
|
+
value: m._id
|
|
387
|
+
}))
|
|
388
|
+
);
|
|
389
|
+
function T() {
|
|
390
|
+
n("close"), r.push({ name: se.TRANSFER_TEMPLATE });
|
|
391
|
+
}
|
|
392
|
+
function b() {
|
|
393
|
+
n("close");
|
|
394
|
+
}
|
|
395
|
+
function u([m]) {
|
|
396
|
+
e.value = m;
|
|
397
|
+
}
|
|
398
|
+
function g() {
|
|
399
|
+
n("update:modelValue", e.value), b();
|
|
400
|
+
}
|
|
401
|
+
return (m, s) => {
|
|
402
|
+
const i = j("FmIcon"), w = j("FmButton");
|
|
403
|
+
return E(), z("div", Oe, [
|
|
404
|
+
s[2] || (s[2] = $("div", { class: "h-32 text-fm-color-typo-primary fm-typo-en-title-md-600" }, "Select one template", -1)),
|
|
405
|
+
L(ne, {
|
|
406
|
+
"model-value": [e.value],
|
|
407
|
+
"onUpdate:modelValue": u,
|
|
408
|
+
items: p.value,
|
|
409
|
+
loading: f.value,
|
|
410
|
+
"no-shadow": "",
|
|
411
|
+
"single-select": ""
|
|
412
|
+
}, null, 8, ["model-value", "items", "loading"]),
|
|
413
|
+
!f.value && !p.value.length ? (E(), z("div", Ue, [
|
|
414
|
+
$("div", null, [
|
|
415
|
+
L(i, {
|
|
416
|
+
name: "warning",
|
|
417
|
+
size: "sm"
|
|
418
|
+
})
|
|
419
|
+
]),
|
|
420
|
+
s[0] || (s[0] = $("div", null, "You have not configured any templates", -1))
|
|
421
|
+
])) : ve("", !0),
|
|
422
|
+
$("div", ke, [
|
|
423
|
+
s[1] || (s[1] = $("div", { class: "flex-1" }, null, -1)),
|
|
424
|
+
!f.value && !p.value.length ? (E(), K(w, {
|
|
425
|
+
key: 0,
|
|
426
|
+
label: "Create template",
|
|
427
|
+
"prepend-icon": "add",
|
|
428
|
+
onClick: T
|
|
429
|
+
})) : (E(), K(w, {
|
|
430
|
+
key: 1,
|
|
431
|
+
loading: f.value,
|
|
432
|
+
disabled: !e.value,
|
|
433
|
+
label: "Use template",
|
|
434
|
+
onClick: g
|
|
435
|
+
}, null, 8, ["loading", "disabled"])),
|
|
436
|
+
L(w, {
|
|
437
|
+
label: "Close",
|
|
438
|
+
variant: "tertiary",
|
|
439
|
+
onClick: b
|
|
440
|
+
})
|
|
441
|
+
])
|
|
442
|
+
]);
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
});
|
|
446
|
+
function Be() {
|
|
447
|
+
let o = () => {
|
|
448
|
+
}, l = (e) => Promise.reject(e);
|
|
449
|
+
const n = new Promise((e, t) => {
|
|
450
|
+
o = e, l = t;
|
|
451
|
+
});
|
|
452
|
+
return Object.defineProperty(n, "resolve", {
|
|
453
|
+
get() {
|
|
454
|
+
return o;
|
|
455
|
+
}
|
|
456
|
+
}), Object.defineProperty(n, "reject", {
|
|
457
|
+
get() {
|
|
458
|
+
return l;
|
|
459
|
+
}
|
|
460
|
+
}), n;
|
|
461
|
+
}
|
|
462
|
+
const N = y();
|
|
463
|
+
function xe(o, l) {
|
|
464
|
+
const n = Y(), e = C(), t = me(), r = y(!1), d = J(), f = Ae(), p = y(new Array()), T = y(
|
|
465
|
+
l != null && l.startDate && (l != null && l.endDate) ? l : ge()
|
|
466
|
+
), b = R(() => {
|
|
467
|
+
const c = new Date(T.value.startDate), a = new Date(T.value.endDate);
|
|
468
|
+
return {
|
|
469
|
+
start: ce(c).toISOString(),
|
|
470
|
+
end: le(a).toISOString()
|
|
471
|
+
};
|
|
472
|
+
}), u = y(new Array()), g = ie(), m = y(null);
|
|
473
|
+
function s() {
|
|
474
|
+
const c = Be();
|
|
475
|
+
let a;
|
|
476
|
+
return n.open({
|
|
477
|
+
title: "Select one template",
|
|
478
|
+
dialogComponent: Ee,
|
|
479
|
+
dialogComponentProps: {
|
|
480
|
+
onClose() {
|
|
481
|
+
n.close(), c.resolve(a);
|
|
482
|
+
},
|
|
483
|
+
"onUpdate:modelValue"(h) {
|
|
484
|
+
a = h;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}), c;
|
|
488
|
+
}
|
|
489
|
+
async function i(c) {
|
|
490
|
+
let a;
|
|
491
|
+
if (t.mustUsePoTemplate && !(c != null && c.template) && (a = await s(), !a))
|
|
492
|
+
return;
|
|
493
|
+
const h = {
|
|
494
|
+
mode: B.CREATE,
|
|
495
|
+
modelValue: c || void 0,
|
|
496
|
+
show: !0,
|
|
497
|
+
"onUpdate:show"(v) {
|
|
498
|
+
N.value.show = v;
|
|
499
|
+
},
|
|
500
|
+
templateId: a,
|
|
501
|
+
lastClosingDate: m.value
|
|
502
|
+
};
|
|
503
|
+
N.value = h;
|
|
504
|
+
}
|
|
505
|
+
function w(c) {
|
|
506
|
+
const a = {
|
|
507
|
+
mode: B.UPDATE,
|
|
508
|
+
modelValue: O(c),
|
|
509
|
+
show: !0,
|
|
510
|
+
"onUpdate:show"(h) {
|
|
511
|
+
N.value.show = h;
|
|
512
|
+
},
|
|
513
|
+
lastClosingDate: m.value
|
|
514
|
+
};
|
|
515
|
+
N.value = a;
|
|
516
|
+
}
|
|
517
|
+
async function x() {
|
|
518
|
+
p.value = [], r.value = !0;
|
|
519
|
+
try {
|
|
520
|
+
p.value = await f.getPurchaseOrders(b.value).then((h) => h.sort((v, D) => D._id.localeCompare(v._id)));
|
|
521
|
+
const c = await g.readLastClosing(!0), a = c == null ? void 0 : c._id;
|
|
522
|
+
a && (m.value = be(a));
|
|
523
|
+
} catch {
|
|
524
|
+
d.open({
|
|
525
|
+
title: "Something went wrong",
|
|
526
|
+
message: "Error at fetching purchase orders",
|
|
527
|
+
type: "error"
|
|
528
|
+
});
|
|
529
|
+
} finally {
|
|
530
|
+
r.value = !1;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
async function Z() {
|
|
534
|
+
u.value = [], r.value = !0;
|
|
535
|
+
try {
|
|
536
|
+
u.value = await f.readRequests().then((c) => c.reverse());
|
|
537
|
+
} catch {
|
|
538
|
+
d.open({
|
|
539
|
+
title: "Something went wrong",
|
|
540
|
+
message: "Error at fetching purchase requests",
|
|
541
|
+
type: "error"
|
|
542
|
+
});
|
|
543
|
+
} finally {
|
|
544
|
+
r.value = !1;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
function U() {
|
|
548
|
+
switch (o) {
|
|
549
|
+
case "receive/request":
|
|
550
|
+
return x();
|
|
551
|
+
case "approval":
|
|
552
|
+
return Z();
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
function ee(c, a) {
|
|
556
|
+
T.value = {
|
|
557
|
+
startDate: c,
|
|
558
|
+
endDate: a
|
|
559
|
+
}, U();
|
|
560
|
+
}
|
|
561
|
+
e.watchLocation(async (c) => {
|
|
562
|
+
if (!c) {
|
|
563
|
+
p.value = [];
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
await U();
|
|
567
|
+
});
|
|
568
|
+
const A = y(), V = y(Math.random().toString());
|
|
569
|
+
async function te(c, a) {
|
|
570
|
+
var P, k;
|
|
571
|
+
const h = Math.random().toString();
|
|
572
|
+
V.value = h;
|
|
573
|
+
const v = o === "receive/request" ? e.currentLocation : a == null ? void 0 : a.to, D = {
|
|
574
|
+
poRequest: a,
|
|
575
|
+
purchaseOrder: c,
|
|
576
|
+
transferTo: v == null ? void 0 : v.name,
|
|
577
|
+
transferToDbName: v == null ? void 0 : v.dbName,
|
|
578
|
+
show: !0,
|
|
579
|
+
canResubmit: !1,
|
|
580
|
+
canApprove: o === "approval",
|
|
581
|
+
"onUpdate:show"(F) {
|
|
582
|
+
A.value.show = F;
|
|
583
|
+
}
|
|
584
|
+
};
|
|
585
|
+
if (A.value = D, !(a || c.status !== ue.enum.REQUESTING)) {
|
|
586
|
+
try {
|
|
587
|
+
a = (await f.readRequests(
|
|
588
|
+
`${c.supplier.internal}_${c.supplier._id}`
|
|
589
|
+
)).find((oe) => oe.purchaseOrderId === c._id);
|
|
590
|
+
} catch {
|
|
591
|
+
console.error("Error at fetching po request to check");
|
|
592
|
+
}
|
|
593
|
+
h === V.value && (A.value.canResubmit = !a, A.value.transferTo = (P = a == null ? void 0 : a.to) == null ? void 0 : P.name, A.value.transferToDbName = (k = a == null ? void 0 : a.to) == null ? void 0 : k.dbName);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
async function re(c, a, h, v) {
|
|
597
|
+
r.value = !0;
|
|
598
|
+
try {
|
|
599
|
+
await f.processPurchaseOrder(
|
|
600
|
+
{
|
|
601
|
+
operation: a,
|
|
602
|
+
doc: c,
|
|
603
|
+
options: (
|
|
604
|
+
// auto receive for supplier to warehouse
|
|
605
|
+
(a === S.enum.confirmDraft || // auto receive for warehouse to warehouse
|
|
606
|
+
a === S.enum.completeReceive) && t.autoReceiveWarehouse ? {
|
|
607
|
+
autoReceive: !0
|
|
608
|
+
} : void 0
|
|
609
|
+
)
|
|
610
|
+
},
|
|
611
|
+
v
|
|
612
|
+
), await new Promise((k) => setTimeout(k, 1e3));
|
|
613
|
+
const P = C().currentLocationDBName.startsWith("restaurant_");
|
|
614
|
+
a === S.enum.confirmDraft && c.effectiveAt && P ? d.open({
|
|
615
|
+
title: "Success",
|
|
616
|
+
message: `${h}. The backdate will be reflected once your POS has received this change.`,
|
|
617
|
+
type: "success"
|
|
618
|
+
}) : d.open({
|
|
619
|
+
title: "Success",
|
|
620
|
+
message: h,
|
|
621
|
+
type: "success"
|
|
622
|
+
});
|
|
623
|
+
} catch (D) {
|
|
624
|
+
d.open({
|
|
625
|
+
title: "Something went wrong",
|
|
626
|
+
message: "Please try again.",
|
|
627
|
+
type: "error"
|
|
628
|
+
}), console.error("Error when submitting PO operation", a, c, D);
|
|
629
|
+
} finally {
|
|
630
|
+
r.value = !1, U();
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
async function ae(c, a, h) {
|
|
634
|
+
const v = _e[a];
|
|
635
|
+
if (!v) {
|
|
636
|
+
d.open({
|
|
637
|
+
title: "Something went wrong",
|
|
638
|
+
message: `Cannot process order: ${de(a)}`,
|
|
639
|
+
type: "error"
|
|
640
|
+
});
|
|
641
|
+
return;
|
|
642
|
+
}
|
|
643
|
+
const { successMessage: D, ...P } = v;
|
|
644
|
+
n.open({
|
|
645
|
+
title: P.title,
|
|
646
|
+
message: P.message,
|
|
647
|
+
primaryActions: P.primaryActions
|
|
648
|
+
}).onPrimary(() => {
|
|
649
|
+
re(c, a, D, h);
|
|
650
|
+
});
|
|
651
|
+
}
|
|
652
|
+
return {
|
|
653
|
+
purchaseOrders: p,
|
|
654
|
+
purchaseRequests: u,
|
|
655
|
+
updateDateRange: ee,
|
|
656
|
+
fetchData: U,
|
|
657
|
+
loading: r,
|
|
658
|
+
transferDialogProps: N,
|
|
659
|
+
promptCreateTransferDialog: i,
|
|
660
|
+
promptUpdateTransferDialog: w,
|
|
661
|
+
transferDetailsProps: A,
|
|
662
|
+
promptShowTransferDetails: te,
|
|
663
|
+
submitAction: ae
|
|
664
|
+
};
|
|
665
|
+
}
|
|
666
|
+
function We(o, l, n) {
|
|
667
|
+
const e = (n == null ? void 0 : n.abbrev) ?? l.abbrev;
|
|
668
|
+
return `${pe(o, !1)} ${e}`;
|
|
669
|
+
}
|
|
670
|
+
var Fe = /* @__PURE__ */ ((o) => (o.PURCHASE = "PURCHASE", o.TRANSFER = "TRANSFER", o))(Fe || {});
|
|
671
|
+
export {
|
|
672
|
+
Fe as P,
|
|
673
|
+
X as a,
|
|
674
|
+
Ce as b,
|
|
675
|
+
Ne as c,
|
|
676
|
+
Ae as d,
|
|
677
|
+
_e as e,
|
|
678
|
+
We as f,
|
|
679
|
+
xe as u
|
|
680
|
+
};
|
package/dist/stores/api.d.ts
CHANGED
package/dist/stores/feature.d.ts
CHANGED