@accounter/client 0.0.8-alpha-20251029234818-bb69914cb7aaa4859296baa4a256c251158fd15b → 0.0.8-alpha-20251029235231-f14290dbb5dedec255de3cef292d3b4c5c71298e
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.
- package/CHANGELOG.md +1 -16
- package/dist/assets/{Checkbox-ChZFYaBU.js → Checkbox-m4EJFPdR.js} +2 -2
- package/dist/assets/{MultiSelect-h-orVW8D.js → MultiSelect-9iwOrNey.js} +1 -1
- package/dist/assets/{Progress-DVn-HXq3.js → Progress-jpjCOY1T.js} +1 -1
- package/dist/assets/{Table-B88LD0fO.js → Table-KlqUi970.js} +1 -1
- package/dist/assets/{Typography-DSr2wXoh.js → Typography-DcCXHm8f.js} +1 -1
- package/dist/assets/{YearPickerInput-DQjO6Nmm.js → YearPickerInput-CWNdAJVU.js} +1 -1
- package/dist/assets/{accordion-vlJV5349.js → accordion-DyS7JLRn.js} +1 -1
- package/dist/assets/accountant-approvals-BPCEe5wp.js +1 -0
- package/dist/assets/accounter-table-CdLG0nPv.js +1 -0
- package/dist/assets/{addDays-CiW9nfcU.js → addDays-C65N2SCe.js} +1 -1
- package/dist/assets/all-charges-CrhqMOdj.js +1 -0
- package/dist/assets/{arrow-up-down-DCZ98zEE.js → arrow-up-down-B8i8ydxe.js} +1 -1
- package/dist/assets/{building-2-MkMlc3HY.js → building-2-cN3QI06F.js} +1 -1
- package/dist/assets/{business-extended-info-CFdeLUKP.js → business-extended-info-DCsSJJtc.js} +4 -4
- package/dist/assets/{business-header-pPq6w0Xw.js → business-header-HggV7QvE.js} +1 -1
- package/dist/assets/{business-ledger-filters-ClJxXoLC.js → business-ledger-filters-B9SOs3sR.js} +1 -1
- package/dist/assets/business-ledger-single-BYrOpHks.js +1 -0
- package/dist/assets/business-nIHEv4T5.js +37 -0
- package/dist/assets/business-trip-CaVFJEg1.js +1 -0
- package/dist/assets/charge-XVI9hWTT.js +1 -0
- package/dist/assets/charges-filters-D2_BKbWX.js +1 -0
- package/dist/assets/charges-ledger-validation-FYtG72Q6.js +1 -0
- package/dist/assets/{charges-table-eZes2r5b.js → charges-table-BEP9lXbG.js} +6 -6
- package/dist/assets/{chart-BiPB-6_s.js → chart-DrNm6pqY.js} +1 -1
- package/dist/assets/{data-table-pagination-D9orF6C5.js → data-table-pagination-azA1p3g-.js} +1 -1
- package/dist/assets/{download-csv-button-DUWRJL2T.js → download-csv-button-DsnbHQxU.js} +1 -1
- package/dist/assets/{editable-business-trip-BhXW_0XH.js → editable-business-trip-DuwclYZj.js} +2 -2
- package/dist/assets/{funnel-DrJtNpvJ.js → funnel-DT4mmN3u.js} +1 -1
- package/dist/assets/{index-B0hUbUBg.js → index-4EzhixKH.js} +1 -1
- package/dist/assets/index-B7Rl68zJ.js +6 -0
- package/dist/assets/index-BD4s2ucv.css +1 -0
- package/dist/assets/{index-BidQYESH.js → index-BMBj2AP4.js} +2 -2
- package/dist/assets/{index-BNmy1oek.js → index-BPrO70_k.js} +1 -1
- package/dist/assets/index-BTtuW68l.js +1 -0
- package/dist/assets/index-BlKLmORp.js +1 -0
- package/dist/assets/{index--ZcPa6E_.js → index-Bt8Ea12_.js} +1 -1
- package/dist/assets/{index-Dl0o8K5Z.js → index-BzVbeSlP.js} +1 -1
- package/dist/assets/{index-BsEpUd8e.js → index-C1gcTg-z.js} +2 -2
- package/dist/assets/{index-CuoWV8xf.js → index-C3k8jflc.js} +196 -196
- package/dist/assets/index-CXHGrcA4.js +1 -0
- package/dist/assets/{index-DCJnXE5L.js → index-CjH08FXI.js} +1 -1
- package/dist/assets/{index-BG_PTq9Q.js → index-CsarR72G.js} +2 -2
- package/dist/assets/{index-XNTNgbUr.js → index-Cy1QJKqT.js} +1 -1
- package/dist/assets/{index-Crk-yNk8.js → index-DGb4vHzt.js} +1 -1
- package/dist/assets/{index-z10NcX_S.js → index-DKIBrU0J.js} +1 -1
- package/dist/assets/{index-CsYsahJ3.js → index-DTXvsvms.js} +1 -1
- package/dist/assets/{index-CQwkSv45.js → index-DY9WOuok.js} +1 -1
- package/dist/assets/{index-BHVgafF5.js → index-KrbE7--b.js} +1 -1
- package/dist/assets/index-SMnzi7Aw.js +1 -0
- package/dist/assets/{index-DmOniXdt.js → index-SWslvlxa.js} +1 -1
- package/dist/assets/{index-ZqxiihxR.js → index-faGFVNCX.js} +1 -1
- package/dist/assets/index-hM1FptsM.js +1 -0
- package/dist/assets/{index-CKSGCsKO.js → index-mUNwzNlf.js} +1 -1
- package/dist/assets/{index-HAjwT8i6.js → index-s6ijvE1i.js} +2 -2
- package/dist/assets/{index.es-BiiexU-G.js → index.es-BBqsLcyU.js} +1 -1
- package/dist/assets/{insert-business-trip-modal-CkXaCqH7.js → insert-business-trip-modal-DN3T9OON.js} +2 -2
- package/dist/assets/issue-document-lGktP9-p.js +1 -0
- package/dist/assets/{list-plus-BPyHtPSB.js → list-plus-2cRRgK1O.js} +1 -1
- package/dist/assets/{login-page-CGLD1xCA.js → login-page-DSTZWEBe.js} +1 -1
- package/dist/assets/{match-document-modal-BZOEBBCt.js → match-document-modal-DKRuRsKN.js} +4 -4
- package/dist/assets/missing-info-charges-CJZN7U_u.js +1 -0
- package/dist/assets/{modal-CguzFJgR.js → modal-DNhi-EIe.js} +1 -1
- package/dist/assets/{page-layout-jOFfeRt_.js → page-layout-x3aFVsg9.js} +1 -1
- package/dist/assets/{page-not-found-ghVdWRX4.js → page-not-found-KmbtQYNL.js} +1 -1
- package/dist/assets/{panel-top-open-BLNJL6FI.js → panel-top-open-B-b6XxK7.js} +1 -1
- package/dist/assets/{pencil-DePZCoA1.js → pencil-6cV3Nfmi.js} +1 -1
- package/dist/assets/{report-commentary-row-bJgTfAoe.js → report-commentary-row-PIhBXrbg.js} +1 -1
- package/dist/assets/{save-DDATKcb8.js → save-CjO_Dmsz.js} +1 -1
- package/dist/assets/similar-transactions-modal-C7aYlzhE.js +1 -0
- package/dist/assets/{sub-CUQX8erq.js → sub-CMuEnyTg.js} +1 -1
- package/dist/assets/subMonths-Cs2weYkL.js +1 -0
- package/dist/assets/summary-BWbSzpOQ.js +1 -0
- package/dist/assets/{toggle-expansion-button-BarJY9rA.js → toggle-expansion-button-B-4w-oFe.js} +1 -1
- package/dist/assets/tooltip-DG_b_ZsV.js +1 -0
- package/dist/assets/{use-url-query-CMqziw3P.js → use-url-query-BOxCMiZm.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +2 -2
- package/src/components/business/admin-business-section.tsx +103 -282
- package/src/components/business/charges-section.tsx +5 -5
- package/src/components/businesses/businesses-filters.tsx +7 -2
- package/src/components/charges/charges-filters.tsx +8 -3
- package/src/components/common/accounter-table.tsx +1 -3
- package/src/components/common/index.ts +1 -0
- package/src/components/common/pagination.tsx +84 -0
- package/src/components/ledger-table/index.tsx +15 -8
- package/src/components/transactions-table/index.tsx +11 -5
- package/src/components/ui/pagination.tsx +3 -99
- package/src/gql/gql.ts +3 -3
- package/src/gql/graphql.ts +17 -52
- package/dist/assets/Pagination-CraTfR0n.js +0 -1
- package/dist/assets/accountant-approvals-DOxFOZAO.js +0 -1
- package/dist/assets/accounter-table-D9Vunjfy.js +0 -1
- package/dist/assets/all-charges-bPDT5kwM.js +0 -1
- package/dist/assets/business-BIPODXgU.js +0 -37
- package/dist/assets/business-ledger-single-BOtdOkme.js +0 -1
- package/dist/assets/business-trip-6WyqArkv.js +0 -1
- package/dist/assets/charge-BbtacTJ9.js +0 -1
- package/dist/assets/charges-filters-Ir-7TzSP.js +0 -1
- package/dist/assets/charges-ledger-validation-6prUhTM_.js +0 -1
- package/dist/assets/create-event-handler-BiA-1lGu.js +0 -1
- package/dist/assets/index-1EyW0AOu.js +0 -1
- package/dist/assets/index-2OCszu-l.js +0 -1
- package/dist/assets/index-BKcxKTE4.js +0 -1
- package/dist/assets/index-BUJm5I0K.css +0 -1
- package/dist/assets/index-DVm5mt8x.js +0 -6
- package/dist/assets/index-SAaZFNWd.js +0 -1
- package/dist/assets/index-jf6jgMhL.js +0 -1
- package/dist/assets/issue-document-IUlUh6n7.js +0 -1
- package/dist/assets/missing-info-charges-C1QWCAWR.js +0 -1
- package/dist/assets/similar-transactions-modal-BxhD4UyN.js +0 -1
- package/dist/assets/subMonths-QOcbO9QP.js +0 -1
- package/dist/assets/summary-CBR-TMN0.js +0 -1
- package/dist/assets/tooltip-BFYX9MeB.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ek as It,r as B,eL as xt,bD as S,ah as o,bB as tt,bE as I,bC as m,fh as Et,bF as St,et as Nt,fM as Lt,f1 as jt}from"./index-CuoWV8xf.js";import{c as R}from"./create-event-handler-BiA-1lGu.js";function u(t,e){const a=e-t+1;return Array.from({length:a},(n,i)=>i+t)}const M="dots";function zt({total:t,siblings:e=1,boundaries:a=1,page:n,initialPage:i=1,onChange:s}){const r=Math.max(Math.trunc(t),0),[c,l]=It({value:n,onChange:s,defaultValue:i,finalValue:i}),f=v=>{v<=0?l(1):v>r?l(r):l(v)},g=()=>f(c+1),_=()=>f(c-1),d=()=>f(1),y=()=>f(r);return{range:B.useMemo(()=>{if(e*2+3+a*2>=r)return u(1,r);const w=Math.max(c-e,a),C=Math.min(c+e,r-a),b=w>a+2,$=C<r-(a+1);if(!b&&$){const O=e*2+a+2;return[...u(1,O),M,...u(r-(a-1),r)]}if(b&&!$){const O=a+1+2*e;return[...u(1,a),M,...u(r-O,r)]}return[...u(1,a),M,...u(w,C),M,...u(r-a+1,r)]},[r,e,c]),active:c,setPage:f,next:g,previous:_,first:d,last:y}}const[Rt,Z]=xt("Pagination.Root component was not found in tree"),Mt={siblings:1,boundaries:1};function ft(t){const{total:e,value:a,defaultValue:n,onChange:i,disabled:s,children:r,siblings:c,boundaries:l,color:f,radius:g,onNextPage:_,onPreviousPage:d,onFirstPage:y,onLastPage:j,getItemProps:v,classNames:w,styles:C,unstyled:b,variant:$,size:O}=S("PaginationRoot",Mt,t),{range:U,setPage:W,next:p,previous:z,active:G,first:q,last:J}=zt({page:a,initialPage:n,onChange:i,total:e,siblings:c,boundaries:l}),K=R(_,p),Q=R(d,z),X=R(y,q),Y=R(j,J);return o.createElement(Rt,{value:{total:e,range:U,active:G,disabled:s,color:f,radius:g,getItemProps:v,onChange:W,onNext:K,onPrevious:Q,onFirst:X,onLast:Y,stylesApi:{name:"Pagination",classNames:w,styles:C,unstyled:b,variant:$,size:O}}},r)}const E={xs:I(22),sm:I(26),md:I(32),lg:I(38),xl:I(44)};var Dt=tt((t,{color:e,radius:a,withPadding:n},{size:i})=>{const s=t.fn.variant({color:e,variant:"filled"});return{control:{cursor:"pointer",userSelect:"none",display:"flex",alignItems:"center",justifyContent:"center",border:`${I(1)} solid ${t.colorScheme==="dark"?t.colors.dark[4]:t.colors.gray[4]}`,color:t.colorScheme==="dark"?t.colors.dark[0]:t.black,height:m({size:i,sizes:E}),minWidth:m({size:i,sizes:E}),padding:n?`0 calc(${m({size:i,sizes:t.spacing})} / 2)`:void 0,fontSize:m({size:i,sizes:t.fontSizes}),borderRadius:t.fn.radius(a),lineHeight:1,backgroundColor:t.colorScheme==="dark"?t.colors.dark[6]:t.white,"&:not([data-disabled])":t.fn.hover({backgroundColor:t.colorScheme==="dark"?t.colors.dark[5]:t.colors.gray[0]}),"&:active:not([data-disabled])":t.activeStyles,"&[data-disabled]":{opacity:.4,cursor:"not-allowed",pointerEvents:"none"},"&[data-active]":{borderColor:"transparent",color:s.color,backgroundColor:s.background,"&:not([data-disabled])":t.fn.hover({backgroundColor:s.hover})}}}}),Ft=Object.defineProperty,Vt=Object.defineProperties,kt=Object.getOwnPropertyDescriptors,D=Object.getOwnPropertySymbols,dt=Object.prototype.hasOwnProperty,pt=Object.prototype.propertyIsEnumerable,nt=(t,e,a)=>e in t?Ft(t,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[e]=a,At=(t,e)=>{for(var a in e||(e={}))dt.call(e,a)&&nt(t,a,e[a]);if(D)for(var a of D(e))pt.call(e,a)&&nt(t,a,e[a]);return t},Bt=(t,e)=>Vt(t,kt(e)),Zt=(t,e)=>{var a={};for(var n in t)dt.call(t,n)&&e.indexOf(n)<0&&(a[n]=t[n]);if(t!=null&&D)for(var n of D(t))e.indexOf(n)<0&&pt.call(t,n)&&(a[n]=t[n]);return a};const Ht={withPadding:!0},H=B.forwardRef((t,e)=>{const a=S("PaginationControl",Ht,t),{active:n,className:i,disabled:s,withPadding:r}=a,c=Zt(a,["active","className","disabled","withPadding"]),l=Z(),{classes:f,cx:g}=Dt({color:l.color,radius:l.radius,withPadding:r},l.stylesApi);return o.createElement(Et,Bt(At({},c),{disabled:s,"data-active":n||void 0,"data-disabled":s||void 0,ref:e,className:g(f.control,i)}))});H.displayName="@mantine/core/PaginationControl";var Tt=Object.defineProperty,Ut=Object.defineProperties,Wt=Object.getOwnPropertyDescriptors,F=Object.getOwnPropertySymbols,gt=Object.prototype.hasOwnProperty,Pt=Object.prototype.propertyIsEnumerable,rt=(t,e,a)=>e in t?Tt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[e]=a,h=(t,e)=>{for(var a in e||(e={}))gt.call(e,a)&&rt(t,a,e[a]);if(F)for(var a of F(e))Pt.call(e,a)&&rt(t,a,e[a]);return t},N=(t,e)=>Ut(t,Wt(e)),Gt=(t,e)=>{var a={};for(var n in t)gt.call(t,n)&&e.indexOf(n)<0&&(a[n]=t[n]);if(t!=null&&F)for(var n of F(t))e.indexOf(n)<0&&Pt.call(t,n)&&(a[n]=t[n]);return a};function vt(t){return`calc(${m({size:t,sizes:E})} / 2)`}function L(t){var e=t,{size:a,style:n,children:i,path:s}=e,r=Gt(e,["size","style","children","path"]);return o.createElement("svg",h({viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",style:h({width:a,height:a},n)},r),o.createElement("path",{d:s,fill:"currentColor"}))}const qt=t=>o.createElement(L,N(h({},t),{path:"M8.781 8l-3.3-3.3.943-.943L10.667 8l-4.243 4.243-.943-.943 3.3-3.3z"})),Jt=t=>o.createElement(L,N(h({},t),{path:"M7.219 8l3.3 3.3-.943.943L5.333 8l4.243-4.243.943.943-3.3 3.3z"})),Kt=t=>o.createElement(L,N(h({},t),{path:"M6.85355 3.85355C7.04882 3.65829 7.04882 3.34171 6.85355 3.14645C6.65829 2.95118 6.34171 2.95118 6.14645 3.14645L2.14645 7.14645C1.95118 7.34171 1.95118 7.65829 2.14645 7.85355L6.14645 11.8536C6.34171 12.0488 6.65829 12.0488 6.85355 11.8536C7.04882 11.6583 7.04882 11.3417 6.85355 11.1464L3.20711 7.5L6.85355 3.85355ZM12.8536 3.85355C13.0488 3.65829 13.0488 3.34171 12.8536 3.14645C12.6583 2.95118 12.3417 2.95118 12.1464 3.14645L8.14645 7.14645C7.95118 7.34171 7.95118 7.65829 8.14645 7.85355L12.1464 11.8536C12.3417 12.0488 12.6583 12.0488 12.8536 11.8536C13.0488 11.6583 13.0488 11.3417 12.8536 11.1464L9.20711 7.5L12.8536 3.85355Z"})),Qt=t=>o.createElement(L,N(h({},t),{path:"M2.14645 11.1464C1.95118 11.3417 1.95118 11.6583 2.14645 11.8536C2.34171 12.0488 2.65829 12.0488 2.85355 11.8536L6.85355 7.85355C7.04882 7.65829 7.04882 7.34171 6.85355 7.14645L2.85355 3.14645C2.65829 2.95118 2.34171 2.95118 2.14645 3.14645C1.95118 3.34171 1.95118 3.65829 2.14645 3.85355L5.79289 7.5L2.14645 11.1464ZM8.14645 11.1464C7.95118 11.3417 7.95118 11.6583 8.14645 11.8536C8.34171 12.0488 8.65829 12.0488 8.85355 11.8536L12.8536 7.85355C13.0488 7.65829 13.0488 7.34171 12.8536 7.14645L8.85355 3.14645C8.65829 2.95118 8.34171 2.95118 8.14645 3.14645C7.95118 3.34171 7.95118 3.65829 8.14645 3.85355L11.7929 7.5L8.14645 11.1464Z"})),Xt=t=>o.createElement(L,N(h({},t),{path:"M2 8c0-.733.6-1.333 1.333-1.333.734 0 1.334.6 1.334 1.333s-.6 1.333-1.334 1.333C2.6 9.333 2 8.733 2 8zm9.333 0c0-.733.6-1.333 1.334-1.333C13.4 6.667 14 7.267 14 8s-.6 1.333-1.333 1.333c-.734 0-1.334-.6-1.334-1.333zM6.667 8c0-.733.6-1.333 1.333-1.333s1.333.6 1.333 1.333S8.733 9.333 8 9.333 6.667 8.733 6.667 8z"}));var Yt=tt((t,e,{size:a})=>({dots:{height:m({size:a,sizes:E}),minWidth:m({size:a,sizes:E}),display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none"}})),te=Object.defineProperty,V=Object.getOwnPropertySymbols,ut=Object.prototype.hasOwnProperty,mt=Object.prototype.propertyIsEnumerable,ot=(t,e,a)=>e in t?te(t,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[e]=a,ee=(t,e)=>{for(var a in e||(e={}))ut.call(e,a)&&ot(t,a,e[a]);if(V)for(var a of V(e))mt.call(e,a)&&ot(t,a,e[a]);return t},ae=(t,e)=>{var a={};for(var n in t)ut.call(t,n)&&e.indexOf(n)<0&&(a[n]=t[n]);if(t!=null&&V)for(var n of V(t))e.indexOf(n)<0&&mt.call(t,n)&&(a[n]=t[n]);return a};const ne={icon:Xt},et=B.forwardRef((t,e)=>{const a=S("PaginationDots",ne,t),{className:n,icon:i}=a,s=ae(a,["className","icon"]),r=Z(),{classes:c,cx:l}=Yt(null,r.stylesApi);return o.createElement(St,ee({ref:e,className:l(c.dots,n)},s),o.createElement(i,{size:vt(r.stylesApi.size)}))});et.displayName="@mantine/core/PaginationDots";var re=Object.defineProperty,it=Object.getOwnPropertySymbols,oe=Object.prototype.hasOwnProperty,ie=Object.prototype.propertyIsEnumerable,st=(t,e,a)=>e in t?re(t,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[e]=a,se=(t,e)=>{for(var a in e||(e={}))oe.call(e,a)&&st(t,a,e[a]);if(it)for(var a of it(e))ie.call(e,a)&&st(t,a,e[a]);return t};function at({dotsIcon:t}){const e=Z(),a=e.range.map((n,i)=>{var s;return n==="dots"?o.createElement(et,{icon:t,key:i}):o.createElement(H,se({key:i,active:n===e.active,"aria-current":n===e.active?"page":void 0,onClick:()=>e.onChange(n),disabled:e.disabled},(s=e.getItemProps)==null?void 0:s.call(e,n)),n)});return o.createElement(o.Fragment,null,a)}at.displayName="@mantine/core/PaginationItems";var le=tt(t=>({icon:{transform:t.dir==="rtl"?"rotate(180deg)":"unset"}})),ce=Object.defineProperty,k=Object.getOwnPropertySymbols,_t=Object.prototype.hasOwnProperty,yt=Object.prototype.propertyIsEnumerable,lt=(t,e,a)=>e in t?ce(t,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[e]=a,fe=(t,e)=>{for(var a in e||(e={}))_t.call(e,a)&<(t,a,e[a]);if(k)for(var a of k(e))yt.call(e,a)&<(t,a,e[a]);return t},de=(t,e)=>{var a={};for(var n in t)_t.call(t,n)&&e.indexOf(n)<0&&(a[n]=t[n]);if(t!=null&&k)for(var n of k(t))e.indexOf(n)<0&&yt.call(t,n)&&(a[n]=t[n]);return a};function T({icon:t,name:e,action:a,type:n}){const i={icon:t},s=B.forwardRef((r,c)=>{const l=S(e,i,r),{icon:f}=l,g=de(l,["icon"]),{classes:_}=le(),d=Z(),y=n==="next"?d.active===d.total:d.active===1;return o.createElement(H,fe({disabled:d.disabled||y,ref:c,onClick:d[a],withPadding:!1},g),o.createElement(f,{className:_.icon,size:vt(d.stylesApi.size)}))});return s.displayName=`@mantine/core/${e}`,Nt(s)}const Ot=T({icon:qt,name:"PaginationNext",action:"onNext",type:"next"}),ht=T({icon:Jt,name:"PaginationPrevious",action:"onPrevious",type:"previous"}),wt=T({icon:Kt,name:"PaginationFirst",action:"onFirst",type:"previous"}),Ct=T({icon:Qt,name:"PaginationLast",action:"onLast",type:"next"});var pe=Object.defineProperty,A=Object.getOwnPropertySymbols,bt=Object.prototype.hasOwnProperty,$t=Object.prototype.propertyIsEnumerable,ct=(t,e,a)=>e in t?pe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[e]=a,x=(t,e)=>{for(var a in e||(e={}))bt.call(e,a)&&ct(t,a,e[a]);if(A)for(var a of A(e))$t.call(e,a)&&ct(t,a,e[a]);return t},ge=(t,e)=>{var a={};for(var n in t)bt.call(t,n)&&e.indexOf(n)<0&&(a[n]=t[n]);if(t!=null&&A)for(var n of A(t))e.indexOf(n)<0&&$t.call(t,n)&&(a[n]=t[n]);return a};const Pe={withControls:!0,siblings:1,boundaries:1};function P(t){const e=S("Pagination",Pe,t),{withEdges:a,withControls:n,classNames:i,styles:s,unstyled:r,variant:c,size:l,total:f,value:g,defaultValue:_,onChange:d,disabled:y,siblings:j,boundaries:v,color:w,radius:C,onNextPage:b,onPreviousPage:$,onFirstPage:O,onLastPage:U,getItemProps:W,getControlProps:p,spacing:z,nextIcon:G,previousIcon:q,lastIcon:J,firstIcon:K,dotsIcon:Q}=e,X=ge(e,["withEdges","withControls","classNames","styles","unstyled","variant","size","total","value","defaultValue","onChange","disabled","siblings","boundaries","color","radius","onNextPage","onPreviousPage","onFirstPage","onLastPage","getItemProps","getControlProps","spacing","nextIcon","previousIcon","lastIcon","firstIcon","dotsIcon"]),Y=Lt();return f<=0?null:o.createElement(ft,{classNames:i,styles:s,unstyled:r,variant:c,size:l,total:f,value:g,defaultValue:_,onChange:d,disabled:y,siblings:j,boundaries:v,color:w,radius:C,onNextPage:b,onPreviousPage:$,onFirstPage:O,onLastPage:U,getItemProps:W},o.createElement(jt,x({spacing:z??`calc(${m({size:l,sizes:Y.spacing})} / 2)`},X),a&&o.createElement(wt,x({icon:K},p?.("first"))),n&&o.createElement(ht,x({icon:q},p?.("previous"))),o.createElement(at,{dotsIcon:Q}),n&&o.createElement(Ot,x({icon:G},p?.("next"))),a&&o.createElement(Ct,x({icon:J},p?.("last")))))}P.displayName="@mantine/core/Pagination";P.Root=ft;P.Items=at;P.Control=H;P.Dots=et;P.Next=Ot;P.Previous=ht;P.Last=Ct;P.First=wt;export{P};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as s,F as h,ae as v,ag as C,u as P,j as e,L as A,h9 as F}from"./index-CuoWV8xf.js";import{u as b}from"./use-url-query-CMqziw3P.js";import{C as y}from"./charges-filters-Ir-7TzSP.js";import{P as j}from"./page-layout-jOFfeRt_.js";import{P as D}from"./Progress-DVn-HXq3.js";import"./modal-CguzFJgR.js";import"./Pagination-CraTfR0n.js";import"./create-event-handler-BiA-1lGu.js";import"./funnel-DrJtNpvJ.js";import"./sub-CUQX8erq.js";import"./addDays-CiW9nfcU.js";import"./subMonths-QOcbO9QP.js";import"./MultiSelect-h-orVW8D.js";const T=()=>{const{setFiltersContext:i}=s.useContext(h),{get:c}=b(),{userContext:p}=s.useContext(v),[a,m]=s.useState(c("chargesFilters")?JSON.parse(decodeURIComponent(c("chargesFilters"))):{byOwners:p?.context.adminBusinessId?[p?.context.adminBusinessId]:[],sortBy:{field:C.Date,asc:!1},toAnyDate:null,fromAnyDate:null}),[{data:r,fetching:u}]=P({query:F,variables:{filters:a,page:1,limit:999999}}),t=r?.allCharges?.nodes.length??0;let o=0,l=0,n=0;r?.allCharges?.nodes.map(f=>{switch(f.accountantApproval){case"APPROVED":o+=1;break;case"PENDING":l+=1;break;case"UNAPPROVED":n+=1;break}});const x=100*o/t,d=100*l/t,g=100*n/t;return s.useEffect(()=>{i(e.jsx("div",{className:"flex flex-row gap-x-5",children:e.jsx(y,{filter:a,setFilter:m,activePage:1,setPage:()=>{},totalPages:1})}))},[r,u,a,i,m]),e.jsx(j,{title:"Accountant Approvals Status",children:u?e.jsx(A,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs("div",{className:"mx-10 mt-5 flex flex-col gap-5",children:[`Total charges: ${t}`,e.jsx(D,{color:"green",radius:"xl",size:"xl",sections:[{value:x,color:"green",label:`${x.toFixed(1)}% (${o})`},{value:d,color:"orange",label:`${d.toFixed(1)}% (${l})`},{value:g,color:"red",label:`${g.toFixed(1)}% (${n})`}]})]})})};export{T as AccountantApprovals};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as s,j as t,B as a,dW as d}from"./index-CuoWV8xf.js";import{P as c}from"./Pagination-CraTfR0n.js";import{T as h}from"./Table-B88LD0fO.js";function m(e){const[i,o]=s.useState(!1),n=e.moreInfo?e.moreInfo(e.item):null;return t.jsxs(t.Fragment,{children:[t.jsxs("tr",{children:[e.columns.map((l,r)=>l.disabled?null:t.jsx("td",{style:l.style,children:l.value(e.item,e.rowContext?e.rowContext(e.item):void 0)},String(r))),e.moreInfo&&t.jsx("td",{children:n===null?t.jsx("p",{children:"No Data Related"}):t.jsx(a,{onClick:()=>o(!i),className:"ml-auto",children:"More Info"})})]}),(e.isShowAll||i)&&n!==null&&t.jsx("tr",{children:t.jsx("td",{colSpan:12,children:t.jsx(d,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:n})})})]})}function j(e){const[i,o]=s.useState(!1);return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-row justify-end w-full",children:[e.pagination&&t.jsx(c,{className:"flex-auto",...e.pagination}),e.showButton===!0?t.jsx(a,{type:"button",onClick:()=>{o(n=>!n)},children:i?"Hide All":"Show All"}):null]}),t.jsxs(h,{striped:e.striped,highlightOnHover:e.highlightOnHover,children:[t.jsx("thead",{style:e.stickyHeader?{position:"sticky",top:0,zIndex:20}:{},children:t.jsxs("tr",{className:"px-10 py-10 title-font tracking-wider font-medium text-gray-900 text-sm bg-gray-100 rounded-tl rounded-bl",children:[e.columns.map((n,l)=>n.disabled?null:t.jsx("th",{children:n.title},String(l))),e.moreInfo&&t.jsx("th",{children:"More Info"})]})}),t.jsx("tbody",{children:e.items.map((n,l)=>t.jsx(m,{columns:e.columns,item:n,moreInfo:e.moreInfo,isShowAll:i,rowContext:e.rowContext},l))})]})]})}export{m as A,j as a};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as t,F as y,u as A,j as e,T as N,B as b,L as w,A as O}from"./index-CuoWV8xf.js";import{u as T}from"./use-url-query-CMqziw3P.js";import{C as z}from"./charges-filters-Ir-7TzSP.js";import{C as B}from"./charges-table-eZes2r5b.js";import{M as L}from"./index-DCJnXE5L.js";import{E as R,I as k,M as Q}from"./match-document-modal-BZOEBBCt.js";import{P as U}from"./page-layout-jOFfeRt_.js";import{P as q,a as J}from"./panel-top-open-BLNJL6FI.js";import"./modal-CguzFJgR.js";import"./Pagination-CraTfR0n.js";import"./create-event-handler-BiA-1lGu.js";import"./funnel-DrJtNpvJ.js";import"./sub-CUQX8erq.js";import"./addDays-CiW9nfcU.js";import"./subMonths-QOcbO9QP.js";import"./MultiSelect-h-orVW8D.js";import"./toggle-expansion-button-BarJY9rA.js";import"./index-DVm5mt8x.js";import"./similar-transactions-modal-BxhD4UyN.js";import"./list-plus-BPyHtPSB.js";import"./tooltip-BFYX9MeB.js";import"./Table-B88LD0fO.js";import"./summary-CBR-TMN0.js";import"./Checkbox-ChZFYaBU.js";import"./YearPickerInput-DQjO6Nmm.js";import"./insert-business-trip-modal-CkXaCqH7.js";import"./accounter-table-D9Vunjfy.js";const fe=()=>{const{setFiltersContext:h}=t.useContext(y),[i,C]=t.useState(void 0),[n,f]=t.useState(void 0),[l,x]=t.useState(void 0),[c,j]=t.useState(!1),[a,m]=t.useState([]),{get:p}=T(),[d,M]=t.useState(p("page")?Number(p("page")):1),g=p("chargesFilters"),v=t.useMemo(()=>{if(g)try{return JSON.parse(decodeURIComponent(g))}catch{return}},[g]),[r,S]=t.useState(v),D=t.useCallback((s,F)=>{a.map(u=>u.id).includes(s)?m(a.filter(u=>u.id!==s)):m([...a,{id:s,onChange:F}])},[a]),[{data:o,fetching:I},P]=A({query:O,variables:{filters:r,page:d,limit:100},pause:!0});t.useEffect(()=>{r&&P()},[r,P]);function E(){m([])}return t.useEffect(()=>{h(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(z,{filter:r,setFilter:S,activePage:d,setPage:M,totalPages:o?.allCharges?.pageInfo.totalPages,initiallyOpened:!r}),e.jsx(N,{label:"Expand all accounts",children:e.jsx(b,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>j(s=>!s),children:c?e.jsx(q,{className:"size-5"}):e.jsx(J,{className:"size-5"})})}),e.jsx(L,{selected:a,resetMerge:E})]}))},[o,I,r,d,c,h,M,S,j,a,v]),e.jsxs(U,{title:"All Charges",description:"Manage charges",children:[I?e.jsx(w,{className:"h-10 w-10 animate-spin mr-2 self-center"}):o?.allCharges.nodes?e.jsx(B,{setEditChargeId:C,setInsertDocument:f,setMatchDocuments:x,toggleMergeCharge:D,mergeSelectedCharges:new Set(a.map(s=>s.id)),data:o?.allCharges?.nodes,isAllOpened:c}):e.jsx("span",{children:"Please apply filters"}),i&&e.jsx(R,{chargeId:i?.id,close:()=>C(void 0),onChange:i.onChange}),n&&e.jsx(k,{chargeId:n.id,onChange:n.onChange,close:()=>f(void 0)}),l&&e.jsx(Q,{chargeId:l.id,ownerId:l.ownerId,setMatchDocuments:()=>x(void 0)})]})};export{fe as AllCharges};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import{v as ne,w as we,S as Te,x as ce,u as ie,y as zs,r as C,j as e,D as Xe,z as Je,E as Us,c as vs,g as Be,t as $,i as Pe,U as qs,G as Le,H as Qe,J as Ie,K as Se,N as G,O as W,P as ys,Q as K,V as H,W as Oe,X as Y,Y as y,Z as N,_ as b,$ as w,I as k,a0 as T,a1 as I,a2 as ge,B as D,a3 as M,a4 as Q,a5 as oe,a6 as Ze,a7 as Gs,a8 as Ae,a9 as es,aa as te,ab as R,ac as ss,ad as ze,ae as as,af as Ws,ag as Ks,ah as V,ai as ls,aj as Hs,ak as Ys,al as Xs,am as ae,an as ee,ao as Js,ap as Qs,aq as Zs,ar as Ue,as as fe,at as ve,au as ye,av as Ne,aw as ea,ax as be,ay as sa,az as aa,aA as se,aB as ta,aC as na,aD as qe,aE as Ge,aF as Ns,aG as ia,aH as We,aI as ra,aJ as bs,aK as cs,aL as Cs,aM as la,aN as ca,aO as ts,aP as ws,aQ as ns,aR as As,aS as Is,aT as Ss,aU as Ds,aV as ks,aW as Ts,aX as oa,aY as xe,aZ as da,a_ as ma,a$ as ua,b0 as ha,b1 as xa,b2 as pa,b3 as ja,b4 as ga,b5 as fa,b6 as S,b7 as va,b8 as is,b9 as ya,ba as Na,bb as ba,bc as Ca,F as wa,bd as Aa,be as Ia,bf as J,bg as Sa,bh as Da,bi as U,bj as ka,a as Ta,b as Ea,bk as Ba}from"./index-CuoWV8xf.js";import{S as rs}from"./save-DDATKcb8.js";import{B as Pa}from"./business-extended-info-CFdeLUKP.js";import{B as La}from"./business-header-pPq6w0Xw.js";import{S as Oa,C as Fa,L as Va}from"./charges-table-eZes2r5b.js";import{P as _a}from"./Pagination-CraTfR0n.js";import{i as Ra,D as Ma,f as $a,E as za,L as Ve,a as De,C as Ua,A as qa,b as pe,c as Ga,d as Ke,h as Wa,e as Ka,g as Es,u as Ha,G as Ya,j as os,k as Xa,X as Bs,Y as Ps,l as Ja,m as Qa,R as Za,n as et,o as st,p as at}from"./chart-BiPB-6_s.js";import{P as tt}from"./pencil-DePZCoA1.js";import{E as nt,T as it}from"./index-DVm5mt8x.js";import{A as rt,a as _e,b as Re,c as ds}from"./accordion-vlJV5349.js";import{B as lt}from"./building-2-MkMlc3HY.js";import"./download-csv-button-DUWRJL2T.js";import"./Table-B88LD0fO.js";import"./toggle-expansion-button-BarJY9rA.js";import"./panel-top-open-BLNJL6FI.js";import"./summary-CBR-TMN0.js";import"./create-event-handler-BiA-1lGu.js";import"./list-plus-BPyHtPSB.js";import"./sequential-CAnleQny.js";import"./similar-transactions-modal-BxhD4UyN.js";import"./addDays-CiW9nfcU.js";import"./tooltip-BFYX9MeB.js";/**
|
|
2
|
-
* @license lucide-react v0.548.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const ct=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],ot=ne("chart-line",ct);/**
|
|
7
|
-
* @license lucide-react v0.548.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const dt=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],ms=ne("circle-check",dt);/**
|
|
12
|
-
* @license lucide-react v0.548.0 - ISC
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the ISC license.
|
|
15
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const mt=[["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=ne("dollar-sign",mt);/**
|
|
17
|
-
* @license lucide-react v0.548.0 - ISC
|
|
18
|
-
*
|
|
19
|
-
* This source code is licensed under the ISC license.
|
|
20
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const ut=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m9 15 2 2 4-4",key:"1grp1n"}]],ht=ne("file-check",ut);/**
|
|
22
|
-
* @license lucide-react v0.548.0 - ISC
|
|
23
|
-
*
|
|
24
|
-
* This source code is licensed under the ISC license.
|
|
25
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const xt=[["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"}]],pt=ne("notebook",xt);/**
|
|
27
|
-
* @license lucide-react v0.548.0 - ISC
|
|
28
|
-
*
|
|
29
|
-
* This source code is licensed under the ISC license.
|
|
30
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const jt=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]],gt=ne("plug",jt);/**
|
|
32
|
-
* @license lucide-react v0.548.0 - ISC
|
|
33
|
-
*
|
|
34
|
-
* This source code is licensed under the ISC license.
|
|
35
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
-
*/const ft=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],Me=ne("trending-up",ft);function Ls(s){switch(s){case we.Annual:return"Annual";case we.Monthly:return"Monthly";default:throw new Error(`Unsupported Billing Cycle: ${s}`)}}function Os(s){switch(s){case Te.Enterprise:return"Enterprise";case Te.Pro:return"Pro";default:throw new Error(`Unsupported Subscription plan: ${s}`)}}function vt(s){return ce(s,"yyyy-MM-dd")}function yt({businessId:s,tagIds:a,description:t,open:n,onOpenChange:l,onClose:o}){const[{data:r,fetching:i},c]=ie({pause:!0,query:zs,variables:{businessId:s,tagsDifferentThan:a?a.map(u=>u.id):void 0,descriptionDifferentThan:t}});C.useEffect(()=>{n&&(a||t)&&!r&&c()},[n,a,t,c,r]);const d=C.useCallback(u=>{l(u),n&&!u&&o?.()},[l,o,n]),h=C.useMemo(()=>n&&(!!a||!!t)&&r&&r?.similarChargesByBusiness.length>0,[n,a,t,r]);return e.jsx(Xe,{open:h,onOpenChange:d,children:e.jsx(Je,{className:"overflow-scroll max-h-screen w-full sm:max-w-[640px] md:max-w-[768px] lg:max-w-[900px]",onClick:u=>u.stopPropagation(),children:e.jsx(Us,{fallback:e.jsx("div",{children:"Error fetching similar charges"}),children:i?e.jsx(vs,{}):a||t?e.jsx(Oa,{data:r?.similarChargesByBusiness??[],tagIds:a,description:t,onOpenChange:d,title:"Similar Charges by Business"}):null})})})}const Nt="updateAdminBusiness",bt=()=>{const[{fetching:s},a]=Be(qs),t=C.useCallback(async n=>{const l=`Error updating admin business ID [${n.adminBusinessId}]`,o=`${Nt}-${n.adminBusinessId}`;$.loading("Updating admin business",{id:o});try{const r=await a(n),i=Pe(r,l,o,"updateAdminBusiness");if(i)return $.success("Success",{id:o,description:"Admin Business Updated"}),i.updateAdminBusiness}catch(r){console.error(`${l}: ${r}`),$.error("Error",{id:o,description:l,duration:1e5,closeButton:!0})}},[a]);return{fetching:s,updateAdminBusiness:t}},$e=Ae({year:ss().min(2e3).max(2100),id:R().min(1,{message:"ID is required"})}),Ct=Ae({registrationDate:R().min(1,{message:"Business Registration Start Date is required"}),withholdingTaxAnnualIds:te($e),withholdingTaxCompanyId:R().min(1,{message:"Withholding Tax Company ID is required"}),socialSecurityEmployerIds:te($e),socialSecurityDeductionsId:R().min(1,{message:"Social Security Deductions ID is required"}),taxAdvancesAnnualIds:te($e),taxAdvancesRates:te(Ae({date:ze(),rate:ss().min(0,{message:"Rate must be at least 0"}).max(100,{message:"Rate must be at most 100"})}))});function us(s){return!s||s.__typename!=="LtdFinancialEntity"||!s.adminInfo?{}:{registrationDate:s.adminInfo.registrationDate,withholdingTaxAnnualIds:s.adminInfo.withholdingTaxAnnualIds.sort((a,t)=>t.year-a.year),withholdingTaxCompanyId:s.adminInfo.withholdingTaxCompanyId??void 0,socialSecurityEmployerIds:s.adminInfo.socialSecurityEmployerIds.sort((a,t)=>t.year-a.year),socialSecurityDeductionsId:s.adminInfo.socialSecurityDeductionsId??void 0,taxAdvancesAnnualIds:s.adminInfo.taxAdvancesAnnualIds.sort((a,t)=>t.year-a.year),taxAdvancesRates:s.adminInfo.taxAdvancesRates?.map(a=>({date:a.date,rate:a.rate*100}))}}function wt(s){return{registrationDate:s.registrationDate?vt(new Date(s.registrationDate)):void 0,withholdingTaxAnnualIds:s.withholdingTaxAnnualIds,withholdingTaxCompanyId:s.withholdingTaxCompanyId,socialSecurityEmployerIds:s.socialSecurityEmployerIds,taxAdvancesRates:s.taxAdvancesRates?.map(a=>({date:a.date,rate:a.rate/100})),taxAdvancesAnnualIds:s.taxAdvancesAnnualIds}}function At({data:s,refetchBusiness:a}){const t=Ie(Gs,s),[n,l]=C.useState(us(t)),{updateAdminBusiness:o,fetching:r}=bt(),i=Le({resolver:Qe(Ct),defaultValues:n}),c=async x=>{if(!t)return;const j=es(x,i.formState.dirtyFields);if(!j)return;const P=wt(j);await o({adminBusinessId:t.id,fields:P}),a?.()};C.useEffect(()=>{if(t){const x=us(t);l(x),i.reset(x)}},[t,i]);const{fields:d,append:h,remove:u}=Se({control:i.control,name:"taxAdvancesAnnualIds"}),{fields:p,append:g,remove:A}=Se({control:i.control,name:"withholdingTaxAnnualIds"}),{fields:E,append:B,remove:O}=Se({control:i.control,name:"socialSecurityEmployerIds"}),m={withholdingTaxAnnualIds:{append:g,remove:A},taxAdvancesAnnualIds:{append:h,remove:u},socialSecurityEmployerIds:{append:B,remove:O}},f=x=>{m[x].append({year:new Date().getFullYear(),id:""})},L=(x,j)=>{m[x].remove(j)},{fields:F,append:X,remove:z}=Se({control:i.control,name:"taxAdvancesRates"}),Z=()=>{X({date:ce(new Date,"yyyy-MM-dd"),rate:0})},v=x=>{z(x)};return e.jsxs(G,{children:[e.jsxs(W,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ys,{className:"h-5 w-5 text-primary"}),e.jsx(K,{children:"Admin Business Configuration"})]}),e.jsx(H,{children:"Tax and registration information for the business operating this application"})]}),e.jsx(Oe,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(c),className:"space-y-6",children:[e.jsx(Y,{children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground md:col-span-2",children:"Withholding Tax"}),e.jsx(y,{control:i.control,name:"withholdingTaxCompanyId",render:({field:x,fieldState:j})=>e.jsxs(N,{children:[e.jsx(b,{children:"Company Tax ID"}),e.jsx(w,{children:e.jsx(k,{placeholder:"Enter company ID",...x,className:T(j)})}),e.jsx(I,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ge,{children:"Annual IDs"}),e.jsx(D,{type:"button",variant:"outline",size:"sm",onClick:()=>f("withholdingTaxAnnualIds"),children:e.jsx(M,{className:"size-4"})})]}),e.jsx("div",{className:"space-y-3",children:p.map((x,j)=>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(k,{placeholder:"Year",type:"number",...i.register(`withholdingTaxAnnualIds.${j}.year`,{valueAsNumber:!0})}),e.jsx(k,{placeholder:"ID",...i.register(`withholdingTaxAnnualIds.${j}.id`)})]}),e.jsx(D,{type:"button",variant:"ghost",size:"icon",onClick:()=>L("withholdingTaxAnnualIds",j),children:e.jsx(Q,{className:"size-4"})})]},x.id))})]}),e.jsx(oe,{className:"md:col-span-2"}),e.jsx("h3",{className:"text-sm font-semibold text-foreground md:col-span-2",children:"Tax Advances"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ge,{children:"Annual IDs"}),e.jsx(D,{type:"button",variant:"outline",size:"sm",onClick:()=>f("taxAdvancesAnnualIds"),children:e.jsx(M,{className:"size-4"})})]}),e.jsx("div",{className:"space-y-3",children:d.map((x,j)=>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(k,{placeholder:"Year",type:"number",...i.register(`taxAdvancesAnnualIds.${j}.year`,{valueAsNumber:!0})}),e.jsx(k,{placeholder:"ID",...i.register(`taxAdvancesAnnualIds.${j}.id`)})]}),e.jsx(D,{type:"button",variant:"ghost",size:"icon",onClick:()=>L("taxAdvancesAnnualIds",j),children:e.jsx(Q,{className:"size-4"})})]},x.id))})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ge,{children:"Rates (%)"}),e.jsx(D,{type:"button",variant:"outline",size:"sm",onClick:Z,children:e.jsx(M,{className:"size-4"})})]}),e.jsx("div",{className:"space-y-3",children:F.map((x,j)=>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(k,{placeholder:"Date",type:"date",...i.register(`taxAdvancesRates.${j}.date`)}),e.jsx(k,{placeholder:"Rate",...i.register(`taxAdvancesRates.${j}.rate`,{valueAsNumber:!0})})]}),e.jsx(D,{type:"button",variant:"ghost",size:"icon",onClick:()=>v(j),children:e.jsx(Q,{className:"size-4"})})]},x.id))})]}),e.jsx(oe,{className:"md:col-span-2"}),e.jsx("h3",{className:"text-sm font-semibold text-foreground md:col-span-2",children:"Social Security"}),e.jsx(y,{control:i.control,name:"socialSecurityDeductionsId",render:({field:x,fieldState:j})=>e.jsxs(N,{children:[e.jsx(b,{children:"Deductions ID"}),e.jsx(w,{children:e.jsx(k,{placeholder:"Enter deductions ID",...x,className:T(j)})}),e.jsx(I,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ge,{children:"Annual Employer IDs"}),e.jsx(D,{type:"button",variant:"outline",size:"sm",onClick:()=>f("socialSecurityEmployerIds"),children:e.jsx(M,{className:"size-4"})})]}),e.jsx("div",{className:"space-y-3",children:E.map((x,j)=>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(k,{placeholder:"Year",type:"number",...i.register(`socialSecurityEmployerIds.${j}.year`,{valueAsNumber:!0})}),e.jsx(k,{placeholder:"ID",...i.register(`socialSecurityEmployerIds.${j}.id`)})]}),e.jsx(D,{type:"button",variant:"ghost",size:"icon",onClick:()=>L("socialSecurityEmployerIds",j),children:e.jsx(Q,{className:"size-4"})})]},x.id))})]}),e.jsx(oe,{className:"md:col-span-2"}),e.jsx(y,{control:i.control,name:"registrationDate",render:({field:x,fieldState:j})=>e.jsxs(N,{children:[e.jsx(b,{children:"Business Registration Start Date"}),e.jsx(w,{children:e.jsx(k,{type:"date",...x,className:T(j)})}),e.jsx(I,{})]})})]})}),e.jsx(Ze,{className:"flex justify-end border-t mt-4 pt-6",children:e.jsxs(D,{type:"submit",disabled:r||Object.keys(i.formState.dirtyFields).length===0||!i.formState.isValid,children:[e.jsx(rs,{className:"h-4 w-4"}),"Save Changes"]})})]})})]})}function It({businessId:s}){return e.jsxs(G,{children:[e.jsx(W,{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(K,{children:"Balance"}),e.jsx(H,{children:"Business balance overview"})]})})}),e.jsx(Y,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Pa,{businessID:s,filter:{}})})})]})}function St({businessId:s}){const{userContext:a}=C.useContext(as),[t,n]=C.useState(1),[{data:l,fetching:o}]=ie({query:Ws,variables:{filters:{byOwners:a?.context.adminBusinessId?[a.context.adminBusinessId]:void 0,sortBy:{field:Ks.Date,asc:!1},byBusinesses:[s]},page:t,limit:100}}),r=l?.allCharges?.pageInfo.totalPages??1,i=l?.allCharges?.nodes??[];return o?e.jsx("div",{children:"Loading charges..."}):e.jsxs(G,{children:[e.jsxs(W,{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(K,{children:"Charges"}),e.jsx(H,{children:"Recurring and one-time charges for this business"})]})}),r>1&&e.jsx(_a,{className:"flex-fit",value:t,onChange:n,total:r})]}),e.jsx(Y,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Fa,{data:i,isAllOpened:!1})})})]})}var Dt=["type","layout","connectNulls","ref"],kt=["key"];function de(s){"@babel/helpers - typeof";return de=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},de(s)}function hs(s,a){if(s==null)return{};var t=Tt(s,a),n,l;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(s);for(l=0;l<o.length;l++)n=o[l],!(a.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(s,n)&&(t[n]=s[n])}return t}function Tt(s,a){if(s==null)return{};var t={};for(var n in s)if(Object.prototype.hasOwnProperty.call(s,n)){if(a.indexOf(n)>=0)continue;t[n]=s[n]}return t}function Ce(){return Ce=Object.assign?Object.assign.bind():function(s){for(var a=1;a<arguments.length;a++){var t=arguments[a];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(s[n]=t[n])}return s},Ce.apply(this,arguments)}function xs(s,a){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(s);a&&(n=n.filter(function(l){return Object.getOwnPropertyDescriptor(s,l).enumerable})),t.push.apply(t,n)}return t}function _(s){for(var a=1;a<arguments.length;a++){var t=arguments[a]!=null?arguments[a]:{};a%2?xs(Object(t),!0).forEach(function(n){q(s,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):xs(Object(t)).forEach(function(n){Object.defineProperty(s,n,Object.getOwnPropertyDescriptor(t,n))})}return s}function le(s){return Lt(s)||Pt(s)||Bt(s)||Et()}function Et(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
37
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Bt(s,a){if(s){if(typeof s=="string")return He(s,a);var t=Object.prototype.toString.call(s).slice(8,-1);if(t==="Object"&&s.constructor&&(t=s.constructor.name),t==="Map"||t==="Set")return Array.from(s);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return He(s,a)}}function Pt(s){if(typeof Symbol<"u"&&s[Symbol.iterator]!=null||s["@@iterator"]!=null)return Array.from(s)}function Lt(s){if(Array.isArray(s))return He(s)}function He(s,a){(a==null||a>s.length)&&(a=s.length);for(var t=0,n=new Array(a);t<a;t++)n[t]=s[t];return n}function Ot(s,a){if(!(s instanceof a))throw new TypeError("Cannot call a class as a function")}function ps(s,a){for(var t=0;t<a.length;t++){var n=a[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(s,Vs(n.key),n)}}function Ft(s,a,t){return a&&ps(s.prototype,a),t&&ps(s,t),Object.defineProperty(s,"prototype",{writable:!1}),s}function Vt(s,a,t){return a=Ee(a),_t(s,Fs()?Reflect.construct(a,t||[],Ee(s).constructor):a.apply(s,t))}function _t(s,a){if(a&&(de(a)==="object"||typeof a=="function"))return a;if(a!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Rt(s)}function Rt(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function Fs(){try{var s=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Fs=function(){return!!s})()}function Ee(s){return Ee=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Ee(s)}function Mt(s,a){if(typeof a!="function"&&a!==null)throw new TypeError("Super expression must either be null or a function");s.prototype=Object.create(a&&a.prototype,{constructor:{value:s,writable:!0,configurable:!0}}),Object.defineProperty(s,"prototype",{writable:!1}),a&&Ye(s,a)}function Ye(s,a){return Ye=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,l){return n.__proto__=l,n},Ye(s,a)}function q(s,a,t){return a=Vs(a),a in s?Object.defineProperty(s,a,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[a]=t,s}function Vs(s){var a=$t(s,"string");return de(a)=="symbol"?a:a+""}function $t(s,a){if(de(s)!="object"||!s)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var n=t.call(s,a);if(de(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(s)}var me=(function(s){function a(){var t;Ot(this,a);for(var n=arguments.length,l=new Array(n),o=0;o<n;o++)l[o]=arguments[o];return t=Vt(this,a,[].concat(l)),q(t,"state",{isAnimationFinished:!0,totalLength:0}),q(t,"generateSimpleStrokeDasharray",function(r,i){return"".concat(i,"px ").concat(r-i,"px")}),q(t,"getStrokeDasharray",function(r,i,c){var d=c.reduce(function(O,m){return O+m});if(!d)return t.generateSimpleStrokeDasharray(i,r);for(var h=Math.floor(r/d),u=r%d,p=i-r,g=[],A=0,E=0;A<c.length;E+=c[A],++A)if(E+c[A]>u){g=[].concat(le(c.slice(0,A)),[u-E]);break}var B=g.length%2===0?[0,p]:[p];return[].concat(le(a.repeat(c,h)),le(g),B).map(function(O){return"".concat(O,"px")}).join(", ")}),q(t,"id",Ha("recharts-line-")),q(t,"pathRef",function(r){t.mainCurve=r}),q(t,"handleAnimationEnd",function(){t.setState({isAnimationFinished:!0}),t.props.onAnimationEnd&&t.props.onAnimationEnd()}),q(t,"handleAnimationStart",function(){t.setState({isAnimationFinished:!1}),t.props.onAnimationStart&&t.props.onAnimationStart()}),t}return Mt(a,s),Ft(a,[{key:"componentDidMount",value:function(){if(this.props.isAnimationActive){var n=this.getTotalLength();this.setState({totalLength:n})}}},{key:"componentDidUpdate",value:function(){if(this.props.isAnimationActive){var n=this.getTotalLength();n!==this.state.totalLength&&this.setState({totalLength:n})}}},{key:"getTotalLength",value:function(){var n=this.mainCurve;try{return n&&n.getTotalLength&&n.getTotalLength()||0}catch{return 0}}},{key:"renderErrorBar",value:function(n,l){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var o=this.props,r=o.points,i=o.xAxis,c=o.yAxis,d=o.layout,h=o.children,u=$a(h,za);if(!u)return null;var p=function(E,B){return{x:E.x,y:E.y,value:E.value,errorVal:Es(E.payload,B)}},g={clipPath:n?"url(#clipPath-".concat(l,")"):null};return V.createElement(Ve,g,u.map(function(A){return V.cloneElement(A,{key:"bar-".concat(A.props.dataKey),data:r,xAxis:i,yAxis:c,layout:d,dataPointFormatter:p})}))}},{key:"renderDots",value:function(n,l,o){var r=this.props.isAnimationActive;if(r&&!this.state.isAnimationFinished)return null;var i=this.props,c=i.dot,d=i.points,h=i.dataKey,u=De(this.props,!1),p=De(c,!0),g=d.map(function(E,B){var O=_(_(_({key:"dot-".concat(B),r:3},u),p),{},{index:B,cx:E.x,cy:E.y,value:E.value,dataKey:h,payload:E.payload,points:d});return a.renderDotItem(c,O)}),A={clipPath:n?"url(#clipPath-".concat(l?"":"dots-").concat(o,")"):null};return V.createElement(Ve,Ce({className:"recharts-line-dots",key:"dots"},A),g)}},{key:"renderCurveStatically",value:function(n,l,o,r){var i=this.props,c=i.type,d=i.layout,h=i.connectNulls;i.ref;var u=hs(i,Dt),p=_(_(_({},De(u,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:l?"url(#clipPath-".concat(o,")"):null,points:n},r),{},{type:c,layout:d,connectNulls:h});return V.createElement(Ua,Ce({},p,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(n,l){var o=this,r=this.props,i=r.points,c=r.strokeDasharray,d=r.isAnimationActive,h=r.animationBegin,u=r.animationDuration,p=r.animationEasing,g=r.animationId,A=r.animateNewValues,E=r.width,B=r.height,O=this.state,m=O.prevPoints,f=O.totalLength;return V.createElement(qa,{begin:h,duration:u,isActive:d,easing:p,from:{t:0},to:{t:1},key:"line-".concat(g),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(L){var F=L.t;if(m){var X=m.length/i.length,z=i.map(function(P,Fe){var ue=Math.floor(Fe*X);if(m[ue]){var he=m[ue],re=pe(he.x,P.x),Rs=pe(he.y,P.y);return _(_({},P),{},{x:re(F),y:Rs(F)})}if(A){var Ms=pe(E*2,P.x),$s=pe(B/2,P.y);return _(_({},P),{},{x:Ms(F),y:$s(F)})}return _(_({},P),{},{x:P.x,y:P.y})});return o.renderCurveStatically(z,n,l)}var Z=pe(0,f),v=Z(F),x;if(c){var j="".concat(c).split(/[,\s]+/gim).map(function(P){return parseFloat(P)});x=o.getStrokeDasharray(v,f,j)}else x=o.generateSimpleStrokeDasharray(f,v);return o.renderCurveStatically(i,n,l,{strokeDasharray:x})})}},{key:"renderCurve",value:function(n,l){var o=this.props,r=o.points,i=o.isAnimationActive,c=this.state,d=c.prevPoints,h=c.totalLength;return i&&r&&r.length&&(!d&&h>0||!Ga(d,r))?this.renderCurveWithAnimation(n,l):this.renderCurveStatically(r,n,l)}},{key:"render",value:function(){var n,l=this.props,o=l.hide,r=l.dot,i=l.points,c=l.className,d=l.xAxis,h=l.yAxis,u=l.top,p=l.left,g=l.width,A=l.height,E=l.isAnimationActive,B=l.id;if(o||!i||!i.length)return null;var O=this.state.isAnimationFinished,m=i.length===1,f=ls("recharts-line",c),L=d&&d.allowDataOverflow,F=h&&h.allowDataOverflow,X=L||F,z=Ke(B)?this.id:B,Z=(n=De(r,!1))!==null&&n!==void 0?n:{r:3,strokeWidth:2},v=Z.r,x=v===void 0?3:v,j=Z.strokeWidth,P=j===void 0?2:j,Fe=Wa(r)?r:{},ue=Fe.clipDot,he=ue===void 0?!0:ue,re=x*2+P;return V.createElement(Ve,{className:f},L||F?V.createElement("defs",null,V.createElement("clipPath",{id:"clipPath-".concat(z)},V.createElement("rect",{x:L?p:p-g/2,y:F?u:u-A/2,width:L?g:g*2,height:F?A:A*2})),!he&&V.createElement("clipPath",{id:"clipPath-dots-".concat(z)},V.createElement("rect",{x:p-re/2,y:u-re/2,width:g+re,height:A+re}))):null,!m&&this.renderCurve(X,z),this.renderErrorBar(X,z),(m||r)&&this.renderDots(X,he,z),(!E||O)&&Ka.renderCallByParent(this.props,i))}}],[{key:"getDerivedStateFromProps",value:function(n,l){return n.animationId!==l.prevAnimationId?{prevAnimationId:n.animationId,curPoints:n.points,prevPoints:l.curPoints}:n.points!==l.curPoints?{curPoints:n.points}:null}},{key:"repeat",value:function(n,l){for(var o=n.length%2!==0?[].concat(le(n),[0]):n,r=[],i=0;i<l;++i)r=[].concat(le(r),le(o));return r}},{key:"renderDotItem",value:function(n,l){var o;if(V.isValidElement(n))o=V.cloneElement(n,l);else if(Ra(n))o=n(l);else{var r=l.key,i=hs(l,kt),c=ls("recharts-line-dot",typeof n!="boolean"?n.className:"");o=V.createElement(Ma,Ce({key:r},i,{className:c}))}return o}}])})(C.PureComponent);q(me,"displayName","Line");q(me,"defaultProps",{xAxisId:0,yAxisId:0,connectNulls:!1,activeDot:!0,dot:!0,legendType:"line",stroke:"#3182bd",strokeWidth:1,fill:"#fff",points:[],isAnimationActive:!Ya.isSsr,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",hide:!1,label:!1});q(me,"getComposedData",function(s){var a=s.props,t=s.xAxis,n=s.yAxis,l=s.xAxisTicks,o=s.yAxisTicks,r=s.dataKey,i=s.bandSize,c=s.displayedData,d=s.offset,h=a.layout,u=c.map(function(p,g){var A=Es(p,r);return h==="horizontal"?{x:os({axis:t,ticks:l,bandSize:i,entry:p,index:g}),y:Ke(A)?null:n.scale(A),value:A,payload:p}:{x:Ke(A)?null:t.scale(A),y:os({axis:n,ticks:o,bandSize:i,entry:p,index:g}),value:A,payload:p}});return _({points:u,layout:h},d)});var zt=Xa({chartName:"LineChart",GraphicalChild:me,axisComponents:[{axisType:"xAxis",AxisComp:Bs},{axisType:"yAxis",AxisComp:Ps}],formatAxisMap:Ja});const je=[{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 Ut(){const s=je.reduce((t,n)=>t+n.revenue,0),a=s/je.length;return e.jsxs(G,{children:[e.jsxs(W,{children:[e.jsx(K,{children:"Revenue Analytics"}),e.jsx(H,{children:"Revenue and expenses over time"})]}),e.jsxs(Y,{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:["$",a.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:["$",je[je.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(Qa,{config:{revenue:{label:"Revenue",color:"hsl(var(--chart-1))"},expenses:{label:"Expenses",color:"hsl(var(--chart-2))"}},className:"h-[400px]",children:e.jsx(Za,{width:"100%",height:"100%",children:e.jsxs(zt,{data:je,margin:{top:5,right:10,left:10,bottom:5},children:[e.jsx(et,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(Bs,{dataKey:"month",className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Ps,{className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(st,{content:e.jsx(at,{})}),e.jsx(me,{type:"monotone",dataKey:"revenue",stroke:"var(--color-revenue)",strokeWidth:2,dot:{fill:"var(--color-revenue)",r:4}}),e.jsx(me,{type:"monotone",dataKey:"expenses",stroke:"var(--color-expenses)",strokeWidth:2,dot:{fill:"var(--color-expenses)",r:4}})]})})})]})]})}const qt="updateBusiness",_s=()=>{const[{fetching:s},a]=Be(Hs),t=C.useCallback(async n=>{const l=`Error updating business ID [${n.businessId}]`,o=`${qt}-${n.businessId}`;$.loading("Updating business",{id:o});try{const r=await a(n),i=Pe(r,l,o,"updateBusiness");if(i)return $.success("Success",{id:o,description:"Business updated"}),i.updateBusiness}catch(r){console.error(`${l}: ${r}`),$.error("Error",{id:o,description:l,duration:1e5,closeButton:!0})}},[a]);return{fetching:s,updateBusiness:t}},Gt=Object.values(ta);function js(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(a=>a.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 Wt(s){const t=s.internalLinks||s.useMessageBody||s.attachmentTypes?{internalEmailLinks:s.internalLinks,emailBody:s.useMessageBody,attachments:s.attachmentTypes}:void 0,l=s.description||s.tags||s.phrases||s.emails||t?{description:s.description,tags:s.tags?.map(o=>({id:o})),phrases:s.phrases,emails:s.emails,emailListener:t}: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:l}}function Kt({data:s,refetchBusiness:a}){const t=Ie(Xs,s),[n,l]=C.useState(js(t)),{userContext:o}=C.useContext(as),{updateBusiness:r,fetching:i}=_s(),[c,d]=C.useState(!1),[h,u]=C.useState(void 0),p=Le({defaultValues:n}),g=async E=>{if(!t||!o?.context.adminBusinessId)return;const B=es(E,p.formState.dirtyFields);if(!B)return;const O=Wt(B);await r({businessId:t.id,ownerId:o.context.adminBusinessId,fields:O}),B.tags?.length||B.description?(u({tagIds:B.tags?.map(m=>({id:m})),description:B.description}),d(!0)):a?.()};if(C.useEffect(()=>{if(t){const E=js(t);l(E),p.reset(E)}},[t,p]),!t)return e.jsx("div",{});const A=p.watch("isClient");return e.jsxs(G,{children:[e.jsx(W,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(K,{children:"Configurations"}),e.jsx(H,{children:"Business status, tax settings, automation rules, and integration preferences"})]}),!A&&e.jsx(Ys,{businessId:t.id,onDone:a})]})}),e.jsx(Oe,{...p,children:e.jsxs("form",{onSubmit:p.handleSubmit(g),children:[e.jsxs(Y,{className:"space-y-6",children:[e.jsx(Ht,{form:p}),e.jsx(oe,{}),e.jsx(Yt,{form:p}),e.jsx(oe,{}),e.jsx(Xt,{form:p}),e.jsx(oe,{}),e.jsx(Jt,{form:p})]}),e.jsx(Ze,{className:"flex justify-end border-t pt-6",children:e.jsxs(D,{type:"submit",disabled:i||Object.keys(p.formState.dirtyFields).length===0,children:[e.jsx(rs,{className:"h-4 w-4 mr-2"}),"Save Changes"]})})]})}),e.jsx(yt,{businessId:t.id,tagIds:h?.tagIds,description:h?.description,open:c,onOpenChange:d,onClose:a})]})}function Ht({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(y,{control:s.control,name:"isClient",render:({field:a,fieldState:t})=>e.jsxs(N,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"Is Client"}),e.jsx(ae,{children:"Mark this business as a client"})]}),e.jsx(w,{children:e.jsx(ee,{disabled:!0,checked:a.value,onCheckedChange:a.onChange,className:T(t)})})]})}),e.jsx(y,{control:s.control,name:"isActive",render:({field:a,fieldState:t})=>e.jsxs(N,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"Is Active"}),e.jsx(ae,{children:"Business is currently active"})]}),e.jsx(w,{children:e.jsx(ee,{checked:a.value,onCheckedChange:a.onChange,className:T(t)})})]})}),e.jsx(y,{control:s.control,name:"isReceiptEnough",render:({field:a,fieldState:t})=>e.jsxs(N,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"Is Receipt Enough"}),e.jsx(ae,{children:"Generate ledger for receipt documents if no invoice available"})]}),e.jsx(w,{children:e.jsx(ee,{checked:a.value,onCheckedChange:a.onChange,className:T(t)})})]})}),e.jsx(y,{control:s.control,name:"isDocumentsOptional",render:({field:a,fieldState:t})=>e.jsxs(N,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"No Docs Required"}),e.jsx(ae,{children:"Skip document validation for common charges"})]}),e.jsx(w,{children:e.jsx(ee,{checked:a.value,onCheckedChange:a.onChange,className:T(t)})})]})}),e.jsx(y,{control:s.control,name:"isVatOptional",render:({field:a,fieldState:t})=>e.jsxs(N,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"Is VAT Optional"}),e.jsx(ae,{children:"Mute missing VAT indicator"})]}),e.jsx(w,{children:e.jsx(ee,{checked:a.value,onCheckedChange:a.onChange,className:T(t)})})]})}),e.jsx(y,{control:s.control,name:"isExemptDealer",render:({field:a,fieldState:t})=>e.jsxs(N,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"Is Exempt Dealer"}),e.jsx(ae,{children:"Business is exempt from VAT requirements"})]}),e.jsx(w,{children:e.jsx(ee,{checked:a.value,onCheckedChange:a.onChange,className:T(t)})})]})})]})]})}function Yt({form:s}){const{selectableTaxCategories:a,fetching:t}=Js(),{selectableSortCodes:n,fetching:l,sortCodes:o}=Qs(),{selectableTags:r,fetching:i}=Zs(),c=C.useCallback(d=>{if(d){const h=o.find(u=>Number(u.key)===Number(d));h&&(h.defaultIrsCode?s.setValue("irsCode",h.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(y,{control:s.control,name:"sortCode",render:({field:d,fieldState:h})=>e.jsxs(N,{children:[e.jsx(b,{children:"Sort Code"}),e.jsx(w,{children:e.jsx(Ue,{onChange:u=>{c(u),d.onChange(u)},data:n,value:d.value,disabled:l,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:T(h)}})}),e.jsx(I,{})]})}),e.jsx(y,{control:s.control,name:"taxCategory",render:({field:d,fieldState:h})=>e.jsxs(N,{children:[e.jsx(b,{children:"Tax Category"}),e.jsx(w,{children:e.jsx(Ue,{data:a,disabled:t,value:d.value,onChange:d.onChange,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:T(h)}})}),e.jsx(I,{})]})}),e.jsx(y,{control:s.control,name:"pcn874RecordType",render:({field:d,fieldState:h})=>e.jsxs(N,{children:[e.jsx(b,{children:"PCN874 Record Type"}),e.jsxs(fe,{onValueChange:d.onChange,value:d.value,children:[e.jsx(w,{children:e.jsx(ve,{className:T(h),children:e.jsx(ye,{})})}),e.jsx(Ne,{children:Object.entries(ea).map(([u,p])=>e.jsx(be,{value:u,children:`${p} (${u})`},u))})]}),e.jsx(I,{})]})}),e.jsx(y,{control:s.control,name:"irsCode",render:({field:d,fieldState:h})=>e.jsxs(N,{children:[e.jsx(b,{children:"IRS Code"}),e.jsx(w,{children:e.jsx(sa,{value:d.value??void 0,onValueChange:u=>d.onChange(u??null),hideControls:!0,decimalScale:0,className:T(h)})}),e.jsx(I,{})]})}),e.jsx(y,{control:s.control,name:"description",render:({field:d,fieldState:h})=>e.jsxs(N,{children:[e.jsx(b,{children:"Charge Description"}),e.jsx(w,{children:e.jsx(k,{placeholder:"Enter default charge description",...d,className:T(h)})}),e.jsx(I,{})]})}),e.jsx(y,{control:s.control,name:"tags",render:({field:d,fieldState:h})=>e.jsxs(N,{children:[e.jsx(b,{children:"Tags"}),e.jsx(w,{children:e.jsx(aa,{options:Object.values(r).map(({value:u,label:p})=>({label:p,value:u})),onValueChange:d.onChange,defaultValue:d.value,value:d.value,placeholder:"Select Default Tags",variant:"default",disabled:i,className:T(h)})}),e.jsx(I,{})]})})]})]})}function Xt({form:s}){const[a,t]=C.useState(""),[n,l]=C.useState(""),o=()=>{if(a.trim()){const d=s.getValues("phrases");s.setValue("phrases",[...d,a.trim()],{shouldDirty:!0}),t("")}},r=()=>{if(n.trim()){const d=s.getValues("emails");s.setValue("emails",[...d,n.trim()],{shouldDirty:!0}),l("")}},i=d=>{const h=s.getValues("phrases");s.setValue("phrases",h.filter((u,p)=>p!==d),{shouldDirty:!0})},c=d=>{const h=s.getValues("emails");s.setValue("emails",h.filter((u,p)=>p!==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(y,{control:s.control,name:"phrases",render:({field:d,fieldState:h})=>e.jsxs(N,{children:[e.jsx(b,{children:"Phrases"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k,{placeholder:"Add phrase...",value:a,onChange:u=>t(u.target.value),onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),o())},className:T(h)}),e.jsx(D,{type:"button",size:"sm",onClick:o,children:e.jsx(M,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:d.value?.map((u,p)=>e.jsxs(se,{variant:"secondary",className:"gap-1",children:[u,e.jsx(D,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>i(p),children:e.jsx(Q,{className:"size-3 cursor-pointer",onClick:()=>i(p)})})]},p))}),e.jsx(I,{})]})}),e.jsx(y,{control:s.control,name:"emails",render:({field:d,fieldState:h})=>e.jsxs(N,{children:[e.jsx(b,{children:"Email Addresses"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k,{type:"email",placeholder:"Add email...",value:n,onChange:u=>l(u.target.value),onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),r())},className:T(h)}),e.jsx(D,{type:"button",size:"sm",onClick:r,children:e.jsx(M,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:d.value?.map((u,p)=>e.jsxs(se,{variant:"secondary",className:"gap-1",children:[u,e.jsx(D,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>c(p),children:e.jsx(Q,{className:"size-3 cursor-pointer"})})]},p))}),e.jsx(I,{})]})})]})}function Jt({form:s}){const[a,t]=C.useState(""),n=()=>{if(a.trim()){const r=s.getValues("internalLinks");s.setValue("internalLinks",[...r,a.trim()],{shouldDirty:!0}),t("")}},l=r=>{const i=s.getValues("attachmentTypes");s.setValue("attachmentTypes",i?.includes(r)?i.filter(c=>c!==r):[...i,r],{shouldDirty:!0})},o=r=>{const i=s.getValues("internalLinks");s.setValue("internalLinks",i.filter((c,d)=>d!==r),{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(y,{control:s.control,name:"attachmentTypes",render:({field:r,fieldState:i})=>e.jsxs(N,{children:[e.jsx(b,{children:"Attachment Types"}),e.jsx("div",{className:T(i)+" rounded-md flex flex-wrap gap-2",children:Gt.map(c=>e.jsx(se,{variant:r.value?.includes(c)?"default":"outline",className:"cursor-pointer",onClick:()=>l(c),children:c},c))}),e.jsx(I,{})]})}),e.jsx(y,{control:s.control,name:"internalLinks",render:({field:r,fieldState:i})=>e.jsxs(N,{children:[e.jsx(b,{children:"Internal Links"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k,{type:"url",placeholder:"Add internal link...",value:a,onChange:c=>t(c.target.value),onKeyDown:c=>{c.key==="Enter"&&(c.preventDefault(),n())}}),e.jsx(D,{type:"button",size:"sm",onClick:n,children:e.jsx(M,{className:"h-4 w-4"})})]}),e.jsx("div",{className:T(i)+" flex flex-wrap gap-2 rounded-md",children:r.value?.map((c,d)=>e.jsxs(se,{variant:"secondary",className:"gap-1 max-w-xs truncate",children:[c,e.jsx(D,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>o(d),children:e.jsx(Q,{className:"size-3 cursor-pointer flex-shrink-0"})})]},d))}),e.jsx(I,{})]})}),e.jsx(y,{control:s.control,name:"useMessageBody",render:({field:r,fieldState:i})=>e.jsxs(N,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"Should Use Message Body"}),e.jsx(ae,{children:"Extract information from email message body"})]}),e.jsx(w,{children:e.jsx(ee,{checked:r.value,onCheckedChange:r.onChange,className:T(i)})})]})})]})}const Qt=Ae({businessName:R().min(1,"Business name is required"),locality:R().min(1,"Locality is required"),localName:R().optional(),govId:R().optional(),address:R().optional(),localAddress:R().optional(),phone:R().optional(),website:bs("Invalid URL").optional().or(Cs("")),generalContacts:te(cs()).optional(),billingEmails:te(cs()).optional()});function gs(s){return!s||s.__typename!=="LtdFinancialEntity"?{}:{businessName:s.name,locality:s.country,localName:s.hebrewName??void 0,govId:s.governmentId??void 0,address:s.address??void 0,phone:s.phoneNumber??void 0,website:s.website??void 0,generalContacts:s.email?.split(",").map(a=>a.trim()),billingEmails:s.clientInfo?.emails}}function Zt(s){return{name:s.businessName,country:s.locality,hebrewName:s.localName,governmentId:s.govId,address:s.address,phoneNumber:s.phone,website:s.website,email:s.generalContacts?.join(", ")}}function en({data:s,refetchBusiness:a}){const t=Ie(ra,s),[n,l]=C.useState(gs(t)),{userContext:o}=C.useContext(as),{updateBusiness:r,fetching:i}=_s(),c=Le({resolver:Qe(Qt),defaultValues:n}),{countries:d,fetching:h}=na(),[u,p]=C.useState(""),[g,A]=C.useState(""),E=c.watch("locality"),B=c.watch("address"),O=c.watch("localAddress");C.useEffect(()=>{B!==n.address&&c.setValue("address",B,{shouldDirty:!0})},[B,n.address,c]),C.useEffect(()=>{O!==n.localAddress&&c.setValue("localAddress",O,{shouldDirty:!0})},[O,n.localAddress,c]);const m=t&&"clientInfo"in t&&!!t.clientInfo,f=E===o?.context.locality,L=v=>{u.trim()&&(c.setValue("generalContacts",[...v,u.trim()],{shouldDirty:!0}),p(""))},F=(v,x)=>{c.setValue("generalContacts",v.filter((j,P)=>P!==x),{shouldDirty:!0})},X=v=>{g.trim()&&(c.setValue("billingEmails",[...v,g.trim()],{shouldDirty:!0}),A(""))},z=(v,x)=>{c.setValue("billingEmails",v.filter((j,P)=>P!==x),{shouldDirty:!0})},Z=async v=>{if(!t||!o?.context.adminBusinessId)return;const x=es(v,c.formState.dirtyFields);if(!x)return;const j=Zt(x);await r({businessId:t.id,ownerId:o.context.adminBusinessId,fields:j}),a?.()};return C.useEffect(()=>{if(t){const v=gs(t);l(v),c.reset(v)}},[t,c]),e.jsxs(G,{children:[e.jsxs(W,{children:[e.jsx(K,{children:"Contact Information"}),e.jsx(H,{children:"Business contact details and address information"})]}),e.jsx(Oe,{...c,children:e.jsxs("form",{onSubmit:c.handleSubmit(Z),children:[e.jsx(Y,{children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx(y,{control:c.control,name:"businessName",render:({field:v,fieldState:x})=>e.jsxs(N,{children:[e.jsx(b,{children:"Business Name"}),e.jsx(w,{children:e.jsx(k,{...v,className:T(x)})}),e.jsx(I,{})]})}),e.jsx(y,{control:c.control,name:"locality",render:({field:v,fieldState:x})=>e.jsxs(N,{children:[e.jsx(b,{children:"Locality / Country"}),e.jsx(Ue,{onChange:v.onChange,data:d.map(j=>({value:j.code,label:j.name})),value:v.value,disabled:h,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:T(x)}}),e.jsx(I,{})]})}),f&&e.jsx(y,{control:c.control,name:"localName",render:({field:v,fieldState:x})=>e.jsxs(N,{children:[e.jsx(b,{children:"Local Name"}),e.jsx(w,{children:e.jsx(k,{...v,placeholder:"Business name in local language",className:T(x)})}),e.jsx(I,{})]})}),f&&e.jsx(y,{control:c.control,name:"govId",render:({field:v,fieldState:x})=>e.jsxs(N,{children:[e.jsx(b,{children:"Government ID"}),e.jsx(w,{children:e.jsx(k,{...v,placeholder:"Enter Government ID",className:T(x)})}),e.jsx(I,{})]})}),e.jsx(y,{control:c.control,name:"address",render:({field:v,fieldState:x})=>e.jsxs(N,{className:"md:col-span-2",children:[e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(qe,{className:"h-4 w-4"}),"Address"]}),e.jsx(w,{children:e.jsx(Ge,{...v,rows:3,placeholder:"Enter business address",className:T(x)})}),e.jsx(I,{})]})}),f&&e.jsx(y,{control:c.control,name:"localAddress",render:({field:v,fieldState:x})=>e.jsxs(N,{className:"md:col-span-2",children:[e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(qe,{className:"h-4 w-4"}),"Local Address"]}),e.jsx(w,{children:e.jsx(Ge,{...v,rows:3,placeholder:"Enter address in local language",className:T(x)})}),e.jsx(I,{})]})}),e.jsx(y,{control:c.control,name:"phone",render:({field:v,fieldState:x})=>e.jsxs(N,{children:[e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(Ns,{className:"h-4 w-4"}),"Phone"]}),e.jsx(w,{children:e.jsx(k,{...v,type:"tel",placeholder:"+1 (555) 123-4567",className:T(x)})}),e.jsx(I,{})]})}),e.jsx(y,{control:c.control,name:"website",render:({field:v,fieldState:x})=>e.jsxs(N,{children:[e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(ia,{className:"h-4 w-4"}),"Website"]}),e.jsx(w,{children:e.jsx(k,{...v,type:"url",placeholder:"https://example.com",className:T(x)})}),e.jsx(I,{})]})}),e.jsx(y,{control:c.control,name:"generalContacts",render:({field:v,fieldState:x})=>e.jsxs(N,{className:"md:col-span-2",children:[e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(We,{className:"h-4 w-4"}),"General Contacts"]}),e.jsx(w,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:T(x)+" flex flex-wrap gap-2 mb-2 rounded-md",children:v.value?.map((j,P)=>e.jsxs(se,{variant:"secondary",className:"gap-1 pr-1",children:[j,e.jsx("button",{type:"button",onClick:()=>F(v.value??[],P),className:"ml-1 hover:bg-muted rounded-sm p-0.5",children:e.jsx(Q,{className:"h-3 w-3"})})]},P))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k,{value:u,onChange:j=>p(j.target.value),onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),L(v.value??[]))},placeholder:"Add contact email",type:"email"}),e.jsx(D,{type:"button",variant:"outline",size:"icon",disabled:!u.trim(),onClick:()=>L(v.value??[]),children:e.jsx(M,{className:"h-4 w-4"})})]})]})}),e.jsx(I,{})]})}),m&&e.jsx(y,{control:c.control,name:"billingEmails",render:({field:v,fieldState:x})=>e.jsxs(N,{className:"md:col-span-2",children:[e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(We,{className:"h-4 w-4"}),"Billing Emails"]}),e.jsx(w,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:T(x)+" flex flex-wrap gap-2 mb-2 rounded-md",children:v.value?.map((j,P)=>e.jsxs(se,{variant:"secondary",className:"gap-1 pr-1",children:[j,e.jsx("button",{type:"button",onClick:()=>z(v.value??[],P),className:"ml-1 hover:bg-muted rounded-sm p-0.5",children:e.jsx(Q,{className:"h-3 w-3"})})]},P))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k,{value:g,onChange:j=>A(j.target.value),onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),X(v.value??[]))},placeholder:"Add billing email",type:"email"}),e.jsx(D,{type:"button",variant:"outline",size:"icon",disabled:!g.trim(),onClick:()=>X(v.value??[]),children:e.jsx(M,{className:"h-4 w-4"})})]})]})}),e.jsx(I,{})]})})]})}),e.jsx(Ze,{className:"flex justify-end border-t mt-4 pt-6",children:e.jsxs(D,{type:"submit",disabled:i||Object.keys(c.formState.dirtyFields).length===0,children:[e.jsx(rs,{className:"h-4 w-4 mr-2"}),"Save Changes"]})})]})})]})}const sn="createContract",an=()=>{const[{fetching:s},a]=Be(la),t=C.useCallback(async n=>{const l=`Error creating new contract for client[${n.input.clientId}]`,o=`${sn}-${n.input.clientId}`;$.loading("Creating contract",{id:o});try{const r=await a(n);Pe(r,l,o)&&$.success("Success",{id:o,description:`Contract for client ${n.input.clientId} was successfully created`})}catch(r){console.error(`${l}: ${r}`),$.error("Error",{id:o,description:l,duration:1e5,closeButton:!0})}},[a]);return{creating:s,createContract:t}},tn="updateContract",nn=()=>{const[{fetching:s},a]=Be(ca),t=C.useCallback(async n=>{const l=`Error updating contract ID [${n.contractId}]`,o=`${tn}-${n.contractId}`;$.loading("Updating contract",{id:o});try{const r=await a(n),i=Pe(r,l,o,"updateContract");if(i)return $.success("Success",{id:o,description:"Contract updated"}),i.updateContract}catch(r){console.error(`${l}: ${r}`),$.error("Error",{id:o,description:l,duration:1e5,closeButton:!0})}},[a]);return{updating:s,updateContract:t}},rn=Ae({id:ma().optional(),startDate:ze("Start date is required"),endDate:ze("End date is required"),pos:te(R()),paymentAmount:ss().min(0,"Payment amount must be non-negative"),paymentCurrency:xe(Object.values(ns),"Currency is required"),productType:xe(Object.values(ws)).optional(),msCloudLink:bs().optional().or(Cs("")),billingCycle:xe(Object.values(we)).optional(),subscriptionPlan:xe(Object.values(Te)).optional(),isActive:da(),defaultRemark:R().optional(),defaultDocumentType:xe(Object.values(ts)),operationsLimit:oa().min(0,"Operations limit must be non-negative")}),fs={startDate:"",endDate:"",pos:[],paymentAmount:0,paymentCurrency:ns.Usd,productType:ws.Hive,msCloudLink:void 0,billingCycle:we.Monthly,subscriptionPlan:void 0,isActive:!0,defaultRemark:void 0,defaultDocumentType:ts.Proforma,operationsLimit:0};function ln({clientId:s,contract:a,onDone:t}){const[n,l]=C.useState(!1),[o,r]=C.useState(null),[i,c]=C.useState(""),{updateContract:d,updating:h}=nn(),{createContract:u,creating:p}=an(),g=Le({resolver:Qe(rn),defaultValues:a||fs}),A=()=>{const m=i.trim();if(m){const f=g.getValues("pos");f.includes(m)||g.setValue("pos",[...f,m],{shouldDirty:!0}),c("")}},E=m=>{const f=g.getValues("pos");g.setValue("pos",f.filter((L,F)=>F!==m),{shouldDirty:!0})};C.useEffect(()=>{a&&(r(a),g.reset({startDate:a.startDate,endDate:a.endDate,pos:a.pos,paymentAmount:a.paymentAmount,paymentCurrency:a.paymentCurrency,productType:a.productType,msCloudLink:a.msCloudLink,billingCycle:a.billingCycle,subscriptionPlan:a.subscriptionPlan,isActive:a.isActive,defaultRemark:a.defaultRemark,defaultDocumentType:a.defaultDocumentType,operationsLimit:a.operationsLimit}),l(!0))},[a,g]);const B=()=>{r(null),g.reset(fs),l(!0)},O=C.useCallback(async m=>{if(o)await d({contractId:o.id,input:{amount:{raw:m.paymentAmount,currency:m.paymentCurrency},billingCycle:m.billingCycle,documentType:m.defaultDocumentType,endDate:ce(new Date(m.endDate),"yyyy-MM-dd"),isActive:m.isActive,msCloud:m.msCloudLink,plan:m.subscriptionPlan,product:m.productType,purchaseOrders:m.pos,remarks:m.defaultRemark,startDate:ce(new Date(m.startDate),"yyyy-MM-dd"),operationsLimit:m.operationsLimit}});else{if(!m.billingCycle){g.setError("billingCycle",{message:"Billing cycle is required"});return}await u({input:{clientId:s,amount:{raw:m.paymentAmount,currency:m.paymentCurrency},billingCycle:m.billingCycle,documentType:m.defaultDocumentType,endDate:ce(new Date(m.endDate),"yyyy-MM-dd"),isActive:m.isActive,msCloud:m.msCloudLink,plan:m.subscriptionPlan,product:m.productType,purchaseOrders:m.pos,remarks:m.defaultRemark,startDate:ce(new Date(m.startDate),"yyyy-MM-dd"),operationsLimit:m.operationsLimit}})}l(!1),r(null),t?.()},[o,t,u,d,s,g]);return e.jsxs(Xe,{open:n,onOpenChange:l,children:[e.jsx(As,{asChild:!0,children:e.jsxs(D,{size:"sm",onClick:B,children:[e.jsx(M,{className:"h-4 w-4 mr-2"}),"New Contract"]})}),e.jsxs(Je,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(Is,{children:[e.jsx(Ss,{children:o?"Edit Contract":"Create New Contract"}),e.jsx(Ds,{children:o?"Update contract details":"Add a new contract with all required details"})]}),e.jsx(Oe,{...g,children:e.jsxs("form",{onSubmit:g.handleSubmit(O),children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(y,{control:g.control,name:"operationsLimit",render:({field:m})=>e.jsxs(N,{children:[e.jsx(b,{children:"Operations Limit"}),e.jsx(w,{children:e.jsx(k,{type:"number",placeholder:"500",...m})}),e.jsx(I,{})]})}),e.jsx(y,{control:g.control,name:"pos",render:({field:m})=>e.jsxs(N,{children:[e.jsx(b,{children:"Purchase Orders"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k,{placeholder:"Add PO...",value:i,onChange:f=>c(f.target.value),onKeyDown:f=>{f.key==="Enter"&&(f.preventDefault(),A())}}),e.jsx(D,{type:"button",size:"sm",onClick:A,children:e.jsx(M,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:m.value?.map((f,L)=>e.jsxs(se,{variant:"secondary",className:"gap-1 max-w-xs truncate",children:[f,L===m.value.length-1&&e.jsx(D,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>E(L),children:e.jsx(Q,{className:"size-3 cursor-pointer flex-shrink-0"})})]},f))}),e.jsx(I,{})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(y,{control:g.control,name:"startDate",render:({field:{onChange:m,...f}})=>e.jsxs(N,{children:[e.jsx(b,{children:"Start Date"}),e.jsx(w,{children:e.jsx(k,{type:"date",...f,onInput:L=>m(L)})}),e.jsx(I,{})]})}),e.jsx(y,{control:g.control,name:"endDate",render:({field:{onChange:m,...f}})=>e.jsxs(N,{children:[e.jsx(b,{children:"End Date"}),e.jsx(w,{children:e.jsx(k,{type:"date",...f,onInput:L=>m(L)})}),e.jsx(I,{})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(y,{control:g.control,name:"paymentAmount",render:({field:m})=>e.jsxs(N,{className:"md:col-span-2",children:[e.jsx(b,{children:"Payment Amount"}),e.jsx(w,{children:e.jsx(k,{type:"number",placeholder:"24000",...m,onChange:f=>{m.onChange(f?.target.value?Number(f?.target.value):void 0)}})}),e.jsx(I,{})]})}),e.jsx(y,{control:g.control,name:"paymentCurrency",render:({field:m})=>e.jsxs(N,{children:[e.jsx(b,{children:"Currency"}),e.jsxs(fe,{onValueChange:m.onChange,defaultValue:m.value,children:[e.jsx(w,{children:e.jsx(ve,{children:e.jsx(ye,{})})}),e.jsx(Ne,{children:Object.values(ns).map(f=>e.jsx(be,{value:f,children:f},f))})]}),e.jsx(I,{})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(y,{control:g.control,name:"productType",render:({field:m})=>e.jsxs(N,{children:[e.jsx(b,{children:"Product Type"}),e.jsx(w,{children:e.jsx(k,{placeholder:"Cloud Services",...m})}),e.jsx(I,{})]})}),e.jsx(y,{control:g.control,name:"billingCycle",render:({field:m})=>e.jsxs(N,{children:[e.jsx(b,{children:"Billing Cycle"}),e.jsxs(fe,{onValueChange:m.onChange,defaultValue:m.value,children:[e.jsx(w,{children:e.jsx(ve,{children:e.jsx(ye,{})})}),e.jsx(Ne,{children:Object.values(we).map(f=>e.jsx(be,{value:f,children:Ls(f)},f))})]}),e.jsx(I,{})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(y,{control:g.control,name:"subscriptionPlan",render:({field:m})=>e.jsxs(N,{children:[e.jsx(b,{children:"Subscription Plan"}),e.jsx(w,{children:e.jsxs(fe,{onValueChange:m.onChange,defaultValue:m.value,children:[e.jsx(w,{children:e.jsx(ve,{children:e.jsx(ye,{})})}),e.jsx(Ne,{children:Object.values(Te).map(f=>e.jsx(be,{value:f,children:Os(f)},f))})]})}),e.jsx(I,{})]})}),e.jsx(y,{control:g.control,name:"isActive",render:({field:m})=>e.jsxs(N,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(b,{className:"text-base",children:"Active Status"})}),e.jsx(w,{children:e.jsx(ee,{checked:m.value,onCheckedChange:m.onChange})})]})})]}),e.jsx(y,{control:g.control,name:"msCloudLink",render:({field:m})=>e.jsxs(N,{children:[e.jsx(b,{children:"MS Cloud Link"}),e.jsx(w,{children:e.jsx(k,{type:"url",placeholder:"https://portal.azure.com/contract-id",...m})}),e.jsx(I,{})]})}),e.jsx(y,{control:g.control,name:"defaultDocumentType",render:({field:m})=>e.jsxs(N,{children:[e.jsx(b,{children:"Default Document Type"}),e.jsxs(fe,{onValueChange:m.onChange,defaultValue:m.value,children:[e.jsx(w,{children:e.jsx(ve,{children:e.jsx(ye,{})})}),e.jsx(Ne,{children:Object.values(ts).map(f=>e.jsx(be,{value:f,children:ks(f)},f))})]}),e.jsx(I,{})]})}),e.jsx(y,{control:g.control,name:"defaultRemark",render:({field:m})=>e.jsxs(N,{children:[e.jsx(b,{children:"Default Remark"}),e.jsx(w,{children:e.jsx(Ge,{placeholder:"Enter default remark for this contract...",rows:3,...m})}),e.jsx(I,{})]})})]}),e.jsxs(Ts,{children:[e.jsx(D,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(D,{type:"submit",disabled:p||h,children:o?"Update Contract":"Create Contract"})]})]})})]})]})}function cn(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 on({clientId:s}){const[a,t]=C.useState(null),[{data:n,fetching:l},o]=ie({query:ua,variables:{clientId:s}}),r=n?.contractsByClient??[];return l?e.jsx("div",{children:"Loading contracts..."}):e.jsxs(G,{children:[e.jsx(W,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(K,{children:"Contracts"}),e.jsx(H,{children:"Current and past contracts sorted by start date"})]}),e.jsx(ln,{clientId:s,contract:a,onDone:o})]})}),e.jsx(Y,{className:"space-y-4",children:r.map(i=>{const c=!!i.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:i.product}),e.jsx(se,{variant:c?"default":"secondary",children:i.isActive?"Active":"Inactive"})]}),e.jsx("p",{className:"text-sm text-muted-foreground font-mono",children:i.id})]}),e.jsx(D,{variant:"ghost",size:"sm",onClick:()=>t(cn(i)),children:e.jsx(tt,{className:"h-4 w-4"})})]}),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(ha,{className:"h-3 w-3"}),"Contract Period"]}),e.jsxs("p",{className:"text-sm font-medium",children:[new Date(i.startDate).toLocaleDateString()," →"," ",new Date(i.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:i.purchaseOrders.toReversed()[0]??""}),i.purchaseOrders.length>1&&e.jsx("div",{className:"space-x-1",children:i.purchaseOrders.toReversed().slice(1).map(d=>e.jsx("span",{className:"text-xs font-thin font-mono",children:d},d))})]}),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:xa(i.amount.raw,i.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:Ls(i.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:i.plan?Os(i.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:i.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:ks(i.documentType)})]})]}),i.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:i.remarks})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:i.msCloud&&e.jsx(D,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:i.msCloud.toString(),target:"_blank",rel:"noopener noreferrer",children:[e.jsx(pa,{className:"h-4 w-4 mr-2"}),"MS Cloud",e.jsx(nt,{className:"h-3 w-3 ml-1"})]})})})]},i.id)})})]})}function dn({businessId:s}){return e.jsxs(G,{children:[e.jsx(W,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(K,{children:"Documents"}),e.jsx(H,{children:"Invoices, proformas, receipts, and other accounting documents"})]})})}),e.jsx(Y,{children:e.jsx(ja,{businessId:s,linkedDocumentIds:[],limit:1e3})})]})}const mn=[{id:"hive",name:"Hive",description:"Schema registry, analytics, metrics and gateway for GraphQL federation and other GraphQL APIs",status:"disconnected",lastSync:"Never"},{id:"slack",name:"Slack",description:"Team communication and notifications",status:"disconnected",lastSync:"Never"},{id:"retool",name:"Retool",description:"Internal tools and dashboards",status:"disconnected",lastSync:"Never"},{id:"linear",name:"Linear",description:"Issue tracking and project management",status:"disconnected",lastSync:"Never"},{id:"workflowy",name:"Workflowy",description:"Task management and note taking",status:"disconnected",lastSync:"Never"}];function un({data:s}){const a=Ie(ya,s),[{data:t,fetching:n},l]=ie({query:ga,variables:{clientId:a?.id??""},pause:!a?.clientInfo?.greenInvoiceId||!a?.id}),{updateClient:o}=fa(),r=C.useCallback((c,d)=>{if(!a?.id)return;const h={};h[d]=c,o({businessId:a?.id,fields:h})},[a?.id,o]);C.useEffect(()=>{a?.clientInfo?.greenInvoiceId&&a?.id&&l()},[a?.clientInfo?.greenInvoiceId,a?.id,l]);const i=t?.greenInvoiceClient;return e.jsxs(G,{children:[e.jsx(W,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(K,{children:"Integrations"}),e.jsx(H,{children:"Connected external services and providers"})]}),e.jsxs(D,{size:"sm",children:[e.jsx(M,{className:"h-4 w-4 mr-2"}),"Add Integration"]})]})}),e.jsx(Y,{className:"space-y-6",children:e.jsxs(rt,{type:"multiple",defaultValue:["green-invoice"],className:"space-y-4",children:[n?e.jsxs(_e,{value:"green-invoice",className:"rounded-lg border-2 border-green-600/20 bg-green-600/5",children:[e.jsx("div",{className:"px-4 py-3 bg-green-600/10 rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsx(S,{className:"h-10 w-10 rounded-lg"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{className:"h-6 w-32"}),e.jsx(S,{className:"h-5 w-5 rounded-full"})]}),e.jsx(S,{className:"h-4 w-64"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{className:"h-8 w-24"}),e.jsx(S,{className:"h-8 w-8"})]})]})}),e.jsx(Re,{children:e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(S,{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(S,{className:"h-3 w-24"}),e.jsx(S,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{className:"h-3 w-24"}),e.jsx(S,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{className:"h-3 w-24"}),e.jsx(S,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{className:"h-3 w-24"}),e.jsx(S,{className:"h-4 w-full"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(S,{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(S,{className:"h-3 w-32"}),e.jsx(S,{className:"h-6 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{className:"h-3 w-24"}),e.jsx(S,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{className:"h-3 w-24"}),e.jsx(S,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{className:"h-3 w-24"}),e.jsx(S,{className:"h-4 w-full"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(S,{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(S,{className:"h-3 w-24"}),e.jsx(S,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{className:"h-3 w-24"}),e.jsx(S,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{className:"h-3 w-24"}),e.jsx(S,{className:"h-4 w-full"})]})]})]})]})})]}):e.jsxs(_e,{value:"green-invoice",className:"rounded-lg border-2 border-green-600/20 bg-green-600/5",children:[e.jsx("div",{className:"px-4 py-3 bg-green-600/10 rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-green-600 flex items-center justify-center text-white font-bold",children:"GI"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Green Invoice"}),e.jsx(ms,{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(hn,{id:a?.clientInfo?.greenInvoiceId,provider:"Green Invoice",updateClient:async c=>r(c,"greenInvoiceId")}),e.jsx(ds,{className:"hover:no-underline p-2"})]})]})}),e.jsx(Re,{children:i&&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:a?.clientInfo?.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:i.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:i.country})]}),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:i.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(We,{className:"h-3.5 w-3.5"}),"Email Addresses"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:i.emails?.map((c,d)=>e.jsx("span",{className:"text-sm px-2 py-1 bg-muted rounded",children:c},d))})]}),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(Ns,{className:"h-3.5 w-3.5"}),"Phone"]}),e.jsx("p",{className:"text-sm font-mono",children:i.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:i.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:i.fax})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h4",{className:"font-semibold text-sm text-muted-foreground uppercase tracking-wide flex items-center gap-2",children:[e.jsx(qe,{className:"h-3.5 w-3.5"}),"Address"]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"space-y-1 md:col-span-2",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Street Address"}),e.jsx("p",{className:"text-sm",children:i.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:i.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:i.zip})]})]})]})]})})]}),mn.map(c=>e.jsxs(_e,{value:c.id,className:"rounded-lg border",children:[e.jsx("div",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center gap-3 flex-1",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:c.name}),c.status==="connected"?e.jsx(ms,{className:"h-4 w-4 text-green-600"}):e.jsx(va,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:c.description})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{variant:"ghost",size:"sm",onClick:d=>d.stopPropagation(),children:e.jsx(is,{className:"h-4 w-4"})}),e.jsx(ds,{className:"hover:no-underline p-2"})]})]})}),e.jsx(Re,{children:e.jsx("div",{className:"px-4 pb-4 pt-2 border-t",children:e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Last sync: "}),e.jsx("span",{className:"font-medium",children:c.lastSync})]})})})]},c.id))]})})]})}function hn({id:s,provider:a,updateClient:t}){const[n,l]=C.useState(!1),[o,r]=C.useState(s),i=C.useCallback(async()=>{await t(o),l(!1)},[o,t]);return e.jsxs(Xe,{open:n,onOpenChange:l,children:[e.jsx(As,{asChild:!0,children:e.jsxs(D,{variant:"outline",size:"sm",onClick:c=>c.stopPropagation(),children:[e.jsx(is,{className:"h-4 w-4 mr-2"}),"Configure"]})}),e.jsxs(Je,{onClick:c=>c.stopPropagation(),children:[e.jsxs(Is,{children:[e.jsxs(Ss,{children:["Configure ",a]}),e.jsxs(Ds,{children:["Update your ",a," integration settings"]})]}),e.jsx("div",{className:"space-y-4 py-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ge,{htmlFor:"id",children:[a," ID"]}),e.jsx(k,{id:"id",value:o,onChange:c=>r(c.target.value),placeholder:`Enter ${a} ID`})]})}),e.jsxs(Ts,{children:[e.jsx(D,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(D,{onClick:i,disabled:!o,children:"Save Changes"})]})]})]})}function xn({businessId:s}){const[{data:a,fetching:t}]=ie({query:Na,variables:{businessId:s}});return t?e.jsx("div",{children:"Loading ledger records..."}):e.jsxs(G,{children:[e.jsx(W,{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(K,{children:"Ledger Records"}),e.jsx(H,{children:"Complete ledger history for this business"})]})})}),e.jsx(Y,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Va,{ledgerRecordsData:a?.ledgerRecordsByFinancialEntity??[]})})})]})}function pn({businessId:s}){const[{data:a,fetching:t}]=ie({query:ba,variables:{businessId:s}});return t?e.jsx("div",{children:"Loading transactions..."}):e.jsxs(G,{children:[e.jsx(W,{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(K,{children:"Transactions"}),e.jsx(H,{children:"Complete transaction history for this business"})]})})}),e.jsx(Y,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(it,{transactionsProps:a?.transactionsByFinancialEntity??[]})})})]})}function jn({data:s,refetchBusiness:a}){const t=Ie(ka,s),[n,l]=Ca(),{setFiltersContext:o}=C.useContext(wa);C.useEffect(()=>{o(null)},[o]);const r=n.get("tab")||"contact",i=h=>{l({tab:h})};if(!t)return e.jsx("div",{children:"Business not found"});const c="clientInfo"in t&&!!t.clientInfo,d="adminInfo"in t&&!!t.adminInfo;return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(La,{data:t}),e.jsx("main",{className:"container mx-auto px-4 py-6 md:px-6 lg:px-8 max-w-7xl",children:e.jsxs(Aa,{value:r,onValueChange:i,className:"w-full",children:[e.jsxs(Ia,{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(J,{value:"contact",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(lt,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Contact"})]}),e.jsxs(J,{value:"config",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(is,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Config"})]}),e.jsxs(J,{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(J,{value:"transactions",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Sa,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Transactions"})]}),e.jsxs(J,{value:"documents",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Da,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Documents"})]}),e.jsxs(J,{value:"ledger",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(pt,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Ledger"})]}),e.jsxs(J,{value:"balance",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(ot,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Balance"})]}),c&&e.jsxs(e.Fragment,{children:[e.jsxs(J,{value:"contracts",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(ht,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Contracts"})]}),e.jsxs(J,{value:"integrations",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(gt,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Integrations"})]})]}),d&&e.jsxs(J,{value:"admin",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(ys,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Admin"})]})]}),e.jsx(U,{value:"contact",className:"mt-0",children:e.jsx(en,{data:t,refetchBusiness:a})}),e.jsx(U,{value:"config",className:"mt-0",children:e.jsx(Kt,{data:t,refetchBusiness:a})}),e.jsx(U,{value:"charges",className:"mt-0",children:e.jsx(St,{businessId:t.id})}),e.jsx(U,{value:"transactions",className:"mt-0",children:e.jsx(pn,{businessId:t.id})}),e.jsx(U,{value:"documents",className:"mt-0",children:e.jsx(dn,{businessId:t.id})}),e.jsx(U,{value:"ledger",className:"mt-0",children:e.jsx(xn,{businessId:t.id})}),e.jsx(U,{value:"balance",className:"mt-0",children:e.jsx(It,{businessId:t.id})}),c&&e.jsxs(e.Fragment,{children:[e.jsx(U,{value:"contracts",className:"mt-0",children:e.jsx(on,{clientId:t.id})}),e.jsx(U,{value:"integrations",className:"mt-0",children:e.jsx(un,{data:t})}),e.jsx(U,{value:"charts",className:"mt-0",children:e.jsx(Ut,{})})]}),d&&e.jsx(U,{value:"admin",className:"mt-0",children:e.jsx(At,{data:t})})]})})]})}const Rn=()=>{const{businessId:s}=Ta();let a;try{a=Ea()}catch{}const[{data:t,fetching:n},l]=ie({query:Ba,pause:!s||!!a,variables:{businessId:s??""}}),o=a||t;return!a&&n&&!o?.business?e.jsx(vs,{}):!s||!o?.business?e.jsx("div",{children:"Business not found"}):e.jsx(jn,{data:o.business,refetchBusiness:async()=>l()})};export{Rn as BusinessScreen};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as S,r as c,F as w,u as C,j as n,c as x,aQ as o,bn as y}from"./index-CuoWV8xf.js";import{u as h}from"./use-url-query-CMqziw3P.js";import{a as F}from"./accounter-table-D9Vunjfy.js";import{M as p,B as R}from"./business-extended-info-CFdeLUKP.js";import{B as v}from"./business-ledger-filters-ClJxXoLC.js";import"./Pagination-CraTfR0n.js";import"./create-event-handler-BiA-1lGu.js";import"./Table-B88LD0fO.js";import"./download-csv-button-DUWRJL2T.js";import"./modal-CguzFJgR.js";import"./funnel-DrJtNpvJ.js";import"./MultiSelect-h-orVW8D.js";const $=({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}]=C({query:y,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(x,{}):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{$ as BusinessLedgerRecordsSingle};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as p,r as n,F as u,u as m,j as s,c,bA as x}from"./index-CuoWV8xf.js";import{P as d,C as l,E as b}from"./editable-business-trip-BhXW_0XH.js";import{P as f}from"./page-layout-jOFfeRt_.js";import"./list-plus-BPyHtPSB.js";import"./summary-CBR-TMN0.js";import"./create-event-handler-BiA-1lGu.js";import"./Table-B88LD0fO.js";import"./toggle-expansion-button-BarJY9rA.js";import"./panel-top-open-BLNJL6FI.js";import"./MultiSelect-h-orVW8D.js";import"./similar-transactions-modal-BxhD4UyN.js";import"./tooltip-BFYX9MeB.js";const A=({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(f,{title:`Business Trip: ${r.businessTrip.name}`,description:"Manage business trip",children:s.jsx(l,{className:"mt-5",children:e&&s.jsx(b,{tripId:e,isExtended:!0})})})};export{A as BusinessTrip};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as I,b as x,r as a,u as D,j as e,c as f,C as j}from"./index-CuoWV8xf.js";import{C as v}from"./charges-table-eZes2r5b.js";import{E as M,I as E,M as S}from"./match-document-modal-BZOEBBCt.js";import"./toggle-expansion-button-BarJY9rA.js";import"./panel-top-open-BLNJL6FI.js";import"./index-DVm5mt8x.js";import"./similar-transactions-modal-BxhD4UyN.js";import"./addDays-CiW9nfcU.js";import"./list-plus-BPyHtPSB.js";import"./tooltip-BFYX9MeB.js";import"./Table-B88LD0fO.js";import"./summary-CBR-TMN0.js";import"./create-event-handler-BiA-1lGu.js";import"./YearPickerInput-DQjO6Nmm.js";import"./insert-business-trip-modal-CkXaCqH7.js";import"./accounter-table-D9Vunjfy.js";import"./Pagination-CraTfR0n.js";import"./modal-CguzFJgR.js";const J=({chargeId:u})=>{const{chargeId:g}=I(),r=u||g;let t;try{t=x()}catch{}const[o,i]=a.useState(void 0),[s,n]=a.useState(void 0),[c,d]=a.useState(void 0),[{data:p,fetching:l},m]=D({query:j,pause:!r||!!t,variables:{chargeId:r??""}});a.useEffect(()=>{r&&!t&&m()},[r,t,m]);const h=t||p,C=!t&&l;return r?e.jsxs(e.Fragment,{children:[C?e.jsx(f,{}):e.jsx(v,{setEditChargeId:i,setInsertDocument:n,setMatchDocuments:d,data:h?.charge?[h.charge]:[],isAllOpened:!0}),o&&e.jsx(M,{chargeId:o?.id,close:()=>i(void 0),onChange:o.onChange}),s&&e.jsx(E,{chargeId:s.id,onChange:s.onChange,close:()=>n(void 0)}),c&&e.jsx(S,{chargeId:c.id,ownerId:c.ownerId,setMatchDocuments:()=>d(void 0)})]}):e.jsx("div",{children:"Charge not found"})};export{J as Charge};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as i,bp as B,bw as W,j as e,bq as H,B as z,ae as G,G as U,x as N,ag as D,cQ as _,aq as q,W as Q,cR as J,bs as h,ec as X,bt as P,bu as O,bv as L,e3 as k,an as m,ha as Y,a2 as Z,Y as x,Z as p,_ as j,$ as g,df as $,dg as K,dh as ee}from"./index-CuoWV8xf.js";import{u as se}from"./use-url-query-CMqziw3P.js";import{P as ae}from"./modal-CguzFJgR.js";import{P as te}from"./Pagination-CraTfR0n.js";import{F as ne}from"./funnel-DrJtNpvJ.js";import{s as oe}from"./sub-CUQX8erq.js";import{M as A}from"./MultiSelect-h-orVW8D.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=U({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}=_(),{selectableTags:v,fetching:I}=q(),E=C("sortBy.field");i.useEffect(()=>{E&&!c?u(!0):!E&&c&&u(!1)},[E,c]);const V=s=>{y!=null&&s.sortBy?.field&&(s.sortBy.asc=y),w(s),d()};function R(){w({}),F(!1),d()}return e.jsxs(e.Fragment,{children:[t?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsx(Q,{...o,children:e.jsxs("form",{onSubmit:T(V),children:[e.jsxs(J,{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,M)=>M.label?.toLowerCase().includes(r.toLowerCase().trim())||M.description?.toLowerCase().includes(r.toLowerCase().trim())})}),e.jsx(h,{name:"fromAnyDate",control:l,defaultValue:a.fromAnyDate,rules:{pattern:{value:P,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:P,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(L,{...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(L,{...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(p,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(j,{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(p,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(j,{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(p,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(j,{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(p,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(j,{children:"With Open Documents"})}),e.jsx(g,{children:e.jsxs($,{children:[e.jsx(K,{children:e.jsx(m,{defaultChecked:a.withOpenDocuments??!1,onCheckedChange:s.onChange})}),e.jsx(ee,{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(p,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(j,{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(p,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(j,{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(p,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(j,{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:R,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 ge({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}=se();i.useEffect(()=>{const t=d>1?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(1))},[a,c,u,b]);const S=i.useCallback(t=>{W(t,a)||(w(t),F(!B(t)))},[a,w]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(ae,{opened:T,onClose:()=>C(!1),content:e.jsx(ie,{filter:a,setFilter:S,closeModal:()=>C(!1)}),modalSize:"xl"}),o>1&&e.jsx(te,{className:"flex-auto",value:d,onChange:b,total:o}),e.jsx(H,{inline:!0,size:16,disabled:!y,children:e.jsx(z,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>C(!0),children:e.jsx(ne,{className:"size-5"})})})]})}export{ge as C,ce as c};
|
|
@@ -1 +0,0 @@
|
|
|
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 b,e as z,f as W}from"./index-CuoWV8xf.js";import{u as O}from"./use-url-query-CMqziw3P.js";import{C as k}from"./charges-filters-Ir-7TzSP.js";import{C as B,T as R}from"./charges-table-eZes2r5b.js";import{M as V}from"./index-DCJnXE5L.js";import{E as A,I as Q,M as U}from"./match-document-modal-BZOEBBCt.js";import{P as q}from"./page-layout-jOFfeRt_.js";import{P as J}from"./Progress-DVn-HXq3.js";import{P as $,a as G}from"./panel-top-open-BLNJL6FI.js";import"./modal-CguzFJgR.js";import"./Pagination-CraTfR0n.js";import"./create-event-handler-BiA-1lGu.js";import"./funnel-DrJtNpvJ.js";import"./sub-CUQX8erq.js";import"./addDays-CiW9nfcU.js";import"./subMonths-QOcbO9QP.js";import"./MultiSelect-h-orVW8D.js";import"./toggle-expansion-button-BarJY9rA.js";import"./index-DVm5mt8x.js";import"./similar-transactions-modal-BxhD4UyN.js";import"./list-plus-BPyHtPSB.js";import"./tooltip-BFYX9MeB.js";import"./Table-B88LD0fO.js";import"./summary-CBR-TMN0.js";import"./Checkbox-ChZFYaBU.js";import"./YearPickerInput-DQjO6Nmm.js";import"./insert-business-trip-modal-CkXaCqH7.js";import"./accounter-table-D9Vunjfy.js";const Le=()=>{const{setFiltersContext:p}=t.useContext(D),[n,u]=t.useState(void 0),[l,x]=t.useState(void 0),[c,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:W,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:1,setPage:()=>{},initiallyOpened:!0}),e.jsx(N,{label:"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(V,{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(B,{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(b,{}),i===100&&!a?.chargesWithLedgerChanges.filter(s=>!!s.charge).length&&e.jsx(R,{radius:"xl",size:"xl",color:"green",children:e.jsx(z,{})})]})]}),n&&e.jsx(A,{chargeId:n?.id,close:()=>u(void 0),onChange:n.onChange}),l&&e.jsx(Q,{chargeId:l.id,onChange:l.onChange,close:()=>x(void 0)}),c&&e.jsx(U,{chargeId:c.id,ownerId:c.ownerId,setMatchDocuments:()=>C(void 0)})]})};export{Le as ChargesLedgerValidation};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function i(o,u){return c=>{o?.(c),u?.(c)}}export{i as c};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as M,d9 as W,t as C,r as s,g as X,i as K,da as Q,db as Y,J as F,dc as E,j as e,D as R,aR as G,B as v,a3 as _,z as q,aS as J,aT as U,as as Z,at as ee,au as se,av as te,ax as ne,dd as ae,de as re,df as z,dg as V,bW as ce,dh as $,di as ie,N as P,X as B,L as A,dj as le,e as oe,O as de,Q as ue,dk as me,bh as he,b3 as xe,dl as je,x as k,dm as H,G as pe,K as fe,w as ge,W as ye,a2 as ve,cK as De,cV as be,cW as Ce,cX as O,cY as g,c_ as Ne,c$ as y,a4 as we,bS as Ie,F as Me,c as Te}from"./index-CuoWV8xf.js";import{s as L}from"./subMonths-QOcbO9QP.js";const Se=()=>{const[{data:u,fetching:o,error:c},x]=M({query:W});c&&(console.error(`Error fetching contracts: ${c}`),C.error("Error",{description:"Unable to fetch contracts"}));const a=s.useMemo(()=>u?.allOpenContracts?.slice().sort((t,d)=>t.client.originalBusiness.name>d.client.originalBusiness.name?1:-1)??[],[u]),i=s.useMemo(()=>a.map(t=>({value:t.id,label:t.client.originalBusiness.name})),[a]);return{fetching:o,refresh:()=>x(),openContracts:a,selectableOpenContracts:i}},Fe="IssueMonthlyDocuments",Ee=()=>{const[{fetching:u},o]=X(Q),c=s.useCallback(async x=>{const a="Error issuing monthly documents",i=Fe;C.loading("Issuing documents",{id:i});try{const t=await o(x),d=K(t,a,i);if(d?.issueGreenInvoiceDocuments?.success){C.success("Success",{id:i,description:"Documents issued successfully"});return}d?.issueGreenInvoiceDocuments?.errors&&console.error(d.issueGreenInvoiceDocuments.errors),C.error("Error",{id:i,description:a,duration:1e5,closeButton:!0})}catch(t){console.error(`${a}: ${t}`),C.error("Error",{id:i,description:a,duration:1e5,closeButton:!0})}},[o]);return{fetching:u,issueDocuments:c}};function ke({issueMonth:u,contracts:o,onAdd:c}){const[x,a]=s.useState(!1),[i,t]=s.useState(""),[{data:d},h]=M({query:Y,variables:{issueMonth:u,clientId:i}}),j=s.useCallback(n=>{t(n),h()},[h,t]);return s.useEffect(()=>{i!==""&&d&&(c(F(E,d.clientMonthlyChargeDraft)),a(!1))},[i,d,c]),e.jsxs(R,{open:x,onOpenChange:a,children:[e.jsx(G,{asChild:!0,children:e.jsx(v,{variant:"outline",size:"icon",children:e.jsx(_,{})})}),e.jsxs(q,{className:"w-[400px] max-w-screen-md",children:[e.jsx(J,{children:e.jsx(U,{children:"Select document recipient"})}),e.jsxs(Z,{onValueChange:j,children:[e.jsx(ee,{children:e.jsx(se,{placeholder:"Recipient"})}),e.jsx(te,{children:o.map(n=>e.jsx(ne,{value:n.client.originalBusiness.id,children:n.client.originalBusiness.name},n.client.originalBusiness.id))})]})]})]})}function Pe({onApprove:u,draft:o}){const[c,x]=s.useState(!1),[a,i]=s.useState(!1),[t,d]=s.useState(null),{previewDocument:h,fetching:j}=ae(),[n,N]=s.useState(re(o)),T=s.useCallback((l,p)=>{N(f=>({...f,[l]:p}))},[]);s.useEffect(()=>{i(!1)},[n]);const D=s.useCallback(async()=>{try{const l=await h({input:n});if(!l)throw new Error("No preview data returned");d(l),i(!0)}catch(l){console.error("Failed to generate preview:",l)}},[n,h]);s.useEffect(()=>{c&&!t&&D()},[c,t,D]);const w=n.income?.reduce((l,p)=>{const f=p.price*p.quantity,r=f*((p.vatRate||0)/100);return l+f+r},0)||0,I=()=>{u(n),x(!1)};return e.jsxs(R,{open:c,onOpenChange:x,children:[e.jsx(G,{asChild:!0,type:"button",children:e.jsxs(z,{children:[e.jsx(V,{asChild:!0,type:"button",children:e.jsx(v,{className:"size-7.5",variant:"secondary",onClick:()=>x(l=>!l),type:"button",children:e.jsx(ce,{className:"size-5"})})}),e.jsx($,{children:e.jsx("p",{children:"Edit document"})})]})}),e.jsx(q,{className:"w-7xl sm:max-w-[95%] max-h-[90vh] overflow-y-auto",children:e.jsx("div",{className:"min-h-screen bg-gray-50 p-4",children:e.jsxs("div",{className:"max-w-7xl mx-auto",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"text-3xl font-bold text-gray-900",children:"Edit Document"}),e.jsx("p",{className:"text-gray-600 mt-2",children:"Modify and preview your accounting document before issuing"})]}),e.jsxs("div",{className:"grid lg:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsx(ie,{formData:n,updateFormData:T}),e.jsx(P,{children:e.jsxs(B,{className:"pt-6",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx(v,{onClick:D,disabled:j||a,variant:"outline",className:"flex-1 bg-transparent",children:j?e.jsxs(e.Fragment,{children:[e.jsx(A,{className:"w-4 h-4 mr-2 animate-spin"}),"Generating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(le,{className:"w-4 h-4 mr-2"}),"Preview"]})}),e.jsxs(v,{onClick:I,className:"flex-1",children:[e.jsx(oe,{className:"w-4 h-4 mr-2"}),"Accept Changes"]})]}),w>0&&e.jsx("div",{className:"mt-4 p-3 bg-blue-50 rounded-lg",children:e.jsxs("div",{className:"flex justify-between items-center font-medium text-blue-900",children:[e.jsx("span",{children:"Total Document Amount:"}),e.jsxs("span",{children:[w.toFixed(2)," ",n.currency]})]})})]})})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(P,{className:"h-fit",children:[e.jsx(de,{children:e.jsx(ue,{children:"Document Preview"})}),e.jsx(B,{children:e.jsx("div",{className:"border-2 border-dashed border-gray-200 rounded-lg min-h-[600px] flex items-center justify-center bg-gray-50",children:j?e.jsxs("div",{className:"text-center",children:[e.jsx(A,{className:"w-8 h-8 animate-spin mx-auto mb-4 text-gray-400"}),e.jsx("p",{className:"text-gray-500",children:"Generating document preview..."})]}):t?e.jsx("div",{className:"w-full",children:e.jsx("div",{className:"bg-white shadow-lg rounded-lg overflow-hidden",children:e.jsx("div",{className:"aspect-[8.5/11] bg-white border",children:e.jsx("div",{className:"h-full flex items-center justify-center",children:e.jsxs("div",{className:"text-center p-6",children:[e.jsx(me,{src:t}),!a&&e.jsx("p",{className:"text-xs text-amber-600 mt-3 bg-amber-50 px-2 py-1 rounded",children:"Preview may be outdated"})]})})})})}):e.jsxs("div",{className:"text-center",children:[e.jsx(he,{className:"w-16 h-16 mx-auto mb-4 text-gray-300"}),e.jsx("p",{className:"text-gray-500 mb-2",children:"No preview available"}),e.jsx("p",{className:"text-sm text-gray-400",children:"Click Preview to generate document"})]})})})]}),n.client?.id&&e.jsx(xe,{businessId:n.client?.id,linkedDocumentIds:n.linkedDocumentIds??[]}),e.jsx(je,{documentType:n.type})]})]})]})})})]})}const Be=({drafts:u})=>{const[o,c]=s.useState(u.map(r=>F(E,r))),x=k(L(new Date,1),"yyyy-MM-dd"),[a,i]=s.useState(x),[{data:t},d]=M({query:H,variables:{issueMonth:a},pause:!0});s.useEffect(()=>{t?.clientMonthlyChargesDrafts&&c(t.clientMonthlyChargesDrafts.map(r=>F(E,r)))},[t,c]),s.useEffect(()=>{d()},[a,d]);const h=pe({values:{generateDocumentsInfo:o}}),{issueDocuments:j}=Ee(),{openContracts:n}=Se(),{fields:N,append:T,remove:D,update:w}=fe({control:h.control,name:"generateDocumentsInfo"}),I=h.watch("generateDocumentsInfo"),l=s.useMemo(()=>N.map((r,m)=>({...r,...I[m],id:r.client?.id})),[N,I]),p=s.useCallback(r=>{j(r)},[j]),f=s.useMemo(()=>n.filter(r=>r.billingCycle===ge.Monthly&&!l.some(m=>m.client?.id===r.client.originalBusiness.id)),[l,n]);return e.jsx("div",{className:"p-2",children:e.jsx(ye,{...h,children:e.jsxs("form",{onSubmit:h.handleSubmit(p),children:[e.jsxs("div",{className:"flex gap-2 items-center mb-4",children:[e.jsx(ve,{children:"Issue Month:"}),e.jsx(De,{value:new Date(a),onChange:r=>{const m=new Date(r.getFullYear(),r.getMonth(),15);i(k(m,"yyyy-MM-dd"))},popoverProps:{withinPortal:!0}})]}),e.jsxs(be,{children:[e.jsx(Ce,{children:e.jsxs(O,{children:[e.jsx(g,{children:"Name"}),e.jsx(g,{children:"Document"}),e.jsx(g,{children:"Amount"}),e.jsx(g,{children:"Remark"}),e.jsx(g,{children:"Recipients"}),e.jsx(g,{})]})}),e.jsx(Ne,{children:l.map(({id:r,...m},S)=>e.jsxs(O,{children:[e.jsx(y,{children:m.client?.name}),e.jsx(y,{children:m.type}),e.jsxs(y,{children:[m.income?.[0]?.price," ",m.income?.[0]?.currency]}),e.jsx(y,{children:e.jsx("span",{className:"text-sm text-gray-500 whitespace-normal max-w-50",children:m.remarks})}),e.jsx(y,{children:e.jsx("div",{className:"flex flex-col",children:m.client?.emails?.map(b=>e.jsx("span",{className:"text-sm text-gray-500",children:b},b))})}),e.jsx(y,{children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs(z,{children:[e.jsx(V,{asChild:!0,type:"button",children:e.jsx(v,{className:"size-7.5",variant:"secondary",onClick:()=>D(S),children:e.jsx(we,{size:16})})}),e.jsx($,{children:e.jsx("p",{children:"Remove document"})})]}),e.jsx(Pe,{draft:m,onApprove:b=>{h.setValue(`generateDocumentsInfo.${S}`,b,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0}),w(S,{...b})}})]})})]},r))})]}),e.jsxs("div",{className:"flex justify-between items-center mt-4",children:[e.jsx(ke,{contracts:f,onAdd:T,issueMonth:a}),e.jsx(Ie,{onConfirm:h.handleSubmit(p),title:`Are you sure you want to issue ${l.length} documents?`,children:e.jsx(v,{children:"Issue"})})]})]})})})},Re=()=>{const{setFiltersContext:u}=s.useContext(Me),[{data:o,fetching:c}]=M({query:H,variables:{issueMonth:k(L(new Date,1),"yyyy-MM-dd")}});return s.useEffect(()=>{o?.clientMonthlyChargesDrafts||u(null)},[o,u]),c?e.jsx(Te,{}):e.jsx(Be,{drafts:o?.clientMonthlyChargesDrafts??[]})};export{Re as IssueDocuments};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as l,F as C,u as S,j as e,T as h,B as g,bm as u,aQ as a,L as y,bn as N,bo as R}from"./index-CuoWV8xf.js";import{u as T}from"./use-url-query-CMqziw3P.js";import{A as v}from"./accounter-table-D9Vunjfy.js";import{P as E}from"./page-layout-jOFfeRt_.js";import{C as L,a as F,B,M as z}from"./business-extended-info-CFdeLUKP.js";import{B as I}from"./business-ledger-filters-ClJxXoLC.js";import{P as A,a as k}from"./panel-top-open-BLNJL6FI.js";import{T as O}from"./Table-B88LD0fO.js";import"./Pagination-CraTfR0n.js";import"./create-event-handler-BiA-1lGu.js";import"./download-csv-button-DUWRJL2T.js";import"./modal-CguzFJgR.js";import"./funnel-DrJtNpvJ.js";import"./MultiSelect-h-orVW8D.js";const Y=()=>{const{get:t}=T(),{setFiltersContext:i}=l.useContext(C),[r,o]=l.useState(!1),[p,j]=l.useState(!1),[m,x]=l.useState(t("ledgerRecordsFilters")?JSON.parse(decodeURIComponent(t("ledgerRecordsFilters"))):{}),[{data:c,fetching:w}]=S({query:N,variables:{filters:m}});l.useEffect(()=>{i(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(I,{filter:m,setFilter:x}),e.jsx(h,{label:"Expand all accounts",children:e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>o(s=>!s),children:r?e.jsx(A,{className:"size-5"}):e.jsx(k,{className:"size-5"})})}),e.jsx(h,{label:"Expand all currencies",children:e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>j(s=>!s),children:p?e.jsx(L,{className:"size-5"}):e.jsx(F,{className:"size-5"})})})]}))},[c,m,i,x,r,o,p]);const b=l.useMemo(()=>c?.businessTransactionsSumFromLedgerRecords.__typename==="CommonError"?[]:c?.businessTransactionsSumFromLedgerRecords.businessTransactionsSum?c.businessTransactionsSumFromLedgerRecords.businessTransactionsSum.sort((s,d)=>s.business.name.localeCompare(d.business.name)):[],[c?.businessTransactionsSumFromLedgerRecords]),f=[{title:"Business Name",value:s=>s.business.name},{title:"Debit / Credit",value:s=>e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("p",{className:"flex flex-row gap-2 whitespace-nowrap",children:e.jsx(u,{c:"red",children:s.debit.formatted})}),e.jsx("p",{className:"flex flex-row gap-2 whitespace-nowrap",children:e.jsx(u,{c:"green",children:s.credit.formatted})})]}),style:{whiteSpace:"nowrap"}},{title:"Total",value:s=>e.jsx(u,{c:s.total.raw<-1e-4?"red":s.total.raw>1e-4?"green":void 0,fw:700,children:s.total.formatted}),style:{whiteSpace:"nowrap"}},...n(a.Eur),...n(a.Usd),...n(a.Gbp),...n(a.Cad),...n(a.Jpy),...n(a.Aud),...n(a.Sek),...P(p)];return e.jsx(E,{title:"Business Ledger Records",description:"Business Ledger Records Summary",children:w?e.jsx(y,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs(O,{striped:!0,highlightOnHover:!0,children:[e.jsx("thead",{className:"sticky top-0 z-20",children:e.jsxs("tr",{className:"tracking-wider font-medium text-gray-900 text-sm bg-gray-100",children:[f.map((s,d)=>s.disabled?null:e.jsx("th",{children:s.title},String(d))),e.jsx("th",{children:"More Info"})]})}),e.jsx("tbody",{children:b.map((s,d)=>e.jsx(v,{columns:f,item:s,moreInfo:()=>e.jsx(B,{businessID:s.business.id,filter:m}),isShowAll:r},d))})]})})};function n(t){return[{title:`${t} Debit / Credit`,value:i=>{const r=i.foreignCurrenciesSum.find(o=>o.currency===t);return r?e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("p",{className:"flex flex-row gap-2 whitespace-nowrap",children:e.jsx(u,{c:"red",children:r.debit.formatted})}),e.jsx("p",{className:"flex flex-row gap-2 whitespace-nowrap",children:e.jsx(u,{c:"green",children:r.credit.formatted})})]}):null},style:{whiteSpace:"nowrap"}},{title:`${t} Total`,value:i=>{const r=i.foreignCurrenciesSum.find(o=>o.currency===t);return r?.total?.raw&&(r.total.raw<-1e-4||r.total.raw>1e-4)?e.jsx(z,{color:r.total.raw>0?"green":"red",children:r.total.formatted}):r?.total?.formatted},style:{whiteSpace:"nowrap"}}]}function P(t){return t?Object.values(a).filter(r=>!R.includes(r)).map(n).flat():[]}export{Y as BusinessLedgerRecordsSummery};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{g as k,h as M,r as a,t as j,i as A,u as N,k as F,j as e,c as L,l as P,B as S,m as v,n as T,I as z,F as D,o as $,T as O,L as R,p as U,R as b,q,s as _}from"./index-CuoWV8xf.js";import{u as C}from"./use-url-query-CMqziw3P.js";import{B as Q}from"./business-header-pPq6w0Xw.js";import{C as V,M as H}from"./Checkbox-ChZFYaBU.js";import{P as K}from"./page-layout-jOFfeRt_.js";import{P as G}from"./Pagination-CraTfR0n.js";import{P as J,a as W}from"./panel-top-open-BLNJL6FI.js";import"./building-2-MkMlc3HY.js";import"./create-event-handler-BiA-1lGu.js";const X="mergeBusinesses",Y=()=>{const[{fetching:o},d]=k(M),u=a.useCallback(async l=>{const c=`Error merging into business ID [${l.targetBusinessId}]`,t=`${X}-${l.targetBusinessId}`;j.loading("Merging Businesses",{id:t});try{const i=await d(l),s=A(i,c,t);if(s)return j.success("Success",{id:t,description:"Businesses merged"}),s.mergeBusinesses.id}catch(i){console.error(`${c}: ${i}`),j.error("Error",{id:t,description:c,duration:1e5,closeButton:!0})}},[d]);return{fetching:o,mergeBusinesses:u}};function Z({businessIds:o,onDone:d,resetMerge:u}){const{mergeBusinesses:l,fetching:c}=Y(),t=Array.from(new Set(o)),[{data:i,fetching:s}]=N({query:F,variables:{businessIds:t}}),[m,h]=a.useState(i?.businesses[0]),n=i?.businesses.length!==t.length&&"Some businesses were not Found"||void 0,g=i?.businesses||[],p=a.useCallback(async()=>{if(!m){j.error("Error",{description:"No main business selected"});return}if(t.length<2){j.error("Error",{description:"At least 2 businesses are required to execute a merge"});return}return await l({targetBusinessId:m.id,businessIdsToMerge:t.filter(x=>x!==m.id)}),u(),d()},[m,t,l,d,u]);return e.jsxs(e.Fragment,{children:[s&&e.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:e.jsx(L,{})}),!s&&n&&e.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:e.jsx("h3",{className:"sm:text-2xl text-xl font-medium title-font mb-6 text-gray-900",children:n})}),!s&&!n&&e.jsxs(e.Fragment,{children:[e.jsxs("table",{children:[e.jsxs("tr",{children:[e.jsx("th",{children:"Main"}),g.map(x=>e.jsx("td",{children:e.jsx("div",{className:"flex items-center justify-center mx-2 px-2 py-2 border-2 border-b-0 rounded-t-xl",children:e.jsx(V,{checked:x.id===m?.id,size:"xl",onClick:()=>{h(x)}})})},x.id))]}),e.jsxs("tr",{children:[e.jsx("th",{children:"Name"}),g.map(x=>e.jsx("td",{children:x.name},x.id))]})]}),e.jsxs("div",{className:"flex justify-center gap-5 mt-5",children:[e.jsx("button",{type:"button",className:" text-white bg-blue-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-blue-600 rounded-sm text-lg",disabled:s||c,onClick:p,children:"Accept"}),e.jsx("button",{type:"button",className:" text-white bg-red-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-red-600 rounded-sm text-lg",onClick:d,children:"Cancel"}),e.jsx("button",{type:"button",className:" text-white bg-red-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-red-600 rounded-sm text-lg",onClick:()=>{u(),d()},children:"Reset Merge"})]})]})]})}function ee(o){const[d,{close:u,open:l}]=P(!1),{selected:c,resetMerge:t}=o,i=new Set(c.map(({id:g})=>g)),s=i.size>=1,[m,h]=a.useState(s?"default":"outline");a.useEffect(()=>{h(s?"default":"outline")},[s]);const n=a.useCallback(()=>{u(),c.map(({onChange:g})=>g())},[c,u]);return e.jsxs(e.Fragment,{children:[e.jsx(S,{onClick:()=>{s&&l()},disabled:!s,variant:m,className:v("size-7.5",s?" bg-blue-500 hover:bg-blue-500/90":""),size:"icon",children:e.jsx(H,{className:"size-5"})}),e.jsx(T,{opened:d,onClose:u,size:"auto",centered:!0,children:e.jsx(Z,{businessIds:Array.from(i),onDone:n,resetMerge:t})})]})}function se({activePage:o,setPage:d,totalPages:u=1,businessName:l,setBusinessName:c}){const{get:t,set:i}=C(),[s,m]=a.useState(l);a.useEffect(()=>{const n=o>1?o.toFixed(0):void 0,g=t("page");n!==g&&n!=="1"&&i("page",n)},[o,t,i]),a.useEffect(()=>{const n=setTimeout(()=>{c(s)},600);return()=>{clearTimeout(n)}},[s,c]);const h=n=>{m(n)};return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(G,{className:"flex-auto",value:o,onChange:d,total:u}),e.jsx(z,{className:"w-72",placeholder:"Business Name",defaultValue:l??void 0,onChange:n=>h(n.target.value===""?void 0:n.target.value)})]})}const ue=()=>{const{get:o}=C(),[d,u]=a.useState(!1),[l,c]=a.useState(o("page")?Number(o("page")):1),[t,i]=a.useState(o("name")?o("page"):void 0),{setFiltersContext:s}=a.useContext(D),[{data:m,fetching:h},n]=N({query:_,variables:{page:l,limit:100,name:t}}),g=$(),[p,x]=a.useState([]),y=a.useCallback((r,f)=>{p.map(B=>B.id).includes(r)?x(p.filter(B=>B.id!==r)):x([...p,{id:r,onChange:f}])},[p]);function I(){x([])}a.useEffect(()=>{s(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(se,{activePage:l,setPage:c,businessName:t,setBusinessName:i,totalPages:m?.allBusinesses?.pageInfo.totalPages}),e.jsx(O,{label:"Expand all businesses",children:e.jsx(S,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>u(r=>!r),children:d?e.jsx(J,{className:"size-5"}):e.jsx(W,{className:"size-5"})})}),e.jsx(ee,{selected:p,resetMerge:I})]}))},[m,l,t,d,s,c,i,u,p]);const E=m?.allBusinesses?.nodes.filter(r=>r.__typename==="LtdFinancialEntity").sort((r,f)=>r.name.toLowerCase()>f.name.toLowerCase()?1:-1)??[],w=new Set(p.map(r=>r.id));return e.jsx(K,{title:`Businesses (${m?.allBusinesses?.pageInfo.totalRecords??""})`,description:"All businesses",headerActions:e.jsx("div",{className:"flex items-center py-4 gap-4",children:e.jsx(q,{description:"",onAdd:()=>n()})}),children:h?e.jsx("div",{className:"flex flex-row justify-center",children:e.jsx(R,{className:v("h-10 w-10 animate-spin mr-2")})}):e.jsx("div",{className:"space-y-2",children:E.map(r=>e.jsx("div",{className:"group relative border rounded-lg hover:shadow-md transition-shadow",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"pl-4 flex items-center",children:e.jsx(U,{checked:w.has(r.id),onCheckedChange:()=>{y(r.id,()=>{})},className:"h-4 w-4 rounded border-gray-300 cursor-pointer",onClick:f=>f.stopPropagation()})}),e.jsx("div",{role:"button",tabIndex:0,className:"flex-1 cursor-pointer",onClick:()=>{g(b.BUSINESSES.DETAIL(r.id),{state:{from:b.BUSINESSES.ALL}})},onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),g(b.BUSINESSES.DETAIL(r.id),{state:{from:b.BUSINESSES.ALL}}))},children:e.jsx(Q,{data:r})})]})},r.id))})})};export{ue as Businesses};
|