@feedmepos/mf-inventory-portal 1.7.0-dev.9 → 1.7.1-dev.0

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 (130) hide show
  1. package/dist/{App-DqkccxFd.js → App-B_ja37tB.js} +5 -5
  2. package/dist/ApprovalView-_wG6KeZl.js +249 -0
  3. package/dist/{BindingsDialog-CXBQwYIz.js → BindingsDialog-0IRWCLTc.js} +2 -2
  4. package/dist/{BindingsPicker-BfHSReUF.js → BindingsPicker-DCISa6Fx.js} +2 -2
  5. package/dist/{BindingsTable-CHxIsdzV.js → BindingsTable-B3CmHp97.js} +3 -3
  6. package/dist/BulkReceiveRequestView-Dmqm65c9.js +2025 -0
  7. package/dist/{ChangeLocationComponent.vue_vue_type_script_setup_true_lang-BfN7GDOL.js → ChangeLocationComponent.vue_vue_type_script_setup_true_lang-D4Nd89xp.js} +1 -1
  8. package/dist/{ClosingDraftView-BJQgyPTs.js → ClosingDraftView-DDWU93p0.js} +21 -21
  9. package/dist/{ClosingHistoryView-CLhL3Xfc.js → ClosingHistoryView-KdmhszIO.js} +7 -7
  10. package/dist/ClosingTemplateView-CQRujMB9.js +2346 -0
  11. package/dist/ConnectedBusinessView-Cu2QnRN9.js +533 -0
  12. package/dist/{DefaultView-BQ0Y_nGt.js → DefaultView-QAEDG6pS.js} +2 -2
  13. package/dist/{DeliveryOrderPrintPreview-DHDu2E0L.js → DeliveryOrderPrintPreview-B08SSOCX.js} +2 -2
  14. package/dist/{EmailDialog.vue_vue_type_script_setup_true_lang-Dqy7-a53.js → EmailDialog.vue_vue_type_script_setup_true_lang-DdzV_fzq.js} +13245 -13063
  15. package/dist/{FmAdminBadge-DlplQOHb.js → FmAdminBadge-DH_2w13D.js} +8 -8
  16. package/dist/{FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-BeoDswK2.js → FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-CmH3uhTZ.js} +1 -1
  17. package/dist/FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-Dzqh8pM9.js +84 -0
  18. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-Bq1UiREV.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-Df-yCfRe.js} +4 -4
  19. package/dist/{FmMultiselectDialog-BhDa1RwT.js → FmMultiselectDialog-DpPyNOpJ.js} +1 -1
  20. package/dist/{FmMultiselectDialog-CorNT8gl.js → FmMultiselectDialog-QEs0yct_.js} +2 -2
  21. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-DYIDe_N1.js → FmUnitInput.vue_vue_type_script_setup_true_lang-D8-IQUtA.js} +121 -119
  22. package/dist/{ImportView-C57uYZRr.js → ImportView-8qlgZSTO.js} +8 -8
  23. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-B96kvgzW.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-CGWRbAF2.js} +1 -1
  24. package/dist/{IngredientGroupView-CwhJuG3d.js → IngredientGroupView-BI9SlKfz.js} +6 -6
  25. package/dist/{IngredientsView-oC9fFDvT.js → IngredientsView-1naUkKAi.js} +17 -17
  26. package/dist/{IntegrationExplorerView-4QvHjDRJ.js → IntegrationExplorerView-C6kyLz3y.js} +5 -5
  27. package/dist/{IntegrationView-D-DT3YJs.js → IntegrationView-DrmxLdlk.js} +15 -15
  28. package/dist/{InventoryBindingForm-CYw_09Za.js → InventoryBindingForm-CPNAgZkD.js} +1 -1
  29. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-urLsGkKG.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-sz_VtHRr.js} +5 -5
  30. package/dist/{InventoryBindingSummary-CgqWRDNo.js → InventoryBindingSummary-Cu98L10w.js} +1 -1
  31. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DLUlL05A.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-g2PDNQx-.js} +1 -1
  32. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-3m70pVwB.js → PremiumBadge.vue_vue_type_script_setup_true_lang-BZEa61go.js} +1 -1
  33. package/dist/{ProductionView--WPitDlY.js → ProductionView-D8dxypqA.js} +8 -8
  34. package/dist/{PublishView-D0kB5NQ2.js → PublishView-C82UwIoz.js} +4 -4
  35. package/dist/{PurchaseOrderPrintPreview-B1M-Moro.js → PurchaseOrderPrintPreview-CP40tEma.js} +2 -2
  36. package/dist/ReceiveRequestView-DDo0Pb0J.js +514 -0
  37. package/dist/{RecipeView-C49tT8Cr.js → RecipeView-DB1DJQp7.js} +18 -18
  38. package/dist/{SettingsView-Dt7a_Nkx.js → SettingsView-DsS62lxW.js} +6 -6
  39. package/dist/{SingleColumnLayout.vue_vue_type_script_setup_true_lang-DwrLsWX_.js → SingleColumnLayout.vue_vue_type_script_setup_true_lang-DWsPvPE1.js} +1 -1
  40. package/dist/{StockView-CNzq9TSj.js → StockView-gcf7RCZz.js} +23 -23
  41. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-Cx-XCR_k.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-nXqFCKic.js} +1 -1
  42. package/dist/{SupplierView-7EbI5cfk.js → SupplierView-BIANlKLE.js} +13 -13
  43. package/dist/{SurchargeView-BbfzwuAB.js → SurchargeView-kRzaixM5.js} +7 -7
  44. package/dist/SystemTrailDialog.vue_vue_type_script_setup_true_lang-QMUVuthC.js +211 -0
  45. package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-nO9sybW-.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-BceIOuBq.js} +2 -2
  46. package/dist/TransferDetailsV3.vue_vue_type_script_setup_true_lang-DYAzxoHE.js +5991 -0
  47. package/dist/{TransferTemplateView-Bz5W7dh5.js → TransferTemplateView-Bq68Vh7t.js} +21 -21
  48. package/dist/{UnitCostHistoryView-5wAtW09L.js → UnitCostHistoryView-d0oLssyZ.js} +6 -6
  49. package/dist/{UnitDisplayControl.vue_vue_type_script_setup_true_lang-Ze6egaj8.js → UnitDisplayControl.vue_vue_type_script_setup_true_lang-CLOotG6K.js} +4 -4
  50. package/dist/{UnitView-Mp8CL-lp.js → UnitView-BHfm2IE4.js} +8 -8
  51. package/dist/{WarehouseView-DRkIDq76.js → WarehouseView-CorSYwm6.js} +6 -6
  52. package/dist/{WastageTemplateView-CRLaJJnu.js → WastageTemplateView-CtYZwiRW.js} +15 -15
  53. package/dist/api/connected-business-mapping.d.ts +25 -0
  54. package/dist/api/purchase-order.d.ts +35 -1
  55. package/dist/{app-VqA3hs6t.js → app-37NZKFUI.js} +5557 -5192
  56. package/dist/app.d.ts +88 -0
  57. package/dist/app.js +1 -1
  58. package/dist/{closing-template-CdSV_waS.js → closing-template-C0dl45x2.js} +1 -1
  59. package/dist/components/FmFilterableMenuOptions.vue.d.ts +11 -2
  60. package/dist/connected-business-mapping-ywgqqyMr.js +37 -0
  61. package/dist/{date2-ybHWeys0.js → date2-r4KgBCs9.js} +1 -1
  62. package/dist/{dayjs.min-vhlHpfOd.js → dayjs.min-BKUldDi9.js} +1 -1
  63. package/dist/{decimal-BWaV7aqI.js → decimal-Cgmw6HIY.js} +2 -2
  64. package/dist/{defineDeepModel-Dh55Rpy6.js → defineDeepModel-DXLwZWst.js} +1 -1
  65. package/dist/{duplicate-template-BX4CtnXP.js → duplicate-template-DDA4QWPl.js} +1 -1
  66. package/dist/feature-B4BoCy_k.js +1548 -0
  67. package/dist/{format-time-from-id-CcnUAvw3.js → format-time-from-id-Dhjn5QgH.js} +1 -1
  68. package/dist/{format-unit-display-CpfisOsO.js → format-unit-display-g95-VuYJ.js} +12 -12
  69. package/dist/{import-export.helper-DkxUoI70.js → import-export.helper-DsZFPPqj.js} +6 -6
  70. package/dist/{index-CDTURjdV.js → index-B9WjF3Ox.js} +1 -1
  71. package/dist/{index-BWP_Oz85.js → index-C207KsUh.js} +3 -3
  72. package/dist/{index-C2-NacLA.js → index-D3Bmmx66.js} +1 -1
  73. package/dist/{inventory-core-dart.default-CCuIh47-.js → inventory-core-dart.default-NpD15h63.js} +7104 -5555
  74. package/dist/{jszip.min-CGd5HPaQ.js → jszip.min-B52cHzHI.js} +2 -2
  75. package/dist/{lz-string-DaTOnDE7.js → lz-string-CItFpr5-.js} +1 -1
  76. package/dist/{netsuite-Bv8m4JOq.js → netsuite-R_NkLn5t.js} +2 -2
  77. package/dist/{number-Blpf0ylx.js → number-BkC_lelq.js} +3 -3
  78. package/dist/{predefined-templates-CH1yqXrS.js → predefined-templates-CVT54o4V.js} +1 -1
  79. package/dist/{purchase-order-template-Hzi2jg5i.js → purchase-order-template-DvqAncB2.js} +1 -1
  80. package/dist/{recalculationUtils-Bg_M-poT.js → recalculationUtils-Cak1mo4o.js} +1 -1
  81. package/dist/router/name.d.ts +1 -0
  82. package/dist/{rules-CyLofMuT.js → rules--cnFg-PI.js} +2 -2
  83. package/dist/{stock-DfNx3w-V.js → stock-BLYAJxMj.js} +1 -1
  84. package/dist/{stock-vaSdMe5e.js → stock-DvquSog3.js} +3 -3
  85. package/dist/stores/feature.d.ts +2 -0
  86. package/dist/style.css +1 -1
  87. package/dist/{supplier-DPLDqUXZ.js → supplier-C5X8p_vd.js} +2 -2
  88. package/dist/{surcharge-0-XdT9aW.js → surcharge-CLkpleoW.js} +1 -1
  89. package/dist/tsconfig.app.tsbuildinfo +1 -1
  90. package/dist/{uom-rules-CbYmI74H.js → uom-rules-CykFo_pB.js} +1 -1
  91. package/dist/{use-ingredient-select-dialog-g1T1s6nQ.js → use-ingredient-select-dialog-DlxWMkAI.js} +2 -2
  92. package/dist/{use-inventory-binding-dialog-B0AniKhu.js → use-inventory-binding-dialog-DnWDyziu.js} +2 -2
  93. package/dist/{use-template-enabled-locations-DRkN8eSx.js → use-template-enabled-locations-SRgcWLO4.js} +2 -2
  94. package/dist/{use-transfer-locations-BG1GERbt.js → use-transfer-locations-D4f4Ib1r.js} +2 -2
  95. package/dist/{useHrmPermission-CUPAhcDP.js → useHrmPermission-lAc6ZHVZ.js} +1 -1
  96. package/dist/{useNavigationMenu-D2onvhoK.js → useNavigationMenu-CeN7TEwe.js} +59 -49
  97. package/dist/{useSseClient-DvQsSC57.js → useSseClient-C6ndlLpA.js} +1 -1
  98. package/dist/views/closing-template/components/closing-template-form/composables/use-closing-template-search.d.ts +6 -0
  99. package/dist/views/closing-template/components/closing-template-form/composables/use-closing-template-search.spec.d.ts +1 -0
  100. package/dist/views/connected-business/ConnectedBusinessMappingPanel.vue.d.ts +25 -0
  101. package/dist/views/connected-business/ConnectedBusinessView.vue.d.ts +2 -0
  102. package/dist/views/receive-request/components/CreateTransferChoice.vue.d.ts +27 -0
  103. package/dist/views/receive-request/components/transfer-details/TransferDetailsV3.vue.d.ts +18 -0
  104. package/dist/views/receive-request/components/transfer-dialog/TransferDialogProps.d.ts +1 -0
  105. package/dist/views/receive-request/components/transfer-form/TransferFormProps.d.ts +1 -0
  106. package/dist/views/receive-request/components/transfer-form/TransferFormWithController.vue.d.ts +102 -2
  107. package/dist/views/receive-request/composables/fn.d.ts +2 -1
  108. package/dist/views/receive-request/composables/fn.spec.d.ts +1 -0
  109. package/dist/views/receive-request/composables/use-process-purchase-order.d.ts +119 -3
  110. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +642 -13
  111. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +720 -14
  112. package/dist/views/receive-request/helper/po-version.d.ts +6 -0
  113. package/dist/views/receive-request-bulk/composables/use-bulk-receive-request-form.d.ts +524 -10
  114. package/dist/views/receive-request-bulk/composables/use-bulk-receive-request-table.d.ts +102 -2
  115. package/dist/views/transfer-template/components/transfer-template-dialog/TransferTemplateDialog.vue.d.ts +4 -0
  116. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-locations.d.ts +8 -0
  117. package/dist/views/transfer-template/composables/use-template-item-bulk-editor.d.ts +12 -0
  118. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +24 -0
  119. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +24 -0
  120. package/dist/{vue-i18n-CwNxhUsM.js → vue-i18n-DDqVG60p.js} +291 -291
  121. package/dist/{xlsx.util-dMHkd6XK.js → xlsx.util-BzQcPwvM.js} +2 -2
  122. package/package.json +3 -3
  123. package/dist/ApprovalView-CpeNbbnJ.js +0 -242
  124. package/dist/BulkReceiveRequestView-BFFeVxQF.js +0 -2011
  125. package/dist/ClosingTemplateView-DikY2_9d.js +0 -2270
  126. package/dist/FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-B9CWp_AG.js +0 -76
  127. package/dist/ReceiveRequestView-B1NWO9ih.js +0 -345
  128. package/dist/SystemTrailDialog.vue_vue_type_script_setup_true_lang-CT0KDVR4.js +0 -178
  129. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-DxSXLCtP.js +0 -4660
  130. package/dist/feature-_v_0Btg8.js +0 -1136
@@ -1,2011 +0,0 @@
1
- import { defineComponent as lt, ref as w, computed as R, watch as ze, createElementBlock as g, openBlock as m, Fragment as _e, createBlock as ie, createVNode as F, Teleport as wt, Transition as Pt, withCtx as Fe, createCommentVNode as $, createElementVNode as e, toDisplayString as d, unref as t, normalizeClass as O, renderList as Qe, createTextVNode as Xe, mergeModels as qt, useModel as Tt, resolveComponent as De, reactive as Bt, h as ve, nextTick as tt, watchEffect as Ot, isRef as mt, normalizeStyle as pt, normalizeProps as ft, mergeProps as st, guardReactiveProps as At } from "vue";
2
- import { u as et, a as Nt, E as It, T as vt, U as yt, s as $t, V as Ae, q as zt, c as Lt, Q as Ge, x as Mt } from "./app-VqA3hs6t.js";
3
- import { i as rt, _ as Vt } from "./FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-BeoDswK2.js";
4
- import { a as bt, d as Ut } from "./number-Blpf0ylx.js";
5
- import { c as jt, d as nt, e as Ht, f as Yt, h as Qt, i as Wt, P as it, j as Zt, a as Kt, _ as Jt, b as Xt, g as Gt } from "./TransferDetails.vue_vue_type_script_setup_true_lang-DxSXLCtP.js";
6
- import { i as es } from "./PremiumBadge.vue_vue_type_script_setup_true_lang-3m70pVwB.js";
7
- import { d as Te } from "./dayjs.min-vhlHpfOd.js";
8
- import { e as ts } from "./UnitDisplayControl.vue_vue_type_script_setup_true_lang-Ze6egaj8.js";
9
- import { u as ss } from "./useTabStorage-BkIVScW_.js";
10
- import { u as ns, _ as os } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-DwrLsWX_.js";
11
- import { components as as, useSnackbar as ut, useDialog as rs, useBreakpoints as ls } from "@feedmepos/ui-library";
12
- import { c as is, u as us, h as ht, _ as cs, a as ds, b as ms } from "./EmailDialog.vue_vue_type_script_setup_true_lang-Dqy7-a53.js";
13
- import { useI18n as We, useCoreStore as kt } from "@feedmepos/mf-common";
14
- import { u as Ct, a as ps } from "./supplier-DPLDqUXZ.js";
15
- import { u as fs } from "./stock-DfNx3w-V.js";
16
- import { u as Ft } from "./SystemTrailDialog.vue_vue_type_script_setup_true_lang-CT0KDVR4.js";
17
- import { b as St, a as vs } from "./format-unit-display-CpfisOsO.js";
18
- import { P as ys } from "./inventory-core-dart.default-CCuIh47-.js";
19
- import { _ as bs, F as He } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-DAMpuZ1X.js";
20
- import { u as Rt } from "./feature-_v_0Btg8.js";
21
- import { P as hs, J as gs, D as xs } from "./app-C39bYJmq.js";
22
- import { u as _s } from "./netsuite-Bv8m4JOq.js";
23
- import { s as gt, f as ws } from "./predefined-templates-CH1yqXrS.js";
24
- import { d as ks, t as Cs } from "./date2-ybHWeys0.js";
25
- import { F as xt } from "./form-mode.enum-BKiNVH6A.js";
26
- import { p as Fs } from "./format-time-from-id-CcnUAvw3.js";
27
- const Ss = {
28
- key: 0,
29
- class: "fixed inset-0 z-[200] bg-white flex flex-col overflow-hidden",
30
- style: { "font-family": "Inter, sans-serif" }
31
- }, Rs = {
32
- key: 0,
33
- class: "flex items-center justify-between px-24 h-[64px] border-b border-[#F0F0F0] shrink-0 bg-white"
34
- }, Ds = { class: "fm-typo-en-title-md-800 text-[#1C1C1E]" }, Es = { class: "flex items-center gap-8" }, Ps = {
35
- key: 1,
36
- class: "flex items-center justify-center px-32 py-16 border-b border-[#F0F0F0] shrink-0 bg-white"
37
- }, qs = { class: "flex items-center max-w-[600px] w-full" }, Ts = ["disabled"], Bs = { key: 1 }, Os = ["disabled"], As = { key: 1 }, Ns = {
38
- class: "flex flex-col items-center gap-4 min-w-0",
39
- disabled: !0
40
- }, Is = { class: "flex flex-1 overflow-hidden" }, $s = { class: "flex-1 min-w-0 overflow-y-auto" }, zs = {
41
- key: 0,
42
- class: "px-32 py-24"
43
- }, Ls = { class: "flex flex-col gap-4 mb-10" }, Ms = { class: "fm-typo-en-title-sm-700 text-[#1C1C1E]" }, Vs = { class: "fm-typo-en-body-md-400 text-[#4B4B4B]" }, Us = { class: "mb-12" }, js = { class: "border border-[#E0E0E0] rounded-sm overflow-hidden bg-white" }, Hs = ["onClick"], Ys = { class: "w-32 h-32 rounded-full bg-[#F0F0F0] flex items-center justify-center shrink-0" }, Qs = { class: "fm-typo-en-body-xs text-[#6B6C70]" }, Ws = { class: "flex-1 min-w-0" }, Zs = { class: "fm-typo-en-body-md-600 text-[#1C1C1E]" }, Ks = { class: "fm-typo-en-body-sm-400 text-[#6B6C70] truncate" }, Js = { class: "text-[10px] leading-[12px] font-semibold text-[#6B6C70] bg-[#F6F7F8] px-4 py-1 rounded-[4px] uppercase tracking-[0.08em] shrink-0" }, Xs = {
44
- key: 0,
45
- class: "w-[8px] h-[8px] rounded-full bg-[#FF7823]"
46
- }, Gs = {
47
- key: 0,
48
- class: "py-40 text-center text-[#B2B3B6] fm-typo-en-body-md-400"
49
- }, en = {
50
- key: 1,
51
- class: "px-32 py-24"
52
- }, tn = { class: "flex flex-col gap-4 mb-12" }, sn = { class: "fm-typo-en-title-sm-700 text-[#1C1C1E]" }, nn = { class: "fm-typo-en-body-md-400 text-[#4B4B4B]" }, on = { class: "grid grid-cols-2 gap-12 mb-12" }, an = { class: "flex items-start justify-between mb-12" }, rn = { class: "fm-typo-en-body-md-700 text-[#1C1C1E] mb-4" }, ln = { class: "fm-typo-en-body-sm-400 text-[#6B6C70]" }, un = { class: "flex items-start justify-between mb-12" }, cn = { class: "fm-typo-en-body-md-700 text-[#1C1C1E] mb-4" }, dn = { class: "fm-typo-en-body-sm-400 text-[#6B6C70]" }, mn = { class: "fm-typo-en-body-md-700 text-[#1C1C1E] mb-12" }, pn = { class: "mb-12" }, fn = { class: "border border-[#E0E0E0] rounded-xl overflow-hidden bg-white" }, vn = ["onClick"], yn = { class: "w-32 h-32 rounded-full bg-[#F0F0F0] flex items-center justify-center shrink-0" }, bn = { class: "fm-typo-en-body-xs-600 text-[#6B6C70]" }, hn = { class: "flex-1 min-w-0" }, gn = { class: "fm-typo-en-body-md-600 text-[#1C1C1E]" }, xn = { class: "fm-typo-en-body-sm-400 text-[#6B6C70] truncate" }, _n = { class: "text-[10px] leading-[12px] font-semibold text-[#6B6C70] bg-[#F6F7F8] px-4 py-1 rounded-[4px] uppercase tracking-[0.08em] shrink-0" }, wn = {
53
- key: 0,
54
- class: "w-[8px] h-[8px] rounded-full bg-[#FF7823]"
55
- }, kn = {
56
- key: 0,
57
- class: "py-32 text-center text-[#B2B3B6] fm-typo-en-body-md-400"
58
- }, Cn = { class: "fm-typo-en-body-md-700 text-[#1C1C1E] mb-12" }, Fn = { class: "mb-12" }, Sn = {
59
- key: 0,
60
- class: "py-32 flex justify-center"
61
- }, Rn = {
62
- key: 1,
63
- class: "py-32 text-center text-[#B2B3B6] fm-typo-en-body-md-400"
64
- }, Dn = {
65
- key: 2,
66
- class: "flex flex-col gap-8"
67
- }, En = ["onClick"], Pn = { class: "flex-1 min-w-0" }, qn = { class: "fm-typo-en-body-md-600 text-[#1C1C1E] mb-2" }, Tn = { class: "fm-typo-en-body-sm-400 text-[#6B6C70]" }, Bn = {
68
- key: 0,
69
- class: "w-[8px] h-[8px] rounded-full bg-[#FF7823]"
70
- }, On = {
71
- key: 2,
72
- class: "px-32 py-24"
73
- }, An = { class: "flex flex-col gap-4 mb-12" }, Nn = { class: "fm-typo-en-title-sm-700 text-[#1C1C1E]" }, In = { class: "w-[332px] shrink-0 border-l border-[#F0F0F0] overflow-y-auto bg-white" }, $n = { class: "p-4" }, zn = { class: "flex flex-col gap-0 border border-[#E9EAEC] rounded-2xl bg-white overflow-hidden" }, Ln = { class: "px-10 py-5 border-b border-[#F0F0F0]" }, Mn = { class: "fm-typo-en-body-md-700 text-[#1C1C1E]" }, Vn = { class: "flex flex-col gap-0.5 px-10 py-4 border-b border-[#F0F0F0]" }, Un = { class: "text-[11px] leading-[14px] font-medium text-[#6B6C70]" }, jn = {
74
- key: 0,
75
- class: "text-[11px] leading-[14px] text-[#6B6C70]"
76
- }, Hn = { class: "flex flex-col gap-0.5 px-10 py-4 border-b border-[#F0F0F0]" }, Yn = { class: "text-[11px] leading-[14px] font-medium text-[#6B6C70]" }, Qn = { class: "flex flex-col gap-0.5 px-10 py-4 border-b border-[#F0F0F0]" }, Wn = { class: "text-[11px] leading-[14px] font-medium text-[#6B6C70]" }, Zn = {
77
- key: 0,
78
- class: "text-[11px] leading-[14px] text-[#6B6C70]"
79
- }, Kn = { class: "flex items-center justify-between gap-8 px-10 py-4" }, Jn = { class: "text-[15px] leading-[20px] font-semibold text-[#1C1C1E]" }, Xn = { class: "fm-typo-en-title-md-600" }, Gn = { class: "flex flex-col gap-16" }, eo = { class: "fm-typo-en-body-md-400" }, to = { class: "max-h-[300px] overflow-y-auto" }, so = { class: "list-disc pl-16" }, no = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, oo = { class: "flex w-full gap-8 justify-end" }, ao = /* @__PURE__ */ lt({
80
- __name: "CreateTransferWizard",
81
- props: {
82
- show: { type: Boolean },
83
- lastClosingDate: {},
84
- selectedOutletIds: {}
85
- },
86
- emits: ["update:show", "submitted"],
87
- setup(ne, { emit: k }) {
88
- const { FmButton: z, FmDialog: U, FmIcon: j, FmTextField: D } = as, Z = ne, oe = k, { t: i } = We(), S = ut(), a = et(), ee = Ct(), X = Nt(), we = fs(), q = Ft(), T = St(), b = w(0), ue = w(!1), H = w(null), te = w(""), x = w(null), u = w(null), B = w(null), me = w(""), ce = w(""), K = w(!1), ye = w(!1), be = w(!1), pe = w(!1), Be = w(!1), Oe = w(/* @__PURE__ */ new Map()), Se = w(), ae = w([]), he = R(() => !!H.value), Ne = R(() => x.value === "transfer" ? !!u.value : x.value === "template" ? !!B.value : !1), ke = R(() => (ae.value.length ? ae.value : P.value.items ?? []).some((o) => o.quantity.amount > 0)), p = R(() => K.value), f = R(
89
- () => ke.value && ye.value && be.value && !K.value
90
- ), C = R(() => b.value === 0 ? he.value : b.value === 1 ? Ne.value : b.value === 2 ? f.value : !1), E = R(
91
- () => b.value === 2 ? i("inventory.transfer.receiveRequest.bulk.wizard.createTransferBtn") : i("inventory.transfer.receiveRequest.bulk.wizard.continueBtn")
92
- ), l = R(
93
- () => M.value === "Purchase" ? "Purchase method" : "Transfer method"
94
- ), r = R(
95
- () => M.value === "Purchase" ? "Purchase details" : "Transfer details"
96
- ), c = R(() => {
97
- const s = te.value.trim().toLowerCase();
98
- let o = a.locations;
99
- return Z.selectedOutletIds && Z.selectedOutletIds.length > 0 && (o = o.filter((n) => Z.selectedOutletIds.includes(n.doc._id))), s ? o.filter(
100
- (n) => n.name.toLowerCase().includes(s) || (n.doc.profile.code ?? "").toLowerCase().includes(s)
101
- ) : o;
102
- }), h = R(() => {
103
- var le;
104
- const s = (le = H.value) == null ? void 0 : le.doc._id, o = ee.suppliers.map((J) => ({
105
- doc: J,
106
- name: J.name,
107
- dbName: "",
108
- type: "supplier",
109
- acceptRequest: !0
110
- })), Y = [...a.allLocations ?? a.locations, ...o].filter((J) => J.doc._id !== s), W = me.value.trim().toLowerCase();
111
- return W ? Y.filter((J) => {
112
- var je;
113
- const qe = J.type === "supplier" ? "" : ((je = J.doc.profile) == null ? void 0 : je.code) ?? "";
114
- return J.name.toLowerCase().includes(W) || qe.toLowerCase().includes(W);
115
- }) : Y;
116
- }), y = R(() => {
117
- const s = ce.value.trim().toLowerCase(), o = T.templates;
118
- return s ? o.filter((n) => n.name.toLowerCase().includes(s)) : o;
119
- }), M = R(() => {
120
- var s;
121
- if (P.value.supplier)
122
- return typeof P.value.supplier.internal == "string" ? "Transfer" : "Purchase";
123
- if (x.value === "transfer" && u.value)
124
- return u.value.type === "supplier" ? "Purchase" : "Transfer";
125
- if (x.value === "template" && B.value) {
126
- const o = T.templates.find((n) => n._id === B.value);
127
- if ((s = o == null ? void 0 : o.purchaseOrder) != null && s.supplier)
128
- return typeof o.purchaseOrder.supplier.internal == "string" ? "Transfer" : "Purchase";
129
- }
130
- return "Transfer";
131
- }), A = R(() => H.value ? H.value.name : i("inventory.transfer.receiveRequest.bulk.wizard.notSelected")), v = R(() => x.value === "transfer" ? M.value === "Purchase" ? "Purchase from Supplier" : i("inventory.transfer.receiveRequest.bulk.wizard.outletToOutletMethod") : x.value === "template" ? i("inventory.transfer.receiveRequest.bulk.wizard.fromTemplateMethod") : i("inventory.transfer.receiveRequest.bulk.wizard.notChosen")), I = R(() => {
132
- var s;
133
- if (x.value === "transfer" && u.value)
134
- return u.value.name;
135
- if (x.value === "template" && B.value) {
136
- const o = T.templates.find((n) => n._id === B.value);
137
- return (s = o == null ? void 0 : o.purchaseOrder) != null && s.supplier ? o.purchaseOrder.supplier.name || B.value : (o == null ? void 0 : o.name) ?? B.value;
138
- }
139
- return i("inventory.transfer.receiveRequest.bulk.wizard.noneYet");
140
- });
141
- function de(s) {
142
- var Y, W, le, J, qe;
143
- const o = (Y = s.doc.profile) != null && Y.code ? `#${s.doc.profile.code}` : "", n = [(le = (W = s.doc.profile) == null ? void 0 : W.address) == null ? void 0 : le.line1, (qe = (J = s.doc.profile) == null ? void 0 : J.address) == null ? void 0 : qe.city].filter(Boolean).join(" · ");
144
- return [o, n].filter(Boolean).join(" · ");
145
- }
146
- function ge(s) {
147
- var n, Y;
148
- return [(n = s.doc.address) == null ? void 0 : n.line1, (Y = s.doc.address) == null ? void 0 : Y.city].filter(Boolean).join(" · ");
149
- }
150
- function G(s) {
151
- var o;
152
- return s.type === "supplier" ? "" : ((o = s.doc.profile) == null ? void 0 : o.code) ?? "";
153
- }
154
- function Q(s) {
155
- var o, n, Y, W, le, J;
156
- return s.type === "supplier" ? [(o = s.doc.address) == null ? void 0 : o.line1, (n = s.doc.address) == null ? void 0 : n.city].filter(Boolean).join(" · ") : [(W = (Y = s.doc.profile) == null ? void 0 : Y.address) == null ? void 0 : W.line1, (J = (le = s.doc.profile) == null ? void 0 : le.address) == null ? void 0 : J.city].filter(Boolean).join(" · ");
157
- }
158
- const re = R(
159
- () => H.value ? de(H.value) : ""
160
- ), xe = R(
161
- () => x.value === "transfer" && u.value ? u.value.type === "supplier" ? ge(u.value) : de(u.value) : ""
162
- ), Ee = R(() => {
163
- const o = (ae.value.length ? ae.value : P.value.items ?? []).filter((n) => n.quantity.amount > 0).length;
164
- return o === 0 ? i("inventory.transfer.receiveRequest.bulk.wizard.noneYet") : `${o} ${o === 1 ? "item" : "items"}`;
165
- });
166
- function _(s) {
167
- var n;
168
- const o = (n = s.purchaseOrder) == null ? void 0 : n.supplier;
169
- return o ? o.internal === "warehouse" ? `Transfer from ${o.name}` : o.internal === "restaurant" ? `Transfer from ${o.name}` : `Purchase from ${o.name}` : "";
170
- }
171
- function V(s) {
172
- return {
173
- _id: s.doc._id,
174
- internal: s.type,
175
- contactName: s.doc.profile.name,
176
- name: s.doc.profile.name ?? "",
177
- email: s.doc.profile.email,
178
- phoneNumber: s.doc.profile.phoneNo,
179
- registrationNumber: s.doc.profile.regNo ?? "",
180
- address: s.doc.profile.address ?? {
181
- line1: "",
182
- state: "",
183
- city: "",
184
- postcode: "",
185
- country: ""
186
- }
187
- };
188
- }
189
- function N(s) {
190
- return {
191
- _id: s._id,
192
- internal: void 0,
193
- contactName: s.contactName,
194
- name: s.name ?? "",
195
- email: s.email,
196
- phoneNumber: s.phoneNumber,
197
- registrationNumber: s.registrationNumber ?? "",
198
- supplyItems: s.supplyItems,
199
- _rev: s._rev,
200
- address: s.address ?? {
201
- line2: void 0,
202
- line1: "",
203
- state: "",
204
- city: "",
205
- postcode: "",
206
- country: ""
207
- }
208
- };
209
- }
210
- function L() {
211
- var Y;
212
- const s = B.value ? T.templates.find((W) => W._id === B.value) : void 0, o = {
213
- _rev: void 0,
214
- email: void 0,
215
- internal: void 0,
216
- contactName: void 0,
217
- phoneNumber: void 0,
218
- registrationNumber: "",
219
- supplyItems: void 0,
220
- _id: "",
221
- name: "",
222
- address: { line2: void 0, line1: "", state: "", city: "", postcode: "", country: "" }
223
- }, n = x.value === "transfer" && u.value ? u.value.type === "supplier" ? N(u.value.doc) : V(u.value) : x.value === "template" && (s != null && s.purchaseOrder.supplier) ? s.purchaseOrder.supplier : o;
224
- return {
225
- remark: void 0,
226
- ref: void 0,
227
- stockSnapshotId: void 0,
228
- effectiveAt: void 0,
229
- items: x.value === "template" && ((Y = s == null ? void 0 : s.purchaseOrder) != null && Y.items) ? s.purchaseOrder.items : [],
230
- supplier: n,
231
- status: "DRAFT",
232
- _id: "",
233
- seqNumber: 0,
234
- deliveryOrder: [],
235
- template: B.value ?? void 0,
236
- templateDoc: s
237
- };
238
- }
239
- const P = w(L()), se = w(`${Math.random()}`), fe = R(
240
- () => {
241
- var s;
242
- return ((s = P.value.items) == null ? void 0 : s.filter((o) => o.quantity.amount === 0)) ?? [];
243
- }
244
- );
245
- ze(
246
- () => Z.show,
247
- (s) => {
248
- if (s && (b.value = 0, ue.value = !1, H.value = null, x.value = null, u.value = null, B.value = null, te.value = "", me.value = "", ce.value = "", ye.value = !1, be.value = !1, ae.value = [], P.value = L(), se.value = `${Math.random()}`, T.fetchTemplates(), Z.selectedOutletIds && Z.selectedOutletIds.length === 1)) {
249
- const o = a.locations.find(
250
- (n) => n.doc._id === Z.selectedOutletIds[0]
251
- );
252
- o && (H.value = o, a._currentLocation = o, Ve(), Ue(), b.value = 1);
253
- }
254
- }
255
- );
256
- function Ie() {
257
- if (b.value === 0) {
258
- if (!H.value) return;
259
- a._currentLocation = H.value, Ve(), Ue(), b.value = 1;
260
- } else if (b.value === 1) {
261
- if (!Ne.value) return;
262
- P.value = L(), se.value = `${Math.random()}`, ae.value = [], b.value = 2;
263
- } else b.value === 2 && $e();
264
- }
265
- function Le() {
266
- b.value > 0 && b.value--;
267
- }
268
- function Re(s) {
269
- s < b.value && (b.value = s);
270
- }
271
- function Me() {
272
- oe("update:show", !1);
273
- }
274
- function Ce(s) {
275
- x.value !== s && (x.value = s, u.value = null, B.value = null, ae.value = [], P.value = {
276
- ...P.value,
277
- items: [],
278
- template: void 0,
279
- templateDoc: void 0
280
- });
281
- }
282
- function Pe(s) {
283
- ae.value = s ?? [];
284
- }
285
- ze(B, (s) => {
286
- x.value === "template" && s && (P.value = L(), se.value = `${Math.random()}`);
287
- });
288
- async function Ve() {
289
- ye.value = !1;
290
- try {
291
- await ee.readSuppliers(), ye.value = !0;
292
- } catch {
293
- S.open({
294
- title: i("inventory.transfer.form.unableToFetchListOfSuppliers.title"),
295
- message: i("inventory.transfer.form.unableToFetchListOfSuppliers.message"),
296
- type: "error"
297
- });
298
- }
299
- }
300
- async function Ue() {
301
- Be.value = !0, Oe.value = /* @__PURE__ */ new Map();
302
- try {
303
- const s = await we.readStockBalance(), o = /* @__PURE__ */ new Map();
304
- for (const n of s.skus ?? [])
305
- o.set(n.id, n);
306
- Oe.value = o;
307
- } catch {
308
- } finally {
309
- Be.value = !1;
310
- }
311
- }
312
- function Ze() {
313
- var s;
314
- (s = Se.value) != null && s.getFormData && (P.value = { ...P.value, ...Se.value.getFormData() });
315
- }
316
- function $e() {
317
- if (Ze(), fe.value.length > 0) {
318
- pe.value = !0;
319
- return;
320
- }
321
- Je();
322
- }
323
- function Ke() {
324
- var s;
325
- P.value.items = ((s = P.value.items) == null ? void 0 : s.filter((o) => o.quantity.amount > 0)) ?? [], pe.value = !1, Je();
326
- }
327
- function Je() {
328
- var n, Y;
329
- const s = ys.validatePurchaseOrderItems({
330
- skusById: X.skuById ?? {},
331
- items: P.value.items ?? []
332
- }), o = Object.values(s).flat();
333
- if (o.length > 0) {
334
- const W = o[0];
335
- S.open({
336
- title: `[Row ${W.index + 1}] "${W.poItem.sku.name}"`,
337
- message: `${W.message}`,
338
- type: "error"
339
- });
340
- return;
341
- }
342
- (Y = (n = Se.value) == null ? void 0 : n.validateInputs) == null || Y.call(n);
343
- }
344
- async function Dt() {
345
- const s = P.value;
346
- if (K.value = !0, s.items = s.items.filter((o) => o.quantity.amount > 0), !s.items.length) {
347
- S.open({
348
- title: "Cannot create order",
349
- message: "There are no items with non-zero amount in your request.",
350
- type: "error"
351
- }), K.value = !1;
352
- return;
353
- }
354
- (s.supplier.internal === "warehouse" || s.supplier.internal === "restaurant") && (s.items = s.items.map(({ totalCost: o, ...n }) => n));
355
- try {
356
- await q.createPurchaseOrder(s), S.open({
357
- title: i("inventory.transfer.receiveRequest.create.success"),
358
- message: i("inventory.transfer.receiveRequest.create.successMessage"),
359
- type: "success"
360
- }), oe("submitted"), oe("update:show", !1), Et();
361
- } catch (o) {
362
- S.open({
363
- title: i("inventory.transfer.receiveRequest.create.error.title"),
364
- message: i("inventory.transfer.receiveRequest.create.error.message"),
365
- type: "error"
366
- }), console.error("Error creating purchase order", o);
367
- } finally {
368
- K.value = !1;
369
- }
370
- }
371
- function Et() {
372
- b.value = 0, ue.value = !1, H.value = null, x.value = null, u.value = null, B.value = null, te.value = "", me.value = "", ce.value = "", ye.value = !1, be.value = !1, ae.value = [], P.value = L(), se.value = `${Math.random()}`;
373
- }
374
- return (s, o) => (m(), g(_e, null, [
375
- (m(), ie(wt, { to: "body" }, [
376
- F(Pt, {
377
- "enter-active-class": "transition-opacity duration-150 ease-out",
378
- "enter-from-class": "opacity-0",
379
- "enter-to-class": "opacity-100",
380
- "leave-active-class": "transition-opacity duration-120 ease-in",
381
- "leave-from-class": "opacity-100",
382
- "leave-to-class": "opacity-0"
383
- }, {
384
- default: Fe(() => [
385
- s.show ? (m(), g("div", Ss, [
386
- ue.value ? $("", !0) : (m(), g("div", Rs, [
387
- e("span", Ds, d(t(i)("inventory.transfer.receiveRequest.bulk.wizard.title")), 1),
388
- e("div", Es, [
389
- F(t(z), {
390
- variant: "tertiary",
391
- size: "md",
392
- label: t(i)("inventory.transfer.receiveRequest.bulk.wizard.cancelBtn"),
393
- onClick: Me
394
- }, null, 8, ["label"]),
395
- b.value > 0 ? (m(), ie(t(z), {
396
- key: 0,
397
- variant: "secondary",
398
- size: "md",
399
- "prepend-icon": "arrow_back",
400
- label: t(i)("inventory.transfer.receiveRequest.bulk.wizard.backBtn"),
401
- onClick: Le
402
- }, null, 8, ["label"])) : $("", !0),
403
- F(t(z), {
404
- size: "md",
405
- disabled: !C.value,
406
- loading: K.value,
407
- label: E.value,
408
- onClick: Ie
409
- }, null, 8, ["disabled", "loading", "label"])
410
- ])
411
- ])),
412
- ue.value ? $("", !0) : (m(), g("div", Ps, [
413
- e("div", qs, [
414
- e("button", {
415
- class: "flex flex-col items-center gap-4 min-w-0 group",
416
- disabled: b.value <= 0,
417
- onClick: o[0] || (o[0] = (n) => Re(0))
418
- }, [
419
- e("div", {
420
- class: O([
421
- "w-32 h-32 rounded-full flex items-center justify-center text-sm font-semibold transition-colors duration-150",
422
- b.value > 0 || b.value === 0 ? "bg-[#FF7823] text-white" : "bg-[#F0F0F0] text-[#6B6C70]"
423
- ])
424
- }, [
425
- b.value > 0 ? (m(), ie(t(j), {
426
- key: 0,
427
- name: "check",
428
- size: "sm"
429
- })) : (m(), g("span", Bs, "1"))
430
- ], 2),
431
- e("span", {
432
- class: O(["fm-typo-en-body-xs-500 whitespace-nowrap transition-colors duration-150", b.value >= 0 ? "text-[#1C1C1E]" : "text-[#B2B3B6]"])
433
- }, " Select destination ", 2)
434
- ], 8, Ts),
435
- e("div", {
436
- class: O(["flex-1 h-1 mx-8 transition-colors duration-200", b.value > 0 ? "bg-[#FF7823]" : "bg-[#E0E0E0]"])
437
- }, null, 2),
438
- e("button", {
439
- class: "flex flex-col items-center gap-4 min-w-0 group",
440
- disabled: b.value <= 1,
441
- onClick: o[1] || (o[1] = (n) => Re(1))
442
- }, [
443
- e("div", {
444
- class: O([
445
- "w-32 h-32 rounded-full flex items-center justify-center text-sm font-semibold transition-colors duration-150",
446
- b.value > 1 || b.value === 1 ? "bg-[#FF7823] text-white" : "bg-[#F0F0F0] text-[#6B6C70]"
447
- ])
448
- }, [
449
- b.value > 1 ? (m(), ie(t(j), {
450
- key: 0,
451
- name: "check",
452
- size: "sm"
453
- })) : (m(), g("span", As, "2"))
454
- ], 2),
455
- e("span", {
456
- class: O(["fm-typo-en-body-xs-500 whitespace-nowrap transition-colors duration-150", b.value >= 1 ? "text-[#1C1C1E]" : "text-[#B2B3B6]"])
457
- }, d(l.value), 3)
458
- ], 8, Os),
459
- e("div", {
460
- class: O(["flex-1 h-1 mx-8 transition-colors duration-200", b.value > 1 ? "bg-[#FF7823]" : "bg-[#E0E0E0]"])
461
- }, null, 2),
462
- e("button", Ns, [
463
- e("div", {
464
- class: O([
465
- "w-32 h-32 rounded-full flex items-center justify-center text-sm font-semibold transition-colors duration-150",
466
- b.value === 2 ? "bg-[#FF7823] text-white" : "bg-[#F0F0F0] text-[#6B6C70]"
467
- ])
468
- }, o[11] || (o[11] = [
469
- e("span", null, "3", -1)
470
- ]), 2),
471
- e("span", {
472
- class: O(["fm-typo-en-body-xs-500 whitespace-nowrap transition-colors duration-150", b.value >= 2 ? "text-[#1C1C1E]" : "text-[#B2B3B6]"])
473
- }, d(r.value), 3)
474
- ])
475
- ])
476
- ])),
477
- e("div", Is, [
478
- e("div", $s, [
479
- b.value === 0 ? (m(), g("div", zs, [
480
- e("div", Ls, [
481
- e("h3", Ms, d(t(i)("inventory.transfer.receiveRequest.bulk.wizard.step1Heading")), 1),
482
- e("p", Vs, d(t(i)("inventory.transfer.receiveRequest.bulk.wizard.step1Desc")), 1)
483
- ]),
484
- e("div", Us, [
485
- F(t(D), {
486
- "model-value": te.value,
487
- "onUpdate:modelValue": o[2] || (o[2] = (n) => te.value = n),
488
- "prepend-icon": "search",
489
- placeholder: t(i)("inventory.transfer.receiveRequest.bulk.wizard.step1SearchPlaceholder")
490
- }, null, 8, ["model-value", "placeholder"])
491
- ]),
492
- e("div", js, [
493
- (m(!0), g(_e, null, Qe(c.value, (n, Y) => {
494
- var W, le, J, qe, je, ct, dt;
495
- return m(), g("div", {
496
- key: n.dbName,
497
- class: O(["flex items-center gap-8 px-12 h-[67px] cursor-pointer transition-colors duration-150", [
498
- ((W = H.value) == null ? void 0 : W.dbName) === n.dbName ? "bg-[#FFF5EE]" : "hover:bg-[#FAFAFA]",
499
- Y > 0 ? "border-t border-[#F0F0F0]" : ""
500
- ]]),
501
- onClick: (To) => H.value = n
502
- }, [
503
- e("div", Ys, [
504
- e("span", Qs, d(n.name.slice(0, 2).toUpperCase()), 1)
505
- ]),
506
- e("div", Ws, [
507
- e("div", Zs, d(n.name), 1),
508
- e("div", Ks, [
509
- Xe(d(n.doc.profile.code ? `#${n.doc.profile.code}` : t(i)("inventory.transfer.receiveRequest.bulk.wizard.noCode")) + " ", 1),
510
- (le = n.doc.profile.address) != null && le.line1 || (J = n.doc.profile.address) != null && J.city ? (m(), g(_e, { key: 0 }, [
511
- Xe(" · " + d([(qe = n.doc.profile.address) == null ? void 0 : qe.line1, (je = n.doc.profile.address) == null ? void 0 : je.city].filter(Boolean).join(" · ")), 1)
512
- ], 64)) : $("", !0)
513
- ])
514
- ]),
515
- e("span", Js, d(n.type === "warehouse" ? "Warehouse" : "Restaurant"), 1),
516
- e("div", {
517
- class: O([
518
- "w-[18px] h-[18px] rounded-full border flex items-center justify-center shrink-0 transition-colors duration-150",
519
- ((ct = H.value) == null ? void 0 : ct.dbName) === n.dbName ? "border-[#FF7823]" : "border-[#CCCCCC]"
520
- ])
521
- }, [
522
- ((dt = H.value) == null ? void 0 : dt.dbName) === n.dbName ? (m(), g("div", Xs)) : $("", !0)
523
- ], 2)
524
- ], 10, Hs);
525
- }), 128)),
526
- c.value.length === 0 ? (m(), g("div", Gs, d(t(i)("inventory.transfer.receiveRequest.bulk.wizard.noOutletsAvailable")), 1)) : $("", !0)
527
- ])
528
- ])) : $("", !0),
529
- b.value === 1 ? (m(), g("div", en, [
530
- e("div", tn, [
531
- e("h3", sn, d(t(i)("inventory.transfer.receiveRequest.bulk.wizard.step2Heading")), 1),
532
- e("p", nn, d(t(i)("inventory.transfer.receiveRequest.bulk.wizard.step2Desc")), 1)
533
- ]),
534
- e("div", on, [
535
- e("div", {
536
- class: O([
537
- "border rounded-xl p-16 cursor-pointer transition-all duration-150 flex flex-col",
538
- x.value === "transfer" ? "border-[#FF7823] bg-[#FFF5EE]" : "border-[#E0E0E0] bg-white hover:bg-[#FAFAFA]"
539
- ]),
540
- onClick: o[3] || (o[3] = (n) => Ce("transfer"))
541
- }, [
542
- e("div", an, [
543
- e("div", {
544
- class: O(["w-36 h-36 rounded-xl flex items-center justify-center shrink-0", x.value === "transfer" ? "bg-[#FF7823]" : "bg-[#F0F0F0]"])
545
- }, [
546
- F(t(j), {
547
- name: "swap_horiz",
548
- size: "md",
549
- class: O(x.value === "transfer" ? "text-white" : "text-[#6B6C70]")
550
- }, null, 8, ["class"])
551
- ], 2),
552
- e("div", {
553
- class: O(["w-16 h-16 rounded-full flex items-center justify-center shrink-0", x.value === "transfer" ? "bg-[#FF7823]" : "border border-[#CCCCCC]"])
554
- }, [
555
- x.value === "transfer" ? (m(), ie(t(j), {
556
- key: 0,
557
- name: "check",
558
- size: "sm",
559
- class: "text-white"
560
- })) : $("", !0)
561
- ], 2)
562
- ]),
563
- e("div", rn, d(t(i)("inventory.transfer.receiveRequest.bulk.wizard.outletToOutlet")), 1),
564
- e("div", ln, d(t(i)("inventory.transfer.receiveRequest.bulk.wizard.outletToOutletDesc")), 1)
565
- ], 2),
566
- e("div", {
567
- class: O([
568
- "border rounded-xl p-16 cursor-pointer transition-all duration-150 flex flex-col",
569
- x.value === "template" ? "border-[#FF7823] bg-[#FFF5EE]" : "border-[#E0E0E0] bg-white hover:bg-[#FAFAFA]"
570
- ]),
571
- onClick: o[4] || (o[4] = (n) => Ce("template"))
572
- }, [
573
- e("div", un, [
574
- e("div", {
575
- class: O(["w-36 h-36 rounded-xl flex items-center justify-center shrink-0", x.value === "template" ? "bg-[#FF7823]" : "bg-[#F0F0F0]"])
576
- }, [
577
- F(t(j), {
578
- name: "description",
579
- size: "md",
580
- class: O(x.value === "template" ? "text-white" : "text-[#6B6C70]")
581
- }, null, 8, ["class"])
582
- ], 2),
583
- e("div", {
584
- class: O(["w-16 h-16 rounded-full flex items-center justify-center shrink-0", x.value === "template" ? "bg-[#FF7823]" : "border border-[#CCCCCC]"])
585
- }, [
586
- x.value === "template" ? (m(), ie(t(j), {
587
- key: 0,
588
- name: "check",
589
- size: "sm",
590
- class: "text-white"
591
- })) : $("", !0)
592
- ], 2)
593
- ]),
594
- e("div", cn, d(t(i)("inventory.transfer.receiveRequest.bulk.wizard.fromTemplate")), 1),
595
- e("div", dn, d(t(i)("inventory.transfer.receiveRequest.bulk.wizard.fromTemplateDesc")), 1)
596
- ], 2)
597
- ]),
598
- x.value === "transfer" ? (m(), g(_e, { key: 0 }, [
599
- e("div", mn, d(t(i)("inventory.transfer.receiveRequest.bulk.wizard.step2SourceHeading")), 1),
600
- e("div", pn, [
601
- F(t(D), {
602
- "model-value": me.value,
603
- "onUpdate:modelValue": o[5] || (o[5] = (n) => me.value = n),
604
- "prepend-icon": "search",
605
- placeholder: t(i)(
606
- "inventory.transfer.receiveRequest.bulk.wizard.step2SearchSourcePlaceholder"
607
- )
608
- }, null, 8, ["model-value", "placeholder"])
609
- ]),
610
- e("div", fn, [
611
- (m(!0), g(_e, null, Qe(h.value, (n, Y) => {
612
- var W, le, J;
613
- return m(), g("div", {
614
- key: n.dbName,
615
- class: O(["flex items-center gap-8 px-12 h-[67px] cursor-pointer transition-colors duration-150", [
616
- ((W = u.value) == null ? void 0 : W.doc._id) === n.doc._id ? "bg-[#FFF5EE]" : "hover:bg-[#FAFAFA]",
617
- Y > 0 ? "border-t border-[#F0F0F0]" : ""
618
- ]]),
619
- onClick: (qe) => u.value = n
620
- }, [
621
- e("div", yn, [
622
- e("span", bn, d(n.name.slice(0, 2).toUpperCase()), 1)
623
- ]),
624
- e("div", hn, [
625
- e("div", gn, d(n.name), 1),
626
- e("div", xn, [
627
- Xe(d(G(n) ? `#${G(n)}` : t(i)("inventory.transfer.receiveRequest.bulk.wizard.noCode")) + " ", 1),
628
- Q(n) ? (m(), g(_e, { key: 0 }, [
629
- Xe(" · " + d(Q(n)), 1)
630
- ], 64)) : $("", !0)
631
- ])
632
- ]),
633
- e("span", _n, d(n.type === "warehouse" ? "Warehouse" : n.type === "supplier" ? "Supplier" : "Restaurant"), 1),
634
- e("div", {
635
- class: O([
636
- "w-[18px] h-[18px] rounded-full border flex items-center justify-center shrink-0 transition-colors duration-150",
637
- ((le = u.value) == null ? void 0 : le.doc._id) === n.doc._id ? "border-[#FF7823]" : "border-[#CCCCCC]"
638
- ])
639
- }, [
640
- ((J = u.value) == null ? void 0 : J.doc._id) === n.doc._id ? (m(), g("div", wn)) : $("", !0)
641
- ], 2)
642
- ], 10, vn);
643
- }), 128)),
644
- h.value.length === 0 ? (m(), g("div", kn, d(t(i)("inventory.transfer.receiveRequest.bulk.wizard.noOutletsAvailable")), 1)) : $("", !0)
645
- ])
646
- ], 64)) : $("", !0),
647
- x.value === "template" ? (m(), g(_e, { key: 1 }, [
648
- e("div", Cn, d(t(i)("inventory.transfer.receiveRequest.bulk.wizard.step2TemplateHeading")), 1),
649
- e("div", Fn, [
650
- F(t(D), {
651
- "model-value": ce.value,
652
- "onUpdate:modelValue": o[6] || (o[6] = (n) => ce.value = n),
653
- "prepend-icon": "search",
654
- placeholder: t(i)(
655
- "inventory.transfer.receiveRequest.bulk.wizard.step2SearchTemplatePlaceholder"
656
- )
657
- }, null, 8, ["model-value", "placeholder"])
658
- ]),
659
- t(T).loading ? (m(), g("div", Sn, [
660
- F(t(j), {
661
- name: "progress_activity",
662
- class: "text-[#FF7823] animate-spin"
663
- })
664
- ])) : y.value.length === 0 ? (m(), g("div", Rn, d(t(i)("inventory.transfer.receiveRequest.bulk.wizard.noTemplatesAvailable")), 1)) : (m(), g("div", Dn, [
665
- (m(!0), g(_e, null, Qe(y.value, (n) => (m(), g("div", {
666
- key: n._id,
667
- class: O([
668
- "border rounded-lg px-16 py-12 cursor-pointer transition-all duration-150 flex items-center gap-12",
669
- B.value === n._id ? "border-[#FF7823] bg-[#FFF5EE]" : "border-[#E0E0E0] bg-white hover:bg-[#FAFAFA]"
670
- ]),
671
- onClick: (Y) => B.value = n._id
672
- }, [
673
- e("div", Pn, [
674
- e("div", qn, d(n.name), 1),
675
- e("div", Tn, d(_(n)) + " · " + d(n.purchaseOrder.items.length) + " items ", 1)
676
- ]),
677
- e("div", {
678
- class: O([
679
- "w-[18px] h-[18px] rounded-full border flex items-center justify-center shrink-0 transition-colors duration-150",
680
- B.value === n._id ? "border-[#FF7823]" : "border-[#CCCCCC]"
681
- ])
682
- }, [
683
- B.value === n._id ? (m(), g("div", Bn)) : $("", !0)
684
- ], 2)
685
- ], 10, En))), 128))
686
- ]))
687
- ], 64)) : $("", !0)
688
- ])) : $("", !0),
689
- b.value === 2 ? (m(), g("div", On, [
690
- e("div", An, [
691
- e("h3", Nn, d(r.value), 1)
692
- ]),
693
- (m(), ie(is, {
694
- ref_key: "formRef",
695
- ref: Se,
696
- class: "w-full",
697
- "onForm:ready": o[7] || (o[7] = () => be.value = !0),
698
- "onForm:dataChange": Pe,
699
- onValidationSuccess: Dt,
700
- modelValue: P.value,
701
- "onUpdate:modelValue": o[8] || (o[8] = (n) => P.value = n),
702
- disabled: p.value,
703
- "locked-supplier": P.value.supplier,
704
- suppliers: t(ee).suppliers,
705
- skus: t(X).skus,
706
- key: se.value,
707
- "last-closing-date": s.lastClosingDate,
708
- "sku-balance-map": Oe.value,
709
- "is-balance-loading": Be.value
710
- }, null, 8, ["modelValue", "disabled", "locked-supplier", "suppliers", "skus", "last-closing-date", "sku-balance-map", "is-balance-loading"]))
711
- ])) : $("", !0)
712
- ]),
713
- e("div", In, [
714
- e("div", $n, [
715
- e("div", zn, [
716
- e("div", Ln, [
717
- e("div", Mn, d(t(i)("inventory.transfer.receiveRequest.bulk.wizard.summaryTitle")), 1)
718
- ]),
719
- e("div", Vn, [
720
- e("span", Un, d(t(i)("inventory.transfer.receiveRequest.bulk.wizard.summaryDestination")), 1),
721
- e("span", {
722
- class: O(["text-[15px] leading-[20px] font-semibold transition-colors duration-200", H.value ? "text-[#1C1C1E]" : "text-[#B2B3B6]"])
723
- }, d(A.value), 3),
724
- re.value ? (m(), g("span", jn, d(re.value), 1)) : $("", !0)
725
- ]),
726
- e("div", Hn, [
727
- e("span", Yn, d(t(i)("inventory.transfer.receiveRequest.bulk.wizard.summaryMethod")), 1),
728
- e("span", {
729
- class: O(["text-[15px] leading-[20px] font-semibold transition-colors duration-200", x.value ? "text-[#1C1C1E]" : "text-[#B2B3B6]"])
730
- }, d(v.value), 3)
731
- ]),
732
- e("div", Qn, [
733
- e("span", Wn, d(t(i)("inventory.transfer.receiveRequest.bulk.wizard.summarySource")), 1),
734
- e("span", {
735
- class: O([
736
- "text-[15px] leading-[20px] font-semibold transition-colors duration-200",
737
- u.value || B.value ? "text-[#1C1C1E]" : "text-[#B2B3B6]"
738
- ])
739
- }, d(I.value), 3),
740
- xe.value ? (m(), g("span", Zn, d(xe.value), 1)) : $("", !0)
741
- ]),
742
- e("div", Kn, [
743
- e("span", Jn, d(t(i)("inventory.transfer.receiveRequest.bulk.wizard.summaryItems")), 1),
744
- e("span", {
745
- class: O(["text-[15px] leading-[20px] font-medium transition-colors duration-200", ke.value ? "text-[#1C1C1E]" : "text-[#6B6C70]"])
746
- }, d(Ee.value), 3)
747
- ])
748
- ])
749
- ])
750
- ])
751
- ])
752
- ])) : $("", !0)
753
- ]),
754
- _: 1
755
- })
756
- ])),
757
- F(t(U), {
758
- modelValue: pe.value,
759
- "onUpdate:modelValue": o[10] || (o[10] = (n) => pe.value = n),
760
- overlay: !0
761
- }, {
762
- "dialog-header": Fe(() => [
763
- e("div", Xn, d(t(i)("inventory.transfer.template.zeroQuantity.title")), 1)
764
- ]),
765
- "dialog-footer": Fe(() => [
766
- e("div", oo, [
767
- F(t(z), {
768
- label: t(i)("common.cancel"),
769
- variant: "tertiary",
770
- size: "md",
771
- onClick: o[9] || (o[9] = (n) => pe.value = !1)
772
- }, null, 8, ["label"]),
773
- F(t(z), {
774
- label: t(i)("inventory.transfer.template.zeroQuantity.removeAll"),
775
- variant: "primary",
776
- size: "md",
777
- "prepend-icon": "delete",
778
- onClick: Ke
779
- }, null, 8, ["label"])
780
- ])
781
- ]),
782
- default: Fe(() => [
783
- e("div", Gn, [
784
- e("div", eo, d(t(i)("inventory.transfer.template.zeroQuantity.message", {
785
- count: fe.value.length
786
- })), 1),
787
- e("div", to, [
788
- e("ul", so, [
789
- (m(!0), g(_e, null, Qe(fe.value, (n) => (m(), g("li", {
790
- key: n.sku._id,
791
- class: "fm-typo-en-body-md-400"
792
- }, d(n.sku.name) + " (" + d(n.sku.code) + ") ", 1))), 128))
793
- ])
794
- ]),
795
- e("div", no, d(t(i)("inventory.transfer.template.zeroQuantity.prompt")), 1)
796
- ])
797
- ]),
798
- _: 1
799
- }, 8, ["modelValue"])
800
- ], 64));
801
- }
802
- }), ro = /* @__PURE__ */ lt({
803
- __name: "MultiLocationSelector",
804
- props: /* @__PURE__ */ qt({
805
- locations: {}
806
- }, {
807
- modelValue: { default: () => [] },
808
- modelModifiers: {}
809
- }),
810
- emits: ["update:modelValue"],
811
- setup(ne) {
812
- const { t: k } = We(), z = ne, U = Tt(ne, "modelValue"), j = w(!1), D = w(""), Z = R(() => {
813
- const q = D.value.trim().toLowerCase();
814
- return q ? z.locations.filter(
815
- (T) => T.name.toLowerCase().includes(q) || (T.doc.profile.code ?? "").toLowerCase().includes(q)
816
- ) : z.locations;
817
- }), oe = R(() => U.value.length), i = R(
818
- () => Z.value.length > 0 && Z.value.every((q) => U.value.includes(q.dbName))
819
- ), S = R(
820
- () => Z.value.some((q) => U.value.includes(q.dbName)) && !i.value
821
- ), a = R(() => {
822
- if (oe.value === 0) return k("inventory.transfer.receiveRequest.bulk.noLocationsSelected");
823
- if (oe.value === 1) {
824
- const q = z.locations.find((T) => T.dbName === U.value[0]);
825
- return q ? `${q.name} (${q.doc.profile.code ?? "--"})` : U.value[0];
826
- }
827
- return k("inventory.transfer.receiveRequest.bulk.locationsSelected", [oe.value]);
828
- });
829
- function ee() {
830
- const q = Z.value.map((T) => T.dbName);
831
- i.value ? U.value = U.value.filter((T) => !q.includes(T)) : U.value = [.../* @__PURE__ */ new Set([...U.value, ...q])];
832
- }
833
- function X(q) {
834
- U.value.includes(q) ? U.value = U.value.filter((T) => T !== q) : U.value = [...U.value, q];
835
- }
836
- function we(q) {
837
- return U.value.includes(q);
838
- }
839
- return (q, T) => {
840
- const b = De("FmIcon"), ue = De("FmChip"), H = De("FmTextField"), te = De("FmMenuItem"), x = De("FmMenu");
841
- return m(), ie(x, {
842
- "model-value": j.value,
843
- placement: "bottom-end",
844
- "close-on-click": !1,
845
- onMenuChanged: T[1] || (T[1] = (u) => {
846
- j.value = u, u || (D.value = "");
847
- })
848
- }, {
849
- "menu-button": Fe(() => [
850
- F(ue, {
851
- label: a.value,
852
- class: "text-fm-color-neutral-gray-400 cursor-pointer"
853
- }, {
854
- default: Fe(() => [
855
- F(b, {
856
- name: "storefront",
857
- outline: "",
858
- size: "sm"
859
- }),
860
- e("div", {
861
- class: O(["fm-typo-en-body-md-600 select-none text-ellipsis overflow-hidden whitespace-nowrap max-w-[200px]", { "text-fm-color-typo-primary": oe.value > 0 }])
862
- }, d(a.value), 3),
863
- F(b, {
864
- name: j.value ? "keyboard_arrow_up" : "keyboard_arrow_down",
865
- outline: "",
866
- size: "sm"
867
- }, null, 8, ["name"])
868
- ]),
869
- _: 1
870
- }, 8, ["label"])
871
- ]),
872
- default: Fe(() => [
873
- F(H, {
874
- "model-value": D.value,
875
- "onUpdate:modelValue": T[0] || (T[0] = (u) => D.value = u),
876
- placeholder: t(k)("inventory.common.table.toolbar.filterItems"),
877
- class: "my-8"
878
- }, null, 8, ["model-value", "placeholder"]),
879
- F(te, {
880
- "model-value": i.value,
881
- label: t(k)("inventory.common.selectAll"),
882
- "has-checkbox": !0,
883
- indeterminate: S.value,
884
- onClick: ee
885
- }, null, 8, ["model-value", "label", "indeterminate"]),
886
- (m(!0), g(_e, null, Qe(Z.value, (u) => (m(), ie(te, {
887
- key: u.dbName,
888
- "model-value": we(u.dbName),
889
- label: `${u.name} (${u.doc.profile.code ?? "--"})`,
890
- sublabel: u.type === "restaurant" ? t(k)("inventory.common.restaurant") : t(k)("inventory.common.warehouse"),
891
- "has-checkbox": !0,
892
- onClick: (B) => X(u.dbName)
893
- }, null, 8, ["model-value", "label", "sublabel", "onClick"]))), 128)),
894
- Z.value.length === 0 ? (m(), ie(te, {
895
- key: 0,
896
- disabled: "",
897
- label: t(k)("inventory.common.noResultFound")
898
- }, null, 8, ["label"])) : $("", !0)
899
- ]),
900
- _: 1
901
- }, 8, ["model-value"]);
902
- };
903
- }
904
- }), Ye = w(), ot = w(), at = w();
905
- function lo(ne) {
906
- const k = rs(), z = et(), U = Rt(), j = Ct(), D = kt(), Z = vs(), oe = St(), i = w(!1), S = ut(), { t: a } = We(), ee = Ft(), X = jt(), we = w([]), q = w([]), T = w(new Array()), b = w(
907
- new Array()
908
- ), ue = w(
909
- ne != null && ne.startDate && (ne != null && ne.endDate) ? ne : rt()
910
- ), H = R(() => {
911
- const p = new Date(ue.value.startDate), f = new Date(ue.value.endDate);
912
- return {
913
- start: Cs(p).toISOString(),
914
- end: ks(f).toISOString()
915
- };
916
- }), te = It(), x = w(null), u = Bt({
917
- visible: !1,
918
- title: "",
919
- current: 0,
920
- total: 0,
921
- done: !1,
922
- cancelled: !1
923
- });
924
- function B(p) {
925
- const f = z.locations.find((C) => C.dbName === p._locationDbName);
926
- if (!f) return null;
927
- if (f.type === "restaurant") {
928
- const C = z.locationRestaurantFromCore(f.doc._id);
929
- if (C !== null)
930
- return { ...f, doc: C };
931
- }
932
- return f;
933
- }
934
- function me(p) {
935
- const f = z.locations.find((C) => C.dbName === p._locationDbName);
936
- f && (z._currentLocation = f);
937
- }
938
- async function ce() {
939
- if (q.value = [], T.value = [], we.value.length !== 0) {
940
- i.value = !0;
941
- try {
942
- const f = yt(we.value, 5), C = [];
943
- for (const y of f) {
944
- const M = await Promise.allSettled(
945
- y.map(async (A) => (await ee.getPurchaseOrders({
946
- ...H.value,
947
- dbName: A
948
- })).map((I) => ({ ...I, _locationDbName: A })))
949
- );
950
- for (const A of M)
951
- A.status === "fulfilled" && C.push(...A.value);
952
- }
953
- q.value = C.sort((y, M) => M._id.localeCompare(y._id));
954
- const E = q.value.flatMap((y) => y.shipmentIds || []).filter(Boolean), l = E.length > 0 ? await X.getShipmentsByIds(E) : [];
955
- T.value = l;
956
- const r = await te.readCurrentLocationLastClosing(!0), c = r == null ? void 0 : r._id;
957
- c && (x.value = Fs(c)), await U.awaitFeatureLoaded(() => U.mustUsePoTemplate) && await oe.fetchTemplates();
958
- const h = q.value.map((y) => {
959
- var M;
960
- return ((M = y.request) == null ? void 0 : M.id) ?? "";
961
- }).filter((y) => y);
962
- h.length > 0 && (b.value = await ee.readRequestByIds(h));
963
- } catch {
964
- S.open({
965
- title: "Something went wrong",
966
- message: "Error at fetching purchase orders",
967
- type: "error"
968
- });
969
- } finally {
970
- i.value = !1;
971
- }
972
- }
973
- }
974
- function K(p, f) {
975
- ue.value = { startDate: p, endDate: f }, ce();
976
- }
977
- const ye = w();
978
- async function be(p) {
979
- const f = we.value[0];
980
- if (f) {
981
- const l = z.locations.find((r) => r.dbName === f);
982
- l && (z._currentLocation = l);
983
- }
984
- function C(l) {
985
- const r = {
986
- mode: xt.CREATE,
987
- modelValue: p || void 0,
988
- show: !0,
989
- "onUpdate:show"(c) {
990
- Ye.value.show = c;
991
- },
992
- templateId: l,
993
- lastClosingDate: x.value
994
- };
995
- Ye.value = r;
996
- }
997
- let E;
998
- U.mustUsePoTemplate && !(p != null && p.template) ? k.open({
999
- title: "Create transfer",
1000
- message: "",
1001
- primaryActions: { text: "Select a template", close: !0 },
1002
- secondaryActions: { text: "Outlet to Outlet", variant: "secondary", close: !0 }
1003
- }).onPrimary(async () => {
1004
- E = await Z.getTemplateId(), E && C(E);
1005
- }).onSecondary(() => {
1006
- C(void 0);
1007
- }) : C(E);
1008
- }
1009
- function pe(p) {
1010
- me(p);
1011
- const f = {
1012
- mode: xt.UPDATE,
1013
- modelValue: Lt(p),
1014
- show: !0,
1015
- "onUpdate:show"(C) {
1016
- Ye.value.show = C;
1017
- },
1018
- lastClosingDate: x.value
1019
- };
1020
- Ye.value = f;
1021
- }
1022
- function Be(p) {
1023
- if (me(p), !D.currentBusiness.value) return;
1024
- const f = B(p);
1025
- if (!f) return;
1026
- const C = nt({
1027
- po: p,
1028
- currentLocation: f,
1029
- business: D.currentBusiness.value,
1030
- fulfilling: !1,
1031
- por: p.request
1032
- });
1033
- if (!C) return;
1034
- const E = gt(C.html), l = j.supplierById[p.supplier._id], r = {
1035
- recipientName: l == null ? void 0 : l.name,
1036
- email: (l == null ? void 0 : l.email) ?? "",
1037
- business: D.currentBusiness.value,
1038
- modelValue: E,
1039
- show: !0,
1040
- "onUpdate:show"(c) {
1041
- ot.value.show = c;
1042
- }
1043
- };
1044
- ot.value = r;
1045
- }
1046
- async function Oe(p, f) {
1047
- me(p), f ?? (f = b.value.find((r) => r.purchaseOrderId === p._id) ?? void 0);
1048
- const E = B(p), l = {
1049
- poRequest: f,
1050
- purchaseOrder: p,
1051
- transferTo: E == null ? void 0 : E.name,
1052
- transferToDbName: E == null ? void 0 : E.dbName,
1053
- show: !0,
1054
- canResubmit: !1,
1055
- canApprove: !1,
1056
- "onUpdate:show"(r) {
1057
- ye.value.show = r;
1058
- },
1059
- scope: it.RECEIVE_REQUEST,
1060
- receivedMap: Wt(p) ?? {},
1061
- shipments: T.value
1062
- };
1063
- ye.value = l;
1064
- }
1065
- async function Se(p, f, C, E, l) {
1066
- const r = Zt();
1067
- i.value = !0;
1068
- try {
1069
- await r({
1070
- operate: {
1071
- operation: f,
1072
- doc: p,
1073
- options: (f === Ae.enum.confirmDraft || f === Ae.enum.completeReceive) && U.autoReceiveWarehouse ? { autoReceive: !0 } : void 0
1074
- },
1075
- operateV2: {
1076
- _id: p._id,
1077
- _rev: p._rev ?? "",
1078
- action: f === Ae.enum.submitRequest ? Ae.enum.confirmDraft : f,
1079
- payloads: l ?? []
1080
- },
1081
- transferTo: E
1082
- }), await new Promise((c) => setTimeout(c, 1e3)), S.open({ title: "Success", message: C, type: "success" });
1083
- } catch (c) {
1084
- S.open({
1085
- title: "Something went wrong",
1086
- message: "Please try again.",
1087
- type: "error"
1088
- }), console.error("Error when submitting PO operation", f, p, c);
1089
- } finally {
1090
- i.value = !1, ce();
1091
- }
1092
- }
1093
- async function ae(p, f, C) {
1094
- me(p);
1095
- const E = Ht[f];
1096
- if (!E) {
1097
- S.open({
1098
- title: "Something went wrong",
1099
- message: `Cannot process order: ${$t(f)}`,
1100
- type: "error"
1101
- });
1102
- return;
1103
- }
1104
- const { successMessage: l, ...r } = E;
1105
- if (f === Ae.enum.rejectDraft) {
1106
- let y = "";
1107
- k.open({
1108
- title: r.title,
1109
- message: r.message,
1110
- primaryActions: r.primaryActions,
1111
- contentComponent: Yt,
1112
- contentComponentProps: {
1113
- message: r.message,
1114
- onChange: (M) => y = M
1115
- }
1116
- }).onPrimary(() => {
1117
- Se(p, f, l, C, [
1118
- { action: "rejectDraft", payload: { rejectReason: y } }
1119
- ]);
1120
- });
1121
- return;
1122
- }
1123
- const c = [], h = Qt();
1124
- h.init(p), (f === Ae.enum.confirmDraft || f === Ae.enum.submitRequest) && c.push({
1125
- action: "confirmDraft",
1126
- payload: h.controller.value.toConfirmDraftData(zt())
1127
- }), k.open({
1128
- title: r.title,
1129
- message: r.message,
1130
- primaryActions: r.primaryActions
1131
- }).onPrimary(() => {
1132
- Se(
1133
- p,
1134
- f,
1135
- l,
1136
- C,
1137
- c
1138
- );
1139
- });
1140
- }
1141
- async function he() {
1142
- k.open({
1143
- title: "Upload Transfer",
1144
- primaryActions: { text: "Xilnex transfer note", close: !0 },
1145
- secondaryActions: { text: "Cancel", close: !0 }
1146
- }).onPrimary(() => {
1147
- const p = {
1148
- show: !0,
1149
- "onUpdate:show"(f) {
1150
- at.value.show = f;
1151
- }
1152
- };
1153
- at.value = p;
1154
- });
1155
- }
1156
- async function Ne(p) {
1157
- var c, h;
1158
- const { startDate: f, endDate: C } = ue.value;
1159
- if (Te(C).diff(Te(f), "month", !0) > 2) {
1160
- S.open({
1161
- title: a("inventory.transfer.receiveRequest.bulk.downloadError"),
1162
- message: a("inventory.transfer.receiveRequest.bulk.downloadLimitExceeded"),
1163
- type: "error"
1164
- });
1165
- return;
1166
- }
1167
- if (p.length === 0) {
1168
- S.open({
1169
- title: a("inventory.transfer.receiveRequest.bulk.downloadError"),
1170
- message: a("inventory.transfer.receiveRequest.bulk.noOrdersToDownload"),
1171
- type: "warning"
1172
- });
1173
- return;
1174
- }
1175
- const E = (await import("./jszip.min-CGd5HPaQ.js").then((y) => y.j)).default, l = new E();
1176
- let r = 0;
1177
- u.title = a("inventory.transfer.receiveRequest.bulk.downloadProgress"), u.current = 0, u.total = p.length, u.done = !1, u.cancelled = !1, u.visible = !0, await tt(), await new Promise((y) => setTimeout(y, 150));
1178
- try {
1179
- for (const v of p) {
1180
- if (u.cancelled) break;
1181
- try {
1182
- const I = B(v);
1183
- if (!I) continue;
1184
- const de = nt({
1185
- po: v,
1186
- currentLocation: I,
1187
- business: D.currentBusiness.value,
1188
- fulfilling: !1,
1189
- por: b.value.find((V) => V.purchaseOrderId === v._id)
1190
- });
1191
- if (!de) continue;
1192
- const ge = de.html, G = document.createElement("iframe");
1193
- G.style.cssText = "position:fixed;left:-9999px;top:0;width:210mm;border:none;opacity:0;pointer-events:none;", document.body.appendChild(G);
1194
- const Q = G.contentDocument || ((c = G.contentWindow) == null ? void 0 : c.document);
1195
- if (!Q) {
1196
- document.body.removeChild(G), console.error("Could not access iframe document for PO", v._id);
1197
- continue;
1198
- }
1199
- Q.open(), Q.write(ge), Q.close(), await new Promise((V) => setTimeout(V, 500));
1200
- const re = Q.body.scrollHeight;
1201
- G.style.height = `${re}px`, await new Promise((V) => setTimeout(V, 100));
1202
- const xe = await ht().set({
1203
- margin: [15, 15, 15, 15],
1204
- // 15mm margins on all sides
1205
- filename: "temp.pdf",
1206
- image: { type: "jpeg", quality: 0.95 },
1207
- html2canvas: {
1208
- scale: 2,
1209
- useCORS: !0,
1210
- letterRendering: !0,
1211
- logging: !1,
1212
- scrollY: 0,
1213
- scrollX: 0,
1214
- windowHeight: re,
1215
- height: re
1216
- },
1217
- jsPDF: {
1218
- unit: "mm",
1219
- format: "a4",
1220
- orientation: "portrait"
1221
- }
1222
- }).from(Q.body).toPdf().outputPdf("blob");
1223
- document.body.removeChild(G);
1224
- const _ = `${((h = z.locations.find((V) => V.dbName === v._locationDbName)) == null ? void 0 : h.name) || v._locationDbName}_PO_${v.seqNumber || v._id}`.replace(/[/\\?%*:|"<>]/g, "-").slice(0, 100);
1225
- l.file(`${_}.pdf`, xe);
1226
- } catch (I) {
1227
- console.error("Failed to generate PDF for PO", v._id, I);
1228
- }
1229
- r++, u.current = r, await new Promise((I) => setTimeout(I, 80));
1230
- }
1231
- if (u.cancelled) return;
1232
- u.done = !0, await new Promise((v) => setTimeout(v, 500));
1233
- const y = await l.generateAsync({ type: "blob", compression: "DEFLATE" }), M = URL.createObjectURL(y), A = document.createElement("a");
1234
- A.href = M, A.download = `purchase-orders-${Te().format("YYYY-MM-DD")}.zip`, A.click(), URL.revokeObjectURL(M), S.open({
1235
- title: a("inventory.transfer.receiveRequest.bulk.downloadSuccess"),
1236
- message: a("inventory.transfer.receiveRequest.bulk.downloadSuccessMsg", [
1237
- p.length
1238
- ]),
1239
- type: "success"
1240
- });
1241
- } catch (y) {
1242
- console.error("Bulk download failed", y), S.open({
1243
- title: a("inventory.transfer.receiveRequest.bulk.downloadError"),
1244
- message: a("inventory.transfer.receiveRequest.bulk.downloadErrorMsg"),
1245
- type: "error"
1246
- });
1247
- } finally {
1248
- u.visible = !1;
1249
- }
1250
- }
1251
- async function ke(p) {
1252
- var Ee;
1253
- const f = [
1254
- vt.enum.RECEIVING,
1255
- vt.enum.PROCESSING
1256
- // PARTIAL_RECEIVED display status maps from PROCESSING
1257
- ], C = p.filter((_) => f.includes(_.status));
1258
- if (C.length === 0) {
1259
- S.open({
1260
- title: a("inventory.transfer.receiveRequest.bulk.emailSendError"),
1261
- message: a("inventory.transfer.receiveRequest.bulk.noOrdersToEmail"),
1262
- type: "warning"
1263
- });
1264
- return;
1265
- }
1266
- if (!((Ee = D.currentBusiness.value) != null && Ee._id)) return;
1267
- const E = us(), l = ps(), r = /* @__PURE__ */ new Map(), c = z.locations.map((_) => _.dbName), h = `business_${D.currentBusiness.value._id}`, y = [.../* @__PURE__ */ new Set([...c, h])];
1268
- await Promise.allSettled(
1269
- y.map(async (_) => {
1270
- try {
1271
- (await l.readSuppliersByDbName(_)).forEach((N) => {
1272
- const L = r.get(N._id);
1273
- (!L || !L.email && N.email) && r.set(N._id, N);
1274
- });
1275
- } catch (V) {
1276
- console.warn("[emailAll] fetch failed for", _, V);
1277
- }
1278
- })
1279
- );
1280
- function M(_) {
1281
- var N;
1282
- const V = r.get(_.supplier._id);
1283
- return (V == null ? void 0 : V.email) || ((N = _.supplier) == null ? void 0 : N.email);
1284
- }
1285
- const A = [], v = [];
1286
- for (const _ of C)
1287
- M(_) ? A.push(_) : v.push(_);
1288
- const I = ve(
1289
- "p",
1290
- { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" },
1291
- a("inventory.transfer.receiveRequest.bulk.emailAllowedStatusInfo")
1292
- );
1293
- if (v.length > 0) {
1294
- const _ = /* @__PURE__ */ new Map();
1295
- for (const L of v) {
1296
- const P = L.supplier._id;
1297
- _.has(P) || _.set(P, { supplierName: L.supplier.name, pos: [] }), _.get(P).pos.push(L);
1298
- }
1299
- const V = ve("div", { class: "flex flex-col gap-12" }, [
1300
- I,
1301
- ve(
1302
- "p",
1303
- { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" },
1304
- a("inventory.transfer.receiveRequest.bulk.missingEmailMsg", [v.length])
1305
- ),
1306
- ve(
1307
- "div",
1308
- { class: "flex flex-col gap-4 max-h-[320px] overflow-y-auto rounded-md border border-fm-color-neutral-gray-100 p-8" },
1309
- [..._.values()].map(
1310
- ({ supplierName: L, pos: P }) => ve("div", { class: "flex flex-col gap-2 py-6 border-b border-fm-color-neutral-gray-100 last:border-0" }, [
1311
- ve("div", { class: "fm-typo-en-body-md-600 text-fm-color-typo-primary" }, L),
1312
- ve(
1313
- "div",
1314
- { class: "flex flex-wrap gap-4" },
1315
- P.map(
1316
- (se) => ve("span", {
1317
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary bg-fm-color-neutral-gray-100 rounded px-6 py-2"
1318
- }, `PO #${se.seqNumber ?? se._id}`)
1319
- )
1320
- )
1321
- ])
1322
- )
1323
- ),
1324
- ve(
1325
- "p",
1326
- { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" },
1327
- a("inventory.transfer.receiveRequest.bulk.emailWillSendCount", [A.length, C.length])
1328
- ),
1329
- ve(
1330
- "p",
1331
- { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" },
1332
- a("inventory.transfer.receiveRequest.bulk.missingEmailConfirm")
1333
- )
1334
- ]);
1335
- if (!await new Promise((L) => {
1336
- k.open({
1337
- title: a("inventory.transfer.receiveRequest.bulk.missingEmailTitle"),
1338
- contentComponent: V,
1339
- contentComponentProps: {},
1340
- primaryActions: {
1341
- text: a("inventory.transfer.receiveRequest.bulk.skipAndContinue"),
1342
- close: !0
1343
- },
1344
- secondaryActions: { text: a("inventory.common.cancel"), close: !0 }
1345
- }).onPrimary(() => L(!0)).onSecondary(() => L(!1));
1346
- })) return;
1347
- } else {
1348
- const _ = ve("div", { class: "flex flex-col gap-12" }, [
1349
- I,
1350
- ve(
1351
- "p",
1352
- { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" },
1353
- a("inventory.transfer.receiveRequest.bulk.emailAllConfirmMsg", [A.length])
1354
- )
1355
- ]);
1356
- if (!await new Promise((N) => {
1357
- k.open({
1358
- title: a("inventory.transfer.receiveRequest.bulk.missingEmailTitle"),
1359
- contentComponent: _,
1360
- contentComponentProps: {},
1361
- primaryActions: {
1362
- text: a("inventory.transfer.receiveRequest.bulk.emailConfirm"),
1363
- close: !0
1364
- },
1365
- secondaryActions: { text: a("inventory.common.cancel"), close: !0 }
1366
- }).onPrimary(() => N(!0)).onSecondary(() => N(!1));
1367
- })) return;
1368
- }
1369
- if (A.length === 0) {
1370
- S.open({
1371
- title: a("inventory.transfer.receiveRequest.bulk.emailSendError"),
1372
- message: a("inventory.transfer.receiveRequest.bulk.noEmailsToSend"),
1373
- type: "warning"
1374
- });
1375
- return;
1376
- }
1377
- let de = [];
1378
- try {
1379
- de = await E.getEmailList(D.currentBusiness.value._id);
1380
- } catch {
1381
- S.open({
1382
- title: a("inventory.transfer.receiveRequest.bulk.emailSendError"),
1383
- message: a("inventory.transfer.receiveRequest.bulk.noEmailSender"),
1384
- type: "error"
1385
- });
1386
- return;
1387
- }
1388
- const ge = de.find((_) => _.verified);
1389
- if (!ge) {
1390
- S.open({
1391
- title: a("inventory.transfer.receiveRequest.bulk.emailSendError"),
1392
- message: a("inventory.transfer.receiveRequest.bulk.noEmailSender"),
1393
- type: "error"
1394
- });
1395
- return;
1396
- }
1397
- const Q = yt(A, 2);
1398
- let re = 0;
1399
- const xe = [];
1400
- u.title = a("inventory.transfer.receiveRequest.bulk.emailProgress"), u.current = 0, u.total = A.length, u.done = !1, u.cancelled = !1, u.visible = !0, await tt(), await new Promise((_) => setTimeout(_, 100));
1401
- try {
1402
- for (let _ = 0; _ < Q.length; _++) {
1403
- const V = Q[_];
1404
- await Promise.allSettled(
1405
- V.map(async (N) => {
1406
- var P;
1407
- const L = document.createElement("div");
1408
- L.style.cssText = "position:fixed;left:-99999px;top:0;width:210mm;background:white;z-index:-1;opacity:0;pointer-events:none;", document.body.appendChild(L);
1409
- try {
1410
- const se = B(N);
1411
- if (!se) return;
1412
- const fe = nt({
1413
- po: N,
1414
- currentLocation: se,
1415
- business: D.currentBusiness.value,
1416
- fulfilling: !1,
1417
- por: b.value.find((Pe) => Pe.purchaseOrderId === N._id)
1418
- });
1419
- if (!fe) return;
1420
- const Ie = gt(fe.html), Re = new DOMParser().parseFromString(fe.html, "text/html");
1421
- for (; Re.body.firstChild; )
1422
- L.appendChild(Re.body.firstChild);
1423
- Re.head.querySelectorAll("style").forEach((Pe) => L.prepend(Pe.cloneNode(!0)));
1424
- const Ce = await ht().set({
1425
- margin: 10,
1426
- html2canvas: { scale: 2, useCORS: !0, letterRendering: !0 },
1427
- jsPDF: { unit: "mm", format: "a4", orientation: "portrait" }
1428
- }).from(L).outputPdf("blob");
1429
- if (!Ce) return;
1430
- await E.sendMailFormData({
1431
- businessId: D.currentBusiness.value._id,
1432
- from: {
1433
- name: ge.name || ((P = D.currentBusiness.value) == null ? void 0 : P.name) || "FeedMe Inventory",
1434
- address: ge.emailAddress
1435
- },
1436
- to: [{ name: N.supplier.name, address: M(N) }],
1437
- subject: `Purchase Order #${N.seqNumber ?? N._id}`,
1438
- html: Ie,
1439
- attachments: [Ce],
1440
- usage: "Operational",
1441
- forceSend: !0
1442
- });
1443
- } catch (se) {
1444
- xe.push(`PO #${N.seqNumber ?? N._id}`), console.error("Failed to send email for PO", N._id, se);
1445
- } finally {
1446
- document.body.removeChild(L), re++, u.current = re;
1447
- }
1448
- })
1449
- ), await tt(), _ < Q.length - 1 && await new Promise((N) => setTimeout(N, 1500));
1450
- }
1451
- u.done = !0, xe.length > 0 ? S.open({
1452
- title: a("inventory.transfer.receiveRequest.bulk.emailPartialSuccess"),
1453
- message: a("inventory.transfer.receiveRequest.bulk.emailPartialSuccessMsg", [
1454
- A.length - xe.length,
1455
- A.length
1456
- ]),
1457
- type: "warning"
1458
- }) : S.open({
1459
- title: a("inventory.transfer.receiveRequest.bulk.emailSuccess"),
1460
- message: a("inventory.transfer.receiveRequest.bulk.emailSuccessMsg", [
1461
- A.length
1462
- ]),
1463
- type: "success"
1464
- });
1465
- } catch (_) {
1466
- console.error("Bulk email failed", _), S.open({
1467
- title: a("inventory.transfer.receiveRequest.bulk.emailSendError"),
1468
- message: a("inventory.transfer.receiveRequest.bulk.emailErrorMsg"),
1469
- type: "error"
1470
- });
1471
- } finally {
1472
- u.visible = !1;
1473
- }
1474
- }
1475
- return {
1476
- selectedLocationDbNames: we,
1477
- purchaseOrders: q,
1478
- shipments: T,
1479
- purchaseRequests: b,
1480
- updateDateRange: K,
1481
- fetchData: ce,
1482
- loading: i,
1483
- bulkProgress: u,
1484
- transferDialogProps: Ye,
1485
- promptCreateTransferDialog: be,
1486
- promptUpdateTransferDialog: pe,
1487
- transferDetailsProps: ye,
1488
- promptShowTransferDetails: Oe,
1489
- submitAction: ae,
1490
- xilnexImportDialogProps: at,
1491
- promptUploadTransferDialog: he,
1492
- emailDialogProps: ot,
1493
- promptEmailDialog: Be,
1494
- downloadAll: Ne,
1495
- emailAll: ke,
1496
- lastClosingDate: x
1497
- };
1498
- }
1499
- function io(ne, k) {
1500
- const z = et(), { t: U } = We(), j = Kt(
1501
- it.RECEIVE_REQUEST,
1502
- ne,
1503
- k
1504
- );
1505
- return {
1506
- columnDefs: R(() => {
1507
- const Z = j.columnDefs.value, oe = {
1508
- id: "location",
1509
- header: () => U("inventory.transfer.receiveRequest.bulk.locationColumn"),
1510
- cell(S) {
1511
- const a = S.row.original._locationDbName, ee = z.locations.find((X) => X.dbName === a);
1512
- return ee ? `${ee.name} (${ee.doc.profile.code ?? "--"})` : a;
1513
- },
1514
- enableSorting: !1,
1515
- size: 160
1516
- }, i = [...Z];
1517
- return i.splice(1, 0, oe), i;
1518
- }),
1519
- showCustomPrintDialog: j.showCustomPrintDialog,
1520
- customPrintHtml: j.customPrintHtml,
1521
- customPrintTemplateName: j.customPrintTemplateName,
1522
- customPrintIsDefault: j.customPrintIsDefault
1523
- };
1524
- }
1525
- const uo = {
1526
- key: 0,
1527
- class: "flex flex-col items-center justify-center py-48 gap-8 text-fm-color-typo-secondary"
1528
- }, co = { class: "flex-1 w-full flex items-center gap-4 xs:flex-col-reverse sm:flex-col-reverse" }, mo = { class: "flex-1 xs:w-full sm:w-full" }, po = {
1529
- key: 0,
1530
- class: "flex-1"
1531
- }, fo = { class: "w-full max-w-[343px] xs:max-w-[unset] sm:max-w-[unset]" }, vo = {
1532
- key: 0,
1533
- class: "flex flex-col items-center justify-center py-48 gap-8 text-fm-color-typo-secondary"
1534
- }, yo = { class: "fm-typo-en-body-md-400" }, bo = { class: "flex flex-col py-8" }, ho = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, go = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, xo = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary line-clamp-1" }, _o = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary line-clamp-1" }, wo = {
1535
- key: 0,
1536
- class: "fm-typo-en-body-md-400 text-fm-color-typo-primary line-clamp-1"
1537
- }, ko = { class: "pt-8" }, Co = {
1538
- key: 0,
1539
- class: "fixed inset-0 bg-black/40 z-[9999] flex items-center justify-center"
1540
- }, Fo = { class: "bg-white rounded-xl shadow-lg p-24 flex flex-col gap-12 min-w-[320px] max-w-[480px]" }, So = { class: "fm-typo-en-title-sm-600" }, Ro = { class: "flex flex-col gap-8" }, Do = { class: "flex justify-between fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Eo = { class: "w-full bg-fm-color-neutral-gray-200 rounded-full h-8" }, Po = {
1541
- key: 0,
1542
- class: "fm-typo-en-body-sm-400 text-fm-color-semantic-success-500 text-center"
1543
- }, qo = {
1544
- key: 1,
1545
- class: "flex justify-end pt-4"
1546
- }, _t = "BulkReceiveRequestViewSearchCriteria", aa = /* @__PURE__ */ lt({
1547
- __name: "BulkReceiveRequestView",
1548
- setup(ne) {
1549
- const { t: k } = We(), z = ut();
1550
- ws().fetchTemplates(), Ge.object({
1551
- name: Ge.string().optional().nullable(),
1552
- startDate: Ge.string().optional().nullable(),
1553
- endDate: Ge.string().optional().nullable()
1554
- });
1555
- const j = ss(), D = Rt(), Z = _s();
1556
- function oe() {
1557
- const l = {
1558
- name: "",
1559
- ...rt()
1560
- }, r = j.getItem(_t);
1561
- if (!r) return l;
1562
- try {
1563
- return JSON.parse(r);
1564
- } catch {
1565
- return l;
1566
- }
1567
- }
1568
- function i() {
1569
- j.setItem(_t, JSON.stringify(S.value));
1570
- }
1571
- const S = w(oe()), a = lo(S.value), ee = w(!1), { selectedLocationDbNames: X } = a, we = R(() => B.value.filter((l) => X.value.includes(l.dbName)).map((l) => l.doc._id)), {
1572
- columnDefs: q,
1573
- showCustomPrintDialog: T,
1574
- customPrintHtml: b,
1575
- customPrintTemplateName: ue,
1576
- customPrintIsDefault: H
1577
- } = io(a, a.shipments), te = et(), x = Mt(), u = kt(), B = w([]);
1578
- Ot(() => {
1579
- const l = te.locations;
1580
- l.length > 0 && (B.value = l);
1581
- });
1582
- async function me() {
1583
- var r;
1584
- if ((r = u.currentBusiness.value) != null && r._id)
1585
- try {
1586
- const c = await x.readAllInventoryLocations();
1587
- c.length > 0 && (B.value = c);
1588
- } catch {
1589
- }
1590
- }
1591
- ze(
1592
- [() => u.sessionUser.value, () => u.currentBusiness.value],
1593
- ([l, r]) => {
1594
- l && r && me();
1595
- },
1596
- { immediate: !0 }
1597
- );
1598
- const ce = R(() => a.loading.value), K = a.bulkProgress;
1599
- async function ye() {
1600
- const l = `inventory-record_${Te(S.value.startDate).format("DD-MM-YYYY_HH-mm")}-${Te(S.value.endDate).format("DD-MM-YYYY_HH-mm")}.xlsx`, r = a.purchaseOrders.value.flatMap(
1601
- (h) => h.items.map((y) => {
1602
- var G, Q;
1603
- const M = new Date(es(h._id) ?? ""), A = h.effectiveAt ? new Date(h.effectiveAt) : void 0, v = bt(
1604
- Gt(y.sku, h.deliveryOrder || [])
1605
- ), I = bt(y.quantity), de = ((G = y == null ? void 0 : y.measurement) == null ? void 0 : G.abbrev) || y.sku.unit.abbrev;
1606
- return {
1607
- Location: ((Q = te.locations.find((re) => re.dbName === h._locationDbName)) == null ? void 0 : Q.name) ?? "",
1608
- "SKU code": y.code,
1609
- "SKU name": y.name,
1610
- "PO #": h.seqNumber,
1611
- "Effective at": A,
1612
- Date: M,
1613
- Status: h.status,
1614
- Reference: h.ref ?? "",
1615
- "Received quantity": v,
1616
- "Ordered quantity": I,
1617
- Unit: de,
1618
- "Total cost": y.totalCost ? Ut(y.totalCost) : null
1619
- };
1620
- })
1621
- ), c = [
1622
- "Location",
1623
- "SKU code",
1624
- "SKU name",
1625
- "PO #",
1626
- "Date",
1627
- "Status",
1628
- "Reference",
1629
- "Received quantity",
1630
- "Ordered quantity",
1631
- "Unit"
1632
- ];
1633
- D.enableBackdatePo && c.insert("Effective at", 5), D.enableTotalCost && c.push("Total cost"), await ts([{ name: "purchases", data: r, columns: c }], l), z.open({
1634
- title: k("inventory.transfer.receiveRequest.export.success"),
1635
- message: k("inventory.transfer.receiveRequest.export.message", [l]),
1636
- type: "success"
1637
- });
1638
- }
1639
- const be = w(rt()), pe = w("");
1640
- ze([() => be.value], ([l]) => {
1641
- if (!l.startDate || !l.endDate) return;
1642
- if (Te(l.endDate).diff(Te(l.startDate), "day") > 60) {
1643
- z.open({
1644
- title: k("inventory.transfer.receiveRequest.bulk.dateRangeLimitTitle"),
1645
- message: k("inventory.transfer.receiveRequest.bulk.dateRangeLimitMsg"),
1646
- type: "warning"
1647
- }), be.value = {
1648
- startDate: l.startDate,
1649
- endDate: Te(l.startDate).add(60, "day").format("YYYY-MM-DD")
1650
- };
1651
- return;
1652
- }
1653
- S.value.startDate = l.startDate, S.value.endDate = l.endDate, a.updateDateRange(S.value.startDate, S.value.endDate), i();
1654
- }), ze([() => pe.value], () => {
1655
- i();
1656
- }), ze(
1657
- () => X.value,
1658
- () => {
1659
- a.fetchData();
1660
- }
1661
- );
1662
- function Be(l) {
1663
- if (l === "create") {
1664
- if (ce.value) {
1665
- z.open({ title: "Loading data...", message: "Please wait.", type: "info" });
1666
- return;
1667
- }
1668
- if (X.value.length === 0) {
1669
- z.open({
1670
- title: "No outlets selected",
1671
- message: "Please select at least one outlet to create a transfer.",
1672
- type: "warning"
1673
- });
1674
- return;
1675
- }
1676
- ee.value = !0;
1677
- return;
1678
- }
1679
- if (l === "upload" && D.enableXilnexTransferNote)
1680
- return a.promptUploadTransferDialog();
1681
- if (l === "refresh") return a.fetchData();
1682
- if (l === "export") return ye();
1683
- if (l === "downloadAll") return Oe();
1684
- if (l === "emailAll") return Se();
1685
- }
1686
- async function Oe() {
1687
- if (X.value.length === 0) {
1688
- z.open({
1689
- title: k("inventory.transfer.receiveRequest.bulk.noLocationsSelected"),
1690
- message: "",
1691
- type: "warning"
1692
- });
1693
- return;
1694
- }
1695
- await a.downloadAll(E.value);
1696
- }
1697
- async function Se() {
1698
- if (D.enablePurchaseOrderEmail) {
1699
- if (X.value.length === 0) {
1700
- z.open({
1701
- title: k("inventory.transfer.receiveRequest.bulk.noLocationsSelected"),
1702
- message: "",
1703
- type: "warning"
1704
- });
1705
- return;
1706
- }
1707
- await a.emailAll(E.value);
1708
- }
1709
- }
1710
- const { breakpoints: ae } = ls(), he = R(() => ae.value.xs || ae.value.sm), Ne = R(() => he.value ? 10 : 20), ke = ns(), p = R(() => D.enableReceiveRequestBeta ? [
1711
- {
1712
- label: k("inventory.transfer.receiveRequest.actions.create"),
1713
- value: "create",
1714
- isPrimary: !0,
1715
- prependIcon: "add"
1716
- },
1717
- ...D.enableXilnexTransferNote ? [{ label: k("inventory.common.upload"), value: "upload" }] : [],
1718
- { label: k("inventory.common.refresh"), value: "refresh" },
1719
- { label: k("inventory.common.export"), value: "export" },
1720
- ...D.enablePrintTemplate ? [
1721
- {
1722
- label: k("inventory.transfer.receiveRequest.bulk.downloadAll"),
1723
- value: "downloadAll",
1724
- prependIcon: "download"
1725
- }
1726
- ] : [],
1727
- ...D.enablePurchaseOrderEmail ? [
1728
- {
1729
- label: k("inventory.transfer.receiveRequest.bulk.emailAll"),
1730
- value: "emailAll",
1731
- prependIcon: "email"
1732
- }
1733
- ] : []
1734
- ] : []), f = R(() => {
1735
- const l = [
1736
- {
1737
- type: "string",
1738
- key: "status",
1739
- entity: "purchaseOrder",
1740
- values: Array.from(new Set(a.purchaseOrders.value.map((c) => c.status)))
1741
- },
1742
- {
1743
- type: "string",
1744
- key: "transferFrom",
1745
- entity: "purchaseOrder",
1746
- values: Array.from(new Set(a.purchaseOrders.value.map((c) => c.supplier.name)))
1747
- },
1748
- {
1749
- type: "string",
1750
- key: "location",
1751
- entity: "purchaseOrder",
1752
- values: Array.from(
1753
- new Set(
1754
- a.purchaseOrders.value.map((c) => {
1755
- const h = te.locations.find((y) => y.dbName === c._locationDbName);
1756
- return (h == null ? void 0 : h.name) ?? c._locationDbName;
1757
- })
1758
- )
1759
- )
1760
- }
1761
- ], r = [
1762
- {
1763
- type: "string",
1764
- key: "netsuiteTransactionNumber",
1765
- entity: "purchaseOrder",
1766
- values: a.purchaseOrders.value.map((c) => {
1767
- var h, y;
1768
- return (y = (h = c.netSuite) == null ? void 0 : h.additionalInfo) == null ? void 0 : y.transactionnumber;
1769
- }).filter((c) => c != null)
1770
- },
1771
- {
1772
- type: "string",
1773
- key: "netsuiteOrderNo",
1774
- entity: "purchaseOrder",
1775
- values: a.purchaseOrders.value.map((c) => {
1776
- var h;
1777
- return (h = c.netSuite) == null ? void 0 : h.refNo;
1778
- }).filter((c) => c != null)
1779
- },
1780
- {
1781
- type: "string",
1782
- key: "netsuiteOrderId",
1783
- entity: "purchaseOrder",
1784
- values: a.purchaseOrders.value.map((c) => {
1785
- var h;
1786
- return (h = c.netSuite) == null ? void 0 : h.id;
1787
- }).filter((c) => c != null)
1788
- }
1789
- ];
1790
- return [...l, ...Z.isEnabled ? r : []];
1791
- }), C = w(null), E = R(() => {
1792
- if (!C.value) return a.purchaseOrders.value;
1793
- const l = hs.build(C.value);
1794
- return a.purchaseOrders.value.filter((r) => {
1795
- var h, y, M, A, v;
1796
- const c = ((h = te.locations.find((I) => I.dbName === r._locationDbName)) == null ? void 0 : h.name) ?? r._locationDbName;
1797
- return gs(
1798
- {
1799
- netsuiteTransactionNumber: (M = (y = r.netSuite) == null ? void 0 : y.additionalInfo) == null ? void 0 : M.transactionnumber,
1800
- netsuiteOrderNo: (A = r.netSuite) == null ? void 0 : A.refNo,
1801
- netsuiteOrderId: (v = r.netSuite) == null ? void 0 : v.id,
1802
- status: r.status,
1803
- transferFrom: r.supplier.name,
1804
- location: c
1805
- },
1806
- l
1807
- );
1808
- });
1809
- });
1810
- return (l, r) => {
1811
- const c = De("FmIcon"), h = De("FmTextField"), y = De("FmTable"), M = De("FmButton");
1812
- return m(), ie(os, {
1813
- title: t(k)("inventory.transfer.receiveRequest.bulk.title"),
1814
- actions: p.value,
1815
- "onClick:action": Be
1816
- }, {
1817
- default: Fe(() => {
1818
- var A;
1819
- return [
1820
- t(D).isLoaded && !t(D).enableReceiveRequestBeta ? (m(), g("div", uo, [
1821
- F(c, {
1822
- name: "block",
1823
- size: "xl"
1824
- }),
1825
- r[10] || (r[10] = e("p", { class: "fm-typo-en-body-md-400" }, "Not available", -1))
1826
- ])) : t(D).enableReceiveRequestBeta ? (m(), g(_e, { key: 1 }, [
1827
- e("div", {
1828
- class: O(["flex flex-col gap-8 max-h-full", { "p-0": he.value, "px-24": !he.value }])
1829
- }, [
1830
- e("div", {
1831
- class: "flex flex-col gap-8",
1832
- onVnodeMounted: r[4] || (r[4] = //@ts-ignore
1833
- (...v) => t(ke).onMounted && t(ke).onMounted(...v)),
1834
- onVnodeUnmounted: r[5] || (r[5] = //@ts-ignore
1835
- (...v) => t(ke).onUnmounted && t(ke).onUnmounted(...v))
1836
- }, [
1837
- e("div", {
1838
- class: O([
1839
- "flex gap-8 items-center",
1840
- { "px-8 flex-col-reverse h-[unset]": he.value, "h-48": !he.value }
1841
- ])
1842
- }, [
1843
- e("div", {
1844
- class: O(["flex gap-8 items-center", { "w-full overflow-x-auto": he.value }])
1845
- }, [
1846
- F(ro, {
1847
- modelValue: t(X),
1848
- "onUpdate:modelValue": r[0] || (r[0] = (v) => mt(X) ? X.value = v : null),
1849
- locations: B.value
1850
- }, null, 8, ["modelValue", "locations"]),
1851
- F(Vt, {
1852
- "model-value": be.value,
1853
- "onUpdate:modelValue": r[1] || (r[1] = (v) => be.value = v)
1854
- }, null, 8, ["model-value"])
1855
- ], 2),
1856
- e("div", co, [
1857
- e("div", mo, [
1858
- F(t(xs), {
1859
- modelValue: C.value,
1860
- "onUpdate:modelValue": r[2] || (r[2] = (v) => C.value = v),
1861
- attributes: f.value
1862
- }, null, 8, ["modelValue", "attributes"])
1863
- ]),
1864
- he.value ? $("", !0) : (m(), g("div", po)),
1865
- e("div", fo, [
1866
- F(h, {
1867
- "model-value": pe.value,
1868
- "onUpdate:modelValue": r[3] || (r[3] = (v) => pe.value = v),
1869
- "prepend-icon": "search",
1870
- placeholder: t(k)("inventory.common.table.toolbar.filterItems"),
1871
- class: "w-full"
1872
- }, null, 8, ["model-value", "placeholder"])
1873
- ])
1874
- ])
1875
- ], 2)
1876
- ], 512),
1877
- t(X).length === 0 && !ce.value ? (m(), g("div", vo, [
1878
- F(c, {
1879
- name: "storefront",
1880
- size: "xl"
1881
- }),
1882
- e("p", yo, d(t(k)("inventory.transfer.receiveRequest.bulk.selectLocationsHint")), 1)
1883
- ])) : (m(), ie(y, {
1884
- key: 1,
1885
- style: pt(t(ke).tableHeight),
1886
- "column-defs": t(q),
1887
- "row-data": E.value,
1888
- "search-value": pe.value,
1889
- loading: ce.value,
1890
- onRowClick: r[6] || (r[6] = (v) => t(a).promptShowTransferDetails(v.original)),
1891
- "page-size": Ne.value
1892
- }, {
1893
- "list-row": Fe((v) => [
1894
- F(bs, {
1895
- row: v,
1896
- onRowClick: t(a).promptShowTransferDetails
1897
- }, {
1898
- default: Fe((I) => {
1899
- var de, ge, G, Q, re, xe, Ee, _, V, N, L, P, se, fe, Ie, Le, Re, Me, Ce, Pe, Ve, Ue, Ze, $e, Ke;
1900
- return [
1901
- e("div", bo, [
1902
- e("div", ho, [
1903
- F(t(He), {
1904
- render: (G = (ge = (de = I._id) == null ? void 0 : de.column) == null ? void 0 : ge.columnDef) == null ? void 0 : G.cell,
1905
- props: (re = (Q = I._id) == null ? void 0 : Q.getContext) == null ? void 0 : re.call(Q)
1906
- }, null, 8, ["render", "props"])
1907
- ]),
1908
- e("div", go, [
1909
- F(t(He), {
1910
- render: (_ = (Ee = (xe = I.location) == null ? void 0 : xe.column) == null ? void 0 : Ee.columnDef) == null ? void 0 : _.cell,
1911
- props: (N = (V = I.location) == null ? void 0 : V.getContext) == null ? void 0 : N.call(V)
1912
- }, null, 8, ["render", "props"])
1913
- ]),
1914
- e("div", xo, [
1915
- F(t(He), {
1916
- render: (se = (P = (L = I.supplier_name) == null ? void 0 : L.column) == null ? void 0 : P.columnDef) == null ? void 0 : se.cell,
1917
- props: (Ie = (fe = I.supplier_name) == null ? void 0 : fe.getContext) == null ? void 0 : Ie.call(fe)
1918
- }, null, 8, ["render", "props"])
1919
- ]),
1920
- e("div", _o, d(v.original.items.map((Je) => `${Je.name}`).join(", ")), 1),
1921
- v.original.ref ? (m(), g("div", wo, [
1922
- F(t(He), {
1923
- render: (Me = (Re = (Le = I.ref) == null ? void 0 : Le.column) == null ? void 0 : Re.columnDef) == null ? void 0 : Me.cell,
1924
- props: (Pe = (Ce = I.ref) == null ? void 0 : Ce.getContext) == null ? void 0 : Pe.call(Ce)
1925
- }, null, 8, ["render", "props"])
1926
- ])) : $("", !0),
1927
- e("div", ko, [
1928
- F(t(He), {
1929
- render: (Ze = (Ue = (Ve = I.status) == null ? void 0 : Ve.column) == null ? void 0 : Ue.columnDef) == null ? void 0 : Ze.cell,
1930
- props: (Ke = ($e = I.status) == null ? void 0 : $e.getContext) == null ? void 0 : Ke.call($e)
1931
- }, null, 8, ["render", "props"])
1932
- ])
1933
- ])
1934
- ];
1935
- }),
1936
- _: 2
1937
- }, 1032, ["row", "onRowClick"])
1938
- ]),
1939
- _: 1
1940
- }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
1941
- ], 2),
1942
- (m(), ie(wt, { to: "body" }, [
1943
- t(K).visible ? (m(), g("div", Co, [
1944
- e("div", Fo, [
1945
- e("div", So, d(t(K).title), 1),
1946
- e("div", Ro, [
1947
- e("div", Do, [
1948
- e("span", null, d(t(k)("inventory.transfer.receiveRequest.bulk.progressLabel")), 1),
1949
- e("span", null, d(t(K).current) + " / " + d(t(K).total), 1)
1950
- ]),
1951
- e("div", Eo, [
1952
- e("div", {
1953
- class: "bg-fm-color-primary h-8 rounded-full",
1954
- style: pt({
1955
- width: `${t(K).total > 0 ? t(K).current / t(K).total * 100 : 0}%`
1956
- })
1957
- }, null, 4)
1958
- ])
1959
- ]),
1960
- t(K).done ? (m(), g("div", Po, d(t(k)("inventory.transfer.receiveRequest.bulk.progressDone")), 1)) : $("", !0),
1961
- t(K).done ? $("", !0) : (m(), g("div", qo, [
1962
- F(M, {
1963
- variant: "secondary",
1964
- size: "md",
1965
- label: t(k)("inventory.transfer.receiveRequest.bulk.progressCancel"),
1966
- disabled: t(K).cancelled,
1967
- onClick: r[7] || (r[7] = (v) => t(K).cancelled = !0)
1968
- }, null, 8, ["label", "disabled"])
1969
- ]))
1970
- ])
1971
- ])) : $("", !0),
1972
- t(D).enablePurchaseOrderEmail ? (m(), ie(cs, ft(st({ key: 1 }, t(a).emailDialogProps.value)), null, 16)) : $("", !0),
1973
- F(ao, {
1974
- show: ee.value,
1975
- "onUpdate:show": r[8] || (r[8] = (v) => ee.value = v),
1976
- "last-closing-date": t(a).lastClosingDate.value,
1977
- "selected-outlet-ids": we.value,
1978
- onSubmitted: t(a).fetchData
1979
- }, null, 8, ["show", "last-closing-date", "selected-outlet-ids", "onSubmitted"]),
1980
- F(ds, st(t(a).transferDialogProps.value, {
1981
- onSubmitted: t(a).fetchData
1982
- }), null, 16, ["onSubmitted"]),
1983
- F(Jt, st({
1984
- scope: t(it).RECEIVE_REQUEST
1985
- }, {
1986
- ...t(a).transferDetailsProps.value,
1987
- receivedMap: ((A = t(a).transferDetailsProps.value) == null ? void 0 : A.receivedMap) ?? {},
1988
- shipments: t(a).shipments.value ?? []
1989
- }, {
1990
- onSubmitted: t(a).fetchData
1991
- }), null, 16, ["scope", "onSubmitted"]),
1992
- F(ms, ft(At(t(a).xilnexImportDialogProps.value)), null, 16),
1993
- F(Xt, {
1994
- modelValue: t(T),
1995
- "onUpdate:modelValue": r[9] || (r[9] = (v) => mt(T) ? T.value = v : null),
1996
- html: t(b),
1997
- "template-name": t(ue),
1998
- "is-default": t(H)
1999
- }, null, 8, ["modelValue", "html", "template-name", "is-default"])
2000
- ]))
2001
- ], 64)) : $("", !0)
2002
- ];
2003
- }),
2004
- _: 1
2005
- }, 8, ["title", "actions"]);
2006
- };
2007
- }
2008
- });
2009
- export {
2010
- aa as default
2011
- };