@feedmepos/mf-inventory-portal 1.2.5-dev.1 → 1.2.6

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.
Files changed (70) hide show
  1. package/dist/{App-plHMDZk7.js → App-B2pFxU6Q.js} +1 -1
  2. package/dist/{ApprovalView-CChHxp4X.js → ApprovalView-MLCuBCV2.js} +49 -50
  3. package/dist/{BindingsDialog-CU-u0hJx.js → BindingsDialog-CL68c1d8.js} +2 -2
  4. package/dist/{BindingsPicker-BpbNVNQQ.js → BindingsPicker-C1PiRtoM.js} +1 -1
  5. package/dist/{BindingsTable-v1QcskCd.js → BindingsTable-B4VyAoNq.js} +1 -1
  6. package/dist/ClosingDraftView-bLQW2std.js +1739 -0
  7. package/dist/{ClosingTemplateView-ancesrdQ.js → ClosingTemplateView-CABbUEYU.js} +2 -2
  8. package/dist/{DeliveryOrderPrintPreview-DLSzR6HB.js → DeliveryOrderPrintPreview-BybM2hq8.js} +8 -8
  9. package/dist/{FmAdminBadge-Cb9aT29U.js → FmAdminBadge-iN9PJ5nY.js} +1 -1
  10. package/dist/FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-1G6EEocg.js +227 -0
  11. package/dist/{FmMultiselectDialog-SoaYz3_K.js → FmMultiselectDialog-nsl8cwzo.js} +1 -1
  12. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-D5k7Xk3M.js → FmUnitInput.vue_vue_type_script_setup_true_lang-COw0sQLE.js} +15 -15
  13. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-NY7TPnoY.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-BYcFWA7r.js} +1 -1
  14. package/dist/{IngredientGroupView-DmbPHuWG.js → IngredientGroupView-oIBLqCBm.js} +2 -2
  15. package/dist/{IngredientsView-Bxb_BeyP.js → IngredientsView-DfGezD1v.js} +61 -71
  16. package/dist/{IntegrationView-B8mnGO1_.js → IntegrationView-jcuZnZ67.js} +84 -84
  17. package/dist/{InventoryBindingForm-B2tlc3uk.js → InventoryBindingForm-CQlTv-66.js} +1 -1
  18. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-C-qi9Mri.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-CevEjjIF.js} +3 -3
  19. package/dist/{InventoryBindingSummary-BUkLwuPN.js → InventoryBindingSummary-DRJn6ORe.js} +1 -1
  20. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-4W5T_8W7.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CwwxbHy9.js} +1 -1
  21. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-DCtPbVFp.js → PremiumBadge.vue_vue_type_script_setup_true_lang-O2GL2zkX.js} +7 -7
  22. package/dist/{PublishView-Dkq9VZOG.js → PublishView-CY3Gvt3-.js} +7 -7
  23. package/dist/{PurchaseOrderPrintPreview-C-jyn09w.js → PurchaseOrderPrintPreview-Ck5HQc6r.js} +8 -8
  24. package/dist/{ReceiveRequestView-V4YNI_Jd.js → ReceiveRequestView-Da8bRntN.js} +79 -82
  25. package/dist/{RecipeView-Ck3RZRhC.js → RecipeView-B0_ddeT-.js} +3 -3
  26. package/dist/{StockView-nstUyEXe.js → StockView-BetJ_LZd.js} +7 -7
  27. package/dist/{SupplierView-eXyZsmHQ.js → SupplierView-DpDWVeHg.js} +831 -862
  28. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-AIFutKLT.js +2494 -0
  29. package/dist/{TransferTemplateView-DZG_UCWg.js → TransferTemplateView-L0NONcqq.js} +57 -57
  30. package/dist/{UnitView-COiitpcS.js → UnitView-DSTeDI8u.js} +3 -3
  31. package/dist/WarehouseView-DGJhvS_u.js +1034 -0
  32. package/dist/api/inventory.d.ts +0 -8
  33. package/dist/api/warehouse.d.ts +1 -3
  34. package/dist/{app-DayXXH4q.js → app-B7cGGPpZ.js} +15279 -15838
  35. package/dist/app.d.ts +9 -24
  36. package/dist/app.js +1 -1
  37. package/dist/{decimal-CFYWiBC2.js → decimal-DYg5n_FX.js} +1 -1
  38. package/dist/{format-unit-display-DIr9pTFo.js → format-unit-display-DHgB2J8m.js} +21 -21
  39. package/dist/{index-DLOpJmH-.js → index-C6Wn55RU.js} +1 -1
  40. package/dist/{index-tQKFc6GI.js → index-C9zJBvXv.js} +1 -1
  41. package/dist/{stock-DeAkNJnm.js → stock-BcEKPJrt.js} +1 -1
  42. package/dist/stores/feature.d.ts +0 -2
  43. package/dist/stores/inventory.d.ts +0 -1
  44. package/dist/stores/location.d.ts +1 -57
  45. package/dist/stores/supplier.d.ts +0 -96
  46. package/dist/stores/warehouse.d.ts +0 -4
  47. package/dist/{supplier-C4DAoZrI.js → supplier-DFoYi5-b.js} +1 -1
  48. package/dist/tsconfig.app.tsbuildinfo +1 -1
  49. package/dist/{use-ingredient-select-dialog-CV7X8z4O.js → use-ingredient-select-dialog-C7mHdhdS.js} +1 -1
  50. package/dist/{use-inventory-binding-dialog-nuT-Ptlx.js → use-inventory-binding-dialog-CPjMBzhD.js} +1 -1
  51. package/dist/views/closing-draft/composables/use-closing-draft-actions.d.ts +3 -3
  52. package/dist/views/closing-draft/helpers/export-draft.helper.d.ts +2 -2
  53. package/dist/views/receive-request/components/transfer-details/TransferDetailsProps.d.ts +0 -1
  54. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +0 -60
  55. package/dist/views/receive-request/composables/use-process-purchase-order.d.ts +0 -10
  56. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +0 -94
  57. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +1 -72
  58. package/dist/views/supplier/components/SupplierForm.vue.d.ts +0 -8
  59. package/dist/views/supplier/composables/use-supplier-table.d.ts +0 -4
  60. package/dist/views/transfer-template/components/transfer-template-dialog/TransferTemplateDialog.vue.d.ts +0 -8
  61. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-locations.d.ts +0 -16
  62. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +0 -48
  63. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +0 -48
  64. package/dist/views/warehouse/components/WarehouseForm.vue.d.ts +0 -8
  65. package/package.json +2 -2
  66. package/dist/ClosingDraftView-D9HwfK7e.js +0 -1687
  67. package/dist/FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-Cp0j6Sx0.js +0 -230
  68. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-OCR95cDM.js +0 -2578
  69. package/dist/WarehouseView-DhBpkfGm.js +0 -1066
  70. package/dist/api/shipment.d.ts +0 -11
@@ -1,2578 +0,0 @@
1
- import { a4 as ut, u as ve, aT as C, aU as Ue, aC as H, c as Me, b as je, ac as St, ae as wt, af as Rt, aV as xt, e as at, f as dt, a1 as et, aW as Ot, a9 as mt, V as ft, j as ge, a7 as Nt, aX as pt, aj as Ee, h as it, i as oe, D as de, aY as yt, aZ as vt, a_ as Ae, a$ as He, aA as lt, b0 as Se, T as qe, ab as Le, a5 as We, a6 as $t } from "./app-DayXXH4q.js";
2
- import { ref as M, computed as re, h as A, defineComponent as Re, reactive as kt, onMounted as ht, resolveComponent as J, openBlock as v, createBlock as me, withCtx as ne, createElementVNode as e, createVNode as F, unref as R, createElementBlock as w, toDisplayString as S, createCommentVNode as G, Fragment as ie, renderList as be, createTextVNode as $e, normalizeClass as Pe, watch as Dt, isRef as Ct, resolveDynamicComponent as At } from "vue";
3
- import { F as qt } from "./decimal-CFYWiBC2.js";
4
- import { useCoreStore as Ke, useI18n as bt } from "@feedmepos/mf-common";
5
- import { useDialog as tt, useSnackbar as ze, components as Be, FmButtonVariant as ue, useProxiedModel as Tt } from "@feedmepos/ui-library";
6
- import { F as ke } from "./FmAdminBadge-Cb9aT29U.js";
7
- import { b as Pt, u as It, P as we, f as Ft } from "./format-unit-display-DIr9pTFo.js";
8
- import { E as Lt } from "./empty-placeholder-wf6-BWE8.js";
9
- import { _ as Et, F as Bt, a as Vt } from "./FmUnitInput.vue_vue_type_script_setup_true_lang-D5k7Xk3M.js";
10
- import { u as Ut, R as ct } from "./usePromise-CbVUCxhj.js";
11
- import { u as Mt } from "./index-DLOpJmH-.js";
12
- const Ge = ut((y, t) => {
13
- const s = ve(), b = Ke();
14
- return {
15
- async readRequests(l, i, o) {
16
- const a = l ?? s.currentLocationDBName, n = `${y.inventoryBackendUrl}/${a}/purchase-request`;
17
- return i && o ? await t.get(`${n}?startDate=${i}&endDate=${o}`) : await t.get(n);
18
- },
19
- async readRequestById(l, i) {
20
- const o = i ?? s.currentLocationDBName, a = `${y.inventoryBackendUrl}/${o}/purchase-request/${l}`;
21
- return await t.get(a);
22
- },
23
- async readRequestByIds(l, i) {
24
- const o = i ?? s.currentLocationDBName, a = `${y.inventoryBackendUrl}/${o}/purchase-request/find`;
25
- return await t.post(a, { requestIds: l });
26
- },
27
- async getPurchaseOrders({
28
- start: l,
29
- end: i
30
- }) {
31
- const o = s.currentLocationDBName, a = `${y.inventoryBackendUrl}/${o}/purchase-order`;
32
- return await t.get(`${a}?start=${l}&end=${i}`);
33
- },
34
- async getLatestPurchaseOrderRequest(l) {
35
- const i = s.currentLocationDBName, o = `${y.inventoryBackendUrl}/${i}/purchase-request/find-by-purchase-order-id`;
36
- return await t.get(`${o}/${l}`);
37
- },
38
- async getPurchaseOrderById(l) {
39
- const i = s.currentLocationDBName, o = `${y.inventoryBackendUrl}/${i}/purchase-order`;
40
- return await t.get(`${o}/${l}`);
41
- },
42
- /**
43
- * @deprecated Use `processPurchaseOrderV2` instead.
44
- */
45
- async processPurchaseOrder(l, i) {
46
- const o = s.currentLocationDBName, a = i || o, n = `${y.inventoryBackendUrl}/${a}/purchase-order/run-operation`;
47
- return await t.put(n, l);
48
- },
49
- async createPurchaseOrder(l) {
50
- const i = s.currentLocationDBName, o = `${y.inventoryBackendUrl}/${i}/purchase-order`;
51
- return await t.post(o, l);
52
- },
53
- async updatePurchaseOrder(l) {
54
- const i = s.currentLocationDBName, o = `${y.inventoryBackendUrl}/${i}/purchase-order`;
55
- return await t.put(o, l);
56
- },
57
- async importFromXilnex(l) {
58
- const i = s.currentLocationDBName, o = `${y.inventoryBackendUrl}/${i}/purchase-order/import-from-xilnex`;
59
- return await t.post(o, l);
60
- },
61
- async processPurchaseOrderV2(l, i) {
62
- const o = s.currentLocationDBName, a = i || o, n = `${y.inventoryBackendUrl}/${a}/v2/purchase-order/run-operation`;
63
- return await t.put(n, l);
64
- },
65
- async getWorkflowConfig() {
66
- var a;
67
- const i = `business_${(a = b.currentBusiness.value) == null ? void 0 : a._id}`, o = `${y.inventoryBackendUrl}/${i}/v2/purchase-order/workflow-config`;
68
- return await t.get(o);
69
- }
70
- };
71
- }), jt = ut((y, t) => {
72
- const s = ve();
73
- return {
74
- async getShipments({
75
- start: b,
76
- end: l
77
- }) {
78
- const i = s.currentLocationDBName, o = `${y.inventoryBackendUrl}/${i}/shipments`;
79
- return await t.get(`${o}?start=${b}&end=${l}`);
80
- },
81
- async getShipmentsByIds(b) {
82
- if (b.length === 0)
83
- return [];
84
- const l = s.currentLocationDBName, i = `${y.inventoryBackendUrl}/${l}/shipments/get`;
85
- return await t.post(i, { shipmentIds: b });
86
- }
87
- };
88
- }), gt = {
89
- [C.enum.confirmDraft]: {
90
- primaryActions: {
91
- text: "Confirm draft",
92
- close: !0
93
- },
94
- title: "Confirm draft?",
95
- message: "Purchase order cannot be changed after confirm draft.",
96
- successMessage: "Purchase order draft has been confirmed"
97
- },
98
- [C.enum.cancelDraft]: {
99
- primaryActions: {
100
- text: "Cancel draft",
101
- close: !0,
102
- variant: "destructive"
103
- },
104
- title: "Cancel draft?",
105
- message: "Purchase order cannot be changed after cancelled draft.",
106
- successMessage: "Purchase order draft has been cancelled"
107
- },
108
- [C.enum.submitRequest]: {
109
- primaryActions: {
110
- text: "Submit request",
111
- close: !0
112
- },
113
- title: "Confirm draft?",
114
- message: "Purchase order cannot be changed after confirm draft.",
115
- successMessage: "Purchase order draft has been submitted"
116
- },
117
- [C.enum.completeReceive]: {
118
- primaryActions: {
119
- text: "Mark received",
120
- close: !0
121
- },
122
- title: "Mark as received",
123
- message: "Purchase order cannot be changed after it has complete receiving.",
124
- successMessage: "Purchase order has been marked as received"
125
- },
126
- [C.enum.approveRequest]: {
127
- primaryActions: {
128
- text: "Accept request",
129
- close: !0
130
- },
131
- title: "Accept request?",
132
- message: "Transfer out request will be accepted.",
133
- successMessage: "Transfer out request has been approved"
134
- },
135
- [C.enum.rejectRequest]: {
136
- primaryActions: {
137
- text: "Reject request",
138
- close: !0,
139
- variant: "destructive"
140
- },
141
- title: "Reject request?",
142
- message: "Purchase order will be rejected.",
143
- successMessage: "Purchase order has been rejected"
144
- },
145
- [C.enum.processRequest]: {
146
- primaryActions: {
147
- text: "Process request",
148
- close: !0,
149
- variant: "destructive"
150
- },
151
- title: "Process request?",
152
- message: "Purchase order will be processed.",
153
- successMessage: "Purchase order has been processed"
154
- }
155
- };
156
- function Ve(y) {
157
- return Ue.generatedPOReceivedMap({
158
- purchaseOrder: y
159
- });
160
- }
161
- function Kt(y) {
162
- return Ue.validatePOItemReceivedStatus({
163
- dto: y
164
- });
165
- }
166
- function Xe(y) {
167
- return Ue.validatePOReceivedStatus({
168
- receivedMap: y
169
- });
170
- }
171
- function Ze(y, t, s) {
172
- if (!H.safeParse(y).success)
173
- throw new Error(`Invalid purchase order status: ${y}`);
174
- const b = H.parse(y);
175
- return Ue.orderStatusCombination({
176
- status: b,
177
- isPOPartialReceive: t,
178
- isPOOverReceive: s
179
- });
180
- }
181
- function _t() {
182
- const y = ve(), t = Ge(), s = Me();
183
- async function b(i, o) {
184
- const a = y.currentLocationDBName;
185
- return i.doc.supplier.internal && i.operation === C.enum.confirmDraft && (i.operation = C.enum.submitRequest), await t.processPurchaseOrder(i, o || a);
186
- }
187
- async function l(i, o) {
188
- const a = y.currentLocationDBName;
189
- return await t.processPurchaseOrderV2(i, o || a);
190
- }
191
- return (i) => s.useOperatePurchaseOrderV2 ? l(i.operateV2, i.transferTo) : b(i.operate, i.transferTo);
192
- }
193
- var Je = /* @__PURE__ */ ((y) => (y.RECEIVE_REQUEST = "receive/request", y.APPROVAL = "approval", y))(Je || {});
194
- const Te = M(), Ye = M();
195
- function bn(y, t) {
196
- const s = tt(), b = ve(), l = Me();
197
- je();
198
- const i = Pt(), o = It(), a = M(!1), n = ze(), h = Ge(), O = jt(), p = M(new Array()), q = M(new Array()), m = M(
199
- t != null && t.startDate && (t != null && t.endDate) ? t : St()
200
- ), $ = re(() => {
201
- const T = new Date(m.value.startDate), I = new Date(m.value.endDate);
202
- return {
203
- start: wt(T).toISOString(),
204
- end: Rt(I).toISOString()
205
- };
206
- }), u = M(new Array()), c = xt(), g = M(null);
207
- async function N(T) {
208
- function I(Q) {
209
- const le = {
210
- mode: at.CREATE,
211
- modelValue: T || void 0,
212
- show: !0,
213
- "onUpdate:show"(r) {
214
- Te.value.show = r;
215
- },
216
- templateId: Q,
217
- lastClosingDate: g.value
218
- };
219
- Te.value = le;
220
- }
221
- let ee;
222
- l.mustUsePoTemplate && !(T != null && T.template) ? s.open({
223
- title: "Create transfer",
224
- message: "",
225
- primaryActions: {
226
- text: "Select a template",
227
- close: !0
228
- },
229
- secondaryActions: {
230
- text: "Outlet to Outlet",
231
- variant: "secondary",
232
- close: !0
233
- }
234
- }).onPrimary(async () => {
235
- ee = await i.getTemplateId(), ee && I(ee);
236
- }).onSecondary(() => {
237
- I(void 0);
238
- }) : I(ee);
239
- }
240
- function k(T) {
241
- const I = {
242
- mode: at.UPDATE,
243
- modelValue: dt(T),
244
- show: !0,
245
- "onUpdate:show"(ee) {
246
- Te.value.show = ee;
247
- },
248
- lastClosingDate: g.value
249
- };
250
- Te.value = I;
251
- }
252
- async function L() {
253
- p.value = [], q.value = [], a.value = !0;
254
- try {
255
- const T = await h.getPurchaseOrders($.value);
256
- p.value = T.sort((d, x) => x._id.localeCompare(d._id));
257
- const I = T.flatMap((d) => d.shipmentIds || []).filter(Boolean), ee = I.length > 0 ? await O.getShipmentsByIds(I) : [];
258
- q.value = ee;
259
- const Q = await c.readCurrentLocationLastClosing(!0), le = Q == null ? void 0 : Q._id;
260
- le && (g.value = Ot(le)), await l.awaitFeatureLoaded(() => l.mustUsePoTemplate) && await o.fetchTemplates();
261
- const r = p.value.map((d) => {
262
- var x;
263
- return ((x = d.request) == null ? void 0 : x.id) ?? "";
264
- }).filter((d) => d);
265
- u.value = await h.readRequestByIds(r);
266
- } catch {
267
- n.open({
268
- title: "Something went wrong",
269
- message: "Error at fetching purchase orders",
270
- type: "error"
271
- });
272
- } finally {
273
- a.value = !1;
274
- }
275
- }
276
- async function D() {
277
- u.value = [], a.value = !0;
278
- try {
279
- u.value = await h.readRequests(
280
- void 0,
281
- $.value.start,
282
- $.value.end
283
- ).then((T) => T.reverse());
284
- } catch {
285
- n.open({
286
- title: "Something went wrong",
287
- message: "Error at fetching purchase requests",
288
- type: "error"
289
- });
290
- } finally {
291
- a.value = !1;
292
- }
293
- }
294
- function B() {
295
- switch (y) {
296
- case "receive/request":
297
- return L();
298
- case "approval":
299
- return D();
300
- }
301
- }
302
- function Y(T, I) {
303
- m.value = {
304
- startDate: T,
305
- endDate: I
306
- }, B();
307
- }
308
- b.watchLocation(async (T) => {
309
- if (!T) {
310
- p.value = [];
311
- return;
312
- }
313
- await B();
314
- });
315
- const se = M(), ae = M(Math.random().toString());
316
- async function xe(T, I) {
317
- const ee = Math.random().toString();
318
- ae.value = ee, I ?? (I = u.value.computeFirst(
319
- (r) => r.purchaseOrderId === T._id ? r : null
320
- ) ?? void 0);
321
- const Q = y === "receive/request" ? b.currentLocation : I == null ? void 0 : I.to, le = {
322
- poRequest: I,
323
- purchaseOrder: T,
324
- transferTo: Q == null ? void 0 : Q.name,
325
- transferToDbName: Q == null ? void 0 : Q.dbName,
326
- show: !0,
327
- canResubmit: !1,
328
- canApprove: y === "approval",
329
- "onUpdate:show"(r) {
330
- se.value.show = r;
331
- },
332
- scope: y,
333
- receivedMap: Ve(T) ?? {},
334
- shipments: q.value
335
- };
336
- se.value = le;
337
- }
338
- async function Oe(T, I, ee, Q) {
339
- const le = _t();
340
- a.value = !0;
341
- try {
342
- await le({
343
- operate: {
344
- operation: I,
345
- doc: T,
346
- options: (
347
- // auto receive for supplier to warehouse
348
- (I === C.enum.confirmDraft || // auto receive for warehouse to warehouse
349
- I === C.enum.completeReceive) && l.autoReceiveWarehouse ? {
350
- autoReceive: !0
351
- } : void 0
352
- )
353
- },
354
- operateV2: {
355
- _id: T._id,
356
- _rev: T._rev ?? "",
357
- action: I,
358
- payloads: []
359
- },
360
- transferTo: Q
361
- }), await new Promise((x) => setTimeout(x, 1e3));
362
- const d = ve().currentLocationDBName.startsWith("restaurant_");
363
- I === C.enum.confirmDraft && T.effectiveAt && d ? n.open({
364
- title: "Success",
365
- message: `${ee}. The backdate will be reflected once your POS has received this change.`,
366
- type: "success"
367
- }) : n.open({
368
- title: "Success",
369
- message: ee,
370
- type: "success"
371
- });
372
- } catch (r) {
373
- n.open({
374
- title: "Something went wrong",
375
- message: "Please try again.",
376
- type: "error"
377
- }), console.error("Error when submitting PO operation", I, T, r);
378
- } finally {
379
- a.value = !1, B();
380
- }
381
- }
382
- async function fe(T, I, ee) {
383
- const Q = gt[I];
384
- if (!Q) {
385
- n.open({
386
- title: "Something went wrong",
387
- message: `Cannot process order: ${et(I)}`,
388
- type: "error"
389
- });
390
- return;
391
- }
392
- const { successMessage: le, ...r } = Q;
393
- s.open({
394
- title: r.title,
395
- message: r.message,
396
- primaryActions: r.primaryActions
397
- }).onPrimary(() => {
398
- Oe(T, I, le, ee);
399
- });
400
- }
401
- async function Ie() {
402
- s.open({
403
- title: "Upload Transfer",
404
- primaryActions: {
405
- text: "Xilnex transfer note",
406
- close: !0
407
- },
408
- secondaryActions: {
409
- text: "Cancel",
410
- close: !0
411
- }
412
- }).onPrimary(() => {
413
- const T = {
414
- show: !0,
415
- "onUpdate:show"(I) {
416
- Ye.value.show = I;
417
- }
418
- };
419
- Ye.value = T;
420
- });
421
- }
422
- return {
423
- purchaseOrders: p,
424
- shipments: q,
425
- purchaseRequests: u,
426
- updateDateRange: Y,
427
- fetchData: B,
428
- loading: a,
429
- transferDialogProps: Te,
430
- promptCreateTransferDialog: N,
431
- promptUpdateTransferDialog: k,
432
- transferDetailsProps: se,
433
- promptShowTransferDetails: xe,
434
- submitAction: fe,
435
- xilnexImportDialogProps: Ye,
436
- promptUploadTransferDialog: Ie
437
- };
438
- }
439
- function zt(y, t) {
440
- return t.reduce(
441
- (b, l) => {
442
- const i = l.received.find((o) => o.sku._id === y._id);
443
- return i && (b = mt(b, i.amount)), b;
444
- },
445
- qt.toPrecision(ft(0), y.unit.precision)
446
- );
447
- }
448
- function Gt(y) {
449
- const { po: t, currentLocation: s, business: b, fulfilling: l, por: i } = y, { name: o, address: a, regNo: n } = s.doc.profile, h = {
450
- name: o,
451
- registrationNumber: n,
452
- line1: a == null ? void 0 : a.line1,
453
- line2: a == null ? void 0 : a.line2,
454
- postcode: a == null ? void 0 : a.postcode,
455
- city: a == null ? void 0 : a.city,
456
- state: a == null ? void 0 : a.state,
457
- country: a == null ? void 0 : a.country
458
- }, O = {
459
- name: t.supplier.name,
460
- phoneNumber: t.supplier.phoneNumber,
461
- registrationNumber: t.supplier.registrationNumber,
462
- line1: t.supplier.address.line1,
463
- line2: t.supplier.address.line2,
464
- postcode: t.supplier.address.postcode,
465
- city: t.supplier.address.city,
466
- state: t.supplier.address.state,
467
- country: t.supplier.address.country
468
- }, p = t.items.map((k) => {
469
- const { sku: L, measurement: D } = k, B = ge(
470
- zt(k.sku, t.deliveryOrder || []),
471
- !1
472
- );
473
- return {
474
- code: L.code,
475
- description: L.name,
476
- quantity: ge(k.quantity, !1),
477
- unit: (D == null ? void 0 : D.abbrev) || L.unit.abbrev,
478
- received: B,
479
- cost: k.totalCost ? `${k.totalCost.currency} ${Nt.toFormatString({
480
- value: k.totalCost
481
- })}` : void 0
482
- };
483
- }), q = t.deliveryOrder.map((k) => ({
484
- createdAt: pt(new Date(k.createdAt)),
485
- ref: k.deliveryOrderNumber,
486
- remark: k.remark || "",
487
- items: k.received.map((L) => {
488
- var D;
489
- return {
490
- code: L.sku.code,
491
- description: L.sku.name,
492
- quantity: ge(L.amount),
493
- unit: ((D = L.measurement) == null ? void 0 : D.abbrev) || L.sku.unit.abbrev
494
- };
495
- })
496
- })), m = [
497
- // Production
498
- "67ca5d2c80bd0e001c5bf5bc",
499
- // Dev
500
- "6880b36a3054c5001db19218"
501
- ];
502
- let $ = "Inventory Receive Note";
503
- if (t.supplier.internal ? ($ = "Inventory Transfer Note", m.includes((b == null ? void 0 : b._id) || "") && ($ = "Stock Request")) : $ = "Purchase Order", i) {
504
- const k = i.from.dbName;
505
- s.dbName === k || ($ = "Inventory Receive Note");
506
- }
507
- const c = {
508
- title: $,
509
- businessName: b == null ? void 0 : b.name,
510
- logo: b == null ? void 0 : b.thumbnail,
511
- orderNumber: t.seqNumber.toString(),
512
- createdAt: Ee(t._id),
513
- ref: t.ref || "",
514
- remark: t.remark || "",
515
- buyer: h,
516
- supplier: O,
517
- items: p,
518
- status: t.status,
519
- deliveryOrders: q
520
- }, g = new URL(window.location.href), N = l && (t.deliveryFullfillment || []).length > 0 ? "receive-request/delivery-print-preview" : "receive-request/print-preview";
521
- g.pathname = g.hostname.includes("portal.feedme") ? `/inventory/${N}` : `/${N}`, g.searchParams.append("data", JSON.stringify(c)), window.open(g.href, "_blank", "noreferrer");
522
- }
523
- const Ne = {
524
- submitRequest: {
525
- translationKey: "inventory.transfer.receiveRequest.actions.submitRequest",
526
- color: "text-fm-color-typo-primary",
527
- value: C.enum.submitRequest
528
- },
529
- confirmDraft: {
530
- translationKey: "inventory.transfer.receiveRequest.actions.confirmDraft",
531
- color: "text-fm-color-typo-primary",
532
- value: C.enum.confirmDraft
533
- },
534
- cancelDraft: {
535
- translationKey: "inventory.transfer.receiveRequest.actions.cancelDraft",
536
- color: "text-fm-color-typo-error",
537
- value: C.enum.cancelDraft
538
- },
539
- approveRequest: {
540
- translationKey: "inventory.transfer.receiveRequest.actions.approveRequest",
541
- color: "text-fm-color-typo-primary",
542
- value: C.enum.approveRequest
543
- },
544
- rejectRequest: {
545
- translationKey: "inventory.transfer.receiveRequest.actions.rejectRequest",
546
- color: "text-fm-color-typo-error",
547
- value: C.enum.rejectRequest
548
- },
549
- processRequest: {
550
- translationKey: "inventory.transfer.receiveRequest.actions.processRequest",
551
- color: "text-fm-color-typo-primary",
552
- value: C.enum.processRequest
553
- },
554
- receiveStock: {
555
- translationKey: "inventory.transfer.receiveRequest.actions.receiveStock",
556
- color: "text-fm-color-typo-primary",
557
- value: C.enum.receiveStock
558
- },
559
- completeReceive: {
560
- translationKey: "inventory.transfer.receiveRequest.actions.completeReceive",
561
- color: "text-fm-color-typo-primary",
562
- value: C.enum.completeReceive
563
- },
564
- closeRequest: {
565
- translationKey: "inventory.transfer.receiveRequest.actions.closeRequest",
566
- color: "system-error-300",
567
- value: C.enum.closeRequest
568
- },
569
- approveDraft: {
570
- translationKey: "",
571
- color: "",
572
- value: void 0
573
- },
574
- rejectDraft: {
575
- translationKey: "",
576
- color: "",
577
- value: void 0
578
- },
579
- returnStock: {
580
- translationKey: "inventory.transfer.receiveRequest.actions.returnStock",
581
- color: "text-fm-color-typo-primary",
582
- value: C.enum.returnStock
583
- }
584
- };
585
- function gn(y, t, s) {
586
- const b = ve(), l = je(), i = Ke(), { t: o } = bt();
587
- function a(m) {
588
- switch (m.status) {
589
- case "DRAFT":
590
- return [
591
- de[oe.Update],
592
- de[oe.Details],
593
- m.supplier.internal === "restaurant" || m.supplier.internal === "warehouse" ? Ne[C.enum.submitRequest] : Ne[C.enum.confirmDraft],
594
- Ne[C.enum.cancelDraft]
595
- ];
596
- case "RECEIVING":
597
- return [
598
- Ne[C.enum.completeReceive],
599
- de[oe.Details],
600
- de[oe.Print]
601
- ];
602
- case "REQUESTING":
603
- return y === "receive/request" ? [de[oe.Details], de[oe.Print]] : [
604
- Ne[C.enum.approveRequest],
605
- Ne[C.enum.rejectRequest],
606
- de[oe.Details]
607
- // DefaultRowActions[RowActionEnum.Print]
608
- ];
609
- case "PROCESSING":
610
- return [de[oe.Details], de[oe.Print]];
611
- case "COMPLETE":
612
- case "CANCEL":
613
- default:
614
- return [de[oe.Details], de[oe.Print]];
615
- }
616
- }
617
- function n(m) {
618
- return Object.values(C.enum).includes(m);
619
- }
620
- async function h(m, $, u) {
621
- var g, N, k, L, D, B;
622
- const c = dt($);
623
- if (m === oe.Print) {
624
- const Y = (u == null ? void 0 : u.toInventoryLocation) ?? b.currentLocation;
625
- ((g = u == null ? void 0 : u.netSuite) != null && g.refNo || (N = c.netSuite) != null && N.refNo) && (c.ref = [((k = u == null ? void 0 : u.netSuite) == null ? void 0 : k.refNo) || ((L = c.netSuite) == null ? void 0 : L.refNo)].filter((se) => se).join(" ")), Gt({
626
- po: c,
627
- currentLocation: Y,
628
- business: i.currentBusiness.value,
629
- fulfilling: y === "approval",
630
- por: u
631
- });
632
- return;
633
- }
634
- if (m === oe.Details) {
635
- t.promptShowTransferDetails(c, u);
636
- return;
637
- }
638
- if (m === oe.Update) {
639
- (D = t.promptUpdateTransferDialog) == null || D.call(t, c);
640
- return;
641
- }
642
- if (n(m)) {
643
- t.submitAction($, m, (B = u == null ? void 0 : u.to) == null ? void 0 : B.dbName);
644
- return;
645
- }
646
- }
647
- function O() {
648
- var $;
649
- const m = [
650
- {
651
- accessorKey: "seqNumber",
652
- header: () => o("inventory.transfer.table.seqNo"),
653
- enableSorting: !0,
654
- size: 80,
655
- sortUndefined: "last"
656
- },
657
- {
658
- accessorKey: "_id",
659
- header: () => o("inventory.transfer.table.createdAt"),
660
- cell(u) {
661
- return Ee(`${u.getValue()}`);
662
- },
663
- enableSorting: !0
664
- },
665
- {
666
- accessorKey: "supplier.name",
667
- header: () => o("inventory.transfer.table.transferFrom"),
668
- enableSorting: !0,
669
- size: 200
670
- },
671
- {
672
- accessorKey: "items.length",
673
- header: () => o("inventory.transfer.table.noOfItems"),
674
- cell: (u) => {
675
- const c = u.row.original.version || "1", g = u.getValue();
676
- return A("div", { class: "flex items-center gap-2" }, [
677
- g,
678
- c !== "1" ? A(
679
- "div",
680
- { class: "py-3" },
681
- A(
682
- ke,
683
- A(
684
- "div",
685
- {
686
- class: ["fm-status-badge", "fm-status-badge-draft"].join(" ")
687
- },
688
- `v${c}`
689
- )
690
- )
691
- ) : null
692
- ]);
693
- },
694
- enableSorting: !1,
695
- meta: {
696
- width: "10rem"
697
- }
698
- },
699
- {
700
- accessorKey: "ref",
701
- header: () => o("inventory.transfer.table.reference"),
702
- enableSorting: !1,
703
- size: "auto"
704
- },
705
- ...($ = i.sessionUser.value) != null && $.role.isAdmin ? [
706
- {
707
- id: "statusForAdmin",
708
- header: () => A(ke, {}, () => `${o("inventory.transfer.table.status")}`),
709
- cell(u) {
710
- return u.row.original.status;
711
- },
712
- enableSorting: !0,
713
- size: 200
714
- }
715
- ] : [],
716
- {
717
- accessorKey: "status",
718
- header: () => o("inventory.transfer.table.status"),
719
- cell(u) {
720
- const c = u.getValue(), g = Ve(u.row.original), { partial: N, over: k } = Xe(g), L = Ze(c ?? "", N, k);
721
- let D = o(`inventory.transfer.status.${L}`), B = `${c ?? ""}`.toLocaleLowerCase("en-us");
722
- L === H.enum.CLOSE && (D = `${o(`inventory.transfer.status.${H.enum.COMPLETE}`)}`), L === "PARTIAL_RECEIVED" && B === H.enum.PROCESSING.toLocaleLowerCase("en-us") && (B = H.enum.RECEIVING.toLocaleLowerCase("en-us"));
723
- let Y = null;
724
- const se = s.value.find((ae) => ae.ref === u.row.original._id);
725
- if (se != null && se.milestones && se.milestones.length > 0) {
726
- const ae = se.milestones[se.milestones.length - 1];
727
- if (ae.estimatedTime) {
728
- const xe = new Date(ae.estimatedTime), Oe = xe.getDate().toString().padStart(2, "0");
729
- Y = `${xe.toLocaleString("en-US", { month: "short" })} ${Oe}`;
730
- }
731
- }
732
- return A(
733
- "div",
734
- {
735
- class: "flex"
736
- },
737
- [
738
- A(
739
- "div",
740
- { class: "flex items-center" },
741
- A(
742
- "div",
743
- {
744
- class: [
745
- "fm-status-badge",
746
- `fm-status-badge-${B}`,
747
- k && "fm-status-badge-error"
748
- ].filter(Boolean).join(" ")
749
- },
750
- `${D}`
751
- )
752
- ),
753
- ...Y ? [
754
- A(
755
- "div",
756
- {
757
- class: "flex items-center gap-1 ml-2"
758
- },
759
- [
760
- A(Be.FmIcon, {
761
- name: "local_shipping",
762
- size: "md",
763
- color: "neutral-gray-400"
764
- }),
765
- A(
766
- "span",
767
- { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" },
768
- Y
769
- )
770
- ]
771
- )
772
- ] : []
773
- ]
774
- );
775
- },
776
- enableSorting: !0,
777
- size: 150
778
- },
779
- {
780
- id: "action",
781
- cell(u) {
782
- const c = u.row.original, g = a(c);
783
- return it(g, (N) => h(N, c));
784
- },
785
- enableSorting: !1,
786
- size: 40,
787
- meta: {
788
- cellClass: "",
789
- headerClass: ""
790
- }
791
- }
792
- ];
793
- if (l.isEnabled) {
794
- const u = [
795
- {
796
- id: "netsuiteTransferOrder",
797
- accessorFn: (c) => {
798
- var g;
799
- return (g = c.netSuite) != null && g.id ? `${c.netSuite.refNo} (${c.netSuite.id})` : "N/A";
800
- },
801
- header: () => "NetSuite Order (ID)",
802
- cell(c) {
803
- var N;
804
- const g = c.row.original;
805
- return (N = g.netSuite) != null && N.id ? `${g.netSuite.refNo} (${g.netSuite.id})` : "N/A";
806
- },
807
- enableSorting: !1,
808
- size: 200,
809
- meta: {
810
- cellClass: "",
811
- headerClass: ""
812
- }
813
- },
814
- {
815
- id: "netsuiteTransactionNumber",
816
- accessorFn: (c) => {
817
- var g, N;
818
- return ((N = (g = c.netSuite) == null ? void 0 : g.additionalInfo) == null ? void 0 : N.transactionnumber) ?? "N/A";
819
- },
820
- header: () => "NetSuite Transaction No.",
821
- cell(c) {
822
- var N, k;
823
- return ((k = (N = c.row.original.netSuite) == null ? void 0 : N.additionalInfo) == null ? void 0 : k.transactionnumber) ?? "N/A";
824
- },
825
- enableSorting: !1,
826
- size: 200,
827
- meta: {
828
- cellClass: "",
829
- headerClass: ""
830
- }
831
- }
832
- ];
833
- m.splice(m.length - 1, 0, ...u);
834
- }
835
- return m;
836
- }
837
- function p() {
838
- var $;
839
- const m = [
840
- {
841
- accessorKey: "purchaseOrder.seqNumber",
842
- header: () => o("inventory.transfer.table.seqNo"),
843
- enableSorting: !0,
844
- size: 80,
845
- sortUndefined: "last"
846
- },
847
- {
848
- accessorKey: "purchaseOrder._id",
849
- header: () => o("inventory.transfer.table.createdAt"),
850
- cell(u) {
851
- return Ee(`${u.getValue()}`);
852
- },
853
- enableSorting: !0
854
- },
855
- {
856
- accessorKey: "to.name",
857
- header: () => o("inventory.transfer.table.transferTo"),
858
- enableSorting: !1,
859
- size: 200
860
- },
861
- {
862
- accessorKey: "purchaseOrder.items.length",
863
- header: () => o("inventory.transfer.table.noOfItems"),
864
- enableSorting: !1
865
- },
866
- {
867
- accessorKey: "purchaseOrder.ref",
868
- header: () => o("inventory.transfer.table.reference"),
869
- enableSorting: !1,
870
- size: "auto"
871
- },
872
- ...($ = i.sessionUser.value) != null && $.role.isAdmin ? [
873
- {
874
- id: "statusForAdmin",
875
- header: () => A(ke, {}, () => `${o("inventory.transfer.table.status")}`),
876
- cell(u) {
877
- return u.row.original.status;
878
- },
879
- enableSorting: !0,
880
- size: 200
881
- }
882
- ] : [],
883
- {
884
- accessorKey: "purchaseOrder.status",
885
- header: () => o("inventory.transfer.table.status"),
886
- cell(u) {
887
- const c = u.row.original, g = u.getValue();
888
- if (!c.purchaseOrder)
889
- return A(Be.FmChip, {
890
- label: "N/A",
891
- compact: !0
892
- });
893
- const N = Ve(c.purchaseOrder), { partial: k, over: L } = Xe(N), D = Ze(g ?? "", k, L);
894
- let B = o(`inventory.transfer.status.${D}`), Y = `${g ?? ""}`.toLocaleLowerCase("en-us");
895
- return D === H.enum.CLOSE && (B = `${o(`inventory.transfer.status.${H.enum.COMPLETE}`)}`), D === "PARTIAL_RECEIVED" && Y === H.enum.PROCESSING.toLocaleLowerCase("en-us") && (Y = H.enum.RECEIVING.toLocaleLowerCase("en-us")), A(
896
- "div",
897
- {
898
- class: "flex"
899
- },
900
- A(
901
- "div",
902
- {
903
- class: [
904
- "fm-status-badge",
905
- `fm-status-badge-${Y}`,
906
- L && "fm-status-badge-error"
907
- ].filter(Boolean).join(" ")
908
- },
909
- `${B}`
910
- )
911
- );
912
- },
913
- enableSorting: !0
914
- },
915
- {
916
- id: "action",
917
- cell(u) {
918
- const c = u.row.original, N = (c.purchaseOrder ? a(c.purchaseOrder) : []).map((k) => k.value === oe.Print ? {
919
- ...k,
920
- translationKey: "inventory.transfer.receiveRequest.details.printDeliveryOrder"
921
- } : k);
922
- return it(
923
- N,
924
- (k) => c.purchaseOrder ? h(k, c.purchaseOrder, c) : void 0
925
- );
926
- },
927
- enableSorting: !1,
928
- size: 40,
929
- meta: {
930
- cellClass: "",
931
- headerClass: ""
932
- }
933
- }
934
- ];
935
- if (l.isEnabled) {
936
- const u = [
937
- {
938
- id: "netsuiteTransferOrder",
939
- accessorFn: (c) => {
940
- var g;
941
- return (g = c.netSuite) != null && g.id ? `${c.netSuite.refNo} (${c.netSuite.id})` : "N/A";
942
- },
943
- header: () => "NetSuite Order (ID)",
944
- cell(c) {
945
- var N;
946
- const g = c.row.original;
947
- return (N = g.netSuite) != null && N.id ? `${g.netSuite.refNo} (${g.netSuite.id})` : "N/A";
948
- },
949
- enableSorting: !1,
950
- size: 200,
951
- meta: {
952
- cellClass: "",
953
- headerClass: ""
954
- }
955
- },
956
- {
957
- id: "netsuiteTransactionNumber",
958
- accessorFn: (c) => {
959
- var g, N;
960
- return ((N = (g = c.netSuite) == null ? void 0 : g.additionalInfo) == null ? void 0 : N.transactionnumber) ?? "N/A";
961
- },
962
- header: () => "NetSuite Transaction No.",
963
- cell(c) {
964
- var N, k;
965
- return ((k = (N = c.row.original.netSuite) == null ? void 0 : N.additionalInfo) == null ? void 0 : k.transactionnumber) ?? "N/A";
966
- },
967
- enableSorting: !1,
968
- size: 200,
969
- meta: {
970
- cellClass: "",
971
- headerClass: ""
972
- }
973
- }
974
- ];
975
- m.splice(m.length - 2, 0, ...u);
976
- }
977
- return m;
978
- }
979
- return {
980
- columnDefs: re(() => y === "receive/request" ? O() : p())
981
- };
982
- }
983
- const Ht = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, Wt = { class: "flex flex-col gap-8" }, Yt = { class: "flex w-full justify-end gap-16" }, Qt = /* @__PURE__ */ Re({
984
- __name: "FulfillmentForm",
985
- props: {
986
- purchaseOrder: {},
987
- confirm: { type: Function }
988
- },
989
- emits: ["update:show"],
990
- setup(y, { emit: t }) {
991
- const s = y, b = kt({
992
- id: "",
993
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
994
- items: []
995
- }), l = M(), i = t;
996
- ht(() => {
997
- s.purchaseOrder && (b.items = s.purchaseOrder.items.map((a) => ({
998
- id: a.id,
999
- sku: a.sku,
1000
- measurement: a.measurement,
1001
- amount: a.quantity ?? { amount: 1, precision: 0 }
1002
- })));
1003
- });
1004
- const o = re(() => b.items.length <= 10);
1005
- return (a, n) => {
1006
- const h = J("FmTable"), O = J("FmButton"), p = J("FmForm");
1007
- return v(), me(p, {
1008
- ref_key: "formRef",
1009
- ref: l,
1010
- class: "bg-white flex flex-col gap-32 rounded-3xl p-24 w-[800px]",
1011
- onValidationFailed: console.log,
1012
- onValidationSuccess: n[1] || (n[1] = () => s.confirm(b))
1013
- }, {
1014
- default: ne(() => [
1015
- n[2] || (n[2] = e("div", { class: "fm-typo-en-title-sm-600" }, "Confirm the transfer amount", -1)),
1016
- e("div", Ht, [
1017
- e("div", Wt, [
1018
- F(h, {
1019
- "column-defs": [
1020
- {
1021
- header: "Code",
1022
- cell: (q) => {
1023
- const m = s.purchaseOrder.items.find(($) => $.id === q.row.original.id || $.sku._id === q.row.original.sku._id);
1024
- return A(
1025
- R(Be).FmTooltip,
1026
- {
1027
- content: m.code,
1028
- placement: "top",
1029
- variant: "plain",
1030
- zIndex: 50
1031
- },
1032
- A(
1033
- "span",
1034
- {
1035
- class: "flex-auto line-clamp-2 text-ellipsis break-all"
1036
- },
1037
- m.code
1038
- )
1039
- );
1040
- }
1041
- },
1042
- {
1043
- header: "Name",
1044
- cell: (q) => {
1045
- const m = s.purchaseOrder.items.find(($) => $.id === q.row.original.id || $.sku._id === q.row.original.sku._id);
1046
- return A(
1047
- R(Be).FmTooltip,
1048
- {
1049
- content: m.name,
1050
- placement: "top",
1051
- variant: "plain",
1052
- zIndex: 50
1053
- },
1054
- A(
1055
- "span",
1056
- {
1057
- class: "flex-auto line-clamp-2 text-ellipsis break-all"
1058
- },
1059
- m.name
1060
- )
1061
- );
1062
- }
1063
- },
1064
- {
1065
- header: "Amount",
1066
- cell: (q) => {
1067
- const m = q.row.original, $ = s.purchaseOrder.items.find((c) => c.id === m.id || c.sku._id === m.sku._id), u = m.amount ?? {
1068
- amount: 1,
1069
- precision: 0
1070
- };
1071
- return A(Et, {
1072
- style: {
1073
- flex: "1 1 0%"
1074
- },
1075
- modelValue: {
1076
- amount: u,
1077
- measurement: m.measurement ?? null
1078
- },
1079
- key: m.id ?? m.sku._id,
1080
- unit: m.sku.unit,
1081
- "onUpdate:modelValue": (c) => {
1082
- if (!c) return;
1083
- const g = b.items.find((N) => N.id === m.id || N.sku._id === m.sku._id);
1084
- g && (g.amount = c.amount);
1085
- },
1086
- disableUnit: !0,
1087
- rules: [
1088
- R(Bt)(
1089
- +R(ge)({ amount: 0, precision: 0 })
1090
- ),
1091
- R(Vt)(+R(ge)($.quantity))
1092
- ],
1093
- applyDefaultRules: !0
1094
- });
1095
- }
1096
- }
1097
- ],
1098
- "row-data": b.items,
1099
- "hide-footer": o.value
1100
- }, null, 8, ["column-defs", "row-data", "hide-footer"])
1101
- ])
1102
- ]),
1103
- e("div", Yt, [
1104
- F(O, {
1105
- class: "px-16",
1106
- label: "Confirm",
1107
- size: "md",
1108
- variant: "primary",
1109
- type: "submit"
1110
- }),
1111
- F(O, {
1112
- class: "px-16",
1113
- label: "Cancel",
1114
- size: "md",
1115
- variant: "secondary",
1116
- onClick: n[0] || (n[0] = () => i("update:show", !1))
1117
- })
1118
- ])
1119
- ]),
1120
- _: 1
1121
- }, 8, ["onValidationFailed"]);
1122
- };
1123
- }
1124
- }), Qe = {
1125
- submitRequest: {
1126
- translationKey: "inventory.transfer.receiveRequest.actions.submitRequest",
1127
- color: "primary",
1128
- buttonVariant: ue.Primary
1129
- },
1130
- confirmDraft: {
1131
- translationKey: "inventory.transfer.receiveRequest.actions.confirmDraft",
1132
- color: "primary",
1133
- buttonVariant: ue.Primary
1134
- },
1135
- cancelDraft: {
1136
- translationKey: "inventory.transfer.receiveRequest.actions.cancelDraft",
1137
- color: "system-error-300",
1138
- buttonVariant: ue.Destructive
1139
- },
1140
- approveDraft: {
1141
- translationKey: "inventory.transfer.receiveRequest.actions.approveDraft",
1142
- color: "primary",
1143
- buttonVariant: ue.Primary
1144
- },
1145
- rejectDraft: {
1146
- translationKey: "inventory.transfer.receiveRequest.actions.rejectDraft",
1147
- color: "system-error-300",
1148
- buttonVariant: ue.Destructive
1149
- },
1150
- approveRequest: {
1151
- translationKey: "inventory.transfer.receiveRequest.actions.approveRequest",
1152
- color: "primary",
1153
- buttonVariant: ue.Primary
1154
- },
1155
- processRequest: {
1156
- translationKey: "inventory.transfer.receiveRequest.actions.processRequest",
1157
- color: "primary",
1158
- buttonVariant: ue.Primary
1159
- },
1160
- receiveStock: {
1161
- translationKey: "inventory.transfer.receiveRequest.actions.receiveStock",
1162
- color: "primary",
1163
- buttonVariant: ue.Primary,
1164
- available: !1
1165
- },
1166
- completeReceive: {
1167
- translationKey: "inventory.transfer.receiveRequest.actions.completeReceive",
1168
- color: "primary",
1169
- buttonVariant: ue.Plain
1170
- },
1171
- rejectRequest: {
1172
- translationKey: "inventory.transfer.receiveRequest.actions.rejectRequest",
1173
- color: "system-error-300",
1174
- buttonVariant: ue.Destructive
1175
- },
1176
- closeRequest: {
1177
- translationKey: "inventory.transfer.receiveRequest.actions.closeRequest",
1178
- color: "system-error-300",
1179
- buttonVariant: ue.Destructive,
1180
- available: !1
1181
- },
1182
- returnStock: {
1183
- translationKey: "inventory.transfer.receiveRequest.actions.returnStock",
1184
- color: "primary",
1185
- buttonVariant: ue.Primary,
1186
- available: !1
1187
- }
1188
- };
1189
- function Xt() {
1190
- const y = Me();
1191
- return {
1192
- ableToMarkReceived(t) {
1193
- if (!t || t.status !== H.enum.RECEIVING)
1194
- return !1;
1195
- const b = ve().currentLocationDBName;
1196
- return `${t.supplier.internal}_${t.supplier._id}` !== b;
1197
- },
1198
- ableToMarkApproved(t) {
1199
- return !(!t || (t == null ? void 0 : t.status) !== H.enum.REQUESTING);
1200
- },
1201
- ableToCreateFulfillment(t, s) {
1202
- var i, o;
1203
- if (!y.acceptRequireFulfillment || !t || !s || t.status !== H.enum.PROCESSING || !s.processedAt)
1204
- return !1;
1205
- const b = (i = s == null ? void 0 : s.from) == null ? void 0 : i.dbName, l = (o = s == null ? void 0 : s.to) == null ? void 0 : o.dbName;
1206
- return !(b.startsWith("restaurant_") && l.startsWith("restaurant_"));
1207
- }
1208
- };
1209
- }
1210
- const Zt = { class: "flex flex-row-reverse" }, Jt = /* @__PURE__ */ Re({
1211
- __name: "NetSuiteSync",
1212
- props: {
1213
- poRequest: {},
1214
- purchaseOrder: {},
1215
- isTransferBetweenOutlets: { type: Boolean },
1216
- scope: {}
1217
- },
1218
- setup(y) {
1219
- const t = y, s = je(), b = ze(), l = tt(), i = M(!1);
1220
- re(() => {
1221
- var O, p, q, m;
1222
- let a = !0;
1223
- s.isEnabled || (a = !1);
1224
- const n = t.purchaseOrder, h = t.poRequest;
1225
- return n && ((O = n == null ? void 0 : n.supplier) != null && O.internal ? (!h && n.status == H.enum.DRAFT && (a = !1), h && !((p = h == null ? void 0 : h.netSuite) != null && p.id) && (a = !1), t.isTransferBetweenOutlets && (a = !1)) : ((n == null ? void 0 : n.status) !== H.enum.REQUESTING && n.supplier.internal && (a = !1), !h && !((q = n == null ? void 0 : n.netSuite) != null && q.id) && (a = !1), !h && ((m = n == null ? void 0 : n.netSuite) != null && m.id) && (n == null ? void 0 : n.status) == H.enum.REQUESTING && (a = !1))), a;
1226
- });
1227
- async function o() {
1228
- i.value || l.open({
1229
- title: "Sync with NetSuite",
1230
- contentComponent: A("div", [
1231
- A("p", "Are you sure you want to sync now?"),
1232
- A("br"),
1233
- A(
1234
- "p",
1235
- { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" },
1236
- "Please wait a moment before syncing manually to avoid unnecessary actions."
1237
- )
1238
- ]),
1239
- primaryActions: {
1240
- text: "Sync",
1241
- close: !0,
1242
- variant: "destructive"
1243
- },
1244
- secondaryActions: { text: "Not now", close: !0 }
1245
- }).onPrimary(async () => {
1246
- var a, n, h;
1247
- try {
1248
- i.value = !0;
1249
- const O = ((a = t.purchaseOrder) == null ? void 0 : a._id) || ((n = t.poRequest) == null ? void 0 : n.purchaseOrderId) || "", p = (h = t.poRequest) == null ? void 0 : h.to.dbName;
1250
- await s.syncPurchaseOrder(
1251
- O,
1252
- t.scope === "approval" ? p : void 0
1253
- ), b.open({
1254
- title: "Sync with NetSuite",
1255
- message: "Requested to sync with NetSuite. Please wait a moment.",
1256
- type: "success"
1257
- }), await new Promise((q) => setTimeout(q, 5e3)), i.value = !1;
1258
- } catch {
1259
- b.open({
1260
- title: "Error",
1261
- message: "Failed to sync with NetSuite",
1262
- type: "error"
1263
- }), i.value = !1;
1264
- }
1265
- });
1266
- }
1267
- return (a, n) => {
1268
- const h = J("FmButton");
1269
- return v(), w("div", Zt, [
1270
- F(h, {
1271
- "prepend-icon": "sync",
1272
- variant: "secondary",
1273
- label: "Sync",
1274
- loading: i.value,
1275
- onClick: o,
1276
- "text-color": "primary",
1277
- "bg-color": "transparent",
1278
- "border-color": "primary"
1279
- }, null, 8, ["loading"])
1280
- ]);
1281
- };
1282
- }
1283
- }), er = {
1284
- key: 0,
1285
- class: "flex flex-col gap-8"
1286
- }, tr = { class: "flex flex-col gap-4" }, rr = { class: "fm-typo-en-body-lg-600" }, sr = {
1287
- key: 0,
1288
- class: "flex flex-col gap-4"
1289
- }, nr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, or = { class: "fm-typo-en-body-lg-600" }, ar = { key: 0 }, ir = { key: 1 }, lr = {
1290
- key: 1,
1291
- class: "flex flex-col gap-4"
1292
- }, cr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ur = { class: "fm-typo-en-body-lg-600" }, dr = { key: 0 }, mr = { key: 1 }, fr = {
1293
- key: 2,
1294
- class: "flex flex-col gap-4"
1295
- }, pr = { class: "fm-typo-en-body-lg-600" }, yr = {
1296
- key: 3,
1297
- class: "flex flex-col gap-4"
1298
- }, vr = { class: "fm-typo-en-body-lg-600" }, hr = /* @__PURE__ */ Re({
1299
- __name: "NetSuiteInfo",
1300
- props: {
1301
- transferType: {},
1302
- transferToDbName: {},
1303
- poRequest: {},
1304
- purchaseOrder: {},
1305
- isTransferBetweenOutlets: { type: Boolean },
1306
- scope: {}
1307
- },
1308
- setup(y) {
1309
- const t = y, s = je(), b = Ge(), l = M(t.poRequest);
1310
- ht(async () => {
1311
- var n;
1312
- if (!t.poRequest && ((n = t.purchaseOrder) != null && n._id)) {
1313
- const h = await b.getLatestPurchaseOrderRequest(t.purchaseOrder._id);
1314
- l.value = h;
1315
- }
1316
- });
1317
- const i = re(
1318
- () => {
1319
- var n, h, O, p, q, m;
1320
- return s.getSubsidiaryFullName(
1321
- ((O = (h = (n = t.purchaseOrder) == null ? void 0 : n.netSuite) == null ? void 0 : h.subsidiary) == null ? void 0 : O.id) || ((m = (q = (p = t.poRequest) == null ? void 0 : p.netSuite) == null ? void 0 : q.subsidiary) == null ? void 0 : m.id)
1322
- ).fullName;
1323
- }
1324
- ), o = re(() => {
1325
- var n, h, O, p, q, m, $, u, c, g, N, k;
1326
- return (O = (h = (n = t.purchaseOrder) == null ? void 0 : n.netSuite) == null ? void 0 : h.additionalInfo) != null && O.transactionnumber ? (m = (q = (p = t.purchaseOrder) == null ? void 0 : p.netSuite) == null ? void 0 : q.additionalInfo) == null ? void 0 : m.transactionnumber : (c = (u = ($ = l.value) == null ? void 0 : $.netSuite) == null ? void 0 : u.additionalInfo) != null && c.transactionnumber ? (k = (N = (g = l.value) == null ? void 0 : g.netSuite) == null ? void 0 : N.additionalInfo) == null ? void 0 : k.transactionnumber : null;
1327
- }), a = re(() => {
1328
- var n, h, O, p, q, m;
1329
- return (h = (n = t.purchaseOrder) == null ? void 0 : n.deliveryFullfillment) != null && h.length && ((p = (O = t.purchaseOrder) == null ? void 0 : O.deliveryFullfillment) == null ? void 0 : p.length) > 0 ? (m = (q = t.purchaseOrder) == null ? void 0 : q.deliveryFullfillment) == null ? void 0 : m.map(($) => {
1330
- var u;
1331
- return (u = $.netSuite) == null ? void 0 : u.refNo;
1332
- }).join(", ") : "N/A";
1333
- });
1334
- return (n, h) => {
1335
- var O, p, q, m, $, u, c, g, N, k, L, D, B, Y, se, ae;
1336
- return R(s).isEnabled ? (v(), w("div", er, [
1337
- e("div", tr, [
1338
- h[0] || (h[0] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "NetSuite subsidiary", -1)),
1339
- e("div", rr, S(i.value || "N/A"), 1)
1340
- ]),
1341
- !n.isTransferBetweenOutlets && n.scope === R(Je).RECEIVE_REQUEST ? (v(), w("div", sr, [
1342
- e("div", nr, " NetSuite " + S((p = (O = n.purchaseOrder) == null ? void 0 : O.netSuite) != null && p.recordType ? R(yt)((m = (q = n.purchaseOrder) == null ? void 0 : q.netSuite) == null ? void 0 : m.recordType) : n.transferType === R(we).PURCHASE ? "Purchase Order" : "Transfer Order") + " (ID) ", 1),
1343
- e("div", or, [
1344
- (u = ($ = n.purchaseOrder) == null ? void 0 : $.netSuite) != null && u.id ? (v(), w("span", ar, S((g = (c = n.purchaseOrder) == null ? void 0 : c.netSuite) == null ? void 0 : g.refNo) + " (" + S((k = (N = n.purchaseOrder) == null ? void 0 : N.netSuite) == null ? void 0 : k.id) + ") ", 1)) : (v(), w("span", ir, "N/A"))
1345
- ])
1346
- ])) : G("", !0),
1347
- !n.isTransferBetweenOutlets && l.value || n.scope === R(Je).APPROVAL ? (v(), w("div", lr, [
1348
- e("div", cr, " (Request) NetSuite " + S(n.transferType === R(we).PURCHASE ? "Purchase Order" : "Transfer Order") + " (ID) ", 1),
1349
- e("div", ur, [
1350
- (D = (L = l.value) == null ? void 0 : L.netSuite) != null && D.id ? (v(), w("span", dr, S((Y = (B = l.value) == null ? void 0 : B.netSuite) == null ? void 0 : Y.refNo) + " (" + S((ae = (se = l.value) == null ? void 0 : se.netSuite) == null ? void 0 : ae.id) + ") ", 1)) : (v(), w("span", mr, "N/A"))
1351
- ])
1352
- ])) : G("", !0),
1353
- o.value ? (v(), w("div", fr, [
1354
- h[1] || (h[1] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite Transaction Number ", -1)),
1355
- e("div", pr, S(o.value), 1)
1356
- ])) : G("", !0),
1357
- R(s).isEnabled && n.transferType === R(we).TRANSFER && !n.isTransferBetweenOutlets ? (v(), w("div", yr, [
1358
- h[2] || (h[2] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite fulfillment IDs ", -1)),
1359
- e("div", vr, S(a.value), 1)
1360
- ])) : G("", !0)
1361
- ])) : G("", !0);
1362
- };
1363
- }
1364
- }), br = { class: "flex flex-row-reverse" }, gr = /* @__PURE__ */ Re({
1365
- __name: "NetSuiteLog",
1366
- props: {
1367
- netsuiteId: {},
1368
- purchaseOrderId: {}
1369
- },
1370
- setup(y) {
1371
- const t = ze(), s = vt();
1372
- async function b(l, i) {
1373
- const o = [];
1374
- if (l && o.push(`body.message:*${l}*`), i) {
1375
- const O = i.replace(/:/g, "\\:");
1376
- o.push(`${O}`);
1377
- }
1378
- if (o.length === 0) {
1379
- t.open({
1380
- message: "Cannot open logs without valid filters.",
1381
- type: "error"
1382
- });
1383
- return;
1384
- }
1385
- const n = `attributes.pod:netsuite* AND (${o.join(" OR ")})`, { url: h } = await s.getSyncLogs(n);
1386
- t.open(
1387
- {
1388
- message: "Opening NetSuite logs...",
1389
- type: "info"
1390
- },
1391
- 800
1392
- ), await new Promise((O) => setTimeout(O, 800)), window.open(h, "_blank");
1393
- }
1394
- return (l, i) => {
1395
- const o = J("FmButton");
1396
- return v(), w("div", br, [
1397
- F(o, {
1398
- "prepend-icon": "history",
1399
- variant: "secondary",
1400
- label: "Logs",
1401
- onClick: i[0] || (i[0] = (a) => b(l.netsuiteId, l.purchaseOrderId)),
1402
- "text-color": "primary",
1403
- "bg-color": "transparent",
1404
- "border-color": "primary"
1405
- })
1406
- ]);
1407
- };
1408
- }
1409
- }), _r = { class: "flex flex-row-reverse" }, Sr = { key: 0 }, wr = { key: 1 }, Rr = { class: "mb-6" }, xr = { class: "fm-typo-en-body-md-400" }, Or = { key: 0 }, Nr = { key: 1 }, $r = { key: 0 }, kr = {
1410
- key: 1,
1411
- class: "border-t pt-6"
1412
- }, Dr = { class: "fm-typo-en-body-lg-600 mb-4 flex items-center gap-2" }, Cr = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg overflow-y-auto" }, Ar = { class: "w-full" }, qr = {
1413
- class: "p-3 fm-typo-en-body-sm-600",
1414
- style: { "min-width": "130px" }
1415
- }, Tr = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Pr = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Ir = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Fr = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Lr = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Er = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Br = { class: "p-3 fm-typo-en-body-sm-600" }, Vr = { key: 2 }, Ur = { key: 1 }, Mr = /* @__PURE__ */ Re({
1416
- __name: "NetSuiteLatestInfo",
1417
- props: {
1418
- netsuiteId: {},
1419
- purchaseOrderId: {}
1420
- },
1421
- setup(y) {
1422
- const t = y, s = vt(), b = M(!1), l = ve(), i = M(!0), o = M(!1), a = M(!1), n = M(!1), h = M(null), O = M([]);
1423
- async function p() {
1424
- if (!h.value) {
1425
- b.value = !0;
1426
- try {
1427
- i.value = !0;
1428
- const u = await s.getMoreInfo(
1429
- l.currentLocation.dbName,
1430
- t.purchaseOrderId
1431
- );
1432
- h.value = u, o.value = !1;
1433
- } catch {
1434
- o.value = !0;
1435
- } finally {
1436
- i.value = !1;
1437
- }
1438
- await q();
1439
- }
1440
- }
1441
- async function q() {
1442
- if (!(O.value.length > 0))
1443
- try {
1444
- a.value = !0;
1445
- const u = await s.getChangeLogs(t.netsuiteId);
1446
- O.value = u, n.value = !1;
1447
- } catch {
1448
- n.value = !0;
1449
- } finally {
1450
- a.value = !1;
1451
- }
1452
- }
1453
- function m(u) {
1454
- switch (u) {
1455
- case Ae.Create:
1456
- return "text-green-600 bg-green-100";
1457
- case Ae.Set:
1458
- return "text-blue-600 bg-blue-100";
1459
- case Ae.Change:
1460
- return "text-yellow-600 bg-yellow-100";
1461
- case Ae.Unset:
1462
- return "text-red-600 bg-red-100";
1463
- default:
1464
- return "text-gray-600 bg-gray-100";
1465
- }
1466
- }
1467
- function $(u) {
1468
- return new Date(u).toLocaleDateString("en-US", {
1469
- year: "numeric",
1470
- month: "short",
1471
- day: "numeric",
1472
- hour: "2-digit",
1473
- minute: "2-digit"
1474
- });
1475
- }
1476
- return (u, c) => {
1477
- const g = J("FmButton"), N = J("FmLabel"), k = J("FmIcon"), L = J("FmDialog");
1478
- return v(), w("div", _r, [
1479
- F(L, {
1480
- modelValue: b.value,
1481
- "onUpdate:modelValue": c[2] || (c[2] = (D) => b.value = D),
1482
- overlay: !0,
1483
- "max-width": 800
1484
- }, {
1485
- "dialog-button": ne(() => [
1486
- F(g, {
1487
- "prepend-icon": "info",
1488
- variant: "secondary",
1489
- label: "Latest Info",
1490
- onClick: c[0] || (c[0] = (D) => p()),
1491
- "text-color": "primary",
1492
- "bg-color": "transparent",
1493
- "border-color": "primary"
1494
- })
1495
- ]),
1496
- "dialog-header": ne(() => c[3] || (c[3] = [
1497
- e("div", null, "NetSuite latest info", -1)
1498
- ])),
1499
- default: ne(() => [
1500
- i.value ? (v(), w("div", Sr, "Loading...")) : (v(), w("div", wr, [
1501
- o.value ? (v(), w("p", Ur, "Something went wrong.")) : (v(), w(ie, { key: 0 }, [
1502
- e("div", Rr, [
1503
- c[4] || (c[4] = e("h3", { class: "fm-typo-en-body-lg-600 mb-4" }, "NetSuite Order Details", -1)),
1504
- (v(!0), w(ie, null, be(h.value, (D, B) => (v(), w("div", {
1505
- key: B,
1506
- class: "mb-2"
1507
- }, [
1508
- e("div", null, [
1509
- F(N, {
1510
- label: R(et)(B)
1511
- }, null, 8, ["label"]),
1512
- e("div", xr, [
1513
- Array.isArray(D) ? (v(), w("span", Or, S(D.length > 0 ? D.join(", ") : "N/A"), 1)) : (v(), w("span", Nr, S(D), 1))
1514
- ])
1515
- ])
1516
- ]))), 128))
1517
- ]),
1518
- a.value ? (v(), w("div", $r, "Change Log Loading...")) : G("", !0),
1519
- !a.value && O.value.length > 0 ? (v(), w("div", kr, [
1520
- e("h3", Dr, [
1521
- F(k, {
1522
- name: "error",
1523
- color: "#ff9500",
1524
- size: "sm"
1525
- }),
1526
- c[5] || (c[5] = $e(" Change Logs "))
1527
- ]),
1528
- e("div", Cr, [
1529
- e("table", Ar, [
1530
- c[6] || (c[6] = e("thead", { class: "bg-fm-color-neutral-gray-50" }, [
1531
- e("tr", { class: "border-b border-fm-color-neutral-gray-200" }, [
1532
- e("th", {
1533
- class: "text-left p-3 fm-typo-en-body-md-600",
1534
- style: { "min-width": "130px" }
1535
- }, " Date "),
1536
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Role"),
1537
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Name"),
1538
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Context"),
1539
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Type"),
1540
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Line ID"),
1541
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Field"),
1542
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Old Value"),
1543
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "New Value")
1544
- ])
1545
- ], -1)),
1546
- e("tbody", null, [
1547
- (v(!0), w(ie, null, be(O.value, (D, B) => (v(), w("tr", {
1548
- key: B,
1549
- class: "border-b border-fm-color-neutral-gray-200 last:border-b-0"
1550
- }, [
1551
- e("td", qr, S($(D._dateiso8601)), 1),
1552
- e("td", Tr, S(D._rolename), 1),
1553
- e("td", Pr, S(D._employeename), 1),
1554
- e("td", Ir, S(D._contextname), 1),
1555
- e("td", {
1556
- class: Pe(`p-3 fm-typo-en-body-sm-600 ${m(Number(D.type) - 1)}`)
1557
- }, S(R(Ae)[Number(D.type) - 1]), 3),
1558
- e("td", Fr, S(D.lineid || ""), 1),
1559
- e("td", Lr, S(D._fieldname), 1),
1560
- e("td", Er, S(D.oldvalue || ""), 1),
1561
- e("td", Br, S(D.newvalue || ""), 1)
1562
- ]))), 128))
1563
- ])
1564
- ])
1565
- ])
1566
- ])) : (v(), w("div", Vr, c[7] || (c[7] = [
1567
- e("p", null, "No change logs available.", -1)
1568
- ])))
1569
- ], 64))
1570
- ]))
1571
- ]),
1572
- "dialog-footer": ne(() => [
1573
- F(g, {
1574
- class: "ml-auto sm:w-full xs:w-full",
1575
- label: "Close",
1576
- size: "md",
1577
- variant: "primary",
1578
- onClick: c[1] || (c[1] = (D) => b.value = !1)
1579
- })
1580
- ]),
1581
- _: 1
1582
- }, 8, ["modelValue"])
1583
- ]);
1584
- };
1585
- }
1586
- }), jr = {
1587
- key: 0,
1588
- class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16 flex flex-col gap-8"
1589
- }, Kr = { class: "flex gap-8 items-center" }, zr = { class: "ml-auto" }, Gr = { class: "flex gap-3" }, Hr = /* @__PURE__ */ Re({
1590
- __name: "NetSuitePanel",
1591
- props: {
1592
- poRequest: {},
1593
- purchaseOrder: {},
1594
- transferType: {},
1595
- transferToDbName: {},
1596
- scope: {}
1597
- },
1598
- setup(y) {
1599
- const t = y, s = Mt();
1600
- Ke();
1601
- const b = re(() => {
1602
- var a, n, h, O, p, q, m;
1603
- const l = ((a = t.transferToDbName) == null ? void 0 : a.startsWith("restaurant")) && ((h = (n = t.purchaseOrder) == null ? void 0 : n.supplier) == null ? void 0 : h.internal) === "restaurant", i = t.transferType === we.PURCHASE, o = t.transferType === we.TRANSFER;
1604
- return i || o && !l || ((p = (O = t.purchaseOrder) == null ? void 0 : O.netSuite) == null ? void 0 : p.id) || ((m = (q = t.poRequest) == null ? void 0 : q.netSuite) == null ? void 0 : m.id);
1605
- });
1606
- return (l, i) => {
1607
- var a, n;
1608
- const o = J("FmMenuDivider");
1609
- return R(s).isNetSuiteEnabled && b.value ? (v(), w("div", jr, [
1610
- e("div", Kr, [
1611
- i[0] || (i[0] = e("span", { class: "flex-1 fm-typo-en-body-lg-600" }, "NetSuite Info", -1)),
1612
- e("div", zr, [
1613
- e("div", Gr, [
1614
- (n = (a = t.purchaseOrder) == null ? void 0 : a.netSuite) != null && n.id ? (v(), me(ke, { key: 0 }, {
1615
- default: ne(() => {
1616
- var h, O, p;
1617
- return [
1618
- F(Mr, {
1619
- "netsuite-id": (O = (h = l.purchaseOrder) == null ? void 0 : h.netSuite) == null ? void 0 : O.id,
1620
- "purchase-order-id": (p = l.purchaseOrder) == null ? void 0 : p._id
1621
- }, null, 8, ["netsuite-id", "purchase-order-id"])
1622
- ];
1623
- }),
1624
- _: 1
1625
- })) : G("", !0),
1626
- F(ke, null, {
1627
- default: ne(() => {
1628
- var h, O, p;
1629
- return [
1630
- F(gr, {
1631
- "netsuite-id": (O = (h = l.purchaseOrder) == null ? void 0 : h.netSuite) == null ? void 0 : O.id,
1632
- "purchase-order-id": (p = l.purchaseOrder) == null ? void 0 : p._id
1633
- }, null, 8, ["netsuite-id", "purchase-order-id"])
1634
- ];
1635
- }),
1636
- _: 1
1637
- }),
1638
- F(Jt, {
1639
- "po-request": l.poRequest,
1640
- "purchase-order": l.purchaseOrder,
1641
- "is-transfer-between-outlets": !b.value,
1642
- scope: l.scope
1643
- }, null, 8, ["po-request", "purchase-order", "is-transfer-between-outlets", "scope"])
1644
- ])
1645
- ])
1646
- ]),
1647
- F(o),
1648
- F(hr, {
1649
- "po-request": l.poRequest,
1650
- "purchase-order": l.purchaseOrder,
1651
- "transfer-type": l.transferType,
1652
- "transfer-to-db-name": l.transferToDbName,
1653
- "is-transfer-between-outlets": !b.value,
1654
- scope: l.scope
1655
- }, null, 8, ["po-request", "purchase-order", "transfer-type", "transfer-to-db-name", "is-transfer-between-outlets", "scope"])
1656
- ])) : G("", !0);
1657
- };
1658
- }
1659
- }), Wr = { class: "flex flex-col gap-16 w-full h-full" }, Yr = { class: "flex justify-between" }, Qr = { class: "fm-typo-en-body-lg-600" }, Xr = { class: "flex gap-2" }, Zr = {
1660
- key: 0,
1661
- class: "flex items-center gap-1"
1662
- }, Jr = { class: "fm-typo-en-body-md-400" }, es = { class: "flex flex-col gap-8" }, ts = { class: "flex flex-col gap-4" }, rs = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ss = { class: "flex gap-1" }, ns = { class: "fm-typo-en-body-lg-600" }, os = {
1663
- key: 0,
1664
- class: "flex flex-col gap-4"
1665
- }, as = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, is = { class: "fm-typo-en-body-lg-600" }, ls = { class: "flex flex-col gap-4" }, cs = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, us = { class: "fm-typo-en-body-lg-600" }, ds = {
1666
- key: 1,
1667
- class: "flex flex-col gap-4"
1668
- }, ms = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, fs = { class: "fm-typo-en-body-lg-600" }, ps = {
1669
- key: 2,
1670
- class: "flex flex-col gap-4"
1671
- }, ys = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, vs = { class: "fm-typo-en-body-lg-600" }, hs = {
1672
- key: 3,
1673
- class: "flex flex-col gap-4"
1674
- }, bs = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, gs = { class: "fm-typo-en-body-lg-600" }, _s = {
1675
- key: 4,
1676
- class: "flex flex-col gap-4"
1677
- }, Ss = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ws = { class: "fm-typo-en-body-lg-600" }, Rs = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, xs = { class: "flex flex-col gap-8" }, Os = { class: "flex gap-8 items-center" }, Ns = { class: "flex-1 fm-typo-en-body-lg-600" }, $s = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary flex flex-col gap-4" }, ks = { class: "flex w-full gap-4" }, Ds = { class: "basis-1/2 shrink-0 grow fm-typo-en-body-lg-400 line-clamp-2 flex items-center gap-2" }, Cs = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary flex flex-col gap-2" }, As = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, qs = ["innerHTML"], Ts = { class: "flex w-full gap-4 fm-typo-en-body-sm-400" }, Ps = { class: "grow fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-1" }, Is = {
1678
- key: 0,
1679
- class: "line-clamp-1 fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
1680
- }, Fs = { class: "py-8" }, Ls = { class: "flex justify-end gap-4 items-center" }, Es = { class: "fm-typo-en-body-lg-600" }, Bs = {
1681
- key: 1,
1682
- class: "flex-1 xs:w-screen xs:max-w-full"
1683
- }, Vs = {
1684
- key: 0,
1685
- class: "flex flex-col items-center gap-8 h-full"
1686
- }, Us = ["src"], Ms = { class: "fm-typo-en-body-lg-600" }, js = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary px-16" }, Ks = {
1687
- key: 1,
1688
- class: "px-4 flex flex-col"
1689
- }, zs = { class: "flex gap-12 content-stretch" }, Gs = {
1690
- class: "flex flex-col w-24",
1691
- name: "circles"
1692
- }, Hs = { class: "flex-1 flex flex-col items-center" }, Ws = { class: "flex-1 flex flex-col items-center" }, Ys = {
1693
- class: "py-12 flex flex-col gap-4",
1694
- name: "received-at header"
1695
- }, Qs = { class: "fm-typo-en-body-lg-400" }, Xs = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Zs = { class: "flex gap-12 content-stretch" }, Js = {
1696
- class: "flex flex-col w-24",
1697
- name: "circles"
1698
- }, en = { class: "flex-1 flex flex-col items-center" }, tn = {
1699
- class: "py-12 flex flex-col gap-4 flex-1",
1700
- name: "delivery details"
1701
- }, rn = { class: "flex flex-col gap-8" }, sn = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, nn = { class: "flex flex-col gap-4" }, on = { class: "flex gap-8 xs:flex-col" }, _n = /* @__PURE__ */ Re({
1702
- __name: "TransferDetails",
1703
- props: {
1704
- poRequest: {},
1705
- purchaseOrder: {},
1706
- transferTo: {},
1707
- transferToDbName: {},
1708
- show: { type: Boolean },
1709
- canResubmit: { type: Boolean },
1710
- canApprove: { type: Boolean },
1711
- scope: {},
1712
- receivedMap: {},
1713
- shipments: {}
1714
- },
1715
- emits: ["update:show", "submitted"],
1716
- setup(y, { emit: t }) {
1717
- const s = y, b = t, l = tt(), i = ze(), o = Me(), a = ve(), n = Ke(), h = re(
1718
- () => {
1719
- var r, d;
1720
- return {
1721
- id: ((r = n.sessionUser.value) == null ? void 0 : r.id) ?? "",
1722
- name: ((d = n.sessionUser.value) == null ? void 0 : d.displayName) ?? ""
1723
- };
1724
- }
1725
- ), O = Xt(), { t: p } = bt(), q = re(
1726
- () => {
1727
- var r, d, x, _;
1728
- return ((d = (r = s.purchaseOrder) == null ? void 0 : r.supplier) == null ? void 0 : d.internal) === "restaurant" || ((_ = (x = s.purchaseOrder) == null ? void 0 : x.supplier) == null ? void 0 : _.internal) === "warehouse" ? we.TRANSFER : we.PURCHASE;
1729
- }
1730
- ), m = re(() => {
1731
- var x;
1732
- const r = (x = s.shipments) == null ? void 0 : x.find((_) => {
1733
- var P;
1734
- return _.ref === ((P = s.purchaseOrder) == null ? void 0 : P._id);
1735
- });
1736
- let d = null;
1737
- if (r != null && r.milestones && r.milestones.length > 0) {
1738
- const _ = r.milestones[r.milestones.length - 1];
1739
- if (_.estimatedTime) {
1740
- const P = new Date(_.estimatedTime), E = P.getDate().toString().padStart(2, "0");
1741
- d = `${P.toLocaleString("en-US", { month: "short" })} ${E}`;
1742
- }
1743
- }
1744
- return d;
1745
- }), $ = M(!1), u = M(""), c = M(!0), g = Ge(), N = Ut(g.getWorkflowConfig), k = _t(), L = re(() => {
1746
- if (!s.purchaseOrder)
1747
- return [];
1748
- const r = N.result.value;
1749
- if (r.state === ct.loading)
1750
- return [];
1751
- const d = {
1752
- user: h.value,
1753
- executedAt: a.locations.computeFirst(
1754
- (_) => {
1755
- var P;
1756
- return _.dbName === ((P = a._currentLocation) == null ? void 0 : P.dbName) ? _ : null;
1757
- }
1758
- ),
1759
- purchaseOrderRequest: s.poRequest,
1760
- purchaseOrder: s.purchaseOrder
1761
- };
1762
- let x = [];
1763
- try {
1764
- r.state === ct.error ? (console.error("Error fetching workflow config:", r.error), x = He.getAvailableActions({
1765
- ...d,
1766
- orderConfig: He.getDefaultConfig()
1767
- }).actions.filter(
1768
- (_) => (
1769
- // TODO: create receiveStock & processRequest dialog
1770
- // to create their payload
1771
- _ !== C.enum.receiveStock && _ !== C.enum.processRequest && _ !== C.enum.closeRequest
1772
- )
1773
- )) : x = He.getAvailableActions({
1774
- ...d,
1775
- orderConfig: r.data
1776
- }).actions.filter(
1777
- (_) => _ !== C.enum.receiveStock && _ !== C.enum.processRequest && _ !== C.enum.closeRequest
1778
- );
1779
- } catch (_) {
1780
- console.error("Error getting available actions:", _);
1781
- }
1782
- return s.scope === "approval" && (x = x.filter((_) => _ !== C.enum.completeReceive)), x;
1783
- }), D = Tt(s, "show"), B = re(() => [
1784
- {
1785
- label: p("inventory.transfer.receiveRequest.details.overview"),
1786
- value: "overview"
1787
- },
1788
- {
1789
- label: p("inventory.transfer.receiveRequest.details.deliveryHistory"),
1790
- value: "deliveryHistory"
1791
- }
1792
- ]), Y = M(B.value[0]);
1793
- Dt(
1794
- () => s.show,
1795
- (r) => {
1796
- r && (Y.value = B.value[0]);
1797
- }
1798
- );
1799
- async function se(r, d, x, _, P) {
1800
- return new Promise((E, j) => {
1801
- l.open({
1802
- closeButton: !1,
1803
- title: _.title,
1804
- message: _.message,
1805
- primaryActions: _.primaryActions,
1806
- secondaryActions: { text: "No", close: !1 }
1807
- }).onPrimary(async () => {
1808
- var V, X, te, K;
1809
- const f = [];
1810
- x === C.enum.approveRequest ? (f.push({
1811
- action: "approveRequest",
1812
- payload: null
1813
- }), d.fulfillment && f.push({
1814
- action: "processRequest",
1815
- payload: {
1816
- fulfillmentId: "",
1817
- deliveryOrderNumber: "",
1818
- deliveryRemark: null,
1819
- items: d.fulfillment.items,
1820
- createdBy: h.value
1821
- }
1822
- })) : x === C.enum.processRequest ? d.fulfillment && f.push({
1823
- action: "processRequest",
1824
- payload: {
1825
- fulfillmentId: "",
1826
- deliveryOrderNumber: "",
1827
- deliveryRemark: null,
1828
- items: d.fulfillment.items,
1829
- createdBy: h.value
1830
- }
1831
- }) : x === C.enum.rejectRequest ? f.push({
1832
- action: "rejectRequest",
1833
- payload: null
1834
- }) : x === C.enum.closeRequest && f.push({
1835
- action: "closeRequest",
1836
- payload: null
1837
- });
1838
- try {
1839
- await k({
1840
- operate: {
1841
- operation: x,
1842
- doc: r,
1843
- options: d
1844
- },
1845
- operateV2: {
1846
- _id: ((V = s.purchaseOrder) == null ? void 0 : V._id) ?? "",
1847
- _rev: ((X = s.purchaseOrder) == null ? void 0 : X._rev) ?? "",
1848
- action: x,
1849
- payloads: f
1850
- // add payload if action is receiveStock or processRequest
1851
- },
1852
- transferTo: (K = (te = s.poRequest) == null ? void 0 : te.to) == null ? void 0 : K.dbName
1853
- }).delayed(1e3), E("submitted");
1854
- } catch (ce) {
1855
- j(ce);
1856
- }
1857
- }).onSecondary(() => {
1858
- E("cancelled");
1859
- for (let f = 0; f < P + 2; f++)
1860
- l.close();
1861
- }).onClose(() => {
1862
- });
1863
- });
1864
- }
1865
- async function ae(r) {
1866
- var P, E, j, f;
1867
- if (r === C.enum.receiveStock)
1868
- return;
1869
- const d = gt[r];
1870
- if (!d) {
1871
- i.open({
1872
- title: "Something went wrong",
1873
- message: `Cannot process order: ${et(r)}`,
1874
- type: "error"
1875
- });
1876
- return;
1877
- }
1878
- const { successMessage: x, ..._ } = d;
1879
- if (s.purchaseOrder) {
1880
- u.value = `${r}`, $.value = !0, c.value = !1;
1881
- const V = {};
1882
- let X = 0;
1883
- if ((r === C.enum.confirmDraft || // auto receive for warehouse to warehouse
1884
- r === C.enum.completeReceive) && o.autoReceiveWarehouse)
1885
- V.autoReceive = !0;
1886
- else if ((r === C.enum.approveRequest || r === C.enum.processRequest) && o.acceptRequireFulfillment) {
1887
- const te = (E = (P = s.poRequest) == null ? void 0 : P.from) == null ? void 0 : E.dbName, K = (f = (j = s.poRequest) == null ? void 0 : j.to) == null ? void 0 : f.dbName;
1888
- if (te && K && (te.startsWith("warehouse_") || K.startsWith("warehouse_"))) {
1889
- const ce = await new Promise((W, he) => {
1890
- l.open({
1891
- closeButton: !1,
1892
- title: "Confirm transfer amount",
1893
- dialogComponent: Qt,
1894
- dialogComponentProps: {
1895
- purchaseOrder: s.purchaseOrder,
1896
- confirm: W,
1897
- "onUpdate:show": (_e) => {
1898
- _e || (u.value = "", $.value = !1, c.value = !0, X++, l.close()), he("cancelled");
1899
- }
1900
- }
1901
- });
1902
- });
1903
- V.fulfillment = ce;
1904
- }
1905
- }
1906
- try {
1907
- await se(
1908
- s.purchaseOrder,
1909
- V,
1910
- r,
1911
- d,
1912
- X
1913
- ) === "submitted" && (i.open({
1914
- title: "Success",
1915
- message: x,
1916
- type: "success"
1917
- }), b("update:show", !1), b("submitted"));
1918
- } catch (te) {
1919
- i.open({
1920
- title: "Something went wrong",
1921
- message: "Please try again.",
1922
- type: "error"
1923
- }), console.error("Error when submitting PO operation", r, s.purchaseOrder, te);
1924
- } finally {
1925
- u.value = "", $.value = !1, c.value = !0;
1926
- }
1927
- }
1928
- }
1929
- const xe = re(() => {
1930
- var r, d;
1931
- return ((r = s.purchaseOrder) == null ? void 0 : r.status) === H.enum.RECEIVING || ((d = s.purchaseOrder) == null ? void 0 : d.status) === H.enum.COMPLETE;
1932
- }), Oe = re(() => {
1933
- const r = s.purchaseOrder;
1934
- if (!r) return { status: "", statusClass: "" };
1935
- const d = Ve(r), { partial: x, over: _ } = Xe(d), P = Ze(r.status, x, _);
1936
- let E = p(`inventory.transfer.status.${P}`), j = `${r.status}`.toLocaleLowerCase("en-us");
1937
- return P === H.enum.CLOSE && (E = `${p(`inventory.transfer.status.${H.enum.COMPLETE}`)}`), P === "PARTIAL_RECEIVED" && j === H.enum.PROCESSING.toLocaleLowerCase("en-us") && (j = H.enum.RECEIVING.toLocaleLowerCase("en-us")), {
1938
- status: E,
1939
- statusClass: `fm-status-badge fm-status-badge-${j}`
1940
- };
1941
- }), fe = re(() => {
1942
- var E, j;
1943
- const r = ((E = s.purchaseOrder) == null ? void 0 : E.deliveryOrder) ?? [], d = ((j = s.purchaseOrder) == null ? void 0 : j.deliveryFullfillment) ?? [], x = [
1944
- ...r.map((f) => ({
1945
- createdAt: f.createdAt,
1946
- type: "grn",
1947
- doc: f
1948
- })),
1949
- ...d.map((f) => ({
1950
- createdAt: f.createdAt,
1951
- type: "fulfillment",
1952
- doc: f
1953
- }))
1954
- ];
1955
- x.reverse().sort((f, V) => f.createdAt.localeCompare(V.createdAt));
1956
- function _(f) {
1957
- var te, K, ce, W, he, _e, De, Ce, z;
1958
- const V = d.findIndex((U) => U.id === f.fullfillmentId), X = [
1959
- (K = (te = d[V]) == null ? void 0 : te.netSuite) != null && K.refNo ? {
1960
- label: "Fulfillment's ref no. (Netsuite)",
1961
- values: [(W = (ce = d[V]) == null ? void 0 : ce.netSuite) == null ? void 0 : W.refNo]
1962
- } : null,
1963
- (he = f == null ? void 0 : f.netSuite) != null && he.refNo ? {
1964
- label: "Netsuite ref no.",
1965
- values: [(_e = f == null ? void 0 : f.netSuite) == null ? void 0 : _e.refNo]
1966
- } : null,
1967
- (De = f == null ? void 0 : f.netSuite) != null && De.recordType ? {
1968
- label: "Netsuite Type",
1969
- values: [yt((Ce = f == null ? void 0 : f.netSuite) == null ? void 0 : Ce.recordType)]
1970
- } : null
1971
- ];
1972
- return {
1973
- header: "Received",
1974
- date: We(new Date(f.createdAt)),
1975
- info: [
1976
- {
1977
- label: "Adjustment date",
1978
- values: [
1979
- f.adjustment ? We(new Date($t(f.adjustment))) : "-"
1980
- ]
1981
- },
1982
- {
1983
- label: "Received by",
1984
- values: [(z = f.createdBy) == null ? void 0 : z.name]
1985
- },
1986
- {
1987
- label: "Received items",
1988
- values: f.received.map((U) => {
1989
- var Z;
1990
- return A("div", [
1991
- A(
1992
- "div",
1993
- {
1994
- class: "flex gap-4"
1995
- },
1996
- [
1997
- A(
1998
- "div",
1999
- {
2000
- class: "flex flex-col"
2001
- },
2002
- [
2003
- A(
2004
- "span",
2005
- {
2006
- class: "fm-typo-en-body-lg-800 basis-1/2 shrink-0 grow"
2007
- },
2008
- `${U.sku.name}`
2009
- ),
2010
- A(
2011
- "span",
2012
- {
2013
- class: "fm-typo-en-body-md-400"
2014
- },
2015
- `${U.sku.code} `
2016
- )
2017
- ]
2018
- ),
2019
- A(
2020
- "div",
2021
- {
2022
- class: "ml-auto flex flex-col"
2023
- },
2024
- [
2025
- A(
2026
- "div",
2027
- {
2028
- class: "ml-auto flex gap-1"
2029
- },
2030
- [
2031
- A(
2032
- "span",
2033
- {
2034
- class: "fm-typo-en-body-lg-600 self-end"
2035
- },
2036
- ge(U.amount, !1)
2037
- ),
2038
- A(
2039
- "span",
2040
- {
2041
- class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
2042
- },
2043
- ((Z = U.measurement) == null ? void 0 : Z.abbrev) ?? U.sku.unit.abbrev
2044
- )
2045
- ]
2046
- ),
2047
- A(
2048
- "div",
2049
- {
2050
- class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary"
2051
- },
2052
- `${U.cost ? `(${Le(U.cost)})` : ""}`
2053
- )
2054
- ]
2055
- )
2056
- ]
2057
- )
2058
- ]);
2059
- })
2060
- },
2061
- f.deliveryOrderNumber ? {
2062
- label: "Delivery order no.",
2063
- values: [f.deliveryOrderNumber]
2064
- } : null,
2065
- f.remark ? {
2066
- label: "Remark",
2067
- values: [f.remark]
2068
- } : null,
2069
- V > -1 ? {
2070
- label: "Fulfilment's sequence",
2071
- values: [`${V + 1}`]
2072
- } : null,
2073
- ...X
2074
- ].filter((U) => U)
2075
- };
2076
- }
2077
- function P(f) {
2078
- var X, te;
2079
- const V = d.findIndex((K) => K.id === f.id);
2080
- return {
2081
- header: "Fulfillment",
2082
- date: We(new Date(f.createdAt)),
2083
- info: [
2084
- {
2085
- label: "Sequence",
2086
- values: [String(V + 1)]
2087
- },
2088
- {
2089
- label: "Receiveable items",
2090
- values: f.items.map((K) => {
2091
- var ce;
2092
- return A("div", [
2093
- A(
2094
- "div",
2095
- {
2096
- class: "flex gap-4"
2097
- },
2098
- [
2099
- A(
2100
- "div",
2101
- {
2102
- class: "flex flex-col"
2103
- },
2104
- [
2105
- A(
2106
- "span",
2107
- {
2108
- class: "fm-typo-en-body-lg-800 basis-1/2 shrink-0 grow"
2109
- },
2110
- `${K.sku.name}`
2111
- ),
2112
- A(
2113
- "span",
2114
- {
2115
- class: "fm-typo-en-body-md-400"
2116
- },
2117
- `${K.sku.code} `
2118
- )
2119
- ]
2120
- ),
2121
- A(
2122
- "div",
2123
- {
2124
- class: "ml-auto flex flex-col"
2125
- },
2126
- [
2127
- A(
2128
- "div",
2129
- {
2130
- class: "ml-auto flex gap-1"
2131
- },
2132
- [
2133
- A(
2134
- "span",
2135
- {
2136
- class: "fm-typo-en-body-lg-600 self-end"
2137
- },
2138
- ge(K.amount, !1)
2139
- ),
2140
- A(
2141
- "span",
2142
- {
2143
- class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
2144
- },
2145
- ((ce = K.measurement) == null ? void 0 : ce.abbrev) ?? K.sku.unit.abbrev
2146
- )
2147
- ]
2148
- ),
2149
- A(
2150
- "div",
2151
- {
2152
- class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary"
2153
- },
2154
- `${K.cost ? `(${Le(K.cost)})` : ""}`
2155
- )
2156
- ]
2157
- )
2158
- ]
2159
- )
2160
- ]);
2161
- })
2162
- },
2163
- (X = f.netSuite) != null && X.refNo ? {
2164
- label: "Ref no. (Netsuite)",
2165
- values: [(te = f.netSuite) == null ? void 0 : te.refNo]
2166
- } : null
2167
- ].filter((K) => K)
2168
- };
2169
- }
2170
- return x.map((f) => {
2171
- switch (f.type) {
2172
- case "grn":
2173
- return _(f.doc);
2174
- case "fulfillment":
2175
- return P(f.doc);
2176
- }
2177
- });
2178
- }), Ie = re(() => {
2179
- var d;
2180
- const r = {
2181
- ...ft(0),
2182
- currency: lt()
2183
- };
2184
- return ((d = s.purchaseOrder) == null ? void 0 : d.items.reduce((x, _) => ({
2185
- ...mt(x, _.totalCost ?? r),
2186
- currency: lt()
2187
- }), r)) ?? r;
2188
- });
2189
- function T(r) {
2190
- var E;
2191
- const x = (((E = s.purchaseOrder) == null ? void 0 : E.version) ?? Se.enum[1]) === Se.enum[2] ? r.id : r.sku._id, _ = s.receivedMap[x];
2192
- return `<span class="${I(r)} fm-typo-en-body-lg-600">${qe.toFormatString({ value: _.received })}</span>/${Ft(r.quantity, r.sku.unit, r.measurement)}`;
2193
- }
2194
- function I(r) {
2195
- var V;
2196
- const x = (((V = s.purchaseOrder) == null ? void 0 : V.version) ?? Se.enum[1]) === Se.enum[2] ? r.id : r.sku._id, _ = s.receivedMap[x], { isPartialReceive: P, isNoReceive: E, isOverReceive: j, isFullReceive: f } = Kt(_);
2197
- return E ? "text-fm-color-typo-tertiary" : P ? "text-fm-color-system-warning-300" : j ? "text-fm-color-system-error-300" : f ? "text-fm-color-system-success-300" : "";
2198
- }
2199
- const ee = re(() => {
2200
- var r, d, x;
2201
- return (r = s.purchaseOrder) != null && r.itemsAtSubmission ? ((d = s.purchaseOrder) == null ? void 0 : d.version) === Se.enum[2] ? s.purchaseOrder.items.reduce((_, P) => {
2202
- var j, f;
2203
- const E = (f = (j = s.purchaseOrder) == null ? void 0 : j.itemsAtSubmission) == null ? void 0 : f.find(
2204
- (V) => V.id === P.id
2205
- );
2206
- return E && E.quantity !== P.quantity && _.set(P.sku.code, {
2207
- originalAmount: Number(qe.toFormatString({ value: E.quantity })),
2208
- newAmount: Number(qe.toFormatString({ value: P.quantity }))
2209
- }), _;
2210
- }, /* @__PURE__ */ new Map()) : (x = s.purchaseOrder) == null ? void 0 : x.items.reduce((_, P) => {
2211
- var V, X;
2212
- const E = (X = (V = s.purchaseOrder) == null ? void 0 : V.itemsAtSubmission) == null ? void 0 : X.find(
2213
- (te) => te.sku._id === P.sku._id
2214
- ), j = E ? Number(qe.toFormatString({ value: E.quantity })) : 0, f = Number(qe.toFormatString({ value: P.quantity }));
2215
- return E && j !== f && _.set(P.sku.code, {
2216
- originalAmount: j,
2217
- newAmount: f
2218
- }), _;
2219
- }, /* @__PURE__ */ new Map()) : /* @__PURE__ */ new Map();
2220
- }), Q = (r) => {
2221
- var x, _;
2222
- const d = ee.value;
2223
- return ((x = s.purchaseOrder) == null ? void 0 : x.version) === Se.enum[2] ? d.has(r.id) : d.has((_ = r.sku) == null ? void 0 : _.code);
2224
- }, le = (r) => {
2225
- var x, _;
2226
- const d = ee.value;
2227
- return ((x = s.purchaseOrder) == null ? void 0 : x.version) === Se.enum[2] ? d.get(r.id) : d.get((_ = r.sku) == null ? void 0 : _.code);
2228
- };
2229
- return (r, d) => {
2230
- var K, ce;
2231
- const x = J("FmButtonGroup"), _ = J("FmChip"), P = J("FmIcon"), E = J("FmMenuDivider"), j = J("FmCard"), f = J("FmTooltip"), V = J("FmSpacer"), X = J("FmButton"), te = J("FmSideSheet");
2232
- return v(), me(te, {
2233
- header: R(p)("inventory.transfer.receiveRequest.details.title") + ((K = r.purchaseOrder) != null && K.seqNumber ? ` #${(ce = r.purchaseOrder) == null ? void 0 : ce.seqNumber}` : ""),
2234
- modelValue: R(D),
2235
- "onUpdate:modelValue": d[5] || (d[5] = (W) => Ct(D) ? D.value = W : null),
2236
- "dismiss-away": c.value,
2237
- "close-button": "",
2238
- "max-width": 600
2239
- }, {
2240
- default: ne(() => {
2241
- var W, he, _e, De, Ce;
2242
- return [
2243
- e("div", Wr, [
2244
- e("div", null, [
2245
- F(x, {
2246
- items: B.value,
2247
- modelValue: Y.value,
2248
- "onUpdate:modelValue": d[0] || (d[0] = (z) => Y.value = z)
2249
- }, null, 8, ["items", "modelValue"])
2250
- ]),
2251
- Y.value.value === "overview" ? (v(), w(ie, { key: 0 }, [
2252
- e("div", null, [
2253
- F(j, {
2254
- variant: "outlined",
2255
- class: "flex flex-col gap-8 px-12 py-16"
2256
- }, {
2257
- default: ne(() => {
2258
- var z, U, Z, pe, ye, Fe, rt, st, nt;
2259
- return [
2260
- e("div", Yr, [
2261
- e("div", Qr, S(R(p)("inventory.transfer.receiveRequest.details.requestSummary")), 1),
2262
- e("div", Xr, [
2263
- F(ke, null, {
2264
- default: ne(() => {
2265
- var ot;
2266
- return [
2267
- $e(S((ot = s.purchaseOrder) == null ? void 0 : ot.status), 1)
2268
- ];
2269
- }),
2270
- _: 1
2271
- }),
2272
- F(_, {
2273
- label: Oe.value.status,
2274
- class: Pe(Oe.value.statusClass),
2275
- compact: ""
2276
- }, null, 8, ["label", "class"]),
2277
- m.value ? (v(), w("div", Zr, [
2278
- F(P, {
2279
- name: "local_shipping",
2280
- color: "#666666"
2281
- }),
2282
- e("span", Jr, S(m.value), 1)
2283
- ])) : G("", !0)
2284
- ])
2285
- ]),
2286
- F(E),
2287
- e("div", es, [
2288
- e("div", ts, [
2289
- e("div", rs, [
2290
- e("div", ss, S(R(p)("inventory.transfer.receiveRequest.details.createdAt")), 1)
2291
- ]),
2292
- e("div", ns, S(R(Ee)(((z = r.purchaseOrder) == null ? void 0 : z._id) ?? "")), 1)
2293
- ]),
2294
- (U = r.purchaseOrder) != null && U.effectiveAt ? (v(), w("div", os, [
2295
- e("div", as, S(R(p)("inventory.transfer.receiveRequest.details.backdatedTo")), 1),
2296
- e("div", is, S(R(pt)(new Date((Z = r.purchaseOrder) == null ? void 0 : Z.effectiveAt))), 1)
2297
- ])) : G("", !0),
2298
- e("div", ls, [
2299
- e("div", cs, S(R(p)("inventory.transfer.receiveRequest.details.type.title")), 1),
2300
- e("div", us, S(R(p)(
2301
- `inventory.transfer.receiveRequest.details.type.${q.value.toLocaleLowerCase("en-US")}`
2302
- )), 1)
2303
- ]),
2304
- (ye = (pe = r.purchaseOrder) == null ? void 0 : pe.supplier) != null && ye.name ? (v(), w("div", ds, [
2305
- e("div", ms, S(R(p)("inventory.transfer.receiveRequest.details.from")), 1),
2306
- e("div", fs, S((rt = (Fe = r.purchaseOrder) == null ? void 0 : Fe.supplier) == null ? void 0 : rt.name), 1)
2307
- ])) : G("", !0),
2308
- r.transferTo ? (v(), w("div", ps, [
2309
- e("div", ys, S(R(p)("inventory.transfer.receiveRequest.details.to")), 1),
2310
- e("div", vs, S(r.transferTo), 1)
2311
- ])) : G("", !0),
2312
- (st = r.purchaseOrder) != null && st.ref ? (v(), w("div", hs, [
2313
- e("div", bs, S(R(p)("inventory.transfer.receiveRequest.details.reference")), 1),
2314
- e("div", gs, S(r.purchaseOrder.ref), 1)
2315
- ])) : G("", !0),
2316
- (nt = r.purchaseOrder) != null && nt.remark ? (v(), w("div", _s, [
2317
- e("div", Ss, S(R(p)("inventory.transfer.receiveRequest.details.remark")), 1),
2318
- e("div", ws, S(r.purchaseOrder.remark), 1)
2319
- ])) : G("", !0)
2320
- ])
2321
- ];
2322
- }),
2323
- _: 1
2324
- })
2325
- ]),
2326
- F(Hr, {
2327
- "po-request": r.poRequest,
2328
- purchaseOrder: r.purchaseOrder,
2329
- transferType: q.value,
2330
- transferToDbName: r.transferToDbName,
2331
- scope: r.scope
2332
- }, null, 8, ["po-request", "purchaseOrder", "transferType", "transferToDbName", "scope"]),
2333
- e("div", Rs, [
2334
- e("div", xs, [
2335
- e("div", Os, [
2336
- e("span", Ns, [
2337
- $e(S(xe.value ? R(p)("inventory.transfer.receiveRequest.details.receivedItems") : R(p)("inventory.transfer.receiveRequest.details.requestedItems")) + " ", 1),
2338
- (he = (W = r.purchaseOrder) == null ? void 0 : W.netSuite) != null && he.missingItems && ((De = (_e = r.purchaseOrder) == null ? void 0 : _e.netSuite) == null ? void 0 : De.missingItems.length) > 0 ? (v(), me(f, {
2339
- key: 0,
2340
- variant: "rich",
2341
- placement: "top",
2342
- "z-index": 51
2343
- }, {
2344
- content: ne(() => {
2345
- var z, U;
2346
- return [
2347
- e("div", $s, [
2348
- (v(!0), w(ie, null, be((U = (z = r.purchaseOrder) == null ? void 0 : z.netSuite) == null ? void 0 : U.missingItems, (Z, pe) => (v(), w("div", {
2349
- class: "flex justify-center align-middle",
2350
- key: pe
2351
- }, [
2352
- F(P, {
2353
- name: "arrow_right",
2354
- size: "sm"
2355
- }),
2356
- $e(" " + S(`(${Z.netSuiteId}) ${Z.name}: ${Z.reason}`), 1)
2357
- ]))), 128))
2358
- ])
2359
- ];
2360
- }),
2361
- default: ne(() => [
2362
- F(P, {
2363
- name: "error",
2364
- color: "#ff2c2c",
2365
- size: "sm"
2366
- })
2367
- ]),
2368
- _: 1
2369
- })) : G("", !0)
2370
- ])
2371
- ]),
2372
- F(E),
2373
- (v(!0), w(ie, null, be(((Ce = r.purchaseOrder) == null ? void 0 : Ce.items) ?? [], (z, U) => {
2374
- var Z;
2375
- return v(), w("div", {
2376
- key: U,
2377
- class: "flex flex-col"
2378
- }, [
2379
- e("div", ks, [
2380
- e("div", Ds, [
2381
- $e(S(z.name) + " ", 1),
2382
- Q(z) ? (v(), me(f, {
2383
- key: 0,
2384
- variant: "rich",
2385
- placement: "top",
2386
- "z-index": 51
2387
- }, {
2388
- content: ne(() => {
2389
- var pe, ye;
2390
- return [
2391
- e("div", Cs, [
2392
- d[6] || (d[6] = e("div", { class: "font-semibold" }, "Submission changes", -1)),
2393
- e("div", null, "Original Amount: " + S((pe = le(z)) == null ? void 0 : pe.originalAmount), 1),
2394
- e("div", null, " New Amount: " + S((ye = le(z)) == null ? void 0 : ye.newAmount), 1)
2395
- ])
2396
- ];
2397
- }),
2398
- default: ne(() => [
2399
- F(P, {
2400
- name: "error",
2401
- color: "#ff9500",
2402
- size: "sm"
2403
- })
2404
- ]),
2405
- _: 2
2406
- }, 1024)) : G("", !0)
2407
- ]),
2408
- e("div", As, [
2409
- e("span", {
2410
- innerHTML: T(z)
2411
- }, null, 8, qs)
2412
- ])
2413
- ]),
2414
- e("div", Ts, [
2415
- e("div", Ps, S(z.code), 1),
2416
- (Z = z.totalCost) != null && Z.amount && R(o).enableTotalCost ? (v(), w("div", Is, " (" + S(R(Le)(z.totalCost)) + ") ", 1)) : G("", !0)
2417
- ])
2418
- ]);
2419
- }), 128)),
2420
- +R(ge)(Ie.value) ? (v(), w(ie, { key: 0 }, [
2421
- e("div", Fs, [
2422
- F(E)
2423
- ]),
2424
- e("div", Ls, [
2425
- d[7] || (d[7] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Total:", -1)),
2426
- e("div", Es, S(R(Le)(Ie.value)), 1)
2427
- ])
2428
- ], 64)) : G("", !0)
2429
- ])
2430
- ])
2431
- ], 64)) : Y.value.value === "deliveryHistory" ? (v(), w("div", Bs, [
2432
- fe.value.length ? (v(), w("div", Ks, [
2433
- (v(!0), w(ie, null, be(fe.value, (z, U) => (v(), w(ie, { key: U }, [
2434
- e("div", zs, [
2435
- e("div", Gs, [
2436
- e("div", Hs, [
2437
- e("div", {
2438
- class: Pe([
2439
- {
2440
- "bg-fm-color-primary": U !== 0,
2441
- "bg-white": U === 0
2442
- },
2443
- "w-[2px] h-full"
2444
- ])
2445
- }, null, 2)
2446
- ]),
2447
- d[8] || (d[8] = e("div", { class: "h-24 w-24 bg-fm-color-primary rounded-full" }, null, -1)),
2448
- e("div", Ws, [
2449
- e("div", {
2450
- class: Pe([
2451
- {
2452
- "bg-fm-color-primary": U < fe.value.length - 1,
2453
- "bg-white": U >= fe.value.length - 1
2454
- },
2455
- "w-[2px] h-full"
2456
- ])
2457
- }, null, 2)
2458
- ])
2459
- ]),
2460
- e("div", Ys, [
2461
- e("div", Qs, S(z.header), 1),
2462
- e("div", Xs, S(z.date), 1)
2463
- ])
2464
- ]),
2465
- e("div", Zs, [
2466
- e("div", Js, [
2467
- e("div", en, [
2468
- e("div", {
2469
- class: Pe([
2470
- {
2471
- "bg-fm-color-primary": U < fe.value.length - 1,
2472
- "bg-white": U >= fe.value.length - 1
2473
- },
2474
- "w-[2px] h-full"
2475
- ])
2476
- }, null, 2)
2477
- ])
2478
- ]),
2479
- e("div", tn, [
2480
- F(j, {
2481
- variant: "outlined",
2482
- class: "py-12 px-16"
2483
- }, {
2484
- default: ne(() => [
2485
- e("div", rn, [
2486
- (v(!0), w(ie, null, be(z.info, (Z, pe) => (v(), w("div", {
2487
- key: pe,
2488
- class: "flex flex-col gap-4"
2489
- }, [
2490
- e("div", sn, S(Z == null ? void 0 : Z.label), 1),
2491
- e("div", nn, [
2492
- (v(!0), w(ie, null, be(Z == null ? void 0 : Z.values, (ye, Fe) => (v(), w("div", {
2493
- key: Fe,
2494
- class: "fm-typo-en-body-lg-600"
2495
- }, [
2496
- typeof ye == "string" ? (v(), w(ie, { key: 0 }, [
2497
- $e(S(ye), 1)
2498
- ], 64)) : (v(), me(At(ye), { key: 1 }))
2499
- ]))), 128))
2500
- ])
2501
- ]))), 128))
2502
- ])
2503
- ]),
2504
- _: 2
2505
- }, 1024)
2506
- ])
2507
- ])
2508
- ], 64))), 128))
2509
- ])) : (v(), w("div", Vs, [
2510
- F(V),
2511
- e("div", null, [
2512
- e("img", {
2513
- src: R(Lt),
2514
- alt: "List is empty"
2515
- }, null, 8, Us)
2516
- ]),
2517
- e("div", Ms, S(R(p)("inventory.transfer.receiveRequest.details.noRecordsFound")), 1),
2518
- e("div", js, S(R(p)("inventory.transfer.receiveRequest.details.trackDeliveryMessage")), 1),
2519
- F(V),
2520
- F(V)
2521
- ]))
2522
- ])) : G("", !0)
2523
- ])
2524
- ];
2525
- }),
2526
- "side-sheet-footer": ne(() => [
2527
- e("div", on, [
2528
- (v(!0), w(ie, null, be(L.value, (W) => (v(), w(ie, null, [
2529
- R(Qe)[W].available != !1 ? (v(), me(X, {
2530
- key: W,
2531
- label: R(p)(R(Qe)[W].translationKey),
2532
- onClick: (he) => ae(W),
2533
- loading: u.value === W,
2534
- disabled: u.value !== W && $.value,
2535
- variant: R(Qe)[W].buttonVariant
2536
- }, null, 8, ["label", "onClick", "loading", "disabled", "variant"])) : G("", !0)
2537
- ], 64))), 256)),
2538
- R(O).ableToMarkReceived(r.purchaseOrder) && !L.value.includes("completeReceive") ? (v(), me(X, {
2539
- key: 0,
2540
- label: R(p)("inventory.transfer.receiveRequest.actions.completeReceive"),
2541
- onClick: d[1] || (d[1] = (W) => ae("completeReceive")),
2542
- loading: u.value === "completeReceive",
2543
- disabled: u.value !== "completeReceive" && $.value
2544
- }, null, 8, ["label", "loading", "disabled"])) : G("", !0),
2545
- R(O).ableToMarkApproved(r.purchaseOrder) && r.canApprove && !L.value.includes("approveRequest") ? (v(), me(X, {
2546
- key: 1,
2547
- label: R(p)("inventory.transfer.approval.actions.approveRequest"),
2548
- onClick: d[2] || (d[2] = (W) => ae("approveRequest")),
2549
- loading: u.value === "approveRequest",
2550
- disabled: u.value !== "approveRequest" && $.value
2551
- }, null, 8, ["label", "loading", "disabled"])) : G("", !0),
2552
- R(O).ableToCreateFulfillment(r.purchaseOrder, r.poRequest) && s.scope === "approval" ? (v(), me(X, {
2553
- key: 2,
2554
- label: R(p)("inventory.transfer.receiveRequest.actions.processRequest"),
2555
- onClick: d[3] || (d[3] = (W) => ae("processRequest")),
2556
- loading: u.value === "processRequest",
2557
- disabled: u.value !== "processRequest" && $.value
2558
- }, null, 8, ["label", "loading", "disabled"])) : G("", !0),
2559
- F(X, {
2560
- label: R(p)("common.close"),
2561
- variant: "tertiary",
2562
- onClick: d[4] || (d[4] = (W) => b("update:show", !1))
2563
- }, null, 8, ["label"])
2564
- ])
2565
- ]),
2566
- _: 1
2567
- }, 8, ["header", "modelValue", "dismiss-away"]);
2568
- };
2569
- }
2570
- });
2571
- export {
2572
- Je as P,
2573
- _n as _,
2574
- bn as a,
2575
- gn as b,
2576
- zt as g,
2577
- Ge as u
2578
- };