@feedmepos/mf-inventory-portal 1.1.3-dev.2 → 1.1.3-dev.3

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