@feedmepos/mf-inventory-portal 1.6.1-dev.0 → 1.6.1-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/dist/{App-CL5dPCEj.js → App-D7SR5dnB.js} +4 -4
  2. package/dist/{ApprovalView-DKJibNlK.js → ApprovalView-Bi7AgvV0.js} +24 -23
  3. package/dist/{BindingsDialog-DLJXu8Dw.js → BindingsDialog-BD8B6cZy.js} +2 -2
  4. package/dist/{BindingsPicker-CW6Tk9JI.js → BindingsPicker-CRvmtsFb.js} +2 -2
  5. package/dist/{BindingsTable-3JJEAQz3.js → BindingsTable-DJ1lLYOb.js} +3 -3
  6. package/dist/BulkReceiveRequestView-CZHXfukP.js +2000 -0
  7. package/dist/{ClosingDraftView-DVoWnPTQ.js → ClosingDraftView-DV1KPp2W.js} +14 -14
  8. package/dist/{ClosingHistoryView-qWjIbBsX.js → ClosingHistoryView-C8fzDS5T.js} +5 -5
  9. package/dist/{ClosingTemplateView-C3Hf510z.js → ClosingTemplateView-qPT5Li2w.js} +14 -14
  10. package/dist/{DefaultView-wBhT3ag9.js → DefaultView-NF80xSuv.js} +2 -2
  11. package/dist/{DeliveryOrderPrintPreview-VnG9wrNu.js → DeliveryOrderPrintPreview-B12J3W3U.js} +11 -11
  12. package/dist/{ReceiveRequestView-DIPZCXxV.js → EmailDialog.vue_vue_type_script_setup_true_lang-CoPqmpvz.js} +12571 -12873
  13. package/dist/FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-DxZ_5mfo.js +61 -0
  14. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-C4pvSYN-.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-B_mANlF3.js} +2 -2
  15. package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-CxDZP-Qo.js +237 -0
  16. package/dist/{FmMultiselectDialog-C7P1UET0.js → FmMultiselectDialog-Btal-2Li.js} +50 -44
  17. package/dist/{FmMultiselectDialog-Dru64kWF.js → FmMultiselectDialog-OVoHPzMx.js} +1 -1
  18. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-BklBxBGT.js → FmUnitInput.vue_vue_type_script_setup_true_lang-ClqEZkaP.js} +5 -5
  19. package/dist/{ImportView-C9w-sF5E.js → ImportView-CKXu4c1J.js} +6 -6
  20. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-BuphGYe2.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-C-fgSyVq.js} +1 -1
  21. package/dist/{IngredientGroupView-BZqXPr_n.js → IngredientGroupView-pwMYUotb.js} +5 -5
  22. package/dist/{IngredientsView-DgTPgkN9.js → IngredientsView-BzKhRbX3.js} +15 -15
  23. package/dist/{IntegrationExplorerView-B8U3LTtj.js → IntegrationExplorerView-BN8bTTW9.js} +5 -5
  24. package/dist/{IntegrationView-QyHxizvF.js → IntegrationView-DcERomsi.js} +13 -13
  25. package/dist/{InventoryBindingForm-NRwFwJt5.js → InventoryBindingForm-q_IGvaah.js} +1 -1
  26. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-C-If3KBe.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-0ti9a4bq.js} +5 -5
  27. package/dist/{InventoryBindingSummary-DqI3M6jQ.js → InventoryBindingSummary-aMQ0ZWgu.js} +1 -1
  28. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-Xt_1oU-z.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DpIGbDcW.js} +1 -1
  29. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-DFYTlv_K.js → PremiumBadge.vue_vue_type_script_setup_true_lang-CeMi5AJ0.js} +1 -1
  30. package/dist/{PublishView-2ytn8EUo.js → PublishView-vOeknkUB.js} +3 -3
  31. package/dist/{PurchaseOrderPrintPreview-Bqim_q38.js → PurchaseOrderPrintPreview-2dot6xAa.js} +9 -9
  32. package/dist/ReceiveRequestView-B9k1gWme.js +345 -0
  33. package/dist/{RecipeView-Bs326Ew3.js → RecipeView-PRj4zn8p.js} +17 -17
  34. package/dist/{SettingsView-frX_dI_K.js → SettingsView-CzxZ18_g.js} +4 -4
  35. package/dist/{StockView-Us8Wx8y_.js → StockView-o-WD1-0x.js} +28 -27
  36. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-Du8BI_cZ.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-B9bLM6Gi.js} +1 -1
  37. package/dist/{SupplierView-8dnHAbK3.js → SupplierView-CMww3rSL.js} +12 -12
  38. package/dist/{SurchargeView-CfqjYiBs.js → SurchargeView-D9KFsMtR.js} +6 -6
  39. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-_03vSZ4W.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-EXFK8KkU.js} +6 -5
  40. package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-CAb7UWFP.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-B9xb2r9v.js} +1 -1
  41. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-B58A7dWI.js → TransferDetails.vue_vue_type_script_setup_true_lang-Bl9bVtVE.js} +1440 -1433
  42. package/dist/{TransferTemplateView-CI84cmV5.js → TransferTemplateView-BTL8deN-.js} +20 -20
  43. package/dist/{UnitCostHistoryView-DXolsbDT.js → UnitCostHistoryView-D6n2ujRf.js} +4 -4
  44. package/dist/{UnitDisplayControl.vue_vue_type_script_setup_true_lang-Bpoawj7B.js → UnitDisplayControl.vue_vue_type_script_setup_true_lang-CNpOAH0D.js} +4 -4
  45. package/dist/{UnitView-DT3fcagF.js → UnitView-DNZW6dI4.js} +7 -7
  46. package/dist/{WarehouseView-C1BHChSJ.js → WarehouseView-gb9pJmNu.js} +5 -5
  47. package/dist/{WastageTemplateView-Bc5CZJ58.js → WastageTemplateView-CGaEJXJv.js} +14 -14
  48. package/dist/api/purchase-order.d.ts +2 -1
  49. package/dist/api/supplier.d.ts +1 -0
  50. package/dist/{app-DpMCzQql.js → app-Dsbvoxur.js} +1321 -965
  51. package/dist/app.d.ts +344 -0
  52. package/dist/app.js +1 -1
  53. package/dist/{closing-template-CaFX19g1.js → closing-template-p88yK47D.js} +1 -1
  54. package/dist/components/FmMultiselectDialog.vue.d.ts +8 -4
  55. package/dist/components/FmMultiselectDialogProps.d.ts +1 -0
  56. package/dist/components/MultiLocationSelector.vue.d.ts +202 -0
  57. package/dist/{date2-DBsUy1HH.js → date2-CtLHtGs5.js} +1 -1
  58. package/dist/{dayjs.min-BVKjPmJE.js → dayjs.min-B2OqD5Yb.js} +12 -12
  59. package/dist/{decimal-DKl2dUd0.js → decimal-Clk9Ewzg.js} +2 -2
  60. package/dist/{defineDeepModel-YeHxg9wN.js → defineDeepModel-B2OEZDfH.js} +1 -1
  61. package/dist/{duplicate-template-Dyx4X380.js → duplicate-template-B2POVQAS.js} +1 -1
  62. package/dist/{feature-ltFu24H8.js → feature-CLIj8wgr.js} +70 -65
  63. package/dist/{format-time-from-id-D3lPFiqA.js → format-time-from-id-DdReiNfK.js} +1 -1
  64. package/dist/{format-unit-display-CD8C9YZc.js → format-unit-display-iz29tCVo.js} +12 -12
  65. package/dist/{import-export.helper-BJ5Lz4Gg.js → import-export.helper-DlHAA9zA.js} +6 -6
  66. package/dist/{index-JOemzj27.js → index-B5Ojq711.js} +1 -1
  67. package/dist/{index-TQKBiFuU.js → index-CswTgtml.js} +3 -3
  68. package/dist/{index-B8xTUvTH.js → index-Dkl97ykE.js} +1 -1
  69. package/dist/{inventory-core-dart.default-Xz0fuxVn.js → inventory-core-dart.default-FvRrnQri.js} +1 -1
  70. package/dist/jszip.min-dfImtC94.js +2322 -0
  71. package/dist/{lz-string-DAdPi3YY.js → lz-string-D1kxEFLt.js} +1 -1
  72. package/dist/{netsuite-qr2wHoV5.js → netsuite-C_Gph48P.js} +2 -2
  73. package/dist/{number-xgIylzEb.js → number-CTKxLav6.js} +3 -3
  74. package/dist/{predefined-templates-j5MqD37J.js → predefined-templates-B2sDdw2Z.js} +1 -1
  75. package/dist/{purchase-order-template-CglLUVxv.js → purchase-order-template-DVDMAhJa.js} +1 -1
  76. package/dist/{recalculationUtils-O8dnzyPD.js → recalculationUtils-BNTXhTSX.js} +1 -1
  77. package/dist/router/name.d.ts +1 -0
  78. package/dist/{rules-BPu-CBAX.js → rules-CRnEoheI.js} +2 -2
  79. package/dist/{stock-VM7b7_Km.js → stock-CeogHsSl.js} +1 -1
  80. package/dist/stores/feature.d.ts +2 -0
  81. package/dist/style.css +1 -1
  82. package/dist/supplier-DmbVK4Tn.js +83 -0
  83. package/dist/{surcharge-CUUDBYUf.js → surcharge-Bm3TRth-.js} +1 -1
  84. package/dist/tsconfig.app.tsbuildinfo +1 -1
  85. package/dist/{uom-rules-D6eW0fAO.js → uom-rules-BmtdGlz9.js} +1 -1
  86. package/dist/{use-ingredient-select-dialog-Cd700UkI.js → use-ingredient-select-dialog-Bm9296fn.js} +2 -2
  87. package/dist/{use-inventory-binding-dialog-Cf8wC8AI.js → use-inventory-binding-dialog-HYJiNm8y.js} +2 -2
  88. package/dist/{use-template-enabled-locations-D1AVostH.js → use-template-enabled-locations-DSEcyYzM.js} +2 -2
  89. package/dist/{use-transfer-locations-uOi6cGul.js → use-transfer-locations-vpiv_TeO.js} +8 -8
  90. package/dist/{useHrmPermission-DEu2Lyei.js → useHrmPermission-DAncjlGt.js} +1 -1
  91. package/dist/{useNavigationMenu-DuIGSnMd.js → useNavigationMenu-BG_AH0Xf.js} +43 -38
  92. package/dist/{useSseClient-D1uc8ZIc.js → useSseClient-CuLS50U2.js} +3 -3
  93. package/dist/views/receive-request/components/transfer-form/TransferFormProps.d.ts +2 -0
  94. package/dist/views/receive-request/components/transfer-form/TransferFormWithController.vue.d.ts +194 -0
  95. package/dist/views/receive-request-bulk/BulkReceiveRequestView.vue.d.ts +3 -0
  96. package/dist/views/receive-request-bulk/components/CreateTransferWizard.vue.d.ts +25 -0
  97. package/dist/views/receive-request-bulk/composables/use-bulk-receive-request-form.d.ts +4138 -0
  98. package/dist/views/receive-request-bulk/composables/use-bulk-receive-request-table.d.ts +771 -0
  99. package/dist/{vue-i18n-DElpxFA8.js → vue-i18n-Tl34av_i.js} +176 -176
  100. package/dist/{xlsx.util-Cm8s0ZJD.js → xlsx.util-CJaAO-II.js} +360 -360
  101. package/package.json +3 -2
  102. package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-Bkh9LvJQ.js +0 -293
  103. package/dist/supplier-W00UQBDk.js +0 -78
@@ -0,0 +1,2000 @@
1
+ import { defineComponent as lt, ref as w, computed as S, watch as ze, openBlock as p, createElementBlock as _, Fragment as Ce, createBlock as ie, Teleport as wt, createVNode as D, Transition as Pt, withCtx as Fe, createElementVNode as e, toDisplayString as d, unref as t, createCommentVNode as L, normalizeClass as O, renderList as Qe, createTextVNode as Xe, mergeModels as qt, useModel as Tt, resolveComponent as Re, reactive as Ot, nextTick as tt, h as ve, watchEffect as At, isRef as mt, normalizeStyle as pt, normalizeProps as ft, mergeProps as st, guardReactiveProps as Bt } from "vue";
2
+ import { u as et, a as Nt, E as It, T as vt, c as $t, s as zt, U as Be, q as Lt, V as yt, Q as Ge, x as Mt } from "./app-Dsbvoxur.js";
3
+ import { i as rt, _ as Vt } from "./FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-DxZ_5mfo.js";
4
+ import { a as bt, d as Ut } from "./number-CTKxLav6.js";
5
+ import { c as jt, d as nt, P as it, e as Ht, f as Yt, h as Qt, i as Wt, j as Zt, a as Kt, _ as Jt, b as Xt, g as Gt } from "./TransferDetails.vue_vue_type_script_setup_true_lang-Bl9bVtVE.js";
6
+ import { i as es } from "./PremiumBadge.vue_vue_type_script_setup_true_lang-CeMi5AJ0.js";
7
+ import { d as Te } from "./dayjs.min-B2OqD5Yb.js";
8
+ import { e as ts } from "./UnitDisplayControl.vue_vue_type_script_setup_true_lang-CNpOAH0D.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-DGlWE5I8.js";
11
+ import { useSnackbar as ut, components as as, useDialog as rs, useBreakpoints as ls } from "@feedmepos/ui-library";
12
+ import { c as is, h as ht, u as us, _ as cs, a as ds, b as ms } from "./EmailDialog.vue_vue_type_script_setup_true_lang-CoPqmpvz.js";
13
+ import { useI18n as We, useCoreStore as kt } from "@feedmepos/mf-common";
14
+ import { u as Ct, a as ps } from "./supplier-DmbVK4Tn.js";
15
+ import { u as fs } from "./stock-CeogHsSl.js";
16
+ import { u as Ft } from "./SystemTrailDialog.vue_vue_type_script_setup_true_lang-EXFK8KkU.js";
17
+ import { b as St, a as vs } from "./format-unit-display-iz29tCVo.js";
18
+ import { P as ys } from "./inventory-core-dart.default-FvRrnQri.js";
19
+ import { _ as bs, F as He } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-Ca_eYa8-.js";
20
+ import { u as Dt } from "./feature-CLIj8wgr.js";
21
+ import { P as hs, J as gs, D as xs } from "./app-DiX-EfV6.js";
22
+ import { u as _s } from "./netsuite-C_Gph48P.js";
23
+ import { s as gt, f as ws } from "./predefined-templates-B2sDdw2Z.js";
24
+ import { t as ks, d as Cs } from "./date2-CtLHtGs5.js";
25
+ import { F as xt } from "./form-mode.enum-BKiNVH6A.js";
26
+ import { p as Fs } from "./format-time-from-id-DdReiNfK.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
+ }, Ds = {
32
+ key: 0,
33
+ class: "flex items-center justify-between px-24 h-[64px] border-b border-[#F0F0F0] shrink-0 bg-white"
34
+ }, Rs = { 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"], Os = { key: 1 }, As = ["disabled"], Bs = { 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
+ }, Dn = {
62
+ key: 1,
63
+ class: "py-32 text-center text-[#B2B3B6] fm-typo-en-body-md-400"
64
+ }, Rn = {
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]" }, On = {
68
+ key: 0,
69
+ class: "w-[8px] h-[8px] rounded-full bg-[#FF7823]"
70
+ }, An = {
71
+ key: 2,
72
+ class: "px-32 py-24"
73
+ }, Bn = { 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: $, FmDialog: U, FmIcon: j, FmTextField: A } = as, Z = ne, oe = k, { t: i } = We(), F = ut(), a = et(), ee = Ct(), X = Nt(), _e = fs(), P = Ft(), q = St(), b = w(0), ue = w(!1), H = w(null), te = w(""), g = w(null), u = w(null), T = w(null), me = w(""), ce = w(""), K = w(!1), ye = w(!1), be = w(!1), pe = w(!1), Oe = w(!1), Ae = w(/* @__PURE__ */ new Map()), Se = w(), ae = w([]), he = S(() => !!H.value), Ne = S(() => g.value === "transfer" ? !!u.value : g.value === "template" ? !!T.value : !1), we = S(() => (ae.value.length ? ae.value : E.value.items ?? []).some((o) => o.quantity.amount > 0)), m = S(() => K.value), f = S(
89
+ () => we.value && ye.value && be.value && !K.value
90
+ ), C = S(() => b.value === 0 ? he.value : b.value === 1 ? Ne.value : b.value === 2 ? f.value : !1), R = S(
91
+ () => b.value === 2 ? i("inventory.transfer.receiveRequest.bulk.wizard.createTransferBtn") : i("inventory.transfer.receiveRequest.bulk.wizard.continueBtn")
92
+ ), l = S(
93
+ () => M.value === "Purchase" ? "Purchase method" : "Transfer method"
94
+ ), r = S(
95
+ () => M.value === "Purchase" ? "Purchase details" : "Transfer details"
96
+ ), c = S(() => {
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 = S(() => {
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 = S(() => {
117
+ const s = ce.value.trim().toLowerCase(), o = q.templates;
118
+ return s ? o.filter((n) => n.name.toLowerCase().includes(s)) : o;
119
+ }), M = S(() => {
120
+ var s;
121
+ if (E.value.supplier)
122
+ return typeof E.value.supplier.internal == "string" ? "Transfer" : "Purchase";
123
+ if (g.value === "transfer" && u.value)
124
+ return u.value.type === "supplier" ? "Purchase" : "Transfer";
125
+ if (g.value === "template" && T.value) {
126
+ const o = q.templates.find((n) => n._id === T.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
+ }), B = S(() => H.value ? H.value.name : i("inventory.transfer.receiveRequest.bulk.wizard.notSelected")), v = S(() => g.value === "transfer" ? M.value === "Purchase" ? "Purchase from Supplier" : i("inventory.transfer.receiveRequest.bulk.wizard.outletToOutletMethod") : g.value === "template" ? i("inventory.transfer.receiveRequest.bulk.wizard.fromTemplateMethod") : i("inventory.transfer.receiveRequest.bulk.wizard.notChosen")), I = S(() => {
132
+ var s;
133
+ if (g.value === "transfer" && u.value)
134
+ return u.value.name;
135
+ if (g.value === "template" && T.value) {
136
+ const o = q.templates.find((n) => n._id === T.value);
137
+ return (s = o == null ? void 0 : o.purchaseOrder) != null && s.supplier ? o.purchaseOrder.supplier.name || T.value : (o == null ? void 0 : o.name) ?? T.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 = S(
159
+ () => H.value ? de(H.value) : ""
160
+ ), xe = S(
161
+ () => g.value === "transfer" && u.value ? u.value.type === "supplier" ? ge(u.value) : de(u.value) : ""
162
+ ), Ee = S(() => {
163
+ const o = (ae.value.length ? ae.value : E.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 x(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 z() {
211
+ var Y;
212
+ const s = T.value ? q.templates.find((W) => W._id === T.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 = g.value === "transfer" && u.value ? u.value.type === "supplier" ? N(u.value.doc) : V(u.value) : g.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: g.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: T.value ?? void 0,
236
+ templateDoc: s
237
+ };
238
+ }
239
+ const E = w(z()), se = w(`${Math.random()}`), fe = S(
240
+ () => {
241
+ var s;
242
+ return ((s = E.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, g.value = null, u.value = null, T.value = null, te.value = "", me.value = "", ce.value = "", ye.value = !1, be.value = !1, ae.value = [], E.value = z(), se.value = `${Math.random()}`, q.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
+ E.value = z(), 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 De(s) {
269
+ s < b.value && (b.value = s);
270
+ }
271
+ function Me() {
272
+ oe("update:show", !1);
273
+ }
274
+ function ke(s) {
275
+ g.value !== s && (g.value = s, u.value = null, T.value = null, ae.value = [], E.value = {
276
+ ...E.value,
277
+ items: [],
278
+ template: void 0,
279
+ templateDoc: void 0
280
+ });
281
+ }
282
+ function Pe(s) {
283
+ ae.value = s ?? [];
284
+ }
285
+ ze(T, (s) => {
286
+ g.value === "template" && s && (E.value = z(), 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
+ F.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
+ Oe.value = !0, Ae.value = /* @__PURE__ */ new Map();
302
+ try {
303
+ const s = await _e.readStockBalance(), o = /* @__PURE__ */ new Map();
304
+ for (const n of s.skus ?? [])
305
+ o.set(n.id, n);
306
+ Ae.value = o;
307
+ } catch {
308
+ } finally {
309
+ Oe.value = !1;
310
+ }
311
+ }
312
+ function Ze() {
313
+ var s;
314
+ (s = Se.value) != null && s.getFormData && (E.value = { ...E.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
+ E.value.items = ((s = E.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: E.value.items ?? []
332
+ }), o = Object.values(s).flat();
333
+ if (o.length > 0) {
334
+ const W = o[0];
335
+ F.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 Rt() {
345
+ const s = E.value;
346
+ if (K.value = !0, s.items = s.items.filter((o) => o.quantity.amount > 0), !s.items.length) {
347
+ F.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 P.createPurchaseOrder(s), F.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
+ F.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, g.value = null, u.value = null, T.value = null, te.value = "", me.value = "", ce.value = "", ye.value = !1, be.value = !1, ae.value = [], E.value = z(), se.value = `${Math.random()}`;
373
+ }
374
+ return (s, o) => (p(), _(Ce, null, [
375
+ (p(), ie(wt, { to: "body" }, [
376
+ D(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 ? (p(), _("div", Ss, [
386
+ ue.value ? L("", !0) : (p(), _("div", Ds, [
387
+ e("span", Rs, d(t(i)("inventory.transfer.receiveRequest.bulk.wizard.title")), 1),
388
+ e("div", Es, [
389
+ D(t($), {
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 ? (p(), ie(t($), {
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"])) : L("", !0),
403
+ D(t($), {
404
+ size: "md",
405
+ disabled: !C.value,
406
+ loading: K.value,
407
+ label: R.value,
408
+ onClick: Ie
409
+ }, null, 8, ["disabled", "loading", "label"])
410
+ ])
411
+ ])),
412
+ ue.value ? L("", !0) : (p(), _("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) => De(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 ? (p(), ie(t(j), {
426
+ key: 0,
427
+ name: "check",
428
+ size: "sm"
429
+ })) : (p(), _("span", Os, "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) => De(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 ? (p(), ie(t(j), {
450
+ key: 0,
451
+ name: "check",
452
+ size: "sm"
453
+ })) : (p(), _("span", Bs, "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, As),
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 ? (p(), _("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
+ D(t(A), {
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
+ (p(!0), _(Ce, null, Qe(c.value, (n, Y) => {
494
+ var W, le, J, qe, je, ct, dt;
495
+ return p(), _("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: (qo) => 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 ? (p(), _(Ce, { 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)) : L("", !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 ? (p(), _("div", Xs)) : L("", !0)
523
+ ], 2)
524
+ ], 10, Hs);
525
+ }), 128)),
526
+ c.value.length === 0 ? (p(), _("div", Gs, d(t(i)("inventory.transfer.receiveRequest.bulk.wizard.noOutletsAvailable")), 1)) : L("", !0)
527
+ ])
528
+ ])) : L("", !0),
529
+ b.value === 1 ? (p(), _("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
+ g.value === "transfer" ? "border-[#FF7823] bg-[#FFF5EE]" : "border-[#E0E0E0] bg-white hover:bg-[#FAFAFA]"
539
+ ]),
540
+ onClick: o[3] || (o[3] = (n) => ke("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", g.value === "transfer" ? "bg-[#FF7823]" : "bg-[#F0F0F0]"])
545
+ }, [
546
+ D(t(j), {
547
+ name: "swap_horiz",
548
+ size: "md",
549
+ class: O(g.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", g.value === "transfer" ? "bg-[#FF7823]" : "border border-[#CCCCCC]"])
554
+ }, [
555
+ g.value === "transfer" ? (p(), ie(t(j), {
556
+ key: 0,
557
+ name: "check",
558
+ size: "sm",
559
+ class: "text-white"
560
+ })) : L("", !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
+ g.value === "template" ? "border-[#FF7823] bg-[#FFF5EE]" : "border-[#E0E0E0] bg-white hover:bg-[#FAFAFA]"
570
+ ]),
571
+ onClick: o[4] || (o[4] = (n) => ke("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", g.value === "template" ? "bg-[#FF7823]" : "bg-[#F0F0F0]"])
576
+ }, [
577
+ D(t(j), {
578
+ name: "description",
579
+ size: "md",
580
+ class: O(g.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", g.value === "template" ? "bg-[#FF7823]" : "border border-[#CCCCCC]"])
585
+ }, [
586
+ g.value === "template" ? (p(), ie(t(j), {
587
+ key: 0,
588
+ name: "check",
589
+ size: "sm",
590
+ class: "text-white"
591
+ })) : L("", !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
+ g.value === "transfer" ? (p(), _(Ce, { key: 0 }, [
599
+ e("div", mn, d(t(i)("inventory.transfer.receiveRequest.bulk.wizard.step2SourceHeading")), 1),
600
+ e("div", pn, [
601
+ D(t(A), {
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
+ (p(!0), _(Ce, null, Qe(h.value, (n, Y) => {
612
+ var W, le, J;
613
+ return p(), _("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) ? (p(), _(Ce, { key: 0 }, [
629
+ Xe(" · " + d(Q(n)), 1)
630
+ ], 64)) : L("", !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 ? (p(), _("div", wn)) : L("", !0)
641
+ ], 2)
642
+ ], 10, vn);
643
+ }), 128)),
644
+ h.value.length === 0 ? (p(), _("div", kn, d(t(i)("inventory.transfer.receiveRequest.bulk.wizard.noOutletsAvailable")), 1)) : L("", !0)
645
+ ])
646
+ ], 64)) : L("", !0),
647
+ g.value === "template" ? (p(), _(Ce, { key: 1 }, [
648
+ e("div", Cn, d(t(i)("inventory.transfer.receiveRequest.bulk.wizard.step2TemplateHeading")), 1),
649
+ e("div", Fn, [
650
+ D(t(A), {
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(q).loading ? (p(), _("div", Sn, [
660
+ D(t(j), {
661
+ name: "progress_activity",
662
+ class: "text-[#FF7823] animate-spin"
663
+ })
664
+ ])) : y.value.length === 0 ? (p(), _("div", Dn, d(t(i)("inventory.transfer.receiveRequest.bulk.wizard.noTemplatesAvailable")), 1)) : (p(), _("div", Rn, [
665
+ (p(!0), _(Ce, null, Qe(y.value, (n) => (p(), _("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
+ T.value === n._id ? "border-[#FF7823] bg-[#FFF5EE]" : "border-[#E0E0E0] bg-white hover:bg-[#FAFAFA]"
670
+ ]),
671
+ onClick: (Y) => T.value = n._id
672
+ }, [
673
+ e("div", Pn, [
674
+ e("div", qn, d(n.name), 1),
675
+ e("div", Tn, d(x(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
+ T.value === n._id ? "border-[#FF7823]" : "border-[#CCCCCC]"
681
+ ])
682
+ }, [
683
+ T.value === n._id ? (p(), _("div", On)) : L("", !0)
684
+ ], 2)
685
+ ], 10, En))), 128))
686
+ ]))
687
+ ], 64)) : L("", !0)
688
+ ])) : L("", !0),
689
+ b.value === 2 ? (p(), _("div", An, [
690
+ e("div", Bn, [
691
+ e("h3", Nn, d(r.value), 1)
692
+ ]),
693
+ (p(), 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: Rt,
700
+ modelValue: E.value,
701
+ "onUpdate:modelValue": o[8] || (o[8] = (n) => E.value = n),
702
+ disabled: m.value,
703
+ "locked-supplier": E.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": Ae.value,
709
+ "is-balance-loading": Oe.value
710
+ }, null, 8, ["modelValue", "disabled", "locked-supplier", "suppliers", "skus", "last-closing-date", "sku-balance-map", "is-balance-loading"]))
711
+ ])) : L("", !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(B.value), 3),
724
+ re.value ? (p(), _("span", jn, d(re.value), 1)) : L("", !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", g.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 || T.value ? "text-[#1C1C1E]" : "text-[#B2B3B6]"
738
+ ])
739
+ }, d(I.value), 3),
740
+ xe.value ? (p(), _("span", Zn, d(xe.value), 1)) : L("", !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", we.value ? "text-[#1C1C1E]" : "text-[#6B6C70]"])
746
+ }, d(Ee.value), 3)
747
+ ])
748
+ ])
749
+ ])
750
+ ])
751
+ ])
752
+ ])) : L("", !0)
753
+ ]),
754
+ _: 1
755
+ })
756
+ ])),
757
+ D(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
+ D(t($), {
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
+ D(t($), {
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
+ (p(!0), _(Ce, null, Qe(fe.value, (n) => (p(), _("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(), $ = ne, U = Tt(ne, "modelValue"), j = w(!1), A = w(""), Z = S(() => {
813
+ const P = A.value.trim().toLowerCase();
814
+ return P ? $.locations.filter(
815
+ (q) => q.name.toLowerCase().includes(P) || (q.doc.profile.code ?? "").toLowerCase().includes(P)
816
+ ) : $.locations;
817
+ }), oe = S(() => U.value.length), i = S(
818
+ () => Z.value.length > 0 && Z.value.every((P) => U.value.includes(P.dbName))
819
+ ), F = S(
820
+ () => Z.value.some((P) => U.value.includes(P.dbName)) && !i.value
821
+ ), a = S(() => {
822
+ if (oe.value === 0) return k("inventory.transfer.receiveRequest.bulk.noLocationsSelected");
823
+ if (oe.value === 1) {
824
+ const P = $.locations.find((q) => q.dbName === U.value[0]);
825
+ return P ? `${P.name} (${P.doc.profile.code ?? "--"})` : U.value[0];
826
+ }
827
+ return k("inventory.transfer.receiveRequest.bulk.locationsSelected", [oe.value]);
828
+ });
829
+ function ee() {
830
+ const P = Z.value.map((q) => q.dbName);
831
+ i.value ? U.value = U.value.filter((q) => !P.includes(q)) : U.value = [.../* @__PURE__ */ new Set([...U.value, ...P])];
832
+ }
833
+ function X(P) {
834
+ U.value.includes(P) ? U.value = U.value.filter((q) => q !== P) : U.value = [...U.value, P];
835
+ }
836
+ function _e(P) {
837
+ return U.value.includes(P);
838
+ }
839
+ return (P, q) => {
840
+ const b = Re("FmIcon"), ue = Re("FmChip"), H = Re("FmTextField"), te = Re("FmMenuItem"), g = Re("FmMenu");
841
+ return p(), ie(g, {
842
+ "model-value": j.value,
843
+ placement: "bottom-end",
844
+ "close-on-click": !1,
845
+ onMenuChanged: q[1] || (q[1] = (u) => {
846
+ j.value = u, u || (A.value = "");
847
+ })
848
+ }, {
849
+ "menu-button": Fe(() => [
850
+ D(ue, {
851
+ label: a.value,
852
+ class: "text-fm-color-neutral-gray-400 cursor-pointer"
853
+ }, {
854
+ default: Fe(() => [
855
+ D(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
+ D(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
+ D(H, {
874
+ "model-value": A.value,
875
+ "onUpdate:modelValue": q[0] || (q[0] = (u) => A.value = u),
876
+ placeholder: t(k)("inventory.common.table.toolbar.filterItems"),
877
+ class: "my-8"
878
+ }, null, 8, ["model-value", "placeholder"]),
879
+ D(te, {
880
+ "model-value": i.value,
881
+ label: t(k)("inventory.common.selectAll"),
882
+ "has-checkbox": !0,
883
+ indeterminate: F.value,
884
+ onClick: ee
885
+ }, null, 8, ["model-value", "label", "indeterminate"]),
886
+ (p(!0), _(Ce, null, Qe(Z.value, (u) => (p(), ie(te, {
887
+ key: u.dbName,
888
+ "model-value": _e(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: (T) => X(u.dbName)
893
+ }, null, 8, ["model-value", "label", "sublabel", "onClick"]))), 128)),
894
+ Z.value.length === 0 ? (p(), ie(te, {
895
+ key: 0,
896
+ disabled: "",
897
+ label: t(k)("inventory.common.noResultFound")
898
+ }, null, 8, ["label"])) : L("", !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(), $ = et(), U = Dt(), j = Ct(), A = kt(), Z = vs(), oe = St(), i = w(!1), F = ut(), { t: a } = We(), ee = Ft(), X = jt(), _e = w([]), P = w([]), q = w(new Array()), b = w(
907
+ new Array()
908
+ ), ue = w(
909
+ ne != null && ne.startDate && (ne != null && ne.endDate) ? ne : rt()
910
+ ), H = S(() => {
911
+ const m = new Date(ue.value.startDate), f = new Date(ue.value.endDate);
912
+ return {
913
+ start: ks(m).toISOString(),
914
+ end: Cs(f).toISOString()
915
+ };
916
+ }), te = It(), g = w(null), u = Ot({
917
+ visible: !1,
918
+ title: "",
919
+ current: 0,
920
+ total: 0,
921
+ done: !1,
922
+ cancelled: !1
923
+ });
924
+ function T(m) {
925
+ const f = $.locations.find((C) => C.dbName === m._locationDbName);
926
+ if (!f) return null;
927
+ if (f.type === "restaurant") {
928
+ const C = $.locationRestaurantFromCore(f.doc._id);
929
+ if (C !== null)
930
+ return { ...f, doc: C };
931
+ }
932
+ return f;
933
+ }
934
+ function me(m) {
935
+ const f = $.locations.find((C) => C.dbName === m._locationDbName);
936
+ f && ($._currentLocation = f);
937
+ }
938
+ async function ce() {
939
+ if (P.value = [], q.value = [], _e.value.length !== 0) {
940
+ i.value = !0;
941
+ try {
942
+ const f = vt(_e.value, 5), C = [];
943
+ for (const y of f) {
944
+ const M = await Promise.allSettled(
945
+ y.map(async (B) => (await ee.getPurchaseOrders({
946
+ ...H.value,
947
+ dbName: B
948
+ })).map((I) => ({ ...I, _locationDbName: B })))
949
+ );
950
+ for (const B of M)
951
+ B.status === "fulfilled" && C.push(...B.value);
952
+ }
953
+ P.value = C.sort((y, M) => M._id.localeCompare(y._id));
954
+ const R = P.value.flatMap((y) => y.shipmentIds || []).filter(Boolean), l = R.length > 0 ? await X.getShipmentsByIds(R) : [];
955
+ q.value = l;
956
+ const r = await te.readCurrentLocationLastClosing(!0), c = r == null ? void 0 : r._id;
957
+ c && (g.value = Fs(c)), await U.awaitFeatureLoaded(() => U.mustUsePoTemplate) && await oe.fetchTemplates();
958
+ const h = P.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
+ F.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(m, f) {
975
+ ue.value = { startDate: m, endDate: f }, ce();
976
+ }
977
+ const ye = w();
978
+ async function be(m) {
979
+ const f = _e.value[0];
980
+ if (f) {
981
+ const l = $.locations.find((r) => r.dbName === f);
982
+ l && ($._currentLocation = l);
983
+ }
984
+ function C(l) {
985
+ const r = {
986
+ mode: xt.CREATE,
987
+ modelValue: m || void 0,
988
+ show: !0,
989
+ "onUpdate:show"(c) {
990
+ Ye.value.show = c;
991
+ },
992
+ templateId: l,
993
+ lastClosingDate: g.value
994
+ };
995
+ Ye.value = r;
996
+ }
997
+ let R;
998
+ U.mustUsePoTemplate && !(m != null && m.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
+ R = await Z.getTemplateId(), R && C(R);
1005
+ }).onSecondary(() => {
1006
+ C(void 0);
1007
+ }) : C(R);
1008
+ }
1009
+ function pe(m) {
1010
+ me(m);
1011
+ const f = {
1012
+ mode: xt.UPDATE,
1013
+ modelValue: $t(m),
1014
+ show: !0,
1015
+ "onUpdate:show"(C) {
1016
+ Ye.value.show = C;
1017
+ },
1018
+ lastClosingDate: g.value
1019
+ };
1020
+ Ye.value = f;
1021
+ }
1022
+ function Oe(m) {
1023
+ if (me(m), !A.currentBusiness.value) return;
1024
+ const f = T(m);
1025
+ if (!f) return;
1026
+ const C = nt({
1027
+ po: m,
1028
+ currentLocation: f,
1029
+ business: A.currentBusiness.value,
1030
+ fulfilling: !1,
1031
+ por: m.request
1032
+ });
1033
+ if (!C) return;
1034
+ const R = gt(C.html), l = j.supplierById[m.supplier._id], r = {
1035
+ recipientName: l == null ? void 0 : l.name,
1036
+ email: (l == null ? void 0 : l.email) ?? "",
1037
+ business: A.currentBusiness.value,
1038
+ modelValue: R,
1039
+ show: !0,
1040
+ "onUpdate:show"(c) {
1041
+ ot.value.show = c;
1042
+ }
1043
+ };
1044
+ ot.value = r;
1045
+ }
1046
+ async function Ae(m, f) {
1047
+ me(m), f ?? (f = b.value.find((r) => r.purchaseOrderId === m._id) ?? void 0);
1048
+ const R = T(m), l = {
1049
+ poRequest: f,
1050
+ purchaseOrder: m,
1051
+ transferTo: R == null ? void 0 : R.name,
1052
+ transferToDbName: R == null ? void 0 : R.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: Ht(m) ?? {},
1061
+ shipments: q.value
1062
+ };
1063
+ ye.value = l;
1064
+ }
1065
+ async function Se(m, f, C, R, l) {
1066
+ const r = Wt();
1067
+ i.value = !0;
1068
+ try {
1069
+ await r({
1070
+ operate: {
1071
+ operation: f,
1072
+ doc: m,
1073
+ options: (f === Be.enum.confirmDraft || f === Be.enum.completeReceive) && U.autoReceiveWarehouse ? { autoReceive: !0 } : void 0
1074
+ },
1075
+ operateV2: {
1076
+ _id: m._id,
1077
+ _rev: m._rev ?? "",
1078
+ action: f === Be.enum.submitRequest ? Be.enum.confirmDraft : f,
1079
+ payloads: l ?? []
1080
+ },
1081
+ transferTo: R
1082
+ }), await new Promise((c) => setTimeout(c, 1e3)), F.open({ title: "Success", message: C, type: "success" });
1083
+ } catch (c) {
1084
+ F.open({
1085
+ title: "Something went wrong",
1086
+ message: "Please try again.",
1087
+ type: "error"
1088
+ }), console.error("Error when submitting PO operation", f, m, c);
1089
+ } finally {
1090
+ i.value = !1, ce();
1091
+ }
1092
+ }
1093
+ async function ae(m, f, C) {
1094
+ me(m);
1095
+ const R = Zt[f];
1096
+ if (!R) {
1097
+ F.open({
1098
+ title: "Something went wrong",
1099
+ message: `Cannot process order: ${zt(f)}`,
1100
+ type: "error"
1101
+ });
1102
+ return;
1103
+ }
1104
+ const { successMessage: l, ...r } = R;
1105
+ if (f === Be.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(m, f, l, C, [
1118
+ { action: "rejectDraft", payload: { rejectReason: y } }
1119
+ ]);
1120
+ });
1121
+ return;
1122
+ }
1123
+ const c = [], h = Qt();
1124
+ h.init(m), (f === Be.enum.confirmDraft || f === Be.enum.submitRequest) && c.push({
1125
+ action: "confirmDraft",
1126
+ payload: h.controller.value.toConfirmDraftData(Lt())
1127
+ }), k.open({
1128
+ title: r.title,
1129
+ message: r.message,
1130
+ primaryActions: r.primaryActions
1131
+ }).onPrimary(() => {
1132
+ Se(
1133
+ m,
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 m = {
1148
+ show: !0,
1149
+ "onUpdate:show"(f) {
1150
+ at.value.show = f;
1151
+ }
1152
+ };
1153
+ at.value = m;
1154
+ });
1155
+ }
1156
+ async function Ne(m) {
1157
+ var c, h;
1158
+ const { startDate: f, endDate: C } = ue.value;
1159
+ if (Te(C).diff(Te(f), "month", !0) > 2) {
1160
+ F.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 (m.length === 0) {
1168
+ F.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 R = (await import("./jszip.min-dfImtC94.js").then((y) => y.j)).default, l = new R();
1176
+ let r = 0;
1177
+ u.title = a("inventory.transfer.receiveRequest.bulk.downloadProgress"), u.current = 0, u.total = m.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 m) {
1180
+ if (u.cancelled) break;
1181
+ try {
1182
+ const I = T(v);
1183
+ if (!I) continue;
1184
+ const de = nt({
1185
+ po: v,
1186
+ currentLocation: I,
1187
+ business: A.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 x = `${((h = $.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(`${x}.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), B = document.createElement("a");
1234
+ B.href = M, B.download = `purchase-orders-${Te().format("YYYY-MM-DD")}.zip`, B.click(), URL.revokeObjectURL(M), F.open({
1235
+ title: a("inventory.transfer.receiveRequest.bulk.downloadSuccess"),
1236
+ message: a("inventory.transfer.receiveRequest.bulk.downloadSuccessMsg", [
1237
+ m.length
1238
+ ]),
1239
+ type: "success"
1240
+ });
1241
+ } catch (y) {
1242
+ console.error("Bulk download failed", y), F.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 we(m) {
1252
+ var Ee;
1253
+ const f = [
1254
+ yt.enum.RECEIVING,
1255
+ yt.enum.PROCESSING
1256
+ // PARTIAL_RECEIVED display status maps from PROCESSING
1257
+ ], C = m.filter((x) => f.includes(x.status));
1258
+ if (C.length === 0) {
1259
+ F.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 = A.currentBusiness.value) != null && Ee._id)) return;
1267
+ const R = us(), l = ps(), r = /* @__PURE__ */ new Map(), c = $.locations.map((x) => x.dbName), h = `business_${A.currentBusiness.value._id}`, y = [.../* @__PURE__ */ new Set([...c, h])];
1268
+ await Promise.allSettled(
1269
+ y.map(async (x) => {
1270
+ try {
1271
+ (await l.readSuppliersByDbName(x)).forEach((N) => {
1272
+ const z = r.get(N._id);
1273
+ (!z || !z.email && N.email) && r.set(N._id, N);
1274
+ });
1275
+ } catch (V) {
1276
+ console.warn("[emailAll] fetch failed for", x, V);
1277
+ }
1278
+ })
1279
+ );
1280
+ function M(x) {
1281
+ var N;
1282
+ const V = r.get(x.supplier._id);
1283
+ return (V == null ? void 0 : V.email) || ((N = x.supplier) == null ? void 0 : N.email);
1284
+ }
1285
+ const B = [], v = [];
1286
+ for (const x of C)
1287
+ M(x) ? B.push(x) : v.push(x);
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 x = /* @__PURE__ */ new Map();
1295
+ for (const z of v) {
1296
+ const E = z.supplier._id;
1297
+ x.has(E) || x.set(E, { supplierName: z.supplier.name, pos: [] }), x.get(E).pos.push(z);
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
+ [...x.values()].map(
1310
+ ({ supplierName: z, pos: E }) => 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" }, z),
1312
+ ve(
1313
+ "div",
1314
+ { class: "flex flex-wrap gap-4" },
1315
+ E.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", [B.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((z) => {
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(() => z(!0)).onSecondary(() => z(!1));
1346
+ })) return;
1347
+ } else {
1348
+ const x = 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", [B.length])
1354
+ )
1355
+ ]);
1356
+ if (!await new Promise((N) => {
1357
+ k.open({
1358
+ title: a("inventory.transfer.receiveRequest.bulk.missingEmailTitle"),
1359
+ contentComponent: x,
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 (B.length === 0) {
1370
+ F.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 R.getEmailList(A.currentBusiness.value._id);
1380
+ } catch {
1381
+ F.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((x) => x.verified);
1389
+ if (!ge) {
1390
+ F.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 = vt(B, 2);
1398
+ let re = 0;
1399
+ const xe = [];
1400
+ u.title = a("inventory.transfer.receiveRequest.bulk.emailProgress"), u.current = 0, u.total = B.length, u.done = !1, u.cancelled = !1, u.visible = !0, await tt(), await new Promise((x) => setTimeout(x, 100));
1401
+ try {
1402
+ for (let x = 0; x < Q.length; x++) {
1403
+ const V = Q[x];
1404
+ await Promise.allSettled(
1405
+ V.map(async (N) => {
1406
+ var E;
1407
+ const z = document.createElement("div");
1408
+ z.style.cssText = "position:fixed;left:-99999px;top:0;width:210mm;background:white;z-index:-1;opacity:0;pointer-events:none;", document.body.appendChild(z);
1409
+ try {
1410
+ const se = T(N);
1411
+ if (!se) return;
1412
+ const fe = nt({
1413
+ po: N,
1414
+ currentLocation: se,
1415
+ business: A.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), De = new DOMParser().parseFromString(fe.html, "text/html");
1421
+ for (; De.body.firstChild; )
1422
+ z.appendChild(De.body.firstChild);
1423
+ De.head.querySelectorAll("style").forEach((Pe) => z.prepend(Pe.cloneNode(!0)));
1424
+ const ke = await ht().set({
1425
+ margin: 10,
1426
+ html2canvas: { scale: 2, useCORS: !0, letterRendering: !0 },
1427
+ jsPDF: { unit: "mm", format: "a4", orientation: "portrait" }
1428
+ }).from(z).outputPdf("blob");
1429
+ if (!ke) return;
1430
+ await R.sendMailFormData({
1431
+ businessId: A.currentBusiness.value._id,
1432
+ from: {
1433
+ name: ge.name || ((E = A.currentBusiness.value) == null ? void 0 : E.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: [ke],
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(z), re++, u.current = re;
1447
+ }
1448
+ })
1449
+ ), await tt(), x < Q.length - 1 && await new Promise((N) => setTimeout(N, 1500));
1450
+ }
1451
+ u.done = !0, xe.length > 0 ? F.open({
1452
+ title: a("inventory.transfer.receiveRequest.bulk.emailPartialSuccess"),
1453
+ message: a("inventory.transfer.receiveRequest.bulk.emailPartialSuccessMsg", [
1454
+ B.length - xe.length,
1455
+ B.length
1456
+ ]),
1457
+ type: "warning"
1458
+ }) : F.open({
1459
+ title: a("inventory.transfer.receiveRequest.bulk.emailSuccess"),
1460
+ message: a("inventory.transfer.receiveRequest.bulk.emailSuccessMsg", [
1461
+ B.length
1462
+ ]),
1463
+ type: "success"
1464
+ });
1465
+ } catch (x) {
1466
+ console.error("Bulk email failed", x), F.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: _e,
1477
+ purchaseOrders: P,
1478
+ shipments: q,
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: Ae,
1489
+ submitAction: ae,
1490
+ xilnexImportDialogProps: at,
1491
+ promptUploadTransferDialog: he,
1492
+ emailDialogProps: ot,
1493
+ promptEmailDialog: Oe,
1494
+ downloadAll: Ne,
1495
+ emailAll: we,
1496
+ lastClosingDate: g
1497
+ };
1498
+ }
1499
+ function io(ne, k) {
1500
+ const $ = et(), { t: U } = We(), j = Kt(
1501
+ it.RECEIVE_REQUEST,
1502
+ ne,
1503
+ k
1504
+ );
1505
+ return {
1506
+ columnDefs: S(() => {
1507
+ const Z = j.columnDefs.value, oe = {
1508
+ id: "location",
1509
+ header: () => U("inventory.transfer.receiveRequest.bulk.locationColumn"),
1510
+ cell(F) {
1511
+ const a = F.row.original._locationDbName, ee = $.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 = { class: "flex-1 w-full flex items-center gap-4 xs:flex-col-reverse sm:flex-col-reverse" }, co = { class: "flex-1 xs:w-full sm:w-full" }, mo = {
1526
+ key: 0,
1527
+ class: "flex-1"
1528
+ }, po = { class: "w-full max-w-[343px] xs:max-w-[unset] sm:max-w-[unset]" }, fo = {
1529
+ key: 0,
1530
+ class: "flex flex-col items-center justify-center py-48 gap-8 text-fm-color-typo-secondary"
1531
+ }, vo = { class: "fm-typo-en-body-md-400" }, yo = { class: "flex flex-col py-8" }, bo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ho = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, go = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary line-clamp-1" }, xo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary line-clamp-1" }, _o = {
1532
+ key: 0,
1533
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-primary line-clamp-1"
1534
+ }, wo = { class: "pt-8" }, ko = {
1535
+ key: 0,
1536
+ class: "fixed inset-0 bg-black/40 z-[9999] flex items-center justify-center"
1537
+ }, Co = { class: "bg-white rounded-xl shadow-lg p-24 flex flex-col gap-12 min-w-[320px] max-w-[480px]" }, Fo = { class: "fm-typo-en-title-sm-600" }, So = { class: "flex flex-col gap-8" }, Do = { class: "flex justify-between fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Ro = { class: "w-full bg-fm-color-neutral-gray-200 rounded-full h-8" }, Eo = {
1538
+ key: 0,
1539
+ class: "fm-typo-en-body-sm-400 text-fm-color-semantic-success-500 text-center"
1540
+ }, Po = {
1541
+ key: 1,
1542
+ class: "flex justify-end pt-4"
1543
+ }, _t = "BulkReceiveRequestViewSearchCriteria", oa = /* @__PURE__ */ lt({
1544
+ __name: "BulkReceiveRequestView",
1545
+ setup(ne) {
1546
+ const { t: k } = We(), $ = ut();
1547
+ ws().fetchTemplates(), Ge.object({
1548
+ name: Ge.string().optional().nullable(),
1549
+ startDate: Ge.string().optional().nullable(),
1550
+ endDate: Ge.string().optional().nullable()
1551
+ });
1552
+ const j = ss(), A = Dt(), Z = _s();
1553
+ function oe() {
1554
+ const l = {
1555
+ name: "",
1556
+ ...rt()
1557
+ }, r = j.getItem(_t);
1558
+ if (!r) return l;
1559
+ try {
1560
+ return JSON.parse(r);
1561
+ } catch {
1562
+ return l;
1563
+ }
1564
+ }
1565
+ function i() {
1566
+ j.setItem(_t, JSON.stringify(F.value));
1567
+ }
1568
+ const F = w(oe()), a = lo(F.value), ee = w(!1), { selectedLocationDbNames: X } = a, _e = S(() => T.value.filter((l) => X.value.includes(l.dbName)).map((l) => l.doc._id)), {
1569
+ columnDefs: P,
1570
+ showCustomPrintDialog: q,
1571
+ customPrintHtml: b,
1572
+ customPrintTemplateName: ue,
1573
+ customPrintIsDefault: H
1574
+ } = io(a, a.shipments), te = et(), g = Mt(), u = kt(), T = w([]);
1575
+ At(() => {
1576
+ const l = te.locations;
1577
+ l.length > 0 && (T.value = l);
1578
+ });
1579
+ async function me() {
1580
+ var r;
1581
+ if ((r = u.currentBusiness.value) != null && r._id)
1582
+ try {
1583
+ const c = await g.readAllInventoryLocations();
1584
+ c.length > 0 && (T.value = c);
1585
+ } catch {
1586
+ }
1587
+ }
1588
+ ze(
1589
+ [() => u.sessionUser.value, () => u.currentBusiness.value],
1590
+ ([l, r]) => {
1591
+ l && r && me();
1592
+ },
1593
+ { immediate: !0 }
1594
+ );
1595
+ const ce = S(() => a.loading.value), K = a.bulkProgress;
1596
+ async function ye() {
1597
+ const l = `inventory-record_${Te(F.value.startDate).format("DD-MM-YYYY_HH-mm")}-${Te(F.value.endDate).format("DD-MM-YYYY_HH-mm")}.xlsx`, r = a.purchaseOrders.value.flatMap(
1598
+ (h) => h.items.map((y) => {
1599
+ var G, Q;
1600
+ const M = new Date(es(h._id) ?? ""), B = h.effectiveAt ? new Date(h.effectiveAt) : void 0, v = bt(
1601
+ Gt(y.sku, h.deliveryOrder || [])
1602
+ ), I = bt(y.quantity), de = ((G = y == null ? void 0 : y.measurement) == null ? void 0 : G.abbrev) || y.sku.unit.abbrev;
1603
+ return {
1604
+ Location: ((Q = te.locations.find((re) => re.dbName === h._locationDbName)) == null ? void 0 : Q.name) ?? "",
1605
+ "SKU code": y.code,
1606
+ "SKU name": y.name,
1607
+ "PO #": h.seqNumber,
1608
+ "Effective at": B,
1609
+ Date: M,
1610
+ Status: h.status,
1611
+ Reference: h.ref ?? "",
1612
+ "Received quantity": v,
1613
+ "Ordered quantity": I,
1614
+ Unit: de,
1615
+ "Total cost": y.totalCost ? Ut(y.totalCost) : null
1616
+ };
1617
+ })
1618
+ ), c = [
1619
+ "Location",
1620
+ "SKU code",
1621
+ "SKU name",
1622
+ "PO #",
1623
+ "Date",
1624
+ "Status",
1625
+ "Reference",
1626
+ "Received quantity",
1627
+ "Ordered quantity",
1628
+ "Unit"
1629
+ ];
1630
+ A.enableBackdatePo && c.insert("Effective at", 5), A.enableTotalCost && c.push("Total cost"), await ts([{ name: "purchases", data: r, columns: c }], l), $.open({
1631
+ title: k("inventory.transfer.receiveRequest.export.success"),
1632
+ message: k("inventory.transfer.receiveRequest.export.message", [l]),
1633
+ type: "success"
1634
+ });
1635
+ }
1636
+ const be = w(rt()), pe = w("");
1637
+ ze([() => be.value], ([l]) => {
1638
+ if (!l.startDate || !l.endDate) return;
1639
+ if (Te(l.endDate).diff(Te(l.startDate), "day") > 60) {
1640
+ $.open({
1641
+ title: k("inventory.transfer.receiveRequest.bulk.dateRangeLimitTitle"),
1642
+ message: k("inventory.transfer.receiveRequest.bulk.dateRangeLimitMsg"),
1643
+ type: "warning"
1644
+ }), be.value = {
1645
+ startDate: l.startDate,
1646
+ endDate: Te(l.startDate).add(60, "day").format("YYYY-MM-DD")
1647
+ };
1648
+ return;
1649
+ }
1650
+ F.value.startDate = l.startDate, F.value.endDate = l.endDate, a.updateDateRange(F.value.startDate, F.value.endDate), i();
1651
+ }), ze([() => pe.value], () => {
1652
+ i();
1653
+ }), ze(
1654
+ () => X.value,
1655
+ () => {
1656
+ a.fetchData();
1657
+ }
1658
+ );
1659
+ function Oe(l) {
1660
+ if (l === "create") {
1661
+ if (ce.value) {
1662
+ $.open({ title: "Loading data...", message: "Please wait.", type: "info" });
1663
+ return;
1664
+ }
1665
+ if (X.value.length === 0) {
1666
+ $.open({
1667
+ title: "No outlets selected",
1668
+ message: "Please select at least one outlet to create a transfer.",
1669
+ type: "warning"
1670
+ });
1671
+ return;
1672
+ }
1673
+ ee.value = !0;
1674
+ return;
1675
+ }
1676
+ if (l === "upload" && A.enableXilnexTransferNote)
1677
+ return a.promptUploadTransferDialog();
1678
+ if (l === "refresh") return a.fetchData();
1679
+ if (l === "export") return ye();
1680
+ if (l === "downloadAll") return Ae();
1681
+ if (l === "emailAll") return Se();
1682
+ }
1683
+ async function Ae() {
1684
+ if (X.value.length === 0) {
1685
+ $.open({
1686
+ title: k("inventory.transfer.receiveRequest.bulk.noLocationsSelected"),
1687
+ message: "",
1688
+ type: "warning"
1689
+ });
1690
+ return;
1691
+ }
1692
+ await a.downloadAll(R.value);
1693
+ }
1694
+ async function Se() {
1695
+ if (A.enablePurchaseOrderEmail) {
1696
+ if (X.value.length === 0) {
1697
+ $.open({
1698
+ title: k("inventory.transfer.receiveRequest.bulk.noLocationsSelected"),
1699
+ message: "",
1700
+ type: "warning"
1701
+ });
1702
+ return;
1703
+ }
1704
+ await a.emailAll(R.value);
1705
+ }
1706
+ }
1707
+ const { breakpoints: ae } = ls(), he = S(() => ae.value.xs || ae.value.sm), Ne = S(() => he.value ? 10 : 20), we = ns(), m = S(() => [
1708
+ {
1709
+ label: k("inventory.transfer.receiveRequest.actions.create"),
1710
+ value: "create",
1711
+ isPrimary: !0,
1712
+ prependIcon: "add"
1713
+ },
1714
+ ...A.enableXilnexTransferNote ? [{ label: k("inventory.common.upload"), value: "upload" }] : [],
1715
+ { label: k("inventory.common.refresh"), value: "refresh" },
1716
+ { label: k("inventory.common.export"), value: "export" },
1717
+ ...A.enablePrintTemplate ? [
1718
+ {
1719
+ label: k("inventory.transfer.receiveRequest.bulk.downloadAll"),
1720
+ value: "downloadAll",
1721
+ prependIcon: "download"
1722
+ }
1723
+ ] : [],
1724
+ ...A.enablePurchaseOrderEmail ? [
1725
+ {
1726
+ label: k("inventory.transfer.receiveRequest.bulk.emailAll"),
1727
+ value: "emailAll",
1728
+ prependIcon: "email"
1729
+ }
1730
+ ] : []
1731
+ ]), f = S(() => {
1732
+ const l = [
1733
+ {
1734
+ type: "string",
1735
+ key: "status",
1736
+ entity: "purchaseOrder",
1737
+ values: Array.from(new Set(a.purchaseOrders.value.map((c) => c.status)))
1738
+ },
1739
+ {
1740
+ type: "string",
1741
+ key: "transferFrom",
1742
+ entity: "purchaseOrder",
1743
+ values: Array.from(new Set(a.purchaseOrders.value.map((c) => c.supplier.name)))
1744
+ },
1745
+ {
1746
+ type: "string",
1747
+ key: "location",
1748
+ entity: "purchaseOrder",
1749
+ values: Array.from(
1750
+ new Set(
1751
+ a.purchaseOrders.value.map((c) => {
1752
+ const h = te.locations.find((y) => y.dbName === c._locationDbName);
1753
+ return (h == null ? void 0 : h.name) ?? c._locationDbName;
1754
+ })
1755
+ )
1756
+ )
1757
+ }
1758
+ ], r = [
1759
+ {
1760
+ type: "string",
1761
+ key: "netsuiteTransactionNumber",
1762
+ entity: "purchaseOrder",
1763
+ values: a.purchaseOrders.value.map((c) => {
1764
+ var h, y;
1765
+ return (y = (h = c.netSuite) == null ? void 0 : h.additionalInfo) == null ? void 0 : y.transactionnumber;
1766
+ }).filter((c) => c != null)
1767
+ },
1768
+ {
1769
+ type: "string",
1770
+ key: "netsuiteOrderNo",
1771
+ entity: "purchaseOrder",
1772
+ values: a.purchaseOrders.value.map((c) => {
1773
+ var h;
1774
+ return (h = c.netSuite) == null ? void 0 : h.refNo;
1775
+ }).filter((c) => c != null)
1776
+ },
1777
+ {
1778
+ type: "string",
1779
+ key: "netsuiteOrderId",
1780
+ entity: "purchaseOrder",
1781
+ values: a.purchaseOrders.value.map((c) => {
1782
+ var h;
1783
+ return (h = c.netSuite) == null ? void 0 : h.id;
1784
+ }).filter((c) => c != null)
1785
+ }
1786
+ ];
1787
+ return [...l, ...Z.isEnabled ? r : []];
1788
+ }), C = w(null), R = S(() => {
1789
+ if (!C.value) return a.purchaseOrders.value;
1790
+ const l = hs.build(C.value);
1791
+ return a.purchaseOrders.value.filter((r) => {
1792
+ var h, y, M, B, v;
1793
+ const c = ((h = te.locations.find((I) => I.dbName === r._locationDbName)) == null ? void 0 : h.name) ?? r._locationDbName;
1794
+ return gs(
1795
+ {
1796
+ netsuiteTransactionNumber: (M = (y = r.netSuite) == null ? void 0 : y.additionalInfo) == null ? void 0 : M.transactionnumber,
1797
+ netsuiteOrderNo: (B = r.netSuite) == null ? void 0 : B.refNo,
1798
+ netsuiteOrderId: (v = r.netSuite) == null ? void 0 : v.id,
1799
+ status: r.status,
1800
+ transferFrom: r.supplier.name,
1801
+ location: c
1802
+ },
1803
+ l
1804
+ );
1805
+ });
1806
+ });
1807
+ return (l, r) => {
1808
+ const c = Re("FmTextField"), h = Re("FmIcon"), y = Re("FmTable"), M = Re("FmButton");
1809
+ return p(), ie(os, {
1810
+ title: t(k)("inventory.transfer.receiveRequest.bulk.title"),
1811
+ actions: m.value,
1812
+ "onClick:action": Oe
1813
+ }, {
1814
+ default: Fe(() => {
1815
+ var B;
1816
+ return [
1817
+ e("div", {
1818
+ class: O(["flex flex-col gap-8 max-h-full", { "p-0": he.value, "px-24": !he.value }])
1819
+ }, [
1820
+ e("div", {
1821
+ class: "flex flex-col gap-8",
1822
+ onVnodeMounted: r[4] || (r[4] = //@ts-ignore
1823
+ (...v) => t(we).onMounted && t(we).onMounted(...v)),
1824
+ onVnodeUnmounted: r[5] || (r[5] = //@ts-ignore
1825
+ (...v) => t(we).onUnmounted && t(we).onUnmounted(...v))
1826
+ }, [
1827
+ e("div", {
1828
+ class: O([
1829
+ "flex gap-8 items-center",
1830
+ { "px-8 flex-col-reverse h-[unset]": he.value, "h-48": !he.value }
1831
+ ])
1832
+ }, [
1833
+ e("div", {
1834
+ class: O(["flex gap-8 items-center", { "w-full overflow-x-auto": he.value }])
1835
+ }, [
1836
+ D(ro, {
1837
+ modelValue: t(X),
1838
+ "onUpdate:modelValue": r[0] || (r[0] = (v) => mt(X) ? X.value = v : null),
1839
+ locations: T.value
1840
+ }, null, 8, ["modelValue", "locations"]),
1841
+ D(Vt, {
1842
+ "model-value": be.value,
1843
+ "onUpdate:modelValue": r[1] || (r[1] = (v) => be.value = v)
1844
+ }, null, 8, ["model-value"])
1845
+ ], 2),
1846
+ e("div", uo, [
1847
+ e("div", co, [
1848
+ D(t(xs), {
1849
+ modelValue: C.value,
1850
+ "onUpdate:modelValue": r[2] || (r[2] = (v) => C.value = v),
1851
+ attributes: f.value
1852
+ }, null, 8, ["modelValue", "attributes"])
1853
+ ]),
1854
+ he.value ? L("", !0) : (p(), _("div", mo)),
1855
+ e("div", po, [
1856
+ D(c, {
1857
+ "model-value": pe.value,
1858
+ "onUpdate:modelValue": r[3] || (r[3] = (v) => pe.value = v),
1859
+ "prepend-icon": "search",
1860
+ placeholder: t(k)("inventory.common.table.toolbar.filterItems"),
1861
+ class: "w-full"
1862
+ }, null, 8, ["model-value", "placeholder"])
1863
+ ])
1864
+ ])
1865
+ ], 2)
1866
+ ], 512),
1867
+ t(X).length === 0 && !ce.value ? (p(), _("div", fo, [
1868
+ D(h, {
1869
+ name: "storefront",
1870
+ size: "xl"
1871
+ }),
1872
+ e("p", vo, d(t(k)("inventory.transfer.receiveRequest.bulk.selectLocationsHint")), 1)
1873
+ ])) : (p(), ie(y, {
1874
+ key: 1,
1875
+ style: pt(t(we).tableHeight),
1876
+ "column-defs": t(P),
1877
+ "row-data": R.value,
1878
+ "search-value": pe.value,
1879
+ loading: ce.value,
1880
+ onRowClick: r[6] || (r[6] = (v) => t(a).promptShowTransferDetails(v.original)),
1881
+ "page-size": Ne.value
1882
+ }, {
1883
+ "list-row": Fe((v) => [
1884
+ D(bs, {
1885
+ row: v,
1886
+ onRowClick: t(a).promptShowTransferDetails
1887
+ }, {
1888
+ default: Fe((I) => {
1889
+ var de, ge, G, Q, re, xe, Ee, x, V, N, z, E, se, fe, Ie, Le, De, Me, ke, Pe, Ve, Ue, Ze, $e, Ke;
1890
+ return [
1891
+ e("div", yo, [
1892
+ e("div", bo, [
1893
+ D(t(He), {
1894
+ render: (G = (ge = (de = I._id) == null ? void 0 : de.column) == null ? void 0 : ge.columnDef) == null ? void 0 : G.cell,
1895
+ props: (re = (Q = I._id) == null ? void 0 : Q.getContext) == null ? void 0 : re.call(Q)
1896
+ }, null, 8, ["render", "props"])
1897
+ ]),
1898
+ e("div", ho, [
1899
+ D(t(He), {
1900
+ render: (x = (Ee = (xe = I.location) == null ? void 0 : xe.column) == null ? void 0 : Ee.columnDef) == null ? void 0 : x.cell,
1901
+ props: (N = (V = I.location) == null ? void 0 : V.getContext) == null ? void 0 : N.call(V)
1902
+ }, null, 8, ["render", "props"])
1903
+ ]),
1904
+ e("div", go, [
1905
+ D(t(He), {
1906
+ render: (se = (E = (z = I.supplier_name) == null ? void 0 : z.column) == null ? void 0 : E.columnDef) == null ? void 0 : se.cell,
1907
+ props: (Ie = (fe = I.supplier_name) == null ? void 0 : fe.getContext) == null ? void 0 : Ie.call(fe)
1908
+ }, null, 8, ["render", "props"])
1909
+ ]),
1910
+ e("div", xo, d(v.original.items.map((Je) => `${Je.name}`).join(", ")), 1),
1911
+ v.original.ref ? (p(), _("div", _o, [
1912
+ D(t(He), {
1913
+ render: (Me = (De = (Le = I.ref) == null ? void 0 : Le.column) == null ? void 0 : De.columnDef) == null ? void 0 : Me.cell,
1914
+ props: (Pe = (ke = I.ref) == null ? void 0 : ke.getContext) == null ? void 0 : Pe.call(ke)
1915
+ }, null, 8, ["render", "props"])
1916
+ ])) : L("", !0),
1917
+ e("div", wo, [
1918
+ D(t(He), {
1919
+ render: (Ze = (Ue = (Ve = I.status) == null ? void 0 : Ve.column) == null ? void 0 : Ue.columnDef) == null ? void 0 : Ze.cell,
1920
+ props: (Ke = ($e = I.status) == null ? void 0 : $e.getContext) == null ? void 0 : Ke.call($e)
1921
+ }, null, 8, ["render", "props"])
1922
+ ])
1923
+ ])
1924
+ ];
1925
+ }),
1926
+ _: 2
1927
+ }, 1032, ["row", "onRowClick"])
1928
+ ]),
1929
+ _: 1
1930
+ }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
1931
+ ], 2),
1932
+ (p(), ie(wt, { to: "body" }, [
1933
+ t(K).visible ? (p(), _("div", ko, [
1934
+ e("div", Co, [
1935
+ e("div", Fo, d(t(K).title), 1),
1936
+ e("div", So, [
1937
+ e("div", Do, [
1938
+ e("span", null, d(t(k)("inventory.transfer.receiveRequest.bulk.progressLabel")), 1),
1939
+ e("span", null, d(t(K).current) + " / " + d(t(K).total), 1)
1940
+ ]),
1941
+ e("div", Ro, [
1942
+ e("div", {
1943
+ class: "bg-fm-color-primary h-8 rounded-full",
1944
+ style: pt({
1945
+ width: `${t(K).total > 0 ? t(K).current / t(K).total * 100 : 0}%`
1946
+ })
1947
+ }, null, 4)
1948
+ ])
1949
+ ]),
1950
+ t(K).done ? (p(), _("div", Eo, d(t(k)("inventory.transfer.receiveRequest.bulk.progressDone")), 1)) : L("", !0),
1951
+ t(K).done ? L("", !0) : (p(), _("div", Po, [
1952
+ D(M, {
1953
+ variant: "secondary",
1954
+ size: "md",
1955
+ label: t(k)("inventory.transfer.receiveRequest.bulk.progressCancel"),
1956
+ disabled: t(K).cancelled,
1957
+ onClick: r[7] || (r[7] = (v) => t(K).cancelled = !0)
1958
+ }, null, 8, ["label", "disabled"])
1959
+ ]))
1960
+ ])
1961
+ ])) : L("", !0),
1962
+ t(A).enablePurchaseOrderEmail ? (p(), ie(cs, ft(st({ key: 1 }, t(a).emailDialogProps.value)), null, 16)) : L("", !0),
1963
+ D(ao, {
1964
+ show: ee.value,
1965
+ "onUpdate:show": r[8] || (r[8] = (v) => ee.value = v),
1966
+ "last-closing-date": t(a).lastClosingDate.value,
1967
+ "selected-outlet-ids": _e.value,
1968
+ onSubmitted: t(a).fetchData
1969
+ }, null, 8, ["show", "last-closing-date", "selected-outlet-ids", "onSubmitted"]),
1970
+ D(ds, st(t(a).transferDialogProps.value, {
1971
+ onSubmitted: t(a).fetchData
1972
+ }), null, 16, ["onSubmitted"]),
1973
+ D(Jt, st({
1974
+ scope: t(it).RECEIVE_REQUEST
1975
+ }, {
1976
+ ...t(a).transferDetailsProps.value,
1977
+ receivedMap: ((B = t(a).transferDetailsProps.value) == null ? void 0 : B.receivedMap) ?? {},
1978
+ shipments: t(a).shipments.value ?? []
1979
+ }, {
1980
+ onSubmitted: t(a).fetchData
1981
+ }), null, 16, ["scope", "onSubmitted"]),
1982
+ D(ms, ft(Bt(t(a).xilnexImportDialogProps.value)), null, 16),
1983
+ D(Xt, {
1984
+ modelValue: t(q),
1985
+ "onUpdate:modelValue": r[9] || (r[9] = (v) => mt(q) ? q.value = v : null),
1986
+ html: t(b),
1987
+ "template-name": t(ue),
1988
+ "is-default": t(H)
1989
+ }, null, 8, ["modelValue", "html", "template-name", "is-default"])
1990
+ ]))
1991
+ ];
1992
+ }),
1993
+ _: 1
1994
+ }, 8, ["title", "actions"]);
1995
+ };
1996
+ }
1997
+ });
1998
+ export {
1999
+ oa as default
2000
+ };