@accounter/client 0.0.8-alpha-20251029124401-d15137847e8450b1ecf3e3cfa6b68dda7239ca45 → 0.0.8-alpha-20251029124558-c1dac18cef0a90c88021bcb6e06319cc55ec33d9

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 (113) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/assets/{Checkbox-Cxbop3qM.js → Checkbox-w99PhJ6L.js} +2 -2
  3. package/dist/assets/{MultiSelect-D1XVjXLN.js → MultiSelect-9BbcXHjB.js} +1 -1
  4. package/dist/assets/{Pagination-DMimIHM4.js → Pagination-BVQu3Yj6.js} +1 -1
  5. package/dist/assets/{Progress-CP4jnh2x.js → Progress-BKRQuJXK.js} +1 -1
  6. package/dist/assets/{Table-DTU12O53.js → Table-CR8S5Pp5.js} +1 -1
  7. package/dist/assets/{Typography-IL0wuZeq.js → Typography-D1_XzAPj.js} +1 -1
  8. package/dist/assets/{YearPickerInput-CPL_XozD.js → YearPickerInput-dCiPlZqk.js} +1 -1
  9. package/dist/assets/{accordion-DKLV9b0H.js → accordion-QkFWsf0a.js} +1 -1
  10. package/dist/assets/{accountant-approvals-CdX2nUgB.js → accountant-approvals-AD_TNBTH.js} +1 -1
  11. package/dist/assets/{accounter-table-CeZ4q0re.js → accounter-table-CBigzB_s.js} +1 -1
  12. package/dist/assets/{addDays-sGeEkIxC.js → addDays-CjlJbHpj.js} +1 -1
  13. package/dist/assets/{all-charges-BJvp1ecZ.js → all-charges-BdHR-QjC.js} +1 -1
  14. package/dist/assets/{arrow-up-down-DkEXGAin.js → arrow-up-down-Cq3mRkaO.js} +1 -1
  15. package/dist/assets/{building-2-BcYhLAVP.js → building-2-BE02hpsM.js} +1 -1
  16. package/dist/assets/{business-CO7M6XNI.js → business-CX0D-23F.js} +17 -7
  17. package/dist/assets/business-extended-info-BRde-LSv.js +13 -0
  18. package/dist/assets/{business-header-BG2B-PcM.js → business-header-CMH3yBZc.js} +1 -1
  19. package/dist/assets/business-ledger-filters-DQ4D4mv8.js +1 -0
  20. package/dist/assets/business-ledger-single-BSeNj9f2.js +1 -0
  21. package/dist/assets/business-trip-CX-3yJmB.js +1 -0
  22. package/dist/assets/{charge-Bm0hPNT7.js → charge-BzCN_Szu.js} +1 -1
  23. package/dist/assets/{charges-filters-DjnsiGzC.js → charges-filters-C7YlWAFn.js} +1 -1
  24. package/dist/assets/{charges-ledger-validation-CoHDjCf2.js → charges-ledger-validation-DqM92cc-.js} +1 -1
  25. package/dist/assets/charges-table-BOnvwci9.js +62 -0
  26. package/dist/assets/{chart-SbwWAyei.js → chart-OVHXA3Uy.js} +1 -1
  27. package/dist/assets/{data-table-pagination-DtnUvTOC.js → data-table-pagination-BLbPHs4o.js} +1 -1
  28. package/dist/assets/download-csv-button-C5J9ow3I.js +1 -0
  29. package/dist/assets/{editable-business-trip-xFRu5fSA.js → editable-business-trip-Ito1rWaY.js} +1 -1
  30. package/dist/assets/{funnel-WdA7f2As.js → funnel-IYKnhWOy.js} +1 -1
  31. package/dist/assets/{index-BOhdfO95.js → index-2j4tFkfX.js} +1 -1
  32. package/dist/assets/{index-VzPCd0L-.js → index-4YPOH-A_.js} +2 -2
  33. package/dist/assets/index-B3W0RNqC.js +1 -0
  34. package/dist/assets/{index-Vq1FAgYe.js → index-BOmTn4-L.js} +1 -1
  35. package/dist/assets/{index-BaEmw40f.js → index-C8HkbFzQ.js} +1 -1
  36. package/dist/assets/{index-9JObwNSb.js → index-CP5LZIWs.js} +1 -1
  37. package/dist/assets/{index-Ct0AJEN9.js → index-CY5Ok8zP.js} +2 -2
  38. package/dist/assets/{index-DPvrbbz9.js → index-CcJvt1sI.js} +119 -119
  39. package/dist/assets/{index-BIdEjDD3.js → index-Cn-lknzD.js} +1 -1
  40. package/dist/assets/{index-Ey6XKYuP.js → index-CnlrBGcj.js} +2 -2
  41. package/dist/assets/{index-1loWF1jV.js → index-D1Hpe746.js} +1 -1
  42. package/dist/assets/{index-BxnmQCT9.js → index-D31j2-8X.js} +1 -1
  43. package/dist/assets/{index-mN2sZqiu.js → index-D68aCDMG.js} +7 -7
  44. package/dist/assets/index-DE0nwhFR.js +1 -0
  45. package/dist/assets/{index-CwbqTlM4.js → index-DGxxgGxy.js} +2 -2
  46. package/dist/assets/{index-W6Xv87pg.js → index-DKVhuSlP.js} +1 -1
  47. package/dist/assets/{index-DjQIiDMo.js → index-DeFWFAwx.js} +1 -1
  48. package/dist/assets/{index-Bw5hpWBz.js → index-DjPei962.js} +2 -2
  49. package/dist/assets/{index-CdAUtS2Q.js → index-Dvp0RPEc.js} +1 -1
  50. package/dist/assets/{index-CfsTscFv.js → index-a32atud-.js} +1 -1
  51. package/dist/assets/{index-CXH_lcpK.js → index-kSig9eXf.js} +2 -2
  52. package/dist/assets/index-ofME77ND.js +6 -0
  53. package/dist/assets/{index-Bm3ZL2dx.js → index-ofu4jqHf.js} +1 -1
  54. package/dist/assets/{index--LMZMPY_.js → index-qLJISPWb.js} +1 -1
  55. package/dist/assets/{index-p1BcqxXQ.js → index-smNUtwvf.js} +1 -1
  56. package/dist/assets/{index.es-C3XngPKv.js → index.es-D7_nzQqR.js} +1 -1
  57. package/dist/assets/{insert-business-trip-modal-BHY3QQup.js → insert-business-trip-modal-D08ePEzY.js} +2 -2
  58. package/dist/assets/issue-document-D2L9kG1u.js +1 -0
  59. package/dist/assets/{list-plus-ZvPwjqZn.js → list-plus-Cv8qnwZd.js} +1 -1
  60. package/dist/assets/{login-page-CsXdm3AZ.js → login-page-sUXp3XoV.js} +1 -1
  61. package/dist/assets/{match-document-modal-Cqimg0VE.js → match-document-modal-D2TgC0aR.js} +4 -4
  62. package/dist/assets/{missing-info-charges-DxLGt6Xs.js → missing-info-charges-BJnQHRZs.js} +1 -1
  63. package/dist/assets/{modal-Nvfe-DMu.js → modal-DOtlViK5.js} +1 -1
  64. package/dist/assets/{page-layout-SHFb6rY4.js → page-layout-BNHKLJFL.js} +1 -1
  65. package/dist/assets/{page-not-found-BZ6s-Q5n.js → page-not-found-j9vQhz-c.js} +1 -1
  66. package/dist/assets/{panel-top-open-C3Q9X7Tg.js → panel-top-open-DQ1wo5PZ.js} +1 -1
  67. package/dist/assets/{pencil-CPPx1BhC.js → pencil-BWTnh6hj.js} +1 -1
  68. package/dist/assets/{report-commentary-row-DpYgprQr.js → report-commentary-row-DBOCwi7X.js} +1 -1
  69. package/dist/assets/{save-D-W46u2J.js → save-DuIXDTLc.js} +1 -1
  70. package/dist/assets/{similar-transactions-modal-zQY2R-sr.js → similar-transactions-modal-DDVojjq0.js} +1 -1
  71. package/dist/assets/sub-CIKovQuv.js +1 -0
  72. package/dist/assets/subMonths-GbNm9rnx.js +1 -0
  73. package/dist/assets/{summary-DwX_dmjr.js → summary-BV3HUEgI.js} +1 -1
  74. package/dist/assets/{toggle-expansion-button-Bh24n-cz.js → toggle-expansion-button-Bdpb_YfG.js} +1 -1
  75. package/dist/assets/tooltip-Cy3vJ3fy.js +1 -0
  76. package/dist/assets/{use-url-query-COmN7DHP.js → use-url-query-D-GsTMWL.js} +1 -1
  77. package/dist/index.html +1 -1
  78. package/package.json +1 -1
  79. package/src/components/business/balance-section.tsx +26 -0
  80. package/src/components/business/index.tsx +31 -1
  81. package/src/components/business/ledger-section.tsx +49 -0
  82. package/src/components/business/transactions-section.tsx +24 -2
  83. package/src/components/{business-transactions → business-ledger}/business-extended-info.tsx +25 -27
  84. package/src/components/{business-transactions/business-transactions-filters.tsx → business-ledger/business-ledger-filters.tsx} +12 -12
  85. package/src/components/{business-transactions/business-transactions-single.tsx → business-ledger/business-ledger-single.tsx} +13 -13
  86. package/src/components/{business-transactions → business-ledger}/download-csv.tsx +25 -25
  87. package/src/components/{business-transactions → business-ledger}/index.tsx +15 -15
  88. package/src/components/charges/charge-extended-info.tsx +45 -4
  89. package/src/components/layout/sidelinks.tsx +2 -2
  90. package/src/components/ledger-table/columns.tsx +4 -4
  91. package/src/components/ledger-table/index.tsx +141 -181
  92. package/src/components/reports/conto/custom-node.tsx +1 -1
  93. package/src/components/reports/trial-balance-report/trial-balance-report-account.tsx +1 -1
  94. package/src/components/transactions-table/columns.tsx +9 -9
  95. package/src/components/transactions-table/index.tsx +45 -21
  96. package/src/gql/gql.ts +30 -12
  97. package/src/gql/graphql.ts +181 -406
  98. package/src/router/config.tsx +14 -14
  99. package/src/router/routes.ts +2 -2
  100. package/dist/assets/business-extended-info-MUfOmQ_B.js +0 -13
  101. package/dist/assets/business-transactions-filters-Cijy7ryl.js +0 -1
  102. package/dist/assets/business-transactions-single-DZqMwNkv.js +0 -1
  103. package/dist/assets/business-trip-C7G814AY.js +0 -1
  104. package/dist/assets/charges-table-C_4dY1Ic.js +0 -62
  105. package/dist/assets/download-csv-button-D9_6J2pA.js +0 -1
  106. package/dist/assets/index-Bx-qi8fd.js +0 -1
  107. package/dist/assets/index-D3-tv-Kb.js +0 -1
  108. package/dist/assets/index-DFgRsYAU.js +0 -6
  109. package/dist/assets/issue-document-BpzcqnRu.js +0 -1
  110. package/dist/assets/sub-7frHBT3Y.js +0 -1
  111. package/dist/assets/subMonths-CY79vHaS.js +0 -1
  112. package/dist/assets/tooltip-BaULIFLC.js +0 -1
  113. package/src/app.tsx +0 -108
@@ -1,2 +1,2 @@
1
- import{r as F,j as r,e as Q,u as q,gR as H,L as E,a8 as K,bm as $,B as U,G as X,bo as ee,bp as te,bs as ne,cI as O,x as k,gS as T,bt as se,F as oe,K as re,P as ie,W as le}from"./index-DPvrbbz9.js";import{u as W}from"./use-url-query-COmN7DHP.js";import{P as ae}from"./page-layout-SHFb6rY4.js";import{A as ce,a as fe,c as ue,b as he}from"./accordion-DKLV9b0H.js";import{P as de}from"./modal-Nvfe-DMu.js";import{F as pe}from"./funnel-WdA7f2As.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,Y=l+o-1,Z=h+a-1,J=(_+B)/2;let N;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 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,S=w-u;let b=w,C=S;for(;b<o&&C<a&&s(l+b,h+C);)b++,C++;if(t[u-f*Math.floor(u/f)]=b,B===1&&(N=V-u)>=1-M&&N<M&&b+t[f+N-f*Math.floor(N/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=S,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,S=w-u;let b=w,C=S;for(;b<o&&C<a&&s(Y-b,Z-C);)b++,C++;if(t[f+u-f*Math.floor(u/f)]=b,B===0&&(N=V-u)>=-M&&N<=M&&b+t[N-f*Math.floor(N/f)]>=o)if(M>0||b!==w){i[x++]=l+o-w,i[x++]=w,i[x++]=h+a-S,i[x++]=S,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*P(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=P;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}),G=({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(""),P=Array.from(xe.calcPatch(g,y)),j=[];let e=0;for(const[t,s,i]of P)if(j.length===0&&t>=17&&s<=25&&i.length===s-t){if(P.length===1)return p;continue}else e<t&&j.push([g.slice(e,t).join(""),G]),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(""),G]);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}]=q({query:H,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}=X({defaultValues:{...c}}),{selectableBusinesses:g,fetching:P}=ee(),j=e=>{m(e),D()};return r.jsxs(r.Fragment,{children:[P?r.jsx("div",{children:"Loading..."}):r.jsx("div",{}),r.jsxs("form",{onSubmit:p(j),children:[r.jsx(te,{name:"businessId",control:d,defaultValue:void 0,render:({field:e,fieldState:n})=>r.jsx(ne,{...e,data:g,value:e.value,disabled:P,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",k(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",k(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}=W(),{userContext:g}=F.useContext(K);function P(j){j||={businessId:g?.context.adminBusinessId??c.businessId,fromMonthDate:k(T(new Date),"yyyy-MM-15"),toMonthDate:k(new Date,"yyyy-MM-15")},se(j,c)||m(j)}return F.useEffect(()=>{const j=$(c??{})?null:encodeURIComponent(JSON.stringify(c)),e=p("validateReportsFilters");j!==e&&y("validateReportsFilters",j)},[c,p,y]),r.jsxs(r.Fragment,{children:[r.jsx(de,{opened:D,onClose:()=>d(!1),content:r.jsx(be,{filter:c,setFilter:P,closeModal:()=>d(!1)})}),r.jsx(U,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>d(!0),children:r.jsx(pe,{className:"size-5"})})]})}const Se=()=>{const{get:c}=W(),{setFiltersContext:m}=F.useContext(oe),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:k(T(new Date),"yyyy-MM-15"),toMonthDate:k(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(ae,{title:"Report Validations",children:r.jsx(ce,{type:"single",collapsible:!0,children:r.jsx(fe,{value:"pcn874",children:r.jsxs(re,{className:"p-4",children:[r.jsx(ue,{children:r.jsx(ie,{children:"Monthly VAT (PCN874)"})}),r.jsx(he,{children:r.jsx(le,{children:r.jsx(Me,{filter:d})})})]})})})})};export{Se as ValidateReportsScreen};
1
+ import{r as F,j as r,e as J,u as K,gX as Q,L as E,a8 as H,bo as X,B as U,G as $,bq as ee,br as te,bu as ne,cK as O,x as S,gY as T,bv as se,F as oe,K as re,P as ie,W as le}from"./index-CcJvt1sI.js";import{u as Y}from"./use-url-query-D-GsTMWL.js";import{P as ae}from"./page-layout-BNHKLJFL.js";import{A as ce,a as ue,c as fe,b as he}from"./accordion-QkFWsf0a.js";import{P as de}from"./modal-DOtlViK5.js";import{F as pe}from"./funnel-IYKnhWOy.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 V=o-a,_=o+a,B=_&1,W=l+o-1,Z=h+a-1,q=(_+B)/2;let N;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 f=I;f<=L;f+=2){const A=t[f-1-u*Math.floor((f-1)/u)],R=t[f+1-u*Math.floor((f+1)/u)],w=f===-M||f!==M&&A<R?R: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&&(N=V-f)>=1-M&&N<M&&b+t[u+N-u*Math.floor(N/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)],R=t[u+f+1-u*Math.floor((f+1)/u)],w=f===-M||f!==M&&A<R?R:A+1,k=w-f;let b=w,C=k;for(;b<o&&C<a&&s(W-b,Z-C);)b++,C++;if(t[u+f-u*Math.floor(f/u)]=b,B===0&&(N=V-f)>=-M&&N<=M&&b+t[N-u*Math.floor(N/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 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=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*P(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=P;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}),G=({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(""),P=Array.from(xe.calcPatch(g,y)),j=[];let e=0;for(const[t,s,i]of P)if(j.length===0&&t>=17&&s<=25&&i.length===s-t){if(P.length===1)return p;continue}else e<t&&j.push([g.slice(e,t).join(""),G]),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(""),G]);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(J,{className:"text-green-500"})]}),!!d.length&&d]})},Me=({filter:c})=>{const[{data:m,fetching:D,hasNext:d}]=K({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}=$({defaultValues:{...c}}),{selectableBusinesses:g,fetching:P}=ee(),j=e=>{m(e),D()};return r.jsxs(r.Fragment,{children:[P?r.jsx("div",{children:"Loading..."}):r.jsx("div",{}),r.jsxs("form",{onSubmit:p(j),children:[r.jsx(te,{name:"businessId",control:d,defaultValue:void 0,render:({field:e,fieldState:n})=>r.jsx(ne,{...e,data:g,value:e.value,disabled:P,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 P(j){j||={businessId:g?.context.adminBusinessId??c.businessId,fromMonthDate:S(T(new Date),"yyyy-MM-15"),toMonthDate:S(new Date,"yyyy-MM-15")},se(j,c)||m(j)}return F.useEffect(()=>{const j=X(c??{})?null:encodeURIComponent(JSON.stringify(c)),e=p("validateReportsFilters");j!==e&&y("validateReportsFilters",j)},[c,p,y]),r.jsxs(r.Fragment,{children:[r.jsx(de,{opened:D,onClose:()=>d(!1),content:r.jsx(be,{filter:c,setFilter:P,closeModal:()=>d(!1)})}),r.jsx(U,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>d(!0),children:r.jsx(pe,{className:"size-5"})})]})}const ke=()=>{const{get:c}=Y(),{setFiltersContext:m}=F.useContext(oe),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(T(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(ae,{title:"Report Validations",children:r.jsx(ce,{type:"single",collapsible:!0,children:r.jsx(ue,{value:"pcn874",children:r.jsxs(re,{className:"p-4",children:[r.jsx(fe,{children:r.jsx(ie,{children:"Monthly VAT (PCN874)"})}),r.jsx(he,{children:r.jsx(le,{children:r.jsx(Me,{filter:d})})})]})})})})};export{ke as ValidateReportsScreen};
@@ -0,0 +1 @@
1
+ import{u as x,bw as h,J as T,r,j as s,bp as g,bx as j,F as B,T as w,ah as C,L as b,au as v,by as y}from"./index-CcJvt1sI.js";import{E,P,C as L}from"./editable-business-trip-Ito1rWaY.js";import{I as F}from"./insert-business-trip-modal-D08ePEzY.js";import{P as I}from"./page-layout-BNHKLJFL.js";import{A as m}from"./summary-BV3HUEgI.js";import"./list-plus-Cv8qnwZd.js";import"./Table-CR8S5Pp5.js";import"./toggle-expansion-button-Bdpb_YfG.js";import"./panel-top-open-DQ1wo5PZ.js";import"./MultiSelect-9BbcXHjB.js";import"./similar-transactions-modal-DDVojjq0.js";import"./tooltip-Cy3vJ3fy.js";import"./create-event-handler-BiA-1lGu.js";const S=({data:u,isOpened:o,shouldValidate:l})=>{const e=T(j,u),[{data:i,fetching:a}]=x({pause:!l,query:h,variables:{id:e.id}}),d=r.useMemo(()=>l?i?.businessTrip&&(i.businessTrip.uncategorizedTransactions?.length||i?.businessTrip.summary?.errors?.length):!1,[i]),c=d||e?.accountantApproval!=="APPROVED";return s.jsxs(m.Item,{value:e.id,children:[s.jsx(m.Control,{children:s.jsx(g,{inline:!0,size:12,processing:a,disabled:!c,color:d?"red":"yellow",zIndex:"auto",children:e.name})}),s.jsx(m.Panel,{children:o&&s.jsx(E,{tripId:e.id,isExtended:!0},e.id)})]})},_=()=>{const{setFiltersContext:u}=r.useContext(B),[o,l]=r.useState([]),[e,i]=r.useState(!1),[{data:a,fetching:d}]=x({query:y});r.useEffect(()=>{if(!a?.allBusinessTrips?.length){l([]);return}const t=a.allBusinessTrips.sort((n,p)=>n.dates?.start&&p.dates?.start?n.dates.start<p.dates.start?1:-1:n.dates?.start?-1:p.dates?.start?1:n.name.toLocaleLowerCase()<p.name.toLocaleLowerCase()?-1:1);l(t)},[a?.allBusinessTrips]);const[c,f]=r.useState([]);return r.useEffect(()=>{u(s.jsxs("div",{className:"flex flex-row gap-x-5",children:[s.jsx(F,{}),s.jsx(w,{label:"Toggle business trips validation",children:s.jsxs("div",{className:"flex flex-row items-center gap-x-2",children:[s.jsx(C,{checked:e??!1,onCheckedChange:t=>i(t)}),s.jsx("span",{className:"text-sm text-gray-500",children:"Validate"})]})}),s.jsx(P,{filename:"business_trips"})]}))},[a,d,u,e]),s.jsx(I,{title:"Business Trips",description:"Manage business trips",children:o.length===0&&d?s.jsx(b,{className:"h-10 w-10 animate-spin mr-2 self-center"}):s.jsx(L,{children:s.jsx(m,{className:"w-full",multiple:!0,value:c,onChange:f,chevron:s.jsx(v,{size:"1rem"}),styles:{chevron:{"&[data-rotate]":{transform:"rotate(45deg)"}}},children:o?.map(t=>s.jsx(S,{data:o.find(n=>n.id===t.id),shouldValidate:e,isOpened:c.includes(t.id)},t.id))})})})};export{_ as BusinessTrips};
@@ -1,4 +1,4 @@
1
- import{v as it,r as m,cE as Nc,ab as V,cJ as kc,ac as ae,j as v,cH as vn,dq as It,dr as ge,ds as Ho,cK as Lc,dt as Vc,du as nn,dv as jc,bm as Fi,D as _r,aO as zr,bn as Fc,B as ee,z as $r,aP as Ur,aQ as Hr,G as Wo,bo as Bc,a8 as _c,bp as An,bq as Bi,br as _i,x as rn,ah as Go,b8 as Ko,bt as zc,g as qo,dw as $c,t as Pe,i as Xo,u as rr,dx as Uc,cQ as Hc,dy as Wc,d3 as Gc,d4 as Kc,d5 as qc,L as Yo,I as Wr,cT as Xc,cU as Yc,cV as Nn,cW as Zc,cX as zi,cY as Jc,cZ as $i,c_ as Zo,c$ as Jo,d0 as Qo,dz as Qc,dA as eu,dB as sn,dC as tu,H as nu,a4 as ru,V as iu,X as su,Y as ou,Z as au,_ as lu,a0 as cu,aT as uu,a6 as Ui,dD as du,e as hu,aw as fu,av as Hi,dE as pu,dF as gu,dG as Wi,bR as mu,aN as vu,F as yu,aj as bu,dH as Tu,dI as xu}from"./index-DPvrbbz9.js";import{u as ea}from"./use-url-query-COmN7DHP.js";import{T as yn}from"./tooltip-BaULIFLC.js";import{A as Gi}from"./arrow-up-down-DkEXGAin.js";import{D as Su}from"./download-csv-button-D9_6J2pA.js";import{B as wu}from"./business-extended-info-MUfOmQ_B.js";import{_ as Du,a as bn,s as we,g as Gr,u as Ki,c as Kr,m as wt,d as ir,T as sr}from"./Typography-IL0wuZeq.js";import{P as Cu}from"./pencil-CPPx1BhC.js";import{P as Eu,a as Ou}from"./panel-top-open-C3Q9X7Tg.js";import{F as Pu}from"./funnel-WdA7f2As.js";import{M as Mu}from"./MultiSelect-D1XVjXLN.js";import"./Table-DTU12O53.js";/**
1
+ import{v as it,r as m,cG as Nc,ab as V,cL as kc,ac as ae,j as v,cJ as vn,ds as It,dt as ge,du as Ho,cM as Lc,dv as Vc,dw as nn,dx as jc,bo as Fi,D as _r,aO as zr,bp as Fc,B as ee,z as $r,aP as Ur,aQ as Hr,G as Wo,bq as Bc,a8 as _c,br as An,bs as Bi,bt as _i,x as rn,ah as Go,b8 as Ko,bv as zc,g as qo,dy as $c,t as Pe,i as Xo,u as rr,dz as Uc,cS as Hc,dA as Wc,d5 as Gc,d6 as Kc,d7 as qc,L as Yo,I as Wr,cV as Xc,cW as Yc,cX as Nn,cY as Zc,cZ as zi,c_ as Jc,c$ as $i,d0 as Zo,d1 as Jo,d2 as Qo,dB as Qc,dC as eu,dD as sn,dE as tu,H as nu,a4 as ru,V as iu,X as su,Y as ou,Z as au,_ as lu,a0 as cu,aT as uu,a6 as Ui,dF as du,e as hu,aw as fu,av as Hi,dG as pu,dH as gu,dI as Wi,bT as mu,aN as vu,F as yu,aj as bu,dJ as Tu,dK as xu}from"./index-CcJvt1sI.js";import{u as ea}from"./use-url-query-D-GsTMWL.js";import{T as yn}from"./tooltip-Cy3vJ3fy.js";import{A as Gi}from"./arrow-up-down-Cq3mRkaO.js";import{D as Su}from"./download-csv-button-C5J9ow3I.js";import{B as wu}from"./business-extended-info-BRde-LSv.js";import{_ as Du,a as bn,s as we,g as Gr,u as Ki,c as Kr,m as wt,d as ir,T as sr}from"./Typography-D1_XzAPj.js";import{P as Cu}from"./pencil-BWTnh6hj.js";import{P as Eu,a as Ou}from"./panel-top-open-DQ1wo5PZ.js";import{F as Pu}from"./funnel-IYKnhWOy.js";import{M as Mu}from"./MultiSelect-9BbcXHjB.js";import"./Table-CR8S5Pp5.js";/**
2
2
  * @license lucide-react v0.548.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{j as e,cV as D,cZ as a,x as f,cu as n,J as N,fX as v,r as d,bt as T,D as E,aO as A,B as Y,z as I,bm as O,G as V,cO as M,V as P,X as y,Y as C,Z as F,_ as B,as as L,a0 as R,al as U,aT as _,F as k,a8 as q,u as z,c as G,cT as J,cU as Q,cW as o,cY as $,fY as H}from"./index-DPvrbbz9.js";import{u as w}from"./use-url-query-COmN7DHP.js";import{P as X}from"./page-layout-SHFb6rY4.js";import{F as Z}from"./funnel-WdA7f2As.js";const W=({record:s})=>{const t=N(v,s);return e.jsxs(D,{children:[e.jsx(a,{children:s.description}),e.jsx(a,{children:f(new Date(s.purchaseDate),"dd/MM/yyyy")}),e.jsx(a,{children:s.activationDate?f(new Date(s.activationDate),"dd/MM/yyyy"):void 0}),e.jsx(a,{children:t.originalCost?n(t.originalCost,0):void 0}),e.jsx(a,{children:t.reportYearDelta?n(t.reportYearDelta,0):void 0}),e.jsx(a,{children:n(t.totalDepreciableCosts,0)}),e.jsxs(a,{children:[n(s.statutoryDepreciationRate,0),"%"]}),e.jsx(a,{children:s.claimedDepreciationRate?`${n(s.claimedDepreciationRate,1)}%`:"-"}),e.jsx(a,{children:t.reportYearClaimedDepreciation?n(t.reportYearClaimedDepreciation,0):"-"}),e.jsx(a,{children:t.pastYearsAccumulatedDepreciation?n(t.pastYearsAccumulatedDepreciation,0):"-"}),e.jsx(a,{children:t.totalDepreciation?n(t.totalDepreciation,0):"-"}),e.jsx(a,{children:t.netValue?n(t.netValue,0):"-"})]})};function K(s){return!s||O(s)?null:encodeURIComponent(JSON.stringify(s))}const b="depreciationReportFilters";function ee({filter:s,setFilter:t,close:r}){const m=V({defaultValues:{...s}}),{control:c,handleSubmit:x}=m,{selectableFinancialEntities:u,fetching:l}=M(),j=i=>{t({...i,year:Number(i.year)}),r()};return e.jsx(P,{...m,children:e.jsxs("form",{onSubmit:x(j),className:"space-y-4",children:[e.jsx(y,{name:"year",control:c,rules:{required:"Year is required",validate:i=>{const p=Number(i);return Number.isNaN(p)||p<2e3||p>2100?"Invalid year":!0}},render:({field:i})=>e.jsxs(C,{children:[e.jsx(F,{children:"Year"}),e.jsx(B,{children:e.jsx(L,{...i,hideControls:!0,decimalScale:0})}),e.jsx(R,{})]})}),e.jsx(y,{name:"financialEntityId",defaultValue:s?.financialEntityId,control:c,render:({field:i})=>e.jsxs(C,{children:[e.jsx(F,{children:"Owner"}),e.jsx(U,{...i,data:u,value:i.value??void 0,disabled:l,placeholder:"Select a financial entity",formPart:!0}),e.jsx(R,{})]})}),e.jsx(_,{children:e.jsx(Y,{type:"submit",disabled:l,children:"Filter"})})]})})}function ae({filter:s,setFilter:t}){const[r,m]=d.useState(!1),{get:c,set:x}=w();d.useEffect(()=>{const l=K(s),j=c(b);l!==j&&x(b,l)},[s,c,x]);const u=d.useCallback(l=>{T(l,s)||t(l)},[s,t]);return e.jsxs(E,{open:r,onOpenChange:m,children:[e.jsx(A,{asChild:!0,children:e.jsx(Y,{variant:"outline",size:"icon",children:e.jsx(Z,{size:20})})}),e.jsx(I,{className:"sm:max-w-[425px]",children:e.jsx(ee,{filter:s,setFilter:u,close:()=>m(!1)})})]})}const g=({data:s,groupName:t})=>{const r=N(v,s);return e.jsxs(D,{className:"font-bold border-b border-black",children:[e.jsx(a,{children:t?"Group Total":"Overall Total"}),e.jsx(a,{colSpan:2,children:t}),e.jsx(a,{children:r.originalCost?n(r.originalCost,0):void 0}),e.jsx(a,{children:r.reportYearDelta?n(r.reportYearDelta,0):void 0}),e.jsx(a,{children:r.totalDepreciableCosts?n(r.totalDepreciableCosts,0):void 0}),e.jsx(a,{}),e.jsx(a,{}),e.jsx(a,{children:r.reportYearClaimedDepreciation?n(r.reportYearClaimedDepreciation,0):void 0}),e.jsx(a,{children:r.pastYearsAccumulatedDepreciation?n(r.pastYearsAccumulatedDepreciation,0):void 0}),e.jsx(a,{children:r.totalDepreciation?n(r.totalDepreciation,0):void 0}),e.jsx(a,{children:r.netValue?n(r.netValue,0):void 0})]})},ne=()=>{const{setFiltersContext:s}=d.useContext(k),{userContext:t}=d.useContext(q),{get:r}=w(),m=d.useMemo(()=>{const i={financialEntityId:t?.context.adminBusinessId,year:new Date().getFullYear()},p=r(b);if(p)try{return JSON.parse(decodeURIComponent(p))}catch(h){console.error("Failed to parse depreciation report filters from URL",h)}return i},[t?.context.adminBusinessId]),[c,x]=d.useState(m),[{data:u,fetching:l}]=z({query:H,variables:{filters:c}});d.useEffect(()=>{s(e.jsx("div",{className:"flex flex-row gap-x-5",children:e.jsx(ae,{filter:c,setFilter:x})}))},[c,s,x]);const j=d.useMemo(()=>`Depreciation Report for ${c.year}`,[c.year]);return e.jsx(X,{title:"Depreciation Report",description:j,children:l?e.jsx(G,{}):e.jsxs(J,{children:[e.jsxs(Q,{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($,{children:u?.depreciationReport&&e.jsxs(e.Fragment,{children:[u.depreciationReport.categories.map((i,p)=>e.jsxs(d.Fragment,{children:[e.jsxs(D,{className:"font-bold",children:[e.jsx(a,{children:`Category ${p+1}`}),e.jsx(a,{colSpan:2,children:i.category.name}),e.jsx(a,{colSpan:3}),e.jsxs(a,{children:[n(i.category.percentage,0),"%"]}),e.jsx(a,{colSpan:5})]}),i.records.sort((h,S)=>h.purchaseDate.localeCompare(S.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{ne as DepreciationReport};
1
+ import{j as e,cX as D,c$ as a,x as f,cw as n,J as N,f_ as v,r as d,bv as E,D as T,aO as A,B as w,z as I,bo as O,G as V,cQ as M,V as P,X as y,Y as C,Z as F,_ as B,as as L,a0 as R,al as _,aT as U,F as $,a8 as k,u as q,c as Q,cV as z,cW as G,cY as o,c_ as J,f$ as H}from"./index-CcJvt1sI.js";import{u as S}from"./use-url-query-D-GsTMWL.js";import{P as X}from"./page-layout-BNHKLJFL.js";import{F as W}from"./funnel-IYKnhWOy.js";const Z=({record:s})=>{const t=N(v,s);return e.jsxs(D,{children:[e.jsx(a,{children:s.description}),e.jsx(a,{children:f(new Date(s.purchaseDate),"dd/MM/yyyy")}),e.jsx(a,{children:s.activationDate?f(new Date(s.activationDate),"dd/MM/yyyy"):void 0}),e.jsx(a,{children:t.originalCost?n(t.originalCost,0):void 0}),e.jsx(a,{children:t.reportYearDelta?n(t.reportYearDelta,0):void 0}),e.jsx(a,{children:n(t.totalDepreciableCosts,0)}),e.jsxs(a,{children:[n(s.statutoryDepreciationRate,0),"%"]}),e.jsx(a,{children:s.claimedDepreciationRate?`${n(s.claimedDepreciationRate,1)}%`:"-"}),e.jsx(a,{children:t.reportYearClaimedDepreciation?n(t.reportYearClaimedDepreciation,0):"-"}),e.jsx(a,{children:t.pastYearsAccumulatedDepreciation?n(t.pastYearsAccumulatedDepreciation,0):"-"}),e.jsx(a,{children:t.totalDepreciation?n(t.totalDepreciation,0):"-"}),e.jsx(a,{children:t.netValue?n(t.netValue,0):"-"})]})};function K(s){return!s||O(s)?null:encodeURIComponent(JSON.stringify(s))}const b="depreciationReportFilters";function ee({filter:s,setFilter:t,close:r}){const m=V({defaultValues:{...s}}),{control:c,handleSubmit:x}=m,{selectableFinancialEntities:u,fetching:l}=M(),j=i=>{t({...i,year:Number(i.year)}),r()};return e.jsx(P,{...m,children:e.jsxs("form",{onSubmit:x(j),className:"space-y-4",children:[e.jsx(y,{name:"year",control:c,rules:{required:"Year is required",validate:i=>{const p=Number(i);return Number.isNaN(p)||p<2e3||p>2100?"Invalid year":!0}},render:({field:i})=>e.jsxs(C,{children:[e.jsx(F,{children:"Year"}),e.jsx(B,{children:e.jsx(L,{...i,hideControls:!0,decimalScale:0})}),e.jsx(R,{})]})}),e.jsx(y,{name:"financialEntityId",defaultValue:s?.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(U,{children:e.jsx(w,{type:"submit",disabled:l,children:"Filter"})})]})})}function ae({filter:s,setFilter:t}){const[r,m]=d.useState(!1),{get:c,set:x}=S();d.useEffect(()=>{const l=K(s),j=c(b);l!==j&&x(b,l)},[s,c,x]);const u=d.useCallback(l=>{E(l,s)||t(l)},[s,t]);return e.jsxs(T,{open:r,onOpenChange:m,children:[e.jsx(A,{asChild:!0,children:e.jsx(w,{variant:"outline",size:"icon",children:e.jsx(W,{size:20})})}),e.jsx(I,{className:"sm:max-w-[425px]",children:e.jsx(ee,{filter:s,setFilter:u,close:()=>m(!1)})})]})}const g=({data:s,groupName:t})=>{const r=N(v,s);return e.jsxs(D,{className:"font-bold border-b border-black",children:[e.jsx(a,{children:t?"Group Total":"Overall Total"}),e.jsx(a,{colSpan:2,children:t}),e.jsx(a,{children:r.originalCost?n(r.originalCost,0):void 0}),e.jsx(a,{children:r.reportYearDelta?n(r.reportYearDelta,0):void 0}),e.jsx(a,{children:r.totalDepreciableCosts?n(r.totalDepreciableCosts,0):void 0}),e.jsx(a,{}),e.jsx(a,{}),e.jsx(a,{children:r.reportYearClaimedDepreciation?n(r.reportYearClaimedDepreciation,0):void 0}),e.jsx(a,{children:r.pastYearsAccumulatedDepreciation?n(r.pastYearsAccumulatedDepreciation,0):void 0}),e.jsx(a,{children:r.totalDepreciation?n(r.totalDepreciation,0):void 0}),e.jsx(a,{children:r.netValue?n(r.netValue,0):void 0})]})},ne=()=>{const{setFiltersContext:s}=d.useContext($),{userContext:t}=d.useContext(k),{get:r}=S(),m=d.useMemo(()=>{const i={financialEntityId:t?.context.adminBusinessId,year:new Date().getFullYear()},p=r(b);if(p)try{return JSON.parse(decodeURIComponent(p))}catch(h){console.error("Failed to parse depreciation report filters from URL",h)}return i},[t?.context.adminBusinessId]),[c,x]=d.useState(m),[{data:u,fetching:l}]=q({query:H,variables:{filters:c}});d.useEffect(()=>{s(e.jsx("div",{className:"flex flex-row gap-x-5",children:e.jsx(ae,{filter:c,setFilter:x})}))},[c,s,x]);const j=d.useMemo(()=>`Depreciation Report for ${c.year}`,[c.year]);return e.jsx(X,{title:"Depreciation Report",description:j,children:l?e.jsx(Q,{}):e.jsxs(z,{children:[e.jsxs(G,{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(J,{children:u?.depreciationReport&&e.jsxs(e.Fragment,{children:[u.depreciationReport.categories.map((i,p)=>e.jsxs(d.Fragment,{children:[e.jsxs(D,{className:"font-bold",children:[e.jsx(a,{children:`Category ${p+1}`}),e.jsx(a,{colSpan:2,children:i.category.name}),e.jsx(a,{colSpan:3}),e.jsxs(a,{children:[n(i.category.percentage,0),"%"]}),e.jsx(a,{colSpan:5})]}),i.records.sort((h,Y)=>h.purchaseDate.localeCompare(Y.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{ne as DepreciationReport};
@@ -1 +1 @@
1
- import{j as n,r as x,B as g,J as h,ge as j,a as v,F as D,u as R,L as E,bn as y,dE as T,T as u,gf as w}from"./index-DPvrbbz9.js";import{d as C}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{P as A}from"./page-layout-SHFb6rY4.js";import{P as b}from"./modal-Nvfe-DMu.js";import{Y as F}from"./YearPickerInput-CPL_XozD.js";import{F as I}from"./funnel-WdA7f2As.js";import{T as N}from"./Table-DTU12O53.js";const i=({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(b,{opened:r,onClose:()=>l(!1),withCloseButton:!0,content:n.jsx(F,{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(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>l(!0),children:n.jsx(I,{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)=>T(t).format(a);function m(a,t){if(a.length!==0)return c(a.reduce((r,l)=>r+l,0),t)}const U=()=>{const{year:a}=v(),{setFiltersContext:t}=x.useContext(D),[r,l]=x.useState(a?[Number(a)]:[new Date().getFullYear()]),[{data:d,fetching:p}]=R({query:C(w),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(A,{title:"Corporate Tax Ruling Compliance Report",children:p?n.jsx(E,{className:"h-10 w-10 animate-spin mr-2 self-center"}):n.jsx("div",{className:"flex flex-col gap-4",children:s&&n.jsxs(N,{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(y,{inline:!0,size:12,processing:!s.find(o=>o.year===e)?.differences,disabled:!!s.find(o=>o.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(i,{originalAmount:e.totalIncome.formatted,diffAmount:e.differences?.totalIncome?.formatted??void 0},e.year)),n.jsx(i,{originalAmount:c(s.map(e=>e.totalIncome.raw).reduce((e,o)=>e+o,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(i,{originalAmount:e.researchAndDevelopmentExpenses.formatted,diffAmount:e.differences?.researchAndDevelopmentExpenses?.formatted??void 0},e.year)),n.jsx(i,{originalAmount:c(s.map(e=>e.researchAndDevelopmentExpenses.raw).reduce((e,o)=>e+o,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(i,{originalAmount:e.localDevelopmentExpenses.formatted,diffAmount:e.differences?.localDevelopmentExpenses?.formatted??void 0},e.year)),n.jsx(i,{originalAmount:c(s.map(e=>e.localDevelopmentExpenses.raw).reduce((e,o)=>e+o,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(i,{originalAmount:e.foreignDevelopmentExpenses.formatted,diffAmount:e.differences?.foreignDevelopmentExpenses?.formatted??void 0},e.year)),n.jsx(i,{originalAmount:c(s.map(e=>e.foreignDevelopmentExpenses.raw).reduce((e,o)=>e+o,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(i,{originalAmount:e.businessTripRndExpenses.formatted,diffAmount:e.differences?.businessTripRndExpenses?.formatted??void 0},e.year)),n.jsx(i,{originalAmount:c(s.map(e=>e.businessTripRndExpenses.raw).reduce((e,o)=>e+o,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{U as CorporateTaxRulingComplianceReport};
1
+ import{j as n,r as x,B as g,J as h,gh as j,a as v,F as D,u as R,L as E,bp as y,dG as T,T as u,gi as w}from"./index-CcJvt1sI.js";import{d as C}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{P as A}from"./page-layout-BNHKLJFL.js";import{P as b}from"./modal-DOtlViK5.js";import{Y as F}from"./YearPickerInput-dCiPlZqk.js";import{F as I}from"./funnel-IYKnhWOy.js";import{T as N}from"./Table-CR8S5Pp5.js";const i=({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(b,{opened:r,onClose:()=>l(!1),withCloseButton:!0,content:n.jsx(F,{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(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>l(!0),children:n.jsx(I,{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)=>T(t).format(a);function m(a,t){if(a.length!==0)return c(a.reduce((r,l)=>r+l,0),t)}const U=()=>{const{year:a}=v(),{setFiltersContext:t}=x.useContext(D),[r,l]=x.useState(a?[Number(a)]:[new Date().getFullYear()]),[{data:d,fetching:p}]=R({query:C(w),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(A,{title:"Corporate Tax Ruling Compliance Report",children:p?n.jsx(E,{className:"h-10 w-10 animate-spin mr-2 self-center"}):n.jsx("div",{className:"flex flex-col gap-4",children:s&&n.jsxs(N,{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(y,{inline:!0,size:12,processing:!s.find(o=>o.year===e)?.differences,disabled:!!s.find(o=>o.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(i,{originalAmount:e.totalIncome.formatted,diffAmount:e.differences?.totalIncome?.formatted??void 0},e.year)),n.jsx(i,{originalAmount:c(s.map(e=>e.totalIncome.raw).reduce((e,o)=>e+o,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(i,{originalAmount:e.researchAndDevelopmentExpenses.formatted,diffAmount:e.differences?.researchAndDevelopmentExpenses?.formatted??void 0},e.year)),n.jsx(i,{originalAmount:c(s.map(e=>e.researchAndDevelopmentExpenses.raw).reduce((e,o)=>e+o,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(i,{originalAmount:e.localDevelopmentExpenses.formatted,diffAmount:e.differences?.localDevelopmentExpenses?.formatted??void 0},e.year)),n.jsx(i,{originalAmount:c(s.map(e=>e.localDevelopmentExpenses.raw).reduce((e,o)=>e+o,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(i,{originalAmount:e.foreignDevelopmentExpenses.formatted,diffAmount:e.differences?.foreignDevelopmentExpenses?.formatted??void 0},e.year)),n.jsx(i,{originalAmount:c(s.map(e=>e.foreignDevelopmentExpenses.raw).reduce((e,o)=>e+o,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(i,{originalAmount:e.businessTripRndExpenses.formatted,diffAmount:e.differences?.businessTripRndExpenses?.formatted??void 0},e.year)),n.jsx(i,{originalAmount:c(s.map(e=>e.businessTripRndExpenses.raw).reduce((e,o)=>e+o,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{U as CorporateTaxRulingComplianceReport};
@@ -1,4 +1,4 @@
1
- import{r as h,bm as S,j as e,bn as N,B as y,G as $,bo as k,a8 as R,V as O,bp as f,bq as D,br as C,x as F,X as A,Y as E,Z as z,_ as P,ah as M,bt as L,bj as w,T as B,a$ as j,aN as p,J as V,dl as _,cu as v,F as G,u as q,dm as U,dn as Z,L as H,dp as J}from"./index-DPvrbbz9.js";import{u as I}from"./use-url-query-COmN7DHP.js";import{P as Q}from"./page-layout-SHFb6rY4.js";import{P as X}from"./modal-Nvfe-DMu.js";import{F as K}from"./funnel-WdA7f2As.js";import{M as T}from"./MultiSelect-D1XVjXLN.js";import{D as W}from"./download-csv-button-D9_6J2pA.js";import{B as Y}from"./business-extended-info-MUfOmQ_B.js";import{P as ee,a as te}from"./panel-top-open-C3Q9X7Tg.js";import{T as se}from"./Table-DTU12O53.js";function re({filter:t,setFilter:s,closeModal:i}){const n=$({defaultValues:{...t}}),{control:a,handleSubmit:o}=n,{selectableBusinesses:r,fetching:u}=k(),{userContext:m}=h.useContext(R),c=l=>{l.fromDate?.trim()===""&&(l.fromDate=void 0),l.toDate?.trim()===""&&(l.toDate=void 0),s(l),i()};function d(){s({}),i()}return e.jsxs(e.Fragment,{children:[u?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsx(O,{...n,children:e.jsxs("form",{onSubmit:o(c),className:"space-y-2",children:[e.jsx(f,{name:"ownerIds",control:a,defaultValue:void 0,render:({field:l,fieldState:b})=>e.jsx(T,{...l,data:r,value:l.value??(m?.context.adminBusinessId?[m?.context.adminBusinessId]:void 0),disabled:u,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:b.error?.message})}),e.jsx(f,{name:"businessIDs",control:a,defaultValue:void 0,render:({field:l,fieldState:b})=>e.jsx(T,{...l,data:r,value:l.value??void 0,disabled:u,label:"Businesses",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:b.error?.message})}),e.jsx(f,{name:"fromDate",control:a,defaultValue:t.fromDate,rules:{required:"Required",pattern:{value:D,message:"Date must be im format yyyy-mm-dd"}},render:({field:l,fieldState:b})=>e.jsx(C,{...l,onChange:x=>{const g=x?typeof x=="string"?x:F(x,"yyyy-MM-dd"):void 0;g!==l.value&&l.onChange(g)},value:l.value?new Date(l.value):void 0,label:"From Date",error:b.error?.message,required:!0,popoverProps:{withinPortal:!0}})}),e.jsx(f,{name:"toDate",control:a,defaultValue:t.toDate,rules:{pattern:{value:D,message:"Date must be im format yyyy-mm-dd"}},render:({field:l,fieldState:b})=>e.jsx(C,{...l,onChange:x=>{const g=x?typeof x=="string"?x:F(x,"yyyy-MM-dd"):void 0;g!==l.value&&l.onChange(g)},value:l.value?new Date(l.value):void 0,label:"To Date",error:b.error?.message,required:!0,popoverProps:{withinPortal:!0}})}),e.jsx(A,{name:"isShowZeroedAccounts",control:a,render:({field:l})=>e.jsxs(E,{className:"flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(z,{children:"Show zeroed accounts"})}),e.jsxs("div",{className:"flex flex-row items-center gap-1",children:[e.jsx(P,{children:e.jsx(M,{defaultChecked:t.isShowZeroedAccounts??!1,onCheckedChange:l.onChange,checked:l.value===!0})}),e.jsx("span",{children:l.value?"show":"remove"})]})]})}),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:d,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:i,children:"Cancel"})]})]})})]})}function ae({filter:t,setFilter:s}){const[i,n]=h.useState(!1),[a,o]=h.useState(!S(t)),{get:r,set:u}=I();function m(d){return Object.entries(d??{}).filter(([b,x])=>x!==void 0&&Array.isArray(x)&&x.length>0).length>0}function c(d){L(d,t)||(s(d),o(m(d)))}return h.useEffect(()=>{const d=S(t)?null:encodeURIComponent(JSON.stringify(t)),l=r("trialBalanceReportFilters");d!==l&&u("trialBalanceReportFilters",d)},[t,r,u]),e.jsxs(e.Fragment,{children:[e.jsx(X,{opened:i,onClose:()=>n(!1),content:e.jsx(re,{filter:t,setFilter:c,closeModal:()=>n(!1)})}),e.jsx(N,{inline:!0,size:16,disabled:!a,children:e.jsx(y,{variant:"outline",onClick:()=>n(!0),className:"p-2",children:e.jsx(K,{size:20})})})]})}const ne=({data:t,fromDate:s,toDate:i})=>{const n=h.useCallback(async()=>{const a=oe(t),o=`trial_balance_report${s?`_${s}`:""}${i?`_${i}`:""}`;return{fileContent:a,fileName:o}},[t,s,i]);return e.jsx(W,{createFileVariables:n})},oe=t=>{let s="";s+=`Sort Code,Account Name,Debit,Credit,Balance\r
1
+ import{r as h,bo as S,j as e,bp as N,B as y,G as $,bq as k,a8 as R,V as O,br as f,bs as D,bt as C,x as F,X as A,Y as E,Z as z,_ as P,ah as M,bv as L,bl as w,T as B,a$ as j,aN as p,J as V,dn as _,cw as v,F as q,u as G,dp as U,dq as Z,L as H,dr as J}from"./index-CcJvt1sI.js";import{u as I}from"./use-url-query-D-GsTMWL.js";import{P as Q}from"./page-layout-BNHKLJFL.js";import{P as X}from"./modal-DOtlViK5.js";import{F as K}from"./funnel-IYKnhWOy.js";import{M as T}from"./MultiSelect-9BbcXHjB.js";import{D as W}from"./download-csv-button-C5J9ow3I.js";import{B as Y}from"./business-extended-info-BRde-LSv.js";import{P as ee,a as te}from"./panel-top-open-DQ1wo5PZ.js";import{T as se}from"./Table-CR8S5Pp5.js";function re({filter:t,setFilter:s,closeModal:i}){const n=$({defaultValues:{...t}}),{control:a,handleSubmit:o}=n,{selectableBusinesses:r,fetching:u}=k(),{userContext:m}=h.useContext(R),c=l=>{l.fromDate?.trim()===""&&(l.fromDate=void 0),l.toDate?.trim()===""&&(l.toDate=void 0),s(l),i()};function d(){s({}),i()}return e.jsxs(e.Fragment,{children:[u?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsx(O,{...n,children:e.jsxs("form",{onSubmit:o(c),className:"space-y-2",children:[e.jsx(f,{name:"ownerIds",control:a,defaultValue:void 0,render:({field:l,fieldState:b})=>e.jsx(T,{...l,data:r,value:l.value??(m?.context.adminBusinessId?[m?.context.adminBusinessId]:void 0),disabled:u,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:b.error?.message})}),e.jsx(f,{name:"businessIDs",control:a,defaultValue:void 0,render:({field:l,fieldState:b})=>e.jsx(T,{...l,data:r,value:l.value??void 0,disabled:u,label:"Businesses",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:b.error?.message})}),e.jsx(f,{name:"fromDate",control:a,defaultValue:t.fromDate,rules:{required:"Required",pattern:{value:D,message:"Date must be im format yyyy-mm-dd"}},render:({field:l,fieldState:b})=>e.jsx(C,{...l,onChange:x=>{const g=x?typeof x=="string"?x:F(x,"yyyy-MM-dd"):void 0;g!==l.value&&l.onChange(g)},value:l.value?new Date(l.value):void 0,label:"From Date",error:b.error?.message,required:!0,popoverProps:{withinPortal:!0}})}),e.jsx(f,{name:"toDate",control:a,defaultValue:t.toDate,rules:{pattern:{value:D,message:"Date must be im format yyyy-mm-dd"}},render:({field:l,fieldState:b})=>e.jsx(C,{...l,onChange:x=>{const g=x?typeof x=="string"?x:F(x,"yyyy-MM-dd"):void 0;g!==l.value&&l.onChange(g)},value:l.value?new Date(l.value):void 0,label:"To Date",error:b.error?.message,required:!0,popoverProps:{withinPortal:!0}})}),e.jsx(A,{name:"isShowZeroedAccounts",control:a,render:({field:l})=>e.jsxs(E,{className:"flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(z,{children:"Show zeroed accounts"})}),e.jsxs("div",{className:"flex flex-row items-center gap-1",children:[e.jsx(P,{children:e.jsx(M,{defaultChecked:t.isShowZeroedAccounts??!1,onCheckedChange:l.onChange,checked:l.value===!0})}),e.jsx("span",{children:l.value?"show":"remove"})]})]})}),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:d,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:i,children:"Cancel"})]})]})})]})}function ae({filter:t,setFilter:s}){const[i,n]=h.useState(!1),[a,o]=h.useState(!S(t)),{get:r,set:u}=I();function m(d){return Object.entries(d??{}).filter(([b,x])=>x!==void 0&&Array.isArray(x)&&x.length>0).length>0}function c(d){L(d,t)||(s(d),o(m(d)))}return h.useEffect(()=>{const d=S(t)?null:encodeURIComponent(JSON.stringify(t)),l=r("trialBalanceReportFilters");d!==l&&u("trialBalanceReportFilters",d)},[t,r,u]),e.jsxs(e.Fragment,{children:[e.jsx(X,{opened:i,onClose:()=>n(!1),content:e.jsx(re,{filter:t,setFilter:c,closeModal:()=>n(!1)})}),e.jsx(N,{inline:!0,size:16,disabled:!a,children:e.jsx(y,{variant:"outline",onClick:()=>n(!0),className:"p-2",children:e.jsx(K,{size:20})})})]})}const ne=({data:t,fromDate:s,toDate:i})=>{const n=h.useCallback(async()=>{const a=oe(t),o=`trial_balance_report${s?`_${s}`:""}${i?`_${i}`:""}`;return{fileContent:a,fileName:o}},[t,s,i]);return e.jsx(W,{createFileVariables:n})},oe=t=>{let s="";s+=`Sort Code,Account Name,Debit,Credit,Balance\r
2
2
  `;for(const[i,n]of Object.entries(t)){const a=ie(i,n);s+=a}return s+=`Report total:,,${Object.values(t).reduce((i,n)=>i+n.totalDebit,0)},${Object.values(t).reduce((i,n)=>i+n.totalCredit,0)},${Object.values(t).reduce((i,n)=>i+n.sum,0)}\r
3
3
  `,s};function ie(t,s){let i="";return Object.values(s.sortCodes).sort((n,a)=>n.key-a.key).map(n=>{const a=le(n);i+=a}),i+=`${t.replaceAll("0","*")},Group Total:,${s.totalDebit??""},${s.totalCredit??""},${s.sum}\r
4
4
  `,i}function le(t){let s="";s+=`${t.name}\r
@@ -6,4 +6,4 @@ import{r as h,bm as S,j as e,bn as N,B as y,G as $,bo as k,a8 as R,V as O,bp as
6
6
  `;s+=c});const i=`${t.key},Group total:,${t.totalDebit??""},${t.totalCredit??""},${t.sum}\r
7
7
  `;s+=i;const n=t.debit?`,,,Total Debit Balances:,${t.debit}\r
8
8
  `:"";s+=n;const a=t.credit?`,,,Total Credit Balances:,${t.credit}\r
9
- `:"";return s+=a,s}function ce(t){let s="";return s=t.replace(/"/g,'""'),s}const de=({record:t,sortCodeKey:s,filter:i,isAllOpened:n})=>{const[a,o]=h.useState(n),r=t?.total?.raw??0,u=t?.debit?.raw??0,m=t?.credit?.raw??0;return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{children:[e.jsx("td",{children:s}),e.jsx("td",{children:t.business.id}),e.jsx("td",{children:t.business.name??void 0}),e.jsx("td",{children:u?t?.debit?.formatted:void 0}),e.jsx("td",{children:m?t?.credit?.formatted:void 0}),e.jsx("td",{children:(r>.001||r<-.001)&&e.jsx(w,{color:r>0?"green":"red",children:t?.total?.formatted})}),e.jsx("td",{children:e.jsx(B,{label:"Detailed records",children:e.jsx(y,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>o(c=>!c),children:a||n?e.jsx(ee,{className:"size-5"}):e.jsx(te,{className:"size-5"})})})})]},t.business.id),(a||n)&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,children:e.jsx(Y,{businessID:t.business?.id,filter:i})})})]})},ue=({sortCode:t,filter:s,isAllOpened:i})=>t.records.length>0?e.jsxs(e.Fragment,{children:[e.jsx("tr",{children:e.jsx("td",{colSpan:7,children:e.jsx("span",{className:"font-bold",children:t.name})})}),t.records.sort((n,a)=>n.business.name.localeCompare(a.business.name)).map(n=>e.jsx(de,{record:n,sortCodeKey:t.key,filter:s,isAllOpened:i},n.business.id)),e.jsx("tr",{className:"bg-gray-100",children:t.records.length>1?e.jsxs(e.Fragment,{children:[e.jsx("td",{colSpan:2,children:"Group total:"}),e.jsx("td",{colSpan:1,children:t.key}),e.jsx("td",{colSpan:1,children:!!t.totalDebit&&j(t.totalDebit,p.Ils)}),e.jsx("td",{colSpan:1,children:!!t.totalCredit&&j(t.totalCredit,p.Ils)}),e.jsxs("td",{colSpan:1,children:[e.jsx(w,{c:t.sum>0?"green":t.sum<0?"red":void 0,children:j(t.sum,p.Ils)}),!!t.debit&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),"Total Debit Balances: ",j(t.debit,p.Ils)]}),!!t.credit&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),"Total Credit Balances: ",j(t.credit,p.Ils)]})]})]}):void 0})]}):null,me=({group:t,data:s,filter:i,isAllOpened:n})=>e.jsxs(e.Fragment,{children:[Object.values(s.sortCodes).sort((a,o)=>a.key-o.key).map((a,o)=>e.jsx(ue,{sortCode:a,filter:i,isAllOpened:n},`${a.key} ${o}`)),e.jsxs("tr",{className:"bg-gray-100",children:[e.jsx("td",{colSpan:2,children:"Group total:"}),e.jsx("td",{colSpan:1,children:t.replaceAll("0","*")}),e.jsx("td",{colSpan:1,children:!!s.totalDebit&&j(s.totalDebit,p.Ils)}),e.jsx("td",{colSpan:1,children:!!s.totalCredit&&j(s.totalCredit,p.Ils)}),e.jsx("td",{colSpan:1,children:e.jsx(w,{fw:700,c:s.sum>0?"green":s.sum<0?"red":void 0,children:j(s.sum,p.Ils)})})]},"group"+t)]});function xe(t){return Math.floor(t/100)*100}const he=({data:t,filter:s,isAllOpened:i})=>{const{businessTransactionsSum:n}=V(_,t),a=h.useMemo(()=>{const o={};for(const r of n){r.business.sortCode??={id:"-999",key:-999,name:"Misc"};const u=!r.total.raw||r.total.raw<.001&&r.total.raw>-.001;if(!s.isShowZeroedAccounts&&u)continue;const m=xe(r.business.sortCode.key);o[m]??={sortCodes:{},totalCredit:0,totalDebit:0,credit:0,debit:0,sum:0};const c=o[m];c.sortCodes[r.business.sortCode.key]??={...r.business.sortCode,totalCredit:0,totalDebit:0,records:[],credit:0,debit:0,sum:0};const d=c.sortCodes[r.business.sortCode.key];d.totalCredit+=r.credit.raw,d.totalDebit+=r.debit.raw,d.sum+=r.total.raw,c.totalCredit+=r.credit.raw,c.totalDebit+=r.debit.raw,c.sum+=r.total.raw,r.total.raw>0?(d.credit+=r.total.raw,c.credit+=r.total.raw):(d.debit+=r.total.raw,c.debit+=r.total.raw),d.records.push(r)}return o},[n,s.isShowZeroedAccounts]);return e.jsxs(se,{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:"Sort Code"}),e.jsx("th",{children:"Account"}),e.jsx("th",{children:"Account Name"}),e.jsx("th",{children:"Total Debit"}),e.jsx("th",{children:"Total Credit"}),e.jsx("th",{children:"Balance"}),e.jsx("th",{children:e.jsx(ne,{data:a,fromDate:s.fromDate??void 0,toDate:s.toDate??void 0})})]})}),e.jsxs("tbody",{children:[Object.entries(a).map(([o,r])=>e.jsx(me,{data:r,group:o,filter:s,isAllOpened:i},o)),e.jsxs("tr",{className:"bg-gray-100",children:[e.jsx("td",{colSpan:2,children:"Report total:"}),e.jsx("td",{}),e.jsxs("td",{children:["(",v(Object.values(a).reduce((o,r)=>o+r.totalDebit,0)),")"]}),e.jsxs("td",{children:["(",v(Object.values(a).reduce((o,r)=>o+r.totalCredit,0)),")"]}),e.jsx("td",{colSpan:1,children:v(Object.values(a).reduce((o,r)=>o+r.sum,0))})]})]})]})},Ce=()=>{const[t,s]=h.useState(!1),{get:i}=I(),{setFiltersContext:n}=h.useContext(G),[a,o]=h.useState(i("trialBalanceReportFilters")?JSON.parse(decodeURIComponent(i("trialBalanceReportFilters"))):{}),[{data:r,fetching:u}]=q({query:J,variables:{filters:{fromDate:a?.fromDate,toDate:a?.toDate,ownerIds:a?.ownerIds,businessIDs:a?.businessIDs}}});h.useEffect(()=>{n(e.jsxs("div",{className:"flex flex-row gap-2",children:[e.jsx(B,{label:"Expand all accounts",children:e.jsx(y,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>s(c=>!c),children:t?e.jsx(U,{className:"size-5"}):e.jsx(Z,{className:"size-5"})})}),e.jsx(ae,{filter:a,setFilter:o})]}))},[a,t,n]);const m=h.useMemo(()=>r?.businessTransactionsSumFromLedgerRecords.__typename==="CommonError"?void 0:r?.businessTransactionsSumFromLedgerRecords,[r?.businessTransactionsSumFromLedgerRecords]);return e.jsx(Q,{title:"Trial Balance Report",description:"Trial balance report for all businesses",children:u||!m?e.jsx(H,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsx(he,{data:m,filter:a,isAllOpened:t})})};export{Ce as TrialBalanceReport};
9
+ `:"";return s+=a,s}function ce(t){let s="";return s=t.replace(/"/g,'""'),s}const de=({record:t,sortCodeKey:s,filter:i,isAllOpened:n})=>{const[a,o]=h.useState(n),r=t?.total?.raw??0,u=t?.debit?.raw??0,m=t?.credit?.raw??0;return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{children:[e.jsx("td",{children:s}),e.jsx("td",{children:t.business.id}),e.jsx("td",{children:t.business.name??void 0}),e.jsx("td",{children:u?t?.debit?.formatted:void 0}),e.jsx("td",{children:m?t?.credit?.formatted:void 0}),e.jsx("td",{children:(r>.001||r<-.001)&&e.jsx(w,{color:r>0?"green":"red",children:t?.total?.formatted})}),e.jsx("td",{children:e.jsx(B,{label:"Detailed records",children:e.jsx(y,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>o(c=>!c),children:a||n?e.jsx(ee,{className:"size-5"}):e.jsx(te,{className:"size-5"})})})})]},t.business.id),(a||n)&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,children:e.jsx(Y,{businessID:t.business?.id,filter:i})})})]})},ue=({sortCode:t,filter:s,isAllOpened:i})=>t.records.length>0?e.jsxs(e.Fragment,{children:[e.jsx("tr",{children:e.jsx("td",{colSpan:7,children:e.jsx("span",{className:"font-bold",children:t.name})})}),t.records.sort((n,a)=>n.business.name.localeCompare(a.business.name)).map(n=>e.jsx(de,{record:n,sortCodeKey:t.key,filter:s,isAllOpened:i},n.business.id)),e.jsx("tr",{className:"bg-gray-100",children:t.records.length>1?e.jsxs(e.Fragment,{children:[e.jsx("td",{colSpan:2,children:"Group total:"}),e.jsx("td",{colSpan:1,children:t.key}),e.jsx("td",{colSpan:1,children:!!t.totalDebit&&j(t.totalDebit,p.Ils)}),e.jsx("td",{colSpan:1,children:!!t.totalCredit&&j(t.totalCredit,p.Ils)}),e.jsxs("td",{colSpan:1,children:[e.jsx(w,{c:t.sum>0?"green":t.sum<0?"red":void 0,children:j(t.sum,p.Ils)}),!!t.debit&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),"Total Debit Balances: ",j(t.debit,p.Ils)]}),!!t.credit&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),"Total Credit Balances: ",j(t.credit,p.Ils)]})]})]}):void 0})]}):null,me=({group:t,data:s,filter:i,isAllOpened:n})=>e.jsxs(e.Fragment,{children:[Object.values(s.sortCodes).sort((a,o)=>a.key-o.key).map((a,o)=>e.jsx(ue,{sortCode:a,filter:i,isAllOpened:n},`${a.key} ${o}`)),e.jsxs("tr",{className:"bg-gray-100",children:[e.jsx("td",{colSpan:2,children:"Group total:"}),e.jsx("td",{colSpan:1,children:t.replaceAll("0","*")}),e.jsx("td",{colSpan:1,children:!!s.totalDebit&&j(s.totalDebit,p.Ils)}),e.jsx("td",{colSpan:1,children:!!s.totalCredit&&j(s.totalCredit,p.Ils)}),e.jsx("td",{colSpan:1,children:e.jsx(w,{fw:700,c:s.sum>0?"green":s.sum<0?"red":void 0,children:j(s.sum,p.Ils)})})]},"group"+t)]});function xe(t){return Math.floor(t/100)*100}const he=({data:t,filter:s,isAllOpened:i})=>{const{businessTransactionsSum:n}=V(_,t),a=h.useMemo(()=>{const o={};for(const r of n){r.business.sortCode??={id:"-999",key:-999,name:"Misc"};const u=!r.total.raw||r.total.raw<.001&&r.total.raw>-.001;if(!s.isShowZeroedAccounts&&u)continue;const m=xe(r.business.sortCode.key);o[m]??={sortCodes:{},totalCredit:0,totalDebit:0,credit:0,debit:0,sum:0};const c=o[m];c.sortCodes[r.business.sortCode.key]??={...r.business.sortCode,totalCredit:0,totalDebit:0,records:[],credit:0,debit:0,sum:0};const d=c.sortCodes[r.business.sortCode.key];d.totalCredit+=r.credit.raw,d.totalDebit+=r.debit.raw,d.sum+=r.total.raw,c.totalCredit+=r.credit.raw,c.totalDebit+=r.debit.raw,c.sum+=r.total.raw,r.total.raw>0?(d.credit+=r.total.raw,c.credit+=r.total.raw):(d.debit+=r.total.raw,c.debit+=r.total.raw),d.records.push(r)}return o},[n,s.isShowZeroedAccounts]);return e.jsxs(se,{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:"Sort Code"}),e.jsx("th",{children:"Account"}),e.jsx("th",{children:"Account Name"}),e.jsx("th",{children:"Total Debit"}),e.jsx("th",{children:"Total Credit"}),e.jsx("th",{children:"Balance"}),e.jsx("th",{children:e.jsx(ne,{data:a,fromDate:s.fromDate??void 0,toDate:s.toDate??void 0})})]})}),e.jsxs("tbody",{children:[Object.entries(a).map(([o,r])=>e.jsx(me,{data:r,group:o,filter:s,isAllOpened:i},o)),e.jsxs("tr",{className:"bg-gray-100",children:[e.jsx("td",{colSpan:2,children:"Report total:"}),e.jsx("td",{}),e.jsxs("td",{children:["(",v(Object.values(a).reduce((o,r)=>o+r.totalDebit,0)),")"]}),e.jsxs("td",{children:["(",v(Object.values(a).reduce((o,r)=>o+r.totalCredit,0)),")"]}),e.jsx("td",{colSpan:1,children:v(Object.values(a).reduce((o,r)=>o+r.sum,0))})]})]})]})},Ce=()=>{const[t,s]=h.useState(!1),{get:i}=I(),{setFiltersContext:n}=h.useContext(q),[a,o]=h.useState(i("trialBalanceReportFilters")?JSON.parse(decodeURIComponent(i("trialBalanceReportFilters"))):{}),[{data:r,fetching:u}]=G({query:J,variables:{filters:{fromDate:a?.fromDate,toDate:a?.toDate,ownerIds:a?.ownerIds,businessIDs:a?.businessIDs}}});h.useEffect(()=>{n(e.jsxs("div",{className:"flex flex-row gap-2",children:[e.jsx(B,{label:"Expand all accounts",children:e.jsx(y,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>s(c=>!c),children:t?e.jsx(U,{className:"size-5"}):e.jsx(Z,{className:"size-5"})})}),e.jsx(ae,{filter:a,setFilter:o})]}))},[a,t,n]);const m=h.useMemo(()=>r?.businessTransactionsSumFromLedgerRecords.__typename==="CommonError"?void 0:r?.businessTransactionsSumFromLedgerRecords,[r?.businessTransactionsSumFromLedgerRecords]);return e.jsx(Q,{title:"Trial Balance Report",description:"Trial balance report for all businesses",children:u||!m?e.jsx(H,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsx(he,{data:m,filter:a,isAllOpened:t})})};export{Ce as TrialBalanceReport};