@accounter/client 0.0.9-alpha-20251231083050-a0e737863ca2a9fa68506d15357e55d9287972cb → 0.0.9-alpha-20251231163357-33d4c33fec5e21dad2e04d1f293f6248d2550588

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 (84) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/assets/{Checkbox-DQnX-IHw.js → Checkbox-B9Jxe8oL.js} +1 -1
  3. package/dist/assets/{MultiSelect-1WINlkTu.js → MultiSelect-B-TAg0CU.js} +1 -1
  4. package/dist/assets/{Progress-CP4CpjLB.js → Progress-D_6NsFIY.js} +1 -1
  5. package/dist/assets/{Table-3LUzGF-Y.js → Table-BERLrufH.js} +1 -1
  6. package/dist/assets/{Typography-DjNQi5FL.js → Typography-BK_FOVsg.js} +1 -1
  7. package/dist/assets/{YearPickerInput-B4UXt2Dq.js → YearPickerInput-CCSx1WAA.js} +1 -1
  8. package/dist/assets/{accordion-3APui6eL.js → accordion-Da7XFLSI.js} +1 -1
  9. package/dist/assets/{accountant-approvals-CBdRRVCx.js → accountant-approvals-DtDOIAls.js} +1 -1
  10. package/dist/assets/{accounter-table-DZctE2Ds.js → accounter-table-gSJDWOOH.js} +1 -1
  11. package/dist/assets/{addDays-B6KOnr9d.js → addDays-CPSgiY2b.js} +1 -1
  12. package/dist/assets/{all-charges-EZZPjoH1.js → all-charges-BgCCH1cQ.js} +1 -1
  13. package/dist/assets/{arrow-up-down-DAgx4j1v.js → arrow-up-down-GSDmNUa7.js} +1 -1
  14. package/dist/assets/{building-2-DeX_sgix.js → building-2-BL0OoCnC.js} +1 -1
  15. package/dist/assets/{business-BzUivfwE.js → business-BMpN918H.js} +1 -1
  16. package/dist/assets/{business-extended-info-B2Xyih3c.js → business-extended-info-DCMU2tJH.js} +1 -1
  17. package/dist/assets/{business-header-CLdljOB4.js → business-header-CbO0kf2S.js} +1 -1
  18. package/dist/assets/{business-ledger-filters-DSuUAhpz.js → business-ledger-filters-BwSk0IIQ.js} +1 -1
  19. package/dist/assets/{business-ledger-single-CbRGarkQ.js → business-ledger-single-nfPMvgv7.js} +1 -1
  20. package/dist/assets/{business-trip-BGoFPcCG.js → business-trip-DJEE3jkw.js} +1 -1
  21. package/dist/assets/{charge-8pPIe-1K.js → charge-1v-MCcSM.js} +1 -1
  22. package/dist/assets/{charges-filters-DX5qB120.js → charges-filters-DUUu6SXt.js} +1 -1
  23. package/dist/assets/{charges-ledger-validation-CsvcJrF1.js → charges-ledger-validation-uQuXCk2f.js} +1 -1
  24. package/dist/assets/{charges-table-BqKHuWkm.js → charges-table-BhJhWeOk.js} +1 -1
  25. package/dist/assets/{chart-DEoAP57x.js → chart-7mkwUtAi.js} +1 -1
  26. package/dist/assets/{contracts-DiTPYe_K.js → contracts-Cpj2Httj.js} +1 -1
  27. package/dist/assets/{data-table-column-header-B3XsejWx.js → data-table-column-header-CXNAhFg7.js} +1 -1
  28. package/dist/assets/{data-table-pagination-Dnwks2up.js → data-table-pagination-CMScSWcq.js} +1 -1
  29. package/dist/assets/{deposits-transactions-table-u4MVVhDE.js → deposits-transactions-table-fTRP0dK3.js} +1 -1
  30. package/dist/assets/{download-csv-button-Cd0rXY7Z.js → download-csv-button-Dv6hYXH3.js} +1 -1
  31. package/dist/assets/{editable-business-trip-CFtHoHgD.js → editable-business-trip-CMSRoWTM.js} +1 -1
  32. package/dist/assets/{eye-off-CqyrLNH2.js → eye-off-DarXeCrB.js} +1 -1
  33. package/dist/assets/{funnel-Cq2G1Do_.js → funnel-Bz95UZzU.js} +1 -1
  34. package/dist/assets/{index-C-IbD3J_.js → index-B1C9fgFh.js} +1 -1
  35. package/dist/assets/{index-D6-auP1L.js → index-B5PdCsXq.js} +1 -1
  36. package/dist/assets/{index-CNjMTN0Q.js → index-BgwHW4Nd.js} +1 -1
  37. package/dist/assets/{index-BpEJ93C0.js → index-BhHmBzLB.js} +1 -1
  38. package/dist/assets/{index-B11eQ9zE.js → index-BntKRswi.js} +1 -1
  39. package/dist/assets/{index-DNrPzTVq.js → index-Bxti1KtB.js} +1 -1
  40. package/dist/assets/{index-DrZ1x-RS.js → index-C2Vf3-xU.js} +1 -1
  41. package/dist/assets/{index-BglNOY-K.js → index-C6o95wWk.js} +1 -1
  42. package/dist/assets/{index-B_k8HoAb.js → index-CAG0Njk5.js} +1 -1
  43. package/dist/assets/{index-Dnh3vQj-.js → index-CCsnewX5.js} +1 -1
  44. package/dist/assets/{index-sbjskCmO.js → index-CK0OVeXl.js} +1 -1
  45. package/dist/assets/{index-B4C4roog.js → index-CdWHicsS.js} +1 -1
  46. package/dist/assets/{index-CJ8ooPTa.js → index-CdtvgHIn.js} +1 -1
  47. package/dist/assets/{index-BnQa9D-p.js → index-CoJIQGuq.js} +1 -1
  48. package/dist/assets/{index-DVgehknF.js → index-D0ahdEKx.js} +1 -1
  49. package/dist/assets/{index-CP2Qb-hO.js → index-DCMzSE4I.js} +1 -1
  50. package/dist/assets/{index-iIbhlXwt.js → index-DCwv2bbD.js} +1 -1
  51. package/dist/assets/{index-BWWXDa6R.js → index-DMQlF8c3.js} +1 -1
  52. package/dist/assets/{index-B5cZSJnv.js → index-DdaA5b8b.js} +1 -1
  53. package/dist/assets/{index-D33ZDOgR.js → index-DuOuh1g3.js} +1 -1
  54. package/dist/assets/{index-O1zv8-qd.js → index-L2Li0C19.js} +1 -1
  55. package/dist/assets/{index-MwNvVanh.js → index-Muu0tWiz.js} +1 -1
  56. package/dist/assets/{index-DU027pPm.js → index-OxXg95fa.js} +1 -1
  57. package/dist/assets/{index-CHXDfsUO.js → index-W0pymfZB.js} +101 -118
  58. package/dist/assets/{index-B6b9Rw5K.js → index-XRdd531Y.js} +1 -1
  59. package/dist/assets/{index-Dh8bLiLk.js → index-b_B-JklH.js} +1 -1
  60. package/dist/assets/{index.es-_6Kbkkwx.js → index.es-CdKo0-du.js} +1 -1
  61. package/dist/assets/{insert-business-trip-modal-K2wc3hgW.js → insert-business-trip-modal-B2i2hxuI.js} +1 -1
  62. package/dist/assets/issue-document-DOqWmjJa.js +1 -0
  63. package/dist/assets/{list-plus-B1XUUi79.js → list-plus-BAPfjvM-.js} +1 -1
  64. package/dist/assets/{login-page-lqDJk0_E.js → login-page-DOGQiLGy.js} +1 -1
  65. package/dist/assets/{match-document-modal-CtJxEQcv.js → match-document-modal-DarKQJhx.js} +1 -1
  66. package/dist/assets/{missing-info-charges-CK_ic2ZJ.js → missing-info-charges-DYYePYlA.js} +1 -1
  67. package/dist/assets/{modal-CmNyWfb_.js → modal-r_uBjTC6.js} +1 -1
  68. package/dist/assets/{modify-contract-dialog-C-wdFvim.js → modify-contract-dialog-Zl-TSfnV.js} +1 -1
  69. package/dist/assets/{page-layout-ClvS18JI.js → page-layout-BB7wmuSc.js} +1 -1
  70. package/dist/assets/{page-not-found-Bu7CSbYq.js → page-not-found-DvEDbWj9.js} +1 -1
  71. package/dist/assets/{panel-top-open-ZI73OpgC.js → panel-top-open-fWlzHeN-.js} +1 -1
  72. package/dist/assets/{report-commentary-row-DYuYv4BH.js → report-commentary-row-DkKcwkwG.js} +1 -1
  73. package/dist/assets/{save-BDQNsoKR.js → save-Da7Z0tox.js} +1 -1
  74. package/dist/assets/{similar-transactions-modal-DVKLWVDl.js → similar-transactions-modal-BfVUcf_3.js} +1 -1
  75. package/dist/assets/{sub-Cl3G90K_.js → sub-D2MOo6Sz.js} +1 -1
  76. package/dist/assets/subMonths-BN0YWd5Y.js +1 -0
  77. package/dist/assets/{summary-3HnUK0c0.js → summary-DPh6Auzq.js} +1 -1
  78. package/dist/assets/{toggle-expansion-button-B4wRWu9m.js → toggle-expansion-button-CGUSw3Av.js} +1 -1
  79. package/dist/assets/{use-issue-monthly-documents-BuvBKJJJ.js → use-issue-monthly-documents-BK60cgya.js} +1 -1
  80. package/dist/assets/{use-url-query-Cy2jrPOP.js → use-url-query-Bw2WqiC_.js} +1 -1
  81. package/dist/index.html +1 -1
  82. package/package.json +2 -2
  83. package/dist/assets/issue-document-BCOsBdUg.js +0 -1
  84. package/dist/assets/subMonths-SBqdI_BY.js +0 -1
@@ -1,2 +1,2 @@
1
- import{v as ce,w as Qe,u as le,S as Ks,r as v,j as e,D as Te,x as Be,y as Ys,c as Ze,g as Ee,t as X,i as Pe,U as Xs,z as Oe,E as Je,G as fe,H as Ce,J as Q,K as Z,N as As,O as J,Q as ee,V as Le,W as se,X as de,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 te,a4 as ie,a5 as es,a6 as Qs,a7 as xe,a8 as ss,a9 as ns,aa as ue,ab as M,ac as as,ad as Zs,ae as q,af as Js,ag as re,ah as en,ai as pe,R as Is,aj as sn,ak as nn,al as ts,am as is,an as rs,ao as ws,ap as Ds,aq as ks,ar as Ss,as as Ts,at as oe,au as Bs,av as Es,aw as Ps,ax as an,ay as Os,az as Ue,aA as tn,aB as rn,aC as cs,aD as cn,P as ln,aE as on,aF as H,aG as os,aH as Me,aI as dn,aJ as mn,aK as un,aL as Ls,aM as xn,aN as hn,aO as pn,aP as jn,aQ as gn,aR as Fs,aS as fn,aT as P,aU as qe,aV as Ms,aW as He,aX as ds,aY as vn,aZ as _s,a_ as yn,a$ as Nn,b0 as bn,b1 as me,b2 as Cn,b3 as An,b4 as In,b5 as Ge,b6 as wn,b7 as Dn,b8 as kn,b9 as Sn,ba as Tn,bb as ms,bc as Bn,bd as En,be as Pn,bf as On,bg as us,bh as Ln,bi as Fn,bj as Mn,bk as _n,F as Rn,bl as zn,bm as Vn,bn as ne,bo as $n,bp as Un,bq as Y,br as qn,a as Hn,b as Gn,bs as Wn}from"./index-CHXDfsUO.js";import{S as ls}from"./save-BDQNsoKR.js";import{B as De}from"./building-2-DeX_sgix.js";import{B as Kn}from"./business-extended-info-B2Xyih3c.js";import{B as Yn}from"./business-header-CLdljOB4.js";import{S as Xn,C as Qn,L as Zn,W as Jn}from"./charges-table-BqKHuWkm.js";import{i as ea,D as sa,f as na,E as aa,L as _e,a as we,C as ta,A as ia,b as ve,c as ra,d as We,h as ca,e as la,g as Rs,u as oa,G as da,j as xs,k as ma,X as zs,Y as Vs,l as ua,m as xa,R as ha,n as pa,o as ja,p as ga}from"./chart-DEoAP57x.js";import{M as Ke,s as fa,a as va}from"./modify-contract-dialog-C-wdFvim.js";import{u as ya,E as Na}from"./use-issue-monthly-documents-BuvBKJJJ.js";import{s as ba}from"./subMonths-SBqdI_BY.js";import{E as Ca,T as Aa}from"./index-O1zv8-qd.js";import{A as Ia,a as Re,b as hs,c as ps}from"./accordion-3APui6eL.js";import"./data-table-column-header-B3XsejWx.js";import"./eye-off-CqyrLNH2.js";import"./download-csv-button-Cd0rXY7Z.js";import"./toggle-expansion-button-B4wRWu9m.js";import"./panel-top-open-ZI73OpgC.js";import"./Table-3LUzGF-Y.js";import"./summary-3HnUK0c0.js";import"./list-plus-B1XUUi79.js";import"./deposits-transactions-table-u4MVVhDE.js";import"./Checkbox-DQnX-IHw.js";import"./sequential-CAnleQny.js";import"./similar-transactions-modal-DVKLWVDl.js";import"./addDays-B6KOnr9d.js";const wa=[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["line",{x1:"12",x2:"12.01",y1:"17",y2:"17",key:"io3f8k"}]],Da=ce("badge-question-mark",wa);const ka=[["path",{d:"M11.767 19.089c4.924.868 6.14-6.025 1.216-6.894m-1.216 6.894L5.86 18.047m5.908 1.042-.347 1.97m1.563-8.864c4.924.869 6.14-6.025 1.215-6.893m-1.215 6.893-3.94-.694m5.155-6.2L8.29 4.26m5.908 1.042.348-1.97M7.48 20.364l3.126-17.727",key:"yr8idg"}]],Sa=ce("bitcoin",ka);const Ta=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],Ba=ce("chart-line",Ta);const Ea=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],ze=ce("circle-check",Ea);const Pa=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]],js=ce("circle-slash",Pa);const Oa=[["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"}]],ke=ce("dollar-sign",Oa);const La=[["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"}]],Fa=ce("file-check",La);const Ma=[["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"}]],_a=ce("fullscreen",Ma);const Ra=[["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"}]],za=ce("notebook",Ra);const Va=[["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"}]],$a=ce("plug",Va);function Ua(s){return Qe(s,"yyyy-MM-dd")}function qa({businessId:s,tagIds:n,description:a,open:t,onOpenChange:c,onClose:o}){const[{data:i,fetching:l},x]=le({pause:!0,query:Ks,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(Te,{open:m,onOpenChange:d,children:e.jsx(Be,{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(Ys,{fallback:e.jsx("div",{children:"Error fetching similar charges"}),children:l?e.jsx(Ze,{}):n||a?e.jsx(Xn,{data:i?.similarChargesByBusiness??[],tagIds:n,description:a,onOpenChange:d,title:"Similar Charges by Business"}):null})})})}const Ha="updateAdminBusiness",Ga=()=>{const[{fetching:s},n]=Ee(Xs),a=v.useCallback(async t=>{const c=`Error updating admin business ID [${t.adminBusinessId}]`,o=`${Ha}-${t.adminBusinessId}`;X.loading("Updating admin business",{id:o});try{const i=await n(t),l=Pe(i,c,o,"updateAdminBusiness");if(l)return X.success("Success",{id:o,description:"Admin Business Updated"}),l.updateAdminBusiness}catch(i){console.error(`${c}: ${i}`),X.error("Error",{id:o,description:c,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,updateAdminBusiness:a}},Ve=xe({year:as().min(2e3).max(2100),id:M().min(1,{message:"ID is required"})}),Wa=xe({registrationDate:M().min(1,{message:"Business Registration Start Date is required"}),withholdingTaxAnnualIds:ue(Ve),withholdingTaxCompanyId:M().min(1,{message:"Withholding Tax Company ID is required"}),socialSecurityEmployerIds:ue(Ve),socialSecurityDeductionsId:M().min(1,{message:"Social Security Deductions ID is required"}),taxAdvancesAnnualIds:ue(Ve),taxAdvancesRates:ue(xe({date:Zs(),rate:as().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(ss,{size:12})}),e.jsx("span",{children:n})]});function gs(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 Ka(s){return{registrationDate:s.registrationDate?Ua(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 Ya({data:s,refetchBusiness:n}){const a=fe(Qs,s),[t,c]=v.useState(gs(a)),{updateAdminBusiness:o,fetching:i}=Ga(),l=Oe({resolver:Je(Wa),defaultValues:t}),x=async w=>{if(!a)return;const D=ns(w,l.formState.dirtyFields);if(!D)return;const z=Ka(D);await o({adminBusinessId:a.id,fields:z}),n?.()};v.useEffect(()=>{if(a){const w=gs(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:K,remove:r}=Ce({control:l.control,name:"taxAdvancesRates"}),L=()=>{K({date:Qe(new Date,"yyyy-MM-dd"),rate:0})},U=w=>{r(w)};return e.jsxs(Q,{children:[e.jsxs(Z,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(As,{className:"h-5 w-5 text-primary"}),e.jsx(J,{children:"Admin Business Configuration"})]}),e.jsx(ee,{children:"Tax and registration information for the business operating this application"})]}),e.jsx(Le,{...l,children:e.jsxs("form",{onSubmit:l.handleSubmit(x),className:"space-y-6",children:[e.jsx(se,{children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx(Ne,{href:ye.VAT,children:"VAT"}),e.jsx(de,{className:"md:col-span-2"}),e.jsx(Ne,{href:ye.TAX_ADVANCES,children:"Tax Advances"}),e.jsx(de,{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(te,{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(ie,{className:"size-4"})})]},w.id))})]}),e.jsx(de,{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(te,{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(ie,{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(te,{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(ie,{className:"size-4"})})]},w.id))})]}),e.jsx(de,{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(te,{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(ie,{className:"size-4"})})]},w.id))})]}),e.jsx(de,{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(es,{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(ls,{className:"h-4 w-4"}),"Save Changes"]})})]})})]})}const Xa=s=>{switch(s){case q.BankAccount:return e.jsx(De,{className:"h-5 w-5"});case q.CreditCard:return e.jsx(Js,{className:"h-5 w-5"});case q.CryptoWallet:return e.jsx(Sa,{className:"h-5 w-5"});case q.BankDepositAccount:return e.jsx(De,{className:"h-5 w-5"});case q.ForeignSecurities:return e.jsx(De,{className:"h-5 w-5"});default:return e.jsx(Da,{className:"h-5 w-5"})}},$s=s=>{switch(s){case q.BankAccount:return"Bank Account";case q.CreditCard:return"Credit Card";case q.CryptoWallet:return"Crypto Wallet";case q.BankDepositAccount:return"Bank Deposit Account";case q.ForeignSecurities:return"Foreign Securities";default:return"Unknown Account Type"}};function Qa({account:s,handleOpenModal:n}){return e.jsxs(Q,{children:[e.jsx(Z,{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:Xa(s.type)}),e.jsxs("div",{children:[e.jsxs(J,{className:"text-lg",children:[s.name,s.name===s.number?"":` (${s.number})`]}),e.jsxs(ee,{className:"flex items-center gap-2 mt-1",children:[e.jsx(re,{variant:"outline",children:$s(s.type)}),!s.isBusiness&&e.jsx(re,{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(en,{className:"h-4 w-4","aria-hidden":"true"})})})]})}),e.jsxs(se,{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(pe,{to:Is.TAX_CATEGORIES,target:"_blank",rel:"noreferrer",onClick:t=>t.stopPropagation(),children:e.jsxs(re,{variant:"secondary",className:"text-xs",children:[a.currency," → ",a.taxCategory.name]})},a.currency))})]}),s.type===q.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 Za="createFinancialAccount",Ja=()=>{const[{fetching:s},n]=Ee(sn),a=v.useCallback(async t=>{const c=`Error creating new account "${t.input.name}"`,o=`${Za}-${t.input.name}`;X.loading("Creating account",{id:o});try{const i=await n(t);Pe(i,c,o)&&X.success("Success",{id:o,description:`Financial Account ${t.input.name} was successfully created`})}catch(i){console.error(`${c}: ${i}`),X.error("Error",{id:o,description:c,duration:1e5,closeButton:!0})}},[n]);return{creating:s,createFinancialAccount:a}},et="updateFinancialAccount",st=()=>{const[{fetching:s},n]=Ee(nn),a=v.useCallback(async t=>{const c=`Error updating financial account ID [${t.financialAccountId}]`,o=`${et}-${t.financialAccountId}`;X.loading("Updating financial account",{id:o});try{const i=await n(t),l=Pe(i,c,o,"updateFinancialAccount");if(l)return X.success("Success",{id:o,description:"Financial account updated"}),l.updateFinancialAccount}catch(i){console.error(`${c}: ${i}`),X.error("Error",{id:o,description:c,duration:1e5,closeButton:!0})}},[n]);return{updating:s,updateFinancialAccount:a}},nt=xe({currency:Ps(Object.values(Os),"Currency is required"),taxCategory:xe({id:tn("Tax category ID is required"),name:M().min(1,"Tax category name is required")})}),G=Es(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},as().int().optional()),at=xe({name:M().min(1,"Name is required"),number:M().min(1,"Account number is required"),isBusiness:an().default(!1).optional(),type:Ps(Object.values(q),"Account type is required"),currencies:ue(nt),bankNumber:G,branchNumber:G,iban:Es(s=>s===""?void 0:s,M().optional()),extendedBankNumber:G,partyPreferredIndication:G,partyAccountInvolvementCode:G,accountDealDate:G,accountUpdateDate:G,metegDoarNet:G,kodHarshaatPeilut:G,accountClosingReasonCode:G,accountAgreementOpeningDate:G,serviceAuthorizationDesc:M().optional(),branchTypeCode:G,mymailEntitlementSwitch:G,productLabel:M().optional()}),tt=v.forwardRef(function({ownerId:n,onDone:a},t){const[c,o]=v.useState(!1),[i,l]=v.useState(null),{createFinancialAccount:x,creating:d}=Ja(),{updateFinancialAccount:m,updating:h}=st(),u=Oe({resolver:Je(at),defaultValues:{name:"",number:"",isBusiness:!1,type:q.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?Ue.Business:Ue.Private,U=r.type===q.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:Os.Usd,taxCategory:{id:"",name:""}})},K=r=>{O.remove(r)};return e.jsx(Te,{open:c,onOpenChange:o,children:e.jsxs(Be,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ts,{children:[e.jsx(is,{children:i?"Edit Account":"New Account"}),e.jsx(rs,{children:i?"Update account details and settings":"Add a new financial account"})]}),e.jsx(Le,{...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(ws,{value:r.value,onValueChange:r.onChange,children:[e.jsx(Ds,{id:"type",children:e.jsx(ks,{})}),e.jsx(Ss,{children:Object.values(q).map(L=>e.jsx(Ts,{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(oe,{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(te,{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:()=>K(L),"aria-label":`Remove currency ${k(`currencies.${L}.currency`)||""}`,children:e.jsx(ie,{className:"h-4 w-4","aria-hidden":"true"})})]},r.id))})]}),k("type")===q.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(Bs,{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 it(s){return{id:s.id,name:s.name,number:s.number,isBusiness:s.privateOrBusiness===Ue.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 rt({adminId:s}){const[n,a]=v.useState([]),[{data:t,fetching:c},o]=le({query:rn,variables:{adminId:s}});v.useEffect(()=>{t?.financialAccountsByOwner&&a(t.financialAccountsByOwner?.map(it)??[])},[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(te,{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(Qa,{account:x,handleOpenModal:l},x.id))]}),e.jsx(tt,{ownerId:s,ref:i,onDone:()=>o()})]})}function ct({businessId:s}){return e.jsxs(Q,{children:[e.jsxs(Z,{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(J,{children:"Balance"}),e.jsx(ee,{children:"Business balance overview"})]})}),e.jsx(pe,{to:Is.BUSINESSES.DETAIL_LEDGER(s),children:e.jsx(T,{variant:"outline",size:"icon",children:e.jsx(_a,{})})})]}),e.jsx(se,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Kn,{businessID:s,filter:{}})})})]})}function lt({businessId:s}){const{userContext:n}=v.useContext(cs),[a,t]=v.useState(0),[{data:c,fetching:o}]=le({query:cn,variables:{filters:{byOwners:n?.context.adminBusinessId?[n.context.adminBusinessId]:void 0,sortBy:{field:on.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(Q,{children:[e.jsxs(Z,{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(J,{children:"Charges"}),e.jsx(ee,{children:"Recurring and one-time charges for this business"})]})}),i>1&&e.jsx(ln,{className:"flex-fit w-fit mx-0",currentPageIndex:a,onChange:t,totalPages:i})]}),e.jsx(se,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Qn,{data:l,isAllOpened:!1})})})]})}var ot=["type","layout","connectNulls","ref"],dt=["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 fs(s,n){if(s==null)return{};var a=mt(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 mt(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 vs(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 W(s){for(var n=1;n<arguments.length;n++){var a=arguments[n]!=null?arguments[n]:{};n%2?vs(Object(a),!0).forEach(function(t){ae(s,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(a)):vs(Object(a)).forEach(function(t){Object.defineProperty(s,t,Object.getOwnPropertyDescriptor(a,t))})}return s}function he(s){return pt(s)||ht(s)||xt(s)||ut()}function ut(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
1
+ import{v as ce,w as Qe,u as le,S as Ks,r as v,j as e,D as Te,x as Be,y as Ys,c as Ze,g as Ee,t as X,i as Pe,U as Xs,z as Oe,E as Je,G as fe,H as Ce,J as Q,K as Z,N as As,O as J,Q as ee,V as Le,W as se,X as de,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 te,a4 as ie,a5 as es,a6 as Qs,a7 as xe,a8 as ss,a9 as ns,aa as ue,ab as M,ac as as,ad as Zs,ae as q,af as Js,ag as re,ah as en,ai as pe,R as Is,aj as sn,ak as nn,al as ts,am as is,an as rs,ao as ws,ap as Ds,aq as ks,ar as Ss,as as Ts,at as oe,au as Bs,av as Es,aw as Ps,ax as an,ay as Os,az as Ue,aA as tn,aB as rn,aC as cs,aD as cn,P as ln,aE as on,aF as H,aG as os,aH as Me,aI as dn,aJ as mn,aK as un,aL as Ls,aM as xn,aN as hn,aO as pn,aP as jn,aQ as gn,aR as Fs,aS as fn,aT as P,aU as qe,aV as Ms,aW as He,aX as ds,aY as vn,aZ as _s,a_ as yn,a$ as Nn,b0 as bn,b1 as me,b2 as Cn,b3 as An,b4 as In,b5 as Ge,b6 as wn,b7 as Dn,b8 as kn,b9 as Sn,ba as Tn,bb as ms,bc as Bn,bd as En,be as Pn,bf as us,bg as On,bh as Ln,bi as Fn,bj as Mn,bk as _n,F as Rn,bl as zn,bm as Vn,bn as ne,bo as $n,bp as Un,bq as Y,br as qn,a as Hn,b as Gn,bs as Wn}from"./index-W0pymfZB.js";import{S as ls}from"./save-Da7Z0tox.js";import{B as De}from"./building-2-BL0OoCnC.js";import{B as Kn}from"./business-extended-info-DCMU2tJH.js";import{B as Yn}from"./business-header-CbO0kf2S.js";import{S as Xn,C as Qn,L as Zn,W as Jn}from"./charges-table-BhJhWeOk.js";import{i as ea,D as sa,f as na,E as aa,L as _e,a as we,C as ta,A as ia,b as ve,c as ra,d as We,h as ca,e as la,g as Rs,u as oa,G as da,j as xs,k as ma,X as zs,Y as Vs,l as ua,m as xa,R as ha,n as pa,o as ja,p as ga}from"./chart-7mkwUtAi.js";import{M as Ke,s as fa,a as va}from"./modify-contract-dialog-Zl-TSfnV.js";import{u as ya,E as Na}from"./use-issue-monthly-documents-BK60cgya.js";import{s as ba}from"./subMonths-BN0YWd5Y.js";import{E as Ca,T as Aa}from"./index-L2Li0C19.js";import{A as Ia,a as Re,b as hs,c as ps}from"./accordion-Da7XFLSI.js";import"./data-table-column-header-CXNAhFg7.js";import"./eye-off-DarXeCrB.js";import"./download-csv-button-Dv6hYXH3.js";import"./toggle-expansion-button-CGUSw3Av.js";import"./panel-top-open-fWlzHeN-.js";import"./Table-BERLrufH.js";import"./summary-DPh6Auzq.js";import"./list-plus-BAPfjvM-.js";import"./deposits-transactions-table-fTRP0dK3.js";import"./Checkbox-B9Jxe8oL.js";import"./sequential-CAnleQny.js";import"./similar-transactions-modal-BfVUcf_3.js";import"./addDays-CPSgiY2b.js";const wa=[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["line",{x1:"12",x2:"12.01",y1:"17",y2:"17",key:"io3f8k"}]],Da=ce("badge-question-mark",wa);const ka=[["path",{d:"M11.767 19.089c4.924.868 6.14-6.025 1.216-6.894m-1.216 6.894L5.86 18.047m5.908 1.042-.347 1.97m1.563-8.864c4.924.869 6.14-6.025 1.215-6.893m-1.215 6.893-3.94-.694m5.155-6.2L8.29 4.26m5.908 1.042.348-1.97M7.48 20.364l3.126-17.727",key:"yr8idg"}]],Sa=ce("bitcoin",ka);const Ta=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],Ba=ce("chart-line",Ta);const Ea=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],ze=ce("circle-check",Ea);const Pa=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]],js=ce("circle-slash",Pa);const Oa=[["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"}]],ke=ce("dollar-sign",Oa);const La=[["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"}]],Fa=ce("file-check",La);const Ma=[["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"}]],_a=ce("fullscreen",Ma);const Ra=[["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"}]],za=ce("notebook",Ra);const Va=[["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"}]],$a=ce("plug",Va);function Ua(s){return Qe(s,"yyyy-MM-dd")}function qa({businessId:s,tagIds:n,description:a,open:t,onOpenChange:c,onClose:o}){const[{data:i,fetching:l},x]=le({pause:!0,query:Ks,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(Te,{open:m,onOpenChange:d,children:e.jsx(Be,{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(Ys,{fallback:e.jsx("div",{children:"Error fetching similar charges"}),children:l?e.jsx(Ze,{}):n||a?e.jsx(Xn,{data:i?.similarChargesByBusiness??[],tagIds:n,description:a,onOpenChange:d,title:"Similar Charges by Business"}):null})})})}const Ha="updateAdminBusiness",Ga=()=>{const[{fetching:s},n]=Ee(Xs),a=v.useCallback(async t=>{const c=`Error updating admin business ID [${t.adminBusinessId}]`,o=`${Ha}-${t.adminBusinessId}`;X.loading("Updating admin business",{id:o});try{const i=await n(t),l=Pe(i,c,o,"updateAdminBusiness");if(l)return X.success("Success",{id:o,description:"Admin Business Updated"}),l.updateAdminBusiness}catch(i){console.error(`${c}: ${i}`),X.error("Error",{id:o,description:c,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,updateAdminBusiness:a}},Ve=xe({year:as().min(2e3).max(2100),id:M().min(1,{message:"ID is required"})}),Wa=xe({registrationDate:M().min(1,{message:"Business Registration Start Date is required"}),withholdingTaxAnnualIds:ue(Ve),withholdingTaxCompanyId:M().min(1,{message:"Withholding Tax Company ID is required"}),socialSecurityEmployerIds:ue(Ve),socialSecurityDeductionsId:M().min(1,{message:"Social Security Deductions ID is required"}),taxAdvancesAnnualIds:ue(Ve),taxAdvancesRates:ue(xe({date:Zs(),rate:as().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(ss,{size:12})}),e.jsx("span",{children:n})]});function gs(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 Ka(s){return{registrationDate:s.registrationDate?Ua(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 Ya({data:s,refetchBusiness:n}){const a=fe(Qs,s),[t,c]=v.useState(gs(a)),{updateAdminBusiness:o,fetching:i}=Ga(),l=Oe({resolver:Je(Wa),defaultValues:t}),x=async w=>{if(!a)return;const D=ns(w,l.formState.dirtyFields);if(!D)return;const z=Ka(D);await o({adminBusinessId:a.id,fields:z}),n?.()};v.useEffect(()=>{if(a){const w=gs(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:K,remove:r}=Ce({control:l.control,name:"taxAdvancesRates"}),L=()=>{K({date:Qe(new Date,"yyyy-MM-dd"),rate:0})},U=w=>{r(w)};return e.jsxs(Q,{children:[e.jsxs(Z,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(As,{className:"h-5 w-5 text-primary"}),e.jsx(J,{children:"Admin Business Configuration"})]}),e.jsx(ee,{children:"Tax and registration information for the business operating this application"})]}),e.jsx(Le,{...l,children:e.jsxs("form",{onSubmit:l.handleSubmit(x),className:"space-y-6",children:[e.jsx(se,{children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx(Ne,{href:ye.VAT,children:"VAT"}),e.jsx(de,{className:"md:col-span-2"}),e.jsx(Ne,{href:ye.TAX_ADVANCES,children:"Tax Advances"}),e.jsx(de,{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(te,{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(ie,{className:"size-4"})})]},w.id))})]}),e.jsx(de,{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(te,{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(ie,{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(te,{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(ie,{className:"size-4"})})]},w.id))})]}),e.jsx(de,{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(te,{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(ie,{className:"size-4"})})]},w.id))})]}),e.jsx(de,{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(es,{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(ls,{className:"h-4 w-4"}),"Save Changes"]})})]})})]})}const Xa=s=>{switch(s){case q.BankAccount:return e.jsx(De,{className:"h-5 w-5"});case q.CreditCard:return e.jsx(Js,{className:"h-5 w-5"});case q.CryptoWallet:return e.jsx(Sa,{className:"h-5 w-5"});case q.BankDepositAccount:return e.jsx(De,{className:"h-5 w-5"});case q.ForeignSecurities:return e.jsx(De,{className:"h-5 w-5"});default:return e.jsx(Da,{className:"h-5 w-5"})}},$s=s=>{switch(s){case q.BankAccount:return"Bank Account";case q.CreditCard:return"Credit Card";case q.CryptoWallet:return"Crypto Wallet";case q.BankDepositAccount:return"Bank Deposit Account";case q.ForeignSecurities:return"Foreign Securities";default:return"Unknown Account Type"}};function Qa({account:s,handleOpenModal:n}){return e.jsxs(Q,{children:[e.jsx(Z,{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:Xa(s.type)}),e.jsxs("div",{children:[e.jsxs(J,{className:"text-lg",children:[s.name,s.name===s.number?"":` (${s.number})`]}),e.jsxs(ee,{className:"flex items-center gap-2 mt-1",children:[e.jsx(re,{variant:"outline",children:$s(s.type)}),!s.isBusiness&&e.jsx(re,{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(en,{className:"h-4 w-4","aria-hidden":"true"})})})]})}),e.jsxs(se,{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(pe,{to:Is.TAX_CATEGORIES,target:"_blank",rel:"noreferrer",onClick:t=>t.stopPropagation(),children:e.jsxs(re,{variant:"secondary",className:"text-xs",children:[a.currency," → ",a.taxCategory.name]})},a.currency))})]}),s.type===q.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 Za="createFinancialAccount",Ja=()=>{const[{fetching:s},n]=Ee(sn),a=v.useCallback(async t=>{const c=`Error creating new account "${t.input.name}"`,o=`${Za}-${t.input.name}`;X.loading("Creating account",{id:o});try{const i=await n(t);Pe(i,c,o)&&X.success("Success",{id:o,description:`Financial Account ${t.input.name} was successfully created`})}catch(i){console.error(`${c}: ${i}`),X.error("Error",{id:o,description:c,duration:1e5,closeButton:!0})}},[n]);return{creating:s,createFinancialAccount:a}},et="updateFinancialAccount",st=()=>{const[{fetching:s},n]=Ee(nn),a=v.useCallback(async t=>{const c=`Error updating financial account ID [${t.financialAccountId}]`,o=`${et}-${t.financialAccountId}`;X.loading("Updating financial account",{id:o});try{const i=await n(t),l=Pe(i,c,o,"updateFinancialAccount");if(l)return X.success("Success",{id:o,description:"Financial account updated"}),l.updateFinancialAccount}catch(i){console.error(`${c}: ${i}`),X.error("Error",{id:o,description:c,duration:1e5,closeButton:!0})}},[n]);return{updating:s,updateFinancialAccount:a}},nt=xe({currency:Ps(Object.values(Os),"Currency is required"),taxCategory:xe({id:tn("Tax category ID is required"),name:M().min(1,"Tax category name is required")})}),G=Es(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},as().int().optional()),at=xe({name:M().min(1,"Name is required"),number:M().min(1,"Account number is required"),isBusiness:an().default(!1).optional(),type:Ps(Object.values(q),"Account type is required"),currencies:ue(nt),bankNumber:G,branchNumber:G,iban:Es(s=>s===""?void 0:s,M().optional()),extendedBankNumber:G,partyPreferredIndication:G,partyAccountInvolvementCode:G,accountDealDate:G,accountUpdateDate:G,metegDoarNet:G,kodHarshaatPeilut:G,accountClosingReasonCode:G,accountAgreementOpeningDate:G,serviceAuthorizationDesc:M().optional(),branchTypeCode:G,mymailEntitlementSwitch:G,productLabel:M().optional()}),tt=v.forwardRef(function({ownerId:n,onDone:a},t){const[c,o]=v.useState(!1),[i,l]=v.useState(null),{createFinancialAccount:x,creating:d}=Ja(),{updateFinancialAccount:m,updating:h}=st(),u=Oe({resolver:Je(at),defaultValues:{name:"",number:"",isBusiness:!1,type:q.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?Ue.Business:Ue.Private,U=r.type===q.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:Os.Usd,taxCategory:{id:"",name:""}})},K=r=>{O.remove(r)};return e.jsx(Te,{open:c,onOpenChange:o,children:e.jsxs(Be,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ts,{children:[e.jsx(is,{children:i?"Edit Account":"New Account"}),e.jsx(rs,{children:i?"Update account details and settings":"Add a new financial account"})]}),e.jsx(Le,{...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(ws,{value:r.value,onValueChange:r.onChange,children:[e.jsx(Ds,{id:"type",children:e.jsx(ks,{})}),e.jsx(Ss,{children:Object.values(q).map(L=>e.jsx(Ts,{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(oe,{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(te,{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:()=>K(L),"aria-label":`Remove currency ${k(`currencies.${L}.currency`)||""}`,children:e.jsx(ie,{className:"h-4 w-4","aria-hidden":"true"})})]},r.id))})]}),k("type")===q.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(Bs,{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 it(s){return{id:s.id,name:s.name,number:s.number,isBusiness:s.privateOrBusiness===Ue.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 rt({adminId:s}){const[n,a]=v.useState([]),[{data:t,fetching:c},o]=le({query:rn,variables:{adminId:s}});v.useEffect(()=>{t?.financialAccountsByOwner&&a(t.financialAccountsByOwner?.map(it)??[])},[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(te,{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(Qa,{account:x,handleOpenModal:l},x.id))]}),e.jsx(tt,{ownerId:s,ref:i,onDone:()=>o()})]})}function ct({businessId:s}){return e.jsxs(Q,{children:[e.jsxs(Z,{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(J,{children:"Balance"}),e.jsx(ee,{children:"Business balance overview"})]})}),e.jsx(pe,{to:Is.BUSINESSES.DETAIL_LEDGER(s),children:e.jsx(T,{variant:"outline",size:"icon",children:e.jsx(_a,{})})})]}),e.jsx(se,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Kn,{businessID:s,filter:{}})})})]})}function lt({businessId:s}){const{userContext:n}=v.useContext(cs),[a,t]=v.useState(0),[{data:c,fetching:o}]=le({query:cn,variables:{filters:{byOwners:n?.context.adminBusinessId?[n.context.adminBusinessId]:void 0,sortBy:{field:on.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(Q,{children:[e.jsxs(Z,{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(J,{children:"Charges"}),e.jsx(ee,{children:"Recurring and one-time charges for this business"})]})}),i>1&&e.jsx(ln,{className:"flex-fit w-fit mx-0",currentPageIndex:a,onChange:t,totalPages:i})]}),e.jsx(se,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Qn,{data:l,isAllOpened:!1})})})]})}var ot=["type","layout","connectNulls","ref"],dt=["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 fs(s,n){if(s==null)return{};var a=mt(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 mt(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 vs(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 W(s){for(var n=1;n<arguments.length;n++){var a=arguments[n]!=null?arguments[n]:{};n%2?vs(Object(a),!0).forEach(function(t){ae(s,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(a)):vs(Object(a)).forEach(function(t){Object.defineProperty(s,t,Object.getOwnPropertyDescriptor(a,t))})}return s}function he(s){return pt(s)||ht(s)||xt(s)||ut()}function ut(){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 xt(s,n){if(s){if(typeof s=="string")return Ye(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 Ye(s,n)}}function ht(s){if(typeof Symbol<"u"&&s[Symbol.iterator]!=null||s["@@iterator"]!=null)return Array.from(s)}function pt(s){if(Array.isArray(s))return Ye(s)}function Ye(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 jt(s,n){if(!(s instanceof n))throw new TypeError("Cannot call a class as a function")}function ys(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,qs(t.key),t)}}function gt(s,n,a){return n&&ys(s.prototype,n),a&&ys(s,a),Object.defineProperty(s,"prototype",{writable:!1}),s}function ft(s,n,a){return n=Se(n),vt(s,Us()?Reflect.construct(n,a||[],Se(s).constructor):n.apply(s,a))}function vt(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 yt(s)}function yt(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function Us(){try{var s=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Us=function(){return!!s})()}function Se(s){return Se=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(a){return a.__proto__||Object.getPrototypeOf(a)},Se(s)}function Nt(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&&Xe(s,n)}function Xe(s,n){return Xe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,c){return t.__proto__=c,t},Xe(s,n)}function ae(s,n,a){return n=qs(n),n in s?Object.defineProperty(s,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):s[n]=a,s}function qs(s){var n=bt(s,"string");return je(n)=="symbol"?n:n+""}function bt(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;jt(this,n);for(var t=arguments.length,c=new Array(t),o=0;o<t;o++)c[o]=arguments[o];return a=ft(this,n,[].concat(c)),ae(a,"state",{isAnimationFinished:!0,totalLength:0}),ae(a,"generateSimpleStrokeDasharray",function(i,l){return"".concat(l,"px ").concat(i-l,"px")}),ae(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(he(x.slice(0,I)),[h-k]);break}var B=p.length%2===0?[0,u]:[u];return[].concat(he(n.repeat(x,m)),he(p),B).map(function(_){return"".concat(_,"px")}).join(", ")}),ae(a,"id",oa("recharts-line-")),ae(a,"pathRef",function(i){a.mainCurve=i}),ae(a,"handleAnimationEnd",function(){a.setState({isAnimationFinished:!0}),a.props.onAnimationEnd&&a.props.onAnimationEnd()}),ae(a,"handleAnimationStart",function(){a.setState({isAnimationFinished:!1}),a.props.onAnimationStart&&a.props.onAnimationStart()}),a}return Nt(n,s),gt(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=na(m,aa);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 H.createElement(_e,p,h.map(function(I){return H.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 _=W(W(W({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 H.createElement(_e,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=fs(l,ot),u=W(W(W({},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 H.createElement(ta,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 H.createElement(ia,{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 K=O.length/l.length,r=l.map(function(z,N){var A=Math.floor(N*K);if(O[A]){var E=O[A],F=ve(E.x,z.x),Fe=ve(E.y,z.y);return W(W({},z),{},{x:F(R),y:Fe(R)})}if(I){var Gs=ve(k*2,z.x),Ws=ve(B/2,z.y);return W(W({},z),{},{x:Gs(R),y:Ws(R)})}return W(W({},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||!ra(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=os("recharts-line",x),$=d&&d.allowDataOverflow,R=m&&m.allowDataOverflow,K=$||R,r=We(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=ca(i)?i:{},A=N.clipDot,E=A===void 0?!0:A,F=w*2+z;return H.createElement(_e,{className:V},$||R?H.createElement("defs",null,H.createElement("clipPath",{id:"clipPath-".concat(r)},H.createElement("rect",{x:$?u:u-p/2,y:R?h:h-I/2,width:$?p:p*2,height:R?I:I*2})),!E&&H.createElement("clipPath",{id:"clipPath-dots-".concat(r)},H.createElement("rect",{x:u-F/2,y:h-F/2,width:p+F,height:I+F}))):null,!O&&this.renderCurve(K,r),this.renderErrorBar(K,r),(O||i)&&this.renderDots(K,E,r),(!k||_)&&la.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(he(t),[0]):t,i=[],l=0;l<c;++l)i=[].concat(he(i),he(o));return i}},{key:"renderDotItem",value:function(t,c){var o;if(H.isValidElement(t))o=H.cloneElement(t,c);else if(ea(t))o=t(c);else{var i=c.key,l=fs(c,dt),x=os("recharts-line-dot",typeof t!="boolean"?t.className:"");o=H.createElement(sa,Ie({key:i},l,{className:x}))}return o}}])})(v.PureComponent);ae(ge,"displayName","Line");ae(ge,"defaultProps",{xAxisId:0,yAxisId:0,connectNulls:!1,activeDot:!0,dot:!0,legendType:"line",stroke:"#3182bd",strokeWidth:1,fill:"#fff",points:[],isAnimationActive:!da.isSsr,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",hide:!1,label:!1});ae(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:xs({axis:a,ticks:c,bandSize:l,entry:u,index:p}),y:We(I)?null:t.scale(I),value:I,payload:u}:{x:We(I)?null:a.scale(I),y:xs({axis:t,ticks:o,bandSize:l,entry:u,index:p}),value:I,payload:u}});return W({points:h,layout:m},d)});var Ct=ma({chartName:"LineChart",GraphicalChild:ge,axisComponents:[{axisType:"xAxis",AxisComp:zs},{axisType:"yAxis",AxisComp:Vs}],formatAxisMap:ua});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 At(){const s=be.reduce((a,t)=>a+t.revenue,0),n=s/be.length;return e.jsxs(Q,{children:[e.jsxs(Z,{children:[e.jsx(J,{children:"Revenue Analytics"}),e.jsx(ee,{children:"Revenue and expenses over time"})]}),e.jsxs(se,{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(ke,{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(Me,{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(ke,{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(Me,{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(ke,{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(Me,{className:"h-3 w-3"}),e.jsx("span",{children:"+8.0% from last month"})]})]})]}),e.jsx(xa,{config:{revenue:{label:"Revenue",color:"hsl(var(--chart-1))"},expenses:{label:"Expenses",color:"hsl(var(--chart-2))"}},className:"h-[400px]",children:e.jsx(ha,{width:"100%",height:"100%",children:e.jsxs(Ct,{data:be,margin:{top:5,right:10,left:10,bottom:5},children:[e.jsx(pa,{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(ja,{content:e.jsx(ga,{})}),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 It=({contractId:s})=>{const[n,a]=v.useState(!1),[t,c]=v.useState(void 0),{issueDocuments:o}=ya(),i=Qe(ba(new Date,1),"yyyy-MM-dd"),[{data:l,fetching:x},d]=le({query:dn,variables:{issueMonth:i,contractId:s},pause:!n});v.useEffect(()=>{n&&d()},[n,d]),v.useEffect(()=>{if(l?.periodicalDocumentDraftsByContracts?.length){const h=mn(fe(un,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(Te,{open:n,onOpenChange:a,children:[e.jsx(Ls,{asChild:!0,children:e.jsx(T,{className:"size-7.5",variant:"ghost",children:e.jsx(xn,{className:"size-5"})})}),e.jsxs(Be,{className:"w-[90vw] sm:max-w-[95%] max-h-[90vh] overflow-y-auto",children:[e.jsxs(ts,{children:[e.jsx(is,{children:"Issue Document for Contract"}),e.jsx(rs,{children:"Issue periodically documents based on contract"})]}),x?e.jsx(Ze,{}):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 Ns(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 wt({clientId:s}){const[{data:n,fetching:a},t]=le({query:hn,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(Q,{children:[e.jsx(Z,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(J,{children:"Contracts"}),e.jsx(ee,{children:"Current and past contracts sorted by start date"})]}),e.jsx(Ke,{clientId:s,onDone:t})]})}),e.jsx(se,{className:"space-y-4",children:c.map(o=>e.jsx(Dt,{clientId:s,contract:o,refetch:t},o.id))})]})}function Dt({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(re,{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(Ke,{clientId:s,contract:Ns(n),onDone:a}),e.jsx(Ke,{clientId:s,contract:Ns(n),onDone:a,duplicate:!0}),e.jsx(It,{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(pn,{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:jn(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:gn(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(ss,{className:"h-4 w-4 mr-2"}),"MS Cloud",e.jsx(Ca,{className:"h-3 w-3 ml-1"})]})})})]},n.id)}const kt=[{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 St({data:s}){const[n,a]=v.useState([]),t=fe(vn,s),c=t?.clientInfo?.integrations,{updateClient:o}=Fs(),[{data:i,fetching:l},x]=le({query:fn,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(Q,{children:[e.jsx(Z,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(J,{children:"Integrations"}),e.jsx(ee,{children:"Connected external services and providers"})]})})}),e.jsx(se,{className:"space-y-6",children:e.jsxs(Ia,{type:"multiple",value:n,onValueChange:a,className:"space-y-4",children:[e.jsxs(Re,{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(ze,{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($e,{id:t?.clientInfo?.integrations.greenInvoiceInfo?.greenInvoiceId??void 0,provider:"Green Invoice",updateClient:async u=>h(u,"greenInvoiceId")}),t?.clientInfo?.integrations.greenInvoiceInfo?.greenInvoiceId&&e.jsx(hs,{className:"hover:no-underline p-2"})]})]})}),e.jsx(ps,{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(qe,{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(Ms,{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(He,{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(Re,{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(pe,{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(ds,{})}),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(ze,{className:"h-5 w-5 text-green-600"}):e.jsx(js,{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($e,{id:c?.hiveId??void 0,provider:"Hive",updateClient:async u=>h(u,"hiveId")})}),m&&e.jsx(hs,{className:"hover:no-underline p-2"})]})}),e.jsx(ps,{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(pe,{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(pe,{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"),kt.map(u=>e.jsx(Re,{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(pe,{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(ss,{})})}):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(ds,{})}),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(js,{className:"h-5 w-5 text-red-600"}):e.jsx(ze,{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($e,{id:t?.clientInfo?.integrations[u.id]??void 0,provider:u.name,keyType:u.keyType,updateClient:async p=>h(p,u.id)})})]})})},u.id))]})})]})}function $e({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(Te,{open:c,onOpenChange:o,children:[e.jsx(Ls,{asChild:!0,children:e.jsx(T,{variant:"outline",size:"sm",onClick:d=>d.stopPropagation(),children:e.jsx(_s,{className:"h-4 w-4"})})}),e.jsxs(Be,{onClick:d=>d.stopPropagation(),children:[e.jsxs(ts,{children:[e.jsxs(is,{children:["Configure ",n]}),e.jsxs(rs,{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(Bs,{children:[e.jsx(T,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(T,{onClick:x,disabled:!i,children:"Save Changes"})]})]})]})}const Tt="updateBusiness",Hs=()=>{const[{fetching:s},n]=Ee(yn),a=v.useCallback(async t=>{const c=`Error updating business ID [${t.businessId}]`,o=`${Tt}-${t.businessId}`;X.loading("Updating business",{id:o});try{const i=await n(t),l=Pe(i,c,o,"updateBusiness");if(l)return X.success("Success",{id:o,description:"Business updated"}),l.updateBusiness}catch(i){console.error(`${c}: ${i}`),X.error("Error",{id:o,description:c,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,updateBusiness:a}},Bt=Object.values(Sn);function bs(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 Et(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 Pt({data:s,refetchBusiness:n}){const a=fe(bn,s),[t,c]=v.useState(bs(a)),{userContext:o}=v.useContext(cs),{updateBusiness:i,fetching:l}=Hs(),[x,d]=v.useState(!1),[m,h]=v.useState(void 0),u=Oe({defaultValues:t}),p=async k=>{if(!a||!o?.context.adminBusinessId)return;const B=ns(k,u.formState.dirtyFields);if(!B)return;const _=Et(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=bs(a);c(k),u.reset(k)}},[a,u]),!a)return e.jsx("div",{});const I=u.watch("isClient");return e.jsxs(Q,{children:[e.jsx(Z,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(J,{children:"Configurations"}),e.jsx(ee,{children:"Business status, tax settings, automation rules, and integration preferences"})]}),!I&&e.jsx(Nn,{businessId:a.id,onDone:n})]})}),e.jsx(Le,{...u,children:e.jsxs("form",{onSubmit:u.handleSubmit(p),children:[e.jsxs(se,{className:"space-y-6",children:[e.jsx(Ot,{form:u}),e.jsx(de,{}),e.jsx(Lt,{form:u}),e.jsx(de,{}),e.jsx(Ft,{form:u}),e.jsx(de,{}),e.jsx(Mt,{form:u})]}),e.jsx(es,{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(ls,{className:"h-4 w-4 mr-2"}),"Save Changes"]})})]})}),e.jsx(qa,{businessId:a.id,tagIds:m?.tagIds,description:m?.description,open:x,onOpenChange:d,onClose:n})]})}function Ot({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(me,{children:"Mark this business as a client"})]}),e.jsx(y,{children:e.jsx(oe,{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(me,{children:"Business is currently active"})]}),e.jsx(y,{children:e.jsx(oe,{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(me,{children:"Generate ledger for receipt documents if no invoice available"})]}),e.jsx(y,{children:e.jsx(oe,{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(me,{children:"Skip document validation for common charges"})]}),e.jsx(y,{children:e.jsx(oe,{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(me,{children:"Mute missing VAT indicator"})]}),e.jsx(y,{children:e.jsx(oe,{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(me,{children:"Business is exempt from VAT requirements"})]}),e.jsx(y,{children:e.jsx(oe,{checked:n.value,onCheckedChange:n.onChange,className:S(a)})})]})})]})]})}function Lt({form:s}){const{selectableTaxCategories:n,fetching:a}=Cn(),{selectableSortCodes:t,fetching:c,sortCodes:o}=An(),{selectableTags:i,fetching:l}=In(),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(Ge,{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(Ge,{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(ws,{onValueChange:d.onChange,value:d.value,children:[e.jsx(y,{children:e.jsx(Ds,{className:S(m),children:e.jsx(ks,{})})}),e.jsx(Ss,{children:Object.entries(wn).map(([h,u])=>e.jsx(Ts,{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(Dn,{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(kn,{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 Ft({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(te,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:d.value?.map((h,u)=>e.jsxs(re,{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(ie,{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(te,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:d.value?.map((h,u)=>e.jsxs(re,{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(ie,{className:"size-3 cursor-pointer"})})]},u))}),e.jsx(b,{})]})})]})}function Mt({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:Bt.map(x=>e.jsx(re,{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(te,{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(re,{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(ie,{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(me,{children:"Extract information from email message body"})]}),e.jsx(y,{children:e.jsx(oe,{checked:i.value,onCheckedChange:i.onChange,className:S(l)})})]})})]})}const _t=xe({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:Pn("Invalid URL").optional().or(On("")),generalContacts:ue(us()).optional(),billingEmails:ue(us()).optional()});function Cs(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 Rt(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 zt({data:s,refetchBusiness:n}){const a=fe(En,s),[t,c]=v.useState(Cs(a)),{userContext:o}=v.useContext(cs),{updateBusiness:i,fetching:l}=Hs(),{updateClient:x,fetching:d}=Fs(),m=Oe({resolver:Je(_t),defaultValues:t}),{countries:h,fetching:u}=Tn(),[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 K=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=ns(N,m.formState.dirtyFields);if(!A)return;const E=Rt(A),F=[];Object.values(E).some(Fe=>Fe!=null)&&F.push(i({businessId:a.id,ownerId:o.context.adminBusinessId,fields:E})),K&&A.billingEmails&&F.push(x({businessId:a.id,fields:{emails:A.billingEmails}})),await Promise.all(F),n?.()};return v.useEffect(()=>{if(a){const N=Cs(a);c(N),m.reset(N)}},[a,m]),e.jsxs(Q,{children:[e.jsxs(Z,{children:[e.jsx(J,{children:"Contact Information"}),e.jsx(ee,{children:"Business contact details and address information"})]}),e.jsx(Le,{...m,children:e.jsxs("form",{onSubmit:m.handleSubmit(z),children:[e.jsx(se,{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(Ge,{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(He,{className:"h-4 w-4"}),"Address"]}),e.jsx(y,{children:e.jsx(ms,{...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(He,{className:"h-4 w-4"}),"Local Address"]}),e.jsx(y,{children:e.jsx(ms,{...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(Ms,{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(Bn,{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(qe,{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(re,{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(ie,{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(te,{className:"h-4 w-4"})})]})]})}),e.jsx(b,{})]})}),K&&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(qe,{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(re,{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(ie,{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(te,{className:"h-4 w-4"})})]})]})}),e.jsx(b,{})]})})]})}),e.jsx(es,{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(ls,{className:"h-4 w-4 mr-2"}),"Save Changes"]})})]})})]})}function Vt({businessId:s}){return e.jsxs(Q,{children:[e.jsx(Z,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(J,{children:"Documents"}),e.jsx(ee,{children:"Invoices, proformas, receipts, and other accounting documents"})]})})}),e.jsx(se,{children:e.jsx(Ln,{businessId:s,linkedDocumentIds:[],limit:1e3})})]})}function $t({businessId:s}){const[{data:n,fetching:a}]=le({query:Fn,variables:{businessId:s}});return a?e.jsx("div",{children:"Loading ledger records..."}):e.jsxs(Q,{children:[e.jsx(Z,{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(J,{children:"Ledger Records"}),e.jsx(ee,{children:"Complete ledger history for this business"})]})})}),e.jsx(se,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Zn,{ledgerRecordsData:n?.ledgerRecordsByFinancialEntity??[]})})})]})}function Ut({businessId:s}){const[{data:n,fetching:a}]=le({query:Mn,variables:{businessId:s}});return a?e.jsx("div",{children:"Loading transactions..."}):e.jsxs(Q,{children:[e.jsx(Z,{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(J,{children:"Transactions"}),e.jsx(ee,{children:"Complete transaction history for this business"})]})})}),e.jsx(se,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Aa,{transactionsProps:n?.transactionsByFinancialEntity??[]})})})]})}function qt({data:s,refetchBusiness:n}){const a=fe(qn,s),[t,c]=_n(),{setFiltersContext:o}=v.useContext(Rn);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(Yn,{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(zn,{value:i,onValueChange:l,className:"w-full",children:[e.jsxs(Vn,{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(ne,{value:"contact",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:"Contact"})]}),e.jsxs(ne,{value:"config",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(_s,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Config"})]}),e.jsxs(ne,{value:"charges",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(ke,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Charges"})]}),e.jsxs(ne,{value:"transactions",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:"Transactions"})]}),e.jsxs(ne,{value:"documents",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:"Documents"})]}),e.jsxs(ne,{value:"ledger",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(za,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Ledger"})]}),e.jsxs(ne,{value:"balance",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Ba,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Balance"})]}),x&&e.jsxs(e.Fragment,{children:[e.jsxs(ne,{value:"contracts",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Fa,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Contracts"})]}),e.jsxs(ne,{value:"integrations",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx($a,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Integrations"})]})]}),d&&e.jsxs(e.Fragment,{children:[e.jsxs(ne,{value:"accounts",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Jn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Accounts"})]}),e.jsxs(ne,{value:"admin",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(As,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Admin"})]})]})]}),e.jsx(Y,{value:"contact",className:"mt-0",children:e.jsx(zt,{data:a,refetchBusiness:n})}),e.jsx(Y,{value:"config",className:"mt-0",children:e.jsx(Pt,{data:a,refetchBusiness:n})}),e.jsx(Y,{value:"charges",className:"mt-0",children:e.jsx(lt,{businessId:a.id})}),e.jsx(Y,{value:"transactions",className:"mt-0",children:e.jsx(Ut,{businessId:a.id})}),e.jsx(Y,{value:"documents",className:"mt-0",children:e.jsx(Vt,{businessId:a.id})}),e.jsx(Y,{value:"ledger",className:"mt-0",children:e.jsx($t,{businessId:a.id})}),e.jsx(Y,{value:"balance",className:"mt-0",children:e.jsx(ct,{businessId:a.id})}),x&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{value:"contracts",className:"mt-0",children:e.jsx(wt,{clientId:a.id})}),e.jsx(Y,{value:"integrations",className:"mt-0",children:e.jsx(St,{data:a})}),e.jsx(Y,{value:"charts",className:"mt-0",children:e.jsx(At,{})})]}),d&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{value:"accounts",className:"mt-0",children:e.jsx(rt,{adminId:a.id})}),e.jsx(Y,{value:"admin",className:"mt-0",children:e.jsx(Ya,{data:a})})]})]})})]})}const ji=()=>{const{businessId:s}=Hn();let n;try{n=Gn()}catch{}const[{data:a,fetching:t},c]=le({query:Wn,pause:!s||!!n,variables:{businessId:s??""}}),o=n||a;return!n&&t&&!o?.business?e.jsx(Ze,{}):!s||!o?.business?e.jsx("div",{children:"Business not found"}):e.jsx(qt,{data:o.business,refetchBusiness:async()=>c()})};export{ji as BusinessScreen};
@@ -1,3 +1,3 @@
1
- import{j as e,m as S,aP as H,ai as z,R as F,w as D,ay as d,bw as L,bP as h,bS as B,c1 as G,r as c,dn as Z,u as ee,e5 as te,bX as ne,aT as f,bN as V,bO as P,bQ as k,bR as O,e6 as se,I as ae,bY as re,bZ as oe,B as ie,b_ as le,b$ as ce,c0 as me,ao as ue,ap as de,aq as ge,ar as xe,as as fe,P as he,c3 as pe,c2 as we,c4 as be,c5 as je}from"./index-CHXDfsUO.js";import{D as p}from"./data-table-column-header-B3XsejWx.js";import{D as Ce}from"./download-csv-button-Cd0rXY7Z.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,ai as z,R as F,w as D,ay as d,bw as L,bP as h,bS as B,c1 as G,r as c,dn as Z,u as ee,e5 as te,bX as ne,aT as f,bN as V,bO as P,bQ as k,bR as O,e6 as se,I as ae,bY as re,bZ as oe,B as ie,b_ as le,b$ as ce,c0 as me,ao as ue,ap as de,aq as ge,ar as xe,as as fe,P as he,c3 as pe,c2 as we,c4 as be,c5 as je}from"./index-W0pymfZB.js";import{D as p}from"./data-table-column-header-CXNAhFg7.js";import{D as Ce}from"./download-csv-button-Dv6hYXH3.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:X,...u}=g[o],W=o===0?u.amount.raw:(s[o-1].ilsBalance??0)+u.amount.raw,E={};Object.values(d).map(j=>{if(j!==d.Ils){const _=`${j.toLowerCase()}Balance`;E[_]=o===0?(u.foreignAmount?.currency===j?u.foreignAmount?.raw:0)??0:(s[o-1]?.[_]??0)+(u.foreignAmount?.currency===j?u.foreignAmount?.raw:0)}}),s.push({...u,ilsBalance:W,...E})}return s},[g]),M=c.useMemo(()=>new Set(g.filter(s=>s.foreignAmount?.currency).map(s=>s.foreignAmount.currency)),[g]),R=Me(),b=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{...b,...o}}}catch{}return b});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=>({...b,...s}))},[b]);const i=ne({data:$,columns:R,getCoreRowModel:je(),getSortedRowModel:be(),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((X,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};
@@ -1 +1 @@
1
- import{G as l,j as e,ag as t,w as m,bt as x}from"./index-CHXDfsUO.js";import{B as o}from"./building-2-DeX_sgix.js";function h({data:n}){const s=l(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:m(s.createdAt,"MMM yyyy")})]})]})]})})})}export{h as B};
1
+ import{G as l,j as e,ag as t,w as m,bt as x}from"./index-W0pymfZB.js";import{B as o}from"./building-2-BL0OoCnC.js";function h({data:n}){const s=l(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:m(s.createdAt,"MMM yyyy")})]})]})]})})})}export{h as B};
@@ -1 +1 @@
1
- import{bx as F,r as f,by as I,aF as O,bz as P,bA as y,j as s,bB as E,B as N,z as B,bC as k,aC as M,bD as x,bE as h,bF as j,w as D,bG as R,bH as L}from"./index-CHXDfsUO.js";import{u as A}from"./use-url-query-Cy2jrPOP.js";import{P as T}from"./modal-CmNyWfb_.js";import{F as U}from"./funnel-Cq2G1Do_.js";import{M as C}from"./MultiSelect-1WINlkTu.js";var V=F((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=I("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 O.createElement(P,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(E,{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{bx as F,r as f,by as I,aF as O,bz as P,bA as y,j as s,bB as E,B as N,z as B,bC as k,aC as M,bD as x,bE as h,bF as j,w as D,bG as R,bH as L}from"./index-W0pymfZB.js";import{u as A}from"./use-url-query-Bw2WqiC_.js";import{P as T}from"./modal-r_uBjTC6.js";import{F as U}from"./funnel-Bz95UZzU.js";import{M as C}from"./MultiSelect-B-TAg0CU.js";var V=F((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=I("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 O.createElement(P,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(E,{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 S,r as c,F as w,u as y,j as n,c as C,ay as o,bv as x}from"./index-CHXDfsUO.js";import{u as h}from"./use-url-query-Cy2jrPOP.js";import{a as F}from"./accounter-table-DZctE2Ds.js";import{B as R}from"./business-extended-info-B2Xyih3c.js";import{B as v,M as p}from"./business-ledger-filters-DSuUAhpz.js";import"./Table-3LUzGF-Y.js";import"./data-table-column-header-B3XsejWx.js";import"./eye-off-CqyrLNH2.js";import"./download-csv-button-Cd0rXY7Z.js";import"./modal-CmNyWfb_.js";import"./funnel-Cq2G1Do_.js";import"./MultiSelect-1WINlkTu.js";const H=({businessId:t})=>{const{businessId:r}=S(),{get:s}=h(),{setFiltersContext:u}=c.useContext(w),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 S,r as c,F as w,u as y,j as n,c as C,ay as o,bv as x}from"./index-W0pymfZB.js";import{u as h}from"./use-url-query-Bw2WqiC_.js";import{a as F}from"./accounter-table-gSJDWOOH.js";import{B as R}from"./business-extended-info-DCMU2tJH.js";import{B as v,M as p}from"./business-ledger-filters-BwSk0IIQ.js";import"./Table-BERLrufH.js";import"./data-table-column-header-CXNAhFg7.js";import"./eye-off-DarXeCrB.js";import"./download-csv-button-Dv6hYXH3.js";import"./modal-r_uBjTC6.js";import"./funnel-Bz95UZzU.js";import"./MultiSelect-B-TAg0CU.js";const H=({businessId:t})=>{const{businessId:r}=S(),{get:s}=h(),{setFiltersContext:u}=c.useContext(w),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 +1 @@
1
- import{a as p,r as n,F as u,u as m,j as s,c,cg as x}from"./index-CHXDfsUO.js";import{P as d,C as l,E as f}from"./editable-business-trip-CFtHoHgD.js";import{P as T}from"./page-layout-ClvS18JI.js";import"./list-plus-B1XUUi79.js";import"./summary-3HnUK0c0.js";import"./Table-3LUzGF-Y.js";import"./toggle-expansion-button-B4wRWu9m.js";import"./panel-top-open-ZI73OpgC.js";import"./MultiSelect-1WINlkTu.js";import"./similar-transactions-modal-DVKLWVDl.js";const y=({businessTripId:o})=>{const{businessTripId:a}=p(),{setFiltersContext:i}=n.useContext(u),e=o??a??"",[{data:r,fetching:t}]=m({query:x,variables:{businessTripId:e}});return n.useEffect(()=>{i(s.jsx("div",{className:"flex flex-row gap-x-5",children:s.jsx(d,{filename:"business_trip_report"})}))},[r,t,i]),t||!r?.businessTrip?s.jsx(c,{}):s.jsx(T,{title:`Business Trip: ${r.businessTrip.name}`,description:"Manage business trip",children:s.jsx(l,{className:"mt-5",children:e&&s.jsx(f,{tripId:e,isExtended:!0})})})};export{y as BusinessTrip};
1
+ import{a as p,r as n,F as u,u as m,j as s,c,cg as x}from"./index-W0pymfZB.js";import{P as d,C as l,E as f}from"./editable-business-trip-CMSRoWTM.js";import{P as T}from"./page-layout-BB7wmuSc.js";import"./list-plus-BAPfjvM-.js";import"./summary-DPh6Auzq.js";import"./Table-BERLrufH.js";import"./toggle-expansion-button-CGUSw3Av.js";import"./panel-top-open-fWlzHeN-.js";import"./MultiSelect-B-TAg0CU.js";import"./similar-transactions-modal-BfVUcf_3.js";const y=({businessTripId:o})=>{const{businessTripId:a}=p(),{setFiltersContext:i}=n.useContext(u),e=o??a??"",[{data:r,fetching:t}]=m({query:x,variables:{businessTripId:e}});return n.useEffect(()=>{i(s.jsx("div",{className:"flex flex-row gap-x-5",children:s.jsx(d,{filename:"business_trip_report"})}))},[r,t,i]),t||!r?.businessTrip?s.jsx(c,{}):s.jsx(T,{title:`Business Trip: ${r.businessTrip.name}`,description:"Manage business trip",children:s.jsx(l,{className:"mt-5",children:e&&s.jsx(f,{tripId:e,isExtended:!0})})})};export{y as BusinessTrip};
@@ -1 +1 @@
1
- import{a as I,b as x,r as o,u as D,j as t,c as f,C as j}from"./index-CHXDfsUO.js";import{C as v}from"./charges-table-BqKHuWkm.js";import{E as M,I as E,M as S}from"./match-document-modal-CtJxEQcv.js";import"./toggle-expansion-button-B4wRWu9m.js";import"./panel-top-open-ZI73OpgC.js";import"./index-O1zv8-qd.js";import"./similar-transactions-modal-DVKLWVDl.js";import"./addDays-B6KOnr9d.js";import"./list-plus-B1XUUi79.js";import"./Table-3LUzGF-Y.js";import"./summary-3HnUK0c0.js";import"./deposits-transactions-table-u4MVVhDE.js";import"./Checkbox-DQnX-IHw.js";import"./accordion-3APui6eL.js";import"./data-table-column-header-B3XsejWx.js";import"./eye-off-CqyrLNH2.js";import"./YearPickerInput-B4UXt2Dq.js";import"./insert-business-trip-modal-K2wc3hgW.js";import"./accounter-table-DZctE2Ds.js";import"./modal-CmNyWfb_.js";const N=({chargeId:p})=>{const{chargeId:u}=I(),r=p||u;let e;try{e=x()}catch{}const[a,c]=o.useState(void 0),[s,n]=o.useState(void 0),[i,d]=o.useState(void 0),[{data:g,fetching:l},m]=D({query:j,pause:!r||!!e,variables:{chargeId:r??""}});o.useEffect(()=>{r&&!e&&m()},[r,e,m]);const h=e||g,C=!e&&l;return r?t.jsxs(t.Fragment,{children:[C?t.jsx(f,{}):t.jsx(v,{setEditChargeId:c,setInsertDocument:n,setMatchDocuments:d,data:h?.charge?[h.charge]:[],isAllOpened:!0}),a&&t.jsx(M,{chargeId:a?.id,close:()=>c(void 0),onChange:a.onChange}),s&&t.jsx(E,{chargeId:s.id,onChange:s.onChange,close:()=>n(void 0)}),i&&t.jsx(S,{chargeId:i.id,ownerId:i.ownerId,setMatchDocuments:()=>d(void 0)})]}):t.jsx("div",{children:"Charge not found"})};export{N as Charge};
1
+ import{a as I,b as x,r as o,u as D,j as t,c as f,C as j}from"./index-W0pymfZB.js";import{C as v}from"./charges-table-BhJhWeOk.js";import{E as M,I as E,M as S}from"./match-document-modal-DarKQJhx.js";import"./toggle-expansion-button-CGUSw3Av.js";import"./panel-top-open-fWlzHeN-.js";import"./index-L2Li0C19.js";import"./similar-transactions-modal-BfVUcf_3.js";import"./addDays-CPSgiY2b.js";import"./list-plus-BAPfjvM-.js";import"./Table-BERLrufH.js";import"./summary-DPh6Auzq.js";import"./deposits-transactions-table-fTRP0dK3.js";import"./Checkbox-B9Jxe8oL.js";import"./accordion-Da7XFLSI.js";import"./data-table-column-header-CXNAhFg7.js";import"./eye-off-DarXeCrB.js";import"./YearPickerInput-CCSx1WAA.js";import"./insert-business-trip-modal-B2i2hxuI.js";import"./accounter-table-gSJDWOOH.js";import"./modal-r_uBjTC6.js";const N=({chargeId:p})=>{const{chargeId:u}=I(),r=p||u;let e;try{e=x()}catch{}const[a,c]=o.useState(void 0),[s,n]=o.useState(void 0),[i,d]=o.useState(void 0),[{data:g,fetching:l},m]=D({query:j,pause:!r||!!e,variables:{chargeId:r??""}});o.useEffect(()=>{r&&!e&&m()},[r,e,m]);const h=e||g,C=!e&&l;return r?t.jsxs(t.Fragment,{children:[C?t.jsx(f,{}):t.jsx(v,{setEditChargeId:c,setInsertDocument:n,setMatchDocuments:d,data:h?.charge?[h.charge]:[],isAllOpened:!0}),a&&t.jsx(M,{chargeId:a?.id,close:()=>c(void 0),onChange:a.onChange}),s&&t.jsx(E,{chargeId:s.id,onChange:s.onChange,close:()=>n(void 0)}),i&&t.jsx(S,{chargeId:i.id,ownerId:i.ownerId,setMatchDocuments:()=>d(void 0)})]}):t.jsx("div",{children:"Charge not found"})};export{N as Charge};
@@ -1 +1 @@
1
- import{r as i,bA as B,bH as z,j as e,P as R,bB as U,B as W,aC as G,z as _,w as N,aE as D,dq as q,b4 as J,V as K,dr as Q,bD as h,er as X,bE as M,bF as O,bG as V,ek as k,at as m,hK as Y,a2 as Z,Y as x,Z as j,_ as p,$ as g,bT as $,bU as ee,bV as se}from"./index-CHXDfsUO.js";import{u as ae}from"./use-url-query-Cy2jrPOP.js";import{P as te}from"./modal-CmNyWfb_.js";import{F as ne}from"./funnel-Cq2G1Do_.js";import{s as oe}from"./sub-Cl3G90K_.js";import{M as A}from"./MultiSelect-1WINlkTu.js";function re(a){return!a||B(a)?null:encodeURIComponent(JSON.stringify(a))}const le=[{value:D.AbsAmount,label:"Abs Amount"},{value:D.Amount,label:"Amount"},{value:D.Date,label:"Date"}],ce=[{label:"All",value:k.All},{label:"Income",value:k.Income},{label:"Expense",value:k.Expense}];function ie({filter:a,setFilter:w,closeModal:d}){const{userContext:b}=i.useContext(G),o=_({defaultValues:{byOwners:b?.context.adminBusinessId?[b.context.adminBusinessId]:void 0,sortBy:{field:D.Date,asc:!1},toAnyDate:N(new Date,"yyyy-MM-dd"),fromAnyDate:N(oe(new Date,{years:1}),"yyyy-MM-dd"),...a}}),{control:l,handleSubmit:T,watch:C}=o,[y,F]=i.useState(a.sortBy?.asc??!1),[c,u]=i.useState(!!a.sortBy?.field),{selectableFinancialEntities:S,fetching:t}=q(),{selectableTags:v,fetching:I}=J(),E=C("sortBy.field");i.useEffect(()=>{E&&!c?u(!0):!E&&c&&u(!1)},[E,c]);const L=s=>{y!=null&&s.sortBy?.field&&(s.sortBy.asc=y),w(s),d()};function H(){w({}),F(!1),d()}return e.jsxs(e.Fragment,{children:[t?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsx(K,{...o,children:e.jsxs("form",{onSubmit:T(L),children:[e.jsxs(Q,{cols:2,children:[e.jsx(h,{name:"byOwners",control:l,defaultValue:a.byOwners,render:({field:s,fieldState:n})=>e.jsx(A,{...s,data:S,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(h,{name:"byBusinesses",control:l,defaultValue:a.byBusinesses,render:({field:s,fieldState:n})=>e.jsx(A,{...s,data:S,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(h,{name:"byTags",control:l,defaultValue:a.byTags,render:({field:s,fieldState:n})=>e.jsx(A,{...s,data:v,itemComponent:X,value:s.value??[],disabled:I,label:"Tags",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message,withinPortal:!0,filter:(r,f,P)=>P.label?.toLowerCase().includes(r.toLowerCase().trim())||P.description?.toLowerCase().includes(r.toLowerCase().trim())})}),e.jsx(h,{name:"fromAnyDate",control:l,defaultValue:a.fromAnyDate,rules:{pattern:{value:M,message:"Date must be im format yyyy-mm-dd"}},render:({field:s,fieldState:n})=>e.jsx(O,{...s,onChange:r=>{const f=r?typeof r=="string"?r:N(r,"yyyy-MM-dd"):void 0;f!==s.value&&s.onChange(f)},value:s.value?new Date(s.value):void 0,error:n.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(h,{name:"toAnyDate",control:l,defaultValue:a.toAnyDate,rules:{pattern:{value:M,message:"Date must be im format yyyy-mm-dd"}},render:({field:s,fieldState:n})=>e.jsx(O,{...s,onChange:r=>{const f=r?typeof r=="string"?r:N(r,"yyyy-MM-dd"):void 0;f!==s.value&&s.onChange(f)},value:s.value?new Date(s.value):void 0,error:n.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(h,{name:"chargesType",control:l,defaultValue:a.chargesType,render:({field:s,fieldState:n})=>e.jsx(V,{...s,data:ce,value:s.value??k.All,disabled:t,label:"Charge Type",placeholder:"Filter income/expense",maxDropdownHeight:160,error:n.error?.message,withinPortal:!0})}),e.jsx(h,{name:"sortBy.field",control:l,defaultValue:a.sortBy?.field??D.Date,render:({field:s,fieldState:n})=>e.jsx(V,{...s,data:le,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(m,{defaultChecked:a.sortBy?.asc??!1,checked:y??!1,disabled:!c,onCheckedChange:F}),e.jsx("span",{className:"text-xs",children:y?"ASC":"DESC"})]})})}),e.jsx(h,{name:"accountantStatus",control:l,defaultValue:a.accountantStatus,render:({field:s,fieldState:n})=>e.jsx(A,{...s,value:s.value??[],data:Y,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(x,{control:o.control,name:"withoutInvoice",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(p,{children:"Without Invoice"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.withoutInvoice??!1,onCheckedChange:s.onChange})})]})}),e.jsx(x,{control:o.control,name:"withoutReceipt",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(p,{children:"Without Receipts"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.withoutReceipt??!1,onCheckedChange:s.onChange})})]})}),e.jsx(x,{control:o.control,name:"withoutDocuments",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(p,{children:"Without Documents"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.withoutDocuments??!1,onCheckedChange:s.onChange})})]})}),e.jsx(x,{control:o.control,name:"withOpenDocuments",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(p,{children:"With Open Documents"})}),e.jsx(g,{children:e.jsxs($,{children:[e.jsx(ee,{children:e.jsx(m,{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(x,{control:o.control,name:"withoutTransactions",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(p,{children:"Without Transactions"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.withoutTransactions??!1,onCheckedChange:s.onChange})})]})}),e.jsx(x,{control:o.control,name:"unbalanced",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(p,{children:"Unbalanced businesses"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.unbalanced??!1,onCheckedChange:s.onChange})})]})}),e.jsx(x,{control:o.control,name:"withoutLedger",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(p,{children:"Without ledger"})}),e.jsx(g,{children:e.jsx(m,{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||I,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:H,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:d,children:"Cancel"})]})]})})]})}function pe({filter:a={},setFilter:w,activePage:d,setPage:b,totalPages:o=1,initiallyOpened:l=!1}){const[T,C]=i.useState(l),[y,F]=i.useState(!B(a)),{get:c,set:u}=ae();i.useEffect(()=>{const t=d>0?d.toFixed(0):null,v=c("page");t!==v&&u("page",t)},[d,c,u]),i.useEffect(()=>{const t=re(a),v=c("chargesFilters");t!==v&&(u("chargesFilters",t),u("page"),b(0))},[a,c,u,b]);const S=i.useCallback(t=>{z(t,a)||(w(t),F(!B(t)))},[a,w]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(te,{opened:T,onClose:()=>C(!1),content:e.jsx(ie,{filter:a,setFilter:S,closeModal:()=>C(!1)}),modalSize:"xl"}),o>1&&e.jsx(R,{className:"flex-fit w-fit mx-0",currentPageIndex:d,onChange:b,totalPages:o}),e.jsx(U,{inline:!0,size:16,disabled:!y,children:e.jsx(W,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>C(!0),children:e.jsx(ne,{className:"size-5"})})})]})}export{pe as C,ce as c};
1
+ import{r as i,bA as B,bH as z,j as e,P as R,bB as U,B as W,aC as G,z as _,w as N,aE as D,dq as q,b4 as J,V as K,dr as Q,bD as h,er as X,bE as M,bF as O,bG as V,ek as k,at as m,hK as Y,a2 as Z,Y as x,Z as j,_ as p,$ as g,bT as $,bU as ee,bV as se}from"./index-W0pymfZB.js";import{u as ae}from"./use-url-query-Bw2WqiC_.js";import{P as te}from"./modal-r_uBjTC6.js";import{F as ne}from"./funnel-Bz95UZzU.js";import{s as oe}from"./sub-D2MOo6Sz.js";import{M as A}from"./MultiSelect-B-TAg0CU.js";function re(a){return!a||B(a)?null:encodeURIComponent(JSON.stringify(a))}const le=[{value:D.AbsAmount,label:"Abs Amount"},{value:D.Amount,label:"Amount"},{value:D.Date,label:"Date"}],ce=[{label:"All",value:k.All},{label:"Income",value:k.Income},{label:"Expense",value:k.Expense}];function ie({filter:a,setFilter:w,closeModal:d}){const{userContext:b}=i.useContext(G),o=_({defaultValues:{byOwners:b?.context.adminBusinessId?[b.context.adminBusinessId]:void 0,sortBy:{field:D.Date,asc:!1},toAnyDate:N(new Date,"yyyy-MM-dd"),fromAnyDate:N(oe(new Date,{years:1}),"yyyy-MM-dd"),...a}}),{control:l,handleSubmit:T,watch:C}=o,[y,F]=i.useState(a.sortBy?.asc??!1),[c,u]=i.useState(!!a.sortBy?.field),{selectableFinancialEntities:S,fetching:t}=q(),{selectableTags:v,fetching:I}=J(),E=C("sortBy.field");i.useEffect(()=>{E&&!c?u(!0):!E&&c&&u(!1)},[E,c]);const L=s=>{y!=null&&s.sortBy?.field&&(s.sortBy.asc=y),w(s),d()};function H(){w({}),F(!1),d()}return e.jsxs(e.Fragment,{children:[t?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsx(K,{...o,children:e.jsxs("form",{onSubmit:T(L),children:[e.jsxs(Q,{cols:2,children:[e.jsx(h,{name:"byOwners",control:l,defaultValue:a.byOwners,render:({field:s,fieldState:n})=>e.jsx(A,{...s,data:S,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(h,{name:"byBusinesses",control:l,defaultValue:a.byBusinesses,render:({field:s,fieldState:n})=>e.jsx(A,{...s,data:S,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(h,{name:"byTags",control:l,defaultValue:a.byTags,render:({field:s,fieldState:n})=>e.jsx(A,{...s,data:v,itemComponent:X,value:s.value??[],disabled:I,label:"Tags",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message,withinPortal:!0,filter:(r,f,P)=>P.label?.toLowerCase().includes(r.toLowerCase().trim())||P.description?.toLowerCase().includes(r.toLowerCase().trim())})}),e.jsx(h,{name:"fromAnyDate",control:l,defaultValue:a.fromAnyDate,rules:{pattern:{value:M,message:"Date must be im format yyyy-mm-dd"}},render:({field:s,fieldState:n})=>e.jsx(O,{...s,onChange:r=>{const f=r?typeof r=="string"?r:N(r,"yyyy-MM-dd"):void 0;f!==s.value&&s.onChange(f)},value:s.value?new Date(s.value):void 0,error:n.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(h,{name:"toAnyDate",control:l,defaultValue:a.toAnyDate,rules:{pattern:{value:M,message:"Date must be im format yyyy-mm-dd"}},render:({field:s,fieldState:n})=>e.jsx(O,{...s,onChange:r=>{const f=r?typeof r=="string"?r:N(r,"yyyy-MM-dd"):void 0;f!==s.value&&s.onChange(f)},value:s.value?new Date(s.value):void 0,error:n.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(h,{name:"chargesType",control:l,defaultValue:a.chargesType,render:({field:s,fieldState:n})=>e.jsx(V,{...s,data:ce,value:s.value??k.All,disabled:t,label:"Charge Type",placeholder:"Filter income/expense",maxDropdownHeight:160,error:n.error?.message,withinPortal:!0})}),e.jsx(h,{name:"sortBy.field",control:l,defaultValue:a.sortBy?.field??D.Date,render:({field:s,fieldState:n})=>e.jsx(V,{...s,data:le,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(m,{defaultChecked:a.sortBy?.asc??!1,checked:y??!1,disabled:!c,onCheckedChange:F}),e.jsx("span",{className:"text-xs",children:y?"ASC":"DESC"})]})})}),e.jsx(h,{name:"accountantStatus",control:l,defaultValue:a.accountantStatus,render:({field:s,fieldState:n})=>e.jsx(A,{...s,value:s.value??[],data:Y,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(x,{control:o.control,name:"withoutInvoice",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(p,{children:"Without Invoice"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.withoutInvoice??!1,onCheckedChange:s.onChange})})]})}),e.jsx(x,{control:o.control,name:"withoutReceipt",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(p,{children:"Without Receipts"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.withoutReceipt??!1,onCheckedChange:s.onChange})})]})}),e.jsx(x,{control:o.control,name:"withoutDocuments",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(p,{children:"Without Documents"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.withoutDocuments??!1,onCheckedChange:s.onChange})})]})}),e.jsx(x,{control:o.control,name:"withOpenDocuments",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(p,{children:"With Open Documents"})}),e.jsx(g,{children:e.jsxs($,{children:[e.jsx(ee,{children:e.jsx(m,{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(x,{control:o.control,name:"withoutTransactions",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(p,{children:"Without Transactions"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.withoutTransactions??!1,onCheckedChange:s.onChange})})]})}),e.jsx(x,{control:o.control,name:"unbalanced",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(p,{children:"Unbalanced businesses"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.unbalanced??!1,onCheckedChange:s.onChange})})]})}),e.jsx(x,{control:o.control,name:"withoutLedger",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(p,{children:"Without ledger"})}),e.jsx(g,{children:e.jsx(m,{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||I,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:H,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:d,children:"Cancel"})]})]})})]})}function pe({filter:a={},setFilter:w,activePage:d,setPage:b,totalPages:o=1,initiallyOpened:l=!1}){const[T,C]=i.useState(l),[y,F]=i.useState(!B(a)),{get:c,set:u}=ae();i.useEffect(()=>{const t=d>0?d.toFixed(0):null,v=c("page");t!==v&&u("page",t)},[d,c,u]),i.useEffect(()=>{const t=re(a),v=c("chargesFilters");t!==v&&(u("chargesFilters",t),u("page"),b(0))},[a,c,u,b]);const S=i.useCallback(t=>{z(t,a)||(w(t),F(!B(t)))},[a,w]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(te,{opened:T,onClose:()=>C(!1),content:e.jsx(ie,{filter:a,setFilter:S,closeModal:()=>C(!1)}),modalSize:"xl"}),o>1&&e.jsx(R,{className:"flex-fit w-fit mx-0",currentPageIndex:d,onChange:b,totalPages:o}),e.jsx(U,{inline:!0,size:16,disabled:!y,children:e.jsx(W,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>C(!0),children:e.jsx(ne,{className:"size-5"})})})]})}export{pe as C,ce as c};
@@ -1 +1 @@
1
- import{r as t,F as D,u as E,j as e,T as N,B as w,L as T,d as z,e as W,f as b}from"./index-CHXDfsUO.js";import{u as O}from"./use-url-query-Cy2jrPOP.js";import{C as k}from"./charges-filters-DX5qB120.js";import{M as B,C as R,T as V}from"./charges-table-BqKHuWkm.js";import{E as A,I as Q,M as U}from"./match-document-modal-CtJxEQcv.js";import{P as q}from"./page-layout-ClvS18JI.js";import{P as J}from"./Progress-CP4CpjLB.js";import{P as $,a as G}from"./panel-top-open-ZI73OpgC.js";import"./modal-CmNyWfb_.js";import"./funnel-Cq2G1Do_.js";import"./sub-Cl3G90K_.js";import"./addDays-B6KOnr9d.js";import"./subMonths-SBqdI_BY.js";import"./MultiSelect-1WINlkTu.js";import"./toggle-expansion-button-B4wRWu9m.js";import"./index-O1zv8-qd.js";import"./similar-transactions-modal-DVKLWVDl.js";import"./list-plus-B1XUUi79.js";import"./Table-3LUzGF-Y.js";import"./summary-3HnUK0c0.js";import"./deposits-transactions-table-u4MVVhDE.js";import"./Checkbox-DQnX-IHw.js";import"./accordion-3APui6eL.js";import"./data-table-column-header-B3XsejWx.js";import"./eye-off-CqyrLNH2.js";import"./YearPickerInput-B4UXt2Dq.js";import"./insert-business-trip-modal-K2wc3hgW.js";import"./accounter-table-DZctE2Ds.js";const Le=()=>{const{setFiltersContext:p}=t.useContext(D),[n,u]=t.useState(void 0),[c,x]=t.useState(void 0),[l,C]=t.useState(void 0),[g,f]=t.useState(!1),[r,m]=t.useState([]),{get:F}=O(),d=F("chargesFilters"),I=t.useMemo(()=>{if(d)try{return JSON.parse(decodeURIComponent(d))}catch{return}},[d]),[o,j]=t.useState(I),S=t.useCallback((s,y)=>{r.map(h=>h.id).includes(s)?m(r.filter(h=>h.id!==s)):m([...r,{id:s,onChange:y}])},[r]),[{data:a,fetching:M},v]=E({query:b,variables:{filters:o},pause:!0});function P(){m([])}const i=t.useMemo(()=>a?.chargesWithLedgerChanges?.length?a.chargesWithLedgerChanges[a.chargesWithLedgerChanges.length-1].progress:0,[a?.chargesWithLedgerChanges]),L=t.useCallback(s=>{j(s)},[j]);return t.useEffect(()=>{o&&v()},[o,v]),t.useEffect(()=>{p(e.jsxs("div",{className:"flex flex-row gap-x-5 items-center",children:[e.jsx(J,{value:i,label:`${i?.toFixed(2)}%`,size:"xl",animate:i<100,className:"min-w-52"}),e.jsx(k,{filter:o,setFilter:L,activePage:0,setPage:()=>{},initiallyOpened:!0}),e.jsx(N,{content:"Expand all accounts",children:e.jsx(w,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>f(s=>!s),children:g?e.jsx($,{className:"size-5"}):e.jsx(G,{className:"size-5"})})}),e.jsx(B,{selected:r,resetMerge:P})]}))},[a,M,o,g,p,f,r,i,L]),e.jsxs(q,{title:"Charges Ledger Validation",description:"Manage charges",children:[M?e.jsx(T,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs(e.Fragment,{children:[e.jsx(R,{setEditChargeId:u,setInsertDocument:x,setMatchDocuments:C,toggleMergeCharge:S,mergeSelectedCharges:new Set(r.map(s=>s.id)),data:a?.chargesWithLedgerChanges.filter(s=>!!s.charge).map(s=>s.charge)??[],isAllOpened:g}),e.jsxs("div",{className:"flex flex-row justify-center my-2",children:[i>0&&i<100&&e.jsx(z,{}),i===100&&!a?.chargesWithLedgerChanges.filter(s=>!!s.charge).length&&e.jsx(V,{radius:"xl",size:"xl",color:"green",children:e.jsx(W,{})})]})]}),n&&e.jsx(A,{chargeId:n?.id,close:()=>u(void 0),onChange:n.onChange}),c&&e.jsx(Q,{chargeId:c.id,onChange:c.onChange,close:()=>x(void 0)}),l&&e.jsx(U,{chargeId:l.id,ownerId:l.ownerId,setMatchDocuments:()=>C(void 0)})]})};export{Le as ChargesLedgerValidation};
1
+ import{r as t,F as D,u as E,j as e,T as N,B as w,L as T,d as z,e as W,f as b}from"./index-W0pymfZB.js";import{u as O}from"./use-url-query-Bw2WqiC_.js";import{C as k}from"./charges-filters-DUUu6SXt.js";import{M as B,C as R,T as V}from"./charges-table-BhJhWeOk.js";import{E as A,I as Q,M as U}from"./match-document-modal-DarKQJhx.js";import{P as q}from"./page-layout-BB7wmuSc.js";import{P as J}from"./Progress-D_6NsFIY.js";import{P as $,a as G}from"./panel-top-open-fWlzHeN-.js";import"./modal-r_uBjTC6.js";import"./funnel-Bz95UZzU.js";import"./sub-D2MOo6Sz.js";import"./addDays-CPSgiY2b.js";import"./subMonths-BN0YWd5Y.js";import"./MultiSelect-B-TAg0CU.js";import"./toggle-expansion-button-CGUSw3Av.js";import"./index-L2Li0C19.js";import"./similar-transactions-modal-BfVUcf_3.js";import"./list-plus-BAPfjvM-.js";import"./Table-BERLrufH.js";import"./summary-DPh6Auzq.js";import"./deposits-transactions-table-fTRP0dK3.js";import"./Checkbox-B9Jxe8oL.js";import"./accordion-Da7XFLSI.js";import"./data-table-column-header-CXNAhFg7.js";import"./eye-off-DarXeCrB.js";import"./YearPickerInput-CCSx1WAA.js";import"./insert-business-trip-modal-B2i2hxuI.js";import"./accounter-table-gSJDWOOH.js";const Le=()=>{const{setFiltersContext:p}=t.useContext(D),[n,u]=t.useState(void 0),[c,x]=t.useState(void 0),[l,C]=t.useState(void 0),[g,f]=t.useState(!1),[r,m]=t.useState([]),{get:F}=O(),d=F("chargesFilters"),I=t.useMemo(()=>{if(d)try{return JSON.parse(decodeURIComponent(d))}catch{return}},[d]),[o,j]=t.useState(I),S=t.useCallback((s,y)=>{r.map(h=>h.id).includes(s)?m(r.filter(h=>h.id!==s)):m([...r,{id:s,onChange:y}])},[r]),[{data:a,fetching:M},v]=E({query:b,variables:{filters:o},pause:!0});function P(){m([])}const i=t.useMemo(()=>a?.chargesWithLedgerChanges?.length?a.chargesWithLedgerChanges[a.chargesWithLedgerChanges.length-1].progress:0,[a?.chargesWithLedgerChanges]),L=t.useCallback(s=>{j(s)},[j]);return t.useEffect(()=>{o&&v()},[o,v]),t.useEffect(()=>{p(e.jsxs("div",{className:"flex flex-row gap-x-5 items-center",children:[e.jsx(J,{value:i,label:`${i?.toFixed(2)}%`,size:"xl",animate:i<100,className:"min-w-52"}),e.jsx(k,{filter:o,setFilter:L,activePage:0,setPage:()=>{},initiallyOpened:!0}),e.jsx(N,{content:"Expand all accounts",children:e.jsx(w,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>f(s=>!s),children:g?e.jsx($,{className:"size-5"}):e.jsx(G,{className:"size-5"})})}),e.jsx(B,{selected:r,resetMerge:P})]}))},[a,M,o,g,p,f,r,i,L]),e.jsxs(q,{title:"Charges Ledger Validation",description:"Manage charges",children:[M?e.jsx(T,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs(e.Fragment,{children:[e.jsx(R,{setEditChargeId:u,setInsertDocument:x,setMatchDocuments:C,toggleMergeCharge:S,mergeSelectedCharges:new Set(r.map(s=>s.id)),data:a?.chargesWithLedgerChanges.filter(s=>!!s.charge).map(s=>s.charge)??[],isAllOpened:g}),e.jsxs("div",{className:"flex flex-row justify-center my-2",children:[i>0&&i<100&&e.jsx(z,{}),i===100&&!a?.chargesWithLedgerChanges.filter(s=>!!s.charge).length&&e.jsx(V,{radius:"xl",size:"xl",color:"green",children:e.jsx(W,{})})]})]}),n&&e.jsx(A,{chargeId:n?.id,close:()=>u(void 0),onChange:n.onChange}),c&&e.jsx(Q,{chargeId:c.id,onChange:c.onChange,close:()=>x(void 0)}),l&&e.jsx(U,{chargeId:l.id,ownerId:l.ownerId,setMatchDocuments:()=>C(void 0)})]})};export{Le as ChargesLedgerValidation};