@accounter/client 0.0.8-alpha-20251023121008-8c51a83a479af2fcbc3aa02c876285dc4e21f02b → 0.0.8-alpha-20251023122652-765c7f951395441461726b3b4345eebd020632d7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/CHANGELOG.md +16 -1
  2. package/dist/assets/{Checkbox-Bu7lbyW3.js → Checkbox-CpANMiXr.js} +2 -2
  3. package/dist/assets/{Progress-Cq1kNJW5.js → Progress-BEKiyNRK.js} +1 -1
  4. package/dist/assets/{Typography-qy9vYtPs.js → Typography-C0c5augK.js} +1 -1
  5. package/dist/assets/{accordion-DOoNLp8s.js → accordion-ZFVTCyDy.js} +1 -1
  6. package/dist/assets/accountant-approvals-CpzuSBgK.js +1 -0
  7. package/dist/assets/{all-charges-CkXCeGgB.js → all-charges-BTyaAlp7.js} +1 -1
  8. package/dist/assets/{arrow-up-down-DvV6Dq8U.js → arrow-up-down-PQdrJdei.js} +1 -1
  9. package/dist/assets/business-DiQFqEHI.js +42 -0
  10. package/dist/assets/{business-transactions-single-BSpUxu3D.js → business-transactions-single-DJqvqlMO.js} +1 -1
  11. package/dist/assets/{business-trip-Bv1KXZPV.js → business-trip-BXAjI1mO.js} +1 -1
  12. package/dist/assets/charges-filters-r7FjeZLc.js +1 -0
  13. package/dist/assets/{charges-ledger-validation-BcO2gYIK.js → charges-ledger-validation-CFc_zJFO.js} +1 -1
  14. package/dist/assets/{chart-Cg9PgOtK.js → chart-C5LuxRSv.js} +1 -1
  15. package/dist/assets/{data-table-pagination-aFECnXu9.js → data-table-pagination-g2cF8_uB.js} +1 -1
  16. package/dist/assets/{editable-business-trip-qxr12Yt0.js → editable-business-trip-DyQsUJjl.js} +2 -2
  17. package/dist/assets/index-2g0J28D2.js +1 -0
  18. package/dist/assets/{index-CuIQrA5k.js → index-6-J73JPC.js} +1 -1
  19. package/dist/assets/index-B5j8Fmt8.js +1 -0
  20. package/dist/assets/index-BSBV6pv2.js +9 -0
  21. package/dist/assets/{index-BFERto_M.js → index-BSg8ocop.js} +2 -2
  22. package/dist/assets/{index-B2_BlI07.js → index-Bpef3vuz.js} +2 -2
  23. package/dist/assets/index-BziuNiXZ.js +1 -0
  24. package/dist/assets/{index-BDsbL_Kg.js → index-C0OGGVXE.js} +2 -2
  25. package/dist/assets/index-C7KKktQ5.js +1 -0
  26. package/dist/assets/{index-Dh7go2PN.js → index-C99l-a0m.js} +1 -1
  27. package/dist/assets/index-CE3kLG2a.js +1 -0
  28. package/dist/assets/{index-GwuBtmZO.js → index-CJdrnxxy.js} +2 -2
  29. package/dist/assets/{index-DOrujuWI.js → index-CN2818Wt.js} +223 -233
  30. package/dist/assets/index-CjDRKTTf.js +1 -0
  31. package/dist/assets/index-CzzfC-dD.css +1 -0
  32. package/dist/assets/index-D2xdQJAx.js +1 -0
  33. package/dist/assets/index-DGvh10a7.js +1 -0
  34. package/dist/assets/index-DLI6Z9VU.js +1 -0
  35. package/dist/assets/index-DXL1qPt9.js +1 -0
  36. package/dist/assets/{index-BYyokQ1_.js → index-Is4LJW4y.js} +2 -2
  37. package/dist/assets/{index-aW2k8oov.js → index-S6eSocQH.js} +7 -7
  38. package/dist/assets/index-T-JiUNDA.js +1 -0
  39. package/dist/assets/{index-BNXVR9UW.js → index-gBZ-7Z07.js} +1 -1
  40. package/dist/assets/{index-M3bu66aM.js → index-o_W5PWRq.js} +6 -6
  41. package/dist/assets/{index.es-Bg5AVQ7i.js → index.es-DZgQ4YcV.js} +1 -1
  42. package/dist/assets/{issue-document-B4ZlDg1e.js → issue-document-D-JoFiMZ.js} +1 -1
  43. package/dist/assets/login-page-DsHy5amR.js +1 -0
  44. package/dist/assets/{missing-info-charges-Ck_n6s6i.js → missing-info-charges-CPnjfjfW.js} +1 -1
  45. package/dist/assets/page-not-found-CYmXF0n2.js +1 -0
  46. package/dist/assets/{pencil-CpRI4b2y.js → pencil-BUwX_eHK.js} +1 -1
  47. package/dist/assets/report-commentary-row-Bpvvtwpd.js +1 -0
  48. package/dist/assets/save-Ck68rh6u.js +11 -0
  49. package/dist/assets/similar-charges-by-business-modal-bUtiFfAw.js +1 -0
  50. package/dist/assets/{sub-Daf_8shG.js → sub-C2zifPY5.js} +1 -1
  51. package/dist/assets/subMonths-uUfFviD2.js +1 -0
  52. package/dist/index.html +2 -2
  53. package/package.json +1 -1
  54. package/src/components/business/business-header.tsx +2 -21
  55. package/src/components/businesses/all-businesses-row.tsx +87 -0
  56. package/src/components/businesses/cells/hebrew-name.tsx +31 -0
  57. package/src/components/businesses/cells/index.ts +2 -0
  58. package/src/components/businesses/cells/name.tsx +31 -0
  59. package/src/components/businesses/index.tsx +39 -56
  60. package/src/components/common/forms/business-card.tsx +234 -0
  61. package/src/components/common/forms/index.ts +1 -0
  62. package/src/components/common/modals/insert-business.tsx +51 -659
  63. package/src/gql/gql.ts +30 -6
  64. package/src/gql/graphql.ts +30 -7
  65. package/src/providers/urql-client.ts +2 -3
  66. package/src/providers/urql-error-handler.ts +27 -0
  67. package/src/providers/urql.tsx +5 -0
  68. package/src/router/loaders/business-loader.ts +2 -4
  69. package/src/router/loaders/charge-loader.ts +2 -4
  70. package/dist/assets/accountant-approvals-Be5zF2_c.js +0 -1
  71. package/dist/assets/building-2-B-rX_xIy.js +0 -6
  72. package/dist/assets/business-CNkwr3_Z.js +0 -32
  73. package/dist/assets/business-header-Drp6R3A0.js +0 -1
  74. package/dist/assets/charges-filters-CpNNXLPU.js +0 -1
  75. package/dist/assets/index--C4Az49P.js +0 -1
  76. package/dist/assets/index-A1xHtOLI.js +0 -1
  77. package/dist/assets/index-BrsmDzry.js +0 -1
  78. package/dist/assets/index-C3AdAlvt.js +0 -9
  79. package/dist/assets/index-CD53YLxm.js +0 -1
  80. package/dist/assets/index-CY2CmEvR.js +0 -1
  81. package/dist/assets/index-Crn32InT.js +0 -1
  82. package/dist/assets/index-CyI9xpFz.js +0 -1
  83. package/dist/assets/index-DStQk1jH.js +0 -1
  84. package/dist/assets/index-DtE5Y1ZB.css +0 -1
  85. package/dist/assets/index-DwzG6-LK.js +0 -1
  86. package/dist/assets/index-bPa4yB-5.js +0 -1
  87. package/dist/assets/index-vHwCjYSy.js +0 -1
  88. package/dist/assets/login-page-v4kHU0le.js +0 -1
  89. package/dist/assets/page-not-found-TWjTuISB.js +0 -1
  90. package/dist/assets/report-commentary-row-BNIW-6Qg.js +0 -1
  91. package/dist/assets/save-CjLvssI1.js +0 -6
  92. package/dist/assets/subMonths-DIZWyi5T.js +0 -1
@@ -1,2 +1,2 @@
1
- import{r as P,j as r,g as Q,a as W,fc as $,L as E,u as Y,ae as q,cZ as K,c_ as X,B as U,c$ as ee,V as te,cd as ne,bO as se,bP as oe,db as O,H as S,fd as Z,d0 as re,F as ie,c as le,Y as ae,_ as ce,a1 as ue}from"./index-DOrujuWI.js";import{A as fe,a as he,c as de,b as pe}from"./accordion-DOoNLp8s.js";var v={},z;function ye(){if(z)return v;z=1,Object.defineProperty(v,"__esModule",{value:!0}),v.calcSlices=v.applyPatch=v.calcPatch=v.lcs=v.diff=v.diff_core=void 0;function c(e,n){const{b:t,eq:s,stack_base:i}=e;let{i:l,N:o,j:h,M:a,Z:u,stack_top:x}=e;for(;;)switch(n){case 0:{e:for(;o>0&&a>0;){t.fill(0,0,2*u);const R=o-a,_=o+a,B=_&1,G=l+o-1,H=h+a-1,J=(_+B)/2;let F;t:for(let M=0;M<=J;M++){const I=2*Math.max(0,M-a)-M,L=M-2*Math.max(0,M-o);for(let f=I;f<=L;f+=2){const A=t[f-1-u*Math.floor((f-1)/u)],V=t[f+1-u*Math.floor((f+1)/u)],w=f===-M||f!==M&&A<V?V:A+1,k=w-f;let b=w,C=k;for(;b<o&&C<a&&s(l+b,h+C);)b++,C++;if(t[f-u*Math.floor(f/u)]=b,B===1&&(F=R-f)>=1-M&&F<M&&b+t[u+F-u*Math.floor(F/u)]>=o)if(M>1||b!==w){i[x++]=l+b,i[x++]=o-b,i[x++]=h+C,i[x++]=a-C,o=w,a=k,u=2*(Math.min(o,a)+1);continue e}else break t}for(let f=I;f<=L;f+=2){const A=t[u+f-1-u*Math.floor((f-1)/u)],V=t[u+f+1-u*Math.floor((f+1)/u)],w=f===-M||f!==M&&A<V?V:A+1,k=w-f;let b=w,C=k;for(;b<o&&C<a&&s(G-b,H-C);)b++,C++;if(t[u+f-u*Math.floor(f/u)]=b,B===0&&(F=R-f)>=-M&&F<=M&&b+t[F-u*Math.floor(F/u)]>=o)if(M>0||b!==w){i[x++]=l+o-w,i[x++]=w,i[x++]=h+a-k,i[x++]=k,o=o-b,a=a-C,u=2*(Math.min(o,a)+1);continue e}else break t}}if(o!==a){a>o?(l+=o,h+=o,a-=o,o=0):(l+=a,h+=a,o-=a,a=0);break}}if(o+a!==0)if(e.pxe===l||e.pye===h)e.pxe=l+o,e.pye=h+a;else{const R=e.pxs;if(e.oxs=e.pxs,e.oxe=e.pxe,e.oys=e.pys,e.oye=e.pye,e.pxs=l,e.pxe=l+o,e.pys=h,e.pye=h+a,R>=0)return e.i=l,e.N=o,e.j=h,e.M=a,e.Z=u,e.stack_top=x,1}}case 1:{if(x===0)return 2;a=i[--x],h=i[--x],o=i[--x],l=i[--x],u=2*(Math.min(o,a)+1),n=0}}}class m{constructor(n){this.state=n,this.c=0,this.result={value:null,done:!1}}[Symbol.iterator](){return this}next(){const{state:n,result:t}=this;if(this.c>1)return t.done=!0,t.value=void 0,t;const s=c(n,this.c);return this.c=s,s===1?(t.value=[n.oxs,n.oxe,n.oys,n.oye],t):n.pxs>=0?(t.value=[n.pxs,n.pxe,n.pys,n.pye],t):(t.done=!0,t.value=void 0,t)}}function D(e,n,t,s,i){const l=(Math.min(n,s)+1)*2,o=n+s,h=new(o<256?Uint8Array:o<65536?Uint16Array:Uint32Array)(2*l);return new m({i:e,N:n,j:t,M:s,Z:l,b:h,eq:i,pxs:-1,pxe:-1,pys:-1,pye:-1,oxs:-1,oxe:-1,oys:-1,oye:-1,stack_top:0,stack_base:[]})}v.diff_core=D;function d(e,n,t){let[s,i,l]=[0,e.length,n.length];if(typeof t=="function"){for(;s<i&&s<l&&t(s,s);)s++;if(s===i&&s===l)return[][Symbol.iterator]();for(;t(--i,--l)&&i>s&&l>s;);}else{for(;s<i&&s<l&&e[s]===n[s];)s++;if(s===i&&s===l)return[][Symbol.iterator]();for(;e[--i]===n[--l]&&i>s&&l>s;);t=(o,h)=>e[o]===n[h]}return D(s,i+1-s,s,l+1-s,t)}v.diff=d;class p{constructor(n,t){this.diff=n,this.N=t,this.i=0,this.j=0}[Symbol.iterator](){return this}next(){const n=this.diff.next();if(n.done){const{i:a,j:u,N:x}=this;return a<x&&(n.done=!1,n.value=[a,u,x-a],this.i=x),n}const t=n.value,s=t[0],i=t[1],l=t[3],{i:o,j:h}=this;return o!==s&&(t.length--,t[0]=o,t[1]=h,t[2]=s-o),this.i=i,this.j=l,n}}function y(e,n,t){return new p(d(e,n,t),e.length)}v.lcs=y;function*g(e,n,t){const s=ArrayBuffer.isView(e)?Uint8Array.prototype.subarray:e.slice;for(const i of d(e,n,t))i[2]=s.call(n,i[2],i[3]),yield i}v.calcPatch=g;function*N(e,n){let t=0;const s=ArrayBuffer.isView(e)?Uint8Array.prototype.subarray:e.slice;for(const[i,l,o]of n)t<i&&(yield s.call(e,t,i)),o.length>0&&(yield o),t=l;t<e.length&&(yield s.call(e,t))}v.applyPatch=N;function*j(e,n,t){let s=0;const i=ArrayBuffer.isView(e)?Uint8Array.prototype.subarray:e.slice;for(const[l,o,h,a]of d(e,n,t))s<l&&(yield[0,i.call(e,s,l)]),l<o&&(yield[-1,i.call(e,l,o)]),h<a&&(yield[1,i.call(n,h,a)]),s=o;s<e.length&&(yield[0,e.slice(s)])}return v.calcSlices=j,v}var xe=ye();const me=({children:c})=>r.jsx("span",{className:"bg-green-100",children:c}),je=({children:c})=>r.jsx("span",{className:"bg-red-100 line-through",children:c}),T=({children:c})=>r.jsx("span",{children:c}),ge=({content:c,contentOrigin:m,monthDate:D})=>{const d=P.useMemo(()=>{const p=[];if(!m)return p;const y=c.split(""),g=m.split(""),N=Array.from(xe.calcPatch(g,y)),j=[];let e=0;for(const[t,s,i]of N)if(j.length===0&&t>=17&&s<=25&&i.length===s-t){if(N.length===1)return p;continue}else e<t&&j.push([g.slice(e,t).join(""),T]),s>t&&j.push([g.slice(t,s).join(""),je]),i.length>0&&j.push([i.join(""),me]),e=s;e<g.length&&j.push([g.slice(e).join(""),T]);let n=[];for(const[t,s]of j){const i=t.split(`
2
- `);i.length===1?n.push(r.jsx(s,{children:t},`unchanged-${n.length}`)):i.map((l,o)=>{n.push(r.jsx(s,{children:l},o)),p.push(r.jsx("div",{children:n},p.length-1)),n=[]})}return n.length>0&&p.push(r.jsx("div",{children:n},p.length-1)),p},[c,m]);return r.jsxs("div",{className:"flex flex-col",children:[r.jsxs("div",{className:"text-sm text-gray-500 flex flex-row gap-2",children:[r.jsx("span",{className:"font-bold",children:"Month:"}),r.jsx("span",{children:D.slice(0,7)}),!d.length&&r.jsx(Q,{className:"text-green-500"})]}),!!d.length&&d]})},Me=({filter:c})=>{const[{data:m,fetching:D,hasNext:d}]=W({query:$,variables:c}),p=P.useMemo(()=>m?.pcnByDate?m.pcnByDate.sort((y,g)=>g.date>y.date?1:g.date<y.date?-1:0):[],[m?.pcnByDate]);return D?r.jsx("div",{className:"w-full h-full flex justify-center",children:r.jsx(E,{className:"h-10 w-10 animate-spin mr-2 self-center"})}):r.jsxs("div",{className:"flex flex-col gap-4",children:[!!m&&d&&r.jsx("div",{className:"w-full h-full flex justify-center",children:r.jsx(E,{className:"h-10 w-10 animate-spin mr-2 self-center"})}),p.map((y,g)=>r.jsx(ge,{content:y.content,contentOrigin:y.diffContent,monthDate:y.date},g))]})};function be({filter:c,setFilter:m,closeModal:D}){const{control:d,handleSubmit:p,setValue:y}=te({defaultValues:{...c}}),{selectableBusinesses:g,fetching:N}=ne(),j=e=>{m(e),D()};return r.jsxs(r.Fragment,{children:[N?r.jsx("div",{children:"Loading..."}):r.jsx("div",{}),r.jsxs("form",{onSubmit:p(j),children:[r.jsx(se,{name:"businessId",control:d,defaultValue:void 0,render:({field:e,fieldState:n})=>r.jsx(oe,{...e,data:g,value:e.value,disabled:N,label:"Businesses",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message})}),r.jsx(O,{label:"From date",defaultValue:c?.fromMonthDate?new Date(c.fromMonthDate):new Date,defaultDate:c?.fromMonthDate?new Date(c.fromMonthDate):new Date,onChange:e=>{const n=new Date(e.getFullYear(),e.getMonth(),15);y("fromMonthDate",S(n,"yyyy-MM-dd"))},popoverProps:{withinPortal:!0}}),r.jsx(O,{label:"To date",defaultValue:c?.toMonthDate?new Date(c.toMonthDate):new Date,defaultDate:c?.toMonthDate?new Date(c.toMonthDate):new Date,onChange:e=>{const n=new Date(e.getFullYear(),e.getMonth(),15);y("toMonthDate",S(n,"yyyy-MM-dd"))},popoverProps:{withinPortal:!0}}),r.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[r.jsx(U,{type:"submit",children:"Filter"}),r.jsx(U,{type:"button",onClick:D,children:"Cancel"})]})]})]})}function ve({filter:c,setFilter:m}){const[D,d]=P.useState(!1),{get:p,set:y}=Y(),{userContext:g}=P.useContext(q);function N(j){j||={businessId:g?.context.adminBusinessId??c.businessId,fromMonthDate:S(Z(new Date),"yyyy-MM-15"),toMonthDate:S(new Date,"yyyy-MM-15")},re(j,c)||m(j)}return P.useEffect(()=>{const j=K(c??{})?null:encodeURIComponent(JSON.stringify(c)),e=p("validateReportsFilters");j!==e&&y("validateReportsFilters",j)},[c,p,y]),r.jsxs(r.Fragment,{children:[r.jsx(X,{opened:D,onClose:()=>d(!1),content:r.jsx(be,{filter:c,setFilter:N,closeModal:()=>d(!1)})}),r.jsx(U,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>d(!0),children:r.jsx(ee,{className:"size-5"})})]})}const Ce=()=>{const{get:c}=Y(),{setFiltersContext:m}=P.useContext(ie),D=P.useMemo(()=>{try{if(c("validateReportsFilters"))return JSON.parse(decodeURIComponent(c("validateReportsFilters")))}catch(y){console.error("Error parsing filter from URL",y)}return{fromMonthDate:S(Z(new Date),"yyyy-MM-15"),toMonthDate:S(new Date,"yyyy-MM-15")}},[c]),[d,p]=P.useState(D);return P.useEffect(()=>{m(r.jsx("div",{className:"flex flex-row gap-2",children:r.jsx(ve,{filter:{...d},setFilter:p})}))},[d,m]),r.jsx(le,{title:"Report Validations",children:r.jsx(fe,{type:"single",collapsible:!0,children:r.jsx(he,{value:"pcn874",children:r.jsxs(ae,{className:"p-4",children:[r.jsx(de,{children:r.jsx(ce,{children:"Monthly VAT (PCN874)"})}),r.jsx(pe,{children:r.jsx(ue,{children:r.jsx(Me,{filter:d})})})]})})})})};export{Ce as ValidateReportsScreen};
1
+ import{r as F,j as r,g as W,a as $,fd as q,L as E,u as Y,U as H,d0 as K,d1 as X,B as U,d2 as ee,k as te,cf as ne,bR as se,bS as oe,de as O,Y as S,fe as G,d3 as re,F as ie,c as le,$ as ae,a1 as ce,a3 as fe}from"./index-CN2818Wt.js";import{A as ue,a as he,c as de,b as pe}from"./accordion-ZFVTCyDy.js";var v={},z;function ye(){if(z)return v;z=1,Object.defineProperty(v,"__esModule",{value:!0}),v.calcSlices=v.applyPatch=v.calcPatch=v.lcs=v.diff=v.diff_core=void 0;function c(e,n){const{b:t,eq:s,stack_base:i}=e;let{i:l,N:o,j:h,M:a,Z:f,stack_top:x}=e;for(;;)switch(n){case 0:{e:for(;o>0&&a>0;){t.fill(0,0,2*f);const V=o-a,_=o+a,B=_&1,Z=l+o-1,J=h+a-1,Q=(_+B)/2;let P;t:for(let M=0;M<=Q;M++){const I=2*Math.max(0,M-a)-M,L=M-2*Math.max(0,M-o);for(let u=I;u<=L;u+=2){const A=t[u-1-f*Math.floor((u-1)/f)],R=t[u+1-f*Math.floor((u+1)/f)],w=u===-M||u!==M&&A<R?R:A+1,k=w-u;let b=w,C=k;for(;b<o&&C<a&&s(l+b,h+C);)b++,C++;if(t[u-f*Math.floor(u/f)]=b,B===1&&(P=V-u)>=1-M&&P<M&&b+t[f+P-f*Math.floor(P/f)]>=o)if(M>1||b!==w){i[x++]=l+b,i[x++]=o-b,i[x++]=h+C,i[x++]=a-C,o=w,a=k,f=2*(Math.min(o,a)+1);continue e}else break t}for(let u=I;u<=L;u+=2){const A=t[f+u-1-f*Math.floor((u-1)/f)],R=t[f+u+1-f*Math.floor((u+1)/f)],w=u===-M||u!==M&&A<R?R:A+1,k=w-u;let b=w,C=k;for(;b<o&&C<a&&s(Z-b,J-C);)b++,C++;if(t[f+u-f*Math.floor(u/f)]=b,B===0&&(P=V-u)>=-M&&P<=M&&b+t[P-f*Math.floor(P/f)]>=o)if(M>0||b!==w){i[x++]=l+o-w,i[x++]=w,i[x++]=h+a-k,i[x++]=k,o=o-b,a=a-C,f=2*(Math.min(o,a)+1);continue e}else break t}}if(o!==a){a>o?(l+=o,h+=o,a-=o,o=0):(l+=a,h+=a,o-=a,a=0);break}}if(o+a!==0)if(e.pxe===l||e.pye===h)e.pxe=l+o,e.pye=h+a;else{const V=e.pxs;if(e.oxs=e.pxs,e.oxe=e.pxe,e.oys=e.pys,e.oye=e.pye,e.pxs=l,e.pxe=l+o,e.pys=h,e.pye=h+a,V>=0)return e.i=l,e.N=o,e.j=h,e.M=a,e.Z=f,e.stack_top=x,1}}case 1:{if(x===0)return 2;a=i[--x],h=i[--x],o=i[--x],l=i[--x],f=2*(Math.min(o,a)+1),n=0}}}class m{constructor(n){this.state=n,this.c=0,this.result={value:null,done:!1}}[Symbol.iterator](){return this}next(){const{state:n,result:t}=this;if(this.c>1)return t.done=!0,t.value=void 0,t;const s=c(n,this.c);return this.c=s,s===1?(t.value=[n.oxs,n.oxe,n.oys,n.oye],t):n.pxs>=0?(t.value=[n.pxs,n.pxe,n.pys,n.pye],t):(t.done=!0,t.value=void 0,t)}}function D(e,n,t,s,i){const l=(Math.min(n,s)+1)*2,o=n+s,h=new(o<256?Uint8Array:o<65536?Uint16Array:Uint32Array)(2*l);return new m({i:e,N:n,j:t,M:s,Z:l,b:h,eq:i,pxs:-1,pxe:-1,pys:-1,pye:-1,oxs:-1,oxe:-1,oys:-1,oye:-1,stack_top:0,stack_base:[]})}v.diff_core=D;function d(e,n,t){let[s,i,l]=[0,e.length,n.length];if(typeof t=="function"){for(;s<i&&s<l&&t(s,s);)s++;if(s===i&&s===l)return[][Symbol.iterator]();for(;t(--i,--l)&&i>s&&l>s;);}else{for(;s<i&&s<l&&e[s]===n[s];)s++;if(s===i&&s===l)return[][Symbol.iterator]();for(;e[--i]===n[--l]&&i>s&&l>s;);t=(o,h)=>e[o]===n[h]}return D(s,i+1-s,s,l+1-s,t)}v.diff=d;class p{constructor(n,t){this.diff=n,this.N=t,this.i=0,this.j=0}[Symbol.iterator](){return this}next(){const n=this.diff.next();if(n.done){const{i:a,j:f,N:x}=this;return a<x&&(n.done=!1,n.value=[a,f,x-a],this.i=x),n}const t=n.value,s=t[0],i=t[1],l=t[3],{i:o,j:h}=this;return o!==s&&(t.length--,t[0]=o,t[1]=h,t[2]=s-o),this.i=i,this.j=l,n}}function y(e,n,t){return new p(d(e,n,t),e.length)}v.lcs=y;function*g(e,n,t){const s=ArrayBuffer.isView(e)?Uint8Array.prototype.subarray:e.slice;for(const i of d(e,n,t))i[2]=s.call(n,i[2],i[3]),yield i}v.calcPatch=g;function*N(e,n){let t=0;const s=ArrayBuffer.isView(e)?Uint8Array.prototype.subarray:e.slice;for(const[i,l,o]of n)t<i&&(yield s.call(e,t,i)),o.length>0&&(yield o),t=l;t<e.length&&(yield s.call(e,t))}v.applyPatch=N;function*j(e,n,t){let s=0;const i=ArrayBuffer.isView(e)?Uint8Array.prototype.subarray:e.slice;for(const[l,o,h,a]of d(e,n,t))s<l&&(yield[0,i.call(e,s,l)]),l<o&&(yield[-1,i.call(e,l,o)]),h<a&&(yield[1,i.call(n,h,a)]),s=o;s<e.length&&(yield[0,e.slice(s)])}return v.calcSlices=j,v}var xe=ye();const me=({children:c})=>r.jsx("span",{className:"bg-green-100",children:c}),je=({children:c})=>r.jsx("span",{className:"bg-red-100 line-through",children:c}),T=({children:c})=>r.jsx("span",{children:c}),ge=({content:c,contentOrigin:m,monthDate:D})=>{const d=F.useMemo(()=>{const p=[];if(!m)return p;const y=c.split(""),g=m.split(""),N=Array.from(xe.calcPatch(g,y)),j=[];let e=0;for(const[t,s,i]of N)if(j.length===0&&t>=17&&s<=25&&i.length===s-t){if(N.length===1)return p;continue}else e<t&&j.push([g.slice(e,t).join(""),T]),s>t&&j.push([g.slice(t,s).join(""),je]),i.length>0&&j.push([i.join(""),me]),e=s;e<g.length&&j.push([g.slice(e).join(""),T]);let n=[];for(const[t,s]of j){const i=t.split(`
2
+ `);i.length===1?n.push(r.jsx(s,{children:t},`unchanged-${n.length}`)):i.map((l,o)=>{n.push(r.jsx(s,{children:l},o)),p.push(r.jsx("div",{children:n},p.length-1)),n=[]})}return n.length>0&&p.push(r.jsx("div",{children:n},p.length-1)),p},[c,m]);return r.jsxs("div",{className:"flex flex-col",children:[r.jsxs("div",{className:"text-sm text-gray-500 flex flex-row gap-2",children:[r.jsx("span",{className:"font-bold",children:"Month:"}),r.jsx("span",{children:D.slice(0,7)}),!d.length&&r.jsx(W,{className:"text-green-500"})]}),!!d.length&&d]})},Me=({filter:c})=>{const[{data:m,fetching:D,hasNext:d}]=$({query:q,variables:c}),p=F.useMemo(()=>m?.pcnByDate?m.pcnByDate.sort((y,g)=>g.date>y.date?1:g.date<y.date?-1:0):[],[m?.pcnByDate]);return D?r.jsx("div",{className:"w-full h-full flex justify-center",children:r.jsx(E,{className:"h-10 w-10 animate-spin mr-2 self-center"})}):r.jsxs("div",{className:"flex flex-col gap-4",children:[!!m&&d&&r.jsx("div",{className:"w-full h-full flex justify-center",children:r.jsx(E,{className:"h-10 w-10 animate-spin mr-2 self-center"})}),p.map((y,g)=>r.jsx(ge,{content:y.content,contentOrigin:y.diffContent,monthDate:y.date},g))]})};function be({filter:c,setFilter:m,closeModal:D}){const{control:d,handleSubmit:p,setValue:y}=te({defaultValues:{...c}}),{selectableBusinesses:g,fetching:N}=ne(),j=e=>{m(e),D()};return r.jsxs(r.Fragment,{children:[N?r.jsx("div",{children:"Loading..."}):r.jsx("div",{}),r.jsxs("form",{onSubmit:p(j),children:[r.jsx(se,{name:"businessId",control:d,defaultValue:void 0,render:({field:e,fieldState:n})=>r.jsx(oe,{...e,data:g,value:e.value,disabled:N,label:"Businesses",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message})}),r.jsx(O,{label:"From date",defaultValue:c?.fromMonthDate?new Date(c.fromMonthDate):new Date,defaultDate:c?.fromMonthDate?new Date(c.fromMonthDate):new Date,onChange:e=>{const n=new Date(e.getFullYear(),e.getMonth(),15);y("fromMonthDate",S(n,"yyyy-MM-dd"))},popoverProps:{withinPortal:!0}}),r.jsx(O,{label:"To date",defaultValue:c?.toMonthDate?new Date(c.toMonthDate):new Date,defaultDate:c?.toMonthDate?new Date(c.toMonthDate):new Date,onChange:e=>{const n=new Date(e.getFullYear(),e.getMonth(),15);y("toMonthDate",S(n,"yyyy-MM-dd"))},popoverProps:{withinPortal:!0}}),r.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[r.jsx(U,{type:"submit",children:"Filter"}),r.jsx(U,{type:"button",onClick:D,children:"Cancel"})]})]})]})}function ve({filter:c,setFilter:m}){const[D,d]=F.useState(!1),{get:p,set:y}=Y(),{userContext:g}=F.useContext(H);function N(j){j||={businessId:g?.context.adminBusinessId??c.businessId,fromMonthDate:S(G(new Date),"yyyy-MM-15"),toMonthDate:S(new Date,"yyyy-MM-15")},re(j,c)||m(j)}return F.useEffect(()=>{const j=K(c??{})?null:encodeURIComponent(JSON.stringify(c)),e=p("validateReportsFilters");j!==e&&y("validateReportsFilters",j)},[c,p,y]),r.jsxs(r.Fragment,{children:[r.jsx(X,{opened:D,onClose:()=>d(!1),content:r.jsx(be,{filter:c,setFilter:N,closeModal:()=>d(!1)})}),r.jsx(U,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>d(!0),children:r.jsx(ee,{className:"size-5"})})]})}const Ce=()=>{const{get:c}=Y(),{setFiltersContext:m}=F.useContext(ie),D=F.useMemo(()=>{try{if(c("validateReportsFilters"))return JSON.parse(decodeURIComponent(c("validateReportsFilters")))}catch(y){console.error("Error parsing filter from URL",y)}return{fromMonthDate:S(G(new Date),"yyyy-MM-15"),toMonthDate:S(new Date,"yyyy-MM-15")}},[c]),[d,p]=F.useState(D);return F.useEffect(()=>{m(r.jsx("div",{className:"flex flex-row gap-2",children:r.jsx(ve,{filter:{...d},setFilter:p})}))},[d,m]),r.jsx(le,{title:"Report Validations",children:r.jsx(ue,{type:"single",collapsible:!0,children:r.jsx(he,{value:"pcn874",children:r.jsxs(ae,{className:"p-4",children:[r.jsx(de,{children:r.jsx(ce,{children:"Monthly VAT (PCN874)"})}),r.jsx(pe,{children:r.jsx(fe,{children:r.jsx(Me,{filter:d})})})]})})})})};export{Ce as ValidateReportsScreen};
@@ -0,0 +1 @@
1
+ import{j as n,r as x,d1 as v,eL as g,B as D,d2 as R,D as h,f6 as j,bp as E,F as y,a as C,c as w,L as T,R as b,bC as A,eb as F,T as u,f7 as I}from"./index-CN2818Wt.js";import{d as N}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";const o=({originalAmount:a,diffAmount:t})=>!t||a===t?n.jsx("td",{children:a}):n.jsx("td",{children:n.jsxs("div",{className:"flex flex-col",children:[n.jsx("p",{className:t?"line-through":"",children:a}),t&&n.jsx("div",{className:"border-2 border-yellow-500 rounded-md",children:t})]})});function P({years:a,setYears:t}){const[r,l]=x.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsx(v,{opened:r,onClose:()=>l(!1),withCloseButton:!0,content:n.jsx(g,{type:"multiple",label:"Pick years",value:a?.map(d=>new Date(d,0,1)),onChange:d=>t(d.map(p=>p.getFullYear())),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date})}),n.jsx(D,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>l(!0),children:n.jsx(R,{className:"size-5"})})]})}const f=({originalRuleData:a,diffRuleData:t})=>{const r=h(j,a),l=h(j,t),d=l?.isCompliant!==r.isCompliant||l?.percentage.formatted!==r.percentage.formatted;return!l||!d?n.jsx("td",{className:r.isCompliant?"text-green-500":"text-red-500",children:r.percentage.formatted}):n.jsx("td",{className:r.isCompliant?"text-green-500":"text-red-500",children:n.jsxs("div",{className:"flex flex-col",children:[n.jsx("p",{className:"line-through ".concat(r.isCompliant?"text-green-500":"text-red-500"),children:r.percentage.formatted}),l&&n.jsx("div",{className:"border-2 border-yellow-500 rounded-md ".concat(l.isCompliant?"text-green-500":"text-red-500"),children:l.percentage.formatted})]})})},c=(a,t)=>F(t).format(a);function m(a,t){if(a.length!==0)return c(a.reduce((r,l)=>r+l,0),t)}const B=()=>{const{year:a}=E(),{setFiltersContext:t}=x.useContext(y),[r,l]=x.useState(a?[Number(a)]:[new Date().getFullYear()]),[{data:d,fetching:p}]=C({query:N(I),variables:{years:r}});x.useEffect(()=>{t(n.jsx("div",{className:"flex flex-row gap-2",children:n.jsx(P,{years:r,setYears:l})}))},[r,p,t]);const s=d?.corporateTaxRulingComplianceReport??[];return n.jsx(w,{title:"Corporate Tax Ruling Compliance Report",children:p?n.jsx(T,{className:"h-10 w-10 animate-spin mr-2 self-center"}):n.jsx("div",{className:"flex flex-col gap-4",children:s&&n.jsxs(b,{highlightOnHover:!0,fontSize:"md",children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{}),r.map(e=>n.jsx("th",{children:n.jsx(A,{inline:!0,size:12,processing:!s.find(i=>i.year===e)?.differences,disabled:!!s.find(i=>i.year===e)?.differences,color:"orange",zIndex:"auto",children:e})},e)),n.jsx("th",{children:"Summary"},"sum")]})}),n.jsxs("tbody",{children:[n.jsxs("tr",{children:[n.jsx("td",{children:"Total Income"}),s.map(e=>n.jsx(o,{originalAmount:e.totalIncome.formatted,diffAmount:e.differences?.totalIncome?.formatted??void 0},e.year)),n.jsx(o,{originalAmount:c(s.map(e=>e.totalIncome.raw).reduce((e,i)=>e+i,0),s[0].totalIncome.currency),diffAmount:m(s.map(e=>e.differences?.totalIncome?.raw??e.totalIncome.raw).filter(e=>!!e),s[0].totalIncome.currency)},"sum")]}),n.jsxs("tr",{children:[n.jsx("td",{children:"Total R&D Expensess"}),s.map(e=>n.jsx(o,{originalAmount:e.researchAndDevelopmentExpenses.formatted,diffAmount:e.differences?.researchAndDevelopmentExpenses?.formatted??void 0},e.year)),n.jsx(o,{originalAmount:c(s.map(e=>e.researchAndDevelopmentExpenses.raw).reduce((e,i)=>e+i,0),s[0].researchAndDevelopmentExpenses.currency),diffAmount:m(s.map(e=>e.differences?.researchAndDevelopmentExpenses?.raw??e.researchAndDevelopmentExpenses.raw).filter(e=>!!e),s[0].researchAndDevelopmentExpenses.currency)},"sum")]}),n.jsxs("tr",{children:[n.jsx("th",{children:n.jsx(u,{multiline:!0,width:220,transitionProps:{duration:200},label:s[0]?.rndRelativeToIncome.rule,children:n.jsx("p",{children:"R&D Expenses out of Income"})})}),s.map(e=>n.jsx(f,{originalRuleData:e.rndRelativeToIncome,diffRuleData:e.differences?.rndRelativeToIncome??void 0},e.year)),n.jsx("td",{})]}),n.jsxs("tr",{children:[n.jsx("td",{children:"Local Development Expenses"}),s.map(e=>n.jsx(o,{originalAmount:e.localDevelopmentExpenses.formatted,diffAmount:e.differences?.localDevelopmentExpenses?.formatted??void 0},e.year)),n.jsx(o,{originalAmount:c(s.map(e=>e.localDevelopmentExpenses.raw).reduce((e,i)=>e+i,0),s[0].localDevelopmentExpenses.currency),diffAmount:m(s.map(e=>e.differences?.localDevelopmentExpenses?.raw??e.localDevelopmentExpenses.raw).filter(e=>!!e),s[0].localDevelopmentExpenses.currency)},"sum")]}),n.jsxs("tr",{children:[n.jsx("th",{children:n.jsx(u,{multiline:!0,width:220,transitionProps:{duration:200},label:s[0]?.localDevelopmentRelativeToRnd.rule,children:n.jsx("p",{children:"Local Development out of R&D"})})}),s.map(e=>n.jsx(f,{originalRuleData:e.localDevelopmentRelativeToRnd,diffRuleData:e.differences?.localDevelopmentRelativeToRnd??void 0},e.year)),n.jsx("td",{})]}),n.jsxs("tr",{children:[n.jsx("td",{children:"Foreign Development Expenses"}),s.map(e=>n.jsx(o,{originalAmount:e.foreignDevelopmentExpenses.formatted,diffAmount:e.differences?.foreignDevelopmentExpenses?.formatted??void 0},e.year)),n.jsx(o,{originalAmount:c(s.map(e=>e.foreignDevelopmentExpenses.raw).reduce((e,i)=>e+i,0),s[0].foreignDevelopmentExpenses.currency),diffAmount:m(s.map(e=>e.differences?.foreignDevelopmentExpenses?.raw??e.foreignDevelopmentExpenses.raw).filter(e=>!!e),s[0].foreignDevelopmentExpenses.currency)},"sum")]}),n.jsxs("tr",{children:[n.jsx("th",{children:n.jsx(u,{multiline:!0,width:220,transitionProps:{duration:200},label:s[0]?.foreignDevelopmentRelativeToRnd.rule,children:n.jsx("p",{children:"Foreign Development out of R&D"})})}),s.map(e=>n.jsx(f,{originalRuleData:e.foreignDevelopmentRelativeToRnd,diffRuleData:e.differences?.foreignDevelopmentRelativeToRnd??void 0},e.year)),n.jsx("td",{})]}),n.jsxs("tr",{children:[n.jsx("td",{children:"R&D Business Trips Expenses"}),s.map(e=>n.jsx(o,{originalAmount:e.businessTripRndExpenses.formatted,diffAmount:e.differences?.businessTripRndExpenses?.formatted??void 0},e.year)),n.jsx(o,{originalAmount:c(s.map(e=>e.businessTripRndExpenses.raw).reduce((e,i)=>e+i,0),s[0].businessTripRndExpenses.currency),diffAmount:m(s.map(e=>e.differences?.businessTripRndExpenses?.raw??e.businessTripRndExpenses.raw).filter(e=>!!e),s[0].businessTripRndExpenses.currency)},"sum")]})]})]})})})};export{B as CorporateTaxRulingComplianceReport};
@@ -1,4 +1,4 @@
1
- import{D as V,i as q,eB as E,r,t as k,l as F,a as $,eC as _,j as s,n as L,eD as R,o as H,B as Q,p as X,q as G}from"./index-DOrujuWI.js";import{C as J,M as K}from"./Checkbox-Bu7lbyW3.js";/**
1
+ import{V,p as B,eC as q,r,t as k,s as F,a as $,eD as _,j as s,w as L,eE as R,x as H,B as Q,y as X,z as G}from"./index-CN2818Wt.js";import{C as J,M as K}from"./Checkbox-CpANMiXr.js";/**
2
2
  * @license lucide-react v0.546.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -8,4 +8,4 @@ import{D as V,i as q,eB as E,r,t as k,l as F,a as $,eC as _,j as s,n as L,eD as
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
- */const W=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],N=V("square-x",W),Y="mergeCharges",Z=()=>{const[{fetching:C},a]=q(E),c=r.useCallback(async x=>{const u=`Error merging into charge ID [${x.baseChargeID}]`,l=`${Y}-${x.baseChargeID}`;k.loading("Merging Charges",{id:l});try{const d=await a(x),n=F(d,u,l,"mergeCharges");if(n)return k.success("Success",{id:l,description:"Charges were merged"}),n.mergeCharges.charge}catch(d){console.error(`${u}: ${d}`),k.error("Error",{id:l,description:u,duration:1e5,closeButton:!0})}},[a]);return{fetching:C,mergeCharges:c}};function ee({chargeIds:C,onDone:a,resetMerge:c}){const{mergeCharges:x,fetching:u}=Z(),l=Array.from(new Set(C)),[{data:d,fetching:n}]=$({query:_,variables:{chargeIds:l}}),[i,I]=r.useState(d?.chargesByIDs[0]),[m,p]=r.useState(void 0),[f,z]=r.useState(void 0),[j,w]=r.useState(void 0),[v,M]=r.useState(void 0),[D,T]=r.useState(void 0),[y,A]=r.useState(void 0),[b,O]=r.useState(void 0),[h,P]=r.useState(void 0),S=d?.chargesByIDs.length!==l.length&&"Some charges were not Found"||void 0,o=d?.chargesByIDs||[],B=r.useCallback(async()=>{if(!i){k.error("Error",{description:"No main charge selected"});return}if(l.length<2){k.error("Error",{description:"At least 2 charges are required to execute a merge"});return}let e;return m&&m.value!==i.userDescription&&(e??={},e={...e,userDescription:m.value}),f&&f.value!==i.owner.id&&(e??={},e={...e,ownerId:f.value}),y&&y.value!==i.conversion&&(e??={},e={...e,isConversion:y.value}),j&&j.value!==i.property&&(e??={},e={...e,isProperty:j.value}),v&&v.value!==i.optionalVAT&&(e??={},e={...e,optionalVAT:v.value}),D&&D.value!==i.optionalDocuments&&(e??={},e={...e,optionalDocuments:D.value}),h&&h.value!==i.tags.map(t=>t.name).join(",")&&(e??={},e={...e,tags:h.value.split(",").filter(t=>t!=="").map(t=>({id:t}))}),b&&b.value!==i.isInvoicePaymentDifferentCurrency&&(e??={},e={...e,isInvoicePaymentDifferentCurrency:b.value}),await x({baseChargeID:i.id,chargeIdsToMerge:l.filter(t=>t!==i.id),fields:e}),c(),a()},[i,l,x,m,f,y,j,v,b,h,a,c]);return s.jsxs(s.Fragment,{children:[n&&s.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:s.jsx(L,{})}),!n&&S&&s.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:s.jsx("h3",{className:"sm:text-2xl text-xl font-medium title-font mb-6 text-gray-900",children:S})}),!n&&!S&&s.jsxs(s.Fragment,{children:[s.jsxs("table",{children:[s.jsxs("tr",{children:[s.jsx("th",{children:"Main"}),o.map(e=>s.jsx("td",{children:s.jsx("div",{className:"flex items-center justify-center mx-2 px-2 py-2 border-2 border-b-0 rounded-t-xl",children:s.jsx(J,{checked:e.id===i?.id,size:"xl",onClick:()=>{I(e),p({id:e.id,value:e.userDescription??""}),z({id:e.id,value:e.owner.id}),w({id:e.id,value:e.property??!1}),M({id:e.id,value:e.optionalVAT??!1}),T({id:e.id,value:e.optionalDocuments??!1}),O({id:e.id,value:e.isInvoicePaymentDifferentCurrency??!1}),A({id:e.id,value:e.conversion??!1}),P({id:e.id,value:(e.tags.map(t=>t.name)??[]).join(",")})}})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Description"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:!e.userDescription||m?.value===e.userDescription,onClick:()=>p({id:e.id,value:e.userDescription??""}),children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:m?.id===e.id?{background:"#228be633"}:{},children:e.userDescription})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Owner"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:f?.value===e.owner.id,onClick:()=>z({id:e.id,value:e.owner.id}),children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:f?.id===e.id?{background:"#228be633"}:{},children:e.owner.name})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Is Property"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:e.property==null||e.property===j?.value,onClick:()=>{w({id:e.id,value:e.property??!1})},children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:j?.id===e.id?{background:"#228be633"}:{},children:e.property?s.jsx(g,{size:20,color:"green"}):s.jsx(N,{size:20,color:"red"})})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Is Conversion"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:e.conversion==null||e.conversion===y?.value,onClick:()=>{A({id:e.id,value:e.conversion??!1})},children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:y?.id===e.id?{background:"#228be633"}:{},children:e.conversion?s.jsx(g,{size:20,color:"green"}):s.jsx(N,{size:20,color:"red"})})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Optional VAT"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:e.optionalVAT==null||e.optionalVAT===v?.value,onClick:()=>{M({id:e.id,value:e.optionalVAT??!1})},children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:v?.id===e.id?{background:"#228be633"}:{},children:e.optionalVAT?s.jsx(g,{size:20,color:"green"}):s.jsx(N,{size:20,color:"red"})})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Optional Documents"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:e.optionalDocuments==null||e.optionalDocuments===D?.value,onClick:()=>{T({id:e.id,value:e.optionalDocuments??!1})},children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:D?.id===e.id?{background:"#228be633"}:{},children:e.optionalDocuments?s.jsx(g,{size:20,color:"green"}):s.jsx(N,{size:20,color:"red"})})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Invoice-Payment Currency Difference"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:e.isInvoicePaymentDifferentCurrency==null||e.isInvoicePaymentDifferentCurrency===b?.value,onClick:()=>{w({id:e.id,value:e.isInvoicePaymentDifferentCurrency??!1})},children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:b?.id===e.id?{background:"#228be633"}:{},children:e.isInvoicePaymentDifferentCurrency?s.jsx(g,{size:20,color:"green"}):s.jsx(N,{size:20,color:"red"})})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Tags"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:e.tags==null||e.tags.map(t=>t.name).join(",")===h?.value,onClick:()=>{P({id:e.id,value:(e.tags.map(t=>t.name)??[]).join(",")})},children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:h?.id===e.id?{background:"#228be633"}:{},children:s.jsx(R,{items:e.tags.map(t=>s.jsxs("div",{className:"flex flex-col items-center",children:[s.jsx("div",{children:t.name}),t.namePath&&s.jsx("div",{children:t.namePath.join(" > ")})]},t.id))})})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Transactions"}),o.map(e=>s.jsx("td",{children:s.jsx("div",{className:"flex items-center justify-center mx-2 px-2 py-2 border-x-2",children:e.metadata?.transactionsCount??0})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Invoices"}),o.map(e=>s.jsx("td",{children:s.jsx("div",{className:"flex items-center justify-center mx-2 px-2 py-2 border-2 border-t-0 rounded-b-xl",children:e.metadata?.invoicesCount??0})},e.id))]})]}),s.jsxs("div",{className:"flex justify-center gap-5 mt-5",children:[s.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:n||u,onClick:B,children:"Accept"}),s.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:a,children:"Cancel"}),s.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:()=>{c(),a()},children:"Reset Merge"})]})]})]})}function ie(C){const[a,{close:c,open:x}]=H(!1),{selected:u,resetMerge:l}=C,d=new Set(u.map(({id:p})=>p)),n=d.size>=1,[i,I]=r.useState(n?"default":"outline");r.useEffect(()=>{I(n?"default":"outline")},[n]);const m=r.useCallback(()=>{c(),u.map(({onChange:p})=>p())},[u,c]);return s.jsxs(s.Fragment,{children:[s.jsx(Q,{onClick:()=>{n&&x()},disabled:!n,variant:i,className:X("size-7.5",n?" bg-blue-500 hover:bg-blue-500/90":""),size:"icon",children:s.jsx(K,{className:"size-5"})}),s.jsx(G,{opened:a,onClose:c,size:"auto",centered:!0,children:s.jsx(ee,{chargeIds:Array.from(d),onDone:m,resetMerge:l})})]})}export{ie as M};
11
+ */const W=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],N=V("square-x",W),Y="mergeCharges",Z=()=>{const[{fetching:C},a]=B(q),c=r.useCallback(async x=>{const u=`Error merging into charge ID [${x.baseChargeID}]`,l=`${Y}-${x.baseChargeID}`;k.loading("Merging Charges",{id:l});try{const d=await a(x),n=F(d,u,l,"mergeCharges");if(n)return k.success("Success",{id:l,description:"Charges were merged"}),n.mergeCharges.charge}catch(d){console.error(`${u}: ${d}`),k.error("Error",{id:l,description:u,duration:1e5,closeButton:!0})}},[a]);return{fetching:C,mergeCharges:c}};function ee({chargeIds:C,onDone:a,resetMerge:c}){const{mergeCharges:x,fetching:u}=Z(),l=Array.from(new Set(C)),[{data:d,fetching:n}]=$({query:_,variables:{chargeIds:l}}),[i,w]=r.useState(d?.chargesByIDs[0]),[m,p]=r.useState(void 0),[f,z]=r.useState(void 0),[j,I]=r.useState(void 0),[v,M]=r.useState(void 0),[D,T]=r.useState(void 0),[y,A]=r.useState(void 0),[b,O]=r.useState(void 0),[h,P]=r.useState(void 0),S=d?.chargesByIDs.length!==l.length&&"Some charges were not Found"||void 0,o=d?.chargesByIDs||[],E=r.useCallback(async()=>{if(!i){k.error("Error",{description:"No main charge selected"});return}if(l.length<2){k.error("Error",{description:"At least 2 charges are required to execute a merge"});return}let e;return m&&m.value!==i.userDescription&&(e??={},e={...e,userDescription:m.value}),f&&f.value!==i.owner.id&&(e??={},e={...e,ownerId:f.value}),y&&y.value!==i.conversion&&(e??={},e={...e,isConversion:y.value}),j&&j.value!==i.property&&(e??={},e={...e,isProperty:j.value}),v&&v.value!==i.optionalVAT&&(e??={},e={...e,optionalVAT:v.value}),D&&D.value!==i.optionalDocuments&&(e??={},e={...e,optionalDocuments:D.value}),h&&h.value!==i.tags.map(t=>t.name).join(",")&&(e??={},e={...e,tags:h.value.split(",").filter(t=>t!=="").map(t=>({id:t}))}),b&&b.value!==i.isInvoicePaymentDifferentCurrency&&(e??={},e={...e,isInvoicePaymentDifferentCurrency:b.value}),await x({baseChargeID:i.id,chargeIdsToMerge:l.filter(t=>t!==i.id),fields:e}),c(),a()},[i,l,x,m,f,y,j,v,b,h,a,c]);return s.jsxs(s.Fragment,{children:[n&&s.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:s.jsx(L,{})}),!n&&S&&s.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:s.jsx("h3",{className:"sm:text-2xl text-xl font-medium title-font mb-6 text-gray-900",children:S})}),!n&&!S&&s.jsxs(s.Fragment,{children:[s.jsxs("table",{children:[s.jsxs("tr",{children:[s.jsx("th",{children:"Main"}),o.map(e=>s.jsx("td",{children:s.jsx("div",{className:"flex items-center justify-center mx-2 px-2 py-2 border-2 border-b-0 rounded-t-xl",children:s.jsx(J,{checked:e.id===i?.id,size:"xl",onClick:()=>{w(e),p({id:e.id,value:e.userDescription??""}),z({id:e.id,value:e.owner.id}),I({id:e.id,value:e.property??!1}),M({id:e.id,value:e.optionalVAT??!1}),T({id:e.id,value:e.optionalDocuments??!1}),O({id:e.id,value:e.isInvoicePaymentDifferentCurrency??!1}),A({id:e.id,value:e.conversion??!1}),P({id:e.id,value:(e.tags.map(t=>t.name)??[]).join(",")})}})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Description"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:!e.userDescription||m?.value===e.userDescription,onClick:()=>p({id:e.id,value:e.userDescription??""}),children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:m?.id===e.id?{background:"#228be633"}:{},children:e.userDescription})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Owner"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:f?.value===e.owner.id,onClick:()=>z({id:e.id,value:e.owner.id}),children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:f?.id===e.id?{background:"#228be633"}:{},children:e.owner.name})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Is Property"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:e.property==null||e.property===j?.value,onClick:()=>{I({id:e.id,value:e.property??!1})},children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:j?.id===e.id?{background:"#228be633"}:{},children:e.property?s.jsx(g,{size:20,color:"green"}):s.jsx(N,{size:20,color:"red"})})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Is Conversion"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:e.conversion==null||e.conversion===y?.value,onClick:()=>{A({id:e.id,value:e.conversion??!1})},children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:y?.id===e.id?{background:"#228be633"}:{},children:e.conversion?s.jsx(g,{size:20,color:"green"}):s.jsx(N,{size:20,color:"red"})})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Optional VAT"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:e.optionalVAT==null||e.optionalVAT===v?.value,onClick:()=>{M({id:e.id,value:e.optionalVAT??!1})},children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:v?.id===e.id?{background:"#228be633"}:{},children:e.optionalVAT?s.jsx(g,{size:20,color:"green"}):s.jsx(N,{size:20,color:"red"})})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Optional Documents"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:e.optionalDocuments==null||e.optionalDocuments===D?.value,onClick:()=>{T({id:e.id,value:e.optionalDocuments??!1})},children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:D?.id===e.id?{background:"#228be633"}:{},children:e.optionalDocuments?s.jsx(g,{size:20,color:"green"}):s.jsx(N,{size:20,color:"red"})})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Invoice-Payment Currency Difference"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:e.isInvoicePaymentDifferentCurrency==null||e.isInvoicePaymentDifferentCurrency===b?.value,onClick:()=>{I({id:e.id,value:e.isInvoicePaymentDifferentCurrency??!1})},children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:b?.id===e.id?{background:"#228be633"}:{},children:e.isInvoicePaymentDifferentCurrency?s.jsx(g,{size:20,color:"green"}):s.jsx(N,{size:20,color:"red"})})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Tags"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:e.tags==null||e.tags.map(t=>t.name).join(",")===h?.value,onClick:()=>{P({id:e.id,value:(e.tags.map(t=>t.name)??[]).join(",")})},children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:h?.id===e.id?{background:"#228be633"}:{},children:s.jsx(R,{items:e.tags.map(t=>s.jsxs("div",{className:"flex flex-col items-center",children:[s.jsx("div",{children:t.name}),t.namePath&&s.jsx("div",{children:t.namePath.join(" > ")})]},t.id))})})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Transactions"}),o.map(e=>s.jsx("td",{children:s.jsx("div",{className:"flex items-center justify-center mx-2 px-2 py-2 border-x-2",children:e.metadata?.transactionsCount??0})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Invoices"}),o.map(e=>s.jsx("td",{children:s.jsx("div",{className:"flex items-center justify-center mx-2 px-2 py-2 border-2 border-t-0 rounded-b-xl",children:e.metadata?.invoicesCount??0})},e.id))]})]}),s.jsxs("div",{className:"flex justify-center gap-5 mt-5",children:[s.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:n||u,onClick:E,children:"Accept"}),s.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:a,children:"Cancel"}),s.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:()=>{c(),a()},children:"Reset Merge"})]})]})]})}function ie(C){const[a,{close:c,open:x}]=H(!1),{selected:u,resetMerge:l}=C,d=new Set(u.map(({id:p})=>p)),n=d.size>=1,[i,w]=r.useState(n?"default":"outline");r.useEffect(()=>{w(n?"default":"outline")},[n]);const m=r.useCallback(()=>{c(),u.map(({onChange:p})=>p())},[u,c]);return s.jsxs(s.Fragment,{children:[s.jsx(Q,{onClick:()=>{n&&x()},disabled:!n,variant:i,className:X("size-7.5",n?" bg-blue-500 hover:bg-blue-500/90":""),size:"icon",children:s.jsx(K,{className:"size-5"})}),s.jsx(G,{opened:a,onClose:c,size:"auto",centered:!0,children:s.jsx(ee,{chargeIds:Array.from(d),onDone:m,resetMerge:l})})]})}export{ie as M};
@@ -0,0 +1 @@
1
+ import{r as c,a as N,i as k,j as e,e as w,U as E,k as z,l as D,m as L,n as A,o as T,p as O,q as P,t as B,s as R,v as U,w as $,x as q,B as C,y as S,z as H,D as v,G as _,H as Q,P as F,b as I,J as V,K as G,N as J,u as M,O as K,Q as W,F as X,T as Y,c as Z,L as ee,R as se,S as te}from"./index-CN2818Wt.js";import{C as ne,M as ie}from"./Checkbox-CpANMiXr.js";import{u as ae,S as re}from"./similar-charges-by-business-modal-bUtiFfAw.js";function oe({businessID:t,updateBusiness:n}){const[r,u]=c.useState(void 0),[{data:o,fetching:i},l]=N({query:k,variables:{id:t}});return c.useEffect(()=>{i?u(void 0):o&&o.business.__typename==="LtdFinancialEntity"&&u(o.business)},[o,i]),c.useEffect(()=>{r&&n(r)},[r,n]),e.jsx("div",{className:"flex flex-col gap-5",children:r?e.jsx(le,{business:r,refetchBusiness:l}):i?e.jsx(w,{className:"flex self-center my-5",color:"dark",size:"xl",variant:"dots"}):e.jsx("p",{children:"Error fetching extended information for this business"})})}function le({business:t,refetchBusiness:n}){const[r,u]=c.useState(!1),[o,i]=c.useState(!1),[l,d]=c.useState(void 0),{userContext:g}=c.useContext(E),{updateBusiness:f,fetching:a}=ae(),x=z({defaultValues:{...t,taxCategory:t.taxCategory?.id,sortCode:t?.sortCode?.key,irsCode:t?.irsCode}}),{handleSubmit:p,formState:{dirtyFields:h}}=x,b=async j=>{if(!t||!g?.context.adminBusinessId)return;const s=T(j,h);s&&Object.keys(s).length>0&&(s.sortCode&&=parseInt(s.sortCode.toString()),s.suggestions?.tags&&(s.suggestions.tags=s.suggestions.tags.map(m=>({id:m.id}))),s.suggestions?.phrases&&(s.suggestions.phrases=j.suggestions.phrases.map(m=>m)),s.suggestions?.emails&&(s.suggestions.emails=j.suggestions.emails.map(m=>m)),s.suggestions?.emailListener&&(s.suggestions.emailListener.attachments&&=j.suggestions.emailListener.attachments.map(m=>m),s.suggestions.emailListener.internalEmailLinks&&=j.suggestions.emailListener.internalEmailLinks.map(m=>m)),await f({businessId:t.id,ownerId:g.context.adminBusinessId,fields:s}),s.suggestions?.tags?.length||s.suggestions?.description?(d({tagIds:s.suggestions?.tags?.map(m=>({id:m.id})),description:s.suggestions?.description??void 0}),i(!0)):n())};return e.jsxs(e.Fragment,{children:[r&&e.jsx(w,{className:"flex self-center my-5",color:"dark",size:"xl",variant:"dots"}),e.jsx("div",{className:"flex flex-row gap-5",children:e.jsx(D,{...x,children:e.jsxs("form",{onSubmit:p(b),children:[e.jsxs("div",{className:"flex flex-row mx-3 pt-3 sm:text-1xl gap-10",children:[e.jsx("h1",{className:"sm:text-2xl font-small text-gray-900",children:"Edit Business:"}),e.jsxs("div",{className:"flex flex-row gap-2",children:["ID: ",t.id,e.jsx(L,{content:t.id})]})]}),e.jsx("div",{className:"flex-row px-10 h-max justify-start block",children:e.jsx(A,{isInsert:!1,formManager:x,setFetching:u})}),e.jsx("div",{className:"mt-10 mb-5 flex justify-center gap-5",children:e.jsx("button",{type:"submit",onClick:()=>p(b),className:"mt-8 text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",disabled:a||Object.keys(h).length===0,children:"Update"})})]})})}),e.jsx(re,{businessId:t.id,tagIds:l?.tagIds,description:l?.description,open:o,onOpenChange:i,onClose:n})]})}const ce="mergeBusinesses",de=()=>{const[{fetching:t},n]=O(P),r=c.useCallback(async u=>{const o=`Error merging into business ID [${u.targetBusinessId}]`,i=`${ce}-${u.targetBusinessId}`;B.loading("Merging Businesses",{id:i});try{const l=await n(u),d=R(l,o,i);if(d)return B.success("Success",{id:i,description:"Businesses merged"}),d.mergeBusinesses.id}catch(l){console.error(`${o}: ${l}`),B.error("Error",{id:i,description:o,duration:1e5,closeButton:!0})}},[n]);return{fetching:t,mergeBusinesses:r}};function ue({businessIds:t,onDone:n,resetMerge:r}){const{mergeBusinesses:u,fetching:o}=de(),i=Array.from(new Set(t)),[{data:l,fetching:d}]=N({query:U,variables:{businessIds:i}}),[g,f]=c.useState(l?.businesses[0]),a=l?.businesses.length!==i.length&&"Some businesses were not Found"||void 0,x=l?.businesses||[],p=c.useCallback(async()=>{if(!g){B.error("Error",{description:"No main business selected"});return}if(i.length<2){B.error("Error",{description:"At least 2 businesses are required to execute a merge"});return}return await u({targetBusinessId:g.id,businessIdsToMerge:i.filter(h=>h!==g.id)}),r(),n()},[g,i,u,n,r]);return e.jsxs(e.Fragment,{children:[d&&e.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:e.jsx($,{})}),!d&&a&&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:a})}),!d&&!a&&e.jsxs(e.Fragment,{children:[e.jsxs("table",{children:[e.jsxs("tr",{children:[e.jsx("th",{children:"Main"}),x.map(h=>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(ne,{checked:h.id===g?.id,size:"xl",onClick:()=>{f(h)}})})},h.id))]}),e.jsxs("tr",{children:[e.jsx("th",{children:"Name"}),x.map(h=>e.jsx("td",{children:h.name},h.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:d||o,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:n,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:()=>{r(),n()},children:"Reset Merge"})]})]})]})}function ge(t){const[n,{close:r,open:u}]=q(!1),{selected:o,resetMerge:i}=t,l=new Set(o.map(({id:x})=>x)),d=l.size>=1,[g,f]=c.useState(d?"default":"outline");c.useEffect(()=>{f(d?"default":"outline")},[d]);const a=c.useCallback(()=>{r(),o.map(({onChange:x})=>x())},[o,r]);return e.jsxs(e.Fragment,{children:[e.jsx(C,{onClick:()=>{d&&u()},disabled:!d,variant:g,className:S("size-7.5",d?" bg-blue-500 hover:bg-blue-500/90":""),size:"icon",children:e.jsx(ie,{className:"size-5"})}),e.jsx(H,{opened:n,onClose:r,size:"auto",centered:!0,children:e.jsx(ue,{businessIds:Array.from(l),onDone:a,resetMerge:i})})]})}const me=({data:t})=>{const n=v(_,t);return e.jsx("td",{children:e.jsx("div",{style:{whiteSpace:"nowrap"},children:n.hebrewName})})},xe=({data:t})=>{const n=v(Q,t);return e.jsx("td",{children:e.jsx("div",{style:{whiteSpace:"nowrap"},children:n.name})})},he=({data:t,isAllOpened:n,toggleMergeBusiness:r,isSelectedForMerge:u})=>{const[o,i]=c.useState(!1),[l,d]=c.useState(v(J,t));return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{children:[e.jsx(xe,{data:l}),e.jsx(me,{data:l}),e.jsx("td",{children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(C,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>{i(g=>!g)},children:n||o?e.jsx(F,{className:"size-5"}):e.jsx(I,{className:"size-5"})}),r&&e.jsx(V,{toggleMergeSelected:()=>r(()=>{}),mergeSelected:u})]})})]}),(n||o)&&e.jsx("tr",{children:e.jsx("td",{colSpan:12,children:e.jsx(G,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:e.jsx(oe,{businessID:l.id,updateBusiness:d})})})})]})};function fe({activePage:t,setPage:n,totalPages:r=1,businessName:u,setBusinessName:o}){const{get:i,set:l}=M(),[d,g]=c.useState(u);c.useEffect(()=>{const a=t>1?t.toFixed(0):void 0,x=i("page");a!==x&&a!=="1"&&l("page",a)},[t,i,l]),c.useEffect(()=>{const a=setTimeout(()=>{o(d)},600);return()=>{clearTimeout(a)}},[d,o]);const f=a=>{g(a)};return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(K,{className:"flex-auto",value:t,onChange:n,total:r}),e.jsx(W,{className:"w-72",placeholder:"Business Name",defaultValue:u??void 0,onChange:a=>f(a.target.value===""?void 0:a.target.value)})]})}const Be=()=>{const{get:t}=M(),[n,r]=c.useState(!1),[u,o]=c.useState(t("page")?Number(t("page")):1),[i,l]=c.useState(t("name")?t("page"):void 0),{setFiltersContext:d}=c.useContext(X),[{data:g,fetching:f}]=N({query:te,variables:{page:u,limit:100,name:i}}),[a,x]=c.useState([]),p=c.useCallback((s,m)=>{a.map(y=>y.id).includes(s)?x(a.filter(y=>y.id!==s)):x([...a,{id:s,onChange:m}])},[a]);function h(){x([])}c.useEffect(()=>{d(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(fe,{activePage:u,setPage:o,businessName:i,setBusinessName:l,totalPages:g?.allBusinesses?.pageInfo.totalPages}),e.jsx(Y,{label:"Expand all businesses",children:e.jsx(C,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>r(s=>!s),children:n?e.jsx(F,{className:"size-5"}):e.jsx(I,{className:"size-5"})})}),e.jsx(ge,{selected:a,resetMerge:h})]}))},[g,u,i,n,d,o,l,r,a]);const b=g?.allBusinesses?.nodes.filter(s=>s.__typename==="LtdFinancialEntity").sort((s,m)=>s.name.toLowerCase()>m.name.toLowerCase()?1:-1)??[],j=new Set(a.map(s=>s.id));return e.jsx(Z,{title:`Businesses (${b.length})`,description:"All businesses",children:f?e.jsx("div",{className:"flex flex-row justify-center",children:e.jsx(ee,{className:S("h-10 w-10 animate-spin mr-2")})}):e.jsxs(se,{striped:!0,highlightOnHover:!0,children:[e.jsx("thead",{className:"sticky top-0 z-20",children:e.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.jsx("th",{children:"Name"}),e.jsx("th",{children:"Hebrew Name"}),e.jsx("th",{children:"More Info"})]})}),e.jsx("tbody",{children:b.map(s=>e.jsx(he,{data:s,isAllOpened:n,toggleMergeBusiness:p?m=>p(s.id,m):void 0,isSelectedForMerge:j.has(s.id)??!1},s.id))})]})})};export{Be as Businesses};
@@ -1 +1 @@
1
- import{j as e,dp as D,dt as t,H as y,cS as n,X as N,eP as v,cZ as T,r as d,u as S,d0 as A,K as I,an as O,B as w,c$ as P,N as M,V as L,dh as V,a0 as q,a2 as f,a3 as C,a4 as F,a5 as B,aO as U,a7 as R,aM as $,aA as k,F as H,ae as Q,a as _,c as z,n as G,dm as J,dn as K,dq as o,ds as X,eQ as Z}from"./index-DOrujuWI.js";const W=({record:a})=>{const s=N(v,a);return e.jsxs(D,{children:[e.jsx(t,{children:a.description}),e.jsx(t,{children:y(new Date(a.purchaseDate),"dd/MM/yyyy")}),e.jsx(t,{children:a.activationDate?y(new Date(a.activationDate),"dd/MM/yyyy"):void 0}),e.jsx(t,{children:s.originalCost?n(s.originalCost,0):void 0}),e.jsx(t,{children:s.reportYearDelta?n(s.reportYearDelta,0):void 0}),e.jsx(t,{children:n(s.totalDepreciableCosts,0)}),e.jsxs(t,{children:[n(a.statutoryDepreciationRate,0),"%"]}),e.jsx(t,{children:a.claimedDepreciationRate?`${n(a.claimedDepreciationRate,1)}%`:"-"}),e.jsx(t,{children:s.reportYearClaimedDepreciation?n(s.reportYearClaimedDepreciation,0):"-"}),e.jsx(t,{children:s.pastYearsAccumulatedDepreciation?n(s.pastYearsAccumulatedDepreciation,0):"-"}),e.jsx(t,{children:s.totalDepreciation?n(s.totalDepreciation,0):"-"}),e.jsx(t,{children:s.netValue?n(s.netValue,0):"-"})]})};function Y(a){return!a||T(a)?null:encodeURIComponent(JSON.stringify(a))}const b="depreciationReportFilters";function ee({filter:a,setFilter:s,close:r}){const p=L({defaultValues:{...a}}),{control:c,handleSubmit:x}=p,{selectableFinancialEntities:u,fetching:l}=V(),j=i=>{s({...i,year:Number(i.year)}),r()};return e.jsx(q,{...p,children:e.jsxs("form",{onSubmit:x(j),className:"space-y-4",children:[e.jsx(f,{name:"year",control:c,rules:{required:"Year is required",validate:i=>{const m=Number(i);return Number.isNaN(m)||m<2e3||m>2100?"Invalid year":!0}},render:({field:i})=>e.jsxs(C,{children:[e.jsx(F,{children:"Year"}),e.jsx(B,{children:e.jsx(U,{...i,hideControls:!0,decimalScale:0})}),e.jsx(R,{})]})}),e.jsx(f,{name:"financialEntityId",defaultValue:a?.financialEntityId,control:c,render:({field:i})=>e.jsxs(C,{children:[e.jsx(F,{children:"Owner"}),e.jsx($,{...i,data:u,value:i.value??void 0,disabled:l,placeholder:"Select a financial entity",formPart:!0}),e.jsx(R,{})]})}),e.jsx(k,{children:e.jsx(w,{type:"submit",disabled:l,children:"Filter"})})]})})}function ae({filter:a,setFilter:s}){const[r,p]=d.useState(!1),{get:c,set:x}=S();d.useEffect(()=>{const l=Y(a),j=c(b);l!==j&&x(b,l)},[a,c,x]);const u=d.useCallback(l=>{A(l,a)||s(l)},[a,s]);return e.jsxs(I,{open:r,onOpenChange:p,children:[e.jsx(O,{asChild:!0,children:e.jsx(w,{variant:"outline",size:"icon",children:e.jsx(P,{size:20})})}),e.jsx(M,{className:"sm:max-w-[425px]",children:e.jsx(ee,{filter:a,setFilter:u,close:()=>p(!1)})})]})}const g=({data:a,groupName:s})=>{const r=N(v,a);return e.jsxs(D,{className:"font-bold border-b border-black",children:[e.jsx(t,{children:s?"Group Total":"Overall Total"}),e.jsx(t,{colSpan:2,children:s}),e.jsx(t,{children:r.originalCost?n(r.originalCost,0):void 0}),e.jsx(t,{children:r.reportYearDelta?n(r.reportYearDelta,0):void 0}),e.jsx(t,{children:r.totalDepreciableCosts?n(r.totalDepreciableCosts,0):void 0}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{children:r.reportYearClaimedDepreciation?n(r.reportYearClaimedDepreciation,0):void 0}),e.jsx(t,{children:r.pastYearsAccumulatedDepreciation?n(r.pastYearsAccumulatedDepreciation,0):void 0}),e.jsx(t,{children:r.totalDepreciation?n(r.totalDepreciation,0):void 0}),e.jsx(t,{children:r.netValue?n(r.netValue,0):void 0})]})};function te(a){const s=new URLSearchParams,r=Y(a);return r&&s.append(b,r),`/reports/depreciation${s.size>0?`?${s}`:""}`}const re=()=>{const{setFiltersContext:a}=d.useContext(H),{userContext:s}=d.useContext(Q),{get:r}=S(),p=d.useMemo(()=>{const i={financialEntityId:s?.context.adminBusinessId,year:new Date().getFullYear()},m=r(b);if(m)try{return JSON.parse(decodeURIComponent(m))}catch(h){console.error("Failed to parse depreciation report filters from URL",h)}return i},[s?.context.adminBusinessId]),[c,x]=d.useState(p),[{data:u,fetching:l}]=_({query:Z,variables:{filters:c}});d.useEffect(()=>{a(e.jsx("div",{className:"flex flex-row gap-x-5",children:e.jsx(ae,{filter:c,setFilter:x})}))},[c,a,x]);const j=d.useMemo(()=>`Depreciation Report for ${c.year}`,[c.year]);return e.jsx(z,{title:"Depreciation Report",description:j,children:l?e.jsx(G,{}):e.jsxs(J,{children:[e.jsxs(K,{children:[e.jsxs(D,{className:"font-bold text-xl",children:[e.jsx(o,{colSpan:6,className:"text-center border-x",children:"List of Assets and Costs"}),e.jsx(o,{colSpan:5,className:"text-center border-x",children:"Depreciation"}),e.jsx(o,{className:"text-center border-x",children:"Remaining"})]}),e.jsxs(D,{className:"border-b border-black",children:[e.jsx(o,{className:"whitespace-normal",children:"Assets List and Descriptions"}),e.jsx(o,{className:"whitespace-normal",children:"Date of Purchase"}),e.jsx(o,{className:"whitespace-normal",children:"Activation Date"}),e.jsx(o,{className:"whitespace-normal",children:"Original Cost"}),e.jsx(o,{className:"whitespace-normal",children:"Changes During the Year"}),e.jsx(o,{className:"whitespace-normal",children:"Total Depreciable Assets"}),e.jsx(o,{className:"whitespace-normal",children:"Statutory Depreciation Rate"}),e.jsx(o,{className:"whitespace-normal",children:"Claimed Depreciation Rate"}),e.jsx(o,{className:"whitespace-normal",children:"Depreciation Claimed This Year"}),e.jsx(o,{className:"whitespace-normal",children:"Previous Tax Years Accumulated Depreciation"}),e.jsx(o,{className:"whitespace-normal",children:"Total Depreciation"}),e.jsx(o,{className:"whitespace-normal",children:"Net Book Value"})]})]}),e.jsx(X,{children:u?.depreciationReport&&e.jsxs(e.Fragment,{children:[u.depreciationReport.categories.map((i,m)=>e.jsxs(d.Fragment,{children:[e.jsxs(D,{className:"font-bold",children:[e.jsx(t,{children:`Category ${m+1}`}),e.jsx(t,{colSpan:2,children:i.category.name}),e.jsx(t,{colSpan:3}),e.jsxs(t,{children:[n(i.category.percentage,0),"%"]}),e.jsx(t,{colSpan:5})]}),i.records.sort((h,E)=>h.purchaseDate.localeCompare(E.purchaseDate)).map(h=>e.jsx(W,{record:h},h.id)),e.jsx(g,{data:i.summary,groupName:i.category.name})]},i.id)),e.jsx(g,{data:u.depreciationReport.summary})]})})]})})};export{re as DepreciationReport,te as getDepreciationReportHref};
1
+ import{j as e,ds as D,dw as t,Y as y,cV as n,D as N,eQ as v,d0 as T,r as d,u as w,d3 as A,ao as I,ap as O,B as S,d2 as P,ar as L,k as M,dk as U,l as V,a4 as f,a5 as C,a6 as R,a7 as q,aQ as B,a9 as F,aO as k,aC as Q,F as $,U as _,a as z,c as H,w as G,dq as J,dr as K,dt as o,dv as W,eR as X}from"./index-CN2818Wt.js";const Z=({record:a})=>{const s=N(v,a);return e.jsxs(D,{children:[e.jsx(t,{children:a.description}),e.jsx(t,{children:y(new Date(a.purchaseDate),"dd/MM/yyyy")}),e.jsx(t,{children:a.activationDate?y(new Date(a.activationDate),"dd/MM/yyyy"):void 0}),e.jsx(t,{children:s.originalCost?n(s.originalCost,0):void 0}),e.jsx(t,{children:s.reportYearDelta?n(s.reportYearDelta,0):void 0}),e.jsx(t,{children:n(s.totalDepreciableCosts,0)}),e.jsxs(t,{children:[n(a.statutoryDepreciationRate,0),"%"]}),e.jsx(t,{children:a.claimedDepreciationRate?`${n(a.claimedDepreciationRate,1)}%`:"-"}),e.jsx(t,{children:s.reportYearClaimedDepreciation?n(s.reportYearClaimedDepreciation,0):"-"}),e.jsx(t,{children:s.pastYearsAccumulatedDepreciation?n(s.pastYearsAccumulatedDepreciation,0):"-"}),e.jsx(t,{children:s.totalDepreciation?n(s.totalDepreciation,0):"-"}),e.jsx(t,{children:s.netValue?n(s.netValue,0):"-"})]})};function Y(a){return!a||T(a)?null:encodeURIComponent(JSON.stringify(a))}const b="depreciationReportFilters";function ee({filter:a,setFilter:s,close:r}){const p=M({defaultValues:{...a}}),{control:c,handleSubmit:x}=p,{selectableFinancialEntities:u,fetching:l}=U(),j=i=>{s({...i,year:Number(i.year)}),r()};return e.jsx(V,{...p,children:e.jsxs("form",{onSubmit:x(j),className:"space-y-4",children:[e.jsx(f,{name:"year",control:c,rules:{required:"Year is required",validate:i=>{const m=Number(i);return Number.isNaN(m)||m<2e3||m>2100?"Invalid year":!0}},render:({field:i})=>e.jsxs(C,{children:[e.jsx(R,{children:"Year"}),e.jsx(q,{children:e.jsx(B,{...i,hideControls:!0,decimalScale:0})}),e.jsx(F,{})]})}),e.jsx(f,{name:"financialEntityId",defaultValue:a?.financialEntityId,control:c,render:({field:i})=>e.jsxs(C,{children:[e.jsx(R,{children:"Owner"}),e.jsx(k,{...i,data:u,value:i.value??void 0,disabled:l,placeholder:"Select a financial entity",formPart:!0}),e.jsx(F,{})]})}),e.jsx(Q,{children:e.jsx(S,{type:"submit",disabled:l,children:"Filter"})})]})})}function ae({filter:a,setFilter:s}){const[r,p]=d.useState(!1),{get:c,set:x}=w();d.useEffect(()=>{const l=Y(a),j=c(b);l!==j&&x(b,l)},[a,c,x]);const u=d.useCallback(l=>{A(l,a)||s(l)},[a,s]);return e.jsxs(I,{open:r,onOpenChange:p,children:[e.jsx(O,{asChild:!0,children:e.jsx(S,{variant:"outline",size:"icon",children:e.jsx(P,{size:20})})}),e.jsx(L,{className:"sm:max-w-[425px]",children:e.jsx(ee,{filter:a,setFilter:u,close:()=>p(!1)})})]})}const g=({data:a,groupName:s})=>{const r=N(v,a);return e.jsxs(D,{className:"font-bold border-b border-black",children:[e.jsx(t,{children:s?"Group Total":"Overall Total"}),e.jsx(t,{colSpan:2,children:s}),e.jsx(t,{children:r.originalCost?n(r.originalCost,0):void 0}),e.jsx(t,{children:r.reportYearDelta?n(r.reportYearDelta,0):void 0}),e.jsx(t,{children:r.totalDepreciableCosts?n(r.totalDepreciableCosts,0):void 0}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{children:r.reportYearClaimedDepreciation?n(r.reportYearClaimedDepreciation,0):void 0}),e.jsx(t,{children:r.pastYearsAccumulatedDepreciation?n(r.pastYearsAccumulatedDepreciation,0):void 0}),e.jsx(t,{children:r.totalDepreciation?n(r.totalDepreciation,0):void 0}),e.jsx(t,{children:r.netValue?n(r.netValue,0):void 0})]})};function te(a){const s=new URLSearchParams,r=Y(a);return r&&s.append(b,r),`/reports/depreciation${s.size>0?`?${s}`:""}`}const re=()=>{const{setFiltersContext:a}=d.useContext($),{userContext:s}=d.useContext(_),{get:r}=w(),p=d.useMemo(()=>{const i={financialEntityId:s?.context.adminBusinessId,year:new Date().getFullYear()},m=r(b);if(m)try{return JSON.parse(decodeURIComponent(m))}catch(h){console.error("Failed to parse depreciation report filters from URL",h)}return i},[s?.context.adminBusinessId]),[c,x]=d.useState(p),[{data:u,fetching:l}]=z({query:X,variables:{filters:c}});d.useEffect(()=>{a(e.jsx("div",{className:"flex flex-row gap-x-5",children:e.jsx(ae,{filter:c,setFilter:x})}))},[c,a,x]);const j=d.useMemo(()=>`Depreciation Report for ${c.year}`,[c.year]);return e.jsx(H,{title:"Depreciation Report",description:j,children:l?e.jsx(G,{}):e.jsxs(J,{children:[e.jsxs(K,{children:[e.jsxs(D,{className:"font-bold text-xl",children:[e.jsx(o,{colSpan:6,className:"text-center border-x",children:"List of Assets and Costs"}),e.jsx(o,{colSpan:5,className:"text-center border-x",children:"Depreciation"}),e.jsx(o,{className:"text-center border-x",children:"Remaining"})]}),e.jsxs(D,{className:"border-b border-black",children:[e.jsx(o,{className:"whitespace-normal",children:"Assets List and Descriptions"}),e.jsx(o,{className:"whitespace-normal",children:"Date of Purchase"}),e.jsx(o,{className:"whitespace-normal",children:"Activation Date"}),e.jsx(o,{className:"whitespace-normal",children:"Original Cost"}),e.jsx(o,{className:"whitespace-normal",children:"Changes During the Year"}),e.jsx(o,{className:"whitespace-normal",children:"Total Depreciable Assets"}),e.jsx(o,{className:"whitespace-normal",children:"Statutory Depreciation Rate"}),e.jsx(o,{className:"whitespace-normal",children:"Claimed Depreciation Rate"}),e.jsx(o,{className:"whitespace-normal",children:"Depreciation Claimed This Year"}),e.jsx(o,{className:"whitespace-normal",children:"Previous Tax Years Accumulated Depreciation"}),e.jsx(o,{className:"whitespace-normal",children:"Total Depreciation"}),e.jsx(o,{className:"whitespace-normal",children:"Net Book Value"})]})]}),e.jsx(W,{children:u?.depreciationReport&&e.jsxs(e.Fragment,{children:[u.depreciationReport.categories.map((i,m)=>e.jsxs(d.Fragment,{children:[e.jsxs(D,{className:"font-bold",children:[e.jsx(t,{children:`Category ${m+1}`}),e.jsx(t,{colSpan:2,children:i.category.name}),e.jsx(t,{colSpan:3}),e.jsxs(t,{children:[n(i.category.percentage,0),"%"]}),e.jsx(t,{colSpan:5})]}),i.records.sort((h,E)=>h.purchaseDate.localeCompare(E.purchaseDate)).map(h=>e.jsx(Z,{record:h},h.id)),e.jsx(g,{data:i.summary,groupName:i.category.name})]},i.id)),e.jsx(g,{data:u.depreciationReport.summary})]})})]})})};export{re as DepreciationReport,te as getDepreciationReportHref};
@@ -0,0 +1 @@
1
+ import{r as h,j as e,d1 as u,eL as p,B as y,d2 as g,bp as D,F as P,a as R,c as w,L as E,R as v,eM as F}from"./index-CN2818Wt.js";import{d as C}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{R as d}from"./report-commentary-row-Bpvvtwpd.js";function A({year:l,setYear:m,referenceYears:o,setReferenceYears:j}){const[c,x]=h.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(u,{opened:c,onClose:()=>x(!1),withCloseButton:!0,content:e.jsxs(e.Fragment,{children:[e.jsx(p,{label:"Change report year",value:new Date(l,0,1),onChange:n=>n&&m(n?.getFullYear()),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date}),e.jsx(p,{type:"multiple",label:"Pick reference years",value:o?.map(n=>new Date(n,0,1)),onChange:n=>j(n.map(i=>i.getFullYear()).filter(i=>l!==i)),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date})]})}),e.jsx(y,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>x(!0),children:e.jsx(g,{className:"size-5"})})]})}const b=()=>{const{year:l}=D(),{setFiltersContext:m}=h.useContext(P),[o,j]=h.useState(l?Number(l):new Date().getFullYear()),[c,x]=h.useState([]),[{data:n,fetching:i}]=R({query:C(F),variables:{reportYear:o,referenceYears:c}});h.useEffect(()=>{m(e.jsx("div",{className:"flex flex-row gap-2",children:e.jsx(A,{year:o,setYear:j,referenceYears:c,setReferenceYears:x})}))},[o,i,m,c,x]);const f=n?.profitAndLossReport,a=f?.report,s=f?.reference??[];return e.jsx(w,{title:"Profit and Loss Report",children:i?e.jsx(E,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsx("div",{className:"flex flex-col gap-4",children:a&&e.jsxs(v,{highlightOnHover:!0,fontSize:"md",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{}),e.jsx("th",{children:o},o),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.year},t.year))]})}),e.jsxs("tbody",{children:[e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("th",{children:"Revenue"}),e.jsx("th",{children:a.revenue.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("th",{children:r.revenue.amount.formatted},r.year))]}),commentaryData:a.revenue}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Cost of Sales"}),e.jsx("td",{children:a.costOfSales.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("td",{children:r.costOfSales.amount.formatted},r.year))]}),commentaryData:a.costOfSales}),e.jsxs("tr",{children:[e.jsx("th",{children:"Gross Profit"}),e.jsx("th",{children:a.grossProfit.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.grossProfit.formatted},t.year))]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"R&D Expenses"}),e.jsx("td",{children:a.researchAndDevelopmentExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("td",{children:r.researchAndDevelopmentExpenses.amount.formatted},r.year))]}),commentaryData:a.researchAndDevelopmentExpenses}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Marketing Expenses"}),e.jsx("td",{children:a.marketingExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("td",{children:r.marketingExpenses.amount.formatted},r.year))]}),commentaryData:a.marketingExpenses}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Management and General Expenses"}),e.jsx("td",{children:a.managementAndGeneralExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("td",{children:r.managementAndGeneralExpenses.amount.formatted},r.year))]}),commentaryData:a.managementAndGeneralExpenses}),e.jsxs("tr",{children:[e.jsx("th",{children:"Operating Profit"}),e.jsx("th",{children:a.operatingProfit.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.operatingProfit.formatted},t.year))]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Financial Expenses"}),e.jsx("td",{children:a.financialExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("td",{children:r.financialExpenses.amount.formatted},r.year))]}),commentaryData:a.financialExpenses}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Other Income"}),e.jsx("td",{children:a.otherIncome.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("td",{children:r.otherIncome.amount.formatted},r.year))]}),commentaryData:a.otherIncome}),e.jsxs("tr",{children:[e.jsx("th",{children:"Profit Before Tax"}),e.jsx("th",{children:a.profitBeforeTax.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.profitBeforeTax.formatted},t.year))]}),e.jsxs("tr",{children:[e.jsx("td",{children:"Tax"}),e.jsx("td",{children:a.tax.formatted}),e.jsx("td",{}),s.map(t=>e.jsx("td",{children:t.tax.formatted},t.year))]})]}),e.jsx("tfoot",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Net Profit"}),e.jsx("th",{children:a.netProfit.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.netProfit.formatted},t.year))]})})]})})})};export{b as ProfitAndLossReport};
@@ -1,6 +1,6 @@
1
- import{D as q,r as d,j as e,X as p,B as g,P as w,b as y,C as F,ek as G,el as H,em as _,en as Q,cS as D,cm as M,eo as E,ep as R,eq as T,er as $,es as J,ca as V,et as X,eu as Y,ev as Z,ew as K,a as z,t as W,ex as ee,T as te,ey as se,u as O,ae as k,cZ as ae,c_ as ne,c$ as re,V as oe,dh as ie,bO as A,bP as S,ez as N,db as ce,H as I,d0 as le,F as de,c as he,L as xe,E as ue,I as me,M as pe,eA as ge}from"./index-DOrujuWI.js";import{d as B}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{M as je}from"./index-BDsbL_Kg.js";import{c as fe}from"./charges-filters-CpNNXLPU.js";import"./Checkbox-Bu7lbyW3.js";import"./sub-Daf_8shG.js";import"./subMonths-DIZWyi5T.js";/**
1
+ import{V as q,r as d,j as e,D as p,B as g,P as w,b as y,C as F,en as G,eo as H,ep as _,eq as J,cV as D,co as M,J as E,K as R,er as T,es as Q,et as Y,R as V,eu as $,ev as K,ew as W,ex as X,a as z,t as Z,ey as ee,T as te,ez as se,u as k,U as O,d0 as ae,d1 as ne,d2 as re,k as oe,dk as ie,bR as A,bS as S,eA as N,de as ce,Y as I,d3 as le,F as de,c as he,L as xe,E as ue,I as me,M as pe,eB as ge}from"./index-CN2818Wt.js";import{d as B}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{M as je}from"./index-C0OGGVXE.js";import{c as fe}from"./charges-filters-r7FjeZLc.js";import"./Checkbox-CpANMiXr.js";import"./sub-C2zifPY5.js";import"./subMonths-uUfFviD2.js";/**
2
2
  * @license lucide-react v0.546.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const ve=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["rect",{width:"4",height:"6",x:"2",y:"12",rx:"2",key:"jm304g"}],["path",{d:"M10 12h2v6",key:"12zw74"}],["path",{d:"M10 18h4",key:"1ulq68"}]],we=q("file-digit",ve),ye=({data:a,setEditCharge:c,setInsertDocument:l,setMatchDocuments:r,toggleMergeCharge:o,mergeSelectedCharges:n})=>{const s=p(G,a),[t,i]=d.useState(!0);return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-lg font-semibold whitespace-nowrap flex flex-row gap-4",children:[e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>i(h=>!h),children:t?e.jsx(w,{className:"size-5"}):e.jsx(y,{className:"size-5"})}),"Business Trips"]}),t&&s&&e.jsx(F,{setEditChargeId:c,setInsertDocument:l,setMatchDocuments:r,data:s.businessTrips,isAllOpened:!1,toggleMergeCharge:o,mergeSelectedCharges:n})]})};function P({data:a}){const{chargeId:c,chargeAccountantStatus:l}=p(H,a),{updateChargeAccountantApproval:r}=_();return e.jsx("td",{children:e.jsx(Q,{value:l??void 0,onChange:o=>r({chargeId:c,status:o})})})}const be=({data:a,toggleMergeCharge:c,mergeSelectedCharges:l,cumulativeVat:r,cumulativeAmount:o})=>{const[n,s]=d.useState(!1),t=p($,a);return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"bg-gray-100",children:[e.jsxs("td",{className:"flex flex-col gap-1",children:[t.business?.name,t.vatNumber&&e.jsx("span",{style:{fontSize:"10px",color:"darkGray"},children:t.vatNumber})]}),e.jsx("td",{children:t.image&&e.jsx("a",{href:t.image,target:"_blank",rel:"noreferrer",children:e.jsx("img",{alt:"missing img",src:t.image,height:80,width:80})})}),e.jsx("td",{children:t.documentSerial}),e.jsx("td",{children:t.documentDate}),e.jsx("td",{children:t.chargeDate}),e.jsx("td",{className:"whitespace-nowrap",children:t.amount.formatted}),e.jsx("td",{className:"whitespace-nowrap",children:t.localAmount?.formatted}),e.jsx("td",{className:"whitespace-nowrap",children:t.localVat?.formatted}),e.jsx("td",{className:"whitespace-nowrap",children:t.localVatAfterDeduction?.formatted}),e.jsx("td",{className:"whitespace-nowrap",children:t.foreignVatAfterDeduction?.formatted}),e.jsx("td",{className:"whitespace-nowrap",children:t.roundedLocalVatAfterDeduction?.formatted}),e.jsxs("td",{className:"whitespace-nowrap",children:["₪ ",D(r,0)]}),e.jsxs("td",{className:"whitespace-nowrap",children:["₪ ",D(o,0)]}),e.jsx(P,{data:t}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx(M,{toggleExpansion:s,isExpanded:n})})}),e.jsx("td",{children:e.jsx(E,{toggleMergeSelected:()=>c(t.chargeId),mergeSelected:l.includes(t.chargeId)})})]}),n&&e.jsx("tr",{children:e.jsx("td",{colSpan:17,children:e.jsx(R,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:e.jsx(T,{chargeID:t.chargeId,fetching:!!t})})})})]})},Ce=({data:a,toggleMergeCharge:c,mergeSelectedCharges:l})=>{const{expenses:r}=p(J,a)??{expenses:[]},[o,n]=d.useState(!0);let s=0,t=0;return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-lg font-semibold whitespace-nowrap flex flex-row gap-4",children:[e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>n(i=>!i),children:o?e.jsx(w,{className:"size-5"}):e.jsx(y,{className:"size-5"})}),"Expenses"]}),o&&e.jsxs(V,{highlightOnHover:!0,children:[e.jsx("thead",{style:{position:"sticky",top:0,zIndex:20},children:e.jsxs("tr",{className:"bg-gray-300",children:[e.jsx("th",{children:"Business"}),e.jsx("th",{children:"Invoice"}),e.jsx("th",{children:"Invoice Serial#"}),e.jsx("th",{children:"Invoice Date"}),e.jsx("th",{children:"Transaction Date"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Amount ₪"}),e.jsx("th",{children:"VAT"}),e.jsx("th",{children:"VAT ₪"}),e.jsx("th",{children:"Actual VAT"}),e.jsx("th",{children:"Rounded VAT"}),e.jsx("th",{children:"Cumulative VAT"}),e.jsx("th",{children:"Amount without VAT ₪"}),e.jsx("th",{children:"Cumulative Amount without VAT ₪"}),e.jsx("th",{children:"Accountant Approval"}),e.jsx("th",{colSpan:2,children:"Edit"})]})}),e.jsx("tbody",{children:r.map((i,h)=>{s+=i.taxReducedLocalAmount?.raw??0;const m=s;t+=i.roundedLocalVatAfterDeduction?.raw??0;const x=t;return e.jsx(be,{data:i,toggleMergeCharge:c,mergeSelectedCharges:l,cumulativeVat:x,cumulativeAmount:m},h)})})]})]})},De=({data:a,toggleMergeCharge:c,mergeSelectedCharges:l,cumulativeAmount:r})=>{const[o,n]=d.useState(!1),s=p(X,a);return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"bg-gray-100",children:[e.jsxs("td",{className:"flex flex-col gap-1",children:[s.business?.name,s.vatNumber&&e.jsx("span",{style:{fontSize:"10px",color:"darkGray"},children:s.vatNumber})]}),e.jsx("td",{children:s.image&&e.jsx("a",{href:s.image,target:"_blank",rel:"noreferrer",children:e.jsx("img",{alt:"missing img",src:s.image,height:80,width:80})})}),e.jsx("td",{children:s.documentSerial}),e.jsx("td",{children:s.documentDate}),e.jsx("td",{children:s.chargeDate}),e.jsx("td",{children:s.taxReducedForeignAmount?.formatted}),e.jsx("td",{children:s.taxReducedLocalAmount?.formatted}),e.jsx("td",{children:"₪ "+D(r,0)}),e.jsx(P,{data:s}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx(M,{toggleExpansion:n,isExpanded:o})})}),e.jsx("td",{children:e.jsx(E,{toggleMergeSelected:()=>c(s.chargeId),mergeSelected:l.includes(s.chargeId)})})]}),o&&e.jsx("tr",{children:e.jsx("td",{colSpan:11,children:e.jsx(R,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:e.jsx(T,{chargeID:s.chargeId,fetching:!!s})})})})]})},Ne=({data:a,toggleMergeCharge:c,mergeSelectedCharges:l})=>{const{income:r}=p(Y,a)??{income:[]},[o,n]=d.useState(!0);let s=0;return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-lg font-semibold whitespace-nowrap flex flex-row gap-4",children:[e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>n(t=>!t),children:o?e.jsx(w,{className:"size-5"}):e.jsx(y,{className:"size-5"})}),"Income"]}),o&&e.jsxs(V,{highlightOnHover:!0,children:[e.jsx("thead",{style:{position:"sticky",top:0,zIndex:20},children:e.jsxs("tr",{className:"bg-gray-300",children:[e.jsx("th",{children:"Business"}),e.jsx("th",{children:"Invoice"}),e.jsx("th",{children:"Invoice Serial#"}),e.jsx("th",{children:"Invoice Date"}),e.jsx("th",{children:"Transaction Date"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Amount ₪"}),e.jsx("th",{children:"Cumulative Amount ₪"}),e.jsx("th",{children:"Accountant Approval"}),e.jsx("th",{colSpan:2,children:"Edit"})]})}),e.jsx("tbody",{children:r.map((t,i)=>{s+=t.taxReducedLocalAmount?.raw??0;const h=s;return e.jsx(De,{data:t,toggleMergeCharge:c,mergeSelectedCharges:l,cumulativeAmount:h},i)})})]})]})},Fe=({data:a,setEditCharge:c,setInsertDocument:l,setMatchDocuments:r,toggleMergeCharge:o,mergeSelectedCharges:n})=>{const s=p(Z,a),[t,i]=d.useState(!0);return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-lg font-semibold whitespace-nowrap flex flex-row gap-4",children:[e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>i(h=>!h),children:t?e.jsx(w,{className:"size-5"}):e.jsx(y,{className:"size-5"})}),"Misc Charges (which are not on the above tables)"]}),t&&s&&e.jsx(F,{setEditChargeId:c,setInsertDocument:l,setMatchDocuments:r,data:s.differentMonthDoc,isAllOpened:!1,toggleMergeCharge:o,mergeSelectedCharges:n})]})},Ie=({data:a,setEditCharge:c,setInsertDocument:l,setMatchDocuments:r,toggleMergeCharge:o,mergeSelectedCharges:n})=>{const s=p(K,a),[t,i]=d.useState(!0);return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-lg font-semibold whitespace-nowrap flex flex-row gap-4",children:[e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>i(h=>!h),children:t?e.jsx(w,{className:"size-5"}):e.jsx(y,{className:"size-5"})}),"Missing Info"]}),t&&s&&e.jsx(F,{setEditChargeId:c,setInsertDocument:l,setMatchDocuments:r,data:s.missingInfo,isAllOpened:!1,toggleMergeCharge:o,mergeSelectedCharges:n})]})},Ae=({filter:{monthDate:a,financialEntityId:c},isLoading:l})=>{const[{data:r,fetching:o,error:n},s]=z({query:B(se),pause:!0,variables:{monthDate:a,financialEntityId:c}});return d.useEffect(()=>{if(n){const t="Error generating PCN874 file";console.error(`${t}: ${n}`),W.error("Error",{description:t,duration:5e3,closeButton:!0})}},[n]),d.useEffect(()=>{if(r){const t=new File([r.pcnFile.reportContent],"pcn874.txt",{type:"text/plain"});ee(t)}},[r]),e.jsx(te,{label:"Generate and Download PCN874 File",children:e.jsx(g,{disabled:o||l,variant:"outline",size:"icon",className:"size-7.5",onClick:s,children:e.jsx(we,{className:"size-5"})})})};function Se({filter:a,setFilter:c,closeModal:l}){const{control:r,handleSubmit:o,setValue:n}=oe({defaultValues:{...a}}),{selectableFinancialEntities:s,fetching:t}=ie(),i=x=>{c(x),l()};function h(){c(),l()}function m(x){const u=new Date(x.getFullYear(),x.getMonth(),15);n("monthDate",I(u,"yyyy-MM-dd"))}return e.jsxs(e.Fragment,{children:[t?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsxs("form",{onSubmit:o(i),children:[e.jsx(A,{name:"financialEntityId",control:r,defaultValue:void 0,render:({field:x,fieldState:u})=>e.jsx(S,{...x,data:s,value:x.value,disabled:t,label:"Financial Entities",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:u.error?.message})}),e.jsx(A,{name:"chargesType",control:r,defaultValue:a.chargesType,render:({field:x,fieldState:u})=>e.jsx(S,{...x,data:fe,value:x.value??N.All,label:"Charge Type",placeholder:"Filter income/expense",maxDropdownHeight:160,error:u.error?.message})}),e.jsx(ce,{defaultValue:a?.monthDate?new Date(a.monthDate):new Date,defaultDate:a?.monthDate?new Date(a.monthDate):new Date,onChange:m,popoverProps:{withinPortal:!0}}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Filter"}),e.jsx("button",{type:"button",className:"text-white bg-orange-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-orange-600 rounded-sm text-lg",onClick:h,children:"Clear"}),e.jsx("button",{type:"button",className:"text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:l,children:"Cancel"})]})]})]})}function Me({filter:a,setFilter:c}){const[l,r]=d.useState(!1),{get:o,set:n}=O(),{userContext:s}=d.useContext(k);function t(i){i||={financialEntityId:s?.context.adminBusinessId??a.financialEntityId,monthDate:I(new Date,"yyyy-MM-15")},le(i,a)||c(i)}return d.useEffect(()=>{const i=ae(a??{})?null:encodeURIComponent(JSON.stringify(a)),h=o("vatMonthlyReportFilters");i!==h&&n("vatMonthlyReportFilters",i)},[a,o,n]),e.jsxs(e.Fragment,{children:[e.jsx(ne,{opened:l,onClose:()=>r(!1),content:e.jsx(Se,{filter:a,setFilter:t,closeModal:()=>r(!1)})}),e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>r(!0),children:e.jsx(re,{className:"size-5"})})]})}const Be=()=>{const{get:a}=O(),{setFiltersContext:c}=d.useContext(de),{userContext:l}=d.useContext(k),[r,o]=d.useState(a("vatMonthlyReportFilters")?JSON.parse(decodeURIComponent(a("vatMonthlyReportFilters"))):{financialEntityId:l?.context.adminBusinessId??"",monthDate:I(new Date,"yyyy-MM-15")}),[n,s]=d.useState([]),[t,i]=d.useState(void 0),[h,m]=d.useState(void 0),[x,u]=d.useState(void 0),[{data:j,fetching:b}]=z({query:B(ge),variables:{filters:r}}),f=d.useCallback(v=>{n.includes(v)?s(n.filter(U=>U!==v)):s([...n,v])},[n]);function L(){s([])}d.useEffect(()=>{c(e.jsxs("div",{className:"flex flex-row gap-2",children:[e.jsx(Ae,{filter:r,isLoading:b}),e.jsx(Me,{filter:{...r},setFilter:o}),e.jsx(je,{selected:n.map(v=>({id:v,onChange:()=>{}})),resetMerge:L})]}))},[j,r,b,c,n]);const C=d.useMemo(()=>new Set(n),[n]);return e.jsx(he,{title:"VAT Monthly Report",children:b?e.jsx(xe,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs("div",{className:"flex flex-col gap-4",children:[r.chargesType!==N.Expense&&e.jsx(Ne,{data:j?.vatReport,toggleMergeCharge:f,mergeSelectedCharges:n}),r.chargesType!==N.Income&&e.jsx(Ce,{data:j?.vatReport,toggleMergeCharge:f,mergeSelectedCharges:n}),e.jsx(Ie,{data:j?.vatReport,setEditCharge:u,setInsertDocument:i,setMatchDocuments:m,toggleMergeCharge:f,mergeSelectedCharges:C}),e.jsx(ye,{data:j?.vatReport,setEditCharge:u,setInsertDocument:i,setMatchDocuments:m,toggleMergeCharge:f,mergeSelectedCharges:C}),e.jsx(Fe,{data:j?.vatReport,setEditCharge:u,setInsertDocument:i,setMatchDocuments:m,toggleMergeCharge:f,mergeSelectedCharges:C}),x&&e.jsx(ue,{chargeId:x.id,close:()=>u(void 0)}),t&&e.jsx(me,{chargeId:t.id,close:()=>i(void 0)}),h&&e.jsx(pe,{chargeId:h.id,ownerId:h.ownerId,setMatchDocuments:()=>m(void 0)})]})})};export{Be as VatMonthlyReport};
6
+ */const ve=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["rect",{width:"4",height:"6",x:"2",y:"12",rx:"2",key:"jm304g"}],["path",{d:"M10 12h2v6",key:"12zw74"}],["path",{d:"M10 18h4",key:"1ulq68"}]],we=q("file-digit",ve),ye=({data:a,setEditCharge:c,setInsertDocument:l,setMatchDocuments:r,toggleMergeCharge:o,mergeSelectedCharges:n})=>{const s=p(G,a),[t,i]=d.useState(!0);return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-lg font-semibold whitespace-nowrap flex flex-row gap-4",children:[e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>i(h=>!h),children:t?e.jsx(w,{className:"size-5"}):e.jsx(y,{className:"size-5"})}),"Business Trips"]}),t&&s&&e.jsx(F,{setEditChargeId:c,setInsertDocument:l,setMatchDocuments:r,data:s.businessTrips,isAllOpened:!1,toggleMergeCharge:o,mergeSelectedCharges:n})]})};function P({data:a}){const{chargeId:c,chargeAccountantStatus:l}=p(H,a),{updateChargeAccountantApproval:r}=_();return e.jsx("td",{children:e.jsx(J,{value:l??void 0,onChange:o=>r({chargeId:c,status:o})})})}const be=({data:a,toggleMergeCharge:c,mergeSelectedCharges:l,cumulativeVat:r,cumulativeAmount:o})=>{const[n,s]=d.useState(!1),t=p(Q,a);return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"bg-gray-100",children:[e.jsxs("td",{className:"flex flex-col gap-1",children:[t.business?.name,t.vatNumber&&e.jsx("span",{style:{fontSize:"10px",color:"darkGray"},children:t.vatNumber})]}),e.jsx("td",{children:t.image&&e.jsx("a",{href:t.image,target:"_blank",rel:"noreferrer",children:e.jsx("img",{alt:"missing img",src:t.image,height:80,width:80})})}),e.jsx("td",{children:t.documentSerial}),e.jsx("td",{children:t.documentDate}),e.jsx("td",{children:t.chargeDate}),e.jsx("td",{className:"whitespace-nowrap",children:t.amount.formatted}),e.jsx("td",{className:"whitespace-nowrap",children:t.localAmount?.formatted}),e.jsx("td",{className:"whitespace-nowrap",children:t.localVat?.formatted}),e.jsx("td",{className:"whitespace-nowrap",children:t.localVatAfterDeduction?.formatted}),e.jsx("td",{className:"whitespace-nowrap",children:t.foreignVatAfterDeduction?.formatted}),e.jsx("td",{className:"whitespace-nowrap",children:t.roundedLocalVatAfterDeduction?.formatted}),e.jsxs("td",{className:"whitespace-nowrap",children:["₪ ",D(r,0)]}),e.jsxs("td",{className:"whitespace-nowrap",children:["₪ ",D(o,0)]}),e.jsx(P,{data:t}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx(M,{toggleExpansion:s,isExpanded:n})})}),e.jsx("td",{children:e.jsx(E,{toggleMergeSelected:()=>c(t.chargeId),mergeSelected:l.includes(t.chargeId)})})]}),n&&e.jsx("tr",{children:e.jsx("td",{colSpan:17,children:e.jsx(R,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:e.jsx(T,{chargeID:t.chargeId,fetching:!!t})})})})]})},Ce=({data:a,toggleMergeCharge:c,mergeSelectedCharges:l})=>{const{expenses:r}=p(Y,a)??{expenses:[]},[o,n]=d.useState(!0);let s=0,t=0;return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-lg font-semibold whitespace-nowrap flex flex-row gap-4",children:[e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>n(i=>!i),children:o?e.jsx(w,{className:"size-5"}):e.jsx(y,{className:"size-5"})}),"Expenses"]}),o&&e.jsxs(V,{highlightOnHover:!0,children:[e.jsx("thead",{style:{position:"sticky",top:0,zIndex:20},children:e.jsxs("tr",{className:"bg-gray-300",children:[e.jsx("th",{children:"Business"}),e.jsx("th",{children:"Invoice"}),e.jsx("th",{children:"Invoice Serial#"}),e.jsx("th",{children:"Invoice Date"}),e.jsx("th",{children:"Transaction Date"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Amount ₪"}),e.jsx("th",{children:"VAT"}),e.jsx("th",{children:"VAT ₪"}),e.jsx("th",{children:"Actual VAT"}),e.jsx("th",{children:"Rounded VAT"}),e.jsx("th",{children:"Cumulative VAT"}),e.jsx("th",{children:"Amount without VAT ₪"}),e.jsx("th",{children:"Cumulative Amount without VAT ₪"}),e.jsx("th",{children:"Accountant Approval"}),e.jsx("th",{colSpan:2,children:"Edit"})]})}),e.jsx("tbody",{children:r.map((i,h)=>{s+=i.taxReducedLocalAmount?.raw??0;const m=s;t+=i.roundedLocalVatAfterDeduction?.raw??0;const x=t;return e.jsx(be,{data:i,toggleMergeCharge:c,mergeSelectedCharges:l,cumulativeVat:x,cumulativeAmount:m},h)})})]})]})},De=({data:a,toggleMergeCharge:c,mergeSelectedCharges:l,cumulativeAmount:r})=>{const[o,n]=d.useState(!1),s=p($,a);return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"bg-gray-100",children:[e.jsxs("td",{className:"flex flex-col gap-1",children:[s.business?.name,s.vatNumber&&e.jsx("span",{style:{fontSize:"10px",color:"darkGray"},children:s.vatNumber})]}),e.jsx("td",{children:s.image&&e.jsx("a",{href:s.image,target:"_blank",rel:"noreferrer",children:e.jsx("img",{alt:"missing img",src:s.image,height:80,width:80})})}),e.jsx("td",{children:s.documentSerial}),e.jsx("td",{children:s.documentDate}),e.jsx("td",{children:s.chargeDate}),e.jsx("td",{children:s.taxReducedForeignAmount?.formatted}),e.jsx("td",{children:s.taxReducedLocalAmount?.formatted}),e.jsx("td",{children:"₪ "+D(r,0)}),e.jsx(P,{data:s}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx(M,{toggleExpansion:n,isExpanded:o})})}),e.jsx("td",{children:e.jsx(E,{toggleMergeSelected:()=>c(s.chargeId),mergeSelected:l.includes(s.chargeId)})})]}),o&&e.jsx("tr",{children:e.jsx("td",{colSpan:11,children:e.jsx(R,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:e.jsx(T,{chargeID:s.chargeId,fetching:!!s})})})})]})},Ne=({data:a,toggleMergeCharge:c,mergeSelectedCharges:l})=>{const{income:r}=p(K,a)??{income:[]},[o,n]=d.useState(!0);let s=0;return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-lg font-semibold whitespace-nowrap flex flex-row gap-4",children:[e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>n(t=>!t),children:o?e.jsx(w,{className:"size-5"}):e.jsx(y,{className:"size-5"})}),"Income"]}),o&&e.jsxs(V,{highlightOnHover:!0,children:[e.jsx("thead",{style:{position:"sticky",top:0,zIndex:20},children:e.jsxs("tr",{className:"bg-gray-300",children:[e.jsx("th",{children:"Business"}),e.jsx("th",{children:"Invoice"}),e.jsx("th",{children:"Invoice Serial#"}),e.jsx("th",{children:"Invoice Date"}),e.jsx("th",{children:"Transaction Date"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Amount ₪"}),e.jsx("th",{children:"Cumulative Amount ₪"}),e.jsx("th",{children:"Accountant Approval"}),e.jsx("th",{colSpan:2,children:"Edit"})]})}),e.jsx("tbody",{children:r.map((t,i)=>{s+=t.taxReducedLocalAmount?.raw??0;const h=s;return e.jsx(De,{data:t,toggleMergeCharge:c,mergeSelectedCharges:l,cumulativeAmount:h},i)})})]})]})},Fe=({data:a,setEditCharge:c,setInsertDocument:l,setMatchDocuments:r,toggleMergeCharge:o,mergeSelectedCharges:n})=>{const s=p(W,a),[t,i]=d.useState(!0);return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-lg font-semibold whitespace-nowrap flex flex-row gap-4",children:[e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>i(h=>!h),children:t?e.jsx(w,{className:"size-5"}):e.jsx(y,{className:"size-5"})}),"Misc Charges (which are not on the above tables)"]}),t&&s&&e.jsx(F,{setEditChargeId:c,setInsertDocument:l,setMatchDocuments:r,data:s.differentMonthDoc,isAllOpened:!1,toggleMergeCharge:o,mergeSelectedCharges:n})]})},Ie=({data:a,setEditCharge:c,setInsertDocument:l,setMatchDocuments:r,toggleMergeCharge:o,mergeSelectedCharges:n})=>{const s=p(X,a),[t,i]=d.useState(!0);return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-lg font-semibold whitespace-nowrap flex flex-row gap-4",children:[e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>i(h=>!h),children:t?e.jsx(w,{className:"size-5"}):e.jsx(y,{className:"size-5"})}),"Missing Info"]}),t&&s&&e.jsx(F,{setEditChargeId:c,setInsertDocument:l,setMatchDocuments:r,data:s.missingInfo,isAllOpened:!1,toggleMergeCharge:o,mergeSelectedCharges:n})]})},Ae=({filter:{monthDate:a,financialEntityId:c},isLoading:l})=>{const[{data:r,fetching:o,error:n},s]=z({query:B(se),pause:!0,variables:{monthDate:a,financialEntityId:c}});return d.useEffect(()=>{if(n){const t="Error generating PCN874 file";console.error(`${t}: ${n}`),Z.error("Error",{description:t,duration:5e3,closeButton:!0})}},[n]),d.useEffect(()=>{if(r){const t=new File([r.pcnFile.reportContent],"pcn874.txt",{type:"text/plain"});ee(t)}},[r]),e.jsx(te,{label:"Generate and Download PCN874 File",children:e.jsx(g,{disabled:o||l,variant:"outline",size:"icon",className:"size-7.5",onClick:s,children:e.jsx(we,{className:"size-5"})})})};function Se({filter:a,setFilter:c,closeModal:l}){const{control:r,handleSubmit:o,setValue:n}=oe({defaultValues:{...a}}),{selectableFinancialEntities:s,fetching:t}=ie(),i=x=>{c(x),l()};function h(){c(),l()}function m(x){const u=new Date(x.getFullYear(),x.getMonth(),15);n("monthDate",I(u,"yyyy-MM-dd"))}return e.jsxs(e.Fragment,{children:[t?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsxs("form",{onSubmit:o(i),children:[e.jsx(A,{name:"financialEntityId",control:r,defaultValue:void 0,render:({field:x,fieldState:u})=>e.jsx(S,{...x,data:s,value:x.value,disabled:t,label:"Financial Entities",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:u.error?.message})}),e.jsx(A,{name:"chargesType",control:r,defaultValue:a.chargesType,render:({field:x,fieldState:u})=>e.jsx(S,{...x,data:fe,value:x.value??N.All,label:"Charge Type",placeholder:"Filter income/expense",maxDropdownHeight:160,error:u.error?.message})}),e.jsx(ce,{defaultValue:a?.monthDate?new Date(a.monthDate):new Date,defaultDate:a?.monthDate?new Date(a.monthDate):new Date,onChange:m,popoverProps:{withinPortal:!0}}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Filter"}),e.jsx("button",{type:"button",className:"text-white bg-orange-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-orange-600 rounded-sm text-lg",onClick:h,children:"Clear"}),e.jsx("button",{type:"button",className:"text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:l,children:"Cancel"})]})]})]})}function Me({filter:a,setFilter:c}){const[l,r]=d.useState(!1),{get:o,set:n}=k(),{userContext:s}=d.useContext(O);function t(i){i||={financialEntityId:s?.context.adminBusinessId??a.financialEntityId,monthDate:I(new Date,"yyyy-MM-15")},le(i,a)||c(i)}return d.useEffect(()=>{const i=ae(a??{})?null:encodeURIComponent(JSON.stringify(a)),h=o("vatMonthlyReportFilters");i!==h&&n("vatMonthlyReportFilters",i)},[a,o,n]),e.jsxs(e.Fragment,{children:[e.jsx(ne,{opened:l,onClose:()=>r(!1),content:e.jsx(Se,{filter:a,setFilter:t,closeModal:()=>r(!1)})}),e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>r(!0),children:e.jsx(re,{className:"size-5"})})]})}const Be=()=>{const{get:a}=k(),{setFiltersContext:c}=d.useContext(de),{userContext:l}=d.useContext(O),[r,o]=d.useState(a("vatMonthlyReportFilters")?JSON.parse(decodeURIComponent(a("vatMonthlyReportFilters"))):{financialEntityId:l?.context.adminBusinessId??"",monthDate:I(new Date,"yyyy-MM-15")}),[n,s]=d.useState([]),[t,i]=d.useState(void 0),[h,m]=d.useState(void 0),[x,u]=d.useState(void 0),[{data:j,fetching:b}]=z({query:B(ge),variables:{filters:r}}),f=d.useCallback(v=>{n.includes(v)?s(n.filter(U=>U!==v)):s([...n,v])},[n]);function L(){s([])}d.useEffect(()=>{c(e.jsxs("div",{className:"flex flex-row gap-2",children:[e.jsx(Ae,{filter:r,isLoading:b}),e.jsx(Me,{filter:{...r},setFilter:o}),e.jsx(je,{selected:n.map(v=>({id:v,onChange:()=>{}})),resetMerge:L})]}))},[j,r,b,c,n]);const C=d.useMemo(()=>new Set(n),[n]);return e.jsx(he,{title:"VAT Monthly Report",children:b?e.jsx(xe,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs("div",{className:"flex flex-col gap-4",children:[r.chargesType!==N.Expense&&e.jsx(Ne,{data:j?.vatReport,toggleMergeCharge:f,mergeSelectedCharges:n}),r.chargesType!==N.Income&&e.jsx(Ce,{data:j?.vatReport,toggleMergeCharge:f,mergeSelectedCharges:n}),e.jsx(Ie,{data:j?.vatReport,setEditCharge:u,setInsertDocument:i,setMatchDocuments:m,toggleMergeCharge:f,mergeSelectedCharges:C}),e.jsx(ye,{data:j?.vatReport,setEditCharge:u,setInsertDocument:i,setMatchDocuments:m,toggleMergeCharge:f,mergeSelectedCharges:C}),e.jsx(Fe,{data:j?.vatReport,setEditCharge:u,setInsertDocument:i,setMatchDocuments:m,toggleMergeCharge:f,mergeSelectedCharges:C}),x&&e.jsx(ue,{chargeId:x.id,close:()=>u(void 0)}),t&&e.jsx(me,{chargeId:t.id,close:()=>i(void 0)}),h&&e.jsx(pe,{chargeId:h.id,ownerId:h.ownerId,setMatchDocuments:()=>m(void 0)})]})})};export{Be as VatMonthlyReport};