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