@feedmepos/mf-inventory-portal 1.0.13 → 1.0.15-dev.1

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