@accounter/client 0.0.11-alpha-20260125180828-ba6265251b2d2e84e3355b96352f5bf83918317f → 0.0.11-alpha-20260126094406-5e339d8e89f94400c777170c689d55bd9dd5f95c

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 (102) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/assets/{Checkbox-DWmOT4mx.js → Checkbox-Dmuz3t7B.js} +1 -1
  3. package/dist/assets/{MultiSelect-DhEZHYxn.js → MultiSelect-DBeIExB5.js} +1 -1
  4. package/dist/assets/{Progress-DE13gAJ5.js → Progress---sZILQb.js} +1 -1
  5. package/dist/assets/{Table-rNmO5bBI.js → Table-BQv3frL8.js} +1 -1
  6. package/dist/assets/{Typography-C1pdNNG8.js → Typography-B8Kph7eR.js} +1 -1
  7. package/dist/assets/accordion-Bn08_4fN.js +1 -0
  8. package/dist/assets/{accountant-approvals-DXUA4Z8R.js → accountant-approvals-DuNl7y6H.js} +1 -1
  9. package/dist/assets/{accounter-table-CGncq_73.js → accounter-table-DTsgtq5M.js} +1 -1
  10. package/dist/assets/{addDays-DpkzPtfc.js → addDays-DTiBTTns.js} +1 -1
  11. package/dist/assets/{all-charges-CAf5Sz2_.js → all-charges-DPyM-a74.js} +1 -1
  12. package/dist/assets/{arrow-up-down-MrfN0fhR.js → arrow-up-down-VY6mkkTR.js} +1 -1
  13. package/dist/assets/{building-2-CWrl-iq9.js → building-2-CMKd_bU8.js} +1 -1
  14. package/dist/assets/{business-CnobDfUp.js → business-BVMKhHFx.js} +1 -1
  15. package/dist/assets/{business-extended-info-6Ykvm7VT.js → business-extended-info-B94y5ZK6.js} +1 -1
  16. package/dist/assets/business-header-BC86M-9m.js +1 -0
  17. package/dist/assets/{business-ledger-filters-Bi9mwcxM.js → business-ledger-filters-es3H4rPK.js} +1 -1
  18. package/dist/assets/{business-ledger-single-SwmnJ5M-.js → business-ledger-single-U3zkqgW2.js} +1 -1
  19. package/dist/assets/business-trip-BUKYnQkG.js +1 -0
  20. package/dist/assets/charge-DuqIMfNm.js +1 -0
  21. package/dist/assets/charges-filters-CFCAP-bP.js +1 -0
  22. package/dist/assets/{charges-ledger-validation-ClbJGvF9.js → charges-ledger-validation-CCTNRpCE.js} +1 -1
  23. package/dist/assets/{charges-table-zGkVW5or.js → charges-table-BJtpvXfL.js} +3 -3
  24. package/dist/assets/contracts-ljjcB_x7.js +1 -0
  25. package/dist/assets/{data-table-column-header-DDRUwuwC.js → data-table-column-header-CZ1dXiU0.js} +1 -1
  26. package/dist/assets/{data-table-pagination-DxOcd13P.js → data-table-pagination-XAlQIbO9.js} +1 -1
  27. package/dist/assets/deposits-transactions-table-2rtRFZgK.js +1 -0
  28. package/dist/assets/{download-csv-BmamqJJW.js → download-csv-BSGaUZsM.js} +1 -1
  29. package/dist/assets/{download-csv-button-BFfxSTjQ.js → download-csv-button-CMQBUQeX.js} +1 -1
  30. package/dist/assets/{editable-business-trip-CPfdEl45.js → editable-business-trip-CED1Su3d.js} +1 -1
  31. package/dist/assets/{eye-off-DtXkBVx1.js → eye-off-Buv7eciz.js} +1 -1
  32. package/dist/assets/{funnel-B1ZA9LM9.js → funnel-Cfb9Pxmr.js} +1 -1
  33. package/dist/assets/index-3ev2Q3E9.js +1 -0
  34. package/dist/assets/{index-Cs7XgdTM.js → index-7gCTV42h.js} +2 -2
  35. package/dist/assets/{index-Bsnch-zI.js → index-8fdLByFg.js} +1 -1
  36. package/dist/assets/index-B0hZ0TDG.js +1 -0
  37. package/dist/assets/{index-DCmEMj8e.js → index-B4OP8iL7.js} +3 -3
  38. package/dist/assets/{index-DKmgIoB5.js → index-BN-I0GSO.js} +2 -2
  39. package/dist/assets/index-BhFsGqUx.js +1 -0
  40. package/dist/assets/{index-Chao5nQb.js → index-Bui9zV-z.js} +1 -1
  41. package/dist/assets/{index-ciP7vurq.js → index-C7p19nIa.js} +1 -1
  42. package/dist/assets/{index-DwGxsIkH.js → index-CPMJQkvw.js} +1 -1
  43. package/dist/assets/{index-BBOAkvDK.js → index-CSdQtH7c.js} +1 -1
  44. package/dist/assets/index-CcZll7L2.js +1 -0
  45. package/dist/assets/index-CjG9JDZB.js +2 -0
  46. package/dist/assets/{index-DqoPYGJE.js → index-DGAT1KYx.js} +1 -1
  47. package/dist/assets/index-DIrLsKod.js +1 -0
  48. package/dist/assets/{index-DfBrqs5_.js → index-DJY6AKiM.js} +2 -2
  49. package/dist/assets/{index-Bv5ZyMGd.js → index-DOy0Yf1i.js} +1 -1
  50. package/dist/assets/{index-CywvUChw.js → index-DRBzHdu9.js} +1 -1
  51. package/dist/assets/index-Dal_ULkA.js +1 -0
  52. package/dist/assets/{index-DJQjDgkB.js → index-DokXNUuN.js} +1 -1
  53. package/dist/assets/{index-DjsqV-Fn.js → index-Dq33WQoi.js} +1 -1
  54. package/dist/assets/{index-C60AFYOu.js → index-DzzUoyj4.js} +1 -1
  55. package/dist/assets/{index-Vxd58TOQ.js → index-GlUqZUgQ.js} +1 -1
  56. package/dist/assets/index-X3RoQQa9.js +1 -0
  57. package/dist/assets/index-X9rrwleE.js +1 -0
  58. package/dist/assets/{index-DRqooPz9.js → index-rI994S3C.js} +4 -4
  59. package/dist/assets/{index.es-C6H8Q1nD.js → index.es-C2YDJ0AL.js} +1 -1
  60. package/dist/assets/issue-document-zNxGzRkY.js +1 -0
  61. package/dist/assets/login-page-BimTSmTC.js +1 -0
  62. package/dist/assets/{missing-info-charges-Dr8TvB2G.js → missing-info-charges-CVhY60ZL.js} +1 -1
  63. package/dist/assets/{modal-CPrQ9jQu.js → modal-BXR_xgUm.js} +1 -1
  64. package/dist/assets/modify-contract-dialog-flMl2p_T.js +1 -0
  65. package/dist/assets/{page-layout-Dp9Tr43G.js → page-layout-DMGj5xhW.js} +1 -1
  66. package/dist/assets/{page-not-found-BIERJkiT.js → page-not-found-B_GB5ntj.js} +1 -1
  67. package/dist/assets/{panel-top-open-lnF5tdL1.js → panel-top-open-Bf39HBrp.js} +1 -1
  68. package/dist/assets/report-commentary-row-BMyeQR9J.js +1 -0
  69. package/dist/assets/{save-BaXyzRSW.js → save-jkuyCWyY.js} +1 -1
  70. package/dist/assets/{similar-transactions-modal-DilkLkpx.js → similar-transactions-modal-DX3CPrMo.js} +1 -1
  71. package/dist/assets/{sub-764RJPt0.js → sub-CEXBz_OW.js} +1 -1
  72. package/dist/assets/subMonths-DY4HlBVa.js +1 -0
  73. package/dist/assets/summary-CPKS_69D.js +1 -0
  74. package/dist/assets/{toggle-expansion-button-BquTpOYj.js → toggle-expansion-button-Y2eS7nqg.js} +1 -1
  75. package/dist/assets/{update-accountant-status-Btcm95Uc.js → update-accountant-status-zL6vnwU9.js} +1 -1
  76. package/dist/assets/use-issue-monthly-documents-D9vQpbaZ.js +1 -0
  77. package/dist/assets/{use-url-query-A8PE3FMA.js → use-url-query-CqWra6gD.js} +1 -1
  78. package/dist/index.html +1 -1
  79. package/package.json +1 -1
  80. package/dist/assets/accordion-Air1oXnF.js +0 -1
  81. package/dist/assets/business-header-CAJaQahQ.js +0 -1
  82. package/dist/assets/business-trip-ADSYpFTM.js +0 -1
  83. package/dist/assets/charge-CLyQ-8f8.js +0 -1
  84. package/dist/assets/charges-filters-CYR6-jcu.js +0 -1
  85. package/dist/assets/contracts-DCd159UE.js +0 -1
  86. package/dist/assets/deposits-transactions-table-Dhm74qLm.js +0 -1
  87. package/dist/assets/index-5Ht40D_c.js +0 -1
  88. package/dist/assets/index-BL8siR4m.js +0 -1
  89. package/dist/assets/index-C0Bd8nM_.js +0 -1
  90. package/dist/assets/index-CFLkhm3K.js +0 -1
  91. package/dist/assets/index-CXZphjyK.js +0 -1
  92. package/dist/assets/index-Cd9YArsS.js +0 -1
  93. package/dist/assets/index-DynC0Vxq.js +0 -1
  94. package/dist/assets/index-cd89pXq_.js +0 -1
  95. package/dist/assets/index-d-FcvOUD.js +0 -2
  96. package/dist/assets/issue-document-B8SLRY9w.js +0 -1
  97. package/dist/assets/login-page-DF0c_Pay.js +0 -1
  98. package/dist/assets/modify-contract-dialog-BMTCgQ3i.js +0 -1
  99. package/dist/assets/report-commentary-row-BsA3JSzG.js +0 -1
  100. package/dist/assets/subMonths-CZ2djAnO.js +0 -1
  101. package/dist/assets/summary-BvHHpnIR.js +0 -1
  102. package/dist/assets/use-issue-monthly-documents-Dx6_0gyN.js +0 -1
@@ -1,2 +1,2 @@
1
- import{v as oe,w as Xe,u as re,S as Ws,r as v,j as e,D as Se,x as Te,y as Ks,c as Je,z as Ys,g as Be,t as Y,i as Ee,U as Xs,E as Pe,G as Qe,H as fe,J as Ce,K as X,N as J,O as Cs,Q,V as Z,W as Oe,X as ee,Y as le,Z as j,_ as g,$ as f,a0 as y,I as C,a1 as S,a2 as b,a3 as Ae,B as T,a4 as ae,a5 as te,a6 as Ze,a7 as Js,a8 as ue,a9 as es,aa as ss,ab as me,ac as M,ad as ns,ae as Qs,af as ie,ag as Zs,ah as he,R as As,ai as pe,aj as en,ak as sn,al as as,am as ts,an as is,ao as Is,ap as ws,aq as Ds,ar as ks,as as Ss,at as ce,au as Ts,av as Bs,aw as Es,ax as nn,ay as Ps,az as $e,aA as an,aB as tn,aC as rs,aD as rn,P as cn,aE as ln,aF as q,aG as ls,aH as Fe,aI as on,aJ as dn,aK as mn,aL as Os,aM as un,aN as xn,aO as hn,aP as pn,aQ as jn,aR as Ls,aS as gn,aT as P,aU as Ue,aV as Fs,aW as qe,aX as os,aY as fn,aZ as Ms,a_ as vn,a$ as yn,b0 as Nn,b1 as de,b2 as bn,b3 as Cn,b4 as An,b5 as He,b6 as In,b7 as wn,b8 as Dn,b9 as kn,ba as Sn,bb as ds,bc as Tn,bd as Bn,be as En,bf as Pn,bg as ms,bh as On,bi as Ln,bj as Fn,bk as Mn,F as _n,bl as Rn,bm as zn,bn as se,bo as Vn,bp as $n,bq as Un,br as K,bs as qn,a as Hn,b as Gn,bt as Wn}from"./index-DRqooPz9.js";import{S as cs}from"./save-BaXyzRSW.js";import{g as Kn,a as _s}from"./similar-transactions-modal-DilkLkpx.js";import{B as Yn}from"./business-extended-info-6Ykvm7VT.js";import{B as Xn}from"./business-header-CAJaQahQ.js";import{C as Jn,L as Qn}from"./charges-table-zGkVW5or.js";import{i as Zn,D as ea,f as sa,E as na,L as Me,a as we,C as aa,A as ta,b as ve,c as ia,d as Ge,h as ra,e as ca,g as Rs,u as la,G as oa,j as us,k as da,X as zs,Y as Vs,l as ma,m as ua,R as xa,n as ha,o as pa,p as ja,q as ga}from"./download-csv-BmamqJJW.js";import{M as We,s as fa,a as va}from"./modify-contract-dialog-BMTCgQ3i.js";import{u as ya,E as Na}from"./use-issue-monthly-documents-Dx6_0gyN.js";import{s as ba}from"./subMonths-CZ2djAnO.js";import{E as Ca,T as Aa}from"./index-ciP7vurq.js";import{A as Ia,a as _e,b as xs,c as hs}from"./accordion-Air1oXnF.js";import{B as wa}from"./building-2-CWrl-iq9.js";import"./data-table-column-header-DDRUwuwC.js";import"./eye-off-DtXkBVx1.js";import"./download-csv-button-BFfxSTjQ.js";import"./toggle-expansion-button-BquTpOYj.js";import"./panel-top-open-lnF5tdL1.js";import"./update-accountant-status-Btcm95Uc.js";import"./Table-rNmO5bBI.js";import"./summary-BvHHpnIR.js";import"./deposits-transactions-table-Dhm74qLm.js";import"./Checkbox-DWmOT4mx.js";import"./sequential-CjOfRLtc.js";import"./addDays-DpkzPtfc.js";const Da=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],ka=oe("chart-line",Da);const Sa=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Re=oe("circle-check",Sa);const Ta=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]],ps=oe("circle-slash",Ta);const Ba=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],De=oe("dollar-sign",Ba);const Ea=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m9 15 2 2 4-4",key:"1grp1n"}]],Pa=oe("file-check",Ea);const Oa=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["rect",{width:"10",height:"8",x:"7",y:"8",rx:"1",key:"vys8me"}]],La=oe("fullscreen",Oa);const Fa=[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M16 2v20",key:"rotuqe"}]],Ma=oe("notebook",Fa);const _a=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]],Ra=oe("plug",_a);function za(s){return Xe(s,"yyyy-MM-dd")}function Va({businessId:s,tagIds:n,description:a,open:t,onOpenChange:c,onClose:o}){const[{data:i,fetching:l},x]=re({pause:!0,query:Ws,variables:{businessId:s,tagsDifferentThan:n?n.map(h=>h.id):void 0,descriptionDifferentThan:a}});v.useEffect(()=>{t&&(n||a)&&!i&&x()},[t,n,a,x,i]);const d=v.useCallback(h=>{c(h),t&&!h&&o?.()},[c,o,t]),m=v.useMemo(()=>t&&(!!n||!!a)&&i&&i?.similarChargesByBusiness.length>0,[t,n,a,i]);return e.jsx(Se,{open:m,onOpenChange:d,children:e.jsx(Te,{className:"overflow-scroll max-h-screen w-full sm:max-w-[640px] md:max-w-[768px] lg:max-w-[900px]",onClick:h=>h.stopPropagation(),children:e.jsx(Ks,{fallback:e.jsx("div",{children:"Error fetching similar charges"}),children:l?e.jsx(Je,{}):n||a?e.jsx(Ys,{data:i?.similarChargesByBusiness??[],tagIds:n,description:a,onOpenChange:d,title:"Similar Charges by Business"}):null})})})}const $a="updateAdminBusiness",Ua=()=>{const[{fetching:s},n]=Be(Xs),a=v.useCallback(async t=>{const c=`Error updating admin business ID [${t.adminBusinessId}]`,o=`${$a}-${t.adminBusinessId}`;Y.loading("Updating admin business",{id:o});try{const i=await n(t),l=Ee(i,c,o,"updateAdminBusiness");if(l)return Y.success("Success",{id:o,description:"Admin Business Updated"}),l.updateAdminBusiness}catch(i){console.error(`${c}: ${i}`),Y.error("Error",{id:o,description:c,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,updateAdminBusiness:a}},ze=ue({year:ns().min(2e3).max(2100),id:M().min(1,{message:"ID is required"})}),qa=ue({registrationDate:M().min(1,{message:"Business Registration Start Date is required"}),withholdingTaxAnnualIds:me(ze),withholdingTaxCompanyId:M().min(1,{message:"Withholding Tax Company ID is required"}),socialSecurityEmployerIds:me(ze),socialSecurityDeductionsId:M().min(1,{message:"Social Security Deductions ID is required"}),taxAdvancesAnnualIds:me(ze),taxAdvancesRates:me(ue({date:Qs(),rate:ns().min(0,{message:"Rate must be at least 0"}).max(100,{message:"Rate must be at most 100"})}))}),ye={WITHHOLDING_TAX:"https://secapp.taxes.gov.il/NikPay/StartPage.aspx#/Home",TAX_ADVANCES:"https://secapp.taxes.gov.il/gmftashmh/main/entrance",SOCIAL_SECURITY:"https://b2b.btl.gov.il/BTL.ILG.Payments/ChovDochMaasikInfo.aspx",VAT:"https://secapp.taxes.gov.il/emdvhmfrt/wLogOnMenu.aspx"},Ne=({href:s,children:n})=>e.jsxs("h3",{className:"flex flex-row gap-2 text-sm font-semibold text-foreground md:col-span-2",children:[e.jsx("a",{href:s,target:"_blank",rel:"noreferrer",onClick:a=>a.stopPropagation(),className:"inline-flex items-center font-semibold",children:e.jsx(es,{size:12})}),e.jsx("span",{children:n})]});function js(s){return!s||s.__typename!=="LtdFinancialEntity"||!s.adminInfo?{}:{registrationDate:s.adminInfo.registrationDate,withholdingTaxAnnualIds:s.adminInfo.withholdingTaxAnnualIds.sort((n,a)=>a.year-n.year),withholdingTaxCompanyId:s.adminInfo.withholdingTaxCompanyId??void 0,socialSecurityEmployerIds:s.adminInfo.socialSecurityEmployerIds.sort((n,a)=>a.year-n.year),socialSecurityDeductionsId:s.adminInfo.socialSecurityDeductionsId??void 0,taxAdvancesAnnualIds:s.adminInfo.taxAdvancesAnnualIds.sort((n,a)=>a.year-n.year),taxAdvancesRates:s.adminInfo.taxAdvancesRates?.map(n=>({date:n.date,rate:n.rate*100}))}}function Ha(s){return{registrationDate:s.registrationDate?za(new Date(s.registrationDate)):void 0,withholdingTaxAnnualIds:s.withholdingTaxAnnualIds,withholdingTaxCompanyId:s.withholdingTaxCompanyId,socialSecurityEmployerIds:s.socialSecurityEmployerIds,taxAdvancesRates:s.taxAdvancesRates?.map(n=>({date:n.date,rate:n.rate/100})),taxAdvancesAnnualIds:s.taxAdvancesAnnualIds}}function Ga({data:s,refetchBusiness:n}){const a=fe(Js,s),[t,c]=v.useState(js(a)),{updateAdminBusiness:o,fetching:i}=Ua(),l=Pe({resolver:Qe(qa),defaultValues:t}),x=async w=>{if(!a)return;const D=ss(w,l.formState.dirtyFields);if(!D)return;const z=Ha(D);await o({adminBusinessId:a.id,fields:z}),n?.()};v.useEffect(()=>{if(a){const w=js(a);c(w),l.reset(w)}},[a,l]);const{fields:d,append:m,remove:h}=Ce({control:l.control,name:"taxAdvancesAnnualIds"}),{fields:u,append:p,remove:I}=Ce({control:l.control,name:"withholdingTaxAnnualIds"}),{fields:k,append:B,remove:_}=Ce({control:l.control,name:"socialSecurityEmployerIds"}),O={withholdingTaxAnnualIds:{append:p,remove:I},taxAdvancesAnnualIds:{append:m,remove:h},socialSecurityEmployerIds:{append:B,remove:_}},V=w=>{O[w].append({year:new Date().getFullYear(),id:""})},$=(w,D)=>{O[w].remove(D)},{fields:R,append:W,remove:r}=Ce({control:l.control,name:"taxAdvancesRates"}),L=()=>{W({date:Xe(new Date,"yyyy-MM-dd"),rate:0})},U=w=>{r(w)};return e.jsxs(X,{children:[e.jsxs(J,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Cs,{className:"h-5 w-5 text-primary"}),e.jsx(Q,{children:"Admin Business Configuration"})]}),e.jsx(Z,{children:"Tax and registration information for the business operating this application"})]}),e.jsx(Oe,{...l,children:e.jsxs("form",{onSubmit:l.handleSubmit(x),className:"space-y-6",children:[e.jsx(ee,{children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx(Ne,{href:ye.VAT,children:"VAT"}),e.jsx(le,{className:"md:col-span-2"}),e.jsx(Ne,{href:ye.TAX_ADVANCES,children:"Tax Advances"}),e.jsx(le,{className:"md:col-span-2"}),e.jsx(Ne,{href:ye.WITHHOLDING_TAX,children:"Withholding Tax"}),e.jsx(j,{control:l.control,name:"withholdingTaxCompanyId",render:({field:w,fieldState:D})=>e.jsxs(g,{children:[e.jsx(f,{children:"Company Tax ID"}),e.jsx(y,{children:e.jsx(C,{placeholder:"Enter company ID",...w,className:S(D)})}),e.jsx(b,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ae,{children:"Annual IDs"}),e.jsx(T,{type:"button",variant:"outline",size:"sm",onClick:()=>V("withholdingTaxAnnualIds"),children:e.jsx(ae,{className:"size-4"})})]}),e.jsx("div",{className:"space-y-3",children:u.map((w,D)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsxs("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[e.jsx(C,{placeholder:"Year",type:"number",...l.register(`withholdingTaxAnnualIds.${D}.year`,{valueAsNumber:!0})}),e.jsx(C,{placeholder:"ID",...l.register(`withholdingTaxAnnualIds.${D}.id`)})]}),e.jsx(T,{type:"button",variant:"ghost",size:"icon",onClick:()=>$("withholdingTaxAnnualIds",D),children:e.jsx(te,{className:"size-4"})})]},w.id))})]}),e.jsx(le,{className:"md:col-span-2"}),e.jsx(Ne,{href:ye.TAX_ADVANCES,children:"Tax Advances"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ae,{children:"Annual IDs"}),e.jsx(T,{type:"button",variant:"outline",size:"sm",onClick:()=>V("taxAdvancesAnnualIds"),children:e.jsx(ae,{className:"size-4"})})]}),e.jsx("div",{className:"space-y-3",children:d.map((w,D)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsxs("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[e.jsx(C,{placeholder:"Year",type:"number",...l.register(`taxAdvancesAnnualIds.${D}.year`,{valueAsNumber:!0})}),e.jsx(C,{placeholder:"ID",...l.register(`taxAdvancesAnnualIds.${D}.id`)})]}),e.jsx(T,{type:"button",variant:"ghost",size:"icon",onClick:()=>$("taxAdvancesAnnualIds",D),children:e.jsx(te,{className:"size-4"})})]},w.id))})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ae,{children:"Rates (%)"}),e.jsx(T,{type:"button",variant:"outline",size:"sm",onClick:L,children:e.jsx(ae,{className:"size-4"})})]}),e.jsx("div",{className:"space-y-3",children:R.map((w,D)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsxs("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[e.jsx(C,{placeholder:"Date",type:"date",...l.register(`taxAdvancesRates.${D}.date`)}),e.jsx(C,{placeholder:"Rate",...l.register(`taxAdvancesRates.${D}.rate`,{valueAsNumber:!0})})]}),e.jsx(T,{type:"button",variant:"ghost",size:"icon",onClick:()=>U(D),children:e.jsx(te,{className:"size-4"})})]},w.id))})]}),e.jsx(le,{className:"md:col-span-2"}),e.jsx(Ne,{href:ye.SOCIAL_SECURITY,children:"Social Security"}),e.jsx(j,{control:l.control,name:"socialSecurityDeductionsId",render:({field:w,fieldState:D})=>e.jsxs(g,{children:[e.jsx(f,{children:"Deductions ID"}),e.jsx(y,{children:e.jsx(C,{placeholder:"Enter deductions ID",...w,className:S(D)})}),e.jsx(b,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ae,{children:"Annual Employer IDs"}),e.jsx(T,{type:"button",variant:"outline",size:"sm",onClick:()=>V("socialSecurityEmployerIds"),children:e.jsx(ae,{className:"size-4"})})]}),e.jsx("div",{className:"space-y-3",children:k.map((w,D)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsxs("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[e.jsx(C,{placeholder:"Year",type:"number",...l.register(`socialSecurityEmployerIds.${D}.year`,{valueAsNumber:!0})}),e.jsx(C,{placeholder:"ID",...l.register(`socialSecurityEmployerIds.${D}.id`)})]}),e.jsx(T,{type:"button",variant:"ghost",size:"icon",onClick:()=>$("socialSecurityEmployerIds",D),children:e.jsx(te,{className:"size-4"})})]},w.id))})]}),e.jsx(le,{className:"md:col-span-2"}),e.jsx(j,{control:l.control,name:"registrationDate",render:({field:w,fieldState:D})=>e.jsxs(g,{children:[e.jsx(f,{children:"Business Registration Start Date"}),e.jsx(y,{children:e.jsx(C,{type:"date",...w,className:S(D)})}),e.jsx(b,{})]})})]})}),e.jsx(Ze,{className:"flex justify-end border-t mt-4 pt-6",children:e.jsxs(T,{type:"submit",disabled:i||Object.keys(l.formState.dirtyFields).length===0||!l.formState.isValid,children:[e.jsx(cs,{className:"h-4 w-4"}),"Save Changes"]})})]})})]})}function Wa({account:s,handleOpenModal:n}){return e.jsxs(X,{children:[e.jsx(J,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-primary/10 text-primary",children:Kn(s.type)}),e.jsxs("div",{children:[e.jsxs(Q,{className:"text-lg",children:[s.name,s.name===s.number?"":` (${s.number})`]}),e.jsxs(Z,{className:"flex items-center gap-2 mt-1",children:[e.jsx(ie,{variant:"outline",children:_s(s.type)}),!s.isBusiness&&e.jsx(ie,{variant:"secondary",children:"Private"})]})]})]}),e.jsx("div",{className:"flex gap-1",children:e.jsx(T,{variant:"ghost",size:"sm",onClick:()=>n(s),"aria-label":`Edit account ${s.name}`,children:e.jsx(Zs,{className:"h-4 w-4","aria-hidden":"true"})})})]})}),e.jsxs(ee,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2",children:"Currencies & Tax Categories"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:s.currencies?.map(a=>e.jsx(he,{to:As.TAX_CATEGORIES,target:"_blank",rel:"noreferrer",onClick:t=>t.stopPropagation(),children:e.jsxs(ie,{variant:"secondary",className:"text-xs",children:[a.currency," → ",a.taxCategory.name]})},a.currency))})]}),s.type===pe.BankAccount&&e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("h4",{className:"text-sm font-medium mb-3",children:"Bank Details"}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Bank Number:"}),e.jsx("p",{className:"font-medium",children:s.bankNumber})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Branch Number:"}),e.jsx("p",{className:"font-medium",children:s.branchNumber})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Extended Bank Number:"}),e.jsx("p",{className:"font-medium",children:s.extendedBankNumber})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"IBAN:"}),e.jsx("p",{className:"font-medium",children:s.iban})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Party Preferred Indication:"}),e.jsx("p",{className:"font-medium",children:s.partyPreferredIndication})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Party Account Involvement:"}),e.jsx("p",{className:"font-medium",children:s.partyAccountInvolvementCode})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Account Deal Date:"}),e.jsx("p",{className:"font-medium",children:s.accountDealDate})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Account Update Date:"}),e.jsx("p",{className:"font-medium",children:s.accountUpdateDate})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Meteg Dora Net:"}),e.jsx("p",{className:"font-medium",children:s.metegDoarNet})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Kod Harshaot Peilut:"}),e.jsx("p",{className:"font-medium",children:s.kodHarshaatPeilut})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Closing Reason Code:"}),e.jsx("p",{className:"font-medium",children:s.accountClosingReasonCode})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Agreement Opening Date:"}),e.jsx("p",{className:"font-medium",children:s.accountAgreementOpeningDate})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Branch Type Code:"}),e.jsx("p",{className:"font-medium",children:s.branchTypeCode})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Mymail Entitlement:"}),e.jsx("p",{className:"font-medium",children:s.mymailEntitlementSwitch})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Service Authorization:"}),e.jsx("p",{className:"font-medium",children:s.serviceAuthorizationDesc})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Product Label:"}),e.jsx("p",{className:"font-medium",children:s.productLabel})]})]})]})]})]})}const Ka="createFinancialAccount",Ya=()=>{const[{fetching:s},n]=Be(en),a=v.useCallback(async t=>{const c=`Error creating new account "${t.input.name}"`,o=`${Ka}-${t.input.name}`;Y.loading("Creating account",{id:o});try{const i=await n(t);Ee(i,c,o)&&Y.success("Success",{id:o,description:`Financial Account ${t.input.name} was successfully created`})}catch(i){console.error(`${c}: ${i}`),Y.error("Error",{id:o,description:c,duration:1e5,closeButton:!0})}},[n]);return{creating:s,createFinancialAccount:a}},Xa="updateFinancialAccount",Ja=()=>{const[{fetching:s},n]=Be(sn),a=v.useCallback(async t=>{const c=`Error updating financial account ID [${t.financialAccountId}]`,o=`${Xa}-${t.financialAccountId}`;Y.loading("Updating financial account",{id:o});try{const i=await n(t),l=Ee(i,c,o,"updateFinancialAccount");if(l)return Y.success("Success",{id:o,description:"Financial account updated"}),l.updateFinancialAccount}catch(i){console.error(`${c}: ${i}`),Y.error("Error",{id:o,description:c,duration:1e5,closeButton:!0})}},[n]);return{updating:s,updateFinancialAccount:a}},Qa=ue({currency:Es(Object.values(Ps),"Currency is required"),taxCategory:ue({id:an("Tax category ID is required"),name:M().min(1,"Tax category name is required")})}),H=Bs(s=>{if(s===""||s===void 0||s===null)return;const n=typeof s=="string"?parseInt(s,10):s;return Number.isNaN(n)?void 0:n},ns().int().optional()),Za=ue({name:M().min(1,"Name is required"),number:M().min(1,"Account number is required"),isBusiness:nn().default(!1).optional(),type:Es(Object.values(pe),"Account type is required"),currencies:me(Qa),bankNumber:H,branchNumber:H,iban:Bs(s=>s===""?void 0:s,M().optional()),extendedBankNumber:H,partyPreferredIndication:H,partyAccountInvolvementCode:H,accountDealDate:H,accountUpdateDate:H,metegDoarNet:H,kodHarshaatPeilut:H,accountClosingReasonCode:H,accountAgreementOpeningDate:H,serviceAuthorizationDesc:M().optional(),branchTypeCode:H,mymailEntitlementSwitch:H,productLabel:M().optional()}),et=v.forwardRef(function({ownerId:n,onDone:a},t){const[c,o]=v.useState(!1),[i,l]=v.useState(null),{createFinancialAccount:x,creating:d}=Ya(),{updateFinancialAccount:m,updating:h}=Ja(),u=Pe({resolver:Qe(Za),defaultValues:{name:"",number:"",isBusiness:!1,type:pe.BankAccount,currencies:[],bankNumber:void 0,branchNumber:void 0,iban:void 0,extendedBankNumber:void 0,partyPreferredIndication:void 0,partyAccountInvolvementCode:void 0,accountDealDate:void 0,accountUpdateDate:void 0,metegDoarNet:void 0,kodHarshaatPeilut:void 0,accountClosingReasonCode:void 0,accountAgreementOpeningDate:void 0,serviceAuthorizationDesc:void 0,branchTypeCode:void 0,mymailEntitlementSwitch:void 0,productLabel:void 0},mode:"onBlur"}),{control:p,handleSubmit:I,watch:k,reset:B}=u,_=r=>{r?(l(r),B(r)):(l(null),B()),o(!0)};v.useImperativeHandle(t,()=>({open:_}));const O=Ce({control:p,name:"currencies"}),V=()=>{o(!1),l(null),B()},$=async r=>{try{const L=r.isBusiness?$e.Business:$e.Private,U=r.type===pe.BankAccount&&r.bankNumber!==void 0&&r.branchNumber!==void 0?{bankNumber:r.bankNumber,branchNumber:r.branchNumber,...r.iban!==void 0&&{iban:r.iban},...r.extendedBankNumber!==void 0&&{extendedBankNumber:r.extendedBankNumber},...r.partyPreferredIndication!==void 0&&{partyPreferredIndication:r.partyPreferredIndication},...r.partyAccountInvolvementCode!==void 0&&{partyAccountInvolvementCode:r.partyAccountInvolvementCode},...r.accountDealDate!==void 0&&{accountDealDate:r.accountDealDate},...r.accountUpdateDate!==void 0&&{accountUpdateDate:r.accountUpdateDate},...r.metegDoarNet!==void 0&&{metegDoarNet:r.metegDoarNet},...r.kodHarshaatPeilut!==void 0&&{kodHarshaatPeilut:r.kodHarshaatPeilut},...r.accountClosingReasonCode!==void 0&&{accountClosingReasonCode:r.accountClosingReasonCode},...r.accountAgreementOpeningDate!==void 0&&{accountAgreementOpeningDate:r.accountAgreementOpeningDate},...r.serviceAuthorizationDesc!==void 0&&{serviceAuthorizationDesc:r.serviceAuthorizationDesc},...r.branchTypeCode!==void 0&&{branchTypeCode:r.branchTypeCode},...r.mymailEntitlementSwitch!==void 0&&{mymailEntitlementSwitch:r.mymailEntitlementSwitch},...r.productLabel!==void 0&&{productLabel:r.productLabel}}:void 0;i?await m({financialAccountId:i.id,fields:{name:r.name,number:r.number,type:r.type,privateOrBusiness:L,bankAccountDetails:U}}):await x({input:{name:r.name,number:r.number,ownerId:n,type:r.type,privateOrBusiness:L,bankAccountDetails:U}}),V(),a?.()}catch{}},R=()=>{O.append({currency:Ps.Usd,taxCategory:{id:"",name:""}})},W=r=>{O.remove(r)};return e.jsx(Se,{open:c,onOpenChange:o,children:e.jsxs(Te,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(as,{children:[e.jsx(ts,{children:i?"Edit Account":"New Account"}),e.jsx(is,{children:i?"Update account details and settings":"Add a new financial account"})]}),e.jsx(Oe,{...u,children:e.jsxs("form",{onSubmit:I($),className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Basic Information"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(j,{control:p,name:"name",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Name *"}),e.jsx(y,{children:e.jsx(C,{...r})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"number",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Account Number *"}),e.jsx(y,{children:e.jsx(C,{...r})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"type",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Account Type *"}),e.jsxs(Is,{value:r.value,onValueChange:r.onChange,children:[e.jsx(ws,{id:"type",children:e.jsx(Ds,{})}),e.jsx(ks,{children:Object.values(pe).map(L=>e.jsx(Ss,{value:L,children:_s(L)},L))})]}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"isBusiness",render:({field:r})=>e.jsxs(g,{className:"flex items-center space-x-2",children:[e.jsx(y,{children:e.jsx(ce,{id:"isBusiness",checked:r.value,onCheckedChange:r.onChange})}),e.jsx(f,{children:"Business Account"})]})})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Currencies & Tax Categories"}),e.jsxs(T,{type:"button",variant:"outline",size:"sm",onClick:R,"aria-label":"Add currency row",children:[e.jsx(ae,{className:"h-4 w-4 mr-2","aria-hidden":"true"}),"Add Currency"]})]}),e.jsx("div",{className:"space-y-3",children:O.fields.map((r,L)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsxs("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[e.jsx(j,{control:p,name:`currencies.${L}.currency`,render:({field:U})=>e.jsxs(g,{children:[e.jsx(y,{children:e.jsx(C,{placeholder:"Currency (e.g., ILS, USD)",...U})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:`currencies.${L}.taxCategory.id`,render:({field:U})=>e.jsxs(g,{children:[e.jsx(y,{children:e.jsx(C,{placeholder:"Tax Category ID",...U})}),e.jsx(b,{})]})})]}),e.jsx(T,{type:"button",variant:"ghost",size:"icon",onClick:()=>W(L),"aria-label":`Remove currency ${k(`currencies.${L}.currency`)||""}`,children:e.jsx(te,{className:"h-4 w-4","aria-hidden":"true"})})]},r.id))})]}),k("type")===pe.BankAccount&&e.jsxs("div",{className:"space-y-4 border-t pt-4",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Bank-Specific Details"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[e.jsx(j,{control:p,name:"bankNumber",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Bank Number"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"branchNumber",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Branch Number"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"iban",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"IBAN"}),e.jsx(y,{children:e.jsx(C,{value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"extendedBankNumber",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Extended Bank Number"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"partyPreferredIndication",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Party Preferred Indication"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"partyAccountInvolvementCode",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Party Account Involvement Code"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"accountDealDate",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Account Deal Date"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",placeholder:"YYYYMMDD",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"accountUpdateDate",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Account Update Date"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",placeholder:"YYYYMMDD",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"metegDoarNet",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Meteg Dora Net"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"kodHarshaatPeilut",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Kod Harshaot Peilut"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"accountClosingReasonCode",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Account Closing Reason Code"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"accountAgreementOpeningDate",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Account Agreement Opening Date"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",placeholder:"YYYYMMDD",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"branchTypeCode",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Branch Type Code"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"mymailEntitlementSwitch",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Mymail Entitlement Switch"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"serviceAuthorizationDesc",render:({field:r})=>e.jsxs(g,{className:"space-y-2 md:col-span-2",children:[e.jsx(f,{children:"Service Authorization Description"}),e.jsx(y,{children:e.jsx(C,{...r})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"productLabel",render:({field:r})=>e.jsxs(g,{className:"space-y-2 md:col-span-2 lg:col-span-3",children:[e.jsx(f,{children:"Product Label"}),e.jsx(y,{children:e.jsx(C,{...r})}),e.jsx(b,{})]})})]})]}),e.jsxs(Ts,{children:[e.jsx(T,{type:"button",variant:"outline",onClick:V,children:"Cancel"}),e.jsx(T,{type:"submit",disabled:d||h,children:i?h?"Updating…":"Update Account":d?"Creating…":"Create Account"})]})]})})]})})});function st(s){return{id:s.id,name:s.name,number:s.number,isBusiness:s.privateOrBusiness===$e.Business,type:s.type,currencies:s.accountTaxCategories.map(n=>({currency:n.currency,taxCategory:{id:n.taxCategory.id,name:n.taxCategory.name}})),...s.__typename==="BankFinancialAccount"?{bankNumber:s.bankNumber,branchNumber:s.branchNumber,iban:s.iban??void 0,extendedBankNumber:s.extendedBankNumber??void 0,partyPreferredIndication:s.partyPreferredIndication??void 0,partyAccountInvolvementCode:s.partyAccountInvolvementCode??void 0,accountDealDate:s.accountDealDate??void 0,accountUpdateDate:s.accountUpdateDate??void 0,metegDoarNet:s.metegDoarNet??void 0,kodHarshaatPeilut:s.kodHarshaatPeilut??void 0,accountClosingReasonCode:s.accountClosingReasonCode??void 0,accountAgreementOpeningDate:s.accountAgreementOpeningDate??void 0,serviceAuthorizationDesc:s.serviceAuthorizationDesc??void 0,branchTypeCode:s.branchTypeCode??void 0,mymailEntitlementSwitch:s.mymailEntitlementSwitch??void 0,productLabel:s.productLabel??void 0}:{}}}function nt({adminId:s}){const[n,a]=v.useState([]),[{data:t,fetching:c},o]=re({query:tn,variables:{adminId:s}});v.useEffect(()=>{t?.financialAccountsByOwner&&a(t.financialAccountsByOwner?.map(st)??[])},[t]);const i=v.useRef(null),l=x=>{i.current?.open(x)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-semibold tracking-tight",children:"Financial Accounts"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage bank accounts, credit cards, and crypto wallets"})]}),e.jsxs(T,{onClick:()=>l(),"aria-label":"Create new financial account",children:[e.jsx(ae,{className:"h-4 w-4 mr-2","aria-hidden":"true"}),"New Account"]})]}),c?e.jsx("p",{children:"Loading..."}):e.jsxs("div",{className:"grid gap-4",children:[n.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"No financial accounts added yet."}),n.map(x=>e.jsx(Wa,{account:x,handleOpenModal:l},x.id))]}),e.jsx(et,{ownerId:s,ref:i,onDone:()=>o()})]})}function at({businessId:s}){return e.jsxs(X,{children:[e.jsxs(J,{className:"flex w-full justify-between items-center",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(Q,{children:"Balance"}),e.jsx(Z,{children:"Business balance overview"})]})}),e.jsx(he,{to:As.BUSINESSES.DETAIL_LEDGER(s),children:e.jsx(T,{variant:"outline",size:"icon",children:e.jsx(La,{})})})]}),e.jsx(ee,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Yn,{businessID:s,filter:{}})})})]})}function tt({businessId:s}){const{userContext:n}=v.useContext(rs),[a,t]=v.useState(0),[{data:c,fetching:o}]=re({query:rn,variables:{filters:{byOwners:n?.context.adminBusinessId?[n.context.adminBusinessId]:void 0,sortBy:{field:ln.Date,asc:!1},byBusinesses:[s]},page:a,limit:10}}),i=c?.allCharges?.pageInfo.totalPages??1,l=c?.allCharges?.nodes??[];return o?e.jsx("div",{children:"Loading charges..."}):e.jsxs(X,{children:[e.jsxs(J,{className:"flex w-full justify-between items-center",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(Q,{children:"Charges"}),e.jsx(Z,{children:"Recurring and one-time charges for this business"})]})}),i>1&&e.jsx(cn,{className:"flex-fit w-fit mx-0",currentPageIndex:a,onChange:t,totalPages:i})]}),e.jsx(ee,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Jn,{data:l,isAllOpened:!1})})})]})}var it=["type","layout","connectNulls","ref"],rt=["key"];function je(s){"@babel/helpers - typeof";return je=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},je(s)}function gs(s,n){if(s==null)return{};var a=ct(s,n),t,c;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(s);for(c=0;c<o.length;c++)t=o[c],!(n.indexOf(t)>=0)&&Object.prototype.propertyIsEnumerable.call(s,t)&&(a[t]=s[t])}return a}function ct(s,n){if(s==null)return{};var a={};for(var t in s)if(Object.prototype.hasOwnProperty.call(s,t)){if(n.indexOf(t)>=0)continue;a[t]=s[t]}return a}function Ie(){return Ie=Object.assign?Object.assign.bind():function(s){for(var n=1;n<arguments.length;n++){var a=arguments[n];for(var t in a)Object.prototype.hasOwnProperty.call(a,t)&&(s[t]=a[t])}return s},Ie.apply(this,arguments)}function fs(s,n){var a=Object.keys(s);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(s);n&&(t=t.filter(function(c){return Object.getOwnPropertyDescriptor(s,c).enumerable})),a.push.apply(a,t)}return a}function G(s){for(var n=1;n<arguments.length;n++){var a=arguments[n]!=null?arguments[n]:{};n%2?fs(Object(a),!0).forEach(function(t){ne(s,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(a)):fs(Object(a)).forEach(function(t){Object.defineProperty(s,t,Object.getOwnPropertyDescriptor(a,t))})}return s}function xe(s){return mt(s)||dt(s)||ot(s)||lt()}function lt(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
1
+ import{v as oe,w as Xe,u as re,S as Ws,r as v,j as e,D as Se,x as Te,y as Ks,c as Je,z as Ys,g as Be,t as Y,i as Ee,U as Xs,E as Pe,G as Qe,H as Ce,J as X,K as J,N as Cs,O as Q,Q as Z,V as Oe,W as ee,X as le,Y as j,Z as g,_ as f,$ as y,I as C,a0 as S,a1 as b,a2 as Ae,B as T,a3 as ae,a4 as te,a5 as Ze,a6 as fe,a7 as Js,a8 as es,a9 as ss,aa as ue,ab as me,ac as ns,ad as Qs,ae as M,af as ie,ag as Zs,ah as he,R as As,ai as pe,aj as en,ak as sn,al as as,am as ts,an as is,ao as Is,ap as ws,aq as Ds,ar as ks,as as Ss,at as ce,au as Ts,av as Bs,aw as Es,ax as nn,ay as Ps,az as $e,aA as an,aB as tn,aC as rs,aD as rn,P as cn,aE as ln,aF as q,aG as ls,aH as Fe,aI as on,aJ as dn,aK as mn,aL as Os,aM as un,aN as xn,aO as hn,aP as pn,aQ as jn,aR as Ls,aS as gn,aT as P,aU as Ue,aV as Fs,aW as qe,aX as os,aY as fn,aZ as Ms,a_ as vn,a$ as yn,b0 as Nn,b1 as de,b2 as bn,b3 as Cn,b4 as An,b5 as He,b6 as In,b7 as wn,b8 as Dn,b9 as kn,ba as Sn,bb as ds,bc as Tn,bd as Bn,be as En,bf as Pn,bg as ms,bh as On,bi as Ln,bj as Fn,bk as Mn,F as _n,bl as Rn,bm as zn,bn as se,bo as Vn,bp as $n,bq as Un,br as K,bs as qn,a as Hn,b as Gn,bt as Wn}from"./index-rI994S3C.js";import{S as cs}from"./save-jkuyCWyY.js";import{g as Kn,a as _s}from"./similar-transactions-modal-DX3CPrMo.js";import{B as Yn}from"./business-extended-info-B94y5ZK6.js";import{B as Xn}from"./business-header-BC86M-9m.js";import{C as Jn,L as Qn}from"./charges-table-BJtpvXfL.js";import{i as Zn,D as ea,f as sa,E as na,L as Me,a as we,C as aa,A as ta,b as ve,c as ia,d as Ge,h as ra,e as ca,g as Rs,u as la,G as oa,j as us,k as da,X as zs,Y as Vs,l as ma,m as ua,R as xa,n as ha,o as pa,p as ja,q as ga}from"./download-csv-BSGaUZsM.js";import{M as We,s as fa,a as va}from"./modify-contract-dialog-flMl2p_T.js";import{u as ya,E as Na}from"./use-issue-monthly-documents-D9vQpbaZ.js";import{s as ba}from"./subMonths-DY4HlBVa.js";import{E as Ca,T as Aa}from"./index-C7p19nIa.js";import{A as Ia,a as _e,b as xs,c as hs}from"./accordion-Bn08_4fN.js";import{B as wa}from"./building-2-CMKd_bU8.js";import"./data-table-column-header-CZ1dXiU0.js";import"./eye-off-Buv7eciz.js";import"./download-csv-button-CMQBUQeX.js";import"./toggle-expansion-button-Y2eS7nqg.js";import"./panel-top-open-Bf39HBrp.js";import"./update-accountant-status-zL6vnwU9.js";import"./Table-BQv3frL8.js";import"./summary-CPKS_69D.js";import"./deposits-transactions-table-2rtRFZgK.js";import"./Checkbox-Dmuz3t7B.js";import"./sequential-CjOfRLtc.js";import"./addDays-DTiBTTns.js";const Da=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],ka=oe("chart-line",Da);const Sa=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Re=oe("circle-check",Sa);const Ta=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]],ps=oe("circle-slash",Ta);const Ba=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],De=oe("dollar-sign",Ba);const Ea=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m9 15 2 2 4-4",key:"1grp1n"}]],Pa=oe("file-check",Ea);const Oa=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["rect",{width:"10",height:"8",x:"7",y:"8",rx:"1",key:"vys8me"}]],La=oe("fullscreen",Oa);const Fa=[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M16 2v20",key:"rotuqe"}]],Ma=oe("notebook",Fa);const _a=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]],Ra=oe("plug",_a);function za(s){return Xe(s,"yyyy-MM-dd")}function Va({businessId:s,tagIds:n,description:a,open:t,onOpenChange:c,onClose:o}){const[{data:i,fetching:l},x]=re({pause:!0,query:Ws,variables:{businessId:s,tagsDifferentThan:n?n.map(h=>h.id):void 0,descriptionDifferentThan:a}});v.useEffect(()=>{t&&(n||a)&&!i&&x()},[t,n,a,x,i]);const d=v.useCallback(h=>{c(h),t&&!h&&o?.()},[c,o,t]),m=v.useMemo(()=>t&&(!!n||!!a)&&i&&i?.similarChargesByBusiness.length>0,[t,n,a,i]);return e.jsx(Se,{open:m,onOpenChange:d,children:e.jsx(Te,{className:"overflow-scroll max-h-screen w-full sm:max-w-[640px] md:max-w-[768px] lg:max-w-[900px]",onClick:h=>h.stopPropagation(),children:e.jsx(Ks,{fallback:e.jsx("div",{children:"Error fetching similar charges"}),children:l?e.jsx(Je,{}):n||a?e.jsx(Ys,{data:i?.similarChargesByBusiness??[],tagIds:n,description:a,onOpenChange:d,title:"Similar Charges by Business"}):null})})})}const $a="updateAdminBusiness",Ua=()=>{const[{fetching:s},n]=Be(Xs),a=v.useCallback(async t=>{const c=`Error updating admin business ID [${t.adminBusinessId}]`,o=`${$a}-${t.adminBusinessId}`;Y.loading("Updating admin business",{id:o});try{const i=await n(t),l=Ee(i,c,o,"updateAdminBusiness");if(l)return Y.success("Success",{id:o,description:"Admin Business Updated"}),l.updateAdminBusiness}catch(i){console.error(`${c}: ${i}`),Y.error("Error",{id:o,description:c,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,updateAdminBusiness:a}},ze=ue({year:ns().min(2e3).max(2100),id:M().min(1,{message:"ID is required"})}),qa=ue({registrationDate:M().min(1,{message:"Business Registration Start Date is required"}),withholdingTaxAnnualIds:me(ze),withholdingTaxCompanyId:M().min(1,{message:"Withholding Tax Company ID is required"}),socialSecurityEmployerIds:me(ze),socialSecurityDeductionsId:M().min(1,{message:"Social Security Deductions ID is required"}),taxAdvancesAnnualIds:me(ze),taxAdvancesRates:me(ue({date:Qs(),rate:ns().min(0,{message:"Rate must be at least 0"}).max(100,{message:"Rate must be at most 100"})}))}),ye={WITHHOLDING_TAX:"https://secapp.taxes.gov.il/NikPay/StartPage.aspx#/Home",TAX_ADVANCES:"https://secapp.taxes.gov.il/gmftashmh/main/entrance",SOCIAL_SECURITY:"https://b2b.btl.gov.il/BTL.ILG.Payments/ChovDochMaasikInfo.aspx",VAT:"https://secapp.taxes.gov.il/emdvhmfrt/wLogOnMenu.aspx"},Ne=({href:s,children:n})=>e.jsxs("h3",{className:"flex flex-row gap-2 text-sm font-semibold text-foreground md:col-span-2",children:[e.jsx("a",{href:s,target:"_blank",rel:"noreferrer",onClick:a=>a.stopPropagation(),className:"inline-flex items-center font-semibold",children:e.jsx(es,{size:12})}),e.jsx("span",{children:n})]});function js(s){return!s||s.__typename!=="LtdFinancialEntity"||!s.adminInfo?{}:{registrationDate:s.adminInfo.registrationDate,withholdingTaxAnnualIds:s.adminInfo.withholdingTaxAnnualIds.sort((n,a)=>a.year-n.year),withholdingTaxCompanyId:s.adminInfo.withholdingTaxCompanyId??void 0,socialSecurityEmployerIds:s.adminInfo.socialSecurityEmployerIds.sort((n,a)=>a.year-n.year),socialSecurityDeductionsId:s.adminInfo.socialSecurityDeductionsId??void 0,taxAdvancesAnnualIds:s.adminInfo.taxAdvancesAnnualIds.sort((n,a)=>a.year-n.year),taxAdvancesRates:s.adminInfo.taxAdvancesRates?.map(n=>({date:n.date,rate:n.rate*100}))}}function Ha(s){return{registrationDate:s.registrationDate?za(new Date(s.registrationDate)):void 0,withholdingTaxAnnualIds:s.withholdingTaxAnnualIds,withholdingTaxCompanyId:s.withholdingTaxCompanyId,socialSecurityEmployerIds:s.socialSecurityEmployerIds,taxAdvancesRates:s.taxAdvancesRates?.map(n=>({date:n.date,rate:n.rate/100})),taxAdvancesAnnualIds:s.taxAdvancesAnnualIds}}function Ga({data:s,refetchBusiness:n}){const a=fe(Js,s),[t,c]=v.useState(js(a)),{updateAdminBusiness:o,fetching:i}=Ua(),l=Pe({resolver:Qe(qa),defaultValues:t}),x=async w=>{if(!a)return;const D=ss(w,l.formState.dirtyFields);if(!D)return;const z=Ha(D);await o({adminBusinessId:a.id,fields:z}),n?.()};v.useEffect(()=>{if(a){const w=js(a);c(w),l.reset(w)}},[a,l]);const{fields:d,append:m,remove:h}=Ce({control:l.control,name:"taxAdvancesAnnualIds"}),{fields:u,append:p,remove:I}=Ce({control:l.control,name:"withholdingTaxAnnualIds"}),{fields:k,append:B,remove:_}=Ce({control:l.control,name:"socialSecurityEmployerIds"}),O={withholdingTaxAnnualIds:{append:p,remove:I},taxAdvancesAnnualIds:{append:m,remove:h},socialSecurityEmployerIds:{append:B,remove:_}},V=w=>{O[w].append({year:new Date().getFullYear(),id:""})},$=(w,D)=>{O[w].remove(D)},{fields:R,append:W,remove:r}=Ce({control:l.control,name:"taxAdvancesRates"}),L=()=>{W({date:Xe(new Date,"yyyy-MM-dd"),rate:0})},U=w=>{r(w)};return e.jsxs(X,{children:[e.jsxs(J,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Cs,{className:"h-5 w-5 text-primary"}),e.jsx(Q,{children:"Admin Business Configuration"})]}),e.jsx(Z,{children:"Tax and registration information for the business operating this application"})]}),e.jsx(Oe,{...l,children:e.jsxs("form",{onSubmit:l.handleSubmit(x),className:"space-y-6",children:[e.jsx(ee,{children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx(Ne,{href:ye.VAT,children:"VAT"}),e.jsx(le,{className:"md:col-span-2"}),e.jsx(Ne,{href:ye.TAX_ADVANCES,children:"Tax Advances"}),e.jsx(le,{className:"md:col-span-2"}),e.jsx(Ne,{href:ye.WITHHOLDING_TAX,children:"Withholding Tax"}),e.jsx(j,{control:l.control,name:"withholdingTaxCompanyId",render:({field:w,fieldState:D})=>e.jsxs(g,{children:[e.jsx(f,{children:"Company Tax ID"}),e.jsx(y,{children:e.jsx(C,{placeholder:"Enter company ID",...w,className:S(D)})}),e.jsx(b,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ae,{children:"Annual IDs"}),e.jsx(T,{type:"button",variant:"outline",size:"sm",onClick:()=>V("withholdingTaxAnnualIds"),children:e.jsx(ae,{className:"size-4"})})]}),e.jsx("div",{className:"space-y-3",children:u.map((w,D)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsxs("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[e.jsx(C,{placeholder:"Year",type:"number",...l.register(`withholdingTaxAnnualIds.${D}.year`,{valueAsNumber:!0})}),e.jsx(C,{placeholder:"ID",...l.register(`withholdingTaxAnnualIds.${D}.id`)})]}),e.jsx(T,{type:"button",variant:"ghost",size:"icon",onClick:()=>$("withholdingTaxAnnualIds",D),children:e.jsx(te,{className:"size-4"})})]},w.id))})]}),e.jsx(le,{className:"md:col-span-2"}),e.jsx(Ne,{href:ye.TAX_ADVANCES,children:"Tax Advances"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ae,{children:"Annual IDs"}),e.jsx(T,{type:"button",variant:"outline",size:"sm",onClick:()=>V("taxAdvancesAnnualIds"),children:e.jsx(ae,{className:"size-4"})})]}),e.jsx("div",{className:"space-y-3",children:d.map((w,D)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsxs("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[e.jsx(C,{placeholder:"Year",type:"number",...l.register(`taxAdvancesAnnualIds.${D}.year`,{valueAsNumber:!0})}),e.jsx(C,{placeholder:"ID",...l.register(`taxAdvancesAnnualIds.${D}.id`)})]}),e.jsx(T,{type:"button",variant:"ghost",size:"icon",onClick:()=>$("taxAdvancesAnnualIds",D),children:e.jsx(te,{className:"size-4"})})]},w.id))})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ae,{children:"Rates (%)"}),e.jsx(T,{type:"button",variant:"outline",size:"sm",onClick:L,children:e.jsx(ae,{className:"size-4"})})]}),e.jsx("div",{className:"space-y-3",children:R.map((w,D)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsxs("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[e.jsx(C,{placeholder:"Date",type:"date",...l.register(`taxAdvancesRates.${D}.date`)}),e.jsx(C,{placeholder:"Rate",...l.register(`taxAdvancesRates.${D}.rate`,{valueAsNumber:!0})})]}),e.jsx(T,{type:"button",variant:"ghost",size:"icon",onClick:()=>U(D),children:e.jsx(te,{className:"size-4"})})]},w.id))})]}),e.jsx(le,{className:"md:col-span-2"}),e.jsx(Ne,{href:ye.SOCIAL_SECURITY,children:"Social Security"}),e.jsx(j,{control:l.control,name:"socialSecurityDeductionsId",render:({field:w,fieldState:D})=>e.jsxs(g,{children:[e.jsx(f,{children:"Deductions ID"}),e.jsx(y,{children:e.jsx(C,{placeholder:"Enter deductions ID",...w,className:S(D)})}),e.jsx(b,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ae,{children:"Annual Employer IDs"}),e.jsx(T,{type:"button",variant:"outline",size:"sm",onClick:()=>V("socialSecurityEmployerIds"),children:e.jsx(ae,{className:"size-4"})})]}),e.jsx("div",{className:"space-y-3",children:k.map((w,D)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsxs("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[e.jsx(C,{placeholder:"Year",type:"number",...l.register(`socialSecurityEmployerIds.${D}.year`,{valueAsNumber:!0})}),e.jsx(C,{placeholder:"ID",...l.register(`socialSecurityEmployerIds.${D}.id`)})]}),e.jsx(T,{type:"button",variant:"ghost",size:"icon",onClick:()=>$("socialSecurityEmployerIds",D),children:e.jsx(te,{className:"size-4"})})]},w.id))})]}),e.jsx(le,{className:"md:col-span-2"}),e.jsx(j,{control:l.control,name:"registrationDate",render:({field:w,fieldState:D})=>e.jsxs(g,{children:[e.jsx(f,{children:"Business Registration Start Date"}),e.jsx(y,{children:e.jsx(C,{type:"date",...w,className:S(D)})}),e.jsx(b,{})]})})]})}),e.jsx(Ze,{className:"flex justify-end border-t mt-4 pt-6",children:e.jsxs(T,{type:"submit",disabled:i||Object.keys(l.formState.dirtyFields).length===0||!l.formState.isValid,children:[e.jsx(cs,{className:"h-4 w-4"}),"Save Changes"]})})]})})]})}function Wa({account:s,handleOpenModal:n}){return e.jsxs(X,{children:[e.jsx(J,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-primary/10 text-primary",children:Kn(s.type)}),e.jsxs("div",{children:[e.jsxs(Q,{className:"text-lg",children:[s.name,s.name===s.number?"":` (${s.number})`]}),e.jsxs(Z,{className:"flex items-center gap-2 mt-1",children:[e.jsx(ie,{variant:"outline",children:_s(s.type)}),!s.isBusiness&&e.jsx(ie,{variant:"secondary",children:"Private"})]})]})]}),e.jsx("div",{className:"flex gap-1",children:e.jsx(T,{variant:"ghost",size:"sm",onClick:()=>n(s),"aria-label":`Edit account ${s.name}`,children:e.jsx(Zs,{className:"h-4 w-4","aria-hidden":"true"})})})]})}),e.jsxs(ee,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2",children:"Currencies & Tax Categories"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:s.currencies?.map(a=>e.jsx(he,{to:As.TAX_CATEGORIES,target:"_blank",rel:"noreferrer",onClick:t=>t.stopPropagation(),children:e.jsxs(ie,{variant:"secondary",className:"text-xs",children:[a.currency," → ",a.taxCategory.name]})},a.currency))})]}),s.type===pe.BankAccount&&e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("h4",{className:"text-sm font-medium mb-3",children:"Bank Details"}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Bank Number:"}),e.jsx("p",{className:"font-medium",children:s.bankNumber})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Branch Number:"}),e.jsx("p",{className:"font-medium",children:s.branchNumber})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Extended Bank Number:"}),e.jsx("p",{className:"font-medium",children:s.extendedBankNumber})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"IBAN:"}),e.jsx("p",{className:"font-medium",children:s.iban})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Party Preferred Indication:"}),e.jsx("p",{className:"font-medium",children:s.partyPreferredIndication})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Party Account Involvement:"}),e.jsx("p",{className:"font-medium",children:s.partyAccountInvolvementCode})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Account Deal Date:"}),e.jsx("p",{className:"font-medium",children:s.accountDealDate})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Account Update Date:"}),e.jsx("p",{className:"font-medium",children:s.accountUpdateDate})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Meteg Dora Net:"}),e.jsx("p",{className:"font-medium",children:s.metegDoarNet})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Kod Harshaot Peilut:"}),e.jsx("p",{className:"font-medium",children:s.kodHarshaatPeilut})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Closing Reason Code:"}),e.jsx("p",{className:"font-medium",children:s.accountClosingReasonCode})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Agreement Opening Date:"}),e.jsx("p",{className:"font-medium",children:s.accountAgreementOpeningDate})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Branch Type Code:"}),e.jsx("p",{className:"font-medium",children:s.branchTypeCode})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Mymail Entitlement:"}),e.jsx("p",{className:"font-medium",children:s.mymailEntitlementSwitch})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Service Authorization:"}),e.jsx("p",{className:"font-medium",children:s.serviceAuthorizationDesc})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Product Label:"}),e.jsx("p",{className:"font-medium",children:s.productLabel})]})]})]})]})]})}const Ka="createFinancialAccount",Ya=()=>{const[{fetching:s},n]=Be(en),a=v.useCallback(async t=>{const c=`Error creating new account "${t.input.name}"`,o=`${Ka}-${t.input.name}`;Y.loading("Creating account",{id:o});try{const i=await n(t);Ee(i,c,o)&&Y.success("Success",{id:o,description:`Financial Account ${t.input.name} was successfully created`})}catch(i){console.error(`${c}: ${i}`),Y.error("Error",{id:o,description:c,duration:1e5,closeButton:!0})}},[n]);return{creating:s,createFinancialAccount:a}},Xa="updateFinancialAccount",Ja=()=>{const[{fetching:s},n]=Be(sn),a=v.useCallback(async t=>{const c=`Error updating financial account ID [${t.financialAccountId}]`,o=`${Xa}-${t.financialAccountId}`;Y.loading("Updating financial account",{id:o});try{const i=await n(t),l=Ee(i,c,o,"updateFinancialAccount");if(l)return Y.success("Success",{id:o,description:"Financial account updated"}),l.updateFinancialAccount}catch(i){console.error(`${c}: ${i}`),Y.error("Error",{id:o,description:c,duration:1e5,closeButton:!0})}},[n]);return{updating:s,updateFinancialAccount:a}},Qa=ue({currency:Es(Object.values(Ps),"Currency is required"),taxCategory:ue({id:an("Tax category ID is required"),name:M().min(1,"Tax category name is required")})}),H=Bs(s=>{if(s===""||s===void 0||s===null)return;const n=typeof s=="string"?parseInt(s,10):s;return Number.isNaN(n)?void 0:n},ns().int().optional()),Za=ue({name:M().min(1,"Name is required"),number:M().min(1,"Account number is required"),isBusiness:nn().default(!1).optional(),type:Es(Object.values(pe),"Account type is required"),currencies:me(Qa),bankNumber:H,branchNumber:H,iban:Bs(s=>s===""?void 0:s,M().optional()),extendedBankNumber:H,partyPreferredIndication:H,partyAccountInvolvementCode:H,accountDealDate:H,accountUpdateDate:H,metegDoarNet:H,kodHarshaatPeilut:H,accountClosingReasonCode:H,accountAgreementOpeningDate:H,serviceAuthorizationDesc:M().optional(),branchTypeCode:H,mymailEntitlementSwitch:H,productLabel:M().optional()}),et=v.forwardRef(function({ownerId:n,onDone:a},t){const[c,o]=v.useState(!1),[i,l]=v.useState(null),{createFinancialAccount:x,creating:d}=Ya(),{updateFinancialAccount:m,updating:h}=Ja(),u=Pe({resolver:Qe(Za),defaultValues:{name:"",number:"",isBusiness:!1,type:pe.BankAccount,currencies:[],bankNumber:void 0,branchNumber:void 0,iban:void 0,extendedBankNumber:void 0,partyPreferredIndication:void 0,partyAccountInvolvementCode:void 0,accountDealDate:void 0,accountUpdateDate:void 0,metegDoarNet:void 0,kodHarshaatPeilut:void 0,accountClosingReasonCode:void 0,accountAgreementOpeningDate:void 0,serviceAuthorizationDesc:void 0,branchTypeCode:void 0,mymailEntitlementSwitch:void 0,productLabel:void 0},mode:"onBlur"}),{control:p,handleSubmit:I,watch:k,reset:B}=u,_=r=>{r?(l(r),B(r)):(l(null),B()),o(!0)};v.useImperativeHandle(t,()=>({open:_}));const O=Ce({control:p,name:"currencies"}),V=()=>{o(!1),l(null),B()},$=async r=>{try{const L=r.isBusiness?$e.Business:$e.Private,U=r.type===pe.BankAccount&&r.bankNumber!==void 0&&r.branchNumber!==void 0?{bankNumber:r.bankNumber,branchNumber:r.branchNumber,...r.iban!==void 0&&{iban:r.iban},...r.extendedBankNumber!==void 0&&{extendedBankNumber:r.extendedBankNumber},...r.partyPreferredIndication!==void 0&&{partyPreferredIndication:r.partyPreferredIndication},...r.partyAccountInvolvementCode!==void 0&&{partyAccountInvolvementCode:r.partyAccountInvolvementCode},...r.accountDealDate!==void 0&&{accountDealDate:r.accountDealDate},...r.accountUpdateDate!==void 0&&{accountUpdateDate:r.accountUpdateDate},...r.metegDoarNet!==void 0&&{metegDoarNet:r.metegDoarNet},...r.kodHarshaatPeilut!==void 0&&{kodHarshaatPeilut:r.kodHarshaatPeilut},...r.accountClosingReasonCode!==void 0&&{accountClosingReasonCode:r.accountClosingReasonCode},...r.accountAgreementOpeningDate!==void 0&&{accountAgreementOpeningDate:r.accountAgreementOpeningDate},...r.serviceAuthorizationDesc!==void 0&&{serviceAuthorizationDesc:r.serviceAuthorizationDesc},...r.branchTypeCode!==void 0&&{branchTypeCode:r.branchTypeCode},...r.mymailEntitlementSwitch!==void 0&&{mymailEntitlementSwitch:r.mymailEntitlementSwitch},...r.productLabel!==void 0&&{productLabel:r.productLabel}}:void 0;i?await m({financialAccountId:i.id,fields:{name:r.name,number:r.number,type:r.type,privateOrBusiness:L,bankAccountDetails:U}}):await x({input:{name:r.name,number:r.number,ownerId:n,type:r.type,privateOrBusiness:L,bankAccountDetails:U}}),V(),a?.()}catch{}},R=()=>{O.append({currency:Ps.Usd,taxCategory:{id:"",name:""}})},W=r=>{O.remove(r)};return e.jsx(Se,{open:c,onOpenChange:o,children:e.jsxs(Te,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(as,{children:[e.jsx(ts,{children:i?"Edit Account":"New Account"}),e.jsx(is,{children:i?"Update account details and settings":"Add a new financial account"})]}),e.jsx(Oe,{...u,children:e.jsxs("form",{onSubmit:I($),className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Basic Information"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(j,{control:p,name:"name",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Name *"}),e.jsx(y,{children:e.jsx(C,{...r})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"number",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Account Number *"}),e.jsx(y,{children:e.jsx(C,{...r})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"type",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Account Type *"}),e.jsxs(Is,{value:r.value,onValueChange:r.onChange,children:[e.jsx(ws,{id:"type",children:e.jsx(Ds,{})}),e.jsx(ks,{children:Object.values(pe).map(L=>e.jsx(Ss,{value:L,children:_s(L)},L))})]}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"isBusiness",render:({field:r})=>e.jsxs(g,{className:"flex items-center space-x-2",children:[e.jsx(y,{children:e.jsx(ce,{id:"isBusiness",checked:r.value,onCheckedChange:r.onChange})}),e.jsx(f,{children:"Business Account"})]})})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Currencies & Tax Categories"}),e.jsxs(T,{type:"button",variant:"outline",size:"sm",onClick:R,"aria-label":"Add currency row",children:[e.jsx(ae,{className:"h-4 w-4 mr-2","aria-hidden":"true"}),"Add Currency"]})]}),e.jsx("div",{className:"space-y-3",children:O.fields.map((r,L)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsxs("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[e.jsx(j,{control:p,name:`currencies.${L}.currency`,render:({field:U})=>e.jsxs(g,{children:[e.jsx(y,{children:e.jsx(C,{placeholder:"Currency (e.g., ILS, USD)",...U})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:`currencies.${L}.taxCategory.id`,render:({field:U})=>e.jsxs(g,{children:[e.jsx(y,{children:e.jsx(C,{placeholder:"Tax Category ID",...U})}),e.jsx(b,{})]})})]}),e.jsx(T,{type:"button",variant:"ghost",size:"icon",onClick:()=>W(L),"aria-label":`Remove currency ${k(`currencies.${L}.currency`)||""}`,children:e.jsx(te,{className:"h-4 w-4","aria-hidden":"true"})})]},r.id))})]}),k("type")===pe.BankAccount&&e.jsxs("div",{className:"space-y-4 border-t pt-4",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Bank-Specific Details"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[e.jsx(j,{control:p,name:"bankNumber",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Bank Number"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"branchNumber",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Branch Number"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"iban",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"IBAN"}),e.jsx(y,{children:e.jsx(C,{value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"extendedBankNumber",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Extended Bank Number"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"partyPreferredIndication",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Party Preferred Indication"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"partyAccountInvolvementCode",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Party Account Involvement Code"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"accountDealDate",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Account Deal Date"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",placeholder:"YYYYMMDD",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"accountUpdateDate",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Account Update Date"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",placeholder:"YYYYMMDD",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"metegDoarNet",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Meteg Dora Net"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"kodHarshaatPeilut",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Kod Harshaot Peilut"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"accountClosingReasonCode",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Account Closing Reason Code"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"accountAgreementOpeningDate",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Account Agreement Opening Date"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",placeholder:"YYYYMMDD",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"branchTypeCode",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Branch Type Code"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"mymailEntitlementSwitch",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Mymail Entitlement Switch"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"serviceAuthorizationDesc",render:({field:r})=>e.jsxs(g,{className:"space-y-2 md:col-span-2",children:[e.jsx(f,{children:"Service Authorization Description"}),e.jsx(y,{children:e.jsx(C,{...r})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"productLabel",render:({field:r})=>e.jsxs(g,{className:"space-y-2 md:col-span-2 lg:col-span-3",children:[e.jsx(f,{children:"Product Label"}),e.jsx(y,{children:e.jsx(C,{...r})}),e.jsx(b,{})]})})]})]}),e.jsxs(Ts,{children:[e.jsx(T,{type:"button",variant:"outline",onClick:V,children:"Cancel"}),e.jsx(T,{type:"submit",disabled:d||h,children:i?h?"Updating…":"Update Account":d?"Creating…":"Create Account"})]})]})})]})})});function st(s){return{id:s.id,name:s.name,number:s.number,isBusiness:s.privateOrBusiness===$e.Business,type:s.type,currencies:s.accountTaxCategories.map(n=>({currency:n.currency,taxCategory:{id:n.taxCategory.id,name:n.taxCategory.name}})),...s.__typename==="BankFinancialAccount"?{bankNumber:s.bankNumber,branchNumber:s.branchNumber,iban:s.iban??void 0,extendedBankNumber:s.extendedBankNumber??void 0,partyPreferredIndication:s.partyPreferredIndication??void 0,partyAccountInvolvementCode:s.partyAccountInvolvementCode??void 0,accountDealDate:s.accountDealDate??void 0,accountUpdateDate:s.accountUpdateDate??void 0,metegDoarNet:s.metegDoarNet??void 0,kodHarshaatPeilut:s.kodHarshaatPeilut??void 0,accountClosingReasonCode:s.accountClosingReasonCode??void 0,accountAgreementOpeningDate:s.accountAgreementOpeningDate??void 0,serviceAuthorizationDesc:s.serviceAuthorizationDesc??void 0,branchTypeCode:s.branchTypeCode??void 0,mymailEntitlementSwitch:s.mymailEntitlementSwitch??void 0,productLabel:s.productLabel??void 0}:{}}}function nt({adminId:s}){const[n,a]=v.useState([]),[{data:t,fetching:c},o]=re({query:tn,variables:{adminId:s}});v.useEffect(()=>{t?.financialAccountsByOwner&&a(t.financialAccountsByOwner?.map(st)??[])},[t]);const i=v.useRef(null),l=x=>{i.current?.open(x)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-semibold tracking-tight",children:"Financial Accounts"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage bank accounts, credit cards, and crypto wallets"})]}),e.jsxs(T,{onClick:()=>l(),"aria-label":"Create new financial account",children:[e.jsx(ae,{className:"h-4 w-4 mr-2","aria-hidden":"true"}),"New Account"]})]}),c?e.jsx("p",{children:"Loading..."}):e.jsxs("div",{className:"grid gap-4",children:[n.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"No financial accounts added yet."}),n.map(x=>e.jsx(Wa,{account:x,handleOpenModal:l},x.id))]}),e.jsx(et,{ownerId:s,ref:i,onDone:()=>o()})]})}function at({businessId:s}){return e.jsxs(X,{children:[e.jsxs(J,{className:"flex w-full justify-between items-center",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(Q,{children:"Balance"}),e.jsx(Z,{children:"Business balance overview"})]})}),e.jsx(he,{to:As.BUSINESSES.DETAIL_LEDGER(s),children:e.jsx(T,{variant:"outline",size:"icon",children:e.jsx(La,{})})})]}),e.jsx(ee,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Yn,{businessID:s,filter:{}})})})]})}function tt({businessId:s}){const{userContext:n}=v.useContext(rs),[a,t]=v.useState(0),[{data:c,fetching:o}]=re({query:rn,variables:{filters:{byOwners:n?.context.adminBusinessId?[n.context.adminBusinessId]:void 0,sortBy:{field:ln.Date,asc:!1},byBusinesses:[s]},page:a,limit:10}}),i=c?.allCharges?.pageInfo.totalPages??1,l=c?.allCharges?.nodes??[];return o?e.jsx("div",{children:"Loading charges..."}):e.jsxs(X,{children:[e.jsxs(J,{className:"flex w-full justify-between items-center",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(Q,{children:"Charges"}),e.jsx(Z,{children:"Recurring and one-time charges for this business"})]})}),i>1&&e.jsx(cn,{className:"flex-fit w-fit mx-0",currentPageIndex:a,onChange:t,totalPages:i})]}),e.jsx(ee,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Jn,{data:l,isAllOpened:!1})})})]})}var it=["type","layout","connectNulls","ref"],rt=["key"];function je(s){"@babel/helpers - typeof";return je=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},je(s)}function gs(s,n){if(s==null)return{};var a=ct(s,n),t,c;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(s);for(c=0;c<o.length;c++)t=o[c],!(n.indexOf(t)>=0)&&Object.prototype.propertyIsEnumerable.call(s,t)&&(a[t]=s[t])}return a}function ct(s,n){if(s==null)return{};var a={};for(var t in s)if(Object.prototype.hasOwnProperty.call(s,t)){if(n.indexOf(t)>=0)continue;a[t]=s[t]}return a}function Ie(){return Ie=Object.assign?Object.assign.bind():function(s){for(var n=1;n<arguments.length;n++){var a=arguments[n];for(var t in a)Object.prototype.hasOwnProperty.call(a,t)&&(s[t]=a[t])}return s},Ie.apply(this,arguments)}function fs(s,n){var a=Object.keys(s);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(s);n&&(t=t.filter(function(c){return Object.getOwnPropertyDescriptor(s,c).enumerable})),a.push.apply(a,t)}return a}function G(s){for(var n=1;n<arguments.length;n++){var a=arguments[n]!=null?arguments[n]:{};n%2?fs(Object(a),!0).forEach(function(t){ne(s,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(a)):fs(Object(a)).forEach(function(t){Object.defineProperty(s,t,Object.getOwnPropertyDescriptor(a,t))})}return s}function xe(s){return mt(s)||dt(s)||ot(s)||lt()}function lt(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ot(s,n){if(s){if(typeof s=="string")return Ke(s,n);var a=Object.prototype.toString.call(s).slice(8,-1);if(a==="Object"&&s.constructor&&(a=s.constructor.name),a==="Map"||a==="Set")return Array.from(s);if(a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return Ke(s,n)}}function dt(s){if(typeof Symbol<"u"&&s[Symbol.iterator]!=null||s["@@iterator"]!=null)return Array.from(s)}function mt(s){if(Array.isArray(s))return Ke(s)}function Ke(s,n){(n==null||n>s.length)&&(n=s.length);for(var a=0,t=new Array(n);a<n;a++)t[a]=s[a];return t}function ut(s,n){if(!(s instanceof n))throw new TypeError("Cannot call a class as a function")}function vs(s,n){for(var a=0;a<n.length;a++){var t=n[a];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(s,Us(t.key),t)}}function xt(s,n,a){return n&&vs(s.prototype,n),a&&vs(s,a),Object.defineProperty(s,"prototype",{writable:!1}),s}function ht(s,n,a){return n=ke(n),pt(s,$s()?Reflect.construct(n,a||[],ke(s).constructor):n.apply(s,a))}function pt(s,n){if(n&&(je(n)==="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return jt(s)}function jt(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function $s(){try{var s=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return($s=function(){return!!s})()}function ke(s){return ke=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(a){return a.__proto__||Object.getPrototypeOf(a)},ke(s)}function gt(s,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");s.prototype=Object.create(n&&n.prototype,{constructor:{value:s,writable:!0,configurable:!0}}),Object.defineProperty(s,"prototype",{writable:!1}),n&&Ye(s,n)}function Ye(s,n){return Ye=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,c){return t.__proto__=c,t},Ye(s,n)}function ne(s,n,a){return n=Us(n),n in s?Object.defineProperty(s,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):s[n]=a,s}function Us(s){var n=ft(s,"string");return je(n)=="symbol"?n:n+""}function ft(s,n){if(je(s)!="object"||!s)return s;var a=s[Symbol.toPrimitive];if(a!==void 0){var t=a.call(s,n);if(je(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(s)}var ge=(function(s){function n(){var a;ut(this,n);for(var t=arguments.length,c=new Array(t),o=0;o<t;o++)c[o]=arguments[o];return a=ht(this,n,[].concat(c)),ne(a,"state",{isAnimationFinished:!0,totalLength:0}),ne(a,"generateSimpleStrokeDasharray",function(i,l){return"".concat(l,"px ").concat(i-l,"px")}),ne(a,"getStrokeDasharray",function(i,l,x){var d=x.reduce(function(_,O){return _+O});if(!d)return a.generateSimpleStrokeDasharray(l,i);for(var m=Math.floor(i/d),h=i%d,u=l-i,p=[],I=0,k=0;I<x.length;k+=x[I],++I)if(k+x[I]>h){p=[].concat(xe(x.slice(0,I)),[h-k]);break}var B=p.length%2===0?[0,u]:[u];return[].concat(xe(n.repeat(x,m)),xe(p),B).map(function(_){return"".concat(_,"px")}).join(", ")}),ne(a,"id",la("recharts-line-")),ne(a,"pathRef",function(i){a.mainCurve=i}),ne(a,"handleAnimationEnd",function(){a.setState({isAnimationFinished:!0}),a.props.onAnimationEnd&&a.props.onAnimationEnd()}),ne(a,"handleAnimationStart",function(){a.setState({isAnimationFinished:!1}),a.props.onAnimationStart&&a.props.onAnimationStart()}),a}return gt(n,s),xt(n,[{key:"componentDidMount",value:function(){if(this.props.isAnimationActive){var t=this.getTotalLength();this.setState({totalLength:t})}}},{key:"componentDidUpdate",value:function(){if(this.props.isAnimationActive){var t=this.getTotalLength();t!==this.state.totalLength&&this.setState({totalLength:t})}}},{key:"getTotalLength",value:function(){var t=this.mainCurve;try{return t&&t.getTotalLength&&t.getTotalLength()||0}catch{return 0}}},{key:"renderErrorBar",value:function(t,c){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var o=this.props,i=o.points,l=o.xAxis,x=o.yAxis,d=o.layout,m=o.children,h=sa(m,na);if(!h)return null;var u=function(k,B){return{x:k.x,y:k.y,value:k.value,errorVal:Rs(k.payload,B)}},p={clipPath:t?"url(#clipPath-".concat(c,")"):null};return q.createElement(Me,p,h.map(function(I){return q.cloneElement(I,{key:"bar-".concat(I.props.dataKey),data:i,xAxis:l,yAxis:x,layout:d,dataPointFormatter:u})}))}},{key:"renderDots",value:function(t,c,o){var i=this.props.isAnimationActive;if(i&&!this.state.isAnimationFinished)return null;var l=this.props,x=l.dot,d=l.points,m=l.dataKey,h=we(this.props,!1),u=we(x,!0),p=d.map(function(k,B){var _=G(G(G({key:"dot-".concat(B),r:3},h),u),{},{index:B,cx:k.x,cy:k.y,value:k.value,dataKey:m,payload:k.payload,points:d});return n.renderDotItem(x,_)}),I={clipPath:t?"url(#clipPath-".concat(c?"":"dots-").concat(o,")"):null};return q.createElement(Me,Ie({className:"recharts-line-dots",key:"dots"},I),p)}},{key:"renderCurveStatically",value:function(t,c,o,i){var l=this.props,x=l.type,d=l.layout,m=l.connectNulls;l.ref;var h=gs(l,it),u=G(G(G({},we(h,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:c?"url(#clipPath-".concat(o,")"):null,points:t},i),{},{type:x,layout:d,connectNulls:m});return q.createElement(aa,Ie({},u,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(t,c){var o=this,i=this.props,l=i.points,x=i.strokeDasharray,d=i.isAnimationActive,m=i.animationBegin,h=i.animationDuration,u=i.animationEasing,p=i.animationId,I=i.animateNewValues,k=i.width,B=i.height,_=this.state,O=_.prevPoints,V=_.totalLength;return q.createElement(ta,{begin:m,duration:h,isActive:d,easing:u,from:{t:0},to:{t:1},key:"line-".concat(p),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function($){var R=$.t;if(O){var W=O.length/l.length,r=l.map(function(z,N){var A=Math.floor(N*W);if(O[A]){var E=O[A],F=ve(E.x,z.x),Le=ve(E.y,z.y);return G(G({},z),{},{x:F(R),y:Le(R)})}if(I){var Hs=ve(k*2,z.x),Gs=ve(B/2,z.y);return G(G({},z),{},{x:Hs(R),y:Gs(R)})}return G(G({},z),{},{x:z.x,y:z.y})});return o.renderCurveStatically(r,t,c)}var L=ve(0,V),U=L(R),w;if(x){var D="".concat(x).split(/[,\s]+/gim).map(function(z){return parseFloat(z)});w=o.getStrokeDasharray(U,V,D)}else w=o.generateSimpleStrokeDasharray(V,U);return o.renderCurveStatically(l,t,c,{strokeDasharray:w})})}},{key:"renderCurve",value:function(t,c){var o=this.props,i=o.points,l=o.isAnimationActive,x=this.state,d=x.prevPoints,m=x.totalLength;return l&&i&&i.length&&(!d&&m>0||!ia(d,i))?this.renderCurveWithAnimation(t,c):this.renderCurveStatically(i,t,c)}},{key:"render",value:function(){var t,c=this.props,o=c.hide,i=c.dot,l=c.points,x=c.className,d=c.xAxis,m=c.yAxis,h=c.top,u=c.left,p=c.width,I=c.height,k=c.isAnimationActive,B=c.id;if(o||!l||!l.length)return null;var _=this.state.isAnimationFinished,O=l.length===1,V=ls("recharts-line",x),$=d&&d.allowDataOverflow,R=m&&m.allowDataOverflow,W=$||R,r=Ge(B)?this.id:B,L=(t=we(i,!1))!==null&&t!==void 0?t:{r:3,strokeWidth:2},U=L.r,w=U===void 0?3:U,D=L.strokeWidth,z=D===void 0?2:D,N=ra(i)?i:{},A=N.clipDot,E=A===void 0?!0:A,F=w*2+z;return q.createElement(Me,{className:V},$||R?q.createElement("defs",null,q.createElement("clipPath",{id:"clipPath-".concat(r)},q.createElement("rect",{x:$?u:u-p/2,y:R?h:h-I/2,width:$?p:p*2,height:R?I:I*2})),!E&&q.createElement("clipPath",{id:"clipPath-dots-".concat(r)},q.createElement("rect",{x:u-F/2,y:h-F/2,width:p+F,height:I+F}))):null,!O&&this.renderCurve(W,r),this.renderErrorBar(W,r),(O||i)&&this.renderDots(W,E,r),(!k||_)&&ca.renderCallByParent(this.props,l))}}],[{key:"getDerivedStateFromProps",value:function(t,c){return t.animationId!==c.prevAnimationId?{prevAnimationId:t.animationId,curPoints:t.points,prevPoints:c.curPoints}:t.points!==c.curPoints?{curPoints:t.points}:null}},{key:"repeat",value:function(t,c){for(var o=t.length%2!==0?[].concat(xe(t),[0]):t,i=[],l=0;l<c;++l)i=[].concat(xe(i),xe(o));return i}},{key:"renderDotItem",value:function(t,c){var o;if(q.isValidElement(t))o=q.cloneElement(t,c);else if(Zn(t))o=t(c);else{var i=c.key,l=gs(c,rt),x=ls("recharts-line-dot",typeof t!="boolean"?t.className:"");o=q.createElement(ea,Ie({key:i},l,{className:x}))}return o}}])})(v.PureComponent);ne(ge,"displayName","Line");ne(ge,"defaultProps",{xAxisId:0,yAxisId:0,connectNulls:!1,activeDot:!0,dot:!0,legendType:"line",stroke:"#3182bd",strokeWidth:1,fill:"#fff",points:[],isAnimationActive:!oa.isSsr,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",hide:!1,label:!1});ne(ge,"getComposedData",function(s){var n=s.props,a=s.xAxis,t=s.yAxis,c=s.xAxisTicks,o=s.yAxisTicks,i=s.dataKey,l=s.bandSize,x=s.displayedData,d=s.offset,m=n.layout,h=x.map(function(u,p){var I=Rs(u,i);return m==="horizontal"?{x:us({axis:a,ticks:c,bandSize:l,entry:u,index:p}),y:Ge(I)?null:t.scale(I),value:I,payload:u}:{x:Ge(I)?null:a.scale(I),y:us({axis:t,ticks:o,bandSize:l,entry:u,index:p}),value:I,payload:u}});return G({points:h,layout:m},d)});var vt=da({chartName:"LineChart",GraphicalChild:ge,axisComponents:[{axisType:"xAxis",AxisComp:zs},{axisType:"yAxis",AxisComp:Vs}],formatAxisMap:ma});const be=[{month:"Jan",revenue:12500,expenses:8200},{month:"Feb",revenue:15800,expenses:9100},{month:"Mar",revenue:18200,expenses:10500},{month:"Apr",revenue:16900,expenses:9800},{month:"May",revenue:21300,expenses:11200},{month:"Jun",revenue:24500,expenses:12800},{month:"Jul",revenue:22800,expenses:11900},{month:"Aug",revenue:26100,expenses:13500},{month:"Sep",revenue:28900,expenses:14200},{month:"Oct",revenue:31200,expenses:15100}];function yt(){const s=be.reduce((a,t)=>a+t.revenue,0),n=s/be.length;return e.jsxs(X,{children:[e.jsxs(J,{children:[e.jsx(Q,{children:"Revenue Analytics"}),e.jsx(Z,{children:"Revenue and expenses over time"})]}),e.jsxs(ee,{children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-3 mb-6",children:[e.jsxs("div",{className:"rounded-lg border p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(De,{className:"h-4 w-4"}),"Total Revenue"]}),e.jsxs("p",{className:"text-2xl font-bold",children:["$",s.toLocaleString()]}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-green-600",children:[e.jsx(Fe,{className:"h-3 w-3"}),e.jsx("span",{children:"+24.5% from last period"})]})]}),e.jsxs("div",{className:"rounded-lg border p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(De,{className:"h-4 w-4"}),"Average Monthly"]}),e.jsxs("p",{className:"text-2xl font-bold",children:["$",n.toLocaleString(void 0,{maximumFractionDigits:0})]}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-green-600",children:[e.jsx(Fe,{className:"h-3 w-3"}),e.jsx("span",{children:"+18.2% growth rate"})]})]}),e.jsxs("div",{className:"rounded-lg border p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(De,{className:"h-4 w-4"}),"Current Month"]}),e.jsxs("p",{className:"text-2xl font-bold",children:["$",be[be.length-1].revenue.toLocaleString()]}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-green-600",children:[e.jsx(Fe,{className:"h-3 w-3"}),e.jsx("span",{children:"+8.0% from last month"})]})]})]}),e.jsx(ua,{config:{revenue:{label:"Revenue",color:"hsl(var(--chart-1))"},expenses:{label:"Expenses",color:"hsl(var(--chart-2))"}},className:"h-[400px]",children:e.jsx(xa,{width:"100%",height:"100%",children:e.jsxs(vt,{data:be,margin:{top:5,right:10,left:10,bottom:5},children:[e.jsx(ha,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(zs,{dataKey:"month",className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Vs,{className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(pa,{content:e.jsx(ja,{})}),e.jsx(ge,{type:"monotone",dataKey:"revenue",stroke:"var(--color-revenue)",strokeWidth:2,dot:{fill:"var(--color-revenue)",r:4}}),e.jsx(ge,{type:"monotone",dataKey:"expenses",stroke:"var(--color-expenses)",strokeWidth:2,dot:{fill:"var(--color-expenses)",r:4}})]})})})]})]})}const Nt=({contractId:s})=>{const[n,a]=v.useState(!1),[t,c]=v.useState(void 0),{issueDocuments:o}=ya(),i=Xe(ba(new Date,1),"yyyy-MM-dd"),[{data:l,fetching:x},d]=re({query:on,variables:{issueMonth:i,contractId:s},pause:!n});v.useEffect(()=>{n&&d()},[n,d]),v.useEffect(()=>{if(l?.periodicalDocumentDraftsByContracts?.length){const h=dn(fe(mn,l.periodicalDocumentDraftsByContracts[0]));c(h)}else l&&c(void 0)},[l,c]);const m=v.useCallback(async h=>{await o({generateDocumentsInfo:[h]}),a(!1)},[o]);return e.jsxs(Se,{open:n,onOpenChange:a,children:[e.jsx(Os,{asChild:!0,children:e.jsx(T,{className:"size-7.5",variant:"ghost",children:e.jsx(un,{className:"size-5"})})}),e.jsxs(Te,{className:"w-[90vw] sm:max-w-[95%] max-h-[90vh] overflow-y-auto",children:[e.jsxs(as,{children:[e.jsx(ts,{children:"Issue Document for Contract"}),e.jsx(is,{children:"Issue periodically documents based on contract"})]}),x?e.jsx(Je,{}):t?e.jsx(Na,{draft:t,onApprove:m}):e.jsx("div",{className:"text-center p-4 text-muted-foreground",children:"No document draft available to issue for this contract and period."})]})]})};function ys(s){return{id:s.id,pos:s.purchaseOrders??void 0,startDate:s.startDate,endDate:s.endDate,paymentAmount:s.amount.raw,paymentCurrency:s.amount.currency,productType:s.product??void 0,billingCycle:s.billingCycle,msCloudLink:s.msCloud?.toString(),isActive:s.isActive,subscriptionPlan:s.plan??void 0,defaultRemark:s.remarks??void 0,defaultDocumentType:s.documentType??void 0,operationsLimit:s.operationsLimit}}function bt({clientId:s}){const[{data:n,fetching:a},t]=re({query:xn,variables:{clientId:s}}),c=v.useMemo(()=>[...n?.contractsByClient??[]].sort((o,i)=>new Date(i.startDate).getTime()-new Date(o.startDate).getTime()),[n?.contractsByClient]);return a?e.jsx("div",{children:"Loading contracts..."}):e.jsxs(X,{children:[e.jsx(J,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Q,{children:"Contracts"}),e.jsx(Z,{children:"Current and past contracts sorted by start date"})]}),e.jsx(We,{clientId:s,onDone:t})]})}),e.jsx(ee,{className:"space-y-4",children:c.map(o=>e.jsx(Ct,{clientId:s,contract:o,refetch:t},o.id))})]})}function Ct({clientId:s,contract:n,refetch:a}){const t=!!n.isActive;return e.jsxs("div",{className:"rounded-lg border p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"font-semibold",children:n.product}),e.jsx(ie,{variant:t?"default":"secondary",children:n.isActive?"Active":"Inactive"})]}),e.jsx("p",{className:"text-sm text-muted-foreground font-mono",children:n.id})]}),e.jsxs("div",{children:[e.jsx(We,{clientId:s,contract:ys(n),onDone:a}),e.jsx(We,{clientId:s,contract:ys(n),onDone:a,duplicate:!0}),e.jsx(Nt,{contractId:n.id})]})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:[e.jsxs("div",{className:"space-y-0",children:[e.jsxs("p",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(hn,{className:"h-3 w-3"}),"Contract Period"]}),e.jsxs("p",{className:"text-sm font-medium",children:[new Date(n.startDate).toLocaleDateString()," →"," ",new Date(n.endDate).toLocaleDateString()]})]}),e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"PO Numbers"}),e.jsx("p",{className:"text-sm font-medium font-mono",children:n.purchaseOrders.toReversed()[0]??""}),n.purchaseOrders.length>1&&e.jsx("div",{className:"space-x-1",children:n.purchaseOrders.toReversed().slice(1).map(c=>e.jsx("span",{className:"text-xs font-thin font-mono",children:c},c))})]}),e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Payment"}),e.jsx("p",{className:"text-sm font-medium",children:pn(n.amount.raw,n.amount.currency)})]}),e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Billing Cycle"}),e.jsx("p",{className:"text-sm font-medium",children:fa(n.billingCycle)})]}),e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Subscription Plan"}),e.jsx("p",{className:"text-sm font-medium",children:n.plan?va(n.plan):"N/A"})]}),e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Operations Limit"}),e.jsx("p",{className:"text-sm font-medium",children:n.operationsLimit.toLocaleString()})]}),e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Document Type"}),e.jsx("p",{className:"text-sm font-medium",children:jn(n.documentType)})]})]}),n.remarks&&e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Remark"}),e.jsx("p",{className:"text-sm",children:n.remarks})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:n.msCloud&&e.jsx(T,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:n.msCloud.toString(),target:"_blank",rel:"noopener noreferrer",children:[e.jsx(es,{className:"h-4 w-4 mr-2"}),"MS Cloud",e.jsx(Ca,{className:"h-3 w-3 ml-1"})]})})})]},n.id)}const At=[{id:"linearId",name:"Linear",description:"Issue tracking and project management",url:"https://linear.app/the-guild/customer/[ID]",color:"indigo-500"},{id:"slackChannelKey",name:"Slack",description:"Team communication and notifications",keyType:"Channel Key",url:"https://guild-oss.slack.com/archives/[ID]"},{id:"notionId",name:"Notion",description:"Documentation and knowledge management",url:"https://www.notion.so/theguildoss/[ID]"},{id:"workflowyUrl",name:"Workflowy",keyType:"URL",description:"Task management and note taking",url:"[ID]"}];function It({data:s}){const[n,a]=v.useState([]),t=fe(fn,s),c=t?.clientInfo?.integrations,{updateClient:o}=Ls(),[{data:i,fetching:l},x]=re({query:gn,variables:{clientId:t?.id??""},pause:!c?.greenInvoiceInfo||!t?.id||!n.includes("green-invoice")}),d=i?.greenInvoiceClient,m=c?.hiveId,h=v.useCallback((u,p)=>{if(!t?.id)return;const I={};I[p]=u,o({businessId:t?.id,fields:{integrations:I}})},[t?.id,o]);return v.useEffect(()=>{c?.greenInvoiceInfo?.greenInvoiceId&&t?.id&&n.includes("green-invoice")&&x()},[c?.greenInvoiceInfo?.greenInvoiceId,t?.id,x,n]),e.jsxs(X,{children:[e.jsx(J,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(Q,{children:"Integrations"}),e.jsx(Z,{children:"Connected external services and providers"})]})})}),e.jsx(ee,{className:"space-y-6",children:e.jsxs(Ia,{type:"multiple",value:n,onValueChange:a,className:"space-y-4",children:[e.jsxs(_e,{value:"green-invoice",className:"rounded-lg border-2 border-green-600/20 bg-green-600/5",children:[e.jsx("div",{className:"px-4 py-3 bg-green-600/10 rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-green-600 flex items-center justify-center text-white font-bold",children:"GI"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Green Invoice"}),e.jsx(Re,{className:"h-5 w-5 text-green-600"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Israeli invoicing system integration"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ve,{id:t?.clientInfo?.integrations.greenInvoiceInfo?.greenInvoiceId??void 0,provider:"Green Invoice",updateClient:async u=>h(u,"greenInvoiceId")}),t?.clientInfo?.integrations.greenInvoiceInfo?.greenInvoiceId&&e.jsx(xs,{className:"p-2"})]})]})}),e.jsx(hs,{children:l?e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(P,{className:"h-4 w-40"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"h-3 w-24"}),e.jsx(P,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"h-3 w-24"}),e.jsx(P,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"h-3 w-24"}),e.jsx(P,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"h-3 w-24"}),e.jsx(P,{className:"h-4 w-full"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(P,{className:"h-4 w-40"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"h-3 w-32"}),e.jsx(P,{className:"h-6 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"h-3 w-24"}),e.jsx(P,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"h-3 w-24"}),e.jsx(P,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"h-3 w-24"}),e.jsx(P,{className:"h-4 w-full"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(P,{className:"h-4 w-40"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2 md:col-span-2",children:[e.jsx(P,{className:"h-3 w-24"}),e.jsx(P,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"h-3 w-24"}),e.jsx(P,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"h-3 w-24"}),e.jsx(P,{className:"h-4 w-full"})]})]})]})]}):d&&e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-semibold text-sm text-muted-foreground uppercase tracking-wide",children:"Business Information"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Integration ID"}),e.jsx("p",{className:"text-sm font-mono",children:t?.clientInfo?.integrations.greenInvoiceInfo?.greenInvoiceId})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Business Name"}),e.jsx("p",{className:"text-sm",children:d.name})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Country"}),e.jsx("p",{className:"text-sm",children:d.country?.name})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Tax ID"}),e.jsx("p",{className:"text-sm font-mono",children:d.taxId})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-semibold text-sm text-muted-foreground uppercase tracking-wide",children:"Contact Information"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(Ue,{className:"h-3.5 w-3.5"}),"Email Addresses"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:d.emails?.map((u,p)=>e.jsx("span",{className:"text-sm px-2 py-1 bg-muted rounded",children:u},p))})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(Fs,{className:"h-3.5 w-3.5"}),"Phone"]}),e.jsx("p",{className:"text-sm font-mono",children:d.phone})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Mobile"}),e.jsx("p",{className:"text-sm font-mono",children:d.mobile})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Fax"}),e.jsx("p",{className:"text-sm font-mono",children:d.fax})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h4",{className:"font-semibold text-sm text-muted-foreground uppercase tracking-wide flex items-center gap-2",children:[e.jsx(qe,{className:"h-3.5 w-3.5"}),"Address"]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"space-y-1 md:col-span-2",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Street Address"}),e.jsx("p",{className:"text-sm",children:d.address})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"City"}),e.jsx("p",{className:"text-sm",children:d.city})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Zip Code"}),e.jsx("p",{className:"text-sm font-mono",children:d.zip})]})]})]})]})})]}),e.jsxs(_e,{value:"hiveId",className:"rounded-lg border-2 border-green-900/20 bg-green-900/5",children:[e.jsx("div",{className:"px-4 py-3 bg-green-900/10 rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[m?e.jsx(he,{to:"https://the-guild.dev/graphql/hive",target:"_blank",rel:"noreferrer",onClick:u=>u.stopPropagation(),className:"inline-flex items-center font-semibold",children:e.jsx("div",{className:"h-10 w-10 rounded-lg bg-green-900 flex items-center justify-center text-white font-bold",children:e.jsx("img",{src:"/icons/logos/hive.svg",alt:"Hive logo",className:"size-8 object-cover"})})}):e.jsx("div",{className:"h-10 w-10 rounded-lg bg-green-900 flex items-center justify-center text-white font-bold",children:e.jsx(os,{})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Hive"}),m?e.jsx(Re,{className:"h-5 w-5 text-green-600"}):e.jsx(ps,{className:"h-5 w-5 text-red-600"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Schema registry, analytics, metrics and gateway for GraphQL federation and other GraphQL APIs"})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(Ve,{id:c?.hiveId??void 0,provider:"Hive",updateClient:async u=>h(u,"hiveId")})}),m&&e.jsx(xs,{className:"p-2"})]})}),e.jsx(hs,{children:m&&e.jsxs("div",{className:"flex flex-col gap-4 px-4 pb-4 pt-2 border-t",children:[e.jsx("div",{className:"text-sm",children:e.jsxs(he,{to:"https://the-guild.dev/graphql/hive",target:"_blank",rel:"noreferrer",onClick:u=>u.stopPropagation(),className:"inline-flex items-center font-semibold gap-2",children:[e.jsx("img",{src:"/icons/logos/hive.svg",alt:"Hive logo",className:"size-8 object-cover"}),"Hive"]})}),e.jsx("div",{className:"text-sm",children:e.jsxs(he,{to:`https://graphcdn.retool.com/apps/f6c244bc-b7ce-11ef-a86c-0b05f221c5b4/Hive/Hive%20Admin/explore_organization?id=${c.hiveId}`,target:"_blank",rel:"noreferrer",onClick:u=>u.stopPropagation(),className:"inline-flex items-center font-semibold gap-2",children:[e.jsx("img",{src:"/icons/logos/retool.svg",alt:"Retool logo",className:"size-8 object-cover"}),"Retool"]})})]})})]},"hiveId"),At.map(u=>e.jsx(_e,{value:u.id,className:"rounded-lg border-2 border-gray-500/20 bg-gray-500/5",children:e.jsx("div",{className:"px-4 py-3 bg-gray-500/10 rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[c?.[u.id]?e.jsx(he,{to:u.url.replace("[ID]",c?.[u.id]??""),target:"_blank",rel:"noreferrer",onClick:p=>p.stopPropagation(),className:"inline-flex items-center font-semibold",children:e.jsx("div",{className:"h-10 w-10 rounded-lg bg-gray-500 flex items-center justify-center text-white font-bold",children:e.jsx(es,{})})}):e.jsx("div",{className:"h-10 w-10 rounded-lg bg-gray-500 flex items-center justify-center text-white font-bold",children:e.jsx(os,{})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold text-lg",children:u.name}),c?.[u.id]==null?e.jsx(ps,{className:"h-5 w-5 text-red-600"}):e.jsx(Re,{className:"h-5 w-5 text-green-600"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:u.description})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(Ve,{id:t?.clientInfo?.integrations[u.id]??void 0,provider:u.name,keyType:u.keyType,updateClient:async p=>h(p,u.id)})})]})})},u.id))]})})]})}function Ve({id:s,provider:n,keyType:a,updateClient:t}){const[c,o]=v.useState(!1),[i,l]=v.useState(s),x=v.useCallback(async()=>{await t(i),o(!1)},[i,t]);return e.jsxs(Se,{open:c,onOpenChange:o,children:[e.jsx(Os,{asChild:!0,children:e.jsx(T,{variant:"outline",size:"sm",onClick:d=>d.stopPropagation(),children:e.jsx(Ms,{className:"h-4 w-4"})})}),e.jsxs(Te,{onClick:d=>d.stopPropagation(),children:[e.jsxs(as,{children:[e.jsxs(ts,{children:["Configure ",n]}),e.jsxs(is,{children:["Update your ",n," integration settings"]})]}),e.jsx("div",{className:"space-y-4 py-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Ae,{htmlFor:"id",children:[n," ",a??"ID"]}),e.jsx(C,{id:"id",value:i,onChange:d=>l(d.target.value),placeholder:`Enter ${n} ${a??"ID"}`})]})}),e.jsxs(Ts,{children:[e.jsx(T,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(T,{onClick:x,disabled:!i,children:"Save Changes"})]})]})]})}const wt="updateBusiness",qs=()=>{const[{fetching:s},n]=Be(vn),a=v.useCallback(async t=>{const c=`Error updating business ID [${t.businessId}]`,o=`${wt}-${t.businessId}`;Y.loading("Updating business",{id:o});try{const i=await n(t),l=Ee(i,c,o,"updateBusiness");if(l)return Y.success("Success",{id:o,description:"Business updated"}),l.updateBusiness}catch(i){console.error(`${c}: ${i}`),Y.error("Error",{id:o,description:c,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,updateBusiness:a}},Dt=Object.values(kn);function Ns(s){return!s||s.__typename!=="LtdFinancialEntity"?{}:{isClient:!!s.clientInfo?.id,isActive:s.isActive,isReceiptEnough:s.isReceiptEnough??void 0,isDocumentsOptional:s.isDocumentsOptional??void 0,isVatOptional:s.optionalVAT??void 0,isExemptDealer:s.exemptDealer??void 0,sortCode:s.sortCode?.key?.toString()??void 0,taxCategory:s.taxCategory?.id??void 0,pcn874RecordType:s?.pcn874RecordType??void 0,irsCode:s?.irsCode??void 0,description:s.suggestions?.description??void 0,tags:s.suggestions?.tags?.map(n=>n.id)??[],phrases:s.suggestions?.phrases??[],emails:s.suggestions?.emails??[],internalLinks:s.suggestions?.emailListener?.internalEmailLinks??[],attachmentTypes:s.suggestions?.emailListener?.attachments??[],useMessageBody:s.suggestions?.emailListener?.emailBody??void 0}}function kt(s){const a=s.internalLinks||s.useMessageBody||s.attachmentTypes?{internalEmailLinks:s.internalLinks,emailBody:s.useMessageBody,attachments:s.attachmentTypes}:void 0,c=s.description||s.tags||s.phrases||s.emails||a?{description:s.description,tags:s.tags?.map(o=>({id:o})),phrases:s.phrases,emails:s.emails,emailListener:a}:void 0;return{optionalVAT:s.isVatOptional,exemptDealer:s.isExemptDealer,sortCode:s.sortCode?parseInt(s.sortCode):void 0,taxCategory:s.taxCategory,pcn874RecordType:s.pcn874RecordType,irsCode:s.irsCode,isActive:s.isActive,isReceiptEnough:s.isReceiptEnough,isDocumentsOptional:s.isDocumentsOptional,suggestions:c}}function St({data:s,refetchBusiness:n}){const a=fe(Nn,s),[t,c]=v.useState(Ns(a)),{userContext:o}=v.useContext(rs),{updateBusiness:i,fetching:l}=qs(),[x,d]=v.useState(!1),[m,h]=v.useState(void 0),u=Pe({defaultValues:t}),p=async k=>{if(!a||!o?.context.adminBusinessId)return;const B=ss(k,u.formState.dirtyFields);if(!B)return;const _=kt(B);await i({businessId:a.id,ownerId:o.context.adminBusinessId,fields:_}),B.tags?.length||B.description?(h({tagIds:B.tags?.map(O=>({id:O})),description:B.description}),d(!0)):n?.()};if(v.useEffect(()=>{if(a){const k=Ns(a);c(k),u.reset(k)}},[a,u]),!a)return e.jsx("div",{});const I=u.watch("isClient");return e.jsxs(X,{children:[e.jsx(J,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Q,{children:"Configurations"}),e.jsx(Z,{children:"Business status, tax settings, automation rules, and integration preferences"})]}),!I&&e.jsx(yn,{businessId:a.id,onDone:n})]})}),e.jsx(Oe,{...u,children:e.jsxs("form",{onSubmit:u.handleSubmit(p),children:[e.jsxs(ee,{className:"space-y-6",children:[e.jsx(Tt,{form:u}),e.jsx(le,{}),e.jsx(Bt,{form:u}),e.jsx(le,{}),e.jsx(Et,{form:u}),e.jsx(le,{}),e.jsx(Pt,{form:u})]}),e.jsx(Ze,{className:"flex justify-end border-t pt-6",children:e.jsxs(T,{type:"submit",disabled:l||Object.keys(u.formState.dirtyFields).length===0,children:[e.jsx(cs,{className:"h-4 w-4 mr-2"}),"Save Changes"]})})]})}),e.jsx(Va,{businessId:a.id,tagIds:m?.tagIds,description:m?.description,open:x,onOpenChange:d,onClose:n})]})}function Tt({form:s}){return e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Business Status & Behavior"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:s.control,name:"isClient",render:({field:n,fieldState:a})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"Is Client"}),e.jsx(de,{children:"Mark this business as a client"})]}),e.jsx(y,{children:e.jsx(ce,{disabled:!0,checked:n.value,onCheckedChange:n.onChange,className:S(a)})})]})}),e.jsx(j,{control:s.control,name:"isActive",render:({field:n,fieldState:a})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"Is Active"}),e.jsx(de,{children:"Business is currently active"})]}),e.jsx(y,{children:e.jsx(ce,{checked:n.value,onCheckedChange:n.onChange,className:S(a)})})]})}),e.jsx(j,{control:s.control,name:"isReceiptEnough",render:({field:n,fieldState:a})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"Is Receipt Enough"}),e.jsx(de,{children:"Generate ledger for receipt documents if no invoice available"})]}),e.jsx(y,{children:e.jsx(ce,{checked:n.value,onCheckedChange:n.onChange,className:S(a)})})]})}),e.jsx(j,{control:s.control,name:"isDocumentsOptional",render:({field:n,fieldState:a})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"No Docs Required"}),e.jsx(de,{children:"Skip document validation for common charges"})]}),e.jsx(y,{children:e.jsx(ce,{checked:n.value,onCheckedChange:n.onChange,className:S(a)})})]})}),e.jsx(j,{control:s.control,name:"isVatOptional",render:({field:n,fieldState:a})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"Is VAT Optional"}),e.jsx(de,{children:"Mute missing VAT indicator"})]}),e.jsx(y,{children:e.jsx(ce,{checked:n.value,onCheckedChange:n.onChange,className:S(a)})})]})}),e.jsx(j,{control:s.control,name:"isExemptDealer",render:({field:n,fieldState:a})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"Is Exempt Dealer"}),e.jsx(de,{children:"Business is exempt from VAT requirements"})]}),e.jsx(y,{children:e.jsx(ce,{checked:n.value,onCheckedChange:n.onChange,className:S(a)})})]})})]})]})}function Bt({form:s}){const{selectableTaxCategories:n,fetching:a}=bn(),{selectableSortCodes:t,fetching:c,sortCodes:o}=Cn(),{selectableTags:i,fetching:l}=An(),x=v.useCallback(d=>{if(d){const m=o.find(h=>Number(h.key)===Number(d));m&&(m.defaultIrsCode?s.setValue("irsCode",m.defaultIrsCode,{shouldDirty:!0}):s.setValue("irsCode",null,{shouldDirty:!0}))}},[s,o]);return e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Default Settings"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(j,{control:s.control,name:"sortCode",render:({field:d,fieldState:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Sort Code"}),e.jsx(y,{children:e.jsx(He,{onChange:h=>{x(h),d.onChange(h)},data:t,value:d.value,disabled:c,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:S(m)}})}),e.jsx(b,{})]})}),e.jsx(j,{control:s.control,name:"taxCategory",render:({field:d,fieldState:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Tax Category"}),e.jsx(y,{children:e.jsx(He,{data:n,disabled:a,value:d.value,onChange:d.onChange,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:S(m)}})}),e.jsx(b,{})]})}),e.jsx(j,{control:s.control,name:"pcn874RecordType",render:({field:d,fieldState:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"PCN874 Record Type"}),e.jsxs(Is,{onValueChange:d.onChange,value:d.value,children:[e.jsx(y,{children:e.jsx(ws,{className:S(m),children:e.jsx(Ds,{})})}),e.jsx(ks,{children:Object.entries(In).map(([h,u])=>e.jsx(Ss,{value:h,children:`${u} (${h})`},h))})]}),e.jsx(b,{})]})}),e.jsx(j,{control:s.control,name:"irsCode",render:({field:d,fieldState:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"IRS Code"}),e.jsx(y,{children:e.jsx(wn,{value:d.value??void 0,onValueChange:h=>d.onChange(h??null),hideControls:!0,decimalScale:0,className:S(m)})}),e.jsx(b,{})]})}),e.jsx(j,{control:s.control,name:"description",render:({field:d,fieldState:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Charge Description"}),e.jsx(y,{children:e.jsx(C,{placeholder:"Enter default charge description",...d,className:S(m)})}),e.jsx(b,{})]})}),e.jsx(j,{control:s.control,name:"tags",render:({field:d,fieldState:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Tags"}),e.jsx(y,{children:e.jsx(Dn,{options:Object.values(i).map(({value:h,label:u})=>({label:u,value:h})),onValueChange:d.onChange,defaultValue:d.value,value:d.value,placeholder:"Select Default Tags",variant:"default",disabled:l,className:S(m)})}),e.jsx(b,{})]})})]})]})}function Et({form:s}){const[n,a]=v.useState(""),[t,c]=v.useState(""),o=()=>{if(n.trim()){const d=s.getValues("phrases");s.setValue("phrases",[...d,n.trim()],{shouldDirty:!0}),a("")}},i=()=>{if(t.trim()){const d=s.getValues("emails");s.setValue("emails",[...d,t.trim()],{shouldDirty:!0}),c("")}},l=d=>{const m=s.getValues("phrases");s.setValue("phrases",m.filter((h,u)=>u!==d),{shouldDirty:!0})},x=d=>{const m=s.getValues("emails");s.setValue("emails",m.filter((h,u)=>u!==d),{shouldDirty:!0})};return e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Auto-matching Configuration"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure patterns for automatic matching of bank transactions and documents"}),e.jsx(j,{control:s.control,name:"phrases",render:({field:d,fieldState:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Phrases"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(C,{placeholder:"Add phrase...",value:n,onChange:h=>a(h.target.value),onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),o())},className:S(m)}),e.jsx(T,{type:"button",size:"sm",onClick:o,children:e.jsx(ae,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:d.value?.map((h,u)=>e.jsxs(ie,{variant:"secondary",className:"gap-1",children:[h,e.jsx(T,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>l(u),children:e.jsx(te,{className:"size-3 cursor-pointer",onClick:()=>l(u)})})]},u))}),e.jsx(b,{})]})}),e.jsx(j,{control:s.control,name:"emails",render:({field:d,fieldState:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Email Addresses"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(C,{type:"email",placeholder:"Add email...",value:t,onChange:h=>c(h.target.value),onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),i())},className:S(m)}),e.jsx(T,{type:"button",size:"sm",onClick:i,children:e.jsx(ae,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:d.value?.map((h,u)=>e.jsxs(ie,{variant:"secondary",className:"gap-1",children:[h,e.jsx(T,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>x(u),children:e.jsx(te,{className:"size-3 cursor-pointer"})})]},u))}),e.jsx(b,{})]})})]})}function Pt({form:s}){const[n,a]=v.useState(""),t=()=>{if(n.trim()){const i=s.getValues("internalLinks");s.setValue("internalLinks",[...i,n.trim()],{shouldDirty:!0}),a("")}},c=i=>{const l=s.getValues("attachmentTypes");s.setValue("attachmentTypes",l?.includes(i)?l.filter(x=>x!==i):[...l,i],{shouldDirty:!0})},o=i=>{const l=s.getValues("internalLinks");s.setValue("internalLinks",l.filter((x,d)=>d!==i),{shouldDirty:!0})};return e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Gmail Feature Configuration"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure Gmail integration settings for document processing"}),e.jsx(j,{control:s.control,name:"attachmentTypes",render:({field:i,fieldState:l})=>e.jsxs(g,{children:[e.jsx(f,{children:"Attachment Types"}),e.jsx("div",{className:S(l)+" rounded-md flex flex-wrap gap-2",children:Dt.map(x=>e.jsx(ie,{variant:i.value?.includes(x)?"default":"outline",className:"cursor-pointer",onClick:()=>c(x),children:x},x))}),e.jsx(b,{})]})}),e.jsx(j,{control:s.control,name:"internalLinks",render:({field:i,fieldState:l})=>e.jsxs(g,{children:[e.jsx(f,{children:"Internal Links"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(C,{type:"url",placeholder:"Add internal link...",value:n,onChange:x=>a(x.target.value),onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),t())}}),e.jsx(T,{type:"button",size:"sm",onClick:t,children:e.jsx(ae,{className:"h-4 w-4"})})]}),e.jsx("div",{className:S(l)+" flex flex-wrap gap-2 rounded-md",children:i.value?.map((x,d)=>e.jsxs(ie,{variant:"secondary",className:"gap-1 max-w-xs truncate",children:[x,e.jsx(T,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>o(d),children:e.jsx(te,{className:"size-3 cursor-pointer flex-shrink-0"})})]},d))}),e.jsx(b,{})]})}),e.jsx(j,{control:s.control,name:"useMessageBody",render:({field:i,fieldState:l})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"Should Use Message Body"}),e.jsx(de,{children:"Extract information from email message body"})]}),e.jsx(y,{children:e.jsx(ce,{checked:i.value,onCheckedChange:i.onChange,className:S(l)})})]})})]})}const Ot=ue({businessName:M().min(1,"Business name is required"),locality:M().min(1,"Locality is required"),localName:M().optional(),govId:M().optional(),address:M().optional(),city:M().optional(),zipCode:M().optional(),localAddress:M().optional(),phone:M().optional(),website:En("Invalid URL").optional().or(Pn("")),generalContacts:me(ms()).optional(),billingEmails:me(ms()).optional()});function bs(s){return!s||s.__typename!=="LtdFinancialEntity"?{}:{businessName:s.name,locality:s.country?.code,localName:s.hebrewName??void 0,govId:s.governmentId??void 0,address:s.address??void 0,city:s.city??void 0,zipCode:s.zipCode??void 0,phone:s.phoneNumber??void 0,website:s.website??void 0,generalContacts:s.email?.split(",").map(n=>n.trim()),billingEmails:s.clientInfo?.emails}}function Lt(s){return{name:s.businessName,country:s.locality,hebrewName:s.localName,governmentId:s.govId,address:s.address,city:s.city,zipCode:s.zipCode,phoneNumber:s.phone,website:s.website,email:s.generalContacts?.join(", ")}}function Ft({data:s,refetchBusiness:n}){const a=fe(Bn,s),[t,c]=v.useState(bs(a)),{userContext:o}=v.useContext(rs),{updateBusiness:i,fetching:l}=qs(),{updateClient:x,fetching:d}=Ls(),m=Pe({resolver:Qe(Ot),defaultValues:t}),{countries:h,fetching:u}=Sn(),[p,I]=v.useState(""),[k,B]=v.useState(""),_=m.watch("locality"),O=m.watch("address"),V=m.watch("city"),$=m.watch("zipCode"),R=m.watch("localAddress");v.useEffect(()=>{O!==t.address&&m.setValue("address",O,{shouldDirty:!0})},[O,t.address,m]),v.useEffect(()=>{V!==t.city&&m.setValue("city",V,{shouldDirty:!0})},[V,t.city,m]),v.useEffect(()=>{$!==t.zipCode&&m.setValue("zipCode",$,{shouldDirty:!0})},[$,t.zipCode,m]),v.useEffect(()=>{R!==t.localAddress&&m.setValue("localAddress",R,{shouldDirty:!0})},[R,t.localAddress,m]);const W=a&&"clientInfo"in a&&!!a.clientInfo,r=_===o?.context.locality,L=N=>{p.trim()&&(m.setValue("generalContacts",[...N,p.trim()],{shouldDirty:!0}),I(""))},U=(N,A)=>{m.setValue("generalContacts",N.filter((E,F)=>F!==A),{shouldDirty:!0})},w=N=>{k.trim()&&(m.setValue("billingEmails",[...N,k.trim()],{shouldDirty:!0}),B(""))},D=(N,A)=>{m.setValue("billingEmails",N.filter((E,F)=>F!==A),{shouldDirty:!0})},z=async N=>{if(!a||!o?.context.adminBusinessId)return;const A=ss(N,m.formState.dirtyFields);if(!A)return;const E=Lt(A),F=[];Object.values(E).some(Le=>Le!=null)&&F.push(i({businessId:a.id,ownerId:o.context.adminBusinessId,fields:E})),W&&A.billingEmails&&F.push(x({businessId:a.id,fields:{emails:A.billingEmails}})),await Promise.all(F),n?.()};return v.useEffect(()=>{if(a){const N=bs(a);c(N),m.reset(N)}},[a,m]),e.jsxs(X,{children:[e.jsxs(J,{children:[e.jsx(Q,{children:"Contact Information"}),e.jsx(Z,{children:"Business contact details and address information"})]}),e.jsx(Oe,{...m,children:e.jsxs("form",{onSubmit:m.handleSubmit(z),children:[e.jsx(ee,{children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx(j,{control:m.control,name:"businessName",render:({field:N,fieldState:A})=>e.jsxs(g,{children:[e.jsx(f,{children:"Business Name"}),e.jsx(y,{children:e.jsx(C,{...N,className:S(A)})}),e.jsx(b,{})]})}),e.jsx(j,{control:m.control,name:"locality",render:({field:N,fieldState:A})=>e.jsxs(g,{children:[e.jsx(f,{children:"Locality / Country"}),e.jsx(He,{onChange:N.onChange,data:h.map(E=>({value:E.code,label:E.name})),value:N.value,disabled:u,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:S(A)}}),e.jsx(b,{})]})}),r&&e.jsx(j,{control:m.control,name:"localName",render:({field:N,fieldState:A})=>e.jsxs(g,{children:[e.jsx(f,{children:"Local Name"}),e.jsx(y,{children:e.jsx(C,{...N,placeholder:"Business name in local language",className:S(A)})}),e.jsx(b,{})]})}),e.jsx(j,{control:m.control,name:"govId",render:({field:N,fieldState:A})=>e.jsxs(g,{children:[e.jsx(f,{children:"Government ID"}),e.jsx(y,{children:e.jsx(C,{...N,placeholder:"Enter Government ID",className:S(A)})}),e.jsx(b,{})]})}),e.jsx(j,{control:m.control,name:"address",render:({field:N,fieldState:A})=>e.jsxs(g,{className:"md:col-span-2",children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(qe,{className:"h-4 w-4"}),"Address"]}),e.jsx(y,{children:e.jsx(ds,{...N,rows:3,placeholder:"Enter business address",className:S(A)})}),e.jsx(b,{})]})}),e.jsx(j,{control:m.control,name:"city",render:({field:N,fieldState:A})=>e.jsxs(g,{children:[e.jsx(f,{children:"City"}),e.jsx(y,{children:e.jsx(C,{...N,placeholder:"Enter City",className:S(A)})}),e.jsx(b,{})]})}),e.jsx(j,{control:m.control,name:"zipCode",render:({field:N,fieldState:A})=>e.jsxs(g,{children:[e.jsx(f,{children:"Zip Code"}),e.jsx(y,{children:e.jsx(C,{...N,placeholder:"Enter Zip Code",className:S(A)})}),e.jsx(b,{})]})}),r&&e.jsx(j,{control:m.control,name:"localAddress",render:({field:N,fieldState:A})=>e.jsxs(g,{className:"md:col-span-2",children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(qe,{className:"h-4 w-4"}),"Local Address"]}),e.jsx(y,{children:e.jsx(ds,{...N,rows:3,placeholder:"Enter address in local language",className:S(A)})}),e.jsx(b,{})]})}),e.jsx(j,{control:m.control,name:"phone",render:({field:N,fieldState:A})=>e.jsxs(g,{children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(Fs,{className:"h-4 w-4"}),"Phone"]}),e.jsx(y,{children:e.jsx(C,{...N,type:"tel",placeholder:"+1 (555) 123-4567",className:S(A)})}),e.jsx(b,{})]})}),e.jsx(j,{control:m.control,name:"website",render:({field:N,fieldState:A})=>e.jsxs(g,{children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(Tn,{className:"h-4 w-4"}),"Website"]}),e.jsx(y,{children:e.jsx(C,{...N,type:"url",placeholder:"https://example.com",className:S(A)})}),e.jsx(b,{})]})}),e.jsx(j,{control:m.control,name:"generalContacts",render:({field:N,fieldState:A})=>e.jsxs(g,{className:"md:col-span-2",children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(Ue,{className:"h-4 w-4"}),"General Contacts"]}),e.jsx(y,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:S(A)+" flex flex-wrap gap-2 mb-2 rounded-md",children:N.value?.map((E,F)=>e.jsxs(ie,{variant:"secondary",className:"gap-1 pr-1",children:[E,e.jsx("button",{type:"button",onClick:()=>U(N.value??[],F),className:"ml-1 hover:bg-muted rounded-sm p-0.5",children:e.jsx(te,{className:"h-3 w-3"})})]},F))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(C,{value:p,onChange:E=>I(E.target.value),onKeyDown:E=>{E.key==="Enter"&&(E.preventDefault(),L(N.value??[]))},placeholder:"Add contact email",type:"email"}),e.jsx(T,{type:"button",variant:"outline",size:"icon",disabled:!p.trim(),onClick:()=>L(N.value??[]),children:e.jsx(ae,{className:"h-4 w-4"})})]})]})}),e.jsx(b,{})]})}),W&&e.jsx(j,{control:m.control,name:"billingEmails",render:({field:N,fieldState:A})=>e.jsxs(g,{className:"md:col-span-2",children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(Ue,{className:"h-4 w-4"}),"Billing Emails"]}),e.jsx(y,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:S(A)+" flex flex-wrap gap-2 mb-2 rounded-md",children:N.value?.map((E,F)=>e.jsxs(ie,{variant:"secondary",className:"gap-1 pr-1",children:[E,e.jsx("button",{type:"button",onClick:()=>D(N.value??[],F),className:"ml-1 hover:bg-muted rounded-sm p-0.5",children:e.jsx(te,{className:"h-3 w-3"})})]},F))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(C,{value:k,onChange:E=>B(E.target.value),onKeyDown:E=>{E.key==="Enter"&&(E.preventDefault(),w(N.value??[]))},placeholder:"Add billing email",type:"email"}),e.jsx(T,{type:"button",variant:"outline",size:"icon",disabled:!k.trim(),onClick:()=>w(N.value??[]),children:e.jsx(ae,{className:"h-4 w-4"})})]})]})}),e.jsx(b,{})]})})]})}),e.jsx(Ze,{className:"flex justify-end border-t mt-4 pt-6",children:e.jsxs(T,{type:"submit",disabled:l||d||Object.keys(m.formState.dirtyFields).length===0,children:[e.jsx(cs,{className:"h-4 w-4 mr-2"}),"Save Changes"]})})]})})]})}function Mt({businessId:s}){return e.jsxs(X,{children:[e.jsx(J,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(Q,{children:"Documents"}),e.jsx(Z,{children:"Invoices, proformas, receipts, and other accounting documents"})]})})}),e.jsx(ee,{children:e.jsx(On,{businessId:s,linkedDocumentIds:[],limit:1e3})})]})}function _t({businessId:s}){const[{data:n,fetching:a}]=re({query:Ln,variables:{businessId:s}});return a?e.jsx("div",{children:"Loading ledger records..."}):e.jsxs(X,{children:[e.jsx(J,{className:"flex w-full justify-between items-center",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(Q,{children:"Ledger Records"}),e.jsx(Z,{children:"Complete ledger history for this business"})]})})}),e.jsx(ee,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Qn,{ledgerRecordsData:n?.ledgerRecordsByFinancialEntity??[]})})})]})}function Rt({businessId:s}){const[{data:n,fetching:a}]=re({query:Fn,variables:{businessId:s}});return a?e.jsx("div",{children:"Loading transactions..."}):e.jsxs(X,{children:[e.jsxs(J,{className:"flex w-full justify-between items-center",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(Q,{children:"Transactions"}),e.jsx(Z,{children:"Complete transaction history for this business"})]})}),e.jsx(ga,{rawTransactions:n?.transactionsByFinancialEntity??[]})]}),e.jsx(ee,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Aa,{transactionsProps:n?.transactionsByFinancialEntity??[]})})})]})}function zt({data:s,refetchBusiness:n}){const a=fe(qn,s),[t,c]=Mn(),{setFiltersContext:o}=v.useContext(_n);v.useEffect(()=>{o(null)},[o]);const i=t.get("tab")||"contact",l=m=>{c({tab:m})};if(!a)return e.jsx("div",{children:"Business not found"});const x="clientInfo"in a&&!!a.clientInfo,d="adminInfo"in a&&!!a.adminInfo;return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(Xn,{data:a}),e.jsx("main",{className:"container mx-auto px-4 py-6 md:px-6 lg:px-8 max-w-7xl",children:e.jsxs(Rn,{value:i,onValueChange:l,className:"w-full",children:[e.jsxs(zn,{className:"grid w-full lg:grid-cols-8 sm:grid-cols-4 grid-cols-8 mb-6 h-auto gap-1 bg-muted/50 p-1",children:[e.jsxs(se,{value:"contact",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(wa,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Contact"})]}),e.jsxs(se,{value:"config",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Ms,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Config"})]}),e.jsxs(se,{value:"charges",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(De,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Charges"})]}),e.jsxs(se,{value:"transactions",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Vn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Transactions"})]}),e.jsxs(se,{value:"documents",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx($n,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Documents"})]}),e.jsxs(se,{value:"ledger",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Ma,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Ledger"})]}),e.jsxs(se,{value:"balance",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(ka,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Balance"})]}),x&&e.jsxs(e.Fragment,{children:[e.jsxs(se,{value:"contracts",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Pa,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Contracts"})]}),e.jsxs(se,{value:"integrations",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Ra,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Integrations"})]})]}),d&&e.jsxs(e.Fragment,{children:[e.jsxs(se,{value:"accounts",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Un,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Accounts"})]}),e.jsxs(se,{value:"admin",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Cs,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Admin"})]})]})]}),e.jsx(K,{value:"contact",className:"mt-0",children:e.jsx(Ft,{data:a,refetchBusiness:n})}),e.jsx(K,{value:"config",className:"mt-0",children:e.jsx(St,{data:a,refetchBusiness:n})}),e.jsx(K,{value:"charges",className:"mt-0",children:e.jsx(tt,{businessId:a.id})}),e.jsx(K,{value:"transactions",className:"mt-0",children:e.jsx(Rt,{businessId:a.id})}),e.jsx(K,{value:"documents",className:"mt-0",children:e.jsx(Mt,{businessId:a.id})}),e.jsx(K,{value:"ledger",className:"mt-0",children:e.jsx(_t,{businessId:a.id})}),e.jsx(K,{value:"balance",className:"mt-0",children:e.jsx(at,{businessId:a.id})}),x&&e.jsxs(e.Fragment,{children:[e.jsx(K,{value:"contracts",className:"mt-0",children:e.jsx(bt,{clientId:a.id})}),e.jsx(K,{value:"integrations",className:"mt-0",children:e.jsx(It,{data:a})}),e.jsx(K,{value:"charts",className:"mt-0",children:e.jsx(yt,{})})]}),d&&e.jsxs(e.Fragment,{children:[e.jsx(K,{value:"accounts",className:"mt-0",children:e.jsx(nt,{adminId:a.id})}),e.jsx(K,{value:"admin",className:"mt-0",children:e.jsx(Ga,{data:a})})]})]})})]})}const ui=()=>{const{businessId:s}=Hn();let n;try{n=Gn()}catch{}const[{data:a,fetching:t},c]=re({query:Wn,pause:!s||!!n,variables:{businessId:s??""}}),o=n||a;return!n&&t&&!o?.business?e.jsx(Je,{}):!s||!o?.business?e.jsx("div",{children:"Business not found"}):e.jsx(zt,{data:o.business,refetchBusiness:async()=>c()})};export{ui as BusinessScreen};
@@ -1,3 +1,3 @@
1
- import{j as e,m as S,aP as H,ah as z,R as F,w as D,ay as d,bx as L,bQ as h,bT as B,c2 as G,r as c,dp as Z,u as ee,e7 as te,bY as ne,aT as f,bO as V,bP as P,bR as k,bS as O,e8 as se,I as ae,bZ as re,b_ as oe,B as ie,b$ as le,c0 as ce,c1 as me,ao as ue,ap as de,aq as ge,ar as xe,as as fe,P as he,c4 as pe,c3 as we,c5 as je,c6 as be}from"./index-DRqooPz9.js";import{D as p}from"./data-table-column-header-DDRUwuwC.js";import{D as Ce}from"./download-csv-button-BFfxSTjQ.js";const Se=({amount:t})=>!t||t.raw===0?e.jsx("span",{className:"text-sm text-gray-400",children:"—"}):e.jsx("span",{className:S("text-sm font-medium whitespace-nowrap",t.raw>0?"text-green-700":"text-red-600"),children:t.formatted}),Ne=({balance:t,currency:r})=>{if(t===0)return e.jsx("span",{className:"text-sm text-gray-400",children:"—"});const n=H(t,r);return e.jsx("span",{className:S("text-sm font-medium whitespace-nowrap",t>0?"text-green-700":"text-red-600"),children:n})},ye=({business:t})=>e.jsx(z,{to:F.BUSINESSES.DETAIL(t.id),target:"_blank",rel:"noopener noreferrer",onClick:r=>r.stopPropagation(),className:"inline-flex items-center font-semibold whitespace-nowrap",children:t.name}),Ae=({counterAccount:t})=>t?e.jsx(z,{to:F.BUSINESSES.DETAIL(t.id),target:"_blank",rel:"noopener noreferrer",onClick:r=>r.stopPropagation(),className:"inline-flex items-center font-semibold whitespace-nowrap text-sm",children:t.name}):e.jsx("span",{className:"text-sm text-gray-400",children:"—"}),Ie=({row:t,currency:r})=>{const n=t.foreignAmount&&t.foreignAmount.currency===r?t.foreignAmount:null;return!n||n.raw===0?e.jsx("span",{className:"text-sm text-gray-400",children:"—"}):e.jsx("span",{className:S("text-sm font-medium whitespace-nowrap",n.raw>0?"text-green-700":"text-red-600"),children:n.formatted})},ve=({row:t,currency:r})=>{const n=`${r.toLowerCase()}Balance`,a=t[n]??0;if(a===0)return e.jsx("span",{className:"text-sm text-gray-400",children:"—"});const l=H(a,r);return e.jsx("span",{className:S("text-sm font-medium whitespace-nowrap",a>0?"text-green-700":"text-red-600"),children:l})},De=({date:t})=>t?e.jsx("span",{className:"text-sm font-medium whitespace-nowrap",children:D(new Date(t),"dd/MM/yy")}):e.jsx("span",{className:"text-sm text-gray-400",children:"—"}),Be=()=>[{accessorKey:"business.name",id:"businessName",header:"Business Name",cell:({row:t})=>e.jsx(ye,{business:t.original.business}),enableSorting:!1,enableHiding:!1},{accessorKey:"invoiceDate",id:"date",header:({column:t})=>e.jsx(p,{column:t,title:"Date"}),cell:({row:t})=>e.jsx(De,{date:t.original.invoiceDate}),sortingFn:"datetime"},{accessorKey:"amount.raw",id:"amount",header:({column:t})=>e.jsx(p,{column:t,title:"Amount"}),cell:({row:t})=>e.jsx(Se,{amount:t.original.amount}),sortingFn:"basic"},{accessorKey:"ilsBalance",id:"ilsBalance",header:({column:t})=>e.jsx(p,{column:t,title:"Amount Balance"}),cell:({row:t})=>e.jsx(Ne,{balance:t.original.ilsBalance,currency:d.Ils}),sortingFn:"basic"}],Fe=()=>Object.values(d).filter(n=>n!==d.Ils).sort((n,a)=>{const l=L.includes(n),m=L.includes(a);return l&&!m?-1:!l&&m?1:n.localeCompare(a)}).flatMap(n=>[{id:`${n.toLowerCase()}Amount`,accessorFn:a=>a.foreignAmount?.currency===n?a.foreignAmount.raw:null,header:({column:a})=>e.jsx(p,{column:a,title:`${n} Amount`}),cell:({row:a})=>e.jsx(Ie,{row:a.original,currency:n}),sortingFn:"basic",enableHiding:!0},{id:`${n.toLowerCase()}Balance`,accessorFn:a=>a[`${n.toLowerCase()}Balance`]??null,header:({column:a})=>e.jsx(p,{column:a,title:`${n} Balance`}),cell:({row:a})=>e.jsx(ve,{row:a.original,currency:n}),sortingFn:"basic",enableHiding:!0}]),$e=()=>[{accessorKey:"reference",id:"reference",header:"Reference",cell:({row:t})=>e.jsx("p",{className:"text-sm whitespace-nowrap",children:t.original.reference??""}),enableSorting:!1},{accessorKey:"details",id:"details",header:"Details",cell:({row:t})=>e.jsx("p",{className:"text-sm whitespace-nowrap",children:t.original.details??""}),enableSorting:!1},{accessorKey:"counterAccount.name",id:"counterAccount",header:"Counter Account",cell:({row:t})=>e.jsx(Ae,{counterAccount:t.original.counterAccount}),enableSorting:!1}],Me=()=>[...Be(),...Fe(),...$e()],Re=t=>{const r={};for(const n of Object.values(d).filter(a=>a!==d.Ils)){const a=t.has(n),l=`${n.toLowerCase()}Amount`,m=`${n.toLowerCase()}Balance`;a||(r[l]=!1,r[m]=!1)}return r},Te=({row:t})=>{const r=n=>{n.stopPropagation(),window.open(F.CHARGES.DETAIL(t.original.chargeId),"_blank","noopener noreferrer")};return e.jsx(h,{onClick:r,className:"cursor-pointer hover:bg-gray-50 transition-colors",children:t.getVisibleCells().map(n=>e.jsx(B,{children:G(n.column.columnDef.cell,n.getContext())},n.id))})},Ee=({ledgerRecords:t,businessName:r,fromDate:n,toDate:a})=>{const l=c.useCallback(async()=>{const m=_e(t);return{fileName:`business_${r}_ledger_records${n?`_${n}`:""}${a?`_${a}`:""}`,fileContent:m}},[t,r,n,a]);return e.jsx(Ce,{createFileVariables:l})},_e=t=>{let r="";const n=Array.from(new Set(t.filter(a=>a.foreignAmount?.currency).map(a=>a.foreignAmount.currency)));r+=`Sorting Date,Date,Amount,Amount Balance,${Le(n)}Reference,Details,Counter Account\r
1
+ import{j as e,m as S,aP as H,ah as z,R as F,w as D,ay as d,bx as L,bQ as h,bT as B,c2 as G,r as c,dp as Z,u as ee,e7 as te,bY as ne,aT as f,bO as V,bP as P,bR as k,bS as O,e8 as se,I as ae,bZ as re,b_ as oe,B as ie,b$ as le,c0 as ce,c1 as me,ao as ue,ap as de,aq as ge,ar as xe,as as fe,P as he,c4 as pe,c3 as we,c5 as je,c6 as be}from"./index-rI994S3C.js";import{D as p}from"./data-table-column-header-CZ1dXiU0.js";import{D as Ce}from"./download-csv-button-CMQBUQeX.js";const Se=({amount:t})=>!t||t.raw===0?e.jsx("span",{className:"text-sm text-gray-400",children:"—"}):e.jsx("span",{className:S("text-sm font-medium whitespace-nowrap",t.raw>0?"text-green-700":"text-red-600"),children:t.formatted}),Ne=({balance:t,currency:r})=>{if(t===0)return e.jsx("span",{className:"text-sm text-gray-400",children:"—"});const n=H(t,r);return e.jsx("span",{className:S("text-sm font-medium whitespace-nowrap",t>0?"text-green-700":"text-red-600"),children:n})},ye=({business:t})=>e.jsx(z,{to:F.BUSINESSES.DETAIL(t.id),target:"_blank",rel:"noopener noreferrer",onClick:r=>r.stopPropagation(),className:"inline-flex items-center font-semibold whitespace-nowrap",children:t.name}),Ae=({counterAccount:t})=>t?e.jsx(z,{to:F.BUSINESSES.DETAIL(t.id),target:"_blank",rel:"noopener noreferrer",onClick:r=>r.stopPropagation(),className:"inline-flex items-center font-semibold whitespace-nowrap text-sm",children:t.name}):e.jsx("span",{className:"text-sm text-gray-400",children:"—"}),Ie=({row:t,currency:r})=>{const n=t.foreignAmount&&t.foreignAmount.currency===r?t.foreignAmount:null;return!n||n.raw===0?e.jsx("span",{className:"text-sm text-gray-400",children:"—"}):e.jsx("span",{className:S("text-sm font-medium whitespace-nowrap",n.raw>0?"text-green-700":"text-red-600"),children:n.formatted})},ve=({row:t,currency:r})=>{const n=`${r.toLowerCase()}Balance`,a=t[n]??0;if(a===0)return e.jsx("span",{className:"text-sm text-gray-400",children:"—"});const l=H(a,r);return e.jsx("span",{className:S("text-sm font-medium whitespace-nowrap",a>0?"text-green-700":"text-red-600"),children:l})},De=({date:t})=>t?e.jsx("span",{className:"text-sm font-medium whitespace-nowrap",children:D(new Date(t),"dd/MM/yy")}):e.jsx("span",{className:"text-sm text-gray-400",children:"—"}),Be=()=>[{accessorKey:"business.name",id:"businessName",header:"Business Name",cell:({row:t})=>e.jsx(ye,{business:t.original.business}),enableSorting:!1,enableHiding:!1},{accessorKey:"invoiceDate",id:"date",header:({column:t})=>e.jsx(p,{column:t,title:"Date"}),cell:({row:t})=>e.jsx(De,{date:t.original.invoiceDate}),sortingFn:"datetime"},{accessorKey:"amount.raw",id:"amount",header:({column:t})=>e.jsx(p,{column:t,title:"Amount"}),cell:({row:t})=>e.jsx(Se,{amount:t.original.amount}),sortingFn:"basic"},{accessorKey:"ilsBalance",id:"ilsBalance",header:({column:t})=>e.jsx(p,{column:t,title:"Amount Balance"}),cell:({row:t})=>e.jsx(Ne,{balance:t.original.ilsBalance,currency:d.Ils}),sortingFn:"basic"}],Fe=()=>Object.values(d).filter(n=>n!==d.Ils).sort((n,a)=>{const l=L.includes(n),m=L.includes(a);return l&&!m?-1:!l&&m?1:n.localeCompare(a)}).flatMap(n=>[{id:`${n.toLowerCase()}Amount`,accessorFn:a=>a.foreignAmount?.currency===n?a.foreignAmount.raw:null,header:({column:a})=>e.jsx(p,{column:a,title:`${n} Amount`}),cell:({row:a})=>e.jsx(Ie,{row:a.original,currency:n}),sortingFn:"basic",enableHiding:!0},{id:`${n.toLowerCase()}Balance`,accessorFn:a=>a[`${n.toLowerCase()}Balance`]??null,header:({column:a})=>e.jsx(p,{column:a,title:`${n} Balance`}),cell:({row:a})=>e.jsx(ve,{row:a.original,currency:n}),sortingFn:"basic",enableHiding:!0}]),$e=()=>[{accessorKey:"reference",id:"reference",header:"Reference",cell:({row:t})=>e.jsx("p",{className:"text-sm whitespace-nowrap",children:t.original.reference??""}),enableSorting:!1},{accessorKey:"details",id:"details",header:"Details",cell:({row:t})=>e.jsx("p",{className:"text-sm whitespace-nowrap",children:t.original.details??""}),enableSorting:!1},{accessorKey:"counterAccount.name",id:"counterAccount",header:"Counter Account",cell:({row:t})=>e.jsx(Ae,{counterAccount:t.original.counterAccount}),enableSorting:!1}],Me=()=>[...Be(),...Fe(),...$e()],Re=t=>{const r={};for(const n of Object.values(d).filter(a=>a!==d.Ils)){const a=t.has(n),l=`${n.toLowerCase()}Amount`,m=`${n.toLowerCase()}Balance`;a||(r[l]=!1,r[m]=!1)}return r},Te=({row:t})=>{const r=n=>{n.stopPropagation(),window.open(F.CHARGES.DETAIL(t.original.chargeId),"_blank","noopener noreferrer")};return e.jsx(h,{onClick:r,className:"cursor-pointer hover:bg-gray-50 transition-colors",children:t.getVisibleCells().map(n=>e.jsx(B,{children:G(n.column.columnDef.cell,n.getContext())},n.id))})},Ee=({ledgerRecords:t,businessName:r,fromDate:n,toDate:a})=>{const l=c.useCallback(async()=>{const m=_e(t);return{fileName:`business_${r}_ledger_records${n?`_${n}`:""}${a?`_${a}`:""}`,fileContent:m}},[t,r,n,a]);return e.jsx(Ce,{createFileVariables:l})},_e=t=>{let r="";const n=Array.from(new Set(t.filter(a=>a.foreignAmount?.currency).map(a=>a.foreignAmount.currency)));r+=`Sorting Date,Date,Amount,Amount Balance,${Le(n)}Reference,Details,Counter Account\r
2
2
  `;for(const a of t){const l=Pe(a,n);r+=l}return r};function Le(t){let r="";return t.map(n=>{const a=Z(n);r+=`${n}(${a}) Amount,${n}(${a}) Balance,`}),r}function Ve(t,r){let n="";return r.map(a=>{t.foreignAmount&&t.foreignAmount.currency===a?n+=`${t.foreignAmount.raw},${t[`${a.toLowerCase()}Balance`]??0},`:n+=",,"}),n}function Pe(t,r){let n="";const a=t.invoiceDate?D(new Date(t.invoiceDate),"yyy-MM-dd"):null,l=t.invoiceDate?D(new Date(t.invoiceDate),"dd/MM/yy"):null,m=t.amount.raw,{ilsBalance:x,reference:w,details:N}=t,y=t.counterAccount?.name??"";return n+=`${a},${l},${m},${x},${Ve(t,r)}${v(w??"")},${v(N??"")},${v(y)},\r
3
3
  `,n}function v(t){return t===""?"":Number.isNaN(Number(t))?String(t).replace(/"/g,'""').replace(/,/g,"."):Number(t).toFixed(2).toString()}const K="businessLedger",C={SORTING:`${K}_sorting`,COLUMN_VISIBILITY:`${K}_columnVisibility`};function He({businessID:t,filter:r}){const[n,a]=c.useState(()=>{try{const s=localStorage.getItem(C.SORTING);return s?JSON.parse(s):[]}catch{return[]}}),[l,m]=c.useState([]),[x,w]=c.useState(""),[N,y]=c.useState({pageIndex:0,pageSize:50});c.useEffect(()=>{try{localStorage.setItem(C.SORTING,JSON.stringify(n))}catch(s){console.warn("Failed to save sorting to localStorage:",s)}},[n]);const{fromDate:U,ownerIds:Y,toDate:J}=r??{},[{data:A,fetching:q}]=ee({query:te,variables:{filters:{fromDate:U,ownerIds:Y,toDate:J,businessIDs:[t]}}}),g=c.useMemo(()=>A?.businessTransactionsFromLedgerRecords.__typename==="CommonError"?[]:A?.businessTransactionsFromLedgerRecords.businessTransactions.sort((s,o)=>s.invoiceDate>o.invoiceDate?1:-1)??[],[A]),$=c.useMemo(()=>{const s=[];for(let o=0;o<g.length;o++){const{__typename:W,...u}=g[o],X=o===0?u.amount.raw:(s[o-1].ilsBalance??0)+u.amount.raw,E={};Object.values(d).map(b=>{if(b!==d.Ils){const _=`${b.toLowerCase()}Balance`;E[_]=o===0?(u.foreignAmount?.currency===b?u.foreignAmount?.raw:0)??0:(s[o-1]?.[_]??0)+(u.foreignAmount?.currency===b?u.foreignAmount?.raw:0)}}),s.push({...u,ilsBalance:X,...E})}return s},[g]),M=c.useMemo(()=>new Set(g.filter(s=>s.foreignAmount?.currency).map(s=>s.foreignAmount.currency)),[g]),R=Me(),j=c.useMemo(()=>Re(M),[M]),[I,T]=c.useState(()=>{try{const s=localStorage.getItem(C.COLUMN_VISIBILITY);if(s){const o=JSON.parse(s);return{...j,...o}}}catch{}return j});c.useEffect(()=>{try{localStorage.setItem(C.COLUMN_VISIBILITY,JSON.stringify(I))}catch(s){console.warn("Failed to save column visibility to localStorage:",s)}},[I]),c.useEffect(()=>{T(s=>({...j,...s}))},[j]);const i=ne({data:$,columns:R,getCoreRowModel:be(),getSortedRowModel:je(),getFilteredRowModel:we(),getPaginationRowModel:pe(),onSortingChange:a,onColumnFiltersChange:m,onColumnVisibilityChange:T,onGlobalFilterChange:w,onPaginationChange:y,globalFilterFn:"includesString",state:{sorting:n,columnFilters:l,columnVisibility:I,globalFilter:x,pagination:N}}),Q=g[0]?.business.name??"unknown";return q?e.jsxs("div",{className:"flex flex-col gap-4 max-w-[90vw] m-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(f,{className:"h-10 w-64"}),e.jsx(f,{className:"h-10 w-32"})]}),e.jsx(f,{className:"size-10"})]}),e.jsx("div",{className:"rounded-md border overflow-x-auto",children:e.jsxs(V,{children:[e.jsx(P,{children:e.jsx(h,{children:Array.from({length:8}).map((s,o)=>e.jsx(k,{children:e.jsx(f,{className:"h-4 w-24"})},o))})}),e.jsx(O,{children:Array.from({length:5}).map((s,o)=>e.jsx(h,{children:Array.from({length:8}).map((W,u)=>e.jsx(B,{children:e.jsx(f,{className:"h-4 w-full"})},u))},o))})]})})]}):e.jsxs("div",{className:"flex flex-col gap-4 max-w-[90vw] m-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px] max-w-sm",children:[e.jsx(se,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-gray-500"}),e.jsx(ae,{placeholder:"Search reference, details, business...",value:x??"",onChange:s=>w(s.target.value),className:"pl-8"})]}),e.jsxs(re,{children:[e.jsx(oe,{asChild:!0,children:e.jsxs(ie,{variant:"outline",size:"sm",children:[e.jsx(le,{className:"mr-2 h-4 w-4"}),"Columns"]})}),e.jsx(ce,{align:"end",className:"max-h-96 overflow-y-auto",children:i.getAllColumns().filter(s=>s.getCanHide()).map(s=>e.jsx(me,{className:"capitalize",checked:s.getIsVisible(),onCheckedChange:o=>s.toggleVisibility(!!o),children:s.id},s.id))})]})]}),e.jsx(Ee,{ledgerRecords:$,businessName:Q,fromDate:r?.fromDate??void 0,toDate:r?.toDate??void 0})]}),e.jsx("div",{className:"rounded-md border overflow-x-auto",children:e.jsxs(V,{children:[e.jsx(P,{className:"sticky top-0 z-20 bg-white border-b",children:i.getHeaderGroups().map(s=>e.jsx(h,{children:s.headers.map(o=>e.jsx(k,{colSpan:o.colSpan,children:o.isPlaceholder?null:G(o.column.columnDef.header,o.getContext())},o.id))},s.id))}),e.jsx(O,{children:i.getRowModel().rows?.length?i.getRowModel().rows.map(s=>e.jsx(Te,{row:s},s.id)):e.jsx(h,{children:e.jsx(B,{colSpan:R.length,className:"h-24 text-center",children:"No transactions found."})})})]})}),e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("p",{className:"text-sm text-gray-700",children:["Showing"," ",i.getState().pagination.pageIndex*i.getState().pagination.pageSize+1," to"," ",Math.min((i.getState().pagination.pageIndex+1)*i.getState().pagination.pageSize,i.getFilteredRowModel().rows.length)," ","of ",i.getFilteredRowModel().rows.length," transactions"]})}),e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Rows per page:"}),e.jsxs(ue,{value:String(i.getState().pagination.pageSize),onValueChange:s=>{i.setPageSize(Number(s))},children:[e.jsx(de,{className:"h-8 w-[70px]",children:e.jsx(ge,{placeholder:i.getState().pagination.pageSize})}),e.jsx(xe,{side:"top",children:[25,50,100,200,500].map(s=>e.jsx(fe,{value:String(s),children:s},s))})]})]}),e.jsx(he,{className:"w-fit mx-0",currentPageIndex:i.getState().pagination.pageIndex,totalPages:i.getPageCount(),onChange:s=>i.setPageIndex(s)})]})]})]})}export{He as B};
@@ -0,0 +1 @@
1
+ import{j as e,af as t,w as l,a6 as m,bu as x}from"./index-rI994S3C.js";import{B as o}from"./building-2-CMKd_bU8.js";function h({data:n}){const s=m(x,n);if(!s||s.__typename!=="LtdFinancialEntity")return e.jsx("div",{});const{isActive:i,adminInfo:r,clientInfo:a}=s,d=!!r?.id,c=!!a?.id;return e.jsx("header",{className:"sticky top-0 z-50 w-full border-b border-border bg-card/95 backdrop-blur supports-[backdrop-filter]:bg-card/60",children:e.jsx("div",{className:"container mx-auto px-4 md:px-6 lg:px-8 max-w-7xl",children:e.jsxs("div",{className:"flex h-16 items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-accent",children:e.jsx(o,{className:"h-5 w-5 text-accent-foreground"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h1",{className:"text-lg font-semibold text-foreground",children:s.name}),i?e.jsx(t,{variant:"secondary",children:"Active"}):e.jsx(t,{variant:"destructive",children:"Inactive"}),d&&e.jsx(t,{variant:"outline",children:"Admin"}),c&&e.jsx(t,{variant:"outline",children:"Client"})]}),e.jsxs("p",{className:"text-sm text-muted-foreground truncate",children:["Business ID: ",s.id]})]})]}),e.jsxs("div",{className:"hidden md:flex items-center gap-6 text-sm",children:[s.governmentId&&e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-muted-foreground",children:"Tax ID"}),e.jsx("p",{className:"font-medium text-foreground",children:s.governmentId})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-muted-foreground",children:"Since"}),e.jsx("p",{className:"font-medium text-foreground",children:l(s.createdAt,"MMM yyyy")})]})]})]})})})}export{h as B};
@@ -1 +1 @@
1
- import{by as I,r as f,bz as E,aF as F,bA as O,bB as y,j as s,bC as P,B as N,E as B,bD as k,aC as M,bE as x,bF as h,bG as j,w as D,bH as R,bI as L}from"./index-DRqooPz9.js";import{u as A}from"./use-url-query-A8PE3FMA.js";import{P as T}from"./modal-CPrQ9jQu.js";import{F as U}from"./funnel-B1ZA9LM9.js";import{M as C}from"./MultiSelect-DhEZHYxn.js";var V=I((e,{color:t})=>({root:{backgroundColor:e.fn.themeColor(t,e.colorScheme==="dark"?5:2),color:e.colorScheme==="dark"?e.colors.dark[9]:"inherit"}})),z=Object.defineProperty,v=Object.getOwnPropertySymbols,_=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable,S=(e,t,a)=>t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,G=(e,t)=>{for(var a in t||(t={}))_.call(t,a)&&S(e,a,t[a]);if(v)for(var a of v(t))w.call(t,a)&&S(e,a,t[a]);return e},H=(e,t)=>{var a={};for(var o in e)_.call(e,o)&&t.indexOf(o)<0&&(a[o]=e[o]);if(e!=null&&v)for(var o of v(e))t.indexOf(o)<0&&w.call(e,o)&&(a[o]=e[o]);return a};const X={color:"yellow"},q=f.forwardRef((e,t)=>{const a=E("Mark",X,e),{color:o,className:u,unstyled:p,variant:c}=a,d=H(a,["color","className","unstyled","variant"]),{classes:m,cx:b}=V({color:o},{unstyled:p,name:"Mark",variant:c});return F.createElement(O,G({component:"mark",ref:t,className:b(m.root,u)},d))});q.displayName="@mantine/core/Mark";function J({filter:e,setFilter:t,closeModal:a,single:o=!1}){const{control:u,handleSubmit:p}=B({defaultValues:{...e}}),{selectableBusinesses:c,fetching:d}=k(),{userContext:m}=f.useContext(M),b=r=>{t(r),a()};function l(){t({businessIDs:o?e.businessIDs:void 0}),a()}return s.jsxs(s.Fragment,{children:[d?s.jsx("div",{children:"Loading..."}):s.jsx("div",{}),s.jsxs("form",{onSubmit:p(b),children:[!o&&s.jsxs(s.Fragment,{children:[s.jsx(x,{name:"ownerIds",control:u,defaultValue:e.ownerIds,render:({field:r,fieldState:i})=>s.jsx(C,{...r,data:c,value:r.value??(m?.context.adminBusinessId?[m.context.adminBusinessId]:void 0),disabled:d,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:i.error?.message})}),s.jsx(x,{name:"businessIDs",control:u,defaultValue:e.businessIDs,render:({field:r,fieldState:i})=>s.jsx(C,{...r,data:c,value:r.value??void 0,disabled:d,label:"Businesses",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:i.error?.message})})]}),s.jsx(x,{name:"fromDate",control:u,defaultValue:e.fromDate,rules:{pattern:{value:h,message:"Date must be im format yyyy-mm-dd"}},render:({field:r,fieldState:i})=>s.jsx(j,{...r,onChange:n=>{const g=n?typeof n=="string"?n:D(n,"yyyy-MM-dd"):void 0;g!==r.value&&r.onChange(g)},value:r.value?new Date(r.value):void 0,error:i.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),s.jsx(x,{name:"toDate",control:u,defaultValue:e.toDate,rules:{pattern:{value:h,message:"Date must be im format yyyy-mm-dd"}},render:({field:r,fieldState:i})=>s.jsx(j,{...r,onChange:n=>{const g=n?typeof n=="string"?n:D(n,"yyyy-MM-dd"):void 0;g!==r.value&&r.onChange(g)},value:r.value?new Date(r.value):void 0,error:i.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),!o&&s.jsx(x,{name:"type",control:u,defaultValue:null,render:({field:r,fieldState:i})=>s.jsx(R,{...r,onChange:n=>r.onChange(n==="NULL"?null:n),data:[{value:"NULL",label:"All"},{value:"BUSINESS",label:"Business"},{value:"TAX_CATEGORY",label:"Tax Category"}],error:i.error?.message,label:"Type"})}),s.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[s.jsx("button",{type:"submit",className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Filter"}),s.jsx("button",{type:"button",className:"text-white bg-orange-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-orange-600 rounded-sm text-lg",onClick:l,children:"Clear"}),s.jsx("button",{type:"button",className:"text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:a,children:"Cancel"})]})]})]})}function $({filter:e,setFilter:t}){const[a,o]=f.useState(!1),[u,p]=f.useState(!y(e)),{get:c,set:d}=A();function m(l){return Object.entries(l??{}).filter(([i,n])=>n!==void 0&&Array.isArray(n)&&n.length>0).length>0}function b(l){l.fromDate?.trim()===""&&(l.fromDate=void 0),l.toDate?.trim()===""&&(l.toDate=void 0),L(l,e)||(t(l),p(m(l)))}return f.useEffect(()=>{const l=y(e)?null:encodeURIComponent(JSON.stringify(e)),r=c("ledgerRecordsFilters");l!==r&&d("ledgerRecordsFilters",l)},[e,c,d]),s.jsxs(s.Fragment,{children:[s.jsx(T,{opened:a,onClose:()=>o(!1),content:s.jsx(J,{single:!0,filter:e,setFilter:b,closeModal:()=>o(!1)})}),s.jsx(P,{inline:!0,size:16,disabled:!u,children:s.jsx(N,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>o(!0),children:s.jsx(U,{className:"size-5"})})})]})}export{$ as B,q as M};
1
+ import{by as I,r as f,bz as E,aF as F,bA as O,bB as y,j as s,bC as P,B as N,E as B,bD as k,aC as M,bE as x,bF as h,bG as j,w as D,bH as R,bI as L}from"./index-rI994S3C.js";import{u as A}from"./use-url-query-CqWra6gD.js";import{P as T}from"./modal-BXR_xgUm.js";import{F as U}from"./funnel-Cfb9Pxmr.js";import{M as C}from"./MultiSelect-DBeIExB5.js";var V=I((e,{color:t})=>({root:{backgroundColor:e.fn.themeColor(t,e.colorScheme==="dark"?5:2),color:e.colorScheme==="dark"?e.colors.dark[9]:"inherit"}})),z=Object.defineProperty,v=Object.getOwnPropertySymbols,_=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable,S=(e,t,a)=>t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,G=(e,t)=>{for(var a in t||(t={}))_.call(t,a)&&S(e,a,t[a]);if(v)for(var a of v(t))w.call(t,a)&&S(e,a,t[a]);return e},H=(e,t)=>{var a={};for(var o in e)_.call(e,o)&&t.indexOf(o)<0&&(a[o]=e[o]);if(e!=null&&v)for(var o of v(e))t.indexOf(o)<0&&w.call(e,o)&&(a[o]=e[o]);return a};const X={color:"yellow"},q=f.forwardRef((e,t)=>{const a=E("Mark",X,e),{color:o,className:u,unstyled:p,variant:c}=a,d=H(a,["color","className","unstyled","variant"]),{classes:m,cx:b}=V({color:o},{unstyled:p,name:"Mark",variant:c});return F.createElement(O,G({component:"mark",ref:t,className:b(m.root,u)},d))});q.displayName="@mantine/core/Mark";function J({filter:e,setFilter:t,closeModal:a,single:o=!1}){const{control:u,handleSubmit:p}=B({defaultValues:{...e}}),{selectableBusinesses:c,fetching:d}=k(),{userContext:m}=f.useContext(M),b=r=>{t(r),a()};function l(){t({businessIDs:o?e.businessIDs:void 0}),a()}return s.jsxs(s.Fragment,{children:[d?s.jsx("div",{children:"Loading..."}):s.jsx("div",{}),s.jsxs("form",{onSubmit:p(b),children:[!o&&s.jsxs(s.Fragment,{children:[s.jsx(x,{name:"ownerIds",control:u,defaultValue:e.ownerIds,render:({field:r,fieldState:i})=>s.jsx(C,{...r,data:c,value:r.value??(m?.context.adminBusinessId?[m.context.adminBusinessId]:void 0),disabled:d,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:i.error?.message})}),s.jsx(x,{name:"businessIDs",control:u,defaultValue:e.businessIDs,render:({field:r,fieldState:i})=>s.jsx(C,{...r,data:c,value:r.value??void 0,disabled:d,label:"Businesses",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:i.error?.message})})]}),s.jsx(x,{name:"fromDate",control:u,defaultValue:e.fromDate,rules:{pattern:{value:h,message:"Date must be im format yyyy-mm-dd"}},render:({field:r,fieldState:i})=>s.jsx(j,{...r,onChange:n=>{const g=n?typeof n=="string"?n:D(n,"yyyy-MM-dd"):void 0;g!==r.value&&r.onChange(g)},value:r.value?new Date(r.value):void 0,error:i.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),s.jsx(x,{name:"toDate",control:u,defaultValue:e.toDate,rules:{pattern:{value:h,message:"Date must be im format yyyy-mm-dd"}},render:({field:r,fieldState:i})=>s.jsx(j,{...r,onChange:n=>{const g=n?typeof n=="string"?n:D(n,"yyyy-MM-dd"):void 0;g!==r.value&&r.onChange(g)},value:r.value?new Date(r.value):void 0,error:i.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),!o&&s.jsx(x,{name:"type",control:u,defaultValue:null,render:({field:r,fieldState:i})=>s.jsx(R,{...r,onChange:n=>r.onChange(n==="NULL"?null:n),data:[{value:"NULL",label:"All"},{value:"BUSINESS",label:"Business"},{value:"TAX_CATEGORY",label:"Tax Category"}],error:i.error?.message,label:"Type"})}),s.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[s.jsx("button",{type:"submit",className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Filter"}),s.jsx("button",{type:"button",className:"text-white bg-orange-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-orange-600 rounded-sm text-lg",onClick:l,children:"Clear"}),s.jsx("button",{type:"button",className:"text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:a,children:"Cancel"})]})]})]})}function $({filter:e,setFilter:t}){const[a,o]=f.useState(!1),[u,p]=f.useState(!y(e)),{get:c,set:d}=A();function m(l){return Object.entries(l??{}).filter(([i,n])=>n!==void 0&&Array.isArray(n)&&n.length>0).length>0}function b(l){l.fromDate?.trim()===""&&(l.fromDate=void 0),l.toDate?.trim()===""&&(l.toDate=void 0),L(l,e)||(t(l),p(m(l)))}return f.useEffect(()=>{const l=y(e)?null:encodeURIComponent(JSON.stringify(e)),r=c("ledgerRecordsFilters");l!==r&&d("ledgerRecordsFilters",l)},[e,c,d]),s.jsxs(s.Fragment,{children:[s.jsx(T,{opened:a,onClose:()=>o(!1),content:s.jsx(J,{single:!0,filter:e,setFilter:b,closeModal:()=>o(!1)})}),s.jsx(P,{inline:!0,size:16,disabled:!u,children:s.jsx(N,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>o(!0),children:s.jsx(U,{className:"size-5"})})})]})}export{$ as B,q as M};
@@ -1 +1 @@
1
- import{a as w,r as c,F as S,u as y,j as n,c as C,ay as o,bw as x}from"./index-DRqooPz9.js";import{u as h}from"./use-url-query-A8PE3FMA.js";import{a as F}from"./accounter-table-CGncq_73.js";import{B as R}from"./business-extended-info-6Ykvm7VT.js";import{B as v,M as p}from"./business-ledger-filters-Bi9mwcxM.js";import"./Table-rNmO5bBI.js";import"./data-table-column-header-DDRUwuwC.js";import"./eye-off-DtXkBVx1.js";import"./download-csv-button-BFfxSTjQ.js";import"./modal-CPrQ9jQu.js";import"./funnel-B1ZA9LM9.js";import"./MultiSelect-DhEZHYxn.js";const H=({businessId:t})=>{const{businessId:r}=w(),{get:s}=h(),{setFiltersContext:u}=c.useContext(S),l=t||r,[m,d]=c.useState(s("ledgerRecordsFilters")?{...JSON.parse(decodeURIComponent(s("ledgerRecordsFilters"))),businessIDs:l?[l]:[]}:{businessIDs:l?[l]:[]}),[{data:a,fetching:f}]=y({query:x,variables:{filters:m}});c.useEffect(()=>{u(n.jsx(v,{filter:m,setFilter:d}))},[a,m,u,d]);const b=c.useMemo(()=>a?.businessTransactionsSumFromLedgerRecords.__typename==="CommonError"?[]:a?.businessTransactionsSumFromLedgerRecords.businessTransactionsSum?a.businessTransactionsSumFromLedgerRecords.businessTransactionsSum.sort((e,g)=>e.business.name.localeCompare(g.business.name)):[],[a?.businessTransactionsSumFromLedgerRecords]);return f?n.jsx(C,{}):n.jsx(F,{moreInfo:e=>n.jsx(R,{businessID:e.business.id,filter:m}),striped:!0,highlightOnHover:!0,stickyHeader:!0,items:b,columns:[{title:"Business Name",value:e=>e.business.name},{title:"Debit",value:e=>e.debit.formatted,style:{whiteSpace:"nowrap"}},{title:"Credit",value:e=>e.credit.formatted,style:{whiteSpace:"nowrap"}},{title:"Total",value:e=>e.total.raw&&(e.total.raw<-1e-4||e.total.raw>1e-4)?n.jsx(p,{color:e.total.raw>0?"green":"red",children:e.total.formatted}):e.total.formatted,style:{whiteSpace:"nowrap"}},...i(o.Eur),...i(o.Usd),...i(o.Gbp),...i(o.Cad),...i(o.Jpy),...i(o.Aud),...i(o.Sek)]})};function i(t){return[{title:`${t} Debit`,value:r=>r.foreignCurrenciesSum.find(s=>s.currency===t)?.debit?.formatted,style:{whiteSpace:"nowrap"}},{title:`${t} Credit`,value:r=>r.foreignCurrenciesSum.find(s=>s.currency===t)?.credit?.formatted,style:{whiteSpace:"nowrap"}},{title:`${t} Total`,value:r=>{const s=r.foreignCurrenciesSum.find(u=>u.currency===t);return s?.total?.raw&&(s.total.raw<-1e-4||s.total.raw>1e-4)?n.jsx(p,{color:s.total.raw>0?"green":"red",children:s.total.formatted}):s?.total?.formatted},style:{whiteSpace:"nowrap"}}]}export{H as BusinessLedgerRecordsSingle};
1
+ import{a as w,r as c,F as S,u as y,j as n,c as C,ay as o,bw as x}from"./index-rI994S3C.js";import{u as h}from"./use-url-query-CqWra6gD.js";import{a as F}from"./accounter-table-DTsgtq5M.js";import{B as R}from"./business-extended-info-B94y5ZK6.js";import{B as v,M as p}from"./business-ledger-filters-es3H4rPK.js";import"./Table-BQv3frL8.js";import"./data-table-column-header-CZ1dXiU0.js";import"./eye-off-Buv7eciz.js";import"./download-csv-button-CMQBUQeX.js";import"./modal-BXR_xgUm.js";import"./funnel-Cfb9Pxmr.js";import"./MultiSelect-DBeIExB5.js";const H=({businessId:t})=>{const{businessId:r}=w(),{get:s}=h(),{setFiltersContext:u}=c.useContext(S),l=t||r,[m,d]=c.useState(s("ledgerRecordsFilters")?{...JSON.parse(decodeURIComponent(s("ledgerRecordsFilters"))),businessIDs:l?[l]:[]}:{businessIDs:l?[l]:[]}),[{data:a,fetching:f}]=y({query:x,variables:{filters:m}});c.useEffect(()=>{u(n.jsx(v,{filter:m,setFilter:d}))},[a,m,u,d]);const b=c.useMemo(()=>a?.businessTransactionsSumFromLedgerRecords.__typename==="CommonError"?[]:a?.businessTransactionsSumFromLedgerRecords.businessTransactionsSum?a.businessTransactionsSumFromLedgerRecords.businessTransactionsSum.sort((e,g)=>e.business.name.localeCompare(g.business.name)):[],[a?.businessTransactionsSumFromLedgerRecords]);return f?n.jsx(C,{}):n.jsx(F,{moreInfo:e=>n.jsx(R,{businessID:e.business.id,filter:m}),striped:!0,highlightOnHover:!0,stickyHeader:!0,items:b,columns:[{title:"Business Name",value:e=>e.business.name},{title:"Debit",value:e=>e.debit.formatted,style:{whiteSpace:"nowrap"}},{title:"Credit",value:e=>e.credit.formatted,style:{whiteSpace:"nowrap"}},{title:"Total",value:e=>e.total.raw&&(e.total.raw<-1e-4||e.total.raw>1e-4)?n.jsx(p,{color:e.total.raw>0?"green":"red",children:e.total.formatted}):e.total.formatted,style:{whiteSpace:"nowrap"}},...i(o.Eur),...i(o.Usd),...i(o.Gbp),...i(o.Cad),...i(o.Jpy),...i(o.Aud),...i(o.Sek)]})};function i(t){return[{title:`${t} Debit`,value:r=>r.foreignCurrenciesSum.find(s=>s.currency===t)?.debit?.formatted,style:{whiteSpace:"nowrap"}},{title:`${t} Credit`,value:r=>r.foreignCurrenciesSum.find(s=>s.currency===t)?.credit?.formatted,style:{whiteSpace:"nowrap"}},{title:`${t} Total`,value:r=>{const s=r.foreignCurrenciesSum.find(u=>u.currency===t);return s?.total?.raw&&(s.total.raw<-1e-4||s.total.raw>1e-4)?n.jsx(p,{color:s.total.raw>0?"green":"red",children:s.total.formatted}):s?.total?.formatted},style:{whiteSpace:"nowrap"}}]}export{H as BusinessLedgerRecordsSingle};
@@ -0,0 +1 @@
1
+ import{a,r as o,F as u,u as m,j as s,c,ci as d}from"./index-rI994S3C.js";import{P as x,E as l}from"./editable-business-trip-CED1Su3d.js";import{P as f}from"./page-layout-DMGj5xhW.js";import"./summary-CPKS_69D.js";import"./update-accountant-status-zL6vnwU9.js";import"./Table-BQv3frL8.js";import"./toggle-expansion-button-Y2eS7nqg.js";import"./panel-top-open-Bf39HBrp.js";import"./MultiSelect-DBeIExB5.js";import"./similar-transactions-modal-DX3CPrMo.js";import"./building-2-CMKd_bU8.js";import"./accordion-Bn08_4fN.js";const C=({businessTripId:n})=>{const{businessTripId:p}=a(),{setFiltersContext:e}=o.useContext(u),i=n??p??"",[{data:r,fetching:t}]=m({query:d,variables:{businessTripId:i}});return o.useEffect(()=>{e(s.jsx("div",{className:"flex flex-row gap-x-5",children:s.jsx(x,{filename:"business_trip_report"})}))},[r,t,e]),t||!r?.businessTrip?s.jsx(c,{}):s.jsx(f,{title:`Business Trip: ${r.businessTrip.name}`,description:"Manage business trip",children:s.jsx("div",{children:i&&s.jsx(l,{tripId:i,isExtended:!0})})})};export{C as BusinessTrip};
@@ -0,0 +1 @@
1
+ import{a as n,b as h,u,r as d,j as a,c as g,C as f}from"./index-rI994S3C.js";import{C as l}from"./charges-table-BJtpvXfL.js";import"./toggle-expansion-button-Y2eS7nqg.js";import"./panel-top-open-Bf39HBrp.js";import"./update-accountant-status-zL6vnwU9.js";import"./index-C7p19nIa.js";import"./similar-transactions-modal-DX3CPrMo.js";import"./building-2-CMKd_bU8.js";import"./addDays-DTiBTTns.js";import"./Table-BQv3frL8.js";import"./summary-CPKS_69D.js";import"./accordion-Bn08_4fN.js";import"./deposits-transactions-table-2rtRFZgK.js";import"./Checkbox-Dmuz3t7B.js";import"./data-table-column-header-CZ1dXiU0.js";import"./eye-off-Buv7eciz.js";const R=({chargeId:s})=>{const{chargeId:i}=n(),t=s||i;let r;try{r=h()}catch{}const[{data:c,fetching:m},e]=u({query:f,pause:!t||!!r,variables:{chargeId:t??""}});d.useEffect(()=>{t&&!r&&e()},[t,r,e]);const o=r||c,p=!r&&m;return t?p?a.jsx(g,{}):a.jsx(l,{data:o?.charge?[o.charge]:[],isAllOpened:!0}):a.jsx("div",{children:"Charge not found"})};export{R as Charge};
@@ -0,0 +1 @@
1
+ import{r as i,bB as I,bI as z,j as e,P as U,bC as G,B as L,aC as _,E as $,aE as D,w as N,dr as q,b4 as J,V as Q,ds as X,bE as x,hE as Y,bF as O,bG as P,bH as V,en as E,at as p,a2 as Z,Y as j,Z as g,_ as b,$ as y,bU as K,bV as ee,bW as se}from"./index-rI994S3C.js";import{u as ae}from"./use-url-query-CqWra6gD.js";import{a as te}from"./update-accountant-status-zL6vnwU9.js";import{P as ne}from"./modal-BXR_xgUm.js";import{F as oe}from"./funnel-Cfb9Pxmr.js";import{s as re}from"./sub-CEXBz_OW.js";import{M as A}from"./MultiSelect-DBeIExB5.js";function le(a){return!a||I(a)?null:encodeURIComponent(JSON.stringify(a))}const ce=[{value:D.AbsAmount,label:"Abs Amount"},{value:D.Amount,label:"Amount"},{value:D.Date,label:"Date"}],ie=[{label:"All",value:E.All},{label:"Income",value:E.Income},{label:"Expense",value:E.Expense}];function de({filter:a,setFilter:u,closeModal:c}){const{userContext:h}=i.useContext(_),o=$({defaultValues:{byOwners:h?.context.adminBusinessId?[h.context.adminBusinessId]:void 0,sortBy:{field:D.Date,asc:!1},toAnyDate:N(new Date,"yyyy-MM-dd"),fromAnyDate:N(re(new Date,{years:1}),"yyyy-MM-dd"),...a}}),{control:r,handleSubmit:k,watch:C}=o,[f,S]=i.useState(a.sortBy?.asc??!1),[d,m]=i.useState(!!a.sortBy?.field),{selectableFinancialEntities:F,fetching:t}=q(),{selectableTags:v,fetching:B}=J(),T=C("sortBy.field");i.useEffect(()=>{T&&!d?m(!0):!T&&d&&m(!1)},[T,d]);const R=s=>{f!=null&&s.sortBy?.field&&(s.sortBy.asc=f),u(s),c()};function W(){u({}),S(!1),c()}return e.jsxs(e.Fragment,{children:[t?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsx(Q,{...o,children:e.jsxs("form",{onSubmit:k(R),children:[e.jsxs(X,{cols:2,children:[e.jsx(x,{name:"byOwners",control:r,defaultValue:a.byOwners,render:({field:s,fieldState:n})=>e.jsx(A,{...s,data:F,value:s.value??[],disabled:t,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message,withinPortal:!0})}),e.jsx(x,{name:"byBusinesses",control:r,defaultValue:a.byBusinesses,render:({field:s,fieldState:n})=>e.jsx(A,{...s,data:F,value:s.value??[],disabled:t,label:"Financial Entities",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message,withinPortal:!0})}),e.jsx(x,{name:"byTags",control:r,defaultValue:a.byTags,render:({field:s,fieldState:n})=>e.jsx(A,{...s,data:v,itemComponent:Y,value:s.value??[],disabled:B,label:"Tags",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message,withinPortal:!0,filter:(l,w,M)=>M.label?.toLowerCase().includes(l.toLowerCase().trim())||M.description?.toLowerCase().includes(l.toLowerCase().trim())})}),e.jsx(x,{name:"fromAnyDate",control:r,defaultValue:a.fromAnyDate,rules:{pattern:{value:O,message:"Date must be im format yyyy-mm-dd"}},render:({field:s,fieldState:n})=>e.jsx(P,{...s,onChange:l=>{const w=l?typeof l=="string"?l:N(l,"yyyy-MM-dd"):void 0;w!==s.value&&s.onChange(w)},value:s.value?new Date(s.value):void 0,error:n.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(x,{name:"toAnyDate",control:r,defaultValue:a.toAnyDate,rules:{pattern:{value:O,message:"Date must be im format yyyy-mm-dd"}},render:({field:s,fieldState:n})=>e.jsx(P,{...s,onChange:l=>{const w=l?typeof l=="string"?l:N(l,"yyyy-MM-dd"):void 0;w!==s.value&&s.onChange(w)},value:s.value?new Date(s.value):void 0,error:n.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(x,{name:"chargesType",control:r,defaultValue:a.chargesType,render:({field:s,fieldState:n})=>e.jsx(V,{...s,data:ie,value:s.value??E.All,disabled:t,label:"Charge Type",placeholder:"Filter income/expense",maxDropdownHeight:160,error:n.error?.message,withinPortal:!0})}),e.jsx(x,{name:"sortBy.field",control:r,defaultValue:a.sortBy?.field??D.Date,render:({field:s,fieldState:n})=>e.jsx(V,{...s,data:ce,label:"Field to sort by",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message,rightSectionProps:{style:{width:"5rem"}},withinPortal:!0,rightSection:e.jsxs("div",{className:"flex flex-row items-center gap-1",children:[e.jsx(p,{defaultChecked:a.sortBy?.asc??!1,checked:f??!1,disabled:!d,onCheckedChange:S}),e.jsx("span",{className:"text-xs",children:f?"ASC":"DESC"})]})})}),e.jsx(x,{name:"accountantStatus",control:r,defaultValue:a.accountantStatus,render:({field:s,fieldState:n})=>e.jsx(A,{...s,value:s.value??[],itemComponent:H,data:Object.values(te),disabled:t,label:"Accountant Status",placeholder:"All",maxDropdownHeight:160,error:n.error?.message,withinPortal:!0})}),e.jsxs("div",{className:"flex flex-col gap-2 mt-4 rounded-lg border p-3 shadow-sm space-y-2",children:[e.jsx(Z,{children:"Missing Information:"}),e.jsx(j,{control:o.control,name:"withoutInvoice",render:({field:s})=>e.jsxs(g,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(b,{children:"Without Invoice"})}),e.jsx(y,{children:e.jsx(p,{defaultChecked:a.withoutInvoice??!1,onCheckedChange:s.onChange})})]})}),e.jsx(j,{control:o.control,name:"withoutReceipt",render:({field:s})=>e.jsxs(g,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(b,{children:"Without Receipts"})}),e.jsx(y,{children:e.jsx(p,{defaultChecked:a.withoutReceipt??!1,onCheckedChange:s.onChange})})]})}),e.jsx(j,{control:o.control,name:"withoutDocuments",render:({field:s})=>e.jsxs(g,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(b,{children:"Without Documents"})}),e.jsx(y,{children:e.jsx(p,{defaultChecked:a.withoutDocuments??!1,onCheckedChange:s.onChange})})]})}),e.jsx(j,{control:o.control,name:"withOpenDocuments",render:({field:s})=>e.jsxs(g,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(b,{children:"With Open Documents"})}),e.jsx(y,{children:e.jsxs(K,{children:[e.jsx(ee,{children:e.jsx(p,{defaultChecked:a.withOpenDocuments??!1,onCheckedChange:s.onChange})}),e.jsx(se,{children:e.jsx("p",{children:"Show only charges with documents that are currently open"})})]})})]})}),e.jsx(j,{control:o.control,name:"withoutTransactions",render:({field:s})=>e.jsxs(g,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(b,{children:"Without Transactions"})}),e.jsx(y,{children:e.jsx(p,{defaultChecked:a.withoutTransactions??!1,onCheckedChange:s.onChange})})]})}),e.jsx(j,{control:o.control,name:"unbalanced",render:({field:s})=>e.jsxs(g,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(b,{children:"Unbalanced businesses"})}),e.jsx(y,{children:e.jsx(p,{defaultChecked:a.unbalanced??!1,onCheckedChange:s.onChange})})]})}),e.jsx(j,{control:o.control,name:"withoutLedger",render:({field:s})=>e.jsxs(g,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(b,{children:"Without ledger"})}),e.jsx(y,{children:e.jsx(p,{defaultChecked:a.withoutLedger??!1,onCheckedChange:s.onChange})})]})})]})]}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",disabled:t||B,className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Filter"}),e.jsx("button",{type:"button",className:"text-white bg-orange-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-orange-600 rounded-sm text-lg",onClick:W,children:"Clear"}),e.jsx("button",{type:"button",className:"text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:c,children:"Cancel"})]})]})})]})}function be({filter:a={},setFilter:u,activePage:c,setPage:h,totalPages:o=1,initiallyOpened:r=!1}){const[k,C]=i.useState(r),[f,S]=i.useState(!I(a)),{get:d,set:m}=ae();i.useEffect(()=>{const t=c>0?c.toFixed(0):null,v=d("page");t!==v&&m("page",t)},[c,d,m]),i.useEffect(()=>{const t=le(a),v=d("chargesFilters");t!==v&&(m("chargesFilters",t),m("page"),h(0))},[a,d,m,h]);const F=i.useCallback(t=>{z(t,a)||(u(t),S(!I(t)))},[a,u]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(ne,{opened:k,onClose:()=>C(!1),content:e.jsx(de,{filter:a,setFilter:F,closeModal:()=>C(!1)}),modalSize:"xl"}),o>1&&e.jsx(U,{className:"flex-fit w-fit mx-0",currentPageIndex:c,onChange:h,totalPages:o}),e.jsx(G,{inline:!0,size:16,disabled:!f,children:e.jsx(L,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>C(!0),children:e.jsx(oe,{className:"size-5"})})})]})}const H=i.forwardRef(({bgColor:a,label:u,color:c,icon:h,...o},r)=>e.jsxs(L,{ref:r,...o,variant:"ghost",size:"sm",className:`h-7 p-0 ${a}`,title:u,children:[e.jsx(h,{className:`h-3.5 w-3.5 ${c}`}),u]}));H.displayName="AccountantStatusMultiSelectItem";export{be as C,ie as c};
@@ -1 +1 @@
1
- import{r as t,F as v,u as M,j as e,T as P,B as y,L as N,d as S,e as T,f as z}from"./index-DRqooPz9.js";import{u as W}from"./use-url-query-A8PE3FMA.js";import{C as b}from"./charges-filters-CYR6-jcu.js";import{M as w,C as E,T as O}from"./charges-table-zGkVW5or.js";import{P as k}from"./page-layout-Dp9Tr43G.js";import{P as B}from"./Progress-DE13gAJ5.js";import{P as R,a as V}from"./panel-top-open-lnF5tdL1.js";import"./update-accountant-status-Btcm95Uc.js";import"./modal-CPrQ9jQu.js";import"./funnel-B1ZA9LM9.js";import"./sub-764RJPt0.js";import"./addDays-DpkzPtfc.js";import"./subMonths-CZ2djAnO.js";import"./MultiSelect-DhEZHYxn.js";import"./toggle-expansion-button-BquTpOYj.js";import"./index-ciP7vurq.js";import"./similar-transactions-modal-DilkLkpx.js";import"./building-2-CWrl-iq9.js";import"./Table-rNmO5bBI.js";import"./summary-BvHHpnIR.js";import"./accordion-Air1oXnF.js";import"./deposits-transactions-table-Dhm74qLm.js";import"./Checkbox-DWmOT4mx.js";import"./data-table-column-header-DDRUwuwC.js";import"./eye-off-DtXkBVx1.js";const ge=()=>{const{setFiltersContext:m}=t.useContext(v),[n,h]=t.useState(!1),[r,l]=t.useState([]),{get:f}=W(),c=f("chargesFilters"),C=t.useMemo(()=>{if(c)try{return JSON.parse(decodeURIComponent(c))}catch{return}},[c]),[o,p]=t.useState(C),j=t.useCallback((s,F)=>{r.map(g=>g.id).includes(s)?l(r.filter(g=>g.id!==s)):l([...r,{id:s,onChange:F}])},[r]),[{data:a,fetching:d},u]=M({query:z,variables:{filters:o},pause:!0});function L(){l([])}const i=t.useMemo(()=>a?.chargesWithLedgerChanges?.length?a.chargesWithLedgerChanges[a.chargesWithLedgerChanges.length-1].progress:0,[a?.chargesWithLedgerChanges]),x=t.useCallback(s=>{p(s)},[p]);return t.useEffect(()=>{o&&u()},[o,u]),t.useEffect(()=>{m(e.jsxs("div",{className:"flex flex-row gap-x-5 items-center",children:[e.jsx(B,{value:i,label:`${i?.toFixed(2)}%`,size:"xl",animate:i<100,className:"min-w-52"}),e.jsx(b,{filter:o,setFilter:x,activePage:0,setPage:()=>{},initiallyOpened:!0}),e.jsx(P,{content:"Expand all accounts",children:e.jsx(y,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>h(s=>!s),children:n?e.jsx(R,{className:"size-5"}):e.jsx(V,{className:"size-5"})})}),e.jsx(w,{selected:r,resetMerge:L})]}))},[a,d,o,n,m,h,r,i,x]),e.jsx(k,{title:"Charges Ledger Validation",description:"Manage charges",children:d?e.jsx(N,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs(e.Fragment,{children:[e.jsx(E,{toggleMergeCharge:j,mergeSelectedCharges:new Set(r.map(s=>s.id)),data:a?.chargesWithLedgerChanges.filter(s=>!!s.charge).map(s=>s.charge)??[],isAllOpened:n}),e.jsxs("div",{className:"flex flex-row justify-center my-2",children:[i>0&&i<100&&e.jsx(S,{}),i===100&&!a?.chargesWithLedgerChanges.filter(s=>!!s.charge).length&&e.jsx(O,{radius:"xl",size:"xl",color:"green",children:e.jsx(T,{})})]})]})})};export{ge as ChargesLedgerValidation};
1
+ import{r as t,F as v,u as M,j as e,T as P,B as y,L as N,d as S,e as T,f as z}from"./index-rI994S3C.js";import{u as W}from"./use-url-query-CqWra6gD.js";import{C as b}from"./charges-filters-CFCAP-bP.js";import{M as w,C as E,T as O}from"./charges-table-BJtpvXfL.js";import{P as k}from"./page-layout-DMGj5xhW.js";import{P as B}from"./Progress---sZILQb.js";import{P as R,a as V}from"./panel-top-open-Bf39HBrp.js";import"./update-accountant-status-zL6vnwU9.js";import"./modal-BXR_xgUm.js";import"./funnel-Cfb9Pxmr.js";import"./sub-CEXBz_OW.js";import"./addDays-DTiBTTns.js";import"./subMonths-DY4HlBVa.js";import"./MultiSelect-DBeIExB5.js";import"./toggle-expansion-button-Y2eS7nqg.js";import"./index-C7p19nIa.js";import"./similar-transactions-modal-DX3CPrMo.js";import"./building-2-CMKd_bU8.js";import"./Table-BQv3frL8.js";import"./summary-CPKS_69D.js";import"./accordion-Bn08_4fN.js";import"./deposits-transactions-table-2rtRFZgK.js";import"./Checkbox-Dmuz3t7B.js";import"./data-table-column-header-CZ1dXiU0.js";import"./eye-off-Buv7eciz.js";const ge=()=>{const{setFiltersContext:m}=t.useContext(v),[n,h]=t.useState(!1),[r,l]=t.useState([]),{get:f}=W(),c=f("chargesFilters"),C=t.useMemo(()=>{if(c)try{return JSON.parse(decodeURIComponent(c))}catch{return}},[c]),[o,p]=t.useState(C),j=t.useCallback((s,F)=>{r.map(g=>g.id).includes(s)?l(r.filter(g=>g.id!==s)):l([...r,{id:s,onChange:F}])},[r]),[{data:a,fetching:d},u]=M({query:z,variables:{filters:o},pause:!0});function L(){l([])}const i=t.useMemo(()=>a?.chargesWithLedgerChanges?.length?a.chargesWithLedgerChanges[a.chargesWithLedgerChanges.length-1].progress:0,[a?.chargesWithLedgerChanges]),x=t.useCallback(s=>{p(s)},[p]);return t.useEffect(()=>{o&&u()},[o,u]),t.useEffect(()=>{m(e.jsxs("div",{className:"flex flex-row gap-x-5 items-center",children:[e.jsx(B,{value:i,label:`${i?.toFixed(2)}%`,size:"xl",animate:i<100,className:"min-w-52"}),e.jsx(b,{filter:o,setFilter:x,activePage:0,setPage:()=>{},initiallyOpened:!0}),e.jsx(P,{content:"Expand all accounts",children:e.jsx(y,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>h(s=>!s),children:n?e.jsx(R,{className:"size-5"}):e.jsx(V,{className:"size-5"})})}),e.jsx(w,{selected:r,resetMerge:L})]}))},[a,d,o,n,m,h,r,i,x]),e.jsx(k,{title:"Charges Ledger Validation",description:"Manage charges",children:d?e.jsx(N,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs(e.Fragment,{children:[e.jsx(E,{toggleMergeCharge:j,mergeSelectedCharges:new Set(r.map(s=>s.id)),data:a?.chargesWithLedgerChanges.filter(s=>!!s.charge).map(s=>s.charge)??[],isAllOpened:n}),e.jsxs("div",{className:"flex flex-row justify-center my-2",children:[i>0&&i<100&&e.jsx(S,{}),i===100&&!a?.chargesWithLedgerChanges.filter(s=>!!s.charge).length&&e.jsx(O,{radius:"xl",size:"xl",color:"green",children:e.jsx(T,{})})]})]})})};export{ge as ChargesLedgerValidation};