@feedmepos/mf-inventory-portal 1.8.0-dev.15 → 1.8.0-dev.16

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 (136) hide show
  1. package/dist/{App-BYwjYoox.js → App-xSsyvQV_.js} +515 -536
  2. package/dist/{ApprovalView-CvfLuQiG.js → ApprovalView-DfJ0FAiD.js} +9 -9
  3. package/dist/{BindingsDialog-CS0IlwGC.js → BindingsDialog-oAZyjgrN.js} +2 -2
  4. package/dist/{BindingsPicker-CqY5tyvT.js → BindingsPicker-CEIo7myR.js} +8 -8
  5. package/dist/{BindingsTable-BA1CMNtR.js → BindingsTable-BKa-JYRR.js} +4 -4
  6. package/dist/BulkReceiveRequestPage-C6Oyg5-E.js +2839 -0
  7. package/dist/{ChangeLocationComponent.vue_vue_type_script_setup_true_lang-B6s_QcuY.js → ChangeLocationComponent.vue_vue_type_script_setup_true_lang-BvleQo5y.js} +1 -1
  8. package/dist/{ClosingDraftView-Bk8TmRfV.js → ClosingDraftView-tJrjqyAC.js} +19 -19
  9. package/dist/{ClosingHistoryView-XMROUlaz.js → ClosingHistoryView-CJQlK4Xc.js} +7 -7
  10. package/dist/{ClosingTemplateView-CxQp2kaI.js → ClosingTemplateView-DYRtdK5h.js} +18 -18
  11. package/dist/{CustomPrintTemplatePreview.vue_vue_type_script_setup_true_lang-KgvAbmkj.js → CustomPrintTemplatePreview.vue_vue_type_script_setup_true_lang-DEwi7wFf.js} +1 -1
  12. package/dist/{DefaultView-DNKPKrrr.js → DefaultView-CxTBlkln.js} +2 -2
  13. package/dist/{DeliveryOrderPrintPreview-CfCMlcEC.js → DeliveryOrderPrintPreview-Bywdjc2U.js} +2 -2
  14. package/dist/{EmailDialog.vue_vue_type_script_setup_true_lang-BLfRq8o3.js → EmailDialog.vue_vue_type_script_setup_true_lang-DcFAUTdO.js} +38 -33
  15. package/dist/{FeatureCapabilityBadge.vue_vue_type_script_setup_true_lang-Bmei7M_d.js → FeatureCapabilityBadge.vue_vue_type_script_setup_true_lang-C8c6rmJv.js} +11 -10
  16. package/dist/FeatureCapabilityGate-B41dULfm.js +77 -0
  17. package/dist/FeaturePageGate.vue_vue_type_script_setup_true_lang-D4G6i1D6.js +189 -0
  18. package/dist/{FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-AKDqv1C8.js → FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-CnqH115V.js} +1 -1
  19. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DQIfW9h3.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-QBviJzAO.js} +2 -2
  20. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DrTNzJSz.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BqHtzo20.js} +2 -2
  21. package/dist/{FmMultiselectDialog-CchCZDYp.js → FmMultiselectDialog-CFNZMzlC.js} +2 -2
  22. package/dist/{FmMultiselectDialog-DD6AbolT.js → FmMultiselectDialog-M6CvNFW1.js} +2 -2
  23. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-MqvhtQcN.js → FmUnitInput.vue_vue_type_script_setup_true_lang-BGco50Ma.js} +5 -5
  24. package/dist/{ImportView-f35OUKFU.js → ImportView-C2GOmpuK.js} +6 -6
  25. package/dist/{IngredientsView-CLC1di0L.js → IngredientsView-wB9kGiOK.js} +15 -15
  26. package/dist/{IntegrationExplorerView-BWzUCAD0.js → IntegrationExplorerView-BujwGE4q.js} +1414 -1485
  27. package/dist/{IntegrationPlatformView-C78gW5nI.js → IntegrationPlatformView-Wnvj6-BG.js} +4899 -4794
  28. package/dist/{IntegrationView-CnUWuRtH.js → IntegrationView-C77rSbpn.js} +14 -14
  29. package/dist/{InventoryBindingForm-ZGjVpCAI.js → InventoryBindingForm-Bs7Duwfj.js} +1 -1
  30. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-CQDso4fW.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-DawAEeuP.js} +4 -4
  31. package/dist/{InventoryBindingSummary-B68FLrzC.js → InventoryBindingSummary-BefkYWIr.js} +1 -1
  32. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DlCmFAUg.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BpUMK6fj.js} +2 -2
  33. package/dist/PlanTierBadge.vue_vue_type_script_setup_true_lang-CM3gtYZo.js +19 -0
  34. package/dist/{PlanUpgradeDialog.vue_vue_type_script_setup_true_lang-E6WVZA-D.js → PlanUpgradeDialog.vue_vue_type_script_setup_true_lang-0F-yOcPC.js} +1 -1
  35. package/dist/PremiumUpgradePage.vue_vue_type_script_setup_true_lang-DGAxPOEh.js +58 -0
  36. package/dist/ProductionRunDetailPage-CVx9LS-P.js +2316 -0
  37. package/dist/{ProductionRunLifecycleDialogs.vue_vue_type_script_setup_true_lang--NWDSxIT.js → ProductionRunLifecycleDialogs.vue_vue_type_script_setup_true_lang-4aYz5NwS.js} +1626 -1712
  38. package/dist/ProductionRunPage-CuXzmWMc.js +953 -0
  39. package/dist/{PublishView-BvuP_W4l.js → PublishView-Bu8J6ndy.js} +3 -3
  40. package/dist/{PurchaseOrderPrintPreview-CTFNQWED.js → PurchaseOrderPrintPreview-DaslFe8u.js} +2 -2
  41. package/dist/{ReceiveRequestView-Ca9jGuKW.js → ReceiveRequestView-CKPBpN4x.js} +13 -13
  42. package/dist/{RecipeView-Vm2c1vGo.js → RecipeView-BeZ9ljtA.js} +15 -15
  43. package/dist/{SettingsView-49IPE742.js → SettingsView-CWhMdNfn.js} +10 -9
  44. package/dist/{StockView-CylYMrFJ.js → StockView-C5IhPGxi.js} +21 -21
  45. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-DYoom8UC.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-B9Rx_9b7.js} +1 -1
  46. package/dist/{SupplierView-CCB8gkT1.js → SupplierView-BSGajl9V.js} +13 -13
  47. package/dist/{SurchargeView-MXCxLWTu.js → SurchargeView-DtAszxTN.js} +7 -7
  48. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-D9LGk7R7.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-CfxroS8u.js} +2 -2
  49. package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-Cp2CDerI.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-CTj_jYK1.js} +1 -1
  50. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-B_9i5LzY.js +4900 -0
  51. package/dist/{TransferTemplateView-DZEYUHOu.js → TransferTemplateView-D6_AfMja.js} +19 -19
  52. package/dist/{UnitCostHistoryView-TnQwZk3R.js → UnitCostHistoryView-kisQehVE.js} +4 -4
  53. package/dist/{UnitDisplayControl.vue_vue_type_script_setup_true_lang-C6o4xrjZ.js → UnitDisplayControl.vue_vue_type_script_setup_true_lang-DKoPNZoW.js} +4 -4
  54. package/dist/{UnitView-CFqdNGjT.js → UnitView-jSLennZW.js} +7 -7
  55. package/dist/{WarehouseView-rH3loGl_.js → WarehouseView-CUdWJCMq.js} +8 -8
  56. package/dist/{WastageTemplateView-Cnsi_EJ1.js → WastageTemplateView--B0LSwHa.js} +15 -15
  57. package/dist/api/netsuite-explorer.d.ts +1 -0
  58. package/dist/{app-O0ln50NT.js → app-Bb5HLWTu.js} +2041 -2045
  59. package/dist/app.d.ts +6 -6
  60. package/dist/app.js +1 -1
  61. package/dist/{closing-template-BcXKc7kW.js → closing-template-CgDMayoo.js} +1 -1
  62. package/dist/components/FeatureCapabilityGate.vue.d.ts +2 -0
  63. package/dist/components/FeatureGateLayout.vue.d.ts +11 -0
  64. package/dist/components/FeaturePageGate.spec.d.ts +1 -0
  65. package/dist/components/FeaturePageGate.vue.d.ts +34 -0
  66. package/dist/components/FmAdminCollapsiblePanel.vue.d.ts +1 -1
  67. package/dist/components/FmDroppableField.vue.d.ts +1 -1
  68. package/dist/components/FmInventoryTableToolbar.vue.d.ts +2 -2
  69. package/dist/components/HrmPermissionGuard.vue.d.ts +1 -1
  70. package/dist/components/PremiumUpgradePage.vue.d.ts +2 -0
  71. package/dist/{date2-BVVlNlAO.js → date2-D9gB9BE-.js} +1 -1
  72. package/dist/{dayjs.min-86T3g7jl.js → dayjs.min-CumM_kH7.js} +1 -1
  73. package/dist/{decimal-BceSQ9qu.js → decimal-CVF1rRoj.js} +2 -2
  74. package/dist/{defineDeepModel-CYCLZ-jP.js → defineDeepModel-DE-DsQjm.js} +1 -1
  75. package/dist/{duplicate-template-BOQW9uDO.js → duplicate-template-CFYtQfQn.js} +1 -1
  76. package/dist/feature-flags/vue.d.ts +22 -1
  77. package/dist/{feature-SfaxOOo8.js → feature-kti8bU8q.js} +412 -346
  78. package/dist/{format-time-from-id-DcZjh4zF.js → format-time-from-id-CWZ5VGvM.js} +1 -1
  79. package/dist/{format-unit-display-B_Leyj1M.js → format-unit-display-BlxdvskN.js} +12 -12
  80. package/dist/{id-to-date-CxJMEppi.js → id-to-date-BaH_1Kui.js} +1 -1
  81. package/dist/{import-export.helper-CTzQihBw.js → import-export.helper-8rKrOB0E.js} +5 -5
  82. package/dist/{index-D5JOuvFG.js → index-B9p_OEdk.js} +1 -1
  83. package/dist/{index-DiN65wc9.js → index-BHc3cNyz.js} +3 -3
  84. package/dist/{index-WnJgGINW.js → index-MEUJonBr.js} +1 -1
  85. package/dist/layout/SingleColumnLayout.vue.d.ts +1 -1
  86. package/dist/{lz-string-COM8L2Yg.js → lz-string-IiazGN0W.js} +1 -1
  87. package/dist/{netsuite-B4PKJ2O4.js → netsuite-BeDxaeKM.js} +2 -2
  88. package/dist/netsuite-explorer-4IluitzS.js +79 -0
  89. package/dist/{predefined-templates-jno0IPO6.js → predefined-templates-D4qVID1q.js} +1 -1
  90. package/dist/{purchase-order-template-CBgiJ239.js → purchase-order-template-GTOntq3C.js} +1 -1
  91. package/dist/{recalculationUtils-C-dyQAGg.js → recalculationUtils-Dye8x2TO.js} +1 -1
  92. package/dist/{row-action.enum-D2CmAs2h.js → row-action.enum-CVJbq_-y.js} +1 -1
  93. package/dist/{rules-CByHkO8L.js → rules-Y3zXVj3i.js} +3 -3
  94. package/dist/{stock-DrSVVTuZ.js → stock-BIjTQFsR.js} +2 -2
  95. package/dist/{stock-DbyYZzKm.js → stock-BR8x3nlx.js} +1 -1
  96. package/dist/stores/feature.d.ts +21 -1
  97. package/dist/stores/feature.load-state.spec.d.ts +1 -0
  98. package/dist/stores/warehouse.d.ts +1 -1
  99. package/dist/style.css +1 -1
  100. package/dist/{supplier-DcqbvDxz.js → supplier-CbdCjiIB.js} +2 -2
  101. package/dist/{surcharge-BqcD_sf2.js → surcharge-BoXLK6o0.js} +1 -1
  102. package/dist/tsconfig.app.tsbuildinfo +1 -1
  103. package/dist/{uom-rules-2cAqJPJa.js → uom-rules-C5h1AoPJ.js} +1 -1
  104. package/dist/{use-ingredient-select-dialog-DwQn7p6y.js → use-ingredient-select-dialog-D196q_qk.js} +2 -2
  105. package/dist/{use-inventory-binding-dialog-Id5sz9Xu.js → use-inventory-binding-dialog-B4IhhCjM.js} +2 -2
  106. package/dist/{use-template-enabled-locations-8RnaHV8u.js → use-template-enabled-locations-CDKP3kTS.js} +2 -2
  107. package/dist/{use-transfer-locations-JvPP8F4f.js → use-transfer-locations-DE4vxSDp.js} +2 -2
  108. package/dist/{useHrmPermission-OGla5jyF.js → useHrmPermission-D1dkveCP.js} +1 -1
  109. package/dist/{useNavigationMenu-BVJlsjVn.js → useNavigationMenu-N5_7da8m.js} +39 -39
  110. package/dist/{useSseClient-BaM0oGDR.js → useSseClient-CKpNaz5g.js} +1 -1
  111. package/dist/views/changelog/composables/use-snapshot-diff.d.ts +2 -2
  112. package/dist/views/integration/IntegrationPlatformView.vue.d.ts +2 -0
  113. package/dist/views/production-run/ProductionRunDetailPage.spec.d.ts +1 -0
  114. package/dist/views/production-run/ProductionRunDetailPage.vue.d.ts +15 -0
  115. package/dist/views/production-run/ProductionRunPage.vue.d.ts +2 -0
  116. package/dist/views/production-run/features/detail/use-production-run-detail.d.ts +11 -1
  117. package/dist/views/production-run/shared/helpers/production-run-navigation.d.ts +0 -1
  118. package/dist/views/production-run/shared/ui/ProductionRunInfoBadge.vue.d.ts +1 -1
  119. package/dist/views/production-run/shared/ui/ProductionRunInfoText.vue.d.ts +1 -1
  120. package/dist/views/production-run/shared/ui/ProductionRunScrollHint.vue.d.ts +2 -2
  121. package/dist/views/production-run/shared/ui/ProductionRunTextarea.vue.d.ts +3 -3
  122. package/dist/views/receive-request/composables/use-receive-request-form.spec.d.ts +1 -0
  123. package/dist/views/receive-request-bulk/BulkReceiveRequestPage.vue.d.ts +2 -0
  124. package/dist/views/receive-request-bulk/components/CreateTransferWizard.spec.d.ts +1 -0
  125. package/dist/views/receive-request-bulk/composables/use-bulk-receive-request-form.d.ts +6 -6
  126. package/dist/views/receive-request-bulk/composables/use-bulk-receive-request-form.readiness.spec.d.ts +1 -0
  127. package/dist/views/warehouse/components/WarehouseForm.vue.d.ts +2 -2
  128. package/dist/{PlanTierBadge.vue_vue_type_script_setup_true_lang-DwUCuX11.js → vue-CxSKQOrZ.js} +84 -68
  129. package/dist/{vue-i18n-Cf9XKwOr.js → vue-i18n-CTR_IUvd.js} +258 -258
  130. package/dist/{xlsx.util-EZTW-mf4.js → xlsx.util-J9pxGRQD.js} +2 -2
  131. package/package.json +4 -4
  132. package/dist/BulkReceiveRequestView-CFaMPFfO.js +0 -2657
  133. package/dist/FeatureCapabilityGate-CFUPteG8.js +0 -74
  134. package/dist/ProductionRunDetailView-DPcovCY1.js +0 -2312
  135. package/dist/ProductionRunView-DJXZ_hmi.js +0 -931
  136. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-BIc4mZJI.js +0 -4847
@@ -0,0 +1,4900 @@
1
+ import { f as lt, p as ks } from "./format-time-from-id-CWZ5VGvM.js";
2
+ import { defineComponent as Ve, ref as oe, watch as Qe, createElementBlock as y, openBlock as i, createCommentVNode as V, createElementVNode as e, withDirectives as xs, toDisplayString as O, unref as b, vModelText as ws, toRaw as $s, shallowRef as dt, onUnmounted as os, triggerRef as Cs, computed as K, getCurrentScope as As, onScopeDispose as Ns, readonly as Ds, h as ae, resolveComponent as le, createVNode as q, Fragment as De, renderList as Te, reactive as Rs, onMounted as ns, createBlock as he, withCtx as pe, createTextVNode as Xe, normalizeClass as Ge, renderSlot as Ps, isRef as Fs, resolveDynamicComponent as Is } from "vue";
3
+ import { c as Gt } from "./component-BmLAdDiY.js";
4
+ import { D as qe, R as Ne } from "./row-action.enum-CVJbq_-y.js";
5
+ import { s as Fe, q as Ce, H as st, d as Ts, u as ze, $ as z, a4 as as, a5 as yt, _ as Se, a as Dt, a6 as Wt, a7 as Es, a8 as qs, G as Vs, t as Rt, c as wt, O as Qt, a9 as ls, r as at, C as je, B as mt, aa as Ls } from "./app-Bb5HLWTu.js";
6
+ import { h as Pt, a as js, t as Us, b as et } from "./date2-D9gB9BE-.js";
7
+ import { l as Ms, a as $e, t as We, d as ut } from "./rules-Y3zXVj3i.js";
8
+ import { F as Be, u as Ye, c as Bs, d as Yt, e as St } from "./feature-kti8bU8q.js";
9
+ import { L as zs } from "./lz-string-IiazGN0W.js";
10
+ import { useI18n as ht, useCoreStore as bt } from "@feedmepos/mf-common";
11
+ import { useDialog as gt, useSnackbar as Je, components as pt, FmButtonVariant as Ue, useProxiedModel as Ks } from "@feedmepos/ui-library";
12
+ import { u as _t, a as Ft, S as Me } from "./netsuite-BeDxaeKM.js";
13
+ import { F as tt } from "./FmAdminBadge-DlplQOHb.js";
14
+ import { _ as Jt } from "./empty-placeholder-B0QU467o.js";
15
+ import { a as Hs, b as Gs, f as ft } from "./format-unit-display-BlxdvskN.js";
16
+ import { u as Ze, _ as Ws } from "./SystemTrailDialog.vue_vue_type_script_setup_true_lang-CfxroS8u.js";
17
+ import { F as Qs } from "./FeatureCapabilityGate-B41dULfm.js";
18
+ import { _ as Ys, a as Js, b as Xs } from "./FmUnitInput.vue_vue_type_script_setup_true_lang-BGco50Ma.js";
19
+ import { e as Zs } from "./index-BHc3cNyz.js";
20
+ import { i as er } from "./FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-CnqH115V.js";
21
+ import { F as Xt } from "./form-mode.enum-BKiNVH6A.js";
22
+ import { u as is } from "./supplier-CbdCjiIB.js";
23
+ import { u as tr } from "./surcharge-BoXLK6o0.js";
24
+ import { f as sr, h as rr, r as or, s as nr } from "./predefined-templates-D4qVID1q.js";
25
+ import { F as ar } from "./decimal-CVF1rRoj.js";
26
+ import { d as us } from "./defineDeepModel-DE-DsQjm.js";
27
+ import { u as lr } from "./vue-i18n-CTR_IUvd.js";
28
+ import { u as ir } from "./useHrmPermission-D1dkveCP.js";
29
+ function cs(u, t) {
30
+ return t.reduce(
31
+ (o, m) => {
32
+ const c = m.received.find((d) => d.sku._id === u._id);
33
+ return c && (o = Ms(o, c.amount)), o;
34
+ },
35
+ ar.toPrecision(Fe.fromNumber(0), u.unit.precision)
36
+ );
37
+ }
38
+ function ds(u) {
39
+ var o;
40
+ const t = Ce(), r = (o = u.supplier.supplyItems) != null && o.length ? { ...u.supplier, registrationNumber: u.supplier.registrationNumber ?? "" } : void 0;
41
+ return (m) => {
42
+ var c, d;
43
+ if ((c = m.totalCost) != null && c.amount) return m.totalCost;
44
+ if (!m.isCustomCost)
45
+ try {
46
+ const { cost: n } = Be.calculateDefaultCost({
47
+ item: m.sku,
48
+ amount: m.quantity,
49
+ measurement: m.measurement,
50
+ overrides: r ? { supplier: r } : void 0,
51
+ defaultCurrency: t
52
+ });
53
+ return n.amount ? n : void 0;
54
+ } catch (n) {
55
+ console.warn("[print] cost auto-calculation failed for item", (d = m.sku) == null ? void 0 : d._id, n);
56
+ return;
57
+ }
58
+ };
59
+ }
60
+ function ur(u) {
61
+ var ke, Ae, Q, ye, P, w, $;
62
+ const { po: t, currentLocation: r, business: o, fulfilling: m, por: c } = u, d = r.doc.profile || {}, { name: n, address: l, regNo: x, legalName: v } = d, D = {
63
+ name: n || r.name || "",
64
+ legalName: v || void 0,
65
+ registrationNumber: x || void 0,
66
+ line1: (l == null ? void 0 : l.line1) || "",
67
+ line2: (l == null ? void 0 : l.line2) || void 0,
68
+ postcode: (l == null ? void 0 : l.postcode) || "",
69
+ city: (l == null ? void 0 : l.city) || "",
70
+ state: (l == null ? void 0 : l.state) || "",
71
+ country: (l == null ? void 0 : l.country) || ""
72
+ }, R = {
73
+ name: t.supplier.name,
74
+ phoneNumber: t.supplier.phoneNumber || void 0,
75
+ registrationNumber: t.supplier.registrationNumber || void 0,
76
+ line1: ((ke = t.supplier.address) == null ? void 0 : ke.line1) || "",
77
+ line2: ((Ae = t.supplier.address) == null ? void 0 : Ae.line2) || void 0,
78
+ postcode: ((Q = t.supplier.address) == null ? void 0 : Q.postcode) || "",
79
+ city: ((ye = t.supplier.address) == null ? void 0 : ye.city) || "",
80
+ state: ((P = t.supplier.address) == null ? void 0 : P.state) || "",
81
+ country: ((w = t.supplier.address) == null ? void 0 : w.country) || ""
82
+ }, T = ds(t), _ = [], M = t.items.filter((N) => N.sku).map((N) => {
83
+ var de;
84
+ const { sku: U, measurement: Z } = N, ue = $e(
85
+ cs(N.sku, t.deliveryOrder || []),
86
+ !1
87
+ ), H = T(N);
88
+ return H && _.push(H), {
89
+ code: U.code,
90
+ description: U.name,
91
+ quantity: $e(N.quantity, !1),
92
+ unit: (Z == null ? void 0 : Z.abbrev) || ((de = U.unit) == null ? void 0 : de.abbrev) || "",
93
+ received: ue,
94
+ unitCost: H ? `${H.currency} ${Be.toFormatString({
95
+ value: N.quantity.amount === 0 ? Be.fromNumber(0) : Be.divide([H, N.quantity])
96
+ })}` : void 0,
97
+ cost: H ? `${H.currency} ${Be.toFormatString({
98
+ value: H
99
+ })}` : void 0
100
+ };
101
+ }), E = _.length ? `${_[0].currency} ${Be.toFormatString({
102
+ value: _.reduce((N, U) => Be.add([N, U]), Be.reset())
103
+ })}` : void 0, te = (t.deliveryOrder || []).map((N) => ({
104
+ createdAt: Pt(new Date(N.createdAt)),
105
+ ref: N.deliveryOrderNumber,
106
+ remark: N.remark || "",
107
+ items: (N.received || []).map((U) => {
108
+ var Z, ue, H, de, xe;
109
+ return {
110
+ code: ((Z = U.sku) == null ? void 0 : Z.code) || "",
111
+ description: ((ue = U.sku) == null ? void 0 : ue.name) || "",
112
+ quantity: $e(U.amount),
113
+ unit: ((H = U.measurement) == null ? void 0 : H.abbrev) || ((xe = (de = U.sku) == null ? void 0 : de.unit) == null ? void 0 : xe.abbrev) || ""
114
+ };
115
+ })
116
+ }));
117
+ let se = st.Enum.purchaseOrder, J = "Inventory Receive Note";
118
+ if (t.supplier.internal ? (J = "Inventory Transfer Note", se = st.Enum.transferOrder) : (J = "Purchase Order", se = st.Enum.purchaseOrder), ($ = c == null ? void 0 : c.from) != null && $.dbName) {
119
+ const N = c.from.dbName;
120
+ r.dbName === N || (J = "Inventory Receive Note", se = st.Enum.goodsReceivedNote);
121
+ }
122
+ const be = {
123
+ title: J,
124
+ businessName: o == null ? void 0 : o.name,
125
+ logo: o == null ? void 0 : o.thumbnail,
126
+ orderNumber: t.seqNumber.toString(),
127
+ createdAt: lt(t._id),
128
+ ref: t.ref || "",
129
+ remark: t.remark || "",
130
+ buyer: D,
131
+ supplier: R,
132
+ items: M,
133
+ grandTotal: E,
134
+ status: t.status,
135
+ deliveryOrders: te
136
+ }, ie = m && (t.deliveryFullfillment || []).length > 0;
137
+ return ie && (se = st.Enum.deliveryOrder), { printData: be, templateType: se, isDeliveryPrint: ie };
138
+ }
139
+ function ms(u) {
140
+ var v;
141
+ const { printData: t, templateType: r } = ur(u), m = sr().getTemplateByType(r), c = !!((v = m == null ? void 0 : m.blocks) != null && v.length), d = rr(r), n = c ? m.blocks : d.blocks, l = c ? m.name : d.name, x = !c;
142
+ try {
143
+ const D = or(n, t), R = D.match(/<style>([\s\S]*?)<\/style>/), T = R ? `<style>${R[1]}</style>` : "", _ = D.replace(/<style>[\s\S]*?<\/style>/, "");
144
+ return {
145
+ html: `<!DOCTYPE html>
146
+ <html>
147
+ <head>
148
+ <meta charset="utf-8">
149
+ <title>Print Preview</title>
150
+ <style>
151
+ @page { margin: 0; }
152
+ @media print {
153
+ body { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
154
+ }
155
+ * { box-sizing: border-box; margin: 0; padding: 0; }
156
+ </style>
157
+ ${T}
158
+ </head>
159
+ <body>${_}</body>
160
+ </html>`,
161
+ templateName: l,
162
+ isDefault: x
163
+ };
164
+ } catch {
165
+ return alert("Failed to render print template. Please try recreating the template."), null;
166
+ }
167
+ }
168
+ const cr = Ts((u, t) => {
169
+ const r = ze();
170
+ return {
171
+ async getShipments({
172
+ start: o,
173
+ end: m
174
+ }) {
175
+ const c = r.currentLocationDBName, d = `${u.inventoryBackendUrl}/${c}/shipments`;
176
+ return await t.get(`${d}?start=${o}&end=${m}`);
177
+ },
178
+ async getShipmentsByIds(o) {
179
+ if (o.length === 0)
180
+ return [];
181
+ const m = r.currentLocationDBName, c = `${u.inventoryBackendUrl}/${m}/shipments/get`;
182
+ return await t.post(c, { shipmentIds: o });
183
+ }
184
+ };
185
+ }), ps = {
186
+ [z.enum.confirmDraft]: {
187
+ primaryActions: {
188
+ text: "Confirm draft",
189
+ close: !0
190
+ },
191
+ title: "Confirm draft?",
192
+ message: "Purchase order cannot be changed after confirm draft.",
193
+ successMessage: "Purchase order draft has been confirmed"
194
+ },
195
+ [z.enum.cancelDraft]: {
196
+ primaryActions: {
197
+ text: "Cancel draft",
198
+ close: !0,
199
+ variant: "destructive"
200
+ },
201
+ title: "Cancel draft?",
202
+ message: "Purchase order cannot be changed after cancelled draft.",
203
+ successMessage: "Purchase order draft has been cancelled"
204
+ },
205
+ [z.enum.approveDraft]: {
206
+ primaryActions: {
207
+ text: "Approve draft",
208
+ close: !0
209
+ },
210
+ title: "Approve draft?",
211
+ message: "Purchase order request will be accepted.",
212
+ successMessage: "Purchase order has been approved"
213
+ },
214
+ [z.enum.rejectDraft]: {
215
+ primaryActions: {
216
+ text: "Reject draft",
217
+ close: !0
218
+ },
219
+ title: "Reject draft?",
220
+ message: "Purchase order request will be rejected. You may provide an optional reason for rejection.",
221
+ successMessage: "Purchase order has been rejected"
222
+ },
223
+ [z.enum.submitRequest]: {
224
+ primaryActions: {
225
+ text: "Submit request",
226
+ close: !0
227
+ },
228
+ title: "Confirm draft?",
229
+ message: "Purchase order cannot be changed after confirm draft.",
230
+ successMessage: "Purchase order draft has been submitted"
231
+ },
232
+ [z.enum.completeReceive]: {
233
+ primaryActions: {
234
+ text: "Mark received",
235
+ close: !0
236
+ },
237
+ title: "Mark as received",
238
+ message: "Purchase order cannot be changed after it has complete receiving.",
239
+ successMessage: "Purchase order has been marked as received"
240
+ },
241
+ [z.enum.approveRequest]: {
242
+ primaryActions: {
243
+ text: "Accept request",
244
+ close: !0
245
+ },
246
+ title: "Accept request?",
247
+ message: "Transfer out request will be accepted.",
248
+ successMessage: "Transfer out request has been approved"
249
+ },
250
+ [z.enum.rejectRequest]: {
251
+ primaryActions: {
252
+ text: "Reject request",
253
+ close: !0,
254
+ variant: "destructive"
255
+ },
256
+ title: "Reject request?",
257
+ message: "Purchase order will be rejected.",
258
+ successMessage: "Purchase order has been rejected"
259
+ },
260
+ [z.enum.processRequest]: {
261
+ primaryActions: {
262
+ text: "Process request",
263
+ close: !0,
264
+ variant: "destructive"
265
+ },
266
+ title: "Process request?",
267
+ message: "Purchase order will be processed.",
268
+ successMessage: "Purchase order has been processed"
269
+ }
270
+ }, dr = { class: "p-4" }, mr = {
271
+ key: 0,
272
+ class: "fm-typo-en-body-md-400 mb-3"
273
+ }, pr = { class: "fm-typo-en-body-md-400" }, fs = /* @__PURE__ */ Ve({
274
+ __name: "RejectDraftForm",
275
+ props: {
276
+ message: {},
277
+ confirm: { type: Function },
278
+ onChange: { type: Function }
279
+ },
280
+ setup(u) {
281
+ const t = u, { t: r } = ht(), o = oe("");
282
+ Qe(o, (c) => {
283
+ var d;
284
+ (d = t.onChange) == null || d.call(t, c ?? "");
285
+ });
286
+ function m() {
287
+ o.value = "";
288
+ }
289
+ return (c, d) => (i(), y("div", dr, [
290
+ t.message ? (i(), y("div", mr, O(t.message), 1)) : V("", !0),
291
+ e("label", pr, O(b(r)("inventory.transfer.receiveRequest.details.rejectionReason")) + " (" + O(b(r)("inventory.common.optional")) + ")", 1),
292
+ xs(e("textarea", {
293
+ "onUpdate:modelValue": d[0] || (d[0] = (n) => o.value = n),
294
+ rows: "4",
295
+ class: "w-full mt-2 p-2 border rounded"
296
+ }, null, 512), [
297
+ [ws, o.value]
298
+ ]),
299
+ e("div", { class: "mt-3 flex gap-2" }, [
300
+ e("button", {
301
+ type: "button",
302
+ class: "fm-btn fm-btn-tertiary",
303
+ onClick: m
304
+ }, "Clear")
305
+ ])
306
+ ]));
307
+ }
308
+ });
309
+ function vt(u) {
310
+ if (u.items == null)
311
+ return {};
312
+ const t = as.safeParse(u);
313
+ if (!t.success) {
314
+ const r = t.error.issues.map((o) => `${o.path.join(".") || "(root)"}: ${o.message}`).join("; ");
315
+ return console.error(
316
+ `Cannot compute receive status for PO ${u == null ? void 0 : u._id}: invalid shape at ${r}`
317
+ ), {};
318
+ }
319
+ return yt.generatedPOReceivedMap({
320
+ purchaseOrder: u
321
+ });
322
+ }
323
+ function fr(u) {
324
+ return yt.validatePOItemReceivedStatus({
325
+ dto: u
326
+ });
327
+ }
328
+ function $t(u) {
329
+ return yt.validatePOReceivedStatus({
330
+ receivedMap: u
331
+ });
332
+ }
333
+ function Ct(u, t, r) {
334
+ if (!Se.safeParse(u).success)
335
+ throw new Error(`Invalid purchase order status: ${u}`);
336
+ const o = Se.parse(u);
337
+ return yt.orderStatusCombination({
338
+ status: o,
339
+ isPOPartialReceive: t,
340
+ isPOOverReceive: r
341
+ });
342
+ }
343
+ function vs() {
344
+ const u = ze(), t = Ze(), r = Ye();
345
+ async function o(c, d) {
346
+ const n = u.currentLocationDBName;
347
+ return c.doc.supplier.internal && c.operation === z.enum.confirmDraft && (c.operation = z.enum.submitRequest), await t.processPurchaseOrder(c, d || n);
348
+ }
349
+ async function m(c, d) {
350
+ const n = u.currentLocationDBName;
351
+ return await t.processPurchaseOrderV2(c, d || n);
352
+ }
353
+ return (c) => r.useOperatePurchaseOrderV2 ? m(c.operateV2, c.transferTo) : o(c.operate, c.transferTo);
354
+ }
355
+ function He(u) {
356
+ const t = $s(u);
357
+ if (Array.isArray(t))
358
+ return t.map(He);
359
+ if (t !== null && typeof t == "object") {
360
+ const r = {};
361
+ for (const o in t)
362
+ Object.prototype.hasOwnProperty.call(t, o) && (r[o] = He(t[o]));
363
+ return r;
364
+ }
365
+ return t;
366
+ }
367
+ const Ot = {
368
+ set: "set",
369
+ add: "add",
370
+ delete: "delete"
371
+ };
372
+ function Zt(u) {
373
+ return {
374
+ dbName: u.dbName,
375
+ type: u.type,
376
+ name: u.name,
377
+ acceptRequest: u.acceptRequest ?? !1,
378
+ doc: u.doc
379
+ };
380
+ }
381
+ const ys = { line1: "", state: "", city: "", postcode: "", country: "" };
382
+ function rt(u) {
383
+ return u == null ? "" : String(u);
384
+ }
385
+ function hs(u) {
386
+ const t = u.address, r = t != null ? {
387
+ ...t,
388
+ line1: rt(t.line1),
389
+ state: rt(t.state),
390
+ city: rt(t.city),
391
+ postcode: rt(t.postcode),
392
+ country: rt(t.country)
393
+ } : { ...ys };
394
+ return {
395
+ ...u,
396
+ registrationNumber: u.registrationNumber ?? "",
397
+ address: r
398
+ };
399
+ }
400
+ function es(u, t, r, o, m) {
401
+ const c = He(u.suppliers ?? []).map(hs), d = He(t.allLocations ?? []).map(Zt), n = t._currentLocation ? Zt(He(t._currentLocation)) : null, l = r.inventory ? [He(r.inventory)] : [], x = o.state.setting ? He(o.state.setting) : null, v = He(m.surcharges ?? []);
402
+ return {
403
+ suppliers: c,
404
+ locations: d,
405
+ currentLocation: n,
406
+ inventoryDoc: l,
407
+ netSuiteSetting: x,
408
+ surcharges: v
409
+ };
410
+ }
411
+ function bs() {
412
+ const u = is(), t = ze(), r = Dt(), o = _t(), m = tr(), c = es(
413
+ u,
414
+ t,
415
+ r,
416
+ o,
417
+ m
418
+ ), d = dt(Bs({ env: c }));
419
+ d.value.setUsePartialUpdates(!0);
420
+ const n = dt(d.value.state()), l = (R) => {
421
+ n.value = d.value.state();
422
+ };
423
+ d.value.addListener(l);
424
+ const x = (R, T, _) => {
425
+ switch (R) {
426
+ case Ot.set:
427
+ Wt(n.value, T, _);
428
+ break;
429
+ case Ot.add:
430
+ qs(n.value, T, _);
431
+ break;
432
+ case Ot.delete:
433
+ Es(n.value, T);
434
+ break;
435
+ default:
436
+ console.warn(`Unknown partial update operation: ${R}, falling back to 'set'`), Wt(n.value, T, _);
437
+ }
438
+ T !== "remark" && T !== "ref" && Cs(n);
439
+ };
440
+ d.value.addPartialListener(x);
441
+ function v() {
442
+ const R = es(
443
+ u,
444
+ t,
445
+ r,
446
+ o,
447
+ m
448
+ );
449
+ try {
450
+ d.value.updateFullEnv(R), n.value = d.value.state();
451
+ } catch (T) {
452
+ console.error("[PurchaseOrderFormController] updateFullEnv failed", T);
453
+ }
454
+ }
455
+ Qe(
456
+ [
457
+ () => u.suppliers,
458
+ () => t.allLocations,
459
+ () => t._currentLocation,
460
+ () => r.inventory,
461
+ () => o.state.setting,
462
+ () => m.surcharges
463
+ ],
464
+ () => {
465
+ v();
466
+ },
467
+ { deep: !0 }
468
+ ), os(() => {
469
+ d.value.removeListener(l), d.value.removePartialListener(x);
470
+ });
471
+ function D(R) {
472
+ var T;
473
+ if (R != null && R._id) {
474
+ const _ = /* @__PURE__ */ new Set(["1", "2"]), M = R, E = M.supplier, te = E != null ? hs(E) : { _id: "", name: "", registrationNumber: "", address: { ...ys } }, se = {
475
+ ...R,
476
+ version: _.has(R.version) ? R.version : null,
477
+ supplier: te,
478
+ // items/deliveryOrder may be absent or contain null/corrupted elements.
479
+ // The Dart bridge has no null guards on sku, sku.unit, and quantity —
480
+ // all three produce "Uncaught (in promise) TypeError: $index on null".
481
+ items: (M.items ?? []).filter((J) => {
482
+ if (J == null || J.sku == null || typeof J.sku != "object") return !1;
483
+ const ne = J;
484
+ return ne.sku.unit != null && ne.quantity != null && typeof ne.quantity == "object";
485
+ }),
486
+ // received[].sku/sku.unit/amount have the exact same Dart-bridge null-guard
487
+ // gap as items[].sku/sku.unit/quantity above — filter the same way.
488
+ deliveryOrder: (M.deliveryOrder ?? []).filter((J) => J != null).map((J) => ({
489
+ ...J,
490
+ received: (J.received ?? []).filter((ne) => {
491
+ if (ne == null || ne.sku == null || typeof ne.sku != "object") return !1;
492
+ const be = ne;
493
+ return be.sku.unit != null && be.amount != null && typeof be.amount == "object";
494
+ })
495
+ }))
496
+ };
497
+ try {
498
+ d.value.loadPurchaseOrder(se);
499
+ } catch (J) {
500
+ console.error("[PurchaseOrderFormController] loadPurchaseOrder failed", J);
501
+ }
502
+ return;
503
+ }
504
+ if (!Ye().mustUsePoTemplate) {
505
+ d.value.init();
506
+ return;
507
+ }
508
+ R != null && R.template && ((T = R.templateDoc) != null && T.purchaseOrder) ? (R.items = R.templateDoc.purchaseOrder.items, d.value.initFromTemplate(R)) : d.value.initOutletToOutlet();
509
+ }
510
+ return {
511
+ controller: d,
512
+ state: n,
513
+ init: D
514
+ };
515
+ }
516
+ var At = /* @__PURE__ */ ((u) => (u.RECEIVE_REQUEST = "receive/request", u.APPROVAL = "approval", u))(At || {});
517
+ const ot = oe(), kt = oe(), xt = oe();
518
+ function ki(u, t) {
519
+ const r = gt(), o = ze(), m = Ye(), c = is(), d = bt(), n = Hs(), l = Gs(), x = oe(!1), v = Je(), D = Ze(), R = cr(), T = oe(new Array()), _ = oe(new Array()), M = oe(
520
+ t != null && t.startDate && (t != null && t.endDate) ? t : er()
521
+ ), E = K(() => {
522
+ const F = new Date(M.value.startDate), h = new Date(M.value.endDate);
523
+ return {
524
+ start: Us(F).toISOString(),
525
+ end: js(h).toISOString()
526
+ };
527
+ }), te = oe(new Array()), se = Vs(), J = oe(null);
528
+ let ne = null, be = null;
529
+ As() && Ns(() => {
530
+ ne == null || ne.abort(), be == null || be.abort();
531
+ });
532
+ async function ie(F) {
533
+ var re, ve, s;
534
+ be == null || be.abort();
535
+ const h = new AbortController();
536
+ be = h;
537
+ const g = (re = o._currentLocation) == null ? void 0 : re.dbName, B = await m.awaitLocationFeatures(g, {
538
+ signal: h.signal,
539
+ retryOnError: !0
540
+ });
541
+ if (h.signal.aborted || ((ve = o._currentLocation) == null ? void 0 : ve.dbName) !== g) return;
542
+ if (B !== "ready") {
543
+ B === "error" && ye();
544
+ return;
545
+ }
546
+ function G(a) {
547
+ var C;
548
+ if (h.signal.aborted || ((C = o._currentLocation) == null ? void 0 : C.dbName) !== g) return;
549
+ const k = {
550
+ mode: Xt.CREATE,
551
+ modelValue: F || void 0,
552
+ show: !0,
553
+ "onUpdate:show"(A) {
554
+ ot.value.show = A;
555
+ },
556
+ templateId: a,
557
+ lastClosingDate: J.value
558
+ };
559
+ ot.value = k;
560
+ }
561
+ let X;
562
+ if (m.mustUsePoTemplate && !(F != null && F.template)) {
563
+ if (await l.fetchTemplates(), h.signal.aborted || ((s = o._currentLocation) == null ? void 0 : s.dbName) !== g) return;
564
+ r.open({
565
+ title: "Create transfer",
566
+ message: "",
567
+ primaryActions: {
568
+ text: "Select a template",
569
+ close: !0
570
+ },
571
+ secondaryActions: {
572
+ text: "Outlet to Outlet",
573
+ variant: "secondary",
574
+ close: !0
575
+ }
576
+ }).onPrimary(async () => {
577
+ X = await n.getTemplateId(), X && G(X);
578
+ }).onSecondary(() => {
579
+ G(void 0);
580
+ });
581
+ } else
582
+ G(X);
583
+ }
584
+ function ke(F) {
585
+ const h = {
586
+ mode: Xt.UPDATE,
587
+ modelValue: wt(F),
588
+ show: !0,
589
+ "onUpdate:show"(g) {
590
+ ot.value.show = g;
591
+ },
592
+ lastClosingDate: J.value
593
+ };
594
+ ot.value = h;
595
+ }
596
+ function Ae(F) {
597
+ if (!d.currentBusiness.value) return;
598
+ const h = o.currentLocation;
599
+ if (h.type === "restaurant") {
600
+ const re = o.locationRestaurantFromCore(h.doc._id);
601
+ re !== null && (h.doc = re);
602
+ }
603
+ const g = ms({
604
+ po: F,
605
+ currentLocation: h,
606
+ business: d.currentBusiness.value,
607
+ fulfilling: u === "approval",
608
+ por: F.request
609
+ });
610
+ if (!g) return;
611
+ const B = nr(g.html), G = c.supplierById[F.supplier._id], X = {
612
+ recipientName: G.name,
613
+ email: (G == null ? void 0 : G.email) ?? "",
614
+ business: d.currentBusiness.value,
615
+ modelValue: B,
616
+ show: !0,
617
+ "onUpdate:show"(re) {
618
+ kt.value.show = re;
619
+ }
620
+ };
621
+ kt.value = X;
622
+ }
623
+ async function Q() {
624
+ var g, B, G, X, re, ve;
625
+ ne == null || ne.abort();
626
+ const F = new AbortController();
627
+ ne = F;
628
+ const h = (g = o._currentLocation) == null ? void 0 : g.dbName;
629
+ T.value = [], _.value = [], x.value = !0;
630
+ try {
631
+ const s = await D.getPurchaseOrders(E.value);
632
+ if (F.signal.aborted || ((B = o._currentLocation) == null ? void 0 : B.dbName) !== h) return;
633
+ T.value = s.sort((ce, f) => f._id.localeCompare(ce._id));
634
+ const a = s.flatMap((ce) => ce.shipmentIds || []).filter(Boolean), k = a.length > 0 ? await R.getShipmentsByIds(a) : [];
635
+ if (F.signal.aborted || ((G = o._currentLocation) == null ? void 0 : G.dbName) !== h) return;
636
+ _.value = k;
637
+ const C = await se.readCurrentLocationLastClosing(!0);
638
+ if (F.signal.aborted || ((X = o._currentLocation) == null ? void 0 : X.dbName) !== h) return;
639
+ const A = C == null ? void 0 : C._id;
640
+ A && (J.value = ks(A));
641
+ const W = await m.awaitLocationFeatures(h, {
642
+ signal: F.signal,
643
+ retryOnError: !0
644
+ });
645
+ if (W === "superseded" || (W === "error" && ye(), W === "ready" && m.mustUsePoTemplate && await l.fetchTemplates(), F.signal.aborted || ((re = o._currentLocation) == null ? void 0 : re.dbName) !== h)) return;
646
+ const fe = T.value.map((ce) => {
647
+ var f;
648
+ return ((f = ce.request) == null ? void 0 : f.id) ?? "";
649
+ }).filter((ce) => ce), I = await D.readRequestByIds(fe);
650
+ if (F.signal.aborted || ((ve = o._currentLocation) == null ? void 0 : ve.dbName) !== h) return;
651
+ te.value = I;
652
+ } catch {
653
+ if (F.signal.aborted) return;
654
+ v.open({
655
+ title: "Something went wrong",
656
+ message: "Error at fetching purchase orders",
657
+ type: "error"
658
+ });
659
+ } finally {
660
+ ne === F && (ne = null, x.value = !1);
661
+ }
662
+ }
663
+ function ye() {
664
+ v.open({
665
+ title: "Outlet settings couldn’t load",
666
+ message: "Transfer template requirements are unconfirmed. Refresh to try again.",
667
+ type: "warning"
668
+ });
669
+ }
670
+ async function P() {
671
+ te.value = [], x.value = !0;
672
+ try {
673
+ te.value = await D.readRequests(
674
+ void 0,
675
+ E.value.start,
676
+ E.value.end
677
+ ).then((F) => F.reverse());
678
+ } catch {
679
+ v.open({
680
+ title: "Something went wrong",
681
+ message: "Error at fetching purchase requests",
682
+ type: "error"
683
+ });
684
+ } finally {
685
+ x.value = !1;
686
+ }
687
+ }
688
+ function w() {
689
+ switch (u) {
690
+ case "receive/request":
691
+ return Q();
692
+ case "approval":
693
+ return P();
694
+ }
695
+ }
696
+ function $(F, h) {
697
+ M.value = {
698
+ startDate: F,
699
+ endDate: h
700
+ }, w();
701
+ }
702
+ o.watchLocation(async (F) => {
703
+ if (!F) {
704
+ T.value = [];
705
+ return;
706
+ }
707
+ await w();
708
+ });
709
+ async function N(F) {
710
+ return F;
711
+ }
712
+ const U = oe(), Z = oe(Math.random().toString());
713
+ async function ue(F, h) {
714
+ const g = Math.random().toString();
715
+ Z.value = g, h ?? (h = te.value.computeFirst(
716
+ (re) => re.purchaseOrderId === F._id ? re : null
717
+ ) ?? void 0);
718
+ const B = u === "receive/request" ? o.currentLocation : h == null ? void 0 : h.to, G = u === "approval", X = {
719
+ poRequest: h,
720
+ purchaseOrder: {
721
+ ...F,
722
+ status: G && (h != null && h.rejectedAt) ? Se.Enum.REJECT : F.status
723
+ },
724
+ transferTo: B == null ? void 0 : B.name,
725
+ transferToDbName: B == null ? void 0 : B.dbName,
726
+ show: !0,
727
+ canResubmit: !1,
728
+ canApprove: G,
729
+ "onUpdate:show"(re) {
730
+ U.value && (U.value = { ...U.value, show: re });
731
+ },
732
+ scope: u,
733
+ receivedMap: vt(F) ?? {},
734
+ shipments: _.value
735
+ };
736
+ U.value = X;
737
+ }
738
+ async function H(F, h, g, B, G) {
739
+ const X = vs();
740
+ x.value = !0;
741
+ try {
742
+ await X({
743
+ operate: {
744
+ operation: h,
745
+ doc: F,
746
+ options: (
747
+ // auto receive for supplier to warehouse
748
+ (h === z.enum.confirmDraft || // auto receive for warehouse to warehouse
749
+ h === z.enum.completeReceive) && m.autoReceiveWarehouse ? {
750
+ autoReceive: !0
751
+ } : void 0
752
+ )
753
+ },
754
+ operateV2: {
755
+ _id: F._id,
756
+ _rev: F._rev ?? "",
757
+ action: h === z.enum.submitRequest ? z.enum.confirmDraft : h,
758
+ payloads: G ?? []
759
+ },
760
+ transferTo: B
761
+ }), await new Promise((s) => setTimeout(s, 1e3));
762
+ const ve = ze().currentLocationDBName.startsWith("restaurant_");
763
+ h === z.enum.confirmDraft && F.effectiveAt && ve ? v.open({
764
+ title: "Success",
765
+ message: `${g}. The backdate will be reflected once your POS has received this change.`,
766
+ type: "success"
767
+ }) : v.open({
768
+ title: "Success",
769
+ message: g,
770
+ type: "success"
771
+ });
772
+ } catch (re) {
773
+ v.open({
774
+ title: "Something went wrong",
775
+ message: re instanceof Error ? re.message : "Please try again.",
776
+ type: "error"
777
+ }), console.error("Error when submitting PO operation", h, F, re);
778
+ } finally {
779
+ x.value = !1, w();
780
+ }
781
+ }
782
+ async function de(F, h, g) {
783
+ const B = ps[h];
784
+ if (!B) {
785
+ v.open({
786
+ title: "Something went wrong",
787
+ message: `Cannot process order: ${Rt(h)}`,
788
+ type: "error"
789
+ });
790
+ return;
791
+ }
792
+ const { successMessage: G, ...X } = B;
793
+ if (h === z.enum.rejectDraft) {
794
+ let s = "";
795
+ r.open({
796
+ title: X.title,
797
+ message: X.message,
798
+ primaryActions: X.primaryActions,
799
+ contentComponent: fs,
800
+ contentComponentProps: {
801
+ message: X.message,
802
+ onChange: (a) => s = a
803
+ }
804
+ }).onPrimary(() => {
805
+ const a = [];
806
+ a.push({
807
+ action: "rejectDraft",
808
+ payload: {
809
+ rejectReason: s
810
+ }
811
+ }), H(F, h, G, g, a);
812
+ });
813
+ return;
814
+ }
815
+ const re = [], ve = bs();
816
+ ve.init(F), (h === z.enum.confirmDraft || h === z.enum.submitRequest) && re.push({
817
+ action: "confirmDraft",
818
+ payload: ve.controller.value.toConfirmDraftData(Ce())
819
+ }), r.open({
820
+ title: X.title,
821
+ message: X.message,
822
+ primaryActions: X.primaryActions
823
+ }).onPrimary(() => {
824
+ H(F, h, G, g, re);
825
+ });
826
+ }
827
+ async function xe() {
828
+ r.open({
829
+ title: "Upload Transfer",
830
+ primaryActions: {
831
+ text: "Xilnex transfer note",
832
+ close: !0
833
+ },
834
+ secondaryActions: {
835
+ text: "Cancel",
836
+ close: !0
837
+ }
838
+ }).onPrimary(() => {
839
+ const F = {
840
+ show: !0,
841
+ "onUpdate:show"(h) {
842
+ xt.value.show = h;
843
+ }
844
+ };
845
+ xt.value = F;
846
+ });
847
+ }
848
+ return {
849
+ purchaseOrders: T,
850
+ shipments: _,
851
+ purchaseRequests: te,
852
+ updateDateRange: $,
853
+ fetchData: w,
854
+ loading: x,
855
+ transferDialogProps: ot,
856
+ promptCreateTransferDialog: ie,
857
+ promptUpdateTransferDialog: ke,
858
+ transferDetailsProps: U,
859
+ promptShowTransferDetails: ue,
860
+ resolvePO: N,
861
+ submitAction: de,
862
+ xilnexImportDialogProps: xt,
863
+ promptUploadTransferDialog: xe,
864
+ emailDialogProps: kt,
865
+ promptEmailDialog: Ae
866
+ };
867
+ }
868
+ function vr(u) {
869
+ var ie, ke, Ae, Q, ye, P;
870
+ const { po: t, currentLocation: r, business: o, fulfilling: m, por: c } = u, { name: d, address: n, regNo: l, legalName: x } = r.doc.profile, v = {
871
+ name: d,
872
+ legalName: x,
873
+ registrationNumber: l,
874
+ line1: n == null ? void 0 : n.line1,
875
+ line2: n == null ? void 0 : n.line2,
876
+ postcode: n == null ? void 0 : n.postcode,
877
+ city: n == null ? void 0 : n.city,
878
+ state: n == null ? void 0 : n.state,
879
+ country: n == null ? void 0 : n.country
880
+ }, D = {
881
+ name: t.supplier.name,
882
+ phoneNumber: t.supplier.phoneNumber,
883
+ registrationNumber: t.supplier.registrationNumber,
884
+ line1: (ie = t.supplier.address) == null ? void 0 : ie.line1,
885
+ line2: (ke = t.supplier.address) == null ? void 0 : ke.line2,
886
+ postcode: (Ae = t.supplier.address) == null ? void 0 : Ae.postcode,
887
+ city: (Q = t.supplier.address) == null ? void 0 : Q.city,
888
+ state: (ye = t.supplier.address) == null ? void 0 : ye.state,
889
+ country: (P = t.supplier.address) == null ? void 0 : P.country
890
+ }, R = ds(t), T = t.items.map((w) => {
891
+ const { sku: $, measurement: N } = w, U = $e(
892
+ cs(w.sku, t.deliveryOrder || []),
893
+ !1
894
+ ), Z = R(w);
895
+ return {
896
+ code: $.code,
897
+ description: $.name,
898
+ quantity: $e(w.quantity, !1),
899
+ unit: (N == null ? void 0 : N.abbrev) || $.unit.abbrev,
900
+ received: U,
901
+ cost: Z ? `${Z.currency} ${Be.toFormatString({
902
+ value: Z
903
+ })}` : void 0
904
+ };
905
+ }), _ = t.deliveryOrder.map((w) => ({
906
+ createdAt: Pt(new Date(w.createdAt)),
907
+ ref: w.deliveryOrderNumber,
908
+ remark: w.remark || "",
909
+ items: w.received.map(($) => {
910
+ var N;
911
+ return {
912
+ code: $.sku.code,
913
+ description: $.sku.name,
914
+ quantity: $e($.amount),
915
+ unit: ((N = $.measurement) == null ? void 0 : N.abbrev) || $.sku.unit.abbrev
916
+ };
917
+ })
918
+ })), M = [
919
+ // Production
920
+ "67ca5d2c80bd0e001c5bf5bc",
921
+ // Dev
922
+ "6880b36a3054c5001db19218"
923
+ ];
924
+ let E = "Inventory Receive Note";
925
+ if (t.supplier.internal ? (E = "Inventory Transfer Note", M.includes((o == null ? void 0 : o._id) || "") && (E = "Stock Request")) : E = "Purchase Order", c) {
926
+ const w = c.from.dbName;
927
+ r.dbName === w || (E = "Inventory Receive Note");
928
+ }
929
+ const se = {
930
+ title: E,
931
+ businessName: o == null ? void 0 : o.name,
932
+ logo: o == null ? void 0 : o.thumbnail,
933
+ orderNumber: t.seqNumber.toString(),
934
+ createdAt: lt(t._id),
935
+ ref: t.ref || "",
936
+ remark: t.remark || "",
937
+ buyer: v,
938
+ supplier: D,
939
+ items: T,
940
+ status: t.status,
941
+ deliveryOrders: _
942
+ }, J = new URL(window.location.href), ne = m && (t.deliveryFullfillment || []).length > 0 ? "receive-request/delivery-print-preview" : "receive-request/print-preview";
943
+ J.pathname = J.hostname.includes("portal.feedme") ? `/inventory/${ne}` : `/${ne}`;
944
+ const be = zs.compressToEncodedURIComponent(JSON.stringify(se));
945
+ J.searchParams.append("data", be), window.open(J.href, "_blank", "noreferrer");
946
+ }
947
+ const Ke = {
948
+ submitRequest: {
949
+ translationKey: "inventory.transfer.receiveRequest.actions.submitRequest",
950
+ color: "text-fm-color-typo-primary",
951
+ value: z.enum.submitRequest
952
+ },
953
+ confirmDraft: {
954
+ translationKey: "inventory.transfer.receiveRequest.actions.confirmDraft",
955
+ color: "text-fm-color-typo-primary",
956
+ value: z.enum.confirmDraft
957
+ },
958
+ cancelDraft: {
959
+ translationKey: "inventory.transfer.receiveRequest.actions.cancelDraft",
960
+ color: "text-fm-color-typo-error",
961
+ value: z.enum.cancelDraft
962
+ },
963
+ approveRequest: {
964
+ translationKey: "inventory.transfer.receiveRequest.actions.approveRequest",
965
+ color: "text-fm-color-typo-primary",
966
+ value: z.enum.approveRequest
967
+ },
968
+ rejectRequest: {
969
+ translationKey: "inventory.transfer.receiveRequest.actions.rejectRequest",
970
+ color: "text-fm-color-typo-error",
971
+ value: z.enum.rejectRequest
972
+ },
973
+ processRequest: {
974
+ translationKey: "inventory.transfer.receiveRequest.actions.processRequest",
975
+ color: "text-fm-color-typo-primary",
976
+ value: z.enum.processRequest
977
+ },
978
+ receiveStock: {
979
+ translationKey: "inventory.transfer.receiveRequest.actions.receiveStock",
980
+ color: "text-fm-color-typo-primary",
981
+ value: z.enum.receiveStock
982
+ },
983
+ completeReceive: {
984
+ translationKey: "inventory.transfer.receiveRequest.actions.completeReceive",
985
+ color: "text-fm-color-typo-primary",
986
+ value: z.enum.completeReceive
987
+ },
988
+ closeRequest: {
989
+ translationKey: "inventory.transfer.receiveRequest.actions.closeRequest",
990
+ color: "system-error-300",
991
+ value: z.enum.closeRequest
992
+ },
993
+ approveDraft: {
994
+ translationKey: "inventory.transfer.receiveRequest.actions.approveDraft",
995
+ color: "text-fm-color-typo-primary",
996
+ value: z.enum.approveDraft
997
+ },
998
+ rejectDraft: {
999
+ translationKey: "inventory.transfer.receiveRequest.actions.rejectDraft",
1000
+ color: "text-fm-color-typo-error",
1001
+ value: z.enum.rejectDraft
1002
+ },
1003
+ returnStock: {
1004
+ translationKey: "inventory.transfer.receiveRequest.actions.returnStock",
1005
+ color: "text-fm-color-typo-primary",
1006
+ value: z.enum.returnStock
1007
+ }
1008
+ };
1009
+ function gs() {
1010
+ const u = Ye();
1011
+ return {
1012
+ ableToMarkReceived(t) {
1013
+ if (!t || t.status !== Se.enum.RECEIVING || u.useOperatePurchaseOrderV2) return !1;
1014
+ const o = ze().currentLocationDBName;
1015
+ return `${t.supplier.internal}_${t.supplier._id}` !== o;
1016
+ },
1017
+ ableToMarkApproved(t) {
1018
+ return !(!t || (t == null ? void 0 : t.status) !== Se.enum.REQUESTING);
1019
+ },
1020
+ ableToCreateFulfillment(t, r) {
1021
+ var c, d;
1022
+ if (!u.acceptRequireFulfillment || !t || !r || t.status !== Se.enum.PROCESSING || !r.processedAt)
1023
+ return !1;
1024
+ const o = (c = r == null ? void 0 : r.from) == null ? void 0 : c.dbName, m = (d = r == null ? void 0 : r.to) == null ? void 0 : d.dbName;
1025
+ return !(o.startsWith("restaurant_") && m.startsWith("restaurant_"));
1026
+ }
1027
+ };
1028
+ }
1029
+ function _s() {
1030
+ const u = K(() => [
1031
+ {
1032
+ action: Qt.Action.manage,
1033
+ subject: Qt.Subject.Business.inventory_orderDraftApproval
1034
+ }
1035
+ ]), { hasPermission: t } = ir(u);
1036
+ return {
1037
+ hasOrderDraftPermission: Ds(t)
1038
+ };
1039
+ }
1040
+ function ts(u) {
1041
+ return u != null && u.id ? `${u.refNo ?? "N/A"} (${u.id})` : "N/A";
1042
+ }
1043
+ function xi(u, t, r, o) {
1044
+ const m = ze(), c = _t(), d = bt(), n = gs(), { t: l } = ht(), x = Je(), { hasOrderDraftPermission: v } = _s(), D = Ye(), R = K(
1045
+ () => D.enablePrintTemplate ? [qe[Ne.PrintCustom]] : []
1046
+ ), T = K(
1047
+ () => D.enablePurchaseOrderEmail ? [qe[Ne.Email]] : []
1048
+ );
1049
+ function _(Q) {
1050
+ const ye = M(Q), P = o == null ? void 0 : o.excludeRowActions;
1051
+ return P != null && P.length ? ye.filter(
1052
+ (w) => !P.includes(w.value)
1053
+ ) : ye;
1054
+ }
1055
+ function M(Q) {
1056
+ switch (Q.status) {
1057
+ case "DRAFT":
1058
+ return [
1059
+ qe[Ne.Update],
1060
+ qe[Ne.Details],
1061
+ Q.supplier.internal === "restaurant" || Q.supplier.internal === "warehouse" ? Ke[z.enum.submitRequest] : Ke[z.enum.confirmDraft],
1062
+ Ke[z.enum.cancelDraft]
1063
+ ];
1064
+ case "RECEIVING":
1065
+ return [
1066
+ ...n.ableToMarkReceived(Q) ? [Ke[z.enum.completeReceive]] : [],
1067
+ qe[Ne.Details],
1068
+ qe[Ne.Print],
1069
+ ...R.value,
1070
+ ...T.value
1071
+ ];
1072
+ case "PENDING_APPROVAL": {
1073
+ const P = [qe[Ne.Details]];
1074
+ return v.value && P.push(
1075
+ qe[Ne.Update],
1076
+ Ke[z.enum.approveDraft],
1077
+ Ke[z.enum.rejectDraft]
1078
+ ), P;
1079
+ }
1080
+ case "REQUESTING":
1081
+ return u === "receive/request" ? [
1082
+ qe[Ne.Details],
1083
+ qe[Ne.Print],
1084
+ ...R.value
1085
+ ] : [
1086
+ Ke[z.enum.approveRequest],
1087
+ Ke[z.enum.rejectRequest],
1088
+ qe[Ne.Details]
1089
+ // DefaultRowActions[RowActionEnum.Print]
1090
+ ];
1091
+ case "PROCESSING":
1092
+ return [
1093
+ qe[Ne.Details],
1094
+ qe[Ne.Print],
1095
+ ...R.value
1096
+ ];
1097
+ case "COMPLETE":
1098
+ case "CANCEL":
1099
+ default:
1100
+ return [
1101
+ qe[Ne.Details],
1102
+ qe[Ne.Print],
1103
+ ...R.value
1104
+ ];
1105
+ }
1106
+ }
1107
+ function E(Q) {
1108
+ return Object.values(z.enum).includes(Q);
1109
+ }
1110
+ async function te(Q, ye, P) {
1111
+ var N, U, Z, ue, H, de, xe, F, h;
1112
+ let w;
1113
+ try {
1114
+ w = t.resolvePO ? await t.resolvePO(ye) : ye;
1115
+ } catch (g) {
1116
+ console.error("Failed to load full purchase order for action", g), x.open({
1117
+ title: l("inventory.common.somethingWentWrong"),
1118
+ message: (g == null ? void 0 : g.message) || l("inventory.common.tryAgain"),
1119
+ type: "error"
1120
+ });
1121
+ return;
1122
+ }
1123
+ const $ = wt(w);
1124
+ if (!(o != null && o.onCustomAction && await o.onCustomAction(Q, $))) {
1125
+ if (Q === Ne.Print || Q === Ne.PrintCustom) {
1126
+ let g = $;
1127
+ if (g.items == null && (o != null && o.fetchFullPo)) {
1128
+ const s = await o.fetchFullPo($);
1129
+ if (s == null) return;
1130
+ g = wt(s);
1131
+ }
1132
+ const B = (N = o == null ? void 0 : o.resolveLocation) == null ? void 0 : N.call(o, $), X = { ...(P == null ? void 0 : P.toInventoryLocation) ?? B ?? m.currentLocation };
1133
+ if (X.type === "restaurant") {
1134
+ const s = m.locationRestaurantFromCore(X.doc._id);
1135
+ s !== null && (X.doc = s);
1136
+ }
1137
+ ((U = P == null ? void 0 : P.netSuite) != null && U.refNo || (Z = g.netSuite) != null && Z.refNo) && (g.ref = [((ue = P == null ? void 0 : P.netSuite) == null ? void 0 : ue.refNo) || ((H = g.netSuite) == null ? void 0 : H.refNo)].filter((s) => s).join(" "));
1138
+ const re = P ?? ((de = o == null ? void 0 : o.resolvePurchaseRequest) == null ? void 0 : de.call(o, $)), ve = {
1139
+ po: g,
1140
+ currentLocation: X,
1141
+ business: d.currentBusiness.value,
1142
+ fulfilling: u === "approval",
1143
+ por: re
1144
+ };
1145
+ if (Q === Ne.PrintCustom) {
1146
+ const s = ms(ve);
1147
+ s && (ie.value = s.html, ke.value = s.templateName, Ae.value = s.isDefault, be.value = !0);
1148
+ } else
1149
+ vr(ve);
1150
+ return;
1151
+ }
1152
+ if (Q === Ne.Details) {
1153
+ t.promptShowTransferDetails($, P);
1154
+ return;
1155
+ }
1156
+ if (Q === Ne.Update) {
1157
+ (xe = t.promptUpdateTransferDialog) == null || xe.call(t, $);
1158
+ return;
1159
+ }
1160
+ if (Q === Ne.Email) {
1161
+ (F = t.promptEmailDialog) == null || F.call(t, $);
1162
+ return;
1163
+ }
1164
+ if (E(Q)) {
1165
+ t.submitAction(w, Q, (h = P == null ? void 0 : P.to) == null ? void 0 : h.dbName);
1166
+ return;
1167
+ }
1168
+ }
1169
+ }
1170
+ function se() {
1171
+ var ye;
1172
+ const Q = [
1173
+ {
1174
+ accessorKey: "seqNumber",
1175
+ header: () => l("inventory.transfer.table.seqNo"),
1176
+ enableSorting: !0,
1177
+ size: 80,
1178
+ sortUndefined: "last"
1179
+ },
1180
+ {
1181
+ accessorKey: "_id",
1182
+ header: () => l("inventory.transfer.table.createdAt"),
1183
+ cell(P) {
1184
+ return lt(`${P.getValue()}`);
1185
+ },
1186
+ enableSorting: !0
1187
+ },
1188
+ {
1189
+ accessorKey: "supplier.name",
1190
+ header: () => l("inventory.transfer.table.transferFrom"),
1191
+ enableSorting: !0,
1192
+ size: 200
1193
+ },
1194
+ {
1195
+ // Bulk-view summary rows carry itemCount instead of the items array
1196
+ id: "noOfItems",
1197
+ accessorFn: (P) => {
1198
+ var w;
1199
+ return P.itemCount ?? ((w = P.items) == null ? void 0 : w.length) ?? 0;
1200
+ },
1201
+ header: () => l("inventory.transfer.table.noOfItems"),
1202
+ cell: (P) => {
1203
+ const w = P.row.original.version || "1", $ = P.getValue();
1204
+ return ae("div", { class: "flex items-center gap-2" }, [
1205
+ $,
1206
+ w !== "1" ? ae(
1207
+ "div",
1208
+ { class: "py-3" },
1209
+ ae(
1210
+ tt,
1211
+ {},
1212
+ () => ae(
1213
+ "div",
1214
+ {
1215
+ class: ["fm-status-badge", "fm-status-badge-draft"].join(" ")
1216
+ },
1217
+ `v${w}`
1218
+ )
1219
+ )
1220
+ ) : null
1221
+ ]);
1222
+ },
1223
+ enableSorting: !1,
1224
+ meta: {
1225
+ width: "10rem"
1226
+ }
1227
+ },
1228
+ {
1229
+ accessorKey: "ref",
1230
+ header: () => l("inventory.transfer.table.reference"),
1231
+ enableSorting: !1,
1232
+ size: "auto"
1233
+ },
1234
+ ...(ye = d.sessionUser.value) != null && ye.role.isAdmin ? [
1235
+ {
1236
+ id: "statusForAdmin",
1237
+ header: () => ae(tt, {}, () => `${l("inventory.transfer.table.status")}`),
1238
+ cell(P) {
1239
+ return P.row.original.status;
1240
+ },
1241
+ enableSorting: !0,
1242
+ size: 200
1243
+ }
1244
+ ] : [],
1245
+ {
1246
+ accessorKey: "status",
1247
+ header: () => l("inventory.transfer.table.status"),
1248
+ cell(P) {
1249
+ const w = P.getValue(), $ = P.row.original, { partial: N, over: U } = $.items == null ? { partial: !!$.partialReceived, over: !!$.overReceived } : $t(vt($)), Z = Ct(w ?? "", N, U);
1250
+ let ue = l(`inventory.transfer.status.${Z}`), H = `${w ?? ""}`.toLocaleLowerCase("en-us");
1251
+ Z === Se.enum.CLOSE && (ue = `${l(`inventory.transfer.status.${Se.enum.COMPLETE}`)}`), Z === "PARTIAL_RECEIVED" && H === Se.enum.PROCESSING.toLocaleLowerCase("en-us") && (H = Se.enum.RECEIVING.toLocaleLowerCase("en-us"));
1252
+ let de = null;
1253
+ const xe = r.value.find((F) => F.ref === P.row.original._id);
1254
+ if (xe != null && xe.milestones && xe.milestones.length > 0) {
1255
+ const F = xe.milestones[xe.milestones.length - 1];
1256
+ if (F.estimatedTime) {
1257
+ const h = new Date(F.estimatedTime), g = h.getDate().toString().padStart(2, "0");
1258
+ de = `${h.toLocaleString("en-US", { month: "short" })} ${g}`;
1259
+ }
1260
+ }
1261
+ return ae(
1262
+ "div",
1263
+ {
1264
+ class: "flex"
1265
+ },
1266
+ [
1267
+ ae(
1268
+ "div",
1269
+ { class: "flex items-center" },
1270
+ ae(
1271
+ "div",
1272
+ {
1273
+ class: [
1274
+ "fm-status-badge",
1275
+ `fm-status-badge-${H}`,
1276
+ U && "fm-status-badge-error"
1277
+ ].filter(Boolean).join(" ")
1278
+ },
1279
+ `${ue}`
1280
+ )
1281
+ ),
1282
+ ...de ? [
1283
+ ae(
1284
+ "div",
1285
+ {
1286
+ class: "flex items-center gap-1 ml-2"
1287
+ },
1288
+ [
1289
+ ae(pt.FmIcon, {
1290
+ name: "local_shipping",
1291
+ size: "md",
1292
+ color: "neutral-gray-400"
1293
+ }),
1294
+ ae(
1295
+ "span",
1296
+ { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" },
1297
+ de
1298
+ )
1299
+ ]
1300
+ )
1301
+ ] : []
1302
+ ]
1303
+ );
1304
+ },
1305
+ enableSorting: !0,
1306
+ size: 150
1307
+ },
1308
+ {
1309
+ id: "action",
1310
+ cell(P) {
1311
+ var N;
1312
+ const w = P.row.original, $ = [
1313
+ ..._(w),
1314
+ ...((N = o == null ? void 0 : o.appendRowActions) == null ? void 0 : N.call(o, w)) ?? []
1315
+ ];
1316
+ return Gt($, (U) => te(U, w));
1317
+ },
1318
+ enableSorting: !1,
1319
+ size: 40,
1320
+ meta: {
1321
+ cellClass: "",
1322
+ headerClass: ""
1323
+ }
1324
+ }
1325
+ ];
1326
+ if (c.isEnabled) {
1327
+ const P = [
1328
+ {
1329
+ id: "netsuiteTransferOrder",
1330
+ accessorFn: (w) => {
1331
+ var $;
1332
+ return ($ = w.netSuite) != null && $.id ? `${w.netSuite.refNo ?? "N/A"} (${w.netSuite.id})` : "N/A";
1333
+ },
1334
+ header: () => "NetSuite Order (ID)",
1335
+ cell(w) {
1336
+ var N;
1337
+ const $ = w.row.original;
1338
+ return (N = $.netSuite) != null && N.id ? `${$.netSuite.refNo ?? "N/A"} (${$.netSuite.id})` : "N/A";
1339
+ },
1340
+ enableSorting: !1,
1341
+ size: 200,
1342
+ meta: {
1343
+ cellClass: "",
1344
+ headerClass: ""
1345
+ }
1346
+ },
1347
+ {
1348
+ id: "netsuiteTransactionNumber",
1349
+ accessorFn: (w) => {
1350
+ var $, N;
1351
+ return ((N = ($ = w.netSuite) == null ? void 0 : $.additionalInfo) == null ? void 0 : N.transactionnumber) ?? "N/A";
1352
+ },
1353
+ header: () => "NetSuite Transaction No.",
1354
+ cell(w) {
1355
+ var N, U;
1356
+ return ((U = (N = w.row.original.netSuite) == null ? void 0 : N.additionalInfo) == null ? void 0 : U.transactionnumber) ?? "N/A";
1357
+ },
1358
+ enableSorting: !1,
1359
+ size: 200,
1360
+ meta: {
1361
+ cellClass: "",
1362
+ headerClass: ""
1363
+ }
1364
+ },
1365
+ {
1366
+ id: "netsuiteRefNo",
1367
+ accessorFn: (w) => {
1368
+ var N, U;
1369
+ const $ = (N = w.deliveryOrder) == null ? void 0 : N.filter((Z) => {
1370
+ var ue;
1371
+ return (ue = Z.netSuite) == null ? void 0 : ue.id;
1372
+ });
1373
+ return $ != null && $.length ? $.map((Z) => {
1374
+ var ue, H;
1375
+ return `${((ue = Z.netSuite) == null ? void 0 : ue.refNo) ?? "N/A"} (${((H = Z.netSuite) == null ? void 0 : H.id) ?? "-"})`;
1376
+ }).join(", ") : (U = w.netSuite) != null && U.id ? `${w.netSuite.refNo ?? "N/A"} (${w.netSuite.id})` : "N/A";
1377
+ },
1378
+ header: () => "Netsuite ref no.",
1379
+ cell(w) {
1380
+ var U, Z;
1381
+ const $ = w.row.original, N = (U = $.deliveryOrder) == null ? void 0 : U.filter((ue) => {
1382
+ var H;
1383
+ return (H = ue.netSuite) == null ? void 0 : H.id;
1384
+ });
1385
+ return N != null && N.length ? N.map((ue) => {
1386
+ var H, de;
1387
+ return `${((H = ue.netSuite) == null ? void 0 : H.refNo) ?? "N/A"} (${((de = ue.netSuite) == null ? void 0 : de.id) ?? "-"})`;
1388
+ }).join(", ") : (Z = $.netSuite) != null && Z.id ? `${$.netSuite.refNo ?? "N/A"} (${$.netSuite.id})` : "N/A";
1389
+ },
1390
+ enableSorting: !1,
1391
+ size: 200,
1392
+ meta: {
1393
+ cellClass: "",
1394
+ headerClass: ""
1395
+ }
1396
+ }
1397
+ ];
1398
+ Q.splice(Q.length - 1, 0, ...P);
1399
+ }
1400
+ return Q;
1401
+ }
1402
+ function J() {
1403
+ var ye;
1404
+ const Q = [
1405
+ {
1406
+ accessorKey: "purchaseOrder.seqNumber",
1407
+ header: () => l("inventory.transfer.table.seqNo"),
1408
+ enableSorting: !0,
1409
+ size: 80,
1410
+ sortUndefined: "last"
1411
+ },
1412
+ {
1413
+ accessorKey: "purchaseOrder._id",
1414
+ header: () => l("inventory.transfer.table.createdAt"),
1415
+ cell(P) {
1416
+ return lt(`${P.getValue()}`);
1417
+ },
1418
+ enableSorting: !0
1419
+ },
1420
+ {
1421
+ accessorKey: "to.name",
1422
+ header: () => l("inventory.transfer.table.transferTo"),
1423
+ enableSorting: !1,
1424
+ size: 200
1425
+ },
1426
+ {
1427
+ accessorKey: "purchaseOrder.items.length",
1428
+ header: () => l("inventory.transfer.table.noOfItems"),
1429
+ enableSorting: !1
1430
+ },
1431
+ {
1432
+ accessorKey: "purchaseOrder.ref",
1433
+ header: () => l("inventory.transfer.table.reference"),
1434
+ enableSorting: !1,
1435
+ size: "auto"
1436
+ },
1437
+ ...(ye = d.sessionUser.value) != null && ye.role.isAdmin ? [
1438
+ {
1439
+ id: "statusForAdmin",
1440
+ header: () => ae(tt, {}, () => `${l("inventory.transfer.table.status")}`),
1441
+ cell(P) {
1442
+ return P.row.original.status;
1443
+ },
1444
+ enableSorting: !0,
1445
+ size: 200
1446
+ }
1447
+ ] : [],
1448
+ {
1449
+ accessorKey: "purchaseOrder.status",
1450
+ header: () => l("inventory.transfer.table.status"),
1451
+ cell(P) {
1452
+ const w = P.row.original, $ = P.getValue();
1453
+ if (!w.purchaseOrder)
1454
+ return ae(pt.FmChip, {
1455
+ label: "N/A",
1456
+ compact: !0
1457
+ });
1458
+ const N = vt(w.purchaseOrder), { partial: U, over: Z } = $t(N), ue = Ct($ ?? "", U, Z);
1459
+ let H = l(`inventory.transfer.status.${ue}`), de = `${$ ?? ""}`.toLocaleLowerCase("en-us");
1460
+ return ue === Se.enum.CLOSE && (H = `${l(`inventory.transfer.status.${Se.enum.COMPLETE}`)}`), ue === "PARTIAL_RECEIVED" && de === Se.enum.PROCESSING.toLocaleLowerCase("en-us") && (de = Se.enum.RECEIVING.toLocaleLowerCase("en-us")), w.rejectedAt && (H = l("inventory.transfer.status.REJECT"), de = Se.enum.REJECT.toLocaleLowerCase("en-us")), ae(
1461
+ "div",
1462
+ {
1463
+ class: "flex"
1464
+ },
1465
+ ae(
1466
+ "div",
1467
+ {
1468
+ class: [
1469
+ "fm-status-badge",
1470
+ `fm-status-badge-${de}`,
1471
+ Z && "fm-status-badge-error"
1472
+ ].filter(Boolean).join(" ")
1473
+ },
1474
+ `${H}`
1475
+ )
1476
+ );
1477
+ },
1478
+ enableSorting: !0
1479
+ },
1480
+ {
1481
+ id: "action",
1482
+ cell(P) {
1483
+ const w = P.row.original, N = (w.purchaseOrder ? _(w.purchaseOrder) : []).map((U) => U.value === Ne.Print ? {
1484
+ ...U,
1485
+ translationKey: "inventory.transfer.receiveRequest.details.printDeliveryOrder"
1486
+ } : U);
1487
+ return Gt(
1488
+ N,
1489
+ (U) => w.purchaseOrder ? te(U, w.purchaseOrder, w) : void 0
1490
+ );
1491
+ },
1492
+ enableSorting: !1,
1493
+ size: 40,
1494
+ meta: {
1495
+ cellClass: "",
1496
+ headerClass: ""
1497
+ }
1498
+ }
1499
+ ];
1500
+ if (c.isEnabled) {
1501
+ const P = [
1502
+ {
1503
+ id: "netsuiteTransferOrder",
1504
+ // The row is the REQUEST. Its own netSuite block describes the request's record,
1505
+ // not the transfer order — that lives on the order embedded under purchaseOrder,
1506
+ // which is why this column read N/A on the warehouse's Transfer out while the
1507
+ // outlet's own view showed the very same order's ZPS number. Prefer the order,
1508
+ // and keep the request's block as a fallback so rows that render today still do.
1509
+ accessorFn: (w) => {
1510
+ var $;
1511
+ return ts((($ = w.purchaseOrder) == null ? void 0 : $.netSuite) ?? w.netSuite);
1512
+ },
1513
+ header: () => "NetSuite Order (ID)",
1514
+ cell(w) {
1515
+ var N;
1516
+ const $ = w.row.original;
1517
+ return ts(((N = $.purchaseOrder) == null ? void 0 : N.netSuite) ?? $.netSuite);
1518
+ },
1519
+ enableSorting: !1,
1520
+ size: 200,
1521
+ meta: {
1522
+ cellClass: "",
1523
+ headerClass: ""
1524
+ }
1525
+ },
1526
+ {
1527
+ id: "netsuiteTransactionNumber",
1528
+ accessorFn: (w) => {
1529
+ var $, N, U;
1530
+ return ((U = (N = (($ = w.purchaseOrder) == null ? void 0 : $.netSuite) ?? w.netSuite) == null ? void 0 : N.additionalInfo) == null ? void 0 : U.transactionnumber) ?? "N/A";
1531
+ },
1532
+ header: () => "NetSuite Transaction No.",
1533
+ cell(w) {
1534
+ var N, U, Z;
1535
+ const $ = w.row.original;
1536
+ return ((Z = (U = ((N = $.purchaseOrder) == null ? void 0 : N.netSuite) ?? $.netSuite) == null ? void 0 : U.additionalInfo) == null ? void 0 : Z.transactionnumber) ?? "N/A";
1537
+ },
1538
+ enableSorting: !1,
1539
+ size: 200,
1540
+ meta: {
1541
+ cellClass: "",
1542
+ headerClass: ""
1543
+ }
1544
+ },
1545
+ {
1546
+ id: "netsuiteRefNo",
1547
+ accessorFn: (w) => {
1548
+ var N, U, Z;
1549
+ const $ = (U = (N = w.purchaseOrder) == null ? void 0 : N.deliveryOrder) == null ? void 0 : U.filter((ue) => {
1550
+ var H;
1551
+ return (H = ue.netSuite) == null ? void 0 : H.id;
1552
+ });
1553
+ return $ != null && $.length ? $.map((ue) => {
1554
+ var H, de;
1555
+ return `${((H = ue.netSuite) == null ? void 0 : H.refNo) ?? "N/A"} (${((de = ue.netSuite) == null ? void 0 : de.id) ?? "-"})`;
1556
+ }).join(", ") : (Z = w.netSuite) != null && Z.id ? `${w.netSuite.refNo ?? "N/A"} (${w.netSuite.id})` : "N/A";
1557
+ },
1558
+ header: () => "Netsuite ref no.",
1559
+ cell(w) {
1560
+ var U, Z, ue;
1561
+ const $ = w.row.original, N = (Z = (U = $.purchaseOrder) == null ? void 0 : U.deliveryOrder) == null ? void 0 : Z.filter((H) => {
1562
+ var de;
1563
+ return (de = H.netSuite) == null ? void 0 : de.id;
1564
+ });
1565
+ return N != null && N.length ? N.map((H) => {
1566
+ var de, xe;
1567
+ return `${((de = H.netSuite) == null ? void 0 : de.refNo) ?? "N/A"} (${((xe = H.netSuite) == null ? void 0 : xe.id) ?? "-"})`;
1568
+ }).join(", ") : (ue = $.netSuite) != null && ue.id ? `${$.netSuite.refNo ?? "N/A"} (${$.netSuite.id})` : "N/A";
1569
+ },
1570
+ enableSorting: !1,
1571
+ size: 200,
1572
+ meta: {
1573
+ cellClass: "",
1574
+ headerClass: ""
1575
+ }
1576
+ }
1577
+ ];
1578
+ Q.splice(Q.length - 2, 0, ...P);
1579
+ }
1580
+ return Q;
1581
+ }
1582
+ const ne = K(() => u === "receive/request" ? se() : J()), be = oe(!1), ie = oe(""), ke = oe(""), Ae = oe(!1);
1583
+ return {
1584
+ columnDefs: ne,
1585
+ showCustomPrintDialog: be,
1586
+ customPrintHtml: ie,
1587
+ customPrintTemplateName: ke,
1588
+ customPrintIsDefault: Ae
1589
+ };
1590
+ }
1591
+ const yr = { class: "flex flex-col gap-4 border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, hr = { class: "flex items-center justify-between" }, br = {
1592
+ key: 0,
1593
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-tertiary"
1594
+ }, gr = { class: "flex justify-between items-start py-1 gap-4" }, _r = { class: "flex-1 min-w-0 flex flex-col gap-2" }, Sr = { class: "flex flex-col gap-2 items-end w-52 shrink-0" }, Or = {
1595
+ key: 0,
1596
+ class: "border-b border-fm-color-stroke-secondary"
1597
+ }, It = /* @__PURE__ */ Ve({
1598
+ __name: "PriceAdjustmentEditor",
1599
+ props: {
1600
+ controller: {},
1601
+ state: {}
1602
+ },
1603
+ setup(u) {
1604
+ const t = u, r = K(() => t.state.adjustments ?? []);
1605
+ function o(l) {
1606
+ return +$e(l.dinero);
1607
+ }
1608
+ function m() {
1609
+ t.controller.addAdjustment();
1610
+ }
1611
+ function c(l, x) {
1612
+ t.controller.updateAdjustment(l, x);
1613
+ }
1614
+ function d(l, x) {
1615
+ t.controller.updateAdjustment(l, null, x);
1616
+ }
1617
+ function n(l) {
1618
+ t.controller.removeAdjustment(l);
1619
+ }
1620
+ return (l, x) => {
1621
+ const v = le("FmButton"), D = le("FmTextField"), R = le("FmStepperField");
1622
+ return i(), y("div", yr, [
1623
+ e("div", hr, [
1624
+ x[0] || (x[0] = e("div", { class: "fm-typo-en-body-lg-600 text-fm-color-typo-secondary" }, "Price adjustments", -1)),
1625
+ q(v, {
1626
+ variant: "tertiary",
1627
+ label: "Add adjustment",
1628
+ "prepend-icon": "add",
1629
+ size: "md",
1630
+ onClick: m
1631
+ })
1632
+ ]),
1633
+ r.value.length === 0 ? (i(), y("div", br, " No price adjustments ")) : V("", !0),
1634
+ (i(!0), y(De, null, Te(r.value, (T, _) => (i(), y("div", {
1635
+ key: T.id
1636
+ }, [
1637
+ e("div", gr, [
1638
+ e("div", _r, [
1639
+ q(D, {
1640
+ "model-value": T.name,
1641
+ "onUpdate:modelValue": (M) => c(T.id, M),
1642
+ label: "Name",
1643
+ placeholder: "e.g. Freight, Discount",
1644
+ size: "md"
1645
+ }, null, 8, ["model-value", "onUpdate:modelValue"])
1646
+ ]),
1647
+ e("div", Sr, [
1648
+ q(R, {
1649
+ "model-value": o(T),
1650
+ "onUpdate:modelValue": (M) => d(T.id, M),
1651
+ label: "Amount (+/-)",
1652
+ step: 0.01,
1653
+ placeholder: "0.00",
1654
+ size: "md",
1655
+ "append-text": b(Ce)()
1656
+ }, null, 8, ["model-value", "onUpdate:modelValue", "append-text"])
1657
+ ]),
1658
+ q(v, {
1659
+ variant: "tertiary",
1660
+ "prepend-icon": "delete",
1661
+ size: "md",
1662
+ class: "mt-6",
1663
+ onClick: (M) => n(T.id)
1664
+ }, null, 8, ["onClick"])
1665
+ ]),
1666
+ _ < r.value.length - 1 ? (i(), y("div", Or)) : V("", !0)
1667
+ ]))), 128))
1668
+ ]);
1669
+ };
1670
+ }
1671
+ });
1672
+ function Tt(u) {
1673
+ const t = dt(
1674
+ Yt({
1675
+ currency: u.currency,
1676
+ adjustments: u.adjustments ?? []
1677
+ })
1678
+ ), r = dt(t.value.state());
1679
+ function o(d) {
1680
+ const n = () => {
1681
+ r.value = d.state();
1682
+ };
1683
+ return d.addListener(n), () => d.removeListener(n);
1684
+ }
1685
+ let m = o(t.value);
1686
+ function c(d) {
1687
+ m(), t.value = Yt({
1688
+ currency: u.currency,
1689
+ adjustments: d ?? []
1690
+ }), m = o(t.value), r.value = t.value.state();
1691
+ }
1692
+ return os(() => m()), { controller: t, state: r, reset: c };
1693
+ }
1694
+ const kr = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, xr = { class: "flex flex-col gap-8" }, wr = { class: "flex w-full justify-end gap-16" }, $r = /* @__PURE__ */ Ve({
1695
+ __name: "FulfillmentForm",
1696
+ props: {
1697
+ purchaseOrder: {},
1698
+ confirm: { type: Function }
1699
+ },
1700
+ emits: ["update:show"],
1701
+ setup(u, { emit: t }) {
1702
+ const r = u, o = Rs({
1703
+ id: "",
1704
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1705
+ items: []
1706
+ }), m = oe(), c = t, d = (l) => l != null && l !== "";
1707
+ ns(() => {
1708
+ r.purchaseOrder && (o.items = r.purchaseOrder.items.map((l) => ({
1709
+ id: l.id,
1710
+ sku: l.sku,
1711
+ measurement: l.measurement,
1712
+ amount: l.quantity ?? { amount: 1, precision: 0 }
1713
+ })));
1714
+ });
1715
+ const n = K(() => o.items.length <= 10);
1716
+ return (l, x) => {
1717
+ const v = le("FmTable"), D = le("FmButton"), R = le("FmForm");
1718
+ return i(), he(R, {
1719
+ ref_key: "formRef",
1720
+ ref: m,
1721
+ class: "bg-white flex flex-col gap-32 rounded-3xl p-24 w-[800px]",
1722
+ onValidationFailed: console.log,
1723
+ onValidationSuccess: x[1] || (x[1] = () => r.confirm(o))
1724
+ }, {
1725
+ default: pe(() => [
1726
+ x[2] || (x[2] = e("div", { class: "fm-typo-en-title-sm-600" }, "Confirm the transfer amount", -1)),
1727
+ e("div", kr, [
1728
+ e("div", xr, [
1729
+ q(v, {
1730
+ "column-defs": [
1731
+ {
1732
+ header: "Code",
1733
+ cell: (T) => {
1734
+ const _ = r.purchaseOrder.items.find((M) => d(T.row.original.id) ? M.id === T.row.original.id : M.sku._id === T.row.original.sku._id);
1735
+ return ae(
1736
+ b(pt).FmTooltip,
1737
+ {
1738
+ content: _.code,
1739
+ placement: "top",
1740
+ variant: "plain",
1741
+ zIndex: 50
1742
+ },
1743
+ ae(
1744
+ "span",
1745
+ {
1746
+ class: "flex-auto line-clamp-2 text-ellipsis break-all"
1747
+ },
1748
+ _.code
1749
+ )
1750
+ );
1751
+ }
1752
+ },
1753
+ {
1754
+ header: "Name",
1755
+ cell: (T) => {
1756
+ const _ = r.purchaseOrder.items.find((M) => d(T.row.original.id) ? M.id === T.row.original.id : M.sku._id === T.row.original.sku._id);
1757
+ return ae(
1758
+ b(pt).FmTooltip,
1759
+ {
1760
+ content: _.name,
1761
+ placement: "top",
1762
+ variant: "plain",
1763
+ zIndex: 50
1764
+ },
1765
+ ae(
1766
+ "span",
1767
+ {
1768
+ class: "flex-auto line-clamp-2 text-ellipsis break-all"
1769
+ },
1770
+ _.name
1771
+ )
1772
+ );
1773
+ }
1774
+ },
1775
+ {
1776
+ header: "Amount",
1777
+ cell: (T) => {
1778
+ const _ = T.row.original, M = r.purchaseOrder.items.find((te) => d(_.id) ? te.id === _.id : te.sku._id === _.sku._id), E = _.amount ?? {
1779
+ amount: 1,
1780
+ precision: 0
1781
+ };
1782
+ return ae(Ys, {
1783
+ style: {
1784
+ flex: "1 1 0%"
1785
+ },
1786
+ modelValue: {
1787
+ amount: E,
1788
+ measurement: _.measurement ?? null
1789
+ },
1790
+ key: d(_.id) ? _.id : _.sku._id,
1791
+ unit: _.sku.unit,
1792
+ "onUpdate:modelValue": (te) => {
1793
+ if (!te) return;
1794
+ const se = o.items.find((J) => d(_.id) ? J.id === _.id : J.sku._id === _.sku._id);
1795
+ se && (se.amount = te.amount);
1796
+ },
1797
+ disableUnit: !0,
1798
+ rules: [
1799
+ b(Js)(
1800
+ +b($e)({ amount: 0, precision: 0 })
1801
+ ),
1802
+ b(Xs)(+b($e)(M.quantity))
1803
+ ],
1804
+ applyDefaultRules: !0
1805
+ });
1806
+ }
1807
+ }
1808
+ ],
1809
+ "row-data": o.items,
1810
+ "hide-footer": n.value
1811
+ }, null, 8, ["column-defs", "row-data", "hide-footer"])
1812
+ ])
1813
+ ]),
1814
+ e("div", wr, [
1815
+ q(D, {
1816
+ class: "px-16",
1817
+ label: "Confirm",
1818
+ size: "md",
1819
+ variant: "primary",
1820
+ type: "submit"
1821
+ }),
1822
+ q(D, {
1823
+ class: "px-16",
1824
+ label: "Cancel",
1825
+ size: "md",
1826
+ variant: "secondary",
1827
+ onClick: x[0] || (x[0] = () => c("update:show", !1))
1828
+ })
1829
+ ])
1830
+ ]),
1831
+ _: 1
1832
+ }, 8, ["onValidationFailed"]);
1833
+ };
1834
+ }
1835
+ });
1836
+ var Nt = /* @__PURE__ */ ((u) => (u.loading = "loading", u.error = "error", u.success = "success", u))(Nt || {});
1837
+ function Cr(u) {
1838
+ const t = oe({
1839
+ state: "loading"
1840
+ /* loading */
1841
+ }), r = async (o) => {
1842
+ const m = o || u;
1843
+ if (!m) {
1844
+ t.value = { state: "error", error: new Error("No promise task provided") };
1845
+ return;
1846
+ }
1847
+ t.value = {
1848
+ state: "loading"
1849
+ /* loading */
1850
+ };
1851
+ try {
1852
+ const c = await m();
1853
+ t.value = { state: "success", data: c };
1854
+ } catch (c) {
1855
+ t.value = { state: "error", error: c };
1856
+ }
1857
+ };
1858
+ return u && r(), { result: t, execute: r };
1859
+ }
1860
+ const nt = {
1861
+ submitRequest: {
1862
+ translationKey: "inventory.transfer.receiveRequest.actions.submitRequest",
1863
+ color: "primary",
1864
+ buttonVariant: Ue.Primary
1865
+ },
1866
+ confirmDraft: {
1867
+ translationKey: "inventory.transfer.receiveRequest.actions.confirmDraft",
1868
+ color: "primary",
1869
+ buttonVariant: Ue.Primary
1870
+ },
1871
+ cancelDraft: {
1872
+ translationKey: "inventory.transfer.receiveRequest.actions.cancelDraft",
1873
+ color: "system-error-300",
1874
+ buttonVariant: Ue.Destructive
1875
+ },
1876
+ approveDraft: {
1877
+ translationKey: "inventory.transfer.receiveRequest.actions.approveDraft",
1878
+ color: "primary",
1879
+ buttonVariant: Ue.Primary
1880
+ },
1881
+ rejectDraft: {
1882
+ translationKey: "inventory.transfer.receiveRequest.actions.rejectDraft",
1883
+ color: "system-error-300",
1884
+ buttonVariant: Ue.Destructive
1885
+ },
1886
+ approveRequest: {
1887
+ translationKey: "inventory.transfer.receiveRequest.actions.approveRequest",
1888
+ color: "primary",
1889
+ buttonVariant: Ue.Primary
1890
+ },
1891
+ processRequest: {
1892
+ translationKey: "inventory.transfer.receiveRequest.actions.processRequest",
1893
+ color: "primary",
1894
+ buttonVariant: Ue.Primary
1895
+ },
1896
+ receiveStock: {
1897
+ translationKey: "inventory.transfer.receiveRequest.actions.receiveStock",
1898
+ color: "primary",
1899
+ buttonVariant: Ue.Primary,
1900
+ available: !1
1901
+ },
1902
+ completeReceive: {
1903
+ translationKey: "inventory.transfer.receiveRequest.actions.completeReceive",
1904
+ color: "primary",
1905
+ buttonVariant: Ue.Plain
1906
+ },
1907
+ rejectRequest: {
1908
+ translationKey: "inventory.transfer.receiveRequest.actions.rejectRequest",
1909
+ color: "system-error-300",
1910
+ buttonVariant: Ue.Destructive
1911
+ },
1912
+ closeRequest: {
1913
+ translationKey: "inventory.transfer.receiveRequest.actions.closeRequest",
1914
+ color: "system-error-300",
1915
+ buttonVariant: Ue.Destructive,
1916
+ available: !1
1917
+ },
1918
+ returnStock: {
1919
+ translationKey: "inventory.transfer.receiveRequest.actions.returnStock",
1920
+ color: "primary",
1921
+ buttonVariant: Ue.Primary,
1922
+ available: !1
1923
+ }
1924
+ }, Ar = { class: "flex flex-row-reverse" }, Nr = /* @__PURE__ */ Ve({
1925
+ __name: "NetSuiteSync",
1926
+ props: {
1927
+ poRequest: {},
1928
+ purchaseOrder: {},
1929
+ isTransferBetweenOutlets: { type: Boolean },
1930
+ scope: {}
1931
+ },
1932
+ setup(u) {
1933
+ const t = u, r = _t(), o = Je(), m = gt(), c = oe(!1);
1934
+ K(() => {
1935
+ var v, D, R, T;
1936
+ let n = !0;
1937
+ r.isEnabled || (n = !1);
1938
+ const l = t.purchaseOrder, x = t.poRequest;
1939
+ return l && ((v = l == null ? void 0 : l.supplier) != null && v.internal ? (!x && l.status == Se.enum.DRAFT && (n = !1), x && !((D = x == null ? void 0 : x.netSuite) != null && D.id) && (n = !1), t.isTransferBetweenOutlets && (n = !1)) : ((l == null ? void 0 : l.status) !== Se.enum.REQUESTING && l.supplier.internal && (n = !1), !x && !((R = l == null ? void 0 : l.netSuite) != null && R.id) && (n = !1), !x && ((T = l == null ? void 0 : l.netSuite) != null && T.id) && (l == null ? void 0 : l.status) == Se.enum.REQUESTING && (n = !1))), n;
1940
+ });
1941
+ async function d() {
1942
+ c.value || m.open({
1943
+ title: "Sync with NetSuite",
1944
+ contentComponent: ae("div", [
1945
+ ae("p", "Are you sure you want to sync now?"),
1946
+ ae("br"),
1947
+ ae(
1948
+ "p",
1949
+ { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" },
1950
+ "Please wait a moment before syncing manually to avoid unnecessary actions."
1951
+ )
1952
+ ]),
1953
+ primaryActions: {
1954
+ text: "Sync",
1955
+ close: !0,
1956
+ variant: "destructive"
1957
+ },
1958
+ secondaryActions: { text: "Not now", close: !0 }
1959
+ }).onPrimary(async () => {
1960
+ var n, l, x, v, D, R, T;
1961
+ try {
1962
+ c.value = !0;
1963
+ const _ = ((n = t.purchaseOrder) == null ? void 0 : n._id) || ((l = t.poRequest) == null ? void 0 : l.purchaseOrderId) || "", M = (x = t.poRequest) == null ? void 0 : x.to.dbName;
1964
+ await r.syncPurchaseOrder({
1965
+ purchaseOrderId: _,
1966
+ locationId: t.scope === "approval" ? M : void 0,
1967
+ netsuiteId: ((D = (v = t.purchaseOrder) == null ? void 0 : v.netSuite) == null ? void 0 : D.id) || ((T = (R = t.poRequest) == null ? void 0 : R.netSuite) == null ? void 0 : T.id)
1968
+ }), o.open({
1969
+ title: "Sync with NetSuite",
1970
+ message: "Requested to sync with NetSuite. Please wait a moment.",
1971
+ type: "success"
1972
+ }), await new Promise((E) => setTimeout(E, 5e3)), c.value = !1;
1973
+ } catch (_) {
1974
+ console.log("Failed to sync with NetSuite", _), o.open({
1975
+ title: "Error",
1976
+ message: "Failed to sync with NetSuite",
1977
+ type: "error"
1978
+ }), c.value = !1;
1979
+ }
1980
+ });
1981
+ }
1982
+ return (n, l) => {
1983
+ const x = le("FmButton");
1984
+ return i(), y("div", Ar, [
1985
+ q(x, {
1986
+ "prepend-icon": "sync",
1987
+ variant: "secondary",
1988
+ label: "Sync",
1989
+ loading: c.value,
1990
+ onClick: d,
1991
+ "text-color": "primary",
1992
+ "bg-color": "transparent",
1993
+ "border-color": "primary"
1994
+ }, null, 8, ["loading"])
1995
+ ]);
1996
+ };
1997
+ }
1998
+ }), Dr = {
1999
+ key: 0,
2000
+ class: "flex flex-col gap-8"
2001
+ }, Rr = { class: "flex flex-col gap-4" }, Pr = { class: "fm-typo-en-body-lg-600" }, Fr = {
2002
+ key: 0,
2003
+ class: "flex flex-col gap-4"
2004
+ }, Ir = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Tr = { class: "fm-typo-en-body-lg-600" }, Er = { key: 0 }, qr = { key: 1 }, Vr = {
2005
+ key: 1,
2006
+ class: "flex flex-col gap-4"
2007
+ }, Lr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, jr = { class: "fm-typo-en-body-lg-600" }, Ur = { key: 0 }, Mr = { key: 1 }, Br = {
2008
+ key: 2,
2009
+ class: "flex flex-col gap-4"
2010
+ }, zr = { class: "fm-typo-en-body-lg-600" }, Kr = {
2011
+ key: 3,
2012
+ class: "flex flex-col gap-4"
2013
+ }, Hr = { class: "fm-typo-en-body-lg-600" }, Gr = /* @__PURE__ */ Ve({
2014
+ __name: "NetSuiteInfo",
2015
+ props: {
2016
+ transferType: {},
2017
+ transferToDbName: {},
2018
+ poRequest: {},
2019
+ purchaseOrder: {},
2020
+ isTransferBetweenOutlets: { type: Boolean },
2021
+ scope: {}
2022
+ },
2023
+ setup(u) {
2024
+ const t = u, r = _t(), o = Ze(), m = oe(t.poRequest);
2025
+ ns(async () => {
2026
+ var l;
2027
+ if (!t.poRequest && ((l = t.purchaseOrder) != null && l._id)) {
2028
+ const x = await o.getLatestPurchaseOrderRequest(t.purchaseOrder._id);
2029
+ m.value = x;
2030
+ }
2031
+ });
2032
+ const c = K(
2033
+ () => {
2034
+ var l, x, v, D, R, T;
2035
+ return r.getSubsidiaryFullName(
2036
+ ((v = (x = (l = t.purchaseOrder) == null ? void 0 : l.netSuite) == null ? void 0 : x.subsidiary) == null ? void 0 : v.id) || ((T = (R = (D = t.poRequest) == null ? void 0 : D.netSuite) == null ? void 0 : R.subsidiary) == null ? void 0 : T.id)
2037
+ ).fullName;
2038
+ }
2039
+ ), d = K(() => {
2040
+ var l, x, v, D, R, T, _, M, E, te, se, J;
2041
+ return (v = (x = (l = t.purchaseOrder) == null ? void 0 : l.netSuite) == null ? void 0 : x.additionalInfo) != null && v.transactionnumber ? (T = (R = (D = t.purchaseOrder) == null ? void 0 : D.netSuite) == null ? void 0 : R.additionalInfo) == null ? void 0 : T.transactionnumber : (E = (M = (_ = m.value) == null ? void 0 : _.netSuite) == null ? void 0 : M.additionalInfo) != null && E.transactionnumber ? (J = (se = (te = m.value) == null ? void 0 : te.netSuite) == null ? void 0 : se.additionalInfo) == null ? void 0 : J.transactionnumber : null;
2042
+ }), n = K(() => {
2043
+ var l, x, v, D, R, T;
2044
+ return (x = (l = t.purchaseOrder) == null ? void 0 : l.deliveryFullfillment) != null && x.length && ((D = (v = t.purchaseOrder) == null ? void 0 : v.deliveryFullfillment) == null ? void 0 : D.length) > 0 ? (T = (R = t.purchaseOrder) == null ? void 0 : R.deliveryFullfillment) == null ? void 0 : T.map(
2045
+ (_) => {
2046
+ var M, E;
2047
+ return `${((M = _.netSuite) == null ? void 0 : M.refNo) ?? "N/A"} (${((E = _.netSuite) == null ? void 0 : E.id) ?? "-"})`;
2048
+ }
2049
+ ).join(", ") : "N/A";
2050
+ });
2051
+ return (l, x) => {
2052
+ var v, D, R, T, _, M, E, te, se, J, ne, be, ie, ke, Ae, Q;
2053
+ return b(r).isEnabled ? (i(), y("div", Dr, [
2054
+ e("div", Rr, [
2055
+ x[0] || (x[0] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "NetSuite subsidiary", -1)),
2056
+ e("div", Pr, O(c.value || "N/A"), 1)
2057
+ ]),
2058
+ !l.isTransferBetweenOutlets && l.scope === b(At).RECEIVE_REQUEST ? (i(), y("div", Fr, [
2059
+ e("div", Ir, " NetSuite " + O((D = (v = l.purchaseOrder) == null ? void 0 : v.netSuite) != null && D.recordType ? b(ls)((T = (R = l.purchaseOrder) == null ? void 0 : R.netSuite) == null ? void 0 : T.recordType) : l.transferType === b(at).enum.purchase ? "Purchase Order" : "Transfer Order") + " (ID) ", 1),
2060
+ e("div", Tr, [
2061
+ (M = (_ = l.purchaseOrder) == null ? void 0 : _.netSuite) != null && M.id ? (i(), y("span", Er, O((te = (E = l.purchaseOrder) == null ? void 0 : E.netSuite) == null ? void 0 : te.refNo) + " (" + O((J = (se = l.purchaseOrder) == null ? void 0 : se.netSuite) == null ? void 0 : J.id) + ") ", 1)) : (i(), y("span", qr, "N/A"))
2062
+ ])
2063
+ ])) : V("", !0),
2064
+ !l.isTransferBetweenOutlets && m.value || l.scope === b(At).APPROVAL ? (i(), y("div", Vr, [
2065
+ e("div", Lr, " (Request) NetSuite " + O(l.transferType === b(at).enum.purchase ? "Purchase Order" : "Transfer Order") + " (ID) ", 1),
2066
+ e("div", jr, [
2067
+ (be = (ne = m.value) == null ? void 0 : ne.netSuite) != null && be.id ? (i(), y("span", Ur, O((ke = (ie = m.value) == null ? void 0 : ie.netSuite) == null ? void 0 : ke.refNo) + " (" + O((Q = (Ae = m.value) == null ? void 0 : Ae.netSuite) == null ? void 0 : Q.id) + ") ", 1)) : (i(), y("span", Mr, "N/A"))
2068
+ ])
2069
+ ])) : V("", !0),
2070
+ d.value ? (i(), y("div", Br, [
2071
+ x[1] || (x[1] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite Transaction Number ", -1)),
2072
+ e("div", zr, O(d.value), 1)
2073
+ ])) : V("", !0),
2074
+ b(r).isEnabled && l.transferType === b(at).enum.transfer && !l.isTransferBetweenOutlets ? (i(), y("div", Kr, [
2075
+ x[2] || (x[2] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite fulfillment IDs ", -1)),
2076
+ e("div", Hr, O(n.value), 1)
2077
+ ])) : V("", !0)
2078
+ ])) : V("", !0);
2079
+ };
2080
+ }
2081
+ }), Wr = { class: "flex flex-row-reverse" }, Qr = /* @__PURE__ */ Ve({
2082
+ __name: "NetSuiteLog",
2083
+ props: {
2084
+ netsuiteId: {},
2085
+ purchaseOrderId: {}
2086
+ },
2087
+ setup(u) {
2088
+ const t = Je(), r = Ft();
2089
+ async function o(m, c) {
2090
+ const d = [];
2091
+ if (m && d.push(`body.message:*${m}*`), c) {
2092
+ const v = c.replace(/:/g, "\\:");
2093
+ d.push(`${v}`);
2094
+ }
2095
+ if (d.length === 0) {
2096
+ t.open({
2097
+ message: "Cannot open logs without valid filters.",
2098
+ type: "error"
2099
+ });
2100
+ return;
2101
+ }
2102
+ const l = `attributes.pod:netsuite* AND (${d.join(" OR ")})`, { url: x } = await r.getSyncLogs(l);
2103
+ t.open(
2104
+ {
2105
+ message: "Opening NetSuite logs...",
2106
+ type: "info"
2107
+ },
2108
+ 800
2109
+ ), await new Promise((v) => setTimeout(v, 800)), window.open(x, "_blank");
2110
+ }
2111
+ return (m, c) => {
2112
+ const d = le("FmButton");
2113
+ return i(), y("div", Wr, [
2114
+ q(d, {
2115
+ "prepend-icon": "history",
2116
+ variant: "secondary",
2117
+ label: "Logs",
2118
+ onClick: c[0] || (c[0] = (n) => o(m.netsuiteId, m.purchaseOrderId)),
2119
+ "text-color": "primary",
2120
+ "bg-color": "transparent",
2121
+ "border-color": "primary"
2122
+ })
2123
+ ]);
2124
+ };
2125
+ }
2126
+ }), Yr = { class: "flex flex-row-reverse" }, Jr = { key: 0 }, Xr = { key: 1 }, Zr = { class: "mb-6" }, eo = { class: "fm-typo-en-body-md-400" }, to = { key: 0 }, so = { key: 1 }, ro = {
2127
+ key: 0,
2128
+ class: "flex"
2129
+ }, oo = {
2130
+ key: 1,
2131
+ class: "border-t pt-6"
2132
+ }, no = { class: "fm-typo-en-body-lg-600 mb-4 flex items-center gap-2" }, ao = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg overflow-y-auto" }, lo = { class: "w-full" }, io = {
2133
+ class: "p-3 fm-typo-en-body-sm-600",
2134
+ style: { "min-width": "130px" }
2135
+ }, uo = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, co = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, mo = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, po = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, fo = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, vo = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, yo = { class: "p-3 fm-typo-en-body-sm-600" }, ho = { key: 2 }, bo = { key: 1 }, go = /* @__PURE__ */ Ve({
2136
+ __name: "NetSuiteLatestInfo",
2137
+ props: {
2138
+ netsuiteId: {},
2139
+ purchaseOrderId: {}
2140
+ },
2141
+ setup(u) {
2142
+ const t = u, r = Ft(), o = oe(!1), m = ze(), c = oe(!0), d = oe(!1), n = oe(!1), l = oe(!1), x = oe(null), v = oe([]);
2143
+ async function D() {
2144
+ if (!x.value) {
2145
+ o.value = !0;
2146
+ try {
2147
+ c.value = !0;
2148
+ const M = await r.getMoreInfo(
2149
+ m.currentLocation.dbName,
2150
+ t.purchaseOrderId
2151
+ );
2152
+ x.value = M, d.value = !1;
2153
+ } catch {
2154
+ d.value = !0;
2155
+ } finally {
2156
+ c.value = !1;
2157
+ }
2158
+ await R();
2159
+ }
2160
+ }
2161
+ async function R() {
2162
+ if (!(v.value.length > 0))
2163
+ try {
2164
+ n.value = !0;
2165
+ const M = await r.getChangeLogs(t.netsuiteId);
2166
+ v.value = M, l.value = !1;
2167
+ } catch {
2168
+ l.value = !0;
2169
+ } finally {
2170
+ n.value = !1;
2171
+ }
2172
+ }
2173
+ function T(M) {
2174
+ switch (M) {
2175
+ case Me.Create:
2176
+ return "text-green-600 bg-green-100";
2177
+ case Me.Set:
2178
+ return "text-blue-600 bg-blue-100";
2179
+ case Me.Change:
2180
+ return "text-yellow-600 bg-yellow-100";
2181
+ case Me.Unset:
2182
+ return "text-red-600 bg-red-100";
2183
+ default:
2184
+ return "text-gray-600 bg-gray-100";
2185
+ }
2186
+ }
2187
+ function _(M) {
2188
+ return new Date(M).toLocaleDateString("en-US", {
2189
+ year: "numeric",
2190
+ month: "short",
2191
+ day: "numeric",
2192
+ hour: "2-digit",
2193
+ minute: "2-digit"
2194
+ });
2195
+ }
2196
+ return (M, E) => {
2197
+ const te = le("FmButton"), se = le("FmLabel"), J = le("FmCircularProgress"), ne = le("FmIcon"), be = le("FmDialog");
2198
+ return i(), y("div", Yr, [
2199
+ q(be, {
2200
+ modelValue: o.value,
2201
+ "onUpdate:modelValue": E[2] || (E[2] = (ie) => o.value = ie),
2202
+ overlay: !0,
2203
+ "max-width": 800
2204
+ }, {
2205
+ "dialog-button": pe(() => [
2206
+ q(te, {
2207
+ "prepend-icon": "info",
2208
+ variant: "secondary",
2209
+ label: "Latest Info",
2210
+ onClick: E[0] || (E[0] = (ie) => D()),
2211
+ "text-color": "primary",
2212
+ "bg-color": "transparent",
2213
+ "border-color": "primary"
2214
+ })
2215
+ ]),
2216
+ "dialog-header": pe(() => E[3] || (E[3] = [
2217
+ e("div", null, "NetSuite latest info", -1)
2218
+ ])),
2219
+ default: pe(() => [
2220
+ c.value ? (i(), y("div", Jr, "Loading...")) : (i(), y("div", Xr, [
2221
+ d.value ? (i(), y("p", bo, "Something went wrong.")) : (i(), y(De, { key: 0 }, [
2222
+ e("div", Zr, [
2223
+ E[4] || (E[4] = e("h3", { class: "fm-typo-en-body-lg-600 mb-4" }, "NetSuite Order Details", -1)),
2224
+ (i(!0), y(De, null, Te(x.value, (ie, ke) => (i(), y("div", {
2225
+ key: ke,
2226
+ class: "mb-2"
2227
+ }, [
2228
+ e("div", null, [
2229
+ q(se, {
2230
+ label: b(Rt)(ke)
2231
+ }, null, 8, ["label"]),
2232
+ e("div", eo, [
2233
+ Array.isArray(ie) ? (i(), y("span", to, O(ie.length > 0 ? ie.join(", ") : "N/A"), 1)) : (i(), y("span", so, O(ie), 1))
2234
+ ])
2235
+ ])
2236
+ ]))), 128))
2237
+ ]),
2238
+ n.value ? (i(), y("div", ro, [
2239
+ E[5] || (E[5] = e("span", null, "Change Log Loading...", -1)),
2240
+ q(J, { size: "md" })
2241
+ ])) : V("", !0),
2242
+ !n.value && v.value.length > 0 ? (i(), y("div", oo, [
2243
+ e("h3", no, [
2244
+ q(ne, {
2245
+ name: "error",
2246
+ color: "#ff9500",
2247
+ size: "sm"
2248
+ }),
2249
+ E[6] || (E[6] = Xe(" Change Logs "))
2250
+ ]),
2251
+ e("div", ao, [
2252
+ e("table", lo, [
2253
+ E[7] || (E[7] = e("thead", { class: "bg-fm-color-neutral-gray-50" }, [
2254
+ e("tr", { class: "border-b border-fm-color-neutral-gray-200" }, [
2255
+ e("th", {
2256
+ class: "text-left p-3 fm-typo-en-body-md-600",
2257
+ style: { "min-width": "130px" }
2258
+ }, " Date "),
2259
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Role"),
2260
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Name"),
2261
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Context"),
2262
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Type"),
2263
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Line ID"),
2264
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Field"),
2265
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Old Value"),
2266
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "New Value")
2267
+ ])
2268
+ ], -1)),
2269
+ e("tbody", null, [
2270
+ (i(!0), y(De, null, Te(v.value, (ie, ke) => (i(), y("tr", {
2271
+ key: ke,
2272
+ class: "border-b border-fm-color-neutral-gray-200 last:border-b-0"
2273
+ }, [
2274
+ e("td", io, O(_(ie._dateiso8601)), 1),
2275
+ e("td", uo, O(ie._rolename), 1),
2276
+ e("td", co, O(ie._employeename), 1),
2277
+ e("td", mo, O(ie._contextname), 1),
2278
+ e("td", {
2279
+ class: Ge(`p-3 fm-typo-en-body-sm-600 ${T(Number(ie.type) - 1)}`)
2280
+ }, O(b(Me)[Number(ie.type) - 1]), 3),
2281
+ e("td", po, O(ie.lineid || ""), 1),
2282
+ e("td", fo, O(ie._fieldname), 1),
2283
+ e("td", vo, O(ie.oldvalue || ""), 1),
2284
+ e("td", yo, O(ie.newvalue || ""), 1)
2285
+ ]))), 128))
2286
+ ])
2287
+ ])
2288
+ ])
2289
+ ])) : (i(), y("div", ho, E[8] || (E[8] = [
2290
+ e("p", null, "No change logs available.", -1)
2291
+ ])))
2292
+ ], 64))
2293
+ ]))
2294
+ ]),
2295
+ "dialog-footer": pe(() => [
2296
+ q(te, {
2297
+ class: "ml-auto sm:w-full xs:w-full",
2298
+ label: "Close",
2299
+ size: "md",
2300
+ variant: "primary",
2301
+ onClick: E[1] || (E[1] = (ie) => o.value = !1)
2302
+ })
2303
+ ]),
2304
+ _: 1
2305
+ }, 8, ["modelValue"])
2306
+ ]);
2307
+ };
2308
+ }
2309
+ }), _o = {
2310
+ key: 0,
2311
+ class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16 flex flex-col gap-8"
2312
+ }, So = { class: "flex gap-8 items-center" }, Oo = { class: "ml-auto" }, ko = { class: "flex gap-3" }, xo = /* @__PURE__ */ Ve({
2313
+ __name: "NetSuitePanel",
2314
+ props: {
2315
+ poRequest: {},
2316
+ purchaseOrder: {},
2317
+ transferType: {},
2318
+ transferToDbName: {},
2319
+ scope: {}
2320
+ },
2321
+ setup(u) {
2322
+ const t = u, r = Zs(), o = K(() => r.isNetSuiteEnabled);
2323
+ return (m, c) => {
2324
+ var n, l;
2325
+ const d = le("FmMenuDivider");
2326
+ return o.value ? (i(), y("div", _o, [
2327
+ e("div", So, [
2328
+ c[0] || (c[0] = e("span", { class: "flex-1 fm-typo-en-body-lg-600" }, "NetSuite Info", -1)),
2329
+ e("div", Oo, [
2330
+ e("div", ko, [
2331
+ (l = (n = t.purchaseOrder) == null ? void 0 : n.netSuite) != null && l.id ? (i(), he(tt, { key: 0 }, {
2332
+ default: pe(() => {
2333
+ var x, v, D;
2334
+ return [
2335
+ q(go, {
2336
+ "netsuite-id": (v = (x = m.purchaseOrder) == null ? void 0 : x.netSuite) == null ? void 0 : v.id,
2337
+ "purchase-order-id": (D = m.purchaseOrder) == null ? void 0 : D._id
2338
+ }, null, 8, ["netsuite-id", "purchase-order-id"])
2339
+ ];
2340
+ }),
2341
+ _: 1
2342
+ })) : V("", !0),
2343
+ q(tt, null, {
2344
+ default: pe(() => {
2345
+ var x, v, D;
2346
+ return [
2347
+ q(Qr, {
2348
+ "netsuite-id": (v = (x = m.purchaseOrder) == null ? void 0 : x.netSuite) == null ? void 0 : v.id,
2349
+ "purchase-order-id": (D = m.purchaseOrder) == null ? void 0 : D._id
2350
+ }, null, 8, ["netsuite-id", "purchase-order-id"])
2351
+ ];
2352
+ }),
2353
+ _: 1
2354
+ }),
2355
+ q(Nr, {
2356
+ "po-request": m.poRequest,
2357
+ "purchase-order": m.purchaseOrder,
2358
+ "is-transfer-between-outlets": !o.value,
2359
+ scope: m.scope
2360
+ }, null, 8, ["po-request", "purchase-order", "is-transfer-between-outlets", "scope"])
2361
+ ])
2362
+ ])
2363
+ ]),
2364
+ q(d),
2365
+ q(Gr, {
2366
+ "po-request": m.poRequest,
2367
+ "purchase-order": m.purchaseOrder,
2368
+ "transfer-type": m.transferType,
2369
+ "transfer-to-db-name": m.transferToDbName,
2370
+ "is-transfer-between-outlets": !o.value,
2371
+ scope: m.scope
2372
+ }, null, 8, ["po-request", "purchase-order", "transfer-type", "transfer-to-db-name", "is-transfer-between-outlets", "scope"])
2373
+ ])) : V("", !0);
2374
+ };
2375
+ }
2376
+ }), wo = ["open"], $o = { class: "fm-typo-en-body-sm-600 cursor-pointer select-none" }, ss = /* @__PURE__ */ Ve({
2377
+ __name: "FmAdminCollapsiblePanel",
2378
+ props: {
2379
+ title: { default: "Admin" },
2380
+ open: { type: Boolean, default: !1 },
2381
+ selectable: { type: Boolean, default: !0 },
2382
+ class: { default: void 0 },
2383
+ contentClass: { default: void 0 }
2384
+ },
2385
+ setup(u) {
2386
+ const t = u;
2387
+ return (r, o) => (i(), he(tt, {
2388
+ selectable: t.selectable,
2389
+ class: Ge(t.class)
2390
+ }, {
2391
+ default: pe(() => [
2392
+ e("details", {
2393
+ open: t.open,
2394
+ class: "w-full"
2395
+ }, [
2396
+ e("summary", $o, O(t.title), 1),
2397
+ e("div", {
2398
+ class: Ge(["mt-4 flex flex-col gap-2", t.contentClass])
2399
+ }, [
2400
+ Ps(r.$slots, "default")
2401
+ ], 2)
2402
+ ], 8, wo)
2403
+ ]),
2404
+ _: 3
2405
+ }, 8, ["selectable", "class"]));
2406
+ }
2407
+ });
2408
+ function Ss(u) {
2409
+ if (!(u != null && u.itemsAtSubmission)) return [];
2410
+ const t = new Set(u.itemsAtSubmission.map((m) => m.sku._id)), r = /* @__PURE__ */ new Set(), o = [];
2411
+ for (const m of u.items) {
2412
+ const c = m.sku._id;
2413
+ t.has(c) || r.has(c) || (r.add(c), o.push(m));
2414
+ }
2415
+ return o;
2416
+ }
2417
+ function Os(u, t) {
2418
+ var m;
2419
+ if (!u || t.length === 0) return {};
2420
+ const r = new Set(t.map((c) => c.sku._id)), o = {};
2421
+ for (const c of u.deliveryOrder ?? [])
2422
+ for (const d of c.received ?? []) {
2423
+ const n = d.sku._id;
2424
+ n && r.has(n) && (o[n] = (o[n] ?? 0) + (((m = d.amount) == null ? void 0 : m.amount) ?? 0));
2425
+ }
2426
+ return t.reduce(
2427
+ (c, d) => {
2428
+ var D, R;
2429
+ const n = d.sku._id ?? "", l = ((D = d.quantity) == null ? void 0 : D.amount) ?? 0, x = o[n] ?? 0, v = ((R = d.quantity) == null ? void 0 : R.precision) ?? 0;
2430
+ return c[n] = {
2431
+ key: n,
2432
+ total: { amount: l, precision: v },
2433
+ received: { amount: x, precision: v },
2434
+ remaining: { amount: l - x, precision: v }
2435
+ }, c;
2436
+ },
2437
+ {}
2438
+ );
2439
+ }
2440
+ const Co = { class: "flex flex-col gap-3" }, Ao = { class: "flex flex-col gap-4" }, No = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, Do = { class: "flex flex-col gap-4" }, Ro = { class: "flex justify-between items-start py-1 gap-4" }, Po = { class: "flex flex-col flex-1 min-w-0" }, Fo = { class: "fm-typo-en-body-lg-600 truncate" }, Io = { class: "fm-typo-en-body-md-400 truncate" }, To = { class: "flex flex-col gap-2 items-end w-52 shrink-0" }, Eo = {
2441
+ key: 0,
2442
+ class: "flex items-center gap-2"
2443
+ }, qo = {
2444
+ key: 0,
2445
+ class: "border-b border-fm-color-stroke-secondary"
2446
+ }, Vo = { class: "flex flex-col gap-4" }, Lo = { class: "flex items-center justify-between" }, jo = {
2447
+ key: 0,
2448
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-tertiary"
2449
+ }, Uo = { class: "flex justify-between items-start py-1 gap-4" }, Mo = { class: "flex-1 min-w-0 flex flex-col gap-2" }, Bo = { class: "flex flex-col gap-2 items-end w-52 shrink-0" }, zo = {
2450
+ key: 0,
2451
+ class: "flex items-center gap-2"
2452
+ }, Ko = {
2453
+ key: 0,
2454
+ class: "border-b border-fm-color-stroke-secondary"
2455
+ }, Ho = { class: "flex flex-col gap-4" }, Go = { class: "flex flex-col gap-4" }, Wo = { class: "flex flex-col gap-4" }, Qo = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, Yo = {
2456
+ key: 1,
2457
+ class: "flex flex-col gap-4"
2458
+ }, Jo = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, ct = "Will be ignored on save (zero or negative quantity)", Xo = /* @__PURE__ */ Ve({
2459
+ __name: "EditForm",
2460
+ props: {
2461
+ purchaseOrder: {},
2462
+ deliveryOrder: {},
2463
+ receivedInfoMap: {}
2464
+ },
2465
+ emits: ["submitted"],
2466
+ setup(u, { emit: t }) {
2467
+ var F;
2468
+ const { t: r } = lr(), o = Ye(), m = Je(), c = oe(!1), d = Dt(), n = u, l = (((F = n.purchaseOrder) == null ? void 0 : F.version) ?? je.enum[1]) === je.enum[2], x = t, v = us("deliveryOrder"), D = Ze(), {
2469
+ controller: R,
2470
+ state: T,
2471
+ reset: _
2472
+ } = Tt({
2473
+ currency: Ce(),
2474
+ adjustments: n.deliveryOrder.priceAdjustments
2475
+ }), M = K(
2476
+ () => {
2477
+ var h;
2478
+ return ((h = n.purchaseOrder.deliveryFullfillment) == null ? void 0 : h.findIndex(
2479
+ (g) => n.deliveryOrder.fullfillmentId && g.id === n.deliveryOrder.fullfillmentId
2480
+ )) ?? -1;
2481
+ }
2482
+ ), E = o.enablePurchaseOrderReceiveWithCustomCost, te = o.enablePortalDeliveryOrderWrite, se = oe({}), J = K(
2483
+ () => (n.purchaseOrder.itemsAtSubmission ?? n.purchaseOrder.items).length
2484
+ ), ne = K(() => Ss(n.purchaseOrder)), be = K(
2485
+ () => Os(n.purchaseOrder, ne.value)
2486
+ ), ie = K(
2487
+ () => n.purchaseOrder.items.map(
2488
+ (h, g) => K({
2489
+ get: () => {
2490
+ var G;
2491
+ const B = (G = v.received[g]) == null ? void 0 : G.amount;
2492
+ return B ? +$e(B) : 0;
2493
+ },
2494
+ set: (B) => {
2495
+ v.received[g].amount = We(B, h.sku.unit.precision);
2496
+ }
2497
+ })
2498
+ )
2499
+ ), ke = K(
2500
+ () => n.purchaseOrder.items.map(
2501
+ (h, g) => K({
2502
+ get: () => {
2503
+ var G;
2504
+ const B = (G = v.received[g]) == null ? void 0 : G.cost;
2505
+ return B ? +$e(B) : 0;
2506
+ },
2507
+ set: (B) => {
2508
+ v.received[g].cost = {
2509
+ currency: Ce(),
2510
+ ...We(B, 4)
2511
+ };
2512
+ }
2513
+ })
2514
+ )
2515
+ );
2516
+ function Ae(h) {
2517
+ var B;
2518
+ const g = !se.value[h];
2519
+ if (se.value[h] = g, g) {
2520
+ const G = (B = v.received[h]) == null ? void 0 : B.cost;
2521
+ v.received[h].cost = G ? { ...G, precision: 4 } : { currency: Ce(), amount: 0, precision: 4 };
2522
+ } else
2523
+ delete v.received[h].cost;
2524
+ }
2525
+ const Q = oe([]), ye = K(
2526
+ () => d.skus.filter((h) => !h.isInactive).map((h) => ({ label: `${h.name} (${h.code})`, value: h._id }))
2527
+ );
2528
+ function P() {
2529
+ Q.value.push({ skuId: null, costEnabled: !1 }), v.received.push({
2530
+ sku: null,
2531
+ amount: Fe.fromNumber(0),
2532
+ measurement: null
2533
+ });
2534
+ }
2535
+ function w(h) {
2536
+ Q.value.splice(h, 1), v.received.splice(J.value + h, 1);
2537
+ }
2538
+ function $(h, g) {
2539
+ Q.value[h].skuId = g;
2540
+ const B = g ? d.skuById[g] : null;
2541
+ v.received[J.value + h].sku = B;
2542
+ }
2543
+ function N(h, g) {
2544
+ var re, ve;
2545
+ const B = (re = n.receivedInfoMap) == null ? void 0 : re[g.sku._id], G = B ? `${r("inventory.transfer.receiveRequest.details.received")} ${Fe.toFormatString({ value: B.received })} / ${ft(g.quantity, g.sku.unit, g.measurement)}` : void 0;
2546
+ return (((ve = ie.value[h]) == null ? void 0 : ve.value) ?? 0) > 0 ? G : G ? `${G} · ${ct}` : ct;
2547
+ }
2548
+ function U(h, g) {
2549
+ var re;
2550
+ const G = (((re = Z.value[g]) == null ? void 0 : re.value) ?? 0) <= 0;
2551
+ let X;
2552
+ if (h.skuId && be.value[h.skuId]) {
2553
+ const ve = be.value[h.skuId], s = Fe.toFormatString({ value: ve.received });
2554
+ X = `${r("inventory.transfer.receiveRequest.details.received")} ${s}`;
2555
+ }
2556
+ return G ? X ? `${X} · ${ct}` : ct : X;
2557
+ }
2558
+ const Z = K(
2559
+ () => Q.value.map((h, g) => {
2560
+ const B = J.value + g;
2561
+ return K({
2562
+ get: () => {
2563
+ var X;
2564
+ const G = (X = v.received[B]) == null ? void 0 : X.amount;
2565
+ return G ? +$e(G) : 0;
2566
+ },
2567
+ set: (G) => {
2568
+ var re, ve, s;
2569
+ const X = ((re = h.historyItem) == null ? void 0 : re.sku.unit.precision) ?? (h.skuId ? (s = (ve = d.skuById[h.skuId]) == null ? void 0 : ve.unit) == null ? void 0 : s.precision : void 0) ?? 2;
2570
+ v.received[B].amount = We(G, X);
2571
+ }
2572
+ });
2573
+ })
2574
+ ), ue = K(
2575
+ () => Q.value.map((h, g) => {
2576
+ const B = J.value + g;
2577
+ return K({
2578
+ get: () => {
2579
+ var X;
2580
+ const G = (X = v.received[B]) == null ? void 0 : X.cost;
2581
+ return G ? +$e(G) : 0;
2582
+ },
2583
+ set: (G) => {
2584
+ v.received[B].cost = {
2585
+ currency: Ce(),
2586
+ ...We(G, 4)
2587
+ };
2588
+ }
2589
+ });
2590
+ })
2591
+ );
2592
+ function H(h) {
2593
+ const g = Q.value[h], B = J.value + h;
2594
+ g.costEnabled = !g.costEnabled, g.costEnabled ? v.received[B].cost = { currency: Ce(), amount: 0, precision: 4 } : delete v.received[B].cost;
2595
+ }
2596
+ Qe(
2597
+ () => c.value,
2598
+ (h) => {
2599
+ var s, a, k;
2600
+ if (!h) {
2601
+ Q.value = [], se.value = {};
2602
+ return;
2603
+ }
2604
+ _(n.deliveryOrder.priceAdjustments);
2605
+ const g = n.purchaseOrder.itemsAtSubmission ?? n.purchaseOrder.items, B = new Set(g.map((C) => C.sku._id)), G = {}, X = [];
2606
+ for (const C of n.deliveryOrder.received ?? []) {
2607
+ const A = (s = C.sku) == null ? void 0 : s._id;
2608
+ A && (B.has(A) ? G[A] = C : X.push(C));
2609
+ }
2610
+ v.received = g.map((C) => {
2611
+ const A = G[C.sku._id];
2612
+ return A ? { ...A } : {
2613
+ // Propagate the stable id so V2 submissions match this existing PO line
2614
+ // instead of the backend treating it as a new extra item (see CreateForm.vue).
2615
+ ...l && C.id ? { id: C.id } : {},
2616
+ sku: C.sku,
2617
+ amount: Fe.fromNumber(0),
2618
+ measurement: C.measurement ?? null
2619
+ };
2620
+ });
2621
+ const re = {};
2622
+ for (let C = 0; C < g.length; C++)
2623
+ (a = G[g[C].sku._id]) != null && a.cost && (re[C] = !0);
2624
+ se.value = re, Q.value = [];
2625
+ const ve = ne.value;
2626
+ for (const C of X) {
2627
+ const A = ve.find((W) => {
2628
+ var fe;
2629
+ return W.sku._id === ((fe = C.sku) == null ? void 0 : fe._id);
2630
+ });
2631
+ Q.value.push({
2632
+ skuId: ((k = C.sku) == null ? void 0 : k._id) ?? null,
2633
+ costEnabled: !!C.cost,
2634
+ locked: !0,
2635
+ quantityLocked: !0,
2636
+ historyItem: A
2637
+ }), v.received.push({ ...C });
2638
+ }
2639
+ if (ve.length) {
2640
+ const C = new Set(X.map((A) => {
2641
+ var W;
2642
+ return (W = A.sku) == null ? void 0 : W._id;
2643
+ }));
2644
+ for (const A of ve)
2645
+ C.has(A.sku._id) || (Q.value.push({
2646
+ skuId: A.sku._id,
2647
+ costEnabled: !1,
2648
+ locked: !0,
2649
+ historyItem: A
2650
+ }), v.received.push({
2651
+ ...l && A.id ? { id: A.id } : {},
2652
+ sku: A.sku,
2653
+ amount: Fe.fromNumber(0),
2654
+ measurement: A.measurement ?? null
2655
+ }));
2656
+ }
2657
+ }
2658
+ );
2659
+ const de = oe(!1);
2660
+ function xe() {
2661
+ de.value = !0, D.updateDeliveryOrder({
2662
+ deliveryOrder: {
2663
+ ...n.deliveryOrder,
2664
+ ...v,
2665
+ priceAdjustments: R.value.state().adjustments
2666
+ },
2667
+ purchaseOrderId: n.purchaseOrder._id,
2668
+ purchaseOrderRev: n.purchaseOrder._rev
2669
+ }).then(() => {
2670
+ m.open(
2671
+ {
2672
+ title: "Success",
2673
+ message: `PO# ${n.purchaseOrder.seqNumber} Changes have been saved`,
2674
+ type: "success"
2675
+ },
2676
+ 1e4
2677
+ ), c.value = !1, x("submitted");
2678
+ }).finally(() => {
2679
+ de.value = !1;
2680
+ });
2681
+ }
2682
+ return (h, g) => {
2683
+ const B = le("FmButton"), G = le("FmStepperField"), X = le("FmSwitch"), re = le("FmSelect"), ve = le("FmTextField"), s = le("FmDialog");
2684
+ return i(), he(s, {
2685
+ modelValue: c.value,
2686
+ "onUpdate:modelValue": g[1] || (g[1] = (a) => c.value = a),
2687
+ overlay: !0,
2688
+ "min-width": 800
2689
+ }, {
2690
+ "dialog-button": pe(() => [
2691
+ b(te) ? (i(), he(B, {
2692
+ key: 0,
2693
+ variant: "plain",
2694
+ label: "Edit",
2695
+ size: "md",
2696
+ "prepend-icon": "edit"
2697
+ })) : V("", !0)
2698
+ ]),
2699
+ "dialog-header": pe(() => [
2700
+ e("div", null, "Received on " + O(b(et)(n.deliveryOrder.createdAt)), 1)
2701
+ ]),
2702
+ "dialog-footer": pe(() => [
2703
+ q(B, {
2704
+ class: "ml-auto",
2705
+ label: "Apply changes",
2706
+ size: "md",
2707
+ variant: "destructive",
2708
+ disabled: de.value,
2709
+ loading: de.value,
2710
+ onClick: xe
2711
+ }, null, 8, ["disabled", "loading"])
2712
+ ]),
2713
+ default: pe(() => [
2714
+ e("div", Co, [
2715
+ e("div", Ao, [
2716
+ g[2] || (g[2] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Adjustment date", -1)),
2717
+ e("div", No, O(n.deliveryOrder.adjustment ? b(et)(new Date(b(mt)(n.deliveryOrder.adjustment))) : "-"), 1)
2718
+ ]),
2719
+ e("div", Do, [
2720
+ g[4] || (g[4] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Items going to receive ", -1)),
2721
+ (i(!0), y(De, null, Te(n.purchaseOrder.items, (a, k) => {
2722
+ var C;
2723
+ return i(), y("div", { key: k }, [
2724
+ e("div", Ro, [
2725
+ e("div", Po, [
2726
+ e("span", Fo, O(a.sku.name), 1),
2727
+ e("span", Io, O(a.sku.code), 1)
2728
+ ]),
2729
+ e("div", To, [
2730
+ q(G, {
2731
+ label: "Receive Quantity",
2732
+ modelValue: ie.value[k].value,
2733
+ "onUpdate:modelValue": (A) => ie.value[k].value = A,
2734
+ "append-text": ((C = a.measurement) == null ? void 0 : C.abbrev) ?? a.sku.unit.abbrev,
2735
+ "helper-text": N(k, a)
2736
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text", "helper-text"]),
2737
+ b(E) ? (i(), y("div", Eo, [
2738
+ q(X, {
2739
+ "model-value": se.value[k],
2740
+ "onUpdate:modelValue": (A) => Ae(k),
2741
+ size: "sm"
2742
+ }, null, 8, ["model-value", "onUpdate:modelValue"]),
2743
+ g[3] || (g[3] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Override cost ", -1))
2744
+ ])) : V("", !0),
2745
+ b(E) && se.value[k] ? (i(), he(G, {
2746
+ key: 1,
2747
+ modelValue: ke.value[k].value,
2748
+ "onUpdate:modelValue": (A) => ke.value[k].value = A,
2749
+ label: "Total Cost",
2750
+ step: 1e-4,
2751
+ min: 0,
2752
+ placeholder: "0.0000",
2753
+ size: "sm",
2754
+ "append-text": b(Ce)()
2755
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text"])) : V("", !0)
2756
+ ])
2757
+ ]),
2758
+ k < n.purchaseOrder.items.length - 1 ? (i(), y("div", qo)) : V("", !0)
2759
+ ]);
2760
+ }), 128))
2761
+ ]),
2762
+ e("div", Vo, [
2763
+ e("div", Lo, [
2764
+ g[5] || (g[5] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Extra items", -1)),
2765
+ q(B, {
2766
+ variant: "tertiary",
2767
+ label: "Add item",
2768
+ "prepend-icon": "add",
2769
+ size: "md",
2770
+ onClick: P
2771
+ })
2772
+ ]),
2773
+ Q.value.length === 0 ? (i(), y("div", jo, " No extra items added ")) : V("", !0),
2774
+ (i(!0), y(De, null, Te(Q.value, (a, k) => {
2775
+ var C, A;
2776
+ return i(), y("div", { key: k }, [
2777
+ e("div", Uo, [
2778
+ e("div", Mo, [
2779
+ q(re, {
2780
+ "model-value": a.skuId,
2781
+ "onUpdate:modelValue": (W) => $(k, W),
2782
+ label: "Ingredient",
2783
+ items: ye.value,
2784
+ searchable: "",
2785
+ searchTarget: "label",
2786
+ placeholder: "Select ingredient",
2787
+ disabled: a.locked
2788
+ }, null, 8, ["model-value", "onUpdate:modelValue", "items", "disabled"])
2789
+ ]),
2790
+ e("div", Bo, [
2791
+ q(G, {
2792
+ label: "Receive Quantity",
2793
+ modelValue: Z.value[k].value,
2794
+ "onUpdate:modelValue": (W) => Z.value[k].value = W,
2795
+ "append-text": a.skuId ? ((A = (C = b(d).skuById[a.skuId]) == null ? void 0 : C.unit) == null ? void 0 : A.abbrev) ?? "" : "",
2796
+ "helper-text": U(a, k),
2797
+ disabled: a.quantityLocked || !a.skuId
2798
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text", "helper-text", "disabled"]),
2799
+ b(E) ? (i(), y("div", zo, [
2800
+ q(X, {
2801
+ "model-value": a.costEnabled,
2802
+ "onUpdate:modelValue": (W) => H(k),
2803
+ size: "sm"
2804
+ }, null, 8, ["model-value", "onUpdate:modelValue"]),
2805
+ g[6] || (g[6] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Override cost ", -1))
2806
+ ])) : V("", !0),
2807
+ b(E) && a.costEnabled ? (i(), he(G, {
2808
+ key: 1,
2809
+ modelValue: ue.value[k].value,
2810
+ "onUpdate:modelValue": (W) => ue.value[k].value = W,
2811
+ label: "Total Cost",
2812
+ step: 1e-4,
2813
+ min: 0,
2814
+ placeholder: "0.0000",
2815
+ size: "sm",
2816
+ "append-text": b(Ce)()
2817
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text"])) : V("", !0)
2818
+ ]),
2819
+ a.locked ? V("", !0) : (i(), he(B, {
2820
+ key: 0,
2821
+ variant: "tertiary",
2822
+ "prepend-icon": "delete",
2823
+ size: "md",
2824
+ class: "mt-6",
2825
+ onClick: (W) => w(k)
2826
+ }, null, 8, ["onClick"]))
2827
+ ]),
2828
+ k < Q.value.length - 1 ? (i(), y("div", Ko)) : V("", !0)
2829
+ ]);
2830
+ }), 128))
2831
+ ]),
2832
+ e("div", Ho, [
2833
+ g[7] || (g[7] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Delivery order no.", -1)),
2834
+ e("div", Go, [
2835
+ q(ve, {
2836
+ modelValue: b(v).deliveryOrderNumber,
2837
+ "onUpdate:modelValue": g[0] || (g[0] = (a) => b(v).deliveryOrderNumber = a),
2838
+ size: "md",
2839
+ placeholder: n.deliveryOrder.deliveryOrderNumber
2840
+ }, null, 8, ["modelValue", "placeholder"])
2841
+ ])
2842
+ ]),
2843
+ e("div", Wo, [
2844
+ g[8] || (g[8] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Remark", -1)),
2845
+ e("div", Qo, O(n.deliveryOrder.remark || "N/A"), 1)
2846
+ ]),
2847
+ b(o).enablePurchaseOrderPriceAdjustment ? (i(), he(It, {
2848
+ key: 0,
2849
+ controller: b(R),
2850
+ state: b(T)
2851
+ }, null, 8, ["controller", "state"])) : V("", !0),
2852
+ M.value >= 0 ? (i(), y("div", Yo, [
2853
+ g[9] || (g[9] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Fulfilment's sequence", -1)),
2854
+ e("div", Jo, O(M.value + 1), 1)
2855
+ ])) : V("", !0)
2856
+ ])
2857
+ ]),
2858
+ _: 1
2859
+ }, 8, ["modelValue"]);
2860
+ };
2861
+ }
2862
+ }), Zo = { class: "flex flex-col gap-3" }, en = { class: "flex flex-col gap-4" }, tn = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, sn = {
2863
+ key: 0,
2864
+ class: "flex flex-col gap-4"
2865
+ }, rn = { class: "flex items-center justify-between" }, on = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, nn = {
2866
+ key: 0,
2867
+ class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
2868
+ }, an = { class: "flex gap-4" }, ln = { class: "flex-1" }, un = { class: "flex-1" }, cn = {
2869
+ key: 0,
2870
+ class: "flex items-center text-fm-color-system-error-300"
2871
+ }, dn = { class: "fm-typo-en-body-md-400" }, mn = { class: "flex flex-col gap-4" }, pn = { class: "flex justify-between items-start py-1 gap-4" }, fn = { class: "flex flex-col flex-1 min-w-0" }, vn = { class: "fm-typo-en-body-lg-600 truncate" }, yn = { class: "fm-typo-en-body-md-400 truncate" }, hn = { class: "flex flex-col gap-2 items-end w-52 shrink-0" }, bn = {
2872
+ key: 0,
2873
+ class: "fm-typo-en-body-sm-400 text-fm-color-system-error-300 self-end text-right"
2874
+ }, gn = {
2875
+ key: 1,
2876
+ class: "flex items-center gap-2"
2877
+ }, _n = {
2878
+ key: 0,
2879
+ class: "border-b border-fm-color-stroke-secondary"
2880
+ }, Sn = { class: "flex flex-col gap-4" }, On = { class: "flex items-center justify-between" }, kn = {
2881
+ key: 0,
2882
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-tertiary"
2883
+ }, xn = { class: "flex justify-between items-start py-1 gap-4" }, wn = { class: "flex-1 min-w-0 flex flex-col gap-2" }, $n = { class: "flex flex-col gap-2 items-end w-52 shrink-0" }, Cn = {
2884
+ key: 0,
2885
+ class: "fm-typo-en-body-sm-400 text-fm-color-system-error-300 self-end text-right"
2886
+ }, An = {
2887
+ key: 1,
2888
+ class: "flex items-center gap-2"
2889
+ }, Nn = {
2890
+ key: 0,
2891
+ class: "border-b border-fm-color-stroke-secondary"
2892
+ }, Dn = { class: "flex flex-col gap-4" }, Rn = { class: "flex flex-col gap-4" }, Pn = { class: "flex flex-col gap-4" }, Fn = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, rs = "Will be ignored on save (zero or negative quantity)", In = /* @__PURE__ */ Ve({
2893
+ __name: "CreateForm",
2894
+ props: {
2895
+ purchaseOrder: {},
2896
+ receivedInfoMap: {},
2897
+ receivedMap: {}
2898
+ },
2899
+ emits: ["submitted"],
2900
+ setup(u, { emit: t }) {
2901
+ var fe, I, ce;
2902
+ const { t: r } = ht(), o = oe(!1), m = bt(), c = u, d = t, n = us("", {
2903
+ default: {
2904
+ deliveryOrderNumber: "",
2905
+ remark: "",
2906
+ received: (c.purchaseOrder.itemsAtSubmission ?? c.purchaseOrder.items).map((f) => {
2907
+ var p;
2908
+ return {
2909
+ // Propagate the stable id so V2 submissions match this existing PO line instead
2910
+ // of the backend's classify-received.ts treating it as a new extra item (which
2911
+ // appends a duplicate item record with quantity = this delivery's amount, on
2912
+ // every single delivery — inflating the PO's total ordered quantity forever).
2913
+ ...(((p = c.purchaseOrder) == null ? void 0 : p.version) ?? je.enum[1]) === je.enum[2] && f.id ? { id: f.id } : {},
2914
+ sku: f.sku,
2915
+ amount: Fe.fromNumber(0),
2916
+ measurement: f.measurement
2917
+ };
2918
+ }),
2919
+ createdBy: {
2920
+ id: ((fe = m.sessionUser.value) == null ? void 0 : fe.id) || "",
2921
+ name: ((I = m.sessionUser.value) == null ? void 0 : I.displayName) || ""
2922
+ },
2923
+ createdAt: ""
2924
+ }
2925
+ }), l = Ze(), x = gt(), v = Ye(), D = Dt(), {
2926
+ controller: R,
2927
+ state: T,
2928
+ reset: _
2929
+ } = Tt({ currency: Ce() }), M = K(
2930
+ () => c.purchaseOrder.deliveryFullfillment != null
2931
+ ), E = K(
2932
+ () => v.enablePortalDeliveryOrderWrite && (c.purchaseOrder.status === Se.Enum.RECEIVING || c.purchaseOrder.status === Se.Enum.COMPLETE) && !M.value
2933
+ ), te = v.enablePurchaseOrderReceiveWithCustomCost, se = v.enableBackdateReceive, J = oe({}), ne = K(
2934
+ () => c.purchaseOrder.itemsAtSubmission ?? c.purchaseOrder.items
2935
+ ), be = K(() => Ss(c.purchaseOrder)), ie = K(
2936
+ () => Os(c.purchaseOrder, be.value)
2937
+ );
2938
+ function ke(f) {
2939
+ return f.sku._id ?? null;
2940
+ }
2941
+ const Ae = (((ce = c.purchaseOrder) == null ? void 0 : ce.version) ?? je.enum[1]) === je.enum[2], Q = Je(), ye = K({
2942
+ get() {
2943
+ if (!n.createdAt) return "";
2944
+ const f = new Date(n.createdAt), p = f.getFullYear(), S = String(f.getMonth() + 1).padStart(2, "0"), L = String(f.getDate()).padStart(2, "0");
2945
+ return `${p}-${S}-${L}`;
2946
+ },
2947
+ set(f) {
2948
+ if (f) {
2949
+ const p = n.createdAt ? new Date(n.createdAt) : /* @__PURE__ */ new Date(), [S, L, j] = f.split("-");
2950
+ p.setFullYear(parseInt(S)), p.setMonth(parseInt(L) - 1), p.setDate(parseInt(j)), n.createdAt = p.toISOString();
2951
+ }
2952
+ }
2953
+ }), P = K({
2954
+ get() {
2955
+ if (!n.createdAt) return "";
2956
+ const f = new Date(n.createdAt), p = String(f.getHours()).padStart(2, "0"), S = String(f.getMinutes()).padStart(2, "0");
2957
+ return `${p}:${S}`;
2958
+ },
2959
+ set(f) {
2960
+ if (f) {
2961
+ const p = n.createdAt ? new Date(n.createdAt) : /* @__PURE__ */ new Date(), [S, L] = f.split(":");
2962
+ p.setHours(parseInt(S)), p.setMinutes(parseInt(L)), n.createdAt = p.toISOString();
2963
+ }
2964
+ }
2965
+ }), w = K(() => {
2966
+ const f = mt(c.purchaseOrder._id);
2967
+ if (!f) return "";
2968
+ const p = new Date(f), S = p.getFullYear(), L = String(p.getMonth() + 1).padStart(2, "0"), j = String(p.getDate()).padStart(2, "0");
2969
+ return `${S}-${L}-${j}`;
2970
+ }), $ = K(() => {
2971
+ const f = mt(c.purchaseOrder._id);
2972
+ return f ? new Date(f) : null;
2973
+ }), N = K(() => {
2974
+ if (!ye.value || !P.value || !$.value) return null;
2975
+ if (/* @__PURE__ */ new Date(`${ye.value}T${P.value}:00`) < $.value) {
2976
+ const p = w.value, S = $.value.getHours(), L = $.value.getMinutes(), j = S >= 12 ? "PM" : "AM", Oe = S % 12 || 12, we = `${String(Oe).padStart(2, "0")}:${String(L).padStart(2, "0")} ${j}`;
2977
+ return `Delivery date & time cannot be earlier than order creation (${p} ${we})`;
2978
+ }
2979
+ return null;
2980
+ }), U = K(() => N.value || F.value.some((p) => !p.skuId) ? !1 : n.received.some((p) => {
2981
+ const S = p.amount;
2982
+ return S ? +$e(S) > 0 : !1;
2983
+ }));
2984
+ function Z(f) {
2985
+ var L;
2986
+ const p = (L = c.receivedInfoMap[f.sku._id]) == null ? void 0 : L.received, S = p != null ? Fe.toFormatString({ value: p }) : "0";
2987
+ return `${r("inventory.transfer.receiveRequest.details.received")} ${S} / ${ft(f.quantity, f.sku.unit, f.measurement)}`;
2988
+ }
2989
+ function ue() {
2990
+ n.createdAt = "";
2991
+ }
2992
+ const H = K(() => ne.value.map((f, p) => K({
2993
+ get: () => {
2994
+ var L;
2995
+ const S = (L = n.received[p]) == null ? void 0 : L.amount;
2996
+ return S ? +$e(S) : 0;
2997
+ },
2998
+ set: (S) => {
2999
+ var j;
3000
+ const L = ((j = ne.value[p]) == null ? void 0 : j.sku.unit.precision) ?? 2;
3001
+ n.received[p].amount = We(S, L);
3002
+ }
3003
+ })));
3004
+ function de(f) {
3005
+ const p = !J.value[f];
3006
+ if (J.value[f] = p, p) {
3007
+ const S = ne.value[f];
3008
+ S.totalCost ? n.received[f].cost = {
3009
+ currency: S.totalCost.currency,
3010
+ amount: S.totalCost.amount,
3011
+ precision: 4
3012
+ // Standardize to 4 decimals
3013
+ } : n.received[f].cost = {
3014
+ currency: Ce(),
3015
+ amount: 0,
3016
+ precision: 4
3017
+ };
3018
+ } else
3019
+ delete n.received[f].cost;
3020
+ }
3021
+ const xe = K(() => ne.value.map((f, p) => K({
3022
+ get: () => {
3023
+ var L;
3024
+ const S = (L = n.received[p]) == null ? void 0 : L.cost;
3025
+ return S ? +$e(S) : 0;
3026
+ },
3027
+ set: (S) => {
3028
+ n.received[p].cost = {
3029
+ currency: Ce(),
3030
+ ...We(S, 4)
3031
+ };
3032
+ }
3033
+ }))), F = oe([]), h = K(
3034
+ () => D.skus.filter((f) => !f.isInactive).map((f) => ({ label: `${f.name} (${f.code})`, value: f._id }))
3035
+ ), g = K(() => ne.value.length);
3036
+ function B() {
3037
+ F.value.push({ skuId: null, stableKey: null, costEnabled: !1 }), n.received.push({
3038
+ sku: null,
3039
+ amount: Fe.fromNumber(0),
3040
+ measurement: null
3041
+ });
3042
+ }
3043
+ function G(f) {
3044
+ F.value.splice(f, 1), n.received.splice(g.value + f, 1);
3045
+ }
3046
+ function X(f, p) {
3047
+ F.value[f].skuId = p;
3048
+ const S = p ? D.skuById[p] : null;
3049
+ n.received[g.value + f].sku = S;
3050
+ }
3051
+ function re(f) {
3052
+ const p = f.stableKey;
3053
+ if (p && ie.value[p]) {
3054
+ const S = ie.value[p], L = Fe.toFormatString({ value: S.received });
3055
+ return `${r("inventory.transfer.receiveRequest.details.received")} ${L}`;
3056
+ }
3057
+ }
3058
+ const ve = K(
3059
+ () => F.value.map((f, p) => {
3060
+ const S = g.value + p;
3061
+ return K({
3062
+ get: () => {
3063
+ var j;
3064
+ const L = (j = n.received[S]) == null ? void 0 : j.amount;
3065
+ return L ? +$e(L) : 0;
3066
+ },
3067
+ set: (L) => {
3068
+ var we, Y, ee;
3069
+ const j = F.value[p], Oe = ((we = j == null ? void 0 : j.historyItem) == null ? void 0 : we.sku.unit.precision) ?? (j != null && j.skuId ? (ee = (Y = D.skuById[j.skuId]) == null ? void 0 : Y.unit) == null ? void 0 : ee.precision : void 0) ?? 2;
3070
+ n.received[S].amount = We(L, Oe);
3071
+ }
3072
+ });
3073
+ })
3074
+ ), s = K(
3075
+ () => F.value.map((f, p) => {
3076
+ const S = g.value + p;
3077
+ return K({
3078
+ get: () => {
3079
+ var j;
3080
+ const L = (j = n.received[S]) == null ? void 0 : j.cost;
3081
+ return L ? +$e(L) : 0;
3082
+ },
3083
+ set: (L) => {
3084
+ n.received[S].cost = {
3085
+ currency: Ce(),
3086
+ ...We(L, 4)
3087
+ };
3088
+ }
3089
+ });
3090
+ })
3091
+ );
3092
+ function a(f) {
3093
+ const p = F.value[f], S = g.value + f;
3094
+ p.costEnabled = !p.costEnabled, p.costEnabled ? n.received[S].cost = { currency: Ce(), amount: 0, precision: 4 } : delete n.received[S].cost;
3095
+ }
3096
+ function k() {
3097
+ W() && x.open({
3098
+ title: "Confirm Create Delivery Order",
3099
+ message: `Are you sure you want to create delivery order for PO# ${c.purchaseOrder.seqNumber}?`,
3100
+ primaryActions: {
3101
+ text: "Create",
3102
+ close: !0,
3103
+ variant: "primary"
3104
+ },
3105
+ secondaryActions: {
3106
+ text: "Cancel",
3107
+ close: !0
3108
+ }
3109
+ }).onPrimary(() => A());
3110
+ }
3111
+ const C = oe(!1);
3112
+ function A() {
3113
+ W() && (C.value = !0, l.createDeliveryOrder({
3114
+ deliveryOrder: {
3115
+ ...n,
3116
+ priceAdjustments: R.value.state().adjustments
3117
+ },
3118
+ purchaseOrderId: c.purchaseOrder._id,
3119
+ purchaseOrderRev: c.purchaseOrder._rev,
3120
+ currency: Ce()
3121
+ }).then(() => {
3122
+ Q.open(
3123
+ {
3124
+ title: "Success",
3125
+ message: `New delivery order created for PO# ${c.purchaseOrder.seqNumber}`,
3126
+ type: "success"
3127
+ },
3128
+ 1e4
3129
+ ), o.value = !1, d("submitted");
3130
+ }).finally(() => {
3131
+ C.value = !1;
3132
+ }));
3133
+ }
3134
+ function W() {
3135
+ return M.value ? (o.value = !1, Q.open(
3136
+ {
3137
+ title: "Purchase order updated",
3138
+ message: "This purchase order now uses fulfillment receiving. Refresh and receive stock from the fulfillment section.",
3139
+ type: "error"
3140
+ },
3141
+ 1e4
3142
+ ), !1) : !0;
3143
+ }
3144
+ return Qe(M, (f) => {
3145
+ !f || !o.value || W();
3146
+ }), Qe(
3147
+ () => o.value,
3148
+ (f) => {
3149
+ var L;
3150
+ if (!f) {
3151
+ F.value = [], _([]), n.received = ne.value.map((j) => ({
3152
+ ...Ae && j.id ? { id: j.id } : {},
3153
+ sku: j.sku,
3154
+ amount: Fe.fromNumber(0),
3155
+ measurement: j.measurement
3156
+ }));
3157
+ return;
3158
+ }
3159
+ const p = ne.value;
3160
+ for (let j = 0; j < p.length; j++) {
3161
+ const Oe = p[j], Y = (((L = c.purchaseOrder) == null ? void 0 : L.version) ?? je.enum[1]) === je.enum[2] ? Oe.id : Oe.sku._id, ee = c.receivedMap[Y], _e = +$e(Oe.quantity), Pe = ee ? +$e(ee.received) : 0;
3162
+ H.value[j].value = Math.max(0, _e - Pe);
3163
+ }
3164
+ const S = be.value;
3165
+ if (S.length) {
3166
+ for (const j of S) {
3167
+ const Oe = ke(j);
3168
+ F.value.push({
3169
+ skuId: j.sku._id,
3170
+ stableKey: Oe,
3171
+ costEnabled: !1,
3172
+ historyItem: j
3173
+ }), n.received.push({
3174
+ // Propagate the stable id so V2 submissions align with the existing PO line.
3175
+ ...Ae && j.id ? { id: j.id } : {},
3176
+ sku: j.sku,
3177
+ amount: Fe.fromNumber(0),
3178
+ measurement: j.measurement ?? null
3179
+ });
3180
+ }
3181
+ for (let j = 0; j < S.length; j++) {
3182
+ const Oe = ke(S[j]), we = Oe ? ie.value[Oe] : void 0;
3183
+ if (we) {
3184
+ const Y = Math.pow(10, we.remaining.precision ?? 2);
3185
+ ve.value[j].value = Math.max(0, we.remaining.amount / Y);
3186
+ }
3187
+ }
3188
+ }
3189
+ }
3190
+ ), (f, p) => {
3191
+ const S = le("FmButton"), L = le("FmDatePicker"), j = le("FmTimePicker"), Oe = le("FmIcon"), we = le("FmStepperField"), Y = le("FmSwitch"), ee = le("FmSelect"), _e = le("FmTextField"), Pe = le("FmDialog");
3192
+ return i(), he(Pe, {
3193
+ modelValue: o.value,
3194
+ "onUpdate:modelValue": p[4] || (p[4] = (Ie) => o.value = Ie),
3195
+ overlay: !0,
3196
+ "min-width": 800
3197
+ }, {
3198
+ "dialog-button": pe(() => [
3199
+ E.value ? (i(), he(S, {
3200
+ key: 0,
3201
+ variant: "primary",
3202
+ label: "Create",
3203
+ size: "md",
3204
+ "prepend-icon": "add",
3205
+ class: "w-full"
3206
+ })) : V("", !0)
3207
+ ]),
3208
+ "dialog-header": pe(() => [
3209
+ e("div", null, "Order #" + O(c.purchaseOrder.seqNumber) + " (New Delivery Order)", 1)
3210
+ ]),
3211
+ "dialog-footer": pe(() => [
3212
+ q(S, {
3213
+ class: "ml-auto",
3214
+ label: "Create",
3215
+ size: "md",
3216
+ variant: "destructive",
3217
+ disabled: !U.value || C.value,
3218
+ loading: C.value,
3219
+ onClick: k
3220
+ }, null, 8, ["disabled", "loading"])
3221
+ ]),
3222
+ default: pe(() => {
3223
+ var Ie;
3224
+ return [
3225
+ e("div", Zo, [
3226
+ e("div", en, [
3227
+ p[5] || (p[5] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Received by", -1)),
3228
+ e("div", tn, O((Ie = b(m).sessionUser.value) == null ? void 0 : Ie.displayName), 1)
3229
+ ]),
3230
+ b(se) ? (i(), y("div", sn, [
3231
+ e("div", rn, [
3232
+ e("div", on, [
3233
+ p[6] || (p[6] = Xe(" Delivery Date & Time ")),
3234
+ !ye.value && !P.value ? (i(), y("div", nn, " Leave blank to use current date & time ")) : V("", !0)
3235
+ ]),
3236
+ ye.value || P.value ? (i(), he(S, {
3237
+ key: 0,
3238
+ variant: "tertiary",
3239
+ label: "Clear",
3240
+ "prepend-icon": "close",
3241
+ onClick: ue
3242
+ })) : V("", !0)
3243
+ ]),
3244
+ e("div", an, [
3245
+ e("div", ln, [
3246
+ q(L, {
3247
+ modelValue: ye.value,
3248
+ "onUpdate:modelValue": p[0] || (p[0] = (ge) => ye.value = ge)
3249
+ }, null, 8, ["modelValue"])
3250
+ ]),
3251
+ e("div", un, [
3252
+ q(j, {
3253
+ modelValue: P.value,
3254
+ "onUpdate:modelValue": p[1] || (p[1] = (ge) => P.value = ge)
3255
+ }, null, 8, ["modelValue"])
3256
+ ])
3257
+ ]),
3258
+ N.value ? (i(), y("div", cn, [
3259
+ q(Oe, {
3260
+ name: "error",
3261
+ class: "inline-block mr-1",
3262
+ size: "sm"
3263
+ }),
3264
+ e("div", dn, O(N.value), 1)
3265
+ ])) : V("", !0)
3266
+ ])) : V("", !0),
3267
+ e("div", mn, [
3268
+ p[8] || (p[8] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Items going to receive ", -1)),
3269
+ (i(!0), y(De, null, Te(ne.value, (ge, me) => {
3270
+ var Re;
3271
+ return i(), y("div", { key: me }, [
3272
+ e("div", pn, [
3273
+ e("div", fn, [
3274
+ e("span", vn, O(ge.sku.name), 1),
3275
+ e("span", yn, O(ge.sku.code), 1)
3276
+ ]),
3277
+ e("div", hn, [
3278
+ q(we, {
3279
+ label: "Receive Quantity",
3280
+ modelValue: H.value[me].value,
3281
+ "onUpdate:modelValue": (Ee) => H.value[me].value = Ee,
3282
+ "helper-text": Z(ge),
3283
+ "append-text": ((Re = ge.measurement) == null ? void 0 : Re.abbrev) ?? ge.sku.unit.abbrev
3284
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "helper-text", "append-text"]),
3285
+ H.value[me].value <= 0 ? (i(), y("div", bn, O(rs))) : V("", !0),
3286
+ b(te) ? (i(), y("div", gn, [
3287
+ q(Y, {
3288
+ "model-value": J.value[me],
3289
+ "onUpdate:modelValue": (Ee) => de(me),
3290
+ size: "sm"
3291
+ }, null, 8, ["model-value", "onUpdate:modelValue"]),
3292
+ p[7] || (p[7] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Override cost ", -1))
3293
+ ])) : V("", !0),
3294
+ b(te) && J.value[me] ? (i(), he(we, {
3295
+ key: 2,
3296
+ modelValue: xe.value[me].value,
3297
+ "onUpdate:modelValue": (Ee) => xe.value[me].value = Ee,
3298
+ label: "Total Cost",
3299
+ step: 1e-4,
3300
+ min: 0,
3301
+ placeholder: "0.0000",
3302
+ size: "sm",
3303
+ "append-text": b(Ce)()
3304
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text"])) : V("", !0)
3305
+ ])
3306
+ ]),
3307
+ me < ne.value.length - 1 ? (i(), y("div", _n)) : V("", !0)
3308
+ ]);
3309
+ }), 128))
3310
+ ]),
3311
+ e("div", Sn, [
3312
+ e("div", On, [
3313
+ p[9] || (p[9] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Extra items", -1)),
3314
+ q(S, {
3315
+ variant: "tertiary",
3316
+ label: "Add item",
3317
+ "prepend-icon": "add",
3318
+ size: "md",
3319
+ onClick: B
3320
+ })
3321
+ ]),
3322
+ F.value.length === 0 ? (i(), y("div", kn, " No extra items added ")) : V("", !0),
3323
+ (i(!0), y(De, null, Te(F.value, (ge, me) => {
3324
+ var Re, Ee;
3325
+ return i(), y("div", { key: me }, [
3326
+ e("div", xn, [
3327
+ e("div", wn, [
3328
+ q(ee, {
3329
+ "model-value": ge.skuId,
3330
+ "onUpdate:modelValue": (Le) => X(me, Le),
3331
+ label: "Ingredient",
3332
+ items: h.value,
3333
+ searchable: "",
3334
+ searchTarget: "label",
3335
+ placeholder: "Select ingredient",
3336
+ disabled: !!ge.historyItem
3337
+ }, null, 8, ["model-value", "onUpdate:modelValue", "items", "disabled"])
3338
+ ]),
3339
+ e("div", $n, [
3340
+ q(we, {
3341
+ label: "Receive Quantity",
3342
+ modelValue: ve.value[me].value,
3343
+ "onUpdate:modelValue": (Le) => ve.value[me].value = Le,
3344
+ "append-text": ge.skuId ? ((Ee = (Re = b(D).skuById[ge.skuId]) == null ? void 0 : Re.unit) == null ? void 0 : Ee.abbrev) ?? "" : "",
3345
+ "helper-text": re(ge)
3346
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text", "helper-text"]),
3347
+ ve.value[me].value <= 0 ? (i(), y("div", Cn, O(rs))) : V("", !0),
3348
+ b(te) ? (i(), y("div", An, [
3349
+ q(Y, {
3350
+ "model-value": ge.costEnabled,
3351
+ "onUpdate:modelValue": (Le) => a(me),
3352
+ size: "sm"
3353
+ }, null, 8, ["model-value", "onUpdate:modelValue"]),
3354
+ p[10] || (p[10] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Override cost ", -1))
3355
+ ])) : V("", !0),
3356
+ b(te) && ge.costEnabled ? (i(), he(we, {
3357
+ key: 2,
3358
+ modelValue: s.value[me].value,
3359
+ "onUpdate:modelValue": (Le) => s.value[me].value = Le,
3360
+ label: "Total Cost",
3361
+ step: 1e-4,
3362
+ min: 0,
3363
+ placeholder: "0.0000",
3364
+ size: "sm",
3365
+ "append-text": b(Ce)()
3366
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text"])) : V("", !0)
3367
+ ]),
3368
+ ge.historyItem ? V("", !0) : (i(), he(S, {
3369
+ key: 0,
3370
+ variant: "tertiary",
3371
+ "prepend-icon": "delete",
3372
+ size: "md",
3373
+ class: "mt-6",
3374
+ onClick: (Le) => G(me)
3375
+ }, null, 8, ["onClick"]))
3376
+ ]),
3377
+ me < F.value.length - 1 ? (i(), y("div", Nn)) : V("", !0)
3378
+ ]);
3379
+ }), 128))
3380
+ ]),
3381
+ e("div", Dn, [
3382
+ p[11] || (p[11] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Delivery order no.", -1)),
3383
+ e("div", Rn, [
3384
+ q(_e, {
3385
+ modelValue: b(n).deliveryOrderNumber,
3386
+ "onUpdate:modelValue": p[2] || (p[2] = (ge) => b(n).deliveryOrderNumber = ge),
3387
+ size: "md"
3388
+ }, null, 8, ["modelValue"])
3389
+ ])
3390
+ ]),
3391
+ e("div", Pn, [
3392
+ p[12] || (p[12] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Remark", -1)),
3393
+ e("div", Fn, [
3394
+ q(_e, {
3395
+ modelValue: b(n).remark,
3396
+ "onUpdate:modelValue": p[3] || (p[3] = (ge) => b(n).remark = ge),
3397
+ size: "md"
3398
+ }, null, 8, ["modelValue"])
3399
+ ])
3400
+ ]),
3401
+ b(v).enablePurchaseOrderPriceAdjustment ? (i(), he(It, {
3402
+ key: 1,
3403
+ controller: b(R),
3404
+ state: b(T)
3405
+ }, null, 8, ["controller", "state"])) : V("", !0)
3406
+ ])
3407
+ ];
3408
+ }),
3409
+ _: 1
3410
+ }, 8, ["modelValue"]);
3411
+ };
3412
+ }
3413
+ }), Tn = {
3414
+ key: 0,
3415
+ class: "flex flex-col gap-1"
3416
+ }, En = { class: "truncate" }, qn = { class: "shrink-0" }, Vn = /* @__PURE__ */ Ve({
3417
+ __name: "PriceAdjustmentList",
3418
+ props: {
3419
+ adjustments: {}
3420
+ },
3421
+ setup(u) {
3422
+ const t = u, r = K(() => t.adjustments ?? []);
3423
+ function o(m) {
3424
+ const c = m.amount < 0 ? "-" : "+", d = $e({ ...m, amount: Math.abs(m.amount) });
3425
+ return `${c}${m.currency} ${d}`;
3426
+ }
3427
+ return (m, c) => r.value.length ? (i(), y("div", Tn, [
3428
+ (i(!0), y(De, null, Te(r.value, (d) => (i(), y("div", {
3429
+ key: d.id,
3430
+ class: "flex justify-between gap-4 fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
3431
+ }, [
3432
+ e("span", En, O(d.name), 1),
3433
+ e("span", qn, O(o(d.dinero)), 1)
3434
+ ]))), 128))
3435
+ ])) : V("", !0);
3436
+ }
3437
+ }), Ln = { class: "flex flex-col gap-3" }, jn = /* @__PURE__ */ Ve({
3438
+ __name: "PriceAdjustmentEditForm",
3439
+ props: {
3440
+ purchaseOrder: {}
3441
+ },
3442
+ emits: ["submitted"],
3443
+ setup(u, { emit: t }) {
3444
+ const r = u, o = t, m = Ze(), c = Je(), d = oe(!1), n = oe(!1), { controller: l, state: x, reset: v } = Tt({
3445
+ currency: Ce(),
3446
+ adjustments: r.purchaseOrder.priceAdjustments
3447
+ });
3448
+ Qe(
3449
+ () => d.value,
3450
+ (R) => {
3451
+ R && v(r.purchaseOrder.priceAdjustments);
3452
+ }
3453
+ );
3454
+ function D() {
3455
+ n.value = !0, m.updatePurchaseOrder({
3456
+ ...r.purchaseOrder,
3457
+ priceAdjustments: l.value.state().adjustments
3458
+ }).then(() => {
3459
+ c.open(
3460
+ {
3461
+ title: "Success",
3462
+ message: `PO# ${r.purchaseOrder.seqNumber} price adjustments saved`,
3463
+ type: "success"
3464
+ },
3465
+ 1e4
3466
+ ), d.value = !1, o("submitted");
3467
+ }).finally(() => {
3468
+ n.value = !1;
3469
+ });
3470
+ }
3471
+ return (R, T) => {
3472
+ const _ = le("FmButton"), M = le("FmDialog");
3473
+ return i(), he(M, {
3474
+ modelValue: d.value,
3475
+ "onUpdate:modelValue": T[0] || (T[0] = (E) => d.value = E),
3476
+ overlay: !0,
3477
+ "min-width": 600
3478
+ }, {
3479
+ "dialog-button": pe(() => [
3480
+ q(_, {
3481
+ variant: "plain",
3482
+ label: "Edit price adjustments",
3483
+ size: "md",
3484
+ "prepend-icon": "edit"
3485
+ })
3486
+ ]),
3487
+ "dialog-header": pe(() => [
3488
+ e("div", null, "Price adjustments — PO# " + O(r.purchaseOrder.seqNumber), 1)
3489
+ ]),
3490
+ "dialog-footer": pe(() => [
3491
+ q(_, {
3492
+ class: "ml-auto",
3493
+ label: "Apply changes",
3494
+ size: "md",
3495
+ variant: "destructive",
3496
+ disabled: n.value,
3497
+ loading: n.value,
3498
+ onClick: D
3499
+ }, null, 8, ["disabled", "loading"])
3500
+ ]),
3501
+ default: pe(() => [
3502
+ e("div", Ln, [
3503
+ q(It, {
3504
+ controller: b(l),
3505
+ state: b(x)
3506
+ }, null, 8, ["controller", "state"])
3507
+ ])
3508
+ ]),
3509
+ _: 1
3510
+ }, 8, ["modelValue"]);
3511
+ };
3512
+ }
3513
+ }), Un = { class: "flex flex-row-reverse" }, Mn = {
3514
+ key: 0,
3515
+ class: "flex"
3516
+ }, Bn = {
3517
+ key: 1,
3518
+ class: "border-t pt-6"
3519
+ }, zn = { class: "fm-typo-en-body-lg-600 mb-4 flex items-center gap-2" }, Kn = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg overflow-y-auto" }, Hn = { class: "w-full" }, Gn = {
3520
+ class: "p-3 fm-typo-en-body-sm-600",
3521
+ style: { "min-width": "130px" }
3522
+ }, Wn = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Qn = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Yn = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Jn = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Xn = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Zn = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, ea = { class: "p-3 fm-typo-en-body-sm-600" }, ta = { key: 2 }, sa = /* @__PURE__ */ Ve({
3523
+ __name: "NetSuiteTransactionChangeLog",
3524
+ props: {
3525
+ netsuiteId: {}
3526
+ },
3527
+ setup(u) {
3528
+ const t = u, r = Ft(), o = oe(!1), m = oe(!1), c = oe(!1), d = oe([]);
3529
+ async function n() {
3530
+ if (!(d.value.length > 0))
3531
+ try {
3532
+ m.value = !0;
3533
+ const v = await r.getChangeLogs(t.netsuiteId);
3534
+ d.value = v, c.value = !1;
3535
+ } catch {
3536
+ c.value = !0;
3537
+ } finally {
3538
+ m.value = !1;
3539
+ }
3540
+ }
3541
+ function l(v) {
3542
+ switch (v) {
3543
+ case Me.Create:
3544
+ return "text-green-600 bg-green-100";
3545
+ case Me.Set:
3546
+ return "text-blue-600 bg-blue-100";
3547
+ case Me.Change:
3548
+ return "text-yellow-600 bg-yellow-100";
3549
+ case Me.Unset:
3550
+ return "text-red-600 bg-red-100";
3551
+ default:
3552
+ return "text-gray-600 bg-gray-100";
3553
+ }
3554
+ }
3555
+ function x(v) {
3556
+ return new Date(v).toLocaleDateString("en-US", {
3557
+ year: "numeric",
3558
+ month: "short",
3559
+ day: "numeric",
3560
+ hour: "2-digit",
3561
+ minute: "2-digit"
3562
+ });
3563
+ }
3564
+ return (v, D) => {
3565
+ const R = le("FmButton"), T = le("FmCircularProgress"), _ = le("FmIcon"), M = le("FmDialog");
3566
+ return i(), y("div", Un, [
3567
+ q(M, {
3568
+ modelValue: o.value,
3569
+ "onUpdate:modelValue": D[2] || (D[2] = (E) => o.value = E),
3570
+ overlay: !0,
3571
+ "max-width": 800
3572
+ }, {
3573
+ "dialog-button": pe(() => [
3574
+ q(R, {
3575
+ "prepend-icon": "info",
3576
+ variant: "secondary",
3577
+ label: "NetSuite",
3578
+ onClick: D[0] || (D[0] = (E) => n()),
3579
+ "text-color": "primary",
3580
+ "bg-color": "transparent",
3581
+ "border-color": "primary"
3582
+ })
3583
+ ]),
3584
+ "dialog-header": pe(() => D[3] || (D[3] = [
3585
+ e("div", null, "NetSuite info", -1)
3586
+ ])),
3587
+ default: pe(() => [
3588
+ m.value ? (i(), y("div", Mn, [
3589
+ D[4] || (D[4] = e("span", null, "Change Log Loading...", -1)),
3590
+ q(T, { size: "md" })
3591
+ ])) : V("", !0),
3592
+ !m.value && d.value.length > 0 ? (i(), y("div", Bn, [
3593
+ e("h3", zn, [
3594
+ q(_, {
3595
+ name: "error",
3596
+ color: "#ff9500",
3597
+ size: "sm"
3598
+ }),
3599
+ D[5] || (D[5] = Xe(" Change Logs "))
3600
+ ]),
3601
+ e("div", Kn, [
3602
+ e("table", Hn, [
3603
+ D[6] || (D[6] = e("thead", { class: "bg-fm-color-neutral-gray-50" }, [
3604
+ e("tr", { class: "border-b border-fm-color-neutral-gray-200" }, [
3605
+ e("th", {
3606
+ class: "text-left p-3 fm-typo-en-body-md-600",
3607
+ style: { "min-width": "130px" }
3608
+ }, " Date "),
3609
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Role"),
3610
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Name"),
3611
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Context"),
3612
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Type"),
3613
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Line ID"),
3614
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Field"),
3615
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Old Value"),
3616
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "New Value")
3617
+ ])
3618
+ ], -1)),
3619
+ e("tbody", null, [
3620
+ (i(!0), y(De, null, Te(d.value, (E, te) => (i(), y("tr", {
3621
+ key: te,
3622
+ class: "border-b border-fm-color-neutral-gray-200 last:border-b-0"
3623
+ }, [
3624
+ e("td", Gn, O(x(E._dateiso8601)), 1),
3625
+ e("td", Wn, O(E._rolename), 1),
3626
+ e("td", Qn, O(E._employeename), 1),
3627
+ e("td", Yn, O(E._contextname), 1),
3628
+ e("td", {
3629
+ class: Ge(`p-3 fm-typo-en-body-sm-600 ${l(Number(E.type) - 1)}`)
3630
+ }, O(b(Me)[Number(E.type) - 1]), 3),
3631
+ e("td", Jn, O(E.lineid || ""), 1),
3632
+ e("td", Xn, O(E._fieldname), 1),
3633
+ e("td", Zn, O(E.oldvalue || ""), 1),
3634
+ e("td", ea, O(E.newvalue || ""), 1)
3635
+ ]))), 128))
3636
+ ])
3637
+ ])
3638
+ ])
3639
+ ])) : (i(), y("div", ta, D[7] || (D[7] = [
3640
+ e("p", null, "No change logs available.", -1)
3641
+ ])))
3642
+ ]),
3643
+ "dialog-footer": pe(() => [
3644
+ q(R, {
3645
+ class: "ml-auto sm:w-full xs:w-full",
3646
+ label: "Close",
3647
+ size: "md",
3648
+ variant: "primary",
3649
+ onClick: D[1] || (D[1] = (E) => o.value = !1)
3650
+ })
3651
+ ]),
3652
+ _: 1
3653
+ }, 8, ["modelValue"])
3654
+ ]);
3655
+ };
3656
+ }
3657
+ }), ra = { class: "flex flex-col w-full gap-3" }, oa = { class: "flex" }, na = { class: "fm-typo-en-title-md-600 text-fm-color-typo-primary" }, aa = { class: "flex flex-col gap-16 w-full h-full" }, la = { class: "flex justify-between" }, ia = { class: "fm-typo-en-body-lg-600" }, ua = { class: "flex gap-2" }, ca = {
3658
+ key: 0,
3659
+ class: "flex items-center gap-1"
3660
+ }, da = { class: "fm-typo-en-body-md-400" }, ma = { class: "flex flex-col gap-8" }, pa = {
3661
+ key: 0,
3662
+ class: "flex items-start justify-between gap-6"
3663
+ }, fa = { class: "text-xs font-mono text-right break-all" }, va = {
3664
+ key: 1,
3665
+ class: "flex items-start justify-between gap-6"
3666
+ }, ya = { class: "fm-typo-en-body-sm-600" }, ha = {
3667
+ key: 2,
3668
+ class: "flex items-start justify-between gap-6"
3669
+ }, ba = { class: "text-xs font-mono text-right break-all" }, ga = {
3670
+ key: 3,
3671
+ class: "flex items-start justify-between gap-6"
3672
+ }, _a = { class: "text-xs font-mono text-right break-all" }, Sa = { class: "flex flex-col gap-4" }, Oa = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ka = { class: "flex gap-1" }, xa = { class: "fm-typo-en-body-lg-600" }, wa = {
3673
+ key: 0,
3674
+ class: "flex flex-col gap-4"
3675
+ }, $a = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ca = { class: "fm-typo-en-body-lg-600" }, Aa = { class: "flex flex-col gap-4" }, Na = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Da = { class: "fm-typo-en-body-lg-600" }, Ra = {
3676
+ key: 1,
3677
+ class: "flex flex-col gap-4"
3678
+ }, Pa = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Fa = { class: "fm-typo-en-body-lg-600" }, Ia = {
3679
+ key: 2,
3680
+ class: "flex flex-col gap-4"
3681
+ }, Ta = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ea = { class: "fm-typo-en-body-lg-600" }, qa = {
3682
+ key: 3,
3683
+ class: "flex flex-col gap-4"
3684
+ }, Va = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, La = { class: "fm-typo-en-body-lg-600" }, ja = {
3685
+ key: 4,
3686
+ class: "flex flex-col gap-4"
3687
+ }, Ua = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ma = { class: "fm-typo-en-body-lg-600" }, Ba = {
3688
+ key: 5,
3689
+ class: "flex flex-col gap-4"
3690
+ }, za = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ka = { class: "fm-typo-en-body-lg-600" }, Ha = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, Ga = { class: "flex flex-col gap-8" }, Wa = { class: "flex gap-8 items-center" }, Qa = { class: "flex-1 fm-typo-en-body-lg-600" }, Ya = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary flex flex-col gap-4" }, Ja = { class: "flex w-full gap-4" }, Xa = { class: "basis-1/2 shrink-0 grow min-w-0 fm-typo-en-body-lg-400 flex items-start gap-2" }, Za = { class: "min-w-0 flex-1 line-clamp-2" }, el = {
3691
+ key: 0,
3692
+ class: "shrink-0"
3693
+ }, tl = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary flex flex-col gap-2" }, sl = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, rl = ["innerHTML"], ol = { class: "flex w-full gap-4 fm-typo-en-body-sm-400" }, nl = { class: "grow fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-1" }, al = { class: "flex items-center gap-4" }, ll = { class: "line-clamp-1 fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, il = {
3694
+ key: 0,
3695
+ class: "inline-flex items-center gap-1 text-xs font-medium text-gray-500 bg-gray-100 px-2 py-0.5 rounded-full"
3696
+ }, ul = { key: 0 }, cl = { class: "py-8" }, dl = { class: "flex justify-end gap-4 items-center" }, ml = { class: "fm-typo-en-body-lg-600" }, pl = {
3697
+ key: 0,
3698
+ class: "flex justify-end"
3699
+ }, fl = {
3700
+ key: 1,
3701
+ class: "flex-1 xs:w-screen xs:max-w-full"
3702
+ }, vl = {
3703
+ key: 0,
3704
+ class: "flex flex-col items-center gap-8 h-full"
3705
+ }, yl = ["src"], hl = { class: "fm-typo-en-body-lg-600" }, bl = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary px-16" }, gl = {
3706
+ key: 1,
3707
+ class: "px-4 flex flex-col"
3708
+ }, _l = { class: "flex gap-12 content-stretch" }, Sl = {
3709
+ class: "flex flex-col w-40",
3710
+ name: "circles"
3711
+ }, Ol = { class: "flex-1 flex flex-col items-center" }, kl = { class: "h-40 w-40 bg-fm-color-primary rounded-full flex items-center justify-center" }, xl = { class: "flex-1 flex flex-col items-center" }, wl = { class: "flex w-full items-center gap-4" }, $l = {
3712
+ class: "py-12 flex flex-col gap-4",
3713
+ name: "received-at header"
3714
+ }, Cl = { class: "fm-typo-en-body-lg-400" }, Al = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Nl = { class: "ml-auto flex gap-1" }, Dl = { class: "flex gap-12 content-stretch" }, Rl = {
3715
+ class: "flex flex-col w-40",
3716
+ name: "circles"
3717
+ }, Pl = { class: "flex-1 flex flex-col items-center" }, Fl = {
3718
+ class: "py-12 flex flex-col gap-4 flex-1",
3719
+ name: "delivery details"
3720
+ }, Il = { class: "flex flex-col gap-8" }, Tl = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, El = { class: "flex flex-col gap-4" }, ql = {
3721
+ key: 2,
3722
+ class: "flex-1 xs:w-screen xs:max-w-full"
3723
+ }, Vl = {
3724
+ key: 0,
3725
+ class: "flex flex-col items-center gap-8 h-full"
3726
+ }, Ll = ["src"], jl = { class: "fm-typo-en-body-lg-600" }, Ul = {
3727
+ key: 1,
3728
+ class: "px-4 flex flex-col gap-12"
3729
+ }, Ml = { class: "flex flex-col gap-4" }, Bl = { class: "flex justify-between gap-8" }, zl = { class: "fm-typo-en-body-lg-600" }, Kl = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary whitespace-nowrap" }, Hl = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Gl = {
3730
+ key: 0,
3731
+ class: "fm-typo-en-body-md-400"
3732
+ }, Wl = { class: "flex gap-8 xs:flex-col" }, wi = /* @__PURE__ */ Ve({
3733
+ __name: "TransferDetails",
3734
+ props: {
3735
+ poRequest: {},
3736
+ purchaseOrder: {},
3737
+ transferTo: {},
3738
+ transferToDbName: {},
3739
+ show: { type: Boolean },
3740
+ canResubmit: { type: Boolean },
3741
+ canApprove: { type: Boolean },
3742
+ scope: {},
3743
+ receivedMap: {},
3744
+ shipments: {}
3745
+ },
3746
+ emits: ["update:show", "submitted"],
3747
+ setup(u, { emit: t }) {
3748
+ const r = u, o = t, m = gt(), c = Je(), d = Ye(), n = ze(), l = bt(), { hasOrderDraftPermission: x } = _s(), v = bs();
3749
+ function D(s) {
3750
+ const a = s.isCustomCost, k = s.totalCost;
3751
+ return a != null ? a === !0 : k != null;
3752
+ }
3753
+ Qe(
3754
+ () => r.purchaseOrder,
3755
+ (s) => {
3756
+ v.init(s);
3757
+ },
3758
+ { immediate: !0 }
3759
+ );
3760
+ const R = K(
3761
+ () => {
3762
+ var s, a;
3763
+ return {
3764
+ id: ((s = l.sessionUser.value) == null ? void 0 : s.id) ?? "",
3765
+ name: ((a = l.sessionUser.value) == null ? void 0 : a.displayName) ?? ""
3766
+ };
3767
+ }
3768
+ ), T = gs(), { t: _ } = ht(), M = K(
3769
+ () => {
3770
+ var s, a, k, C;
3771
+ return ((a = (s = r.purchaseOrder) == null ? void 0 : s.supplier) == null ? void 0 : a.internal) === "restaurant" || ((C = (k = r.purchaseOrder) == null ? void 0 : k.supplier) == null ? void 0 : C.internal) === "warehouse" ? at.enum.transfer : at.enum.purchase;
3772
+ }
3773
+ ), E = K(() => {
3774
+ var k;
3775
+ const s = (k = r.shipments) == null ? void 0 : k.find((C) => {
3776
+ var A;
3777
+ return C.ref === ((A = r.purchaseOrder) == null ? void 0 : A._id);
3778
+ });
3779
+ let a = null;
3780
+ if (s != null && s.milestones && s.milestones.length > 0) {
3781
+ const C = s.milestones[s.milestones.length - 1];
3782
+ if (C.estimatedTime) {
3783
+ const A = new Date(C.estimatedTime), W = A.getDate().toString().padStart(2, "0");
3784
+ a = `${A.toLocaleString("en-US", { month: "short" })} ${W}`;
3785
+ }
3786
+ }
3787
+ return a;
3788
+ }), te = oe(!1), se = oe(""), J = oe(!0), ne = Ze(), be = Cr(ne.getWorkflowConfig), ie = vs(), ke = [
3789
+ z.enum.receiveStock,
3790
+ z.enum.processRequest,
3791
+ z.enum.closeRequest
3792
+ ], Ae = K(() => {
3793
+ var ce, f, p, S, L, j, Oe, we, Y;
3794
+ if (!r.purchaseOrder)
3795
+ return [];
3796
+ const s = be.result.value;
3797
+ if (s.state === Nt.loading)
3798
+ return [];
3799
+ let a;
3800
+ const k = as.safeParse(r.purchaseOrder);
3801
+ if (k.success)
3802
+ a = k.data;
3803
+ else {
3804
+ const ee = /* @__PURE__ */ new Set(["1", "2"]), _e = { line1: "", state: "", city: "", postcode: "", country: "" };
3805
+ a = {
3806
+ _id: ((ce = r.purchaseOrder) == null ? void 0 : ce._id) ?? "",
3807
+ status: ((f = r.purchaseOrder) == null ? void 0 : f.status) ?? Se.enum.DRAFT,
3808
+ version: ee.has((p = r.purchaseOrder) == null ? void 0 : p.version) ? (S = r.purchaseOrder) == null ? void 0 : S.version : null,
3809
+ seqNumber: typeof ((L = r.purchaseOrder) == null ? void 0 : L.seqNumber) == "number" ? r.purchaseOrder.seqNumber : 0,
3810
+ supplier: {
3811
+ _id: ((Oe = (j = r.purchaseOrder) == null ? void 0 : j.supplier) == null ? void 0 : Oe._id) ?? "",
3812
+ name: ((Y = (we = r.purchaseOrder) == null ? void 0 : we.supplier) == null ? void 0 : Y.name) ?? "",
3813
+ address: _e
3814
+ },
3815
+ items: [],
3816
+ deliveryOrder: []
3817
+ };
3818
+ }
3819
+ const C = {
3820
+ user: R.value,
3821
+ executedAt: n.locations.computeFirst(
3822
+ (ee) => {
3823
+ var _e;
3824
+ return ee.dbName === ((_e = n._currentLocation) == null ? void 0 : _e.dbName) ? ee : null;
3825
+ }
3826
+ ),
3827
+ // Strip purchaseOrder and netSuite from the POR before passing to the Dart
3828
+ // bridge — both can carry legacy PO snapshots with "" fields that fail the
3829
+ // bridge's unguarded `as Map<String,dynamic>` casts. Also validate the POR
3830
+ // itself through Zod first: legacy PORs can have null required string fields
3831
+ // (e.g. purchaseOrderId, from.dbName) that cause Dart's _asString to throw.
3832
+ // The workflow engine only needs from/to/processedAt/rejectedAt — passing
3833
+ // null for an unvalidatable POR yields the same available actions.
3834
+ purchaseOrderRequest: (() => {
3835
+ if (r.poRequest == null) return r.poRequest;
3836
+ const ee = Ls.safeParse(r.poRequest);
3837
+ return ee.success ? { ...ee.data, purchaseOrder: null, netSuite: null } : null;
3838
+ })(),
3839
+ purchaseOrder: a
3840
+ }, A = d.useOperatePurchaseOrderV2, W = d.poWorkflowAllowToMarkCompleted, fe = [...ke];
3841
+ A && !W && fe.push(z.enum.completeReceive);
3842
+ let I = [];
3843
+ try {
3844
+ s.state === Nt.error ? (console.error("Error fetching workflow config:", s.error), I = St.getAvailableActions({
3845
+ ...C,
3846
+ orderConfig: St.getDefaultConfig()
3847
+ }).actions.filter((ee) => !fe.includes(ee))) : I = St.getAvailableActions({
3848
+ ...C,
3849
+ orderConfig: s.data
3850
+ }).actions.filter((ee) => !fe.includes(ee));
3851
+ } catch (ee) {
3852
+ console.error("Error getting available actions:", ee);
3853
+ }
3854
+ return r.scope === "approval" && (I = I.filter((ee) => ee !== z.enum.completeReceive)), x.value || (I = I.filter(
3855
+ (ee) => ee !== z.enum.approveDraft && ee !== z.enum.rejectDraft
3856
+ )), I;
3857
+ }), Q = Ks(r, "show"), ye = K(() => [
3858
+ {
3859
+ label: _("inventory.transfer.receiveRequest.details.overview"),
3860
+ value: "overview"
3861
+ },
3862
+ {
3863
+ label: _("inventory.transfer.receiveRequest.details.deliveryHistory"),
3864
+ value: "deliveryHistory"
3865
+ },
3866
+ {
3867
+ label: _("inventory.transfer.receiveRequest.details.actionLogs"),
3868
+ value: "actionLogs"
3869
+ }
3870
+ ]), P = oe(ye.value[0]);
3871
+ Qe(
3872
+ () => r.show,
3873
+ (s) => {
3874
+ s && (P.value = ye.value[0]);
3875
+ }
3876
+ );
3877
+ function w(s) {
3878
+ return s.map((a) => ({
3879
+ ...a,
3880
+ amount: {
3881
+ ...a.amount,
3882
+ amount: -Math.abs(a.amount.amount)
3883
+ }
3884
+ }));
3885
+ }
3886
+ async function $(s, a, k, C, A) {
3887
+ return new Promise((W, fe) => {
3888
+ const I = {
3889
+ closeButton: !1,
3890
+ title: C.title,
3891
+ message: C.message,
3892
+ primaryActions: C.primaryActions,
3893
+ secondaryActions: { text: "No", close: !1 }
3894
+ };
3895
+ let ce = a.rejectReason ?? "";
3896
+ k === z.enum.rejectDraft && (I.contentComponent = fs, I.contentComponentProps = {
3897
+ message: C.message,
3898
+ onChange: (f) => {
3899
+ ce = f ?? "";
3900
+ }
3901
+ }), m.open(I).onPrimary(async () => {
3902
+ var p, S, L, j;
3903
+ const f = [];
3904
+ k === z.enum.confirmDraft || k === z.enum.submitRequest ? f.push({
3905
+ action: "confirmDraft",
3906
+ payload: v.controller.value.toConfirmDraftData(Ce())
3907
+ }) : k === z.enum.approveRequest ? (f.push({
3908
+ action: "approveRequest",
3909
+ payload: null
3910
+ }), a.fulfillment && f.push({
3911
+ action: "processRequest",
3912
+ payload: {
3913
+ fulfillmentId: "",
3914
+ deliveryOrderNumber: "",
3915
+ deliveryRemark: null,
3916
+ items: w(a.fulfillment.items),
3917
+ createdBy: R.value
3918
+ }
3919
+ })) : k === z.enum.processRequest ? a.fulfillment && f.push({
3920
+ action: "processRequest",
3921
+ payload: {
3922
+ fulfillmentId: "",
3923
+ deliveryOrderNumber: "",
3924
+ deliveryRemark: null,
3925
+ items: w(a.fulfillment.items),
3926
+ createdBy: R.value
3927
+ }
3928
+ }) : k === z.enum.rejectRequest ? f.push({
3929
+ action: "rejectRequest",
3930
+ payload: null
3931
+ }) : k === z.enum.closeRequest ? f.push({
3932
+ action: "closeRequest",
3933
+ payload: null
3934
+ }) : k === z.enum.rejectDraft && f.push({
3935
+ action: "rejectDraft",
3936
+ payload: {
3937
+ rejectReason: ce ?? ""
3938
+ }
3939
+ });
3940
+ try {
3941
+ await ie({
3942
+ operate: {
3943
+ operation: k,
3944
+ doc: s,
3945
+ options: a
3946
+ },
3947
+ operateV2: {
3948
+ _id: ((p = r.purchaseOrder) == null ? void 0 : p._id) ?? "",
3949
+ _rev: ((S = r.purchaseOrder) == null ? void 0 : S._rev) ?? "",
3950
+ action: k === z.enum.submitRequest ? z.enum.confirmDraft : k,
3951
+ payloads: f
3952
+ // add payload if action is receiveStock or processRequest
3953
+ },
3954
+ transferTo: (j = (L = r.poRequest) == null ? void 0 : L.to) == null ? void 0 : j.dbName
3955
+ }).delayed(1e3), W("submitted");
3956
+ } catch (Oe) {
3957
+ fe(Oe);
3958
+ }
3959
+ }).onSecondary(() => {
3960
+ W("cancelled");
3961
+ for (let f = 0; f < A + 2; f++)
3962
+ m.close();
3963
+ }).onClose(() => {
3964
+ });
3965
+ });
3966
+ }
3967
+ async function N(s) {
3968
+ var A, W, fe, I;
3969
+ if (s === z.enum.receiveStock)
3970
+ return;
3971
+ const a = ps[s];
3972
+ if (!a) {
3973
+ c.open({
3974
+ title: "Something went wrong",
3975
+ message: `Cannot process order: ${Rt(s)}`,
3976
+ type: "error"
3977
+ });
3978
+ return;
3979
+ }
3980
+ const { successMessage: k, ...C } = a;
3981
+ if (r.purchaseOrder) {
3982
+ se.value = `${s}`, te.value = !0, J.value = !1;
3983
+ const ce = {};
3984
+ let f = 0;
3985
+ if ((s === z.enum.confirmDraft || // auto receive for warehouse to warehouse
3986
+ s === z.enum.completeReceive) && d.autoReceiveWarehouse)
3987
+ ce.autoReceive = !0;
3988
+ else if ((s === z.enum.approveRequest || s === z.enum.processRequest) && d.acceptRequireFulfillment) {
3989
+ const p = (W = (A = r.poRequest) == null ? void 0 : A.from) == null ? void 0 : W.dbName, S = (I = (fe = r.poRequest) == null ? void 0 : fe.to) == null ? void 0 : I.dbName;
3990
+ if (p && S && (p.startsWith("warehouse_") || S.startsWith("warehouse_"))) {
3991
+ const L = await new Promise((j, Oe) => {
3992
+ m.open({
3993
+ closeButton: !1,
3994
+ title: "Confirm transfer amount",
3995
+ dialogComponent: $r,
3996
+ dialogComponentProps: {
3997
+ purchaseOrder: r.purchaseOrder,
3998
+ confirm: j,
3999
+ "onUpdate:show": (we) => {
4000
+ we || (se.value = "", te.value = !1, J.value = !0, f++, m.close()), Oe("cancelled");
4001
+ }
4002
+ }
4003
+ });
4004
+ });
4005
+ ce.fulfillment = L;
4006
+ }
4007
+ }
4008
+ try {
4009
+ await $(
4010
+ r.purchaseOrder,
4011
+ ce,
4012
+ s,
4013
+ a,
4014
+ f
4015
+ ) === "submitted" && (c.open({
4016
+ title: "Success",
4017
+ message: k,
4018
+ type: "success"
4019
+ }), o("update:show", !1), o("submitted"));
4020
+ } catch (p) {
4021
+ c.open({
4022
+ title: "Something went wrong",
4023
+ message: p instanceof Error ? p.message : "Please try again.",
4024
+ type: "error"
4025
+ }), console.error("Error when submitting PO operation", s, r.purchaseOrder, p);
4026
+ } finally {
4027
+ se.value = "", te.value = !1, J.value = !0;
4028
+ }
4029
+ }
4030
+ }
4031
+ const U = K(() => {
4032
+ var s, a;
4033
+ return ((s = r.purchaseOrder) == null ? void 0 : s.status) === Se.enum.RECEIVING || ((a = r.purchaseOrder) == null ? void 0 : a.status) === Se.enum.COMPLETE;
4034
+ }), Z = K(() => r.purchaseOrder ? vt(r.purchaseOrder) : {}), ue = K(() => {
4035
+ const s = r.purchaseOrder;
4036
+ if (!s) return { status: "", statusClass: "" };
4037
+ const { partial: a, over: k } = $t(Z.value), C = Ct(s.status, a, k);
4038
+ let A = _(`inventory.transfer.status.${C}`), W = `${s.status}`.toLocaleLowerCase("en-us");
4039
+ return C === Se.enum.CLOSE && (A = `${_(`inventory.transfer.status.${Se.enum.COMPLETE}`)}`), C === "PARTIAL_RECEIVED" && W === Se.enum.PROCESSING.toLocaleLowerCase("en-us") && (W = Se.enum.RECEIVING.toLocaleLowerCase("en-us")), {
4040
+ status: A,
4041
+ statusClass: `fm-status-badge fm-status-badge-${W}`
4042
+ };
4043
+ }), H = K(() => {
4044
+ var W, fe;
4045
+ const s = ((W = r.purchaseOrder) == null ? void 0 : W.deliveryOrder) ?? [], a = ((fe = r.purchaseOrder) == null ? void 0 : fe.deliveryFullfillment) ?? [], k = [
4046
+ ...s.map((I) => ({
4047
+ createdAt: I.createdAt,
4048
+ type: "grn",
4049
+ doc: I
4050
+ })),
4051
+ ...a.map((I) => ({
4052
+ createdAt: I.createdAt,
4053
+ type: "fulfillment",
4054
+ doc: I
4055
+ }))
4056
+ ];
4057
+ k.reverse().sort((I, ce) => I.createdAt.localeCompare(ce.createdAt));
4058
+ function C(I) {
4059
+ var p, S, L, j, Oe, we, Y, ee, _e, Pe, Ie, ge;
4060
+ const ce = a.findIndex((me) => me.id === I.fullfillmentId), f = [
4061
+ (S = (p = a[ce]) == null ? void 0 : p.netSuite) != null && S.id ? {
4062
+ label: "Fulfillment's ref no. (Netsuite)",
4063
+ values: [
4064
+ `${((j = (L = a[ce]) == null ? void 0 : L.netSuite) == null ? void 0 : j.refNo) ?? "N/A"} (${((we = (Oe = a[ce]) == null ? void 0 : Oe.netSuite) == null ? void 0 : we.id) ?? "-"})`
4065
+ ]
4066
+ } : null,
4067
+ (Y = I == null ? void 0 : I.netSuite) != null && Y.id ? {
4068
+ label: "Netsuite ref no.",
4069
+ values: [`${((ee = I == null ? void 0 : I.netSuite) == null ? void 0 : ee.refNo) ?? "N/A"} (${((_e = I == null ? void 0 : I.netSuite) == null ? void 0 : _e.id) ?? "-"})`]
4070
+ } : null,
4071
+ (Pe = I == null ? void 0 : I.netSuite) != null && Pe.recordType ? {
4072
+ label: "Netsuite Type",
4073
+ values: [ls((Ie = I == null ? void 0 : I.netSuite) == null ? void 0 : Ie.recordType)]
4074
+ } : null
4075
+ ];
4076
+ return {
4077
+ header: "Received",
4078
+ deliveryOrder: I,
4079
+ date: et(new Date(I.createdAt)),
4080
+ info: [
4081
+ {
4082
+ label: "Adjustment date",
4083
+ values: [
4084
+ I.adjustment ? et(new Date(mt(I.adjustment))) : "-"
4085
+ ]
4086
+ },
4087
+ {
4088
+ label: "Received by",
4089
+ values: [(ge = I.createdBy) == null ? void 0 : ge.name]
4090
+ },
4091
+ {
4092
+ label: "Received items",
4093
+ values: I.received.map((me) => {
4094
+ var Re;
4095
+ return ae("div", [
4096
+ ae(
4097
+ "div",
4098
+ {
4099
+ class: "flex gap-4"
4100
+ },
4101
+ [
4102
+ ae(
4103
+ "div",
4104
+ {
4105
+ class: "flex flex-col"
4106
+ },
4107
+ [
4108
+ ae(
4109
+ "span",
4110
+ {
4111
+ class: "fm-typo-en-body-lg-800 basis-1/2 shrink-0 grow"
4112
+ },
4113
+ `${me.sku.name}`
4114
+ ),
4115
+ ae(
4116
+ "span",
4117
+ {
4118
+ class: "fm-typo-en-body-md-400"
4119
+ },
4120
+ `${me.sku.code} `
4121
+ )
4122
+ ]
4123
+ ),
4124
+ ae(
4125
+ "div",
4126
+ {
4127
+ class: "ml-auto flex flex-col"
4128
+ },
4129
+ [
4130
+ ae(
4131
+ "div",
4132
+ {
4133
+ class: "ml-auto flex gap-1"
4134
+ },
4135
+ [
4136
+ ae(
4137
+ "span",
4138
+ {
4139
+ class: "fm-typo-en-body-lg-600 self-end"
4140
+ },
4141
+ $e(me.amount, !1)
4142
+ ),
4143
+ ae(
4144
+ "span",
4145
+ {
4146
+ class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
4147
+ },
4148
+ ((Re = me.measurement) == null ? void 0 : Re.abbrev) ?? me.sku.unit.abbrev
4149
+ )
4150
+ ]
4151
+ ),
4152
+ ae(
4153
+ "div",
4154
+ {
4155
+ class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary"
4156
+ },
4157
+ `${me.cost ? `(${ut(me.cost)})` : ""}`
4158
+ )
4159
+ ]
4160
+ )
4161
+ ]
4162
+ )
4163
+ ]);
4164
+ })
4165
+ },
4166
+ {
4167
+ label: "Delivery order no.",
4168
+ values: [I.deliveryOrderNumber || "N/A"]
4169
+ },
4170
+ {
4171
+ label: "Remark",
4172
+ values: [I.remark || "N/A"]
4173
+ },
4174
+ ce > -1 ? {
4175
+ label: "Fulfilment's sequence",
4176
+ values: [`${ce + 1}`]
4177
+ } : null,
4178
+ ...f
4179
+ ].filter((me) => !!me)
4180
+ };
4181
+ }
4182
+ function A(I) {
4183
+ var f, p, S;
4184
+ const ce = a.findIndex((L) => L.id === I.id);
4185
+ return {
4186
+ header: "Fulfillment",
4187
+ date: et(new Date(I.createdAt)),
4188
+ info: [
4189
+ {
4190
+ label: "Sequence",
4191
+ values: [String(ce + 1)]
4192
+ },
4193
+ {
4194
+ label: "Receiveable items",
4195
+ values: I.items.map((L) => {
4196
+ var j;
4197
+ return ae("div", [
4198
+ ae(
4199
+ "div",
4200
+ {
4201
+ class: "flex gap-4"
4202
+ },
4203
+ [
4204
+ ae(
4205
+ "div",
4206
+ {
4207
+ class: "flex flex-col"
4208
+ },
4209
+ [
4210
+ ae(
4211
+ "span",
4212
+ {
4213
+ class: "fm-typo-en-body-lg-800 basis-1/2 shrink-0 grow"
4214
+ },
4215
+ `${L.sku.name}`
4216
+ ),
4217
+ ae(
4218
+ "span",
4219
+ {
4220
+ class: "fm-typo-en-body-md-400"
4221
+ },
4222
+ `${L.sku.code} `
4223
+ )
4224
+ ]
4225
+ ),
4226
+ ae(
4227
+ "div",
4228
+ {
4229
+ class: "ml-auto flex flex-col"
4230
+ },
4231
+ [
4232
+ ae(
4233
+ "div",
4234
+ {
4235
+ class: "ml-auto flex gap-1"
4236
+ },
4237
+ [
4238
+ ae(
4239
+ "span",
4240
+ {
4241
+ class: "fm-typo-en-body-lg-600 self-end"
4242
+ },
4243
+ $e(L.amount, !1)
4244
+ ),
4245
+ ae(
4246
+ "span",
4247
+ {
4248
+ class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
4249
+ },
4250
+ ((j = L.measurement) == null ? void 0 : j.abbrev) ?? L.sku.unit.abbrev
4251
+ )
4252
+ ]
4253
+ ),
4254
+ ae(
4255
+ "div",
4256
+ {
4257
+ class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary"
4258
+ },
4259
+ `${L.cost ? `(${ut(L.cost)})` : ""}`
4260
+ )
4261
+ ]
4262
+ )
4263
+ ]
4264
+ )
4265
+ ]);
4266
+ })
4267
+ },
4268
+ (f = I.netSuite) != null && f.refNo ? {
4269
+ label: "Netsuite Ref no. (ID)",
4270
+ values: [`${(p = I.netSuite) == null ? void 0 : p.refNo} (${((S = I.netSuite) == null ? void 0 : S.id) ?? "-"})`]
4271
+ } : null
4272
+ ].filter((L) => !!L)
4273
+ };
4274
+ }
4275
+ return k.map(
4276
+ (I) => I.type === "grn" ? C(I.doc) : A(I.doc)
4277
+ );
4278
+ }), de = K(() => {
4279
+ const s = r.purchaseOrder;
4280
+ if (!s) return [];
4281
+ if (!s.itemsAtSubmission) return s.items ?? [];
4282
+ const a = new Set(s.itemsAtSubmission.map((A) => A.sku._id)), k = [];
4283
+ for (const A of s.items ?? [])
4284
+ a.has(A.sku._id) || (a.add(A.sku._id), k.push(A));
4285
+ return [...s.itemsAtSubmission.map(
4286
+ (A) => {
4287
+ var W;
4288
+ return ((W = s.items) == null ? void 0 : W.find(
4289
+ (fe) => s.version === je.enum[2] ? fe.id === A.id : fe.sku._id === A.sku._id
4290
+ )) ?? A;
4291
+ }
4292
+ ), ...k];
4293
+ }), xe = K(() => {
4294
+ const s = r.purchaseOrder;
4295
+ if (!s || s.version !== je.enum[2]) return r.receivedMap;
4296
+ const a = {}, k = {};
4297
+ for (const A of s.items ?? [])
4298
+ a[A.sku._id] || (a[A.sku._id] = []), k[A.sku._id] = A.sku.unit.precision, A.id && a[A.sku._id].push(A.id);
4299
+ const C = {};
4300
+ for (const [A, W] of Object.entries(a)) {
4301
+ const fe = W.map((p) => r.receivedMap[p]).filter(Boolean);
4302
+ if (fe.length === 0) continue;
4303
+ const I = { amount: 0, precision: k[A] ?? 0 }, ce = fe.reduce((p, S) => Fe.add([p, S.total]), I), f = fe.reduce((p, S) => Fe.add([p, S.received]), I);
4304
+ C[A] = {
4305
+ key: A,
4306
+ total: ce,
4307
+ received: f,
4308
+ remaining: Fe.subtract([ce, f])
4309
+ };
4310
+ }
4311
+ return C;
4312
+ });
4313
+ function F(s) {
4314
+ const a = xe.value[s.sku._id], k = g(s);
4315
+ return a ? `<span class="${k} fm-typo-en-body-lg-600">${Fe.toFormatString({ value: a.received })}</span>/${ft(s.quantity, s.sku.unit, s.measurement)}` : `<span class="fm-typo-en-body-lg-600">-</span>/${ft(s.quantity, s.sku.unit, s.measurement)}`;
4316
+ }
4317
+ function h(s) {
4318
+ const a = r.purchaseOrder;
4319
+ return a != null && a.itemsAtSubmission ? !a.itemsAtSubmission.some((k) => k.sku._id === s.sku._id) : !1;
4320
+ }
4321
+ function g(s) {
4322
+ const a = xe.value[s.sku._id];
4323
+ if (!a)
4324
+ return "text-fm-color-typo-tertiary";
4325
+ const { isPartialReceive: k, isNoReceive: C, isOverReceive: A, isFullReceive: W } = fr(a);
4326
+ return C ? "text-fm-color-typo-tertiary" : k ? "text-fm-color-system-warning-300" : A ? "text-fm-color-system-error-300" : W ? "text-fm-color-system-success-300" : "";
4327
+ }
4328
+ const B = K(() => {
4329
+ var s, a, k;
4330
+ return (s = r.purchaseOrder) != null && s.itemsAtSubmission ? ((a = r.purchaseOrder) == null ? void 0 : a.version) === je.enum[2] ? r.purchaseOrder.items.reduce((C, A) => {
4331
+ var fe, I;
4332
+ const W = (I = (fe = r.purchaseOrder) == null ? void 0 : fe.itemsAtSubmission) == null ? void 0 : I.find(
4333
+ (ce) => ce.id === A.id
4334
+ );
4335
+ return A.id && W && W.quantity !== A.quantity && C.set(A.id, {
4336
+ originalAmount: Number(Fe.toFormatString({ value: W.quantity })),
4337
+ newAmount: Number(Fe.toFormatString({ value: A.quantity }))
4338
+ }), C;
4339
+ }, /* @__PURE__ */ new Map()) : (k = r.purchaseOrder) == null ? void 0 : k.items.reduce((C, A) => {
4340
+ var ce, f;
4341
+ const W = (f = (ce = r.purchaseOrder) == null ? void 0 : ce.itemsAtSubmission) == null ? void 0 : f.find(
4342
+ (p) => p.sku._id === A.sku._id
4343
+ ), fe = W ? Number(Fe.toFormatString({ value: W.quantity })) : 0, I = Number(Fe.toFormatString({ value: A.quantity }));
4344
+ return W && fe !== I && C.set(A.sku.code, {
4345
+ originalAmount: fe,
4346
+ newAmount: I
4347
+ }), C;
4348
+ }, /* @__PURE__ */ new Map()) : /* @__PURE__ */ new Map();
4349
+ }), G = (s) => {
4350
+ var k, C;
4351
+ const a = B.value;
4352
+ return ((k = r.purchaseOrder) == null ? void 0 : k.version) === je.enum[2] ? a.has(s.id) : a.has((C = s.sku) == null ? void 0 : C.code);
4353
+ }, X = (s) => {
4354
+ var k, C;
4355
+ const a = B.value;
4356
+ return ((k = r.purchaseOrder) == null ? void 0 : k.version) === je.enum[2] ? a.get(s.id) : a.get((C = s.sku) == null ? void 0 : C.code);
4357
+ }, re = K(() => {
4358
+ const s = r.purchaseOrder;
4359
+ if (!s) return "";
4360
+ const a = s.actionChangelogs ?? [], k = a.length ? a[a.length - 1] : null;
4361
+ if (k && k.action === "rejectDraft") {
4362
+ const C = k.remarks ?? "";
4363
+ return C && C.toString().trim() !== "" ? C.toString() : "-";
4364
+ }
4365
+ return "";
4366
+ }), ve = K(() => {
4367
+ const s = r.purchaseOrder;
4368
+ return s ? [...s.actionChangelogs ?? []].reverse() : [];
4369
+ });
4370
+ return (s, a) => {
4371
+ const k = le("FmButton"), C = le("FmButtonGroup"), A = le("FmChip"), W = le("FmIcon"), fe = le("FmMenuDivider"), I = le("FmCard"), ce = le("FmTooltip"), f = le("FmSpacer"), p = le("FmSideSheet");
4372
+ return i(), he(p, {
4373
+ modelValue: b(Q),
4374
+ "onUpdate:modelValue": a[9] || (a[9] = (S) => Fs(Q) ? Q.value = S : null),
4375
+ "dismiss-away": J.value,
4376
+ "max-width": 600,
4377
+ "close-button": !1
4378
+ }, {
4379
+ "side-sheet-header": pe(() => {
4380
+ var S, L;
4381
+ return [
4382
+ e("div", ra, [
4383
+ e("div", oa, [
4384
+ e("div", na, O(b(_)("inventory.transfer.receiveRequest.details.title") + ((S = s.purchaseOrder) != null && S.seqNumber ? ` #${(L = s.purchaseOrder) == null ? void 0 : L.seqNumber}` : "")), 1),
4385
+ q(k, {
4386
+ class: "ml-auto -m-2",
4387
+ variant: "tertiary",
4388
+ "prepend-icon": "close",
4389
+ onClick: a[0] || (a[0] = (j) => o("update:show", !1))
4390
+ })
4391
+ ]),
4392
+ q(C, {
4393
+ items: ye.value,
4394
+ modelValue: P.value,
4395
+ "onUpdate:modelValue": a[1] || (a[1] = (j) => P.value = j)
4396
+ }, null, 8, ["items", "modelValue"]),
4397
+ s.purchaseOrder && P.value.value === "deliveryHistory" ? (i(), he(In, {
4398
+ key: 0,
4399
+ "purchase-order": s.purchaseOrder,
4400
+ "received-info-map": Z.value,
4401
+ "received-map": s.receivedMap,
4402
+ onSubmitted: a[2] || (a[2] = () => {
4403
+ o("update:show", !1), o("submitted");
4404
+ })
4405
+ }, null, 8, ["purchase-order", "received-info-map", "received-map"])) : V("", !0)
4406
+ ])
4407
+ ];
4408
+ }),
4409
+ default: pe(() => {
4410
+ var S, L, j, Oe, we;
4411
+ return [
4412
+ e("div", aa, [
4413
+ P.value.value === "overview" ? (i(), y(De, { key: 0 }, [
4414
+ e("div", null, [
4415
+ q(I, {
4416
+ variant: "outlined",
4417
+ class: "flex flex-col gap-8 px-12 py-16"
4418
+ }, {
4419
+ default: pe(() => {
4420
+ var Y, ee, _e, Pe, Ie, ge, me, Re, Ee, Le;
4421
+ return [
4422
+ e("div", la, [
4423
+ e("div", ia, O(b(_)("inventory.transfer.receiveRequest.details.requestSummary")), 1),
4424
+ e("div", ua, [
4425
+ q(A, {
4426
+ label: ue.value.status,
4427
+ class: Ge(ue.value.statusClass),
4428
+ compact: ""
4429
+ }, null, 8, ["label", "class"]),
4430
+ E.value ? (i(), y("div", ca, [
4431
+ q(W, {
4432
+ name: "local_shipping",
4433
+ color: "#666666"
4434
+ }),
4435
+ e("span", da, O(E.value), 1)
4436
+ ])) : V("", !0)
4437
+ ])
4438
+ ]),
4439
+ q(fe),
4440
+ e("div", ma, [
4441
+ q(ss, { title: "Debug Info" }, {
4442
+ default: pe(() => {
4443
+ var it, Et, qt, Vt, Lt, jt, Ut, Mt, Bt, zt, Kt, Ht;
4444
+ return [
4445
+ (it = s.purchaseOrder) != null && it._id ? (i(), y("div", pa, [
4446
+ a[10] || (a[10] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Purchase Order ID ", -1)),
4447
+ e("span", fa, O((Et = s.purchaseOrder) == null ? void 0 : Et._id), 1)
4448
+ ])) : V("", !0),
4449
+ (qt = s.purchaseOrder) != null && qt.status ? (i(), y("div", va, [
4450
+ a[11] || (a[11] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Purchase Order Status ", -1)),
4451
+ e("span", ya, O((Vt = s.purchaseOrder) == null ? void 0 : Vt.status), 1)
4452
+ ])) : V("", !0),
4453
+ (jt = (Lt = s.purchaseOrder) == null ? void 0 : Lt.supplier) != null && jt._id ? (i(), y("div", ha, [
4454
+ a[12] || (a[12] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Source Location ID ", -1)),
4455
+ e("span", ba, O(((Mt = (Ut = s.purchaseOrder) == null ? void 0 : Ut.supplier) == null ? void 0 : Mt.internal) != null ? `${(zt = (Bt = s.purchaseOrder) == null ? void 0 : Bt.supplier) == null ? void 0 : zt.internal}_` : "") + O((Ht = (Kt = s.purchaseOrder) == null ? void 0 : Kt.supplier) == null ? void 0 : Ht._id), 1)
4456
+ ])) : V("", !0),
4457
+ s.transferToDbName ? (i(), y("div", ga, [
4458
+ a[13] || (a[13] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Destination Location ID ", -1)),
4459
+ e("span", _a, O(s.transferToDbName), 1)
4460
+ ])) : V("", !0)
4461
+ ];
4462
+ }),
4463
+ _: 1
4464
+ }),
4465
+ e("div", Sa, [
4466
+ e("div", Oa, [
4467
+ e("div", ka, O(b(_)("inventory.transfer.receiveRequest.details.createdAt")), 1)
4468
+ ]),
4469
+ e("div", xa, O(b(lt)(((Y = s.purchaseOrder) == null ? void 0 : Y._id) ?? "")), 1)
4470
+ ]),
4471
+ (ee = s.purchaseOrder) != null && ee.effectiveAt ? (i(), y("div", wa, [
4472
+ e("div", $a, O(b(_)("inventory.transfer.receiveRequest.details.date")), 1),
4473
+ e("div", Ca, O(b(Pt)(new Date((_e = s.purchaseOrder) == null ? void 0 : _e.effectiveAt))), 1)
4474
+ ])) : V("", !0),
4475
+ e("div", Aa, [
4476
+ e("div", Na, O(b(_)("inventory.transfer.receiveRequest.details.type.title")), 1),
4477
+ e("div", Da, O(b(_)(
4478
+ `inventory.transfer.receiveRequest.details.type.${M.value.toLocaleLowerCase("en-US")}`
4479
+ )), 1)
4480
+ ]),
4481
+ (Ie = (Pe = s.purchaseOrder) == null ? void 0 : Pe.supplier) != null && Ie.name ? (i(), y("div", Ra, [
4482
+ e("div", Pa, O(b(_)("inventory.transfer.receiveRequest.details.from")), 1),
4483
+ e("div", Fa, O((me = (ge = s.purchaseOrder) == null ? void 0 : ge.supplier) == null ? void 0 : me.name), 1)
4484
+ ])) : V("", !0),
4485
+ s.transferTo ? (i(), y("div", Ia, [
4486
+ e("div", Ta, O(b(_)("inventory.transfer.receiveRequest.details.to")), 1),
4487
+ e("div", Ea, O(s.transferTo), 1)
4488
+ ])) : V("", !0),
4489
+ (Re = s.purchaseOrder) != null && Re.ref ? (i(), y("div", qa, [
4490
+ e("div", Va, O(b(_)("inventory.transfer.receiveRequest.details.reference")), 1),
4491
+ e("div", La, O(s.purchaseOrder.ref), 1)
4492
+ ])) : V("", !0),
4493
+ (Ee = s.purchaseOrder) != null && Ee.remark ? (i(), y("div", ja, [
4494
+ e("div", Ua, O(b(_)("inventory.transfer.receiveRequest.details.remark")), 1),
4495
+ e("div", Ma, O(s.purchaseOrder.remark), 1)
4496
+ ])) : V("", !0),
4497
+ ((Le = s.purchaseOrder) == null ? void 0 : Le.status) === b(Se).enum.DRAFT && re.value ? (i(), y("div", Ba, [
4498
+ e("div", za, O(b(_)("inventory.transfer.receiveRequest.details.rejectionReason")), 1),
4499
+ e("div", Ka, O(re.value !== "" ? re.value : "-"), 1)
4500
+ ])) : V("", !0)
4501
+ ])
4502
+ ];
4503
+ }),
4504
+ _: 1
4505
+ })
4506
+ ]),
4507
+ q(xo, {
4508
+ "po-request": s.poRequest,
4509
+ purchaseOrder: s.purchaseOrder,
4510
+ transferType: M.value,
4511
+ transferToDbName: s.transferToDbName,
4512
+ scope: s.scope
4513
+ }, null, 8, ["po-request", "purchaseOrder", "transferType", "transferToDbName", "scope"]),
4514
+ e("div", Ha, [
4515
+ e("div", Ga, [
4516
+ e("div", Wa, [
4517
+ e("span", Qa, [
4518
+ Xe(O(U.value ? b(_)("inventory.transfer.receiveRequest.details.receivedItems") : b(_)("inventory.transfer.receiveRequest.details.requestedItems")) + " ", 1),
4519
+ (L = (S = s.purchaseOrder) == null ? void 0 : S.netSuite) != null && L.missingItems && ((Oe = (j = s.purchaseOrder) == null ? void 0 : j.netSuite) == null ? void 0 : Oe.missingItems.length) > 0 ? (i(), he(ce, {
4520
+ key: 0,
4521
+ variant: "rich",
4522
+ placement: "top",
4523
+ "z-index": 51
4524
+ }, {
4525
+ content: pe(() => {
4526
+ var Y, ee;
4527
+ return [
4528
+ e("div", Ya, [
4529
+ (i(!0), y(De, null, Te((ee = (Y = s.purchaseOrder) == null ? void 0 : Y.netSuite) == null ? void 0 : ee.missingItems, (_e, Pe) => (i(), y("div", {
4530
+ class: "flex justify-center align-middle",
4531
+ key: Pe
4532
+ }, [
4533
+ q(W, {
4534
+ name: "arrow_right",
4535
+ size: "sm"
4536
+ }),
4537
+ Xe(" " + O(`(${_e.netSuiteId}) ${_e.name}: ${_e.reason}`), 1)
4538
+ ]))), 128))
4539
+ ])
4540
+ ];
4541
+ }),
4542
+ default: pe(() => [
4543
+ q(W, {
4544
+ name: "error",
4545
+ color: "#ff2c2c",
4546
+ size: "sm"
4547
+ })
4548
+ ]),
4549
+ _: 1
4550
+ })) : V("", !0)
4551
+ ])
4552
+ ]),
4553
+ q(fe),
4554
+ (i(!0), y(De, null, Te(de.value, (Y, ee) => {
4555
+ var _e;
4556
+ return i(), y("div", {
4557
+ key: ee,
4558
+ class: "flex flex-col"
4559
+ }, [
4560
+ e("div", Ja, [
4561
+ e("div", Xa, [
4562
+ e("span", Za, O(Y.name), 1),
4563
+ h(Y) || G(Y) ? (i(), y("span", el, [
4564
+ h(Y) ? (i(), he(ce, {
4565
+ key: 0,
4566
+ variant: "rich",
4567
+ placement: "top",
4568
+ "z-index": 51
4569
+ }, {
4570
+ content: pe(() => a[14] || (a[14] = [
4571
+ e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Extra item (added during delivery) ", -1)
4572
+ ])),
4573
+ default: pe(() => [
4574
+ q(W, {
4575
+ name: "add_circle",
4576
+ color: "#6b7280",
4577
+ size: "sm"
4578
+ })
4579
+ ]),
4580
+ _: 1
4581
+ })) : V("", !0),
4582
+ G(Y) ? (i(), he(ce, {
4583
+ key: 1,
4584
+ variant: "rich",
4585
+ placement: "top",
4586
+ "z-index": 51
4587
+ }, {
4588
+ content: pe(() => {
4589
+ var Pe, Ie;
4590
+ return [
4591
+ e("div", tl, [
4592
+ a[15] || (a[15] = e("div", { class: "font-semibold" }, "Submission changes", -1)),
4593
+ e("div", null, " Original Amount: " + O((Pe = X(Y)) == null ? void 0 : Pe.originalAmount), 1),
4594
+ e("div", null, " New Amount: " + O((Ie = X(Y)) == null ? void 0 : Ie.newAmount), 1)
4595
+ ])
4596
+ ];
4597
+ }),
4598
+ default: pe(() => [
4599
+ q(W, {
4600
+ name: "error",
4601
+ color: "#ff9500",
4602
+ size: "sm"
4603
+ })
4604
+ ]),
4605
+ _: 2
4606
+ }, 1024)) : V("", !0)
4607
+ ])) : V("", !0)
4608
+ ]),
4609
+ e("div", sl, [
4610
+ e("span", {
4611
+ innerHTML: F(Y)
4612
+ }, null, 8, rl)
4613
+ ])
4614
+ ]),
4615
+ e("div", ol, [
4616
+ e("div", nl, O(Y.code), 1),
4617
+ (_e = Y.totalCost) != null && _e.amount || typeof Y.sku == "object" && Y.sku != null ? (i(), he(Qs, {
4618
+ key: 0,
4619
+ "feature-key": "total-cost",
4620
+ compact: "",
4621
+ "show-locked-content": ""
4622
+ }, {
4623
+ default: pe(() => {
4624
+ var Pe;
4625
+ return [
4626
+ e("div", al, [
4627
+ e("span", ll, O(b(ut)(
4628
+ (Pe = Y.totalCost) != null && Pe.amount ? Y.totalCost : b(v).controller.value.getItemCost(Y, b(Ce)()).cost
4629
+ )), 1),
4630
+ D(Y) ? V("", !0) : (i(), y("span", il, [
4631
+ a[16] || (a[16] = e("span", { class: "w-1.5 h-1.5 rounded-full bg-gray-400" }, null, -1)),
4632
+ Xe(" " + O(b(_)("inventory.transfer.form.items.autoCalculated")), 1)
4633
+ ]))
4634
+ ])
4635
+ ];
4636
+ }),
4637
+ _: 2
4638
+ }, 1024)) : V("", !0)
4639
+ ])
4640
+ ]);
4641
+ }), 128)),
4642
+ +b($e)(b(v).controller.value.getTotalCosts()) ? (i(), y("div", ul, [
4643
+ e("div", cl, [
4644
+ q(fe)
4645
+ ]),
4646
+ e("div", dl, [
4647
+ a[17] || (a[17] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Total:", -1)),
4648
+ e("div", ml, O(b(Ce)()) + " " + O(b(ut)({
4649
+ ...b(v).controller.value.getTotalCosts(),
4650
+ currency: b(Ce)()
4651
+ }).replace(/[^0-9.,]/g, "")), 1)
4652
+ ])
4653
+ ])) : V("", !0),
4654
+ b(d).enablePurchaseOrderPriceAdjustment ? (i(), y(De, { key: 1 }, [
4655
+ q(Vn, {
4656
+ adjustments: (we = s.purchaseOrder) == null ? void 0 : we.priceAdjustments
4657
+ }, null, 8, ["adjustments"]),
4658
+ s.purchaseOrder ? (i(), y("div", pl, [
4659
+ q(jn, {
4660
+ "purchase-order": s.purchaseOrder,
4661
+ onSubmitted: a[3] || (a[3] = () => {
4662
+ o("update:show", !1), o("submitted");
4663
+ })
4664
+ }, null, 8, ["purchase-order"])
4665
+ ])) : V("", !0)
4666
+ ], 64)) : V("", !0)
4667
+ ])
4668
+ ])
4669
+ ], 64)) : P.value.value === "deliveryHistory" ? (i(), y("div", fl, [
4670
+ H.value.length ? (i(), y("div", gl, [
4671
+ (i(!0), y(De, null, Te(H.value, (Y, ee) => {
4672
+ var _e, Pe, Ie, ge, me;
4673
+ return i(), y(De, { key: ee }, [
4674
+ e("div", _l, [
4675
+ e("div", Sl, [
4676
+ e("div", Ol, [
4677
+ e("div", {
4678
+ class: Ge([
4679
+ {
4680
+ "bg-fm-color-primary": ee !== 0,
4681
+ "bg-white": ee === 0
4682
+ },
4683
+ "w-[2px] h-full"
4684
+ ])
4685
+ }, null, 2)
4686
+ ]),
4687
+ e("div", kl, [
4688
+ Y.header === "Received" ? (i(), he(W, {
4689
+ key: 0,
4690
+ name: "local_shipping",
4691
+ outline: "",
4692
+ color: "#ffffff"
4693
+ })) : V("", !0)
4694
+ ]),
4695
+ e("div", xl, [
4696
+ e("div", {
4697
+ class: Ge([
4698
+ {
4699
+ "bg-fm-color-primary": ee < H.value.length - 1,
4700
+ "bg-white": ee >= H.value.length - 1
4701
+ },
4702
+ "w-[2px] h-full"
4703
+ ])
4704
+ }, null, 2)
4705
+ ])
4706
+ ]),
4707
+ e("div", wl, [
4708
+ e("div", $l, [
4709
+ e("div", Cl, O(Y.header), 1),
4710
+ e("div", Al, O(Y.date), 1)
4711
+ ]),
4712
+ e("div", Nl, [
4713
+ Y.header === "Received" && Y.deliveryOrder && s.purchaseOrder ? (i(), he(Xo, {
4714
+ key: 0,
4715
+ deliveryOrder: Y.deliveryOrder,
4716
+ purchaseOrder: s.purchaseOrder,
4717
+ "received-info-map": Z.value,
4718
+ onSubmitted: a[4] || (a[4] = () => {
4719
+ o("update:show", !1), o("submitted");
4720
+ })
4721
+ }, null, 8, ["deliveryOrder", "purchaseOrder", "received-info-map"])) : V("", !0),
4722
+ (Pe = (_e = Y.deliveryOrder) == null ? void 0 : _e.netSuite) != null && Pe.id ? (i(), he(ss, {
4723
+ key: 1,
4724
+ title: "Admin",
4725
+ class: "min-w-[140px]"
4726
+ }, {
4727
+ default: pe(() => {
4728
+ var Re, Ee;
4729
+ return [
4730
+ q(sa, {
4731
+ "netsuite-id": (Ee = (Re = Y.deliveryOrder) == null ? void 0 : Re.netSuite) == null ? void 0 : Ee.id
4732
+ }, null, 8, ["netsuite-id"])
4733
+ ];
4734
+ }),
4735
+ _: 2
4736
+ }, 1024)) : V("", !0),
4737
+ s.purchaseOrder && ((Ie = Y.deliveryOrder) != null && Ie.id) ? (i(), he(Ws, {
4738
+ key: 2,
4739
+ "purchase-order-id": (ge = s.purchaseOrder) == null ? void 0 : ge._id,
4740
+ "delivery-order-id": (me = Y.deliveryOrder) == null ? void 0 : me.id
4741
+ }, null, 8, ["purchase-order-id", "delivery-order-id"])) : V("", !0)
4742
+ ])
4743
+ ])
4744
+ ]),
4745
+ e("div", Dl, [
4746
+ e("div", Rl, [
4747
+ e("div", Pl, [
4748
+ e("div", {
4749
+ class: Ge([
4750
+ {
4751
+ "bg-fm-color-primary": ee < H.value.length - 1,
4752
+ "bg-white": ee >= H.value.length - 1
4753
+ },
4754
+ "w-[2px] h-full"
4755
+ ])
4756
+ }, null, 2)
4757
+ ])
4758
+ ]),
4759
+ e("div", Fl, [
4760
+ q(I, {
4761
+ variant: "outlined",
4762
+ class: "py-12 px-16"
4763
+ }, {
4764
+ default: pe(() => [
4765
+ e("div", Il, [
4766
+ (i(!0), y(De, null, Te(Y.info, (Re, Ee) => (i(), y("div", {
4767
+ key: Ee,
4768
+ class: "flex flex-col gap-4"
4769
+ }, [
4770
+ e("div", Tl, O(Re == null ? void 0 : Re.label), 1),
4771
+ e("div", El, [
4772
+ (i(!0), y(De, null, Te(Re == null ? void 0 : Re.values, (Le, it) => (i(), y("div", {
4773
+ key: it,
4774
+ class: "fm-typo-en-body-lg-600"
4775
+ }, [
4776
+ typeof Le == "string" ? (i(), y(De, { key: 0 }, [
4777
+ Xe(O(Le), 1)
4778
+ ], 64)) : (i(), he(Is(Le), { key: 1 }))
4779
+ ]))), 128))
4780
+ ])
4781
+ ]))), 128))
4782
+ ])
4783
+ ]),
4784
+ _: 2
4785
+ }, 1024)
4786
+ ])
4787
+ ])
4788
+ ], 64);
4789
+ }), 128))
4790
+ ])) : (i(), y("div", vl, [
4791
+ q(f),
4792
+ e("div", null, [
4793
+ e("img", {
4794
+ src: b(Jt),
4795
+ alt: "List is empty"
4796
+ }, null, 8, yl)
4797
+ ]),
4798
+ e("div", hl, O(b(_)("inventory.transfer.receiveRequest.details.noRecordsFound")), 1),
4799
+ e("div", bl, O(b(_)("inventory.transfer.receiveRequest.details.trackDeliveryMessage")), 1),
4800
+ q(f),
4801
+ q(f)
4802
+ ]))
4803
+ ])) : P.value.value === "actionLogs" ? (i(), y("div", ql, [
4804
+ ve.value.length ? (i(), y("div", Ul, [
4805
+ (i(!0), y(De, null, Te(ve.value, (Y, ee) => (i(), he(I, {
4806
+ key: ee,
4807
+ variant: "outlined",
4808
+ class: "py-12 px-16"
4809
+ }, {
4810
+ default: pe(() => {
4811
+ var _e;
4812
+ return [
4813
+ e("div", Ml, [
4814
+ e("div", Bl, [
4815
+ e("div", zl, O(b(nt)[Y.action] ? b(_)(b(nt)[Y.action].translationKey) : Y.action), 1),
4816
+ e("div", Kl, O(b(et)(Y.changedAt)), 1)
4817
+ ]),
4818
+ e("div", Hl, O((_e = Y.changedBy) == null ? void 0 : _e.name), 1),
4819
+ Y.remarks ? (i(), y("div", Gl, O(Y.remarks), 1)) : V("", !0)
4820
+ ])
4821
+ ];
4822
+ }),
4823
+ _: 2
4824
+ }, 1024))), 128))
4825
+ ])) : (i(), y("div", Vl, [
4826
+ q(f),
4827
+ e("div", null, [
4828
+ e("img", {
4829
+ src: b(Jt),
4830
+ alt: "List is empty"
4831
+ }, null, 8, Ll)
4832
+ ]),
4833
+ e("div", jl, O(b(_)("inventory.transfer.receiveRequest.details.noActionLogs")), 1),
4834
+ q(f),
4835
+ q(f)
4836
+ ]))
4837
+ ])) : V("", !0)
4838
+ ])
4839
+ ];
4840
+ }),
4841
+ "side-sheet-footer": pe(() => [
4842
+ e("div", Wl, [
4843
+ (i(!0), y(De, null, Te(Ae.value, (S) => (i(), y(De, null, [
4844
+ b(nt)[S].available != !1 ? (i(), he(k, {
4845
+ key: S,
4846
+ label: b(_)(b(nt)[S].translationKey),
4847
+ onClick: (L) => N(S),
4848
+ loading: se.value === S,
4849
+ disabled: se.value !== S && te.value,
4850
+ variant: b(nt)[S].buttonVariant
4851
+ }, null, 8, ["label", "onClick", "loading", "disabled", "variant"])) : V("", !0)
4852
+ ], 64))), 256)),
4853
+ b(T).ableToMarkReceived(s.purchaseOrder) && !Ae.value.includes("completeReceive") ? (i(), he(k, {
4854
+ key: 0,
4855
+ label: b(_)("inventory.transfer.receiveRequest.actions.completeReceive"),
4856
+ onClick: a[5] || (a[5] = (S) => N("completeReceive")),
4857
+ loading: se.value === "completeReceive",
4858
+ disabled: se.value !== "completeReceive" && te.value
4859
+ }, null, 8, ["label", "loading", "disabled"])) : V("", !0),
4860
+ b(T).ableToMarkApproved(s.purchaseOrder) && s.canApprove && !Ae.value.includes("approveRequest") ? (i(), he(k, {
4861
+ key: 1,
4862
+ label: b(_)("inventory.transfer.approval.actions.approveRequest"),
4863
+ onClick: a[6] || (a[6] = (S) => N("approveRequest")),
4864
+ loading: se.value === "approveRequest",
4865
+ disabled: se.value !== "approveRequest" && te.value
4866
+ }, null, 8, ["label", "loading", "disabled"])) : V("", !0),
4867
+ b(T).ableToCreateFulfillment(s.purchaseOrder, s.poRequest) && r.scope === "approval" ? (i(), he(k, {
4868
+ key: 2,
4869
+ label: b(_)("inventory.transfer.receiveRequest.actions.processRequest"),
4870
+ onClick: a[7] || (a[7] = (S) => N("processRequest")),
4871
+ loading: se.value === "processRequest",
4872
+ disabled: se.value !== "processRequest" && te.value
4873
+ }, null, 8, ["label", "loading", "disabled"])) : V("", !0),
4874
+ q(k, {
4875
+ label: b(_)("common.close"),
4876
+ variant: "tertiary",
4877
+ onClick: a[8] || (a[8] = (S) => o("update:show", !1))
4878
+ }, null, 8, ["label"])
4879
+ ])
4880
+ ]),
4881
+ _: 1
4882
+ }, 8, ["modelValue", "dismiss-away"]);
4883
+ };
4884
+ }
4885
+ });
4886
+ export {
4887
+ At as P,
4888
+ wi as _,
4889
+ xi as a,
4890
+ cr as b,
4891
+ fs as c,
4892
+ ps as d,
4893
+ bs as e,
4894
+ vt as f,
4895
+ cs as g,
4896
+ vs as h,
4897
+ Tt as i,
4898
+ It as j,
4899
+ ki as u
4900
+ };