@accounter/client 0.0.9-alpha-20251231171312-67d2850c6eacafb65d42d987f3d49dca3c0f8bdd → 0.0.9-alpha-20251231172115-20bdd8c1e624a922467480aaa72d0c41ea300dfa

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/CHANGELOG.md +8 -1
  2. package/dist/assets/{Checkbox-B9Jxe8oL.js → Checkbox-CahIfM5W.js} +1 -1
  3. package/dist/assets/{MultiSelect-B-TAg0CU.js → MultiSelect-8bgTFSHE.js} +1 -1
  4. package/dist/assets/{Progress-D_6NsFIY.js → Progress-C_ubfOoo.js} +1 -1
  5. package/dist/assets/{Table-BERLrufH.js → Table-DacHD1KC.js} +1 -1
  6. package/dist/assets/{Typography-BK_FOVsg.js → Typography-DeASQdno.js} +1 -1
  7. package/dist/assets/{YearPickerInput-CCSx1WAA.js → YearPickerInput-D2YpbThb.js} +1 -1
  8. package/dist/assets/{accordion-Da7XFLSI.js → accordion-U3JJX7v1.js} +1 -1
  9. package/dist/assets/{accountant-approvals-DtDOIAls.js → accountant-approvals-BZ6rN20V.js} +1 -1
  10. package/dist/assets/{accounter-table-gSJDWOOH.js → accounter-table-C6a82w9j.js} +1 -1
  11. package/dist/assets/{addDays-CPSgiY2b.js → addDays-DY_U0JGf.js} +1 -1
  12. package/dist/assets/{all-charges-BgCCH1cQ.js → all-charges-C7hdzxH1.js} +1 -1
  13. package/dist/assets/{arrow-up-down-GSDmNUa7.js → arrow-up-down-etu82BqP.js} +1 -1
  14. package/dist/assets/{building-2-BL0OoCnC.js → building-2-BX_dGlZz.js} +1 -1
  15. package/dist/assets/{business-BMpN918H.js → business-Bhy0NR_C.js} +1 -1
  16. package/dist/assets/{business-extended-info-DCMU2tJH.js → business-extended-info-Cq6L23Gq.js} +1 -1
  17. package/dist/assets/{business-header-CbO0kf2S.js → business-header-DOLi738f.js} +1 -1
  18. package/dist/assets/{business-ledger-filters-BwSk0IIQ.js → business-ledger-filters-r96MhKju.js} +1 -1
  19. package/dist/assets/{business-ledger-single-nfPMvgv7.js → business-ledger-single-D6HhOI2M.js} +1 -1
  20. package/dist/assets/{business-trip-DJEE3jkw.js → business-trip-C-UPUfE3.js} +1 -1
  21. package/dist/assets/{charge-1v-MCcSM.js → charge-C4jlV6pl.js} +1 -1
  22. package/dist/assets/{charges-filters-DUUu6SXt.js → charges-filters-DzCr1aok.js} +1 -1
  23. package/dist/assets/{charges-ledger-validation-uQuXCk2f.js → charges-ledger-validation-CaO2LFqc.js} +1 -1
  24. package/dist/assets/{charges-table-BhJhWeOk.js → charges-table-De_dbdrN.js} +1 -1
  25. package/dist/assets/{chart-7mkwUtAi.js → chart-BlfDynnN.js} +1 -1
  26. package/dist/assets/{contracts-Cpj2Httj.js → contracts-CNRxkrnb.js} +1 -1
  27. package/dist/assets/{data-table-column-header-CXNAhFg7.js → data-table-column-header-CRDfu6Fr.js} +1 -1
  28. package/dist/assets/{data-table-pagination-CMScSWcq.js → data-table-pagination-DD-KF_1O.js} +1 -1
  29. package/dist/assets/{deposits-transactions-table-fTRP0dK3.js → deposits-transactions-table-C6kOIrVi.js} +1 -1
  30. package/dist/assets/{download-csv-button-Dv6hYXH3.js → download-csv-button-BMerplQq.js} +1 -1
  31. package/dist/assets/{editable-business-trip-CMSRoWTM.js → editable-business-trip-B1SdO1oP.js} +1 -1
  32. package/dist/assets/{eye-off-DarXeCrB.js → eye-off-V9MErBOs.js} +1 -1
  33. package/dist/assets/{funnel-Bz95UZzU.js → funnel-CJBtCNe7.js} +1 -1
  34. package/dist/assets/{index-b_B-JklH.js → index--ndCCOfW.js} +1 -1
  35. package/dist/assets/{index-CdtvgHIn.js → index-B6sRGNXq.js} +1 -1
  36. package/dist/assets/{index-CoJIQGuq.js → index-B84sRXvs.js} +1 -1
  37. package/dist/assets/{index-B1C9fgFh.js → index-BDZRPn80.js} +1 -1
  38. package/dist/assets/{index-B5PdCsXq.js → index-BJdL8zAZ.js} +1 -1
  39. package/dist/assets/{index-BntKRswi.js → index-BQxOWsaJ.js} +1 -1
  40. package/dist/assets/{index-Bxti1KtB.js → index-Bvsfs1SW.js} +1 -1
  41. package/dist/assets/{index-XRdd531Y.js → index-Bz4vno_v.js} +1 -1
  42. package/dist/assets/{index-DuOuh1g3.js → index-C-747Bll.js} +1 -1
  43. package/dist/assets/{index-Muu0tWiz.js → index-CACx2NzM.js} +1 -1
  44. package/dist/assets/{index-D0ahdEKx.js → index-COSl3OlO.js} +1 -1
  45. package/dist/assets/{index-BhHmBzLB.js → index-CVn3W44h.js} +1 -1
  46. package/dist/assets/{index-C2Vf3-xU.js → index-CWuBglfj.js} +1 -1
  47. package/dist/assets/{index-DCwv2bbD.js → index-CcPu2WaZ.js} +1 -1
  48. package/dist/assets/{index-BgwHW4Nd.js → index-ChpkVmYV.js} +1 -1
  49. package/dist/assets/{index-DMQlF8c3.js → index-CyEYueKG.js} +1 -1
  50. package/dist/assets/{index-CCsnewX5.js → index-D996b9zN.js} +1 -1
  51. package/dist/assets/{index-W0pymfZB.js → index-DFAq0WCG.js} +4 -4
  52. package/dist/assets/{index-L2Li0C19.js → index-DiSSf9rT.js} +1 -1
  53. package/dist/assets/{index-C6o95wWk.js → index-DppixdeF.js} +1 -1
  54. package/dist/assets/{index-OxXg95fa.js → index-JkFw7CSp.js} +1 -1
  55. package/dist/assets/{index-CAG0Njk5.js → index-KN86FG98.js} +1 -1
  56. package/dist/assets/{index-CK0OVeXl.js → index-R_dCmBnm.js} +1 -1
  57. package/dist/assets/{index-DdaA5b8b.js → index-X_lvrT4a.js} +1 -1
  58. package/dist/assets/{index-DCMzSE4I.js → index-jYyg3FeU.js} +1 -1
  59. package/dist/assets/{index-CdWHicsS.js → index-vrsF0A3r.js} +1 -1
  60. package/dist/assets/{index.es-CdKo0-du.js → index.es-CcDwmUIn.js} +1 -1
  61. package/dist/assets/{insert-business-trip-modal-B2i2hxuI.js → insert-business-trip-modal-GjZPaDbh.js} +1 -1
  62. package/dist/assets/issue-document-DspiXmTy.js +1 -0
  63. package/dist/assets/{list-plus-BAPfjvM-.js → list-plus-BUilO-7G.js} +1 -1
  64. package/dist/assets/{login-page-DOGQiLGy.js → login-page-BL3r9BBa.js} +1 -1
  65. package/dist/assets/{match-document-modal-DarKQJhx.js → match-document-modal-CJ4q0Q_E.js} +1 -1
  66. package/dist/assets/{missing-info-charges-DYYePYlA.js → missing-info-charges-CvMVcWLr.js} +1 -1
  67. package/dist/assets/{modal-r_uBjTC6.js → modal-BOOpXH8o.js} +1 -1
  68. package/dist/assets/{modify-contract-dialog-Zl-TSfnV.js → modify-contract-dialog-Bp_yqFgc.js} +1 -1
  69. package/dist/assets/{page-layout-BB7wmuSc.js → page-layout-C_LiLwTe.js} +1 -1
  70. package/dist/assets/{page-not-found-DvEDbWj9.js → page-not-found-B18OXwoI.js} +1 -1
  71. package/dist/assets/{panel-top-open-fWlzHeN-.js → panel-top-open-BEPaPi8H.js} +1 -1
  72. package/dist/assets/{report-commentary-row-DkKcwkwG.js → report-commentary-row-CwLb092w.js} +1 -1
  73. package/dist/assets/{save-Da7Z0tox.js → save-56syHvlw.js} +1 -1
  74. package/dist/assets/{similar-transactions-modal-BfVUcf_3.js → similar-transactions-modal-DsFhMuf5.js} +1 -1
  75. package/dist/assets/{sub-D2MOo6Sz.js → sub-BG0xrToj.js} +1 -1
  76. package/dist/assets/subMonths-C1RrVnqh.js +1 -0
  77. package/dist/assets/{summary-DPh6Auzq.js → summary-CPng7Q39.js} +1 -1
  78. package/dist/assets/{toggle-expansion-button-CGUSw3Av.js → toggle-expansion-button-CmTX8q1G.js} +1 -1
  79. package/dist/assets/{use-issue-monthly-documents-BK60cgya.js → use-issue-monthly-documents-Dmf7tls4.js} +1 -1
  80. package/dist/assets/{use-url-query-Bw2WqiC_.js → use-url-query-CmXUOAIe.js} +1 -1
  81. package/dist/index.html +1 -1
  82. package/package.json +3 -3
  83. package/dist/assets/issue-document-DOqWmjJa.js +0 -1
  84. package/dist/assets/subMonths-BN0YWd5Y.js +0 -1
@@ -1 +1 @@
1
- import{j as e,bP as D,bS as a,w as f,d6 as n,G as N,gh as v,r as d,bH as E,D as T,aL as A,B as w,x as I,bA as O,z as P,dq as L,V as M,Y as y,Z as C,_ as F,$ as V,b7 as B,a1 as g,b5 as U,au as q,F as _,aC as k,u as Q,c as $,bN as z,bO as G,bQ as o,bR as H,gi as J}from"./index-W0pymfZB.js";import{u as S}from"./use-url-query-Bw2WqiC_.js";import{P as Z}from"./page-layout-BB7wmuSc.js";import{F as K}from"./funnel-Bz95UZzU.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 X(s){return!s||O(s)?null:encodeURIComponent(JSON.stringify(s))}const b="depreciationReportFilters";function ee({filter:s,setFilter:t,close:r}){const m=P({defaultValues:{...s}}),{control:c,handleSubmit:x}=m,{selectableFinancialEntities:u,fetching:l}=L(),j=i=>{t({...i,year:Number(i.year)}),r()};return e.jsx(M,{...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(V,{children:e.jsx(B,{...i,hideControls:!0,decimalScale:0})}),e.jsx(g,{})]})}),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(g,{})]})}),e.jsx(q,{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=X(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(K,{size:20})})}),e.jsx(I,{className:"sm:max-w-[425px]",children:e.jsx(ee,{filter:s,setFilter:u,close:()=>m(!1)})})]})}const R=({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:J,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(Z,{title:"Depreciation Report",description:j,children:l?e.jsx($,{}):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(H,{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(W,{record:h},h.id)),e.jsx(R,{data:i.summary,groupName:i.category.name})]},i.id)),e.jsx(R,{data:u.depreciationReport.summary})]})})]})})};export{ne as DepreciationReport};
1
+ import{j as e,bP as D,bS as a,w as f,d6 as n,G as N,gh as v,r as d,bH as E,D as T,aL as A,B as w,x as I,bA as O,z as P,dq as L,V as M,Y as y,Z as C,_ as F,$ as V,b7 as B,a1 as g,b5 as U,au as q,F as _,aC as k,u as Q,c as $,bN as z,bO as G,bQ as o,bR as H,gi as J}from"./index-DFAq0WCG.js";import{u as S}from"./use-url-query-CmXUOAIe.js";import{P as Z}from"./page-layout-C_LiLwTe.js";import{F as K}from"./funnel-CJBtCNe7.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 X(s){return!s||O(s)?null:encodeURIComponent(JSON.stringify(s))}const b="depreciationReportFilters";function ee({filter:s,setFilter:t,close:r}){const m=P({defaultValues:{...s}}),{control:c,handleSubmit:x}=m,{selectableFinancialEntities:u,fetching:l}=L(),j=i=>{t({...i,year:Number(i.year)}),r()};return e.jsx(M,{...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(V,{children:e.jsx(B,{...i,hideControls:!0,decimalScale:0})}),e.jsx(g,{})]})}),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(g,{})]})}),e.jsx(q,{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=X(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(K,{size:20})})}),e.jsx(I,{className:"sm:max-w-[425px]",children:e.jsx(ee,{filter:s,setFilter:u,close:()=>m(!1)})})]})}const R=({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:J,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(Z,{title:"Depreciation Report",description:j,children:l?e.jsx($,{}):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(H,{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(W,{record:h},h.id)),e.jsx(R,{data:i.summary,groupName:i.category.name})]},i.id)),e.jsx(R,{data:u.depreciationReport.summary})]})})]})})};export{ne as DepreciationReport};
@@ -1 +1 @@
1
- import{j as e,Y as C,Z as p,_ as S,$ as y,b7 as w,a1 as b,I as L,g as k,io as H,r as u,t as m,i as R,D as E,aL as M,B as x,ah as _,x as T,al as A,am as $,u as P,ip as z,L as O,z as q,V as K,a9 as V,iq as Q,F as X,bX as Y,bN as Z,bO as G,bP as I,bQ as J,c1 as v,bR as W,bS as g,ir as ee,c4 as se,c3 as te,c5 as oe}from"./index-W0pymfZB.js";import{D as re}from"./data-table-pagination-CMScSWcq.js";import{P as ne}from"./page-layout-BB7wmuSc.js";import{A as D}from"./arrow-up-down-GSDmNUa7.js";function U({isInsert:s,formManager:n}){const{control:o}=n;return e.jsxs(e.Fragment,{children:[e.jsx(C,{name:"key",control:o,disabled:!s,rules:{required:"Required",validate:{positive:t=>Number(t)>0||"Key must be a positive number",integer:t=>Number.isInteger(Number(t))||"Key must be an integer"}},render:({field:t})=>e.jsxs(p,{children:[e.jsx(S,{children:"Key"}),e.jsx(y,{children:e.jsx(w,{...t,value:t.value??void 0,hideControls:!0,decimalScale:0,thousandSeparator:"",required:!0})}),e.jsx(b,{})]})}),e.jsx(C,{name:"name",control:o,rules:{required:"Required",minLength:{value:2,message:"Must be at least 2 characters"}},render:({field:t})=>e.jsxs(p,{children:[e.jsx(S,{children:"Name"}),e.jsx(y,{children:e.jsx(L,{...t,value:t.value??void 0,required:!0})}),e.jsx(b,{})]})}),e.jsx(C,{name:"defaultIrsCode",control:o,render:({field:t})=>e.jsxs(p,{children:[e.jsx(S,{children:"Default IRS Code"}),e.jsx(y,{children:e.jsx(w,{...t,value:t.value??void 0,hideControls:!0,decimalScale:0})}),e.jsx(b,{})]})})]})}const ae="updateSortCode",de=()=>{const[{fetching:s},n]=k(H),o=u.useCallback(async t=>{const d=`Error updating sort code ID [${t.key}]`,r=`${ae}-${t.key}`;m.loading("Updating Sort Code...",{id:r});try{const a=await n(t),i=R(a,d,r,"updateSortCode");if(i)return m.success("Success",{id:r,description:"SortCode updated"}),i.updateSortCode}catch(a){console.error(`${d}: ${a}`),m.error("Error",{id:r,description:d,duration:1e5,closeButton:!0})}return!1},[n]);return{fetching:s,updateSortCode:o}};function ie({sortCodeKey:s,onAdd:n}){const[o,t]=u.useState(!1);return e.jsxs(E,{open:o,onOpenChange:t,children:[e.jsx(M,{asChild:!0,children:e.jsx(x,{variant:"outline",size:"icon",children:e.jsx(_,{})})}),e.jsxs(T,{className:"w-[400px] max-w-screen-md",children:[e.jsx(A,{children:e.jsx($,{children:"Edit Sort Code"})}),e.jsx(le,{sortCodeKey:s,close:()=>t(!1),onAdd:n})]})]})}function le({sortCodeKey:s,close:n,onAdd:o}){const[{data:t,fetching:d}]=P({query:z,variables:{key:s}}),r=t?.sortCode;return!r&&!d&&m.error("Error",{description:"Couldn't find sort code"}),d?e.jsx(O,{className:"h-10 w-10 animate-spin"}):r?e.jsx(ce,{sortCode:r,close:n,onAdd:o}):e.jsx("div",{children:"Sort code not found"})}function ce({sortCode:s,close:n,onAdd:o}){const t=q({defaultValues:s}),{handleSubmit:d,formState:{dirtyFields:r}}=t,{updateSortCode:a,fetching:i}=de(),l=({key:c,...B})=>{const h=V(B,r);if(h&&Object.keys(h).length>0){let N;if(h.defaultIrsCode){const f=h.defaultIrsCode,j=Number(f);if(!Number.isInteger(j)||j<2||j>9999)throw new Error(`Invalid IRS code: ${f}`);N=j}a({fields:{...h,defaultIrsCode:N},key:s.key}).then(f=>{f&&(o?.(s.key),n())})}};return e.jsx(K,{...t,children:e.jsxs("form",{onSubmit:d(l),children:[e.jsx("div",{className:"flex flex-col gap-4 my-4",children:e.jsx(U,{isInsert:!1,formManager:t})}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx(x,{type:"submit",disabled:i,children:"Update"})})]})})}const ue="addSortCode",me=()=>{const[{fetching:s},n]=k(Q),o=u.useCallback(async t=>{const d=`Error adding new sort code [${t.name}]`,r=`${ue}-${t.name}`;m.loading("Adding sort code",{id:r});try{const a=await n(t);R(a,d,r)&&m.success("Success",{id:r,description:`"${t.name}" sort code was successfully added`})}catch(a){console.error(`${d}: ${a}`),m.error("Error",{id:r,description:d,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,addSortCode:o}};function xe({onAdd:s}){const[n,o]=u.useState(!1);return e.jsxs(E,{open:n,onOpenChange:o,children:[e.jsx(M,{asChild:!0,children:e.jsx(x,{children:"Add Sort Code"})}),e.jsxs(T,{className:"w-[90vw] max-w-screen-md",children:[e.jsx(A,{children:e.jsx($,{children:"Add New Sort Code"})}),e.jsx(he,{close:()=>o(!1),onAdd:s})]})]})}function he({close:s,onAdd:n}){const o=q({}),{handleSubmit:t}=o,{addSortCode:d,fetching:r}=me(),a=i=>{i.key&&=parseInt(i.key.toString()),i.defaultIrsCode&&=parseInt(i.defaultIrsCode.toString()),d(i).then(()=>{s(),n?.()})};return e.jsx(K,{...o,children:e.jsxs("form",{onSubmit:t(a),children:[e.jsx("div",{className:"flex flex-col gap-4 my-4",children:e.jsx(U,{isInsert:!0,formManager:o})}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx(x,{type:"submit",disabled:r,children:"Add Sort Code"})})]})})}const F=[{id:"key",accessorKey:"key",cell:({row:s})=>e.jsx(g,{children:s.original.key}),header:({column:s})=>e.jsxs(x,{variant:"ghost",onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:["Key",e.jsx(D,{})]})},{id:"name",accessorKey:"name",cell:({row:s})=>e.jsx(g,{children:s.original.name}),header:({column:s})=>e.jsxs(x,{variant:"ghost",onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:["Name",e.jsx(D,{})]})},{id:"defaultIrsCode",accessorKey:"defaultIrsCode",cell:({row:s})=>e.jsx(g,{className:"flex flex-wrap gap-1 p-1",children:s.original.defaultIrsCode&&e.jsx(x,{variant:"outline",disabled:!0,className:"p-1 w-15",children:s.original.defaultIrsCode})}),header:"Default IRS Code"},{id:"edit",cell:({row:s})=>e.jsx(ie,{sortCodeKey:s.original.key,onAdd:s.original.refetchSortCodes})}],pe=()=>{const[{data:s,fetching:n,error:o},t]=P({query:ee}),{setFiltersContext:d}=u.useContext(X),r=u.useMemo(()=>s?.allSortCodes?.map(l=>({...l,refetchSortCodes:t}))??[],[s?.allSortCodes,t]),a=Y({data:r,columns:F,getCoreRowModel:oe(),getPaginationRowModel:te(),getSortedRowModel:se(),initialState:{pagination:{pageSize:100}}}),i=a.getPageOptions();return u.useEffect(()=>{d(e.jsx("div",{className:"flex items-center justify-end gap-10 space-x-2 py-4",children:e.jsx(re,{table:a})}))},[d,a,i]),u.useEffect(()=>{o&&(console.error("Error fetching sort codes",o),m.error("Error",{description:"Error fetching sort codes"}))},[o]),e.jsx(ne,{title:`Sort Codes (${r.length})`,description:"All sort codes",headerActions:e.jsx(xe,{onAdd:()=>t()}),children:n?e.jsx("div",{className:"flex flex-row justify-center",children:e.jsx(O,{className:"h-10 w-10 animate-spin mr-2"})}):e.jsx("div",{className:"flex flex-col gap-4 rounded-md border",children:e.jsxs(Z,{children:[e.jsx(G,{children:a.getHeaderGroups().map(l=>e.jsx(I,{children:l.headers.map(c=>e.jsx(J,{children:c.isPlaceholder?null:v(c.column.columnDef.header,c.getContext())},c.id))},l.id))}),e.jsx(W,{children:a.getRowModel().rows.length===0?e.jsx(I,{children:e.jsx(g,{colSpan:F.length,className:"text-center py-8",children:"No sort codes found"})}):a.getRowModel().rows.map(l=>e.jsx(I,{children:l.getVisibleCells().map(c=>e.jsx(g,{children:v(c.column.columnDef.cell,c.getContext())},c.id))},l.id))})]})})})};export{pe as SortCodes};
1
+ import{j as e,Y as C,Z as p,_ as S,$ as y,b7 as w,a1 as b,I as L,g as k,io as H,r as u,t as m,i as R,D as E,aL as M,B as x,ah as _,x as T,al as A,am as $,u as P,ip as z,L as O,z as q,V as K,a9 as V,iq as Q,F as X,bX as Y,bN as Z,bO as G,bP as I,bQ as J,c1 as v,bR as W,bS as g,ir as ee,c4 as se,c3 as te,c5 as oe}from"./index-DFAq0WCG.js";import{D as re}from"./data-table-pagination-DD-KF_1O.js";import{P as ne}from"./page-layout-C_LiLwTe.js";import{A as D}from"./arrow-up-down-etu82BqP.js";function U({isInsert:s,formManager:n}){const{control:o}=n;return e.jsxs(e.Fragment,{children:[e.jsx(C,{name:"key",control:o,disabled:!s,rules:{required:"Required",validate:{positive:t=>Number(t)>0||"Key must be a positive number",integer:t=>Number.isInteger(Number(t))||"Key must be an integer"}},render:({field:t})=>e.jsxs(p,{children:[e.jsx(S,{children:"Key"}),e.jsx(y,{children:e.jsx(w,{...t,value:t.value??void 0,hideControls:!0,decimalScale:0,thousandSeparator:"",required:!0})}),e.jsx(b,{})]})}),e.jsx(C,{name:"name",control:o,rules:{required:"Required",minLength:{value:2,message:"Must be at least 2 characters"}},render:({field:t})=>e.jsxs(p,{children:[e.jsx(S,{children:"Name"}),e.jsx(y,{children:e.jsx(L,{...t,value:t.value??void 0,required:!0})}),e.jsx(b,{})]})}),e.jsx(C,{name:"defaultIrsCode",control:o,render:({field:t})=>e.jsxs(p,{children:[e.jsx(S,{children:"Default IRS Code"}),e.jsx(y,{children:e.jsx(w,{...t,value:t.value??void 0,hideControls:!0,decimalScale:0})}),e.jsx(b,{})]})})]})}const ae="updateSortCode",de=()=>{const[{fetching:s},n]=k(H),o=u.useCallback(async t=>{const d=`Error updating sort code ID [${t.key}]`,r=`${ae}-${t.key}`;m.loading("Updating Sort Code...",{id:r});try{const a=await n(t),i=R(a,d,r,"updateSortCode");if(i)return m.success("Success",{id:r,description:"SortCode updated"}),i.updateSortCode}catch(a){console.error(`${d}: ${a}`),m.error("Error",{id:r,description:d,duration:1e5,closeButton:!0})}return!1},[n]);return{fetching:s,updateSortCode:o}};function ie({sortCodeKey:s,onAdd:n}){const[o,t]=u.useState(!1);return e.jsxs(E,{open:o,onOpenChange:t,children:[e.jsx(M,{asChild:!0,children:e.jsx(x,{variant:"outline",size:"icon",children:e.jsx(_,{})})}),e.jsxs(T,{className:"w-[400px] max-w-screen-md",children:[e.jsx(A,{children:e.jsx($,{children:"Edit Sort Code"})}),e.jsx(le,{sortCodeKey:s,close:()=>t(!1),onAdd:n})]})]})}function le({sortCodeKey:s,close:n,onAdd:o}){const[{data:t,fetching:d}]=P({query:z,variables:{key:s}}),r=t?.sortCode;return!r&&!d&&m.error("Error",{description:"Couldn't find sort code"}),d?e.jsx(O,{className:"h-10 w-10 animate-spin"}):r?e.jsx(ce,{sortCode:r,close:n,onAdd:o}):e.jsx("div",{children:"Sort code not found"})}function ce({sortCode:s,close:n,onAdd:o}){const t=q({defaultValues:s}),{handleSubmit:d,formState:{dirtyFields:r}}=t,{updateSortCode:a,fetching:i}=de(),l=({key:c,...B})=>{const h=V(B,r);if(h&&Object.keys(h).length>0){let N;if(h.defaultIrsCode){const f=h.defaultIrsCode,j=Number(f);if(!Number.isInteger(j)||j<2||j>9999)throw new Error(`Invalid IRS code: ${f}`);N=j}a({fields:{...h,defaultIrsCode:N},key:s.key}).then(f=>{f&&(o?.(s.key),n())})}};return e.jsx(K,{...t,children:e.jsxs("form",{onSubmit:d(l),children:[e.jsx("div",{className:"flex flex-col gap-4 my-4",children:e.jsx(U,{isInsert:!1,formManager:t})}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx(x,{type:"submit",disabled:i,children:"Update"})})]})})}const ue="addSortCode",me=()=>{const[{fetching:s},n]=k(Q),o=u.useCallback(async t=>{const d=`Error adding new sort code [${t.name}]`,r=`${ue}-${t.name}`;m.loading("Adding sort code",{id:r});try{const a=await n(t);R(a,d,r)&&m.success("Success",{id:r,description:`"${t.name}" sort code was successfully added`})}catch(a){console.error(`${d}: ${a}`),m.error("Error",{id:r,description:d,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,addSortCode:o}};function xe({onAdd:s}){const[n,o]=u.useState(!1);return e.jsxs(E,{open:n,onOpenChange:o,children:[e.jsx(M,{asChild:!0,children:e.jsx(x,{children:"Add Sort Code"})}),e.jsxs(T,{className:"w-[90vw] max-w-screen-md",children:[e.jsx(A,{children:e.jsx($,{children:"Add New Sort Code"})}),e.jsx(he,{close:()=>o(!1),onAdd:s})]})]})}function he({close:s,onAdd:n}){const o=q({}),{handleSubmit:t}=o,{addSortCode:d,fetching:r}=me(),a=i=>{i.key&&=parseInt(i.key.toString()),i.defaultIrsCode&&=parseInt(i.defaultIrsCode.toString()),d(i).then(()=>{s(),n?.()})};return e.jsx(K,{...o,children:e.jsxs("form",{onSubmit:t(a),children:[e.jsx("div",{className:"flex flex-col gap-4 my-4",children:e.jsx(U,{isInsert:!0,formManager:o})}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx(x,{type:"submit",disabled:r,children:"Add Sort Code"})})]})})}const F=[{id:"key",accessorKey:"key",cell:({row:s})=>e.jsx(g,{children:s.original.key}),header:({column:s})=>e.jsxs(x,{variant:"ghost",onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:["Key",e.jsx(D,{})]})},{id:"name",accessorKey:"name",cell:({row:s})=>e.jsx(g,{children:s.original.name}),header:({column:s})=>e.jsxs(x,{variant:"ghost",onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:["Name",e.jsx(D,{})]})},{id:"defaultIrsCode",accessorKey:"defaultIrsCode",cell:({row:s})=>e.jsx(g,{className:"flex flex-wrap gap-1 p-1",children:s.original.defaultIrsCode&&e.jsx(x,{variant:"outline",disabled:!0,className:"p-1 w-15",children:s.original.defaultIrsCode})}),header:"Default IRS Code"},{id:"edit",cell:({row:s})=>e.jsx(ie,{sortCodeKey:s.original.key,onAdd:s.original.refetchSortCodes})}],pe=()=>{const[{data:s,fetching:n,error:o},t]=P({query:ee}),{setFiltersContext:d}=u.useContext(X),r=u.useMemo(()=>s?.allSortCodes?.map(l=>({...l,refetchSortCodes:t}))??[],[s?.allSortCodes,t]),a=Y({data:r,columns:F,getCoreRowModel:oe(),getPaginationRowModel:te(),getSortedRowModel:se(),initialState:{pagination:{pageSize:100}}}),i=a.getPageOptions();return u.useEffect(()=>{d(e.jsx("div",{className:"flex items-center justify-end gap-10 space-x-2 py-4",children:e.jsx(re,{table:a})}))},[d,a,i]),u.useEffect(()=>{o&&(console.error("Error fetching sort codes",o),m.error("Error",{description:"Error fetching sort codes"}))},[o]),e.jsx(ne,{title:`Sort Codes (${r.length})`,description:"All sort codes",headerActions:e.jsx(xe,{onAdd:()=>t()}),children:n?e.jsx("div",{className:"flex flex-row justify-center",children:e.jsx(O,{className:"h-10 w-10 animate-spin mr-2"})}):e.jsx("div",{className:"flex flex-col gap-4 rounded-md border",children:e.jsxs(Z,{children:[e.jsx(G,{children:a.getHeaderGroups().map(l=>e.jsx(I,{children:l.headers.map(c=>e.jsx(J,{children:c.isPlaceholder?null:v(c.column.columnDef.header,c.getContext())},c.id))},l.id))}),e.jsx(W,{children:a.getRowModel().rows.length===0?e.jsx(I,{children:e.jsx(g,{colSpan:F.length,className:"text-center py-8",children:"No sort codes found"})}):a.getRowModel().rows.map(l=>e.jsx(I,{children:l.getVisibleCells().map(c=>e.jsx(g,{children:v(c.column.columnDef.cell,c.getContext())},c.id))},l.id))})]})})})};export{pe as SortCodes};
@@ -1 +1 @@
1
- import{r,bA as w,bH as O,j as e,bB as K,B as c,aC as U,z,w as v,dq as _,V as B,dr as H,bD as D,bE as M,bF as I,Y as L,Z as q,_ as G,$ as Q,at as J,F as X,u as Y,bX as Z,L as $,ds as W,dt as ee,bN as te,bO as se,bP as S,bQ as ae,c1 as T,bR as ne,bS as k,bY as re,bZ as ie,b$ as le,c0 as oe,du as ce,c4 as de,c3 as me,c5 as ue}from"./index-W0pymfZB.js";import{u as P}from"./use-url-query-Bw2WqiC_.js";import{a as ge}from"./accounter-table-gSJDWOOH.js";import{D as he}from"./data-table-pagination-CMScSWcq.js";import{P as V}from"./modal-r_uBjTC6.js";import{P as xe}from"./page-layout-BB7wmuSc.js";import{F as pe}from"./funnel-Bz95UZzU.js";import{M as R}from"./MultiSelect-B-TAg0CU.js";import{s as je}from"./sub-D2MOo6Sz.js";import{A as b}from"./arrow-up-down-GSDmNUa7.js";import"./Table-BERLrufH.js";import"./addDays-CPSgiY2b.js";import"./subMonths-BN0YWd5Y.js";function fe({filter:t,setFilter:s,closeModal:x}){const{userContext:p}=r.useContext(U),h=z({defaultValues:{ownerIDs:p?.context.adminBusinessId?[p.context.adminBusinessId]:void 0,toDate:v(new Date,"yyyy-MM-dd"),fromDate:v(je(new Date,{years:1}),"yyyy-MM-dd"),...t}}),{control:o,handleSubmit:y}=h,{selectableFinancialEntities:i,fetching:d}=_(),C=a=>{s(a),x()};function m(){s({}),x()}return e.jsxs(e.Fragment,{children:[d?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsx(B,{...h,children:e.jsxs("form",{onSubmit:y(C),children:[e.jsxs(H,{cols:2,children:[e.jsx(D,{name:"ownerIDs",control:o,defaultValue:t.ownerIDs,render:({field:a,fieldState:g})=>e.jsx(R,{...a,data:i,value:a.value??[],disabled:d,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:g.error?.message,withinPortal:!0})}),e.jsx(D,{name:"businessIDs",control:o,defaultValue:t.businessIDs,render:({field:a,fieldState:g})=>e.jsx(R,{...a,data:i,value:a.value??[],disabled:d,label:"Financial Entities",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:g.error?.message,withinPortal:!0})}),e.jsx(D,{name:"fromDate",control:o,defaultValue:t.fromDate,rules:{pattern:{value:M,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:g})=>e.jsx(I,{...a,onChange:l=>{const j=l?typeof l=="string"?l:v(l,"yyyy-MM-dd"):void 0;j!==a.value&&a.onChange(j)},value:a.value?new Date(a.value):void 0,error:g.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(D,{name:"toDate",control:o,defaultValue:t.toDate,rules:{pattern:{value:M,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:g})=>e.jsx(I,{...a,onChange:l=>{const j=l?typeof l=="string"?l:v(l,"yyyy-MM-dd"):void 0;j!==a.value&&a.onChange(j)},value:a.value?new Date(a.value):void 0,error:g.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(L,{name:"unmatched",control:o,render:({field:a})=>e.jsxs(q,{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(G,{children:"Unmatched only"})}),e.jsx(Q,{children:e.jsx(J,{defaultChecked:t.unmatched??!1,onCheckedChange:a.onChange})})]})})]}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",disabled:d,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:m,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:x,children:"Cancel"})]})]})})]})}function be({filter:t={},setFilter:s,initiallyOpened:x=!1}){const[p,h]=r.useState(x),[o,y]=r.useState(!w(t)),{get:i,set:d}=P();r.useEffect(()=>{const m=w(t)?null:encodeURIComponent(JSON.stringify(t)),a=i("documentsFilters");m!==a&&d("documentsFilters",m)},[t,i,d]);const C=r.useCallback(m=>{O(m,t)||(s(m),y(!w(m)))},[t,s]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(V,{opened:p,onClose:()=>h(!1),content:e.jsx(fe,{filter:t,setFilter:C,closeModal:()=>h(!1)}),modalSize:"xl"}),e.jsx(K,{inline:!0,size:16,disabled:!o,children:e.jsx(c,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>h(!0),children:e.jsx(pe,{className:"size-5"})})})]})}const E=[{accessorKey:"__typename",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Type"}),e.jsx(b,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>{const{__typename:s}=t.original;return e.jsx("div",{className:"text-left font-medium",children:s})}},{accessorKey:"image",header:()=>e.jsx("div",{className:"text-left",children:"Image"}),cell:({row:t})=>{const{image:s}=t.original;return e.jsx("div",{className:"text-left font-medium",children:s?e.jsx("img",{alt:"missing img",src:s?.toString(),height:80,width:80}):"No image"})}},{accessorKey:"file",header:()=>e.jsx("div",{className:"text-left",children:"File"}),cell:({row:t})=>{const{file:s}=t.original;return e.jsx("div",{className:"text-left font-medium",children:s&&e.jsx(c,{variant:"outline",size:"sm",asChild:!0,children:e.jsx("a",{target:"_blank",rel:"noreferrer",href:s?.toString(),children:"Open"})})})}},{accessorKey:"date",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Date"}),e.jsx(b,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"date"in t.original&&t.original.date?e.jsx("div",{className:"text-left font-medium",children:v(new Date(t.original.date),"dd/MM/yy")}):null},{accessorKey:"serialNumber",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Serial Number"}),e.jsx(b,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"serialNumber"in t.original&&t.original.serialNumber?e.jsx("div",{className:"text-left font-medium",children:t.original.serialNumber}):null},{accessorKey:"vat.raw",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"VAT"}),e.jsx(b,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"vat"in t.original&&t.original.vat?.formatted?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.vat.formatted}):null},{accessorKey:"amount.raw",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Amount"}),e.jsx(b,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"amount"in t.original&&t.original.amount?.formatted?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.amount.formatted}):null},{accessorKey:"creditor.name",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Creditor"}),e.jsx(b,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"creditor"in t.original&&t.original.creditor?.name?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.creditor.name}):null},{accessorKey:"debtor.name",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Debtor"}),e.jsx(b,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"debtor"in t.original&&t.original.debtor?.name?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.debtor.name}):null},{accessorKey:"charge.transactions[0].id",header:()=>e.jsx("div",{className:"text-left",children:"Related Transaction"}),cell:({row:t})=>t.original.charge?.transactions?.[0]?.id?e.jsx(ge,{items:t.original.charge?.transactions??[],columns:[{title:"Transaction Amount",value:s=>s?.amount.formatted},{title:"Transaction Created At",value:s=>s?.eventDate?v(new Date(s.eventDate),"dd/MM/yy"):null},{title:"Transaction Effective Date",value:s=>s?.effectiveDate?v(new Date(s.effectiveDate),"dd/MM/yy"):null},{title:"Transaction Description",value:s=>s?.sourceDescription}]}):"No Related Transaction"}],Ee=()=>{const[t,s]=r.useState(null),[x,p]=r.useState(!1),{get:h}=P(),o=h("documentsFilters"),y=r.useMemo(()=>{if(o)try{return JSON.parse(decodeURIComponent(o))}catch{return}},[o]),[i,d]=r.useState(y),[C,m]=r.useState([]),[a,g]=r.useState({}),{setFiltersContext:l}=r.useContext(X),[{data:j,fetching:F},N]=Y({query:ce,variables:{filters:i??{}},pause:!0});r.useEffect(()=>{i&&N()},[i,N]);const f=Z({data:j?.documentsByFilters??[],columns:E,getCoreRowModel:ue(),getPaginationRowModel:me(),onSortingChange:m,getSortedRowModel:de(),onColumnVisibilityChange:g,state:{sorting:C,columnVisibility:a}}),A=f.getState().pagination.pageIndex;return r.useEffect(()=>{l(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(he,{table:f}),e.jsx(be,{filter:i,setFilter:d,initiallyOpened:!i})]}))},[f,F,i,l,d,y,A]),e.jsx(xe,{title:"Documents",description:"All documents",headerActions:e.jsxs("div",{className:"flex items-center py-4 gap-4",children:[e.jsxs(re,{children:[e.jsx(ie,{asChild:!0,children:e.jsx(c,{className:"ml-auto",children:"Columns"})}),e.jsx(le,{align:"end",children:f.getAllColumns().filter(n=>n.getCanHide()).map(n=>e.jsx(oe,{className:"capitalize",checked:n.getIsVisible(),onCheckedChange:u=>n.toggleVisibility(!!u),children:n.id},n.id))})]}),e.jsx(c,{onClick:()=>p(!0),children:"Upload Documents"})]}),children:F?e.jsx($,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs(e.Fragment,{children:[e.jsx(W,{open:x,onOpenChange:p,onChange:N}),t&&e.jsx(V,{modalSize:"45%",content:e.jsx(ee,{src:t}),opened:!!t,onClose:()=>s(null)}),e.jsxs(te,{children:[e.jsx(se,{children:f.getHeaderGroups().map(n=>e.jsx(S,{children:n.headers.map(u=>e.jsx(ae,{children:u.isPlaceholder?null:T(u.column.columnDef.header,u.getContext())},u.id))},n.id))}),e.jsx(ne,{children:f.getRowModel().rows?.length?f.getRowModel().rows.map(n=>e.jsx(S,{"data-state":n.getIsSelected()&&"selected",children:n.getVisibleCells().map(u=>e.jsx(k,{children:T(u.column.columnDef.cell,u.getContext())},u.id))},n.id)):e.jsx(S,{children:e.jsx(k,{colSpan:E.length,className:"h-24 text-center",children:"No results."})})})]})]})})};export{Ee as DocumentsReport,E as columns};
1
+ import{r,bA as w,bH as O,j as e,bB as K,B as c,aC as U,z,w as v,dq as _,V as B,dr as H,bD as D,bE as M,bF as I,Y as L,Z as q,_ as G,$ as Q,at as J,F as X,u as Y,bX as Z,L as $,ds as W,dt as ee,bN as te,bO as se,bP as S,bQ as ae,c1 as T,bR as ne,bS as k,bY as re,bZ as ie,b$ as le,c0 as oe,du as ce,c4 as de,c3 as me,c5 as ue}from"./index-DFAq0WCG.js";import{u as P}from"./use-url-query-CmXUOAIe.js";import{a as ge}from"./accounter-table-C6a82w9j.js";import{D as he}from"./data-table-pagination-DD-KF_1O.js";import{P as V}from"./modal-BOOpXH8o.js";import{P as xe}from"./page-layout-C_LiLwTe.js";import{F as pe}from"./funnel-CJBtCNe7.js";import{M as R}from"./MultiSelect-8bgTFSHE.js";import{s as je}from"./sub-BG0xrToj.js";import{A as b}from"./arrow-up-down-etu82BqP.js";import"./Table-DacHD1KC.js";import"./addDays-DY_U0JGf.js";import"./subMonths-C1RrVnqh.js";function fe({filter:t,setFilter:s,closeModal:x}){const{userContext:p}=r.useContext(U),h=z({defaultValues:{ownerIDs:p?.context.adminBusinessId?[p.context.adminBusinessId]:void 0,toDate:v(new Date,"yyyy-MM-dd"),fromDate:v(je(new Date,{years:1}),"yyyy-MM-dd"),...t}}),{control:o,handleSubmit:y}=h,{selectableFinancialEntities:i,fetching:d}=_(),C=a=>{s(a),x()};function m(){s({}),x()}return e.jsxs(e.Fragment,{children:[d?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsx(B,{...h,children:e.jsxs("form",{onSubmit:y(C),children:[e.jsxs(H,{cols:2,children:[e.jsx(D,{name:"ownerIDs",control:o,defaultValue:t.ownerIDs,render:({field:a,fieldState:g})=>e.jsx(R,{...a,data:i,value:a.value??[],disabled:d,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:g.error?.message,withinPortal:!0})}),e.jsx(D,{name:"businessIDs",control:o,defaultValue:t.businessIDs,render:({field:a,fieldState:g})=>e.jsx(R,{...a,data:i,value:a.value??[],disabled:d,label:"Financial Entities",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:g.error?.message,withinPortal:!0})}),e.jsx(D,{name:"fromDate",control:o,defaultValue:t.fromDate,rules:{pattern:{value:M,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:g})=>e.jsx(I,{...a,onChange:l=>{const j=l?typeof l=="string"?l:v(l,"yyyy-MM-dd"):void 0;j!==a.value&&a.onChange(j)},value:a.value?new Date(a.value):void 0,error:g.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(D,{name:"toDate",control:o,defaultValue:t.toDate,rules:{pattern:{value:M,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:g})=>e.jsx(I,{...a,onChange:l=>{const j=l?typeof l=="string"?l:v(l,"yyyy-MM-dd"):void 0;j!==a.value&&a.onChange(j)},value:a.value?new Date(a.value):void 0,error:g.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(L,{name:"unmatched",control:o,render:({field:a})=>e.jsxs(q,{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(G,{children:"Unmatched only"})}),e.jsx(Q,{children:e.jsx(J,{defaultChecked:t.unmatched??!1,onCheckedChange:a.onChange})})]})})]}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",disabled:d,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:m,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:x,children:"Cancel"})]})]})})]})}function be({filter:t={},setFilter:s,initiallyOpened:x=!1}){const[p,h]=r.useState(x),[o,y]=r.useState(!w(t)),{get:i,set:d}=P();r.useEffect(()=>{const m=w(t)?null:encodeURIComponent(JSON.stringify(t)),a=i("documentsFilters");m!==a&&d("documentsFilters",m)},[t,i,d]);const C=r.useCallback(m=>{O(m,t)||(s(m),y(!w(m)))},[t,s]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(V,{opened:p,onClose:()=>h(!1),content:e.jsx(fe,{filter:t,setFilter:C,closeModal:()=>h(!1)}),modalSize:"xl"}),e.jsx(K,{inline:!0,size:16,disabled:!o,children:e.jsx(c,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>h(!0),children:e.jsx(pe,{className:"size-5"})})})]})}const E=[{accessorKey:"__typename",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Type"}),e.jsx(b,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>{const{__typename:s}=t.original;return e.jsx("div",{className:"text-left font-medium",children:s})}},{accessorKey:"image",header:()=>e.jsx("div",{className:"text-left",children:"Image"}),cell:({row:t})=>{const{image:s}=t.original;return e.jsx("div",{className:"text-left font-medium",children:s?e.jsx("img",{alt:"missing img",src:s?.toString(),height:80,width:80}):"No image"})}},{accessorKey:"file",header:()=>e.jsx("div",{className:"text-left",children:"File"}),cell:({row:t})=>{const{file:s}=t.original;return e.jsx("div",{className:"text-left font-medium",children:s&&e.jsx(c,{variant:"outline",size:"sm",asChild:!0,children:e.jsx("a",{target:"_blank",rel:"noreferrer",href:s?.toString(),children:"Open"})})})}},{accessorKey:"date",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Date"}),e.jsx(b,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"date"in t.original&&t.original.date?e.jsx("div",{className:"text-left font-medium",children:v(new Date(t.original.date),"dd/MM/yy")}):null},{accessorKey:"serialNumber",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Serial Number"}),e.jsx(b,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"serialNumber"in t.original&&t.original.serialNumber?e.jsx("div",{className:"text-left font-medium",children:t.original.serialNumber}):null},{accessorKey:"vat.raw",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"VAT"}),e.jsx(b,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"vat"in t.original&&t.original.vat?.formatted?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.vat.formatted}):null},{accessorKey:"amount.raw",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Amount"}),e.jsx(b,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"amount"in t.original&&t.original.amount?.formatted?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.amount.formatted}):null},{accessorKey:"creditor.name",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Creditor"}),e.jsx(b,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"creditor"in t.original&&t.original.creditor?.name?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.creditor.name}):null},{accessorKey:"debtor.name",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Debtor"}),e.jsx(b,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"debtor"in t.original&&t.original.debtor?.name?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.debtor.name}):null},{accessorKey:"charge.transactions[0].id",header:()=>e.jsx("div",{className:"text-left",children:"Related Transaction"}),cell:({row:t})=>t.original.charge?.transactions?.[0]?.id?e.jsx(ge,{items:t.original.charge?.transactions??[],columns:[{title:"Transaction Amount",value:s=>s?.amount.formatted},{title:"Transaction Created At",value:s=>s?.eventDate?v(new Date(s.eventDate),"dd/MM/yy"):null},{title:"Transaction Effective Date",value:s=>s?.effectiveDate?v(new Date(s.effectiveDate),"dd/MM/yy"):null},{title:"Transaction Description",value:s=>s?.sourceDescription}]}):"No Related Transaction"}],Ee=()=>{const[t,s]=r.useState(null),[x,p]=r.useState(!1),{get:h}=P(),o=h("documentsFilters"),y=r.useMemo(()=>{if(o)try{return JSON.parse(decodeURIComponent(o))}catch{return}},[o]),[i,d]=r.useState(y),[C,m]=r.useState([]),[a,g]=r.useState({}),{setFiltersContext:l}=r.useContext(X),[{data:j,fetching:F},N]=Y({query:ce,variables:{filters:i??{}},pause:!0});r.useEffect(()=>{i&&N()},[i,N]);const f=Z({data:j?.documentsByFilters??[],columns:E,getCoreRowModel:ue(),getPaginationRowModel:me(),onSortingChange:m,getSortedRowModel:de(),onColumnVisibilityChange:g,state:{sorting:C,columnVisibility:a}}),A=f.getState().pagination.pageIndex;return r.useEffect(()=>{l(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(he,{table:f}),e.jsx(be,{filter:i,setFilter:d,initiallyOpened:!i})]}))},[f,F,i,l,d,y,A]),e.jsx(xe,{title:"Documents",description:"All documents",headerActions:e.jsxs("div",{className:"flex items-center py-4 gap-4",children:[e.jsxs(re,{children:[e.jsx(ie,{asChild:!0,children:e.jsx(c,{className:"ml-auto",children:"Columns"})}),e.jsx(le,{align:"end",children:f.getAllColumns().filter(n=>n.getCanHide()).map(n=>e.jsx(oe,{className:"capitalize",checked:n.getIsVisible(),onCheckedChange:u=>n.toggleVisibility(!!u),children:n.id},n.id))})]}),e.jsx(c,{onClick:()=>p(!0),children:"Upload Documents"})]}),children:F?e.jsx($,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs(e.Fragment,{children:[e.jsx(W,{open:x,onOpenChange:p,onChange:N}),t&&e.jsx(V,{modalSize:"45%",content:e.jsx(ee,{src:t}),opened:!!t,onClose:()=>s(null)}),e.jsxs(te,{children:[e.jsx(se,{children:f.getHeaderGroups().map(n=>e.jsx(S,{children:n.headers.map(u=>e.jsx(ae,{children:u.isPlaceholder?null:T(u.column.columnDef.header,u.getContext())},u.id))},n.id))}),e.jsx(ne,{children:f.getRowModel().rows?.length?f.getRowModel().rows.map(n=>e.jsx(S,{"data-state":n.getIsSelected()&&"selected",children:n.getVisibleCells().map(u=>e.jsx(k,{children:T(u.column.columnDef.cell,u.getContext())},u.id))},n.id)):e.jsx(S,{children:e.jsx(k,{colSpan:E.length,className:"h-24 text-center",children:"No results."})})})]})]})})};export{Ee as DocumentsReport,E as columns};
@@ -1 +1 @@
1
- import{v as U,r as d,j as e,G as p,B as g,e7 as H,e8 as _,e9 as q,d6 as I,ea as M,eb as Q,ec as J,ed as $,ee as Y,ef as K,eg as W,u as E,t as X,eh as Z,T as ee,ei as te,aC as T,bA as se,z as ae,ej as ne,bD as A,bG as S,ek as D,bM as re,w as N,bH as oe,F as ie,L as ce,el as le}from"./index-W0pymfZB.js";import{d as R}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{u as z}from"./use-url-query-Bw2WqiC_.js";import{C as F,u as de,a as V,b as k,M as he}from"./charges-table-BhJhWeOk.js";import{E as me,I as xe,M as ue}from"./match-document-modal-DarKQJhx.js";import{P as pe}from"./page-layout-BB7wmuSc.js";import{P as v,a as w}from"./panel-top-open-fWlzHeN-.js";import{T as O}from"./toggle-expansion-button-CGUSw3Av.js";import{T as B}from"./Table-BERLrufH.js";import{c as ge}from"./charges-filters-DUUu6SXt.js";import{P as je}from"./modal-r_uBjTC6.js";import{F as fe}from"./funnel-Bz95UZzU.js";import"./index-L2Li0C19.js";import"./similar-transactions-modal-BfVUcf_3.js";import"./addDays-CPSgiY2b.js";import"./list-plus-BAPfjvM-.js";import"./summary-DPh6Auzq.js";import"./deposits-transactions-table-fTRP0dK3.js";import"./Checkbox-B9Jxe8oL.js";import"./accordion-Da7XFLSI.js";import"./data-table-column-header-CXNAhFg7.js";import"./eye-off-DarXeCrB.js";import"./YearPickerInput-CCSx1WAA.js";import"./insert-business-trip-modal-B2i2hxuI.js";import"./accounter-table-gSJDWOOH.js";import"./sub-D2MOo6Sz.js";import"./subMonths-BN0YWd5Y.js";import"./MultiSelect-B-TAg0CU.js";const ye=[["path",{d:"M4 12V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2",key:"jrl274"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 16h2v6",key:"1bxocy"}],["path",{d:"M10 22h4",key:"ceow96"}],["rect",{x:"2",y:"16",width:"4",height:"6",rx:"2",key:"r45zd0"}]],ve=U("file-digit",ye),we=({data:n,setEditCharge:l,setInsertDocument:o,setMatchDocuments:a,toggleMergeCharge:i,mergeSelectedCharges:r})=>{const s=p(H,n),[t,c]=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:()=>c(h=>!h),children:t?e.jsx(v,{className:"size-5"}):e.jsx(w,{className:"size-5"})}),"Business Trips"]}),t&&s&&e.jsx(F,{setEditChargeId:l,setInsertDocument:o,setMatchDocuments:a,data:s.businessTrips,isAllOpened:!1,toggleMergeCharge:i,mergeSelectedCharges:r})]})};function P({data:n}){const{chargeId:l,chargeAccountantStatus:o}=p(_,n),{updateChargeAccountantApproval:a}=de();return e.jsx("td",{children:e.jsx(q,{value:o??void 0,onChange:i=>a({chargeId:l,status:i})})})}const be=({data:n,toggleMergeCharge:l,mergeSelectedCharges:o,cumulativeVat:a,cumulativeAmount:i})=>{const[r,s]=d.useState(!1),t=p(Q,n);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:["₪ ",I(a,0)]}),e.jsxs("td",{className:"whitespace-nowrap",children:["₪ ",I(i,0)]}),e.jsx(P,{data:t}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx(O,{toggleExpansion:s,isExpanded:r})})}),e.jsx("td",{children:e.jsx(V,{toggleMergeSelected:()=>l(t.chargeId),mergeSelected:o.includes(t.chargeId)})})]}),r&&e.jsx("tr",{children:e.jsx("td",{colSpan:17,children:e.jsx(M,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:e.jsx(k,{chargeID:t.chargeId,fetching:!!t})})})})]})},Ce=({data:n,toggleMergeCharge:l,mergeSelectedCharges:o})=>{const{expenses:a}=p(J,n)??{expenses:[]},[i,r]=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:()=>r(c=>!c),children:i?e.jsx(v,{className:"size-5"}):e.jsx(w,{className:"size-5"})}),"Expenses"]}),i&&e.jsxs(B,{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:a.map((c,h)=>{s+=c.taxReducedLocalAmount?.raw??0;const u=s;t+=c.roundedLocalVatAfterDeduction?.raw??0;const m=t;return e.jsx(be,{data:c,toggleMergeCharge:l,mergeSelectedCharges:o,cumulativeVat:m,cumulativeAmount:u},h)})})]})]})},Ie=({data:n,toggleMergeCharge:l,mergeSelectedCharges:o,cumulativeAmount:a})=>{const[i,r]=d.useState(!1),s=p($,n);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:"₪ "+I(a,0)}),e.jsx(P,{data:s}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx(O,{toggleExpansion:r,isExpanded:i})})}),e.jsx("td",{children:e.jsx(V,{toggleMergeSelected:()=>l(s.chargeId),mergeSelected:o.includes(s.chargeId)})})]}),i&&e.jsx("tr",{children:e.jsx("td",{colSpan:11,children:e.jsx(M,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:e.jsx(k,{chargeID:s.chargeId,fetching:!!s})})})})]})},De=({data:n,toggleMergeCharge:l,mergeSelectedCharges:o})=>{const{income:a}=p(Y,n)??{income:[]},[i,r]=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:()=>r(t=>!t),children:i?e.jsx(v,{className:"size-5"}):e.jsx(w,{className:"size-5"})}),"Income"]}),i&&e.jsxs(B,{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:a.map((t,c)=>{s+=t.taxReducedLocalAmount?.raw??0;const h=s;return e.jsx(Ie,{data:t,toggleMergeCharge:l,mergeSelectedCharges:o,cumulativeAmount:h},c)})})]})]})},Ne=({data:n,setEditCharge:l,setInsertDocument:o,setMatchDocuments:a,toggleMergeCharge:i,mergeSelectedCharges:r})=>{const s=p(K,n),[t,c]=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:()=>c(h=>!h),children:t?e.jsx(v,{className:"size-5"}):e.jsx(w,{className:"size-5"})}),"Misc Charges (which are not on the above tables)"]}),t&&s&&e.jsx(F,{setEditChargeId:l,setInsertDocument:o,setMatchDocuments:a,data:s.differentMonthDoc,isAllOpened:!1,toggleMergeCharge:i,mergeSelectedCharges:r})]})},Fe=({data:n,setEditCharge:l,setInsertDocument:o,setMatchDocuments:a,toggleMergeCharge:i,mergeSelectedCharges:r})=>{const s=p(W,n),[t,c]=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:()=>c(h=>!h),children:t?e.jsx(v,{className:"size-5"}):e.jsx(w,{className:"size-5"})}),"Missing Info"]}),t&&s&&e.jsx(F,{setEditChargeId:l,setInsertDocument:o,setMatchDocuments:a,data:s.missingInfo,isAllOpened:!1,toggleMergeCharge:i,mergeSelectedCharges:r})]})},Ae=({filter:{monthDate:n,financialEntityId:l},isLoading:o})=>{const[{data:a,fetching:i,error:r},s]=E({query:R(te),pause:!0,variables:{monthDate:n,financialEntityId:l}});return d.useEffect(()=>{if(r){const t="Error generating PCN874 file";console.error(`${t}: ${r}`),X.error("Error",{description:t,duration:5e3,closeButton:!0})}},[r]),d.useEffect(()=>{if(a){const t=new File([a.pcnFile.reportContent],"pcn874.txt",{type:"text/plain"});Z(t)}},[a]),e.jsx(ee,{content:"Generate and Download PCN874 File",children:e.jsx(g,{disabled:i||o,variant:"outline",size:"icon",className:"size-7.5",onClick:s,children:e.jsx(ve,{className:"size-5"})})})};function Se({filter:n,setFilter:l,closeModal:o}){const{control:a,handleSubmit:i,setValue:r}=ae({defaultValues:{...n}}),{selectableAdminBusinesses:s,fetching:t}=ne(),c=m=>{l(m),o()};function h(){l(),o()}function u(m){const x=new Date(m.getFullYear(),m.getMonth(),15);r("monthDate",N(x,"yyyy-MM-dd"))}return e.jsxs(e.Fragment,{children:[t?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsxs("form",{onSubmit:i(c),children:[e.jsx(A,{name:"financialEntityId",control:a,defaultValue:void 0,render:({field:m,fieldState:x})=>e.jsx(S,{...m,data:s,value:m.value,disabled:t,label:"Report Issuer (Admin Business)",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:x.error?.message})}),e.jsx(A,{name:"chargesType",control:a,defaultValue:n.chargesType,render:({field:m,fieldState:x})=>e.jsx(S,{...m,data:ge,value:m.value??D.All,label:"Charge Type",placeholder:"Filter income/expense",maxDropdownHeight:160,error:x.error?.message})}),e.jsx(re,{defaultValue:n?.monthDate?new Date(n.monthDate):new Date,defaultDate:n?.monthDate?new Date(n.monthDate):new Date,onChange:u,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:o,children:"Cancel"})]})]})]})}function Me({filter:n,setFilter:l}){const[o,a]=d.useState(!1),{get:i,set:r}=z(),{userContext:s}=d.useContext(T);function t(c){c||={financialEntityId:s?.context.adminBusinessId??n.financialEntityId,monthDate:N(new Date,"yyyy-MM-15")},oe(c,n)||l(c)}return d.useEffect(()=>{const c=se(n??{})?null:encodeURIComponent(JSON.stringify(n)),h=i("vatMonthlyReportFilters");c!==h&&r("vatMonthlyReportFilters",c)},[n,i,r]),e.jsxs(e.Fragment,{children:[e.jsx(je,{opened:o,onClose:()=>a(!1),content:e.jsx(Se,{filter:n,setFilter:t,closeModal:()=>a(!1)})}),e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>a(!0),children:e.jsx(fe,{className:"size-5"})})]})}const rt=()=>{const{get:n}=z(),{setFiltersContext:l}=d.useContext(ie),{userContext:o}=d.useContext(T),[a,i]=d.useState(n("vatMonthlyReportFilters")?JSON.parse(decodeURIComponent(n("vatMonthlyReportFilters"))):{financialEntityId:o?.context.adminBusinessId??"",monthDate:N(new Date,"yyyy-MM-15")}),[r,s]=d.useState([]);d.useEffect(()=>{(!a.financialEntityId||a.financialEntityId==="")&&o?.context.adminBusinessId&&i({...a,financialEntityId:o.context.adminBusinessId})},[a,o?.context.adminBusinessId]);const[t,c]=d.useState(void 0),[h,u]=d.useState(void 0),[m,x]=d.useState(void 0),[{data:j,fetching:b}]=E({query:R(le),variables:{filters:a},pause:a.financialEntityId===""}),f=d.useCallback(y=>{r.includes(y)?s(r.filter(G=>G!==y)):s([...r,y])},[r]);function L(){s([])}d.useEffect(()=>{l(e.jsxs("div",{className:"flex flex-row gap-2",children:[e.jsx(Ae,{filter:a,isLoading:b}),e.jsx(Me,{filter:{...a},setFilter:i}),e.jsx(he,{selected:r.map(y=>({id:y,onChange:()=>{}})),resetMerge:L})]}))},[j,a,b,l,r]);const C=d.useMemo(()=>new Set(r),[r]);return e.jsx(pe,{title:"VAT Monthly Report",children:b?e.jsx(ce,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs("div",{className:"flex flex-col gap-4",children:[a.chargesType!==D.Expense&&e.jsx(De,{data:j?.vatReport,toggleMergeCharge:f,mergeSelectedCharges:r}),a.chargesType!==D.Income&&e.jsx(Ce,{data:j?.vatReport,toggleMergeCharge:f,mergeSelectedCharges:r}),e.jsx(Fe,{data:j?.vatReport,setEditCharge:x,setInsertDocument:c,setMatchDocuments:u,toggleMergeCharge:f,mergeSelectedCharges:C}),e.jsx(we,{data:j?.vatReport,setEditCharge:x,setInsertDocument:c,setMatchDocuments:u,toggleMergeCharge:f,mergeSelectedCharges:C}),e.jsx(Ne,{data:j?.vatReport,setEditCharge:x,setInsertDocument:c,setMatchDocuments:u,toggleMergeCharge:f,mergeSelectedCharges:C}),m&&e.jsx(me,{chargeId:m.id,close:()=>x(void 0)}),t&&e.jsx(xe,{chargeId:t.id,close:()=>c(void 0)}),h&&e.jsx(ue,{chargeId:h.id,ownerId:h.ownerId,setMatchDocuments:()=>u(void 0)})]})})};export{rt as VatMonthlyReport};
1
+ import{v as U,r as d,j as e,G as p,B as g,e7 as H,e8 as _,e9 as q,d6 as I,ea as M,eb as Q,ec as J,ed as $,ee as Y,ef as K,eg as W,u as E,t as X,eh as Z,T as ee,ei as te,aC as T,bA as se,z as ae,ej as ne,bD as A,bG as S,ek as D,bM as re,w as N,bH as oe,F as ie,L as ce,el as le}from"./index-DFAq0WCG.js";import{d as R}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{u as z}from"./use-url-query-CmXUOAIe.js";import{C as F,u as de,a as V,b as k,M as he}from"./charges-table-De_dbdrN.js";import{E as me,I as xe,M as ue}from"./match-document-modal-CJ4q0Q_E.js";import{P as pe}from"./page-layout-C_LiLwTe.js";import{P as v,a as w}from"./panel-top-open-BEPaPi8H.js";import{T as O}from"./toggle-expansion-button-CmTX8q1G.js";import{T as B}from"./Table-DacHD1KC.js";import{c as ge}from"./charges-filters-DzCr1aok.js";import{P as je}from"./modal-BOOpXH8o.js";import{F as fe}from"./funnel-CJBtCNe7.js";import"./index-DiSSf9rT.js";import"./similar-transactions-modal-DsFhMuf5.js";import"./addDays-DY_U0JGf.js";import"./list-plus-BUilO-7G.js";import"./summary-CPng7Q39.js";import"./deposits-transactions-table-C6kOIrVi.js";import"./Checkbox-CahIfM5W.js";import"./accordion-U3JJX7v1.js";import"./data-table-column-header-CRDfu6Fr.js";import"./eye-off-V9MErBOs.js";import"./YearPickerInput-D2YpbThb.js";import"./insert-business-trip-modal-GjZPaDbh.js";import"./accounter-table-C6a82w9j.js";import"./sub-BG0xrToj.js";import"./subMonths-C1RrVnqh.js";import"./MultiSelect-8bgTFSHE.js";const ye=[["path",{d:"M4 12V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2",key:"jrl274"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 16h2v6",key:"1bxocy"}],["path",{d:"M10 22h4",key:"ceow96"}],["rect",{x:"2",y:"16",width:"4",height:"6",rx:"2",key:"r45zd0"}]],ve=U("file-digit",ye),we=({data:n,setEditCharge:l,setInsertDocument:o,setMatchDocuments:a,toggleMergeCharge:i,mergeSelectedCharges:r})=>{const s=p(H,n),[t,c]=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:()=>c(h=>!h),children:t?e.jsx(v,{className:"size-5"}):e.jsx(w,{className:"size-5"})}),"Business Trips"]}),t&&s&&e.jsx(F,{setEditChargeId:l,setInsertDocument:o,setMatchDocuments:a,data:s.businessTrips,isAllOpened:!1,toggleMergeCharge:i,mergeSelectedCharges:r})]})};function P({data:n}){const{chargeId:l,chargeAccountantStatus:o}=p(_,n),{updateChargeAccountantApproval:a}=de();return e.jsx("td",{children:e.jsx(q,{value:o??void 0,onChange:i=>a({chargeId:l,status:i})})})}const be=({data:n,toggleMergeCharge:l,mergeSelectedCharges:o,cumulativeVat:a,cumulativeAmount:i})=>{const[r,s]=d.useState(!1),t=p(Q,n);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:["₪ ",I(a,0)]}),e.jsxs("td",{className:"whitespace-nowrap",children:["₪ ",I(i,0)]}),e.jsx(P,{data:t}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx(O,{toggleExpansion:s,isExpanded:r})})}),e.jsx("td",{children:e.jsx(V,{toggleMergeSelected:()=>l(t.chargeId),mergeSelected:o.includes(t.chargeId)})})]}),r&&e.jsx("tr",{children:e.jsx("td",{colSpan:17,children:e.jsx(M,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:e.jsx(k,{chargeID:t.chargeId,fetching:!!t})})})})]})},Ce=({data:n,toggleMergeCharge:l,mergeSelectedCharges:o})=>{const{expenses:a}=p(J,n)??{expenses:[]},[i,r]=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:()=>r(c=>!c),children:i?e.jsx(v,{className:"size-5"}):e.jsx(w,{className:"size-5"})}),"Expenses"]}),i&&e.jsxs(B,{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:a.map((c,h)=>{s+=c.taxReducedLocalAmount?.raw??0;const u=s;t+=c.roundedLocalVatAfterDeduction?.raw??0;const m=t;return e.jsx(be,{data:c,toggleMergeCharge:l,mergeSelectedCharges:o,cumulativeVat:m,cumulativeAmount:u},h)})})]})]})},Ie=({data:n,toggleMergeCharge:l,mergeSelectedCharges:o,cumulativeAmount:a})=>{const[i,r]=d.useState(!1),s=p($,n);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:"₪ "+I(a,0)}),e.jsx(P,{data:s}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx(O,{toggleExpansion:r,isExpanded:i})})}),e.jsx("td",{children:e.jsx(V,{toggleMergeSelected:()=>l(s.chargeId),mergeSelected:o.includes(s.chargeId)})})]}),i&&e.jsx("tr",{children:e.jsx("td",{colSpan:11,children:e.jsx(M,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:e.jsx(k,{chargeID:s.chargeId,fetching:!!s})})})})]})},De=({data:n,toggleMergeCharge:l,mergeSelectedCharges:o})=>{const{income:a}=p(Y,n)??{income:[]},[i,r]=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:()=>r(t=>!t),children:i?e.jsx(v,{className:"size-5"}):e.jsx(w,{className:"size-5"})}),"Income"]}),i&&e.jsxs(B,{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:a.map((t,c)=>{s+=t.taxReducedLocalAmount?.raw??0;const h=s;return e.jsx(Ie,{data:t,toggleMergeCharge:l,mergeSelectedCharges:o,cumulativeAmount:h},c)})})]})]})},Ne=({data:n,setEditCharge:l,setInsertDocument:o,setMatchDocuments:a,toggleMergeCharge:i,mergeSelectedCharges:r})=>{const s=p(K,n),[t,c]=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:()=>c(h=>!h),children:t?e.jsx(v,{className:"size-5"}):e.jsx(w,{className:"size-5"})}),"Misc Charges (which are not on the above tables)"]}),t&&s&&e.jsx(F,{setEditChargeId:l,setInsertDocument:o,setMatchDocuments:a,data:s.differentMonthDoc,isAllOpened:!1,toggleMergeCharge:i,mergeSelectedCharges:r})]})},Fe=({data:n,setEditCharge:l,setInsertDocument:o,setMatchDocuments:a,toggleMergeCharge:i,mergeSelectedCharges:r})=>{const s=p(W,n),[t,c]=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:()=>c(h=>!h),children:t?e.jsx(v,{className:"size-5"}):e.jsx(w,{className:"size-5"})}),"Missing Info"]}),t&&s&&e.jsx(F,{setEditChargeId:l,setInsertDocument:o,setMatchDocuments:a,data:s.missingInfo,isAllOpened:!1,toggleMergeCharge:i,mergeSelectedCharges:r})]})},Ae=({filter:{monthDate:n,financialEntityId:l},isLoading:o})=>{const[{data:a,fetching:i,error:r},s]=E({query:R(te),pause:!0,variables:{monthDate:n,financialEntityId:l}});return d.useEffect(()=>{if(r){const t="Error generating PCN874 file";console.error(`${t}: ${r}`),X.error("Error",{description:t,duration:5e3,closeButton:!0})}},[r]),d.useEffect(()=>{if(a){const t=new File([a.pcnFile.reportContent],"pcn874.txt",{type:"text/plain"});Z(t)}},[a]),e.jsx(ee,{content:"Generate and Download PCN874 File",children:e.jsx(g,{disabled:i||o,variant:"outline",size:"icon",className:"size-7.5",onClick:s,children:e.jsx(ve,{className:"size-5"})})})};function Se({filter:n,setFilter:l,closeModal:o}){const{control:a,handleSubmit:i,setValue:r}=ae({defaultValues:{...n}}),{selectableAdminBusinesses:s,fetching:t}=ne(),c=m=>{l(m),o()};function h(){l(),o()}function u(m){const x=new Date(m.getFullYear(),m.getMonth(),15);r("monthDate",N(x,"yyyy-MM-dd"))}return e.jsxs(e.Fragment,{children:[t?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsxs("form",{onSubmit:i(c),children:[e.jsx(A,{name:"financialEntityId",control:a,defaultValue:void 0,render:({field:m,fieldState:x})=>e.jsx(S,{...m,data:s,value:m.value,disabled:t,label:"Report Issuer (Admin Business)",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:x.error?.message})}),e.jsx(A,{name:"chargesType",control:a,defaultValue:n.chargesType,render:({field:m,fieldState:x})=>e.jsx(S,{...m,data:ge,value:m.value??D.All,label:"Charge Type",placeholder:"Filter income/expense",maxDropdownHeight:160,error:x.error?.message})}),e.jsx(re,{defaultValue:n?.monthDate?new Date(n.monthDate):new Date,defaultDate:n?.monthDate?new Date(n.monthDate):new Date,onChange:u,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:o,children:"Cancel"})]})]})]})}function Me({filter:n,setFilter:l}){const[o,a]=d.useState(!1),{get:i,set:r}=z(),{userContext:s}=d.useContext(T);function t(c){c||={financialEntityId:s?.context.adminBusinessId??n.financialEntityId,monthDate:N(new Date,"yyyy-MM-15")},oe(c,n)||l(c)}return d.useEffect(()=>{const c=se(n??{})?null:encodeURIComponent(JSON.stringify(n)),h=i("vatMonthlyReportFilters");c!==h&&r("vatMonthlyReportFilters",c)},[n,i,r]),e.jsxs(e.Fragment,{children:[e.jsx(je,{opened:o,onClose:()=>a(!1),content:e.jsx(Se,{filter:n,setFilter:t,closeModal:()=>a(!1)})}),e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>a(!0),children:e.jsx(fe,{className:"size-5"})})]})}const rt=()=>{const{get:n}=z(),{setFiltersContext:l}=d.useContext(ie),{userContext:o}=d.useContext(T),[a,i]=d.useState(n("vatMonthlyReportFilters")?JSON.parse(decodeURIComponent(n("vatMonthlyReportFilters"))):{financialEntityId:o?.context.adminBusinessId??"",monthDate:N(new Date,"yyyy-MM-15")}),[r,s]=d.useState([]);d.useEffect(()=>{(!a.financialEntityId||a.financialEntityId==="")&&o?.context.adminBusinessId&&i({...a,financialEntityId:o.context.adminBusinessId})},[a,o?.context.adminBusinessId]);const[t,c]=d.useState(void 0),[h,u]=d.useState(void 0),[m,x]=d.useState(void 0),[{data:j,fetching:b}]=E({query:R(le),variables:{filters:a},pause:a.financialEntityId===""}),f=d.useCallback(y=>{r.includes(y)?s(r.filter(G=>G!==y)):s([...r,y])},[r]);function L(){s([])}d.useEffect(()=>{l(e.jsxs("div",{className:"flex flex-row gap-2",children:[e.jsx(Ae,{filter:a,isLoading:b}),e.jsx(Me,{filter:{...a},setFilter:i}),e.jsx(he,{selected:r.map(y=>({id:y,onChange:()=>{}})),resetMerge:L})]}))},[j,a,b,l,r]);const C=d.useMemo(()=>new Set(r),[r]);return e.jsx(pe,{title:"VAT Monthly Report",children:b?e.jsx(ce,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs("div",{className:"flex flex-col gap-4",children:[a.chargesType!==D.Expense&&e.jsx(De,{data:j?.vatReport,toggleMergeCharge:f,mergeSelectedCharges:r}),a.chargesType!==D.Income&&e.jsx(Ce,{data:j?.vatReport,toggleMergeCharge:f,mergeSelectedCharges:r}),e.jsx(Fe,{data:j?.vatReport,setEditCharge:x,setInsertDocument:c,setMatchDocuments:u,toggleMergeCharge:f,mergeSelectedCharges:C}),e.jsx(we,{data:j?.vatReport,setEditCharge:x,setInsertDocument:c,setMatchDocuments:u,toggleMergeCharge:f,mergeSelectedCharges:C}),e.jsx(Ne,{data:j?.vatReport,setEditCharge:x,setInsertDocument:c,setMatchDocuments:u,toggleMergeCharge:f,mergeSelectedCharges:C}),m&&e.jsx(me,{chargeId:m.id,close:()=>x(void 0)}),t&&e.jsx(xe,{chargeId:t.id,close:()=>c(void 0)}),h&&e.jsx(ue,{chargeId:h.id,ownerId:h.ownerId,setMatchDocuments:()=>u(void 0)})]})})};export{rt as VatMonthlyReport};
@@ -1 +1 @@
1
- import{r as m,j as e,B as u,a as y,F as R,u as T,L as D,ge as E}from"./index-W0pymfZB.js";import{d as b}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{P as w}from"./page-layout-BB7wmuSc.js";import{R as d}from"./report-commentary-row-DkKcwkwG.js";import{P as F}from"./modal-r_uBjTC6.js";import{Y as f}from"./YearPickerInput-CCSx1WAA.js";import{F as g}from"./funnel-Bz95UZzU.js";import{T as v}from"./Table-BERLrufH.js";import"./toggle-expansion-button-CGUSw3Av.js";import"./panel-top-open-fWlzHeN-.js";function B({year:i,setYear:h,referenceYears:x,setReferenceYears:j}){const[l,c]=m.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(F,{opened:l,onClose:()=>c(!1),withCloseButton:!0,content:e.jsxs(e.Fragment,{children:[e.jsx(f,{label:"Change report year",value:new Date(i,0,1),onChange:n=>n&&h(n?.getFullYear()),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date}),e.jsx(f,{type:"multiple",label:"Pick reference years",value:x?.map(n=>new Date(n,0,1)),onChange:n=>j(n.map(o=>o.getFullYear()).filter(o=>i!==o)),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date})]})}),e.jsx(u,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>c(!0),children:e.jsx(g,{className:"size-5"})})]})}const G=()=>{const{year:i}=y(),{setFiltersContext:h}=m.useContext(R),[x,j]=m.useState(i?Number(i):new Date().getFullYear()),[l,c]=m.useState([]),[{data:n,fetching:o}]=T({query:b(E),variables:{reportYear:x,referenceYears:l}});m.useEffect(()=>{h(e.jsx("div",{className:"flex flex-row gap-2",children:e.jsx(B,{year:x,setYear:j,referenceYears:l,setReferenceYears:c})}))},[x,o,h,l,c]);const p=n?.taxReport,s=p?.report,r=p?.reference??[];return e.jsx(w,{title:"Tax Report",children:o?e.jsx(D,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsx("div",{className:"flex flex-col gap-4",children:s&&e.jsxs(v,{highlightOnHover:!0,fontSize:"md",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{}),e.jsx("th",{children:x},x),e.jsx("th",{}),r.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:"Profit Before Tax"}),e.jsx("th",{children:s.profitBeforeTax.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("th",{children:a.profitBeforeTax.amount.formatted},a.year))]}),commentaryData:s.profitBeforeTax}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"R&D Expenses By Records"}),e.jsx("td",{children:s.researchAndDevelopmentExpensesByRecords.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.researchAndDevelopmentExpensesByRecords.amount.formatted},a.year))]}),commentaryData:s.researchAndDevelopmentExpensesByRecords}),e.jsxs("tr",{children:[e.jsx("td",{children:"R&D Expenses For Tax"}),e.jsx("td",{children:s.researchAndDevelopmentExpensesForTax.formatted}),e.jsx("td",{}),r.map(t=>e.jsx("td",{children:t.researchAndDevelopmentExpensesForTax.formatted},t.year)),e.jsx("td",{})]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Fines"}),e.jsx("td",{children:s.fines.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.fines.amount.formatted},a.year))]}),commentaryData:s.fines}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Untaxable Gifts"}),e.jsx("td",{children:s.untaxableGifts.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.untaxableGifts.amount.formatted},a.year))]}),commentaryData:s.untaxableGifts}),e.jsxs("tr",{children:[e.jsx("td",{children:"Business Trips Excess Expenses"}),e.jsx("td",{children:s.businessTripsExcessExpensesAmount.formatted}),e.jsx("td",{}),r.map(t=>e.jsx("td",{children:t.businessTripsExcessExpensesAmount.formatted},t.year)),e.jsx("td",{})]}),e.jsxs("tr",{children:[e.jsx("td",{children:"Salary Excess Expenses"}),e.jsx("td",{children:s.salaryExcessExpensesAmount.formatted}),e.jsx("td",{}),r.map(t=>e.jsx("td",{children:t.salaryExcessExpensesAmount.formatted},t.year)),e.jsx("td",{})]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Reserves"}),e.jsx("td",{children:s.reserves.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.reserves.amount.formatted},a.year))]}),commentaryData:s.reserves}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Nontaxable Linkage"}),e.jsx("td",{children:s.nontaxableLinkage.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.nontaxableLinkage.amount.formatted},a.year))]}),commentaryData:s.nontaxableLinkage}),e.jsxs("tr",{children:[e.jsx("th",{children:"Taxable Income"}),e.jsx("th",{children:s.taxableIncome.formatted}),e.jsx("th",{}),r.map(t=>e.jsx("th",{children:t.taxableIncome.formatted},t.year)),e.jsx("td",{})]}),e.jsxs("tr",{children:[e.jsx("td",{children:"Tax Rate"}),e.jsxs("td",{children:[(s.taxRate*100).toFixed(1),"%"]}),e.jsx("td",{}),r.map(t=>e.jsxs("td",{children:[(t.taxRate*100).toFixed(1),"%"]},t.year)),e.jsx("td",{})]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Income with Special Tax Rate"}),e.jsx("td",{children:s.specialTaxableIncome.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.specialTaxableIncome.amount.formatted},a.year))]}),commentaryData:s.specialTaxableIncome}),e.jsxs("tr",{children:[e.jsx("td",{children:"Special Tax Rate"}),e.jsxs("td",{children:[(s.specialTaxRate*100).toFixed(1),"%"]}),e.jsx("td",{}),r.map(t=>e.jsxs("td",{children:[(t.specialTaxRate*100).toFixed(1),"%"]},t.year)),e.jsx("td",{})]})]}),e.jsx("tfoot",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Annual Tax Expense"}),e.jsx("th",{children:s.annualTaxExpense.formatted}),e.jsx("th",{}),r.map(t=>e.jsx("th",{children:t.annualTaxExpense.formatted},t.year)),e.jsx("td",{})]})})]})})})};export{G as TaxReport};
1
+ import{r as m,j as e,B as u,a as y,F as R,u as T,L as D,ge as E}from"./index-DFAq0WCG.js";import{d as b}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{P as w}from"./page-layout-C_LiLwTe.js";import{R as d}from"./report-commentary-row-CwLb092w.js";import{P as F}from"./modal-BOOpXH8o.js";import{Y as f}from"./YearPickerInput-D2YpbThb.js";import{F as g}from"./funnel-CJBtCNe7.js";import{T as v}from"./Table-DacHD1KC.js";import"./toggle-expansion-button-CmTX8q1G.js";import"./panel-top-open-BEPaPi8H.js";function B({year:i,setYear:h,referenceYears:x,setReferenceYears:j}){const[l,c]=m.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(F,{opened:l,onClose:()=>c(!1),withCloseButton:!0,content:e.jsxs(e.Fragment,{children:[e.jsx(f,{label:"Change report year",value:new Date(i,0,1),onChange:n=>n&&h(n?.getFullYear()),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date}),e.jsx(f,{type:"multiple",label:"Pick reference years",value:x?.map(n=>new Date(n,0,1)),onChange:n=>j(n.map(o=>o.getFullYear()).filter(o=>i!==o)),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date})]})}),e.jsx(u,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>c(!0),children:e.jsx(g,{className:"size-5"})})]})}const G=()=>{const{year:i}=y(),{setFiltersContext:h}=m.useContext(R),[x,j]=m.useState(i?Number(i):new Date().getFullYear()),[l,c]=m.useState([]),[{data:n,fetching:o}]=T({query:b(E),variables:{reportYear:x,referenceYears:l}});m.useEffect(()=>{h(e.jsx("div",{className:"flex flex-row gap-2",children:e.jsx(B,{year:x,setYear:j,referenceYears:l,setReferenceYears:c})}))},[x,o,h,l,c]);const p=n?.taxReport,s=p?.report,r=p?.reference??[];return e.jsx(w,{title:"Tax Report",children:o?e.jsx(D,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsx("div",{className:"flex flex-col gap-4",children:s&&e.jsxs(v,{highlightOnHover:!0,fontSize:"md",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{}),e.jsx("th",{children:x},x),e.jsx("th",{}),r.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:"Profit Before Tax"}),e.jsx("th",{children:s.profitBeforeTax.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("th",{children:a.profitBeforeTax.amount.formatted},a.year))]}),commentaryData:s.profitBeforeTax}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"R&D Expenses By Records"}),e.jsx("td",{children:s.researchAndDevelopmentExpensesByRecords.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.researchAndDevelopmentExpensesByRecords.amount.formatted},a.year))]}),commentaryData:s.researchAndDevelopmentExpensesByRecords}),e.jsxs("tr",{children:[e.jsx("td",{children:"R&D Expenses For Tax"}),e.jsx("td",{children:s.researchAndDevelopmentExpensesForTax.formatted}),e.jsx("td",{}),r.map(t=>e.jsx("td",{children:t.researchAndDevelopmentExpensesForTax.formatted},t.year)),e.jsx("td",{})]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Fines"}),e.jsx("td",{children:s.fines.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.fines.amount.formatted},a.year))]}),commentaryData:s.fines}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Untaxable Gifts"}),e.jsx("td",{children:s.untaxableGifts.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.untaxableGifts.amount.formatted},a.year))]}),commentaryData:s.untaxableGifts}),e.jsxs("tr",{children:[e.jsx("td",{children:"Business Trips Excess Expenses"}),e.jsx("td",{children:s.businessTripsExcessExpensesAmount.formatted}),e.jsx("td",{}),r.map(t=>e.jsx("td",{children:t.businessTripsExcessExpensesAmount.formatted},t.year)),e.jsx("td",{})]}),e.jsxs("tr",{children:[e.jsx("td",{children:"Salary Excess Expenses"}),e.jsx("td",{children:s.salaryExcessExpensesAmount.formatted}),e.jsx("td",{}),r.map(t=>e.jsx("td",{children:t.salaryExcessExpensesAmount.formatted},t.year)),e.jsx("td",{})]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Reserves"}),e.jsx("td",{children:s.reserves.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.reserves.amount.formatted},a.year))]}),commentaryData:s.reserves}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Nontaxable Linkage"}),e.jsx("td",{children:s.nontaxableLinkage.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.nontaxableLinkage.amount.formatted},a.year))]}),commentaryData:s.nontaxableLinkage}),e.jsxs("tr",{children:[e.jsx("th",{children:"Taxable Income"}),e.jsx("th",{children:s.taxableIncome.formatted}),e.jsx("th",{}),r.map(t=>e.jsx("th",{children:t.taxableIncome.formatted},t.year)),e.jsx("td",{})]}),e.jsxs("tr",{children:[e.jsx("td",{children:"Tax Rate"}),e.jsxs("td",{children:[(s.taxRate*100).toFixed(1),"%"]}),e.jsx("td",{}),r.map(t=>e.jsxs("td",{children:[(t.taxRate*100).toFixed(1),"%"]},t.year)),e.jsx("td",{})]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Income with Special Tax Rate"}),e.jsx("td",{children:s.specialTaxableIncome.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.specialTaxableIncome.amount.formatted},a.year))]}),commentaryData:s.specialTaxableIncome}),e.jsxs("tr",{children:[e.jsx("td",{children:"Special Tax Rate"}),e.jsxs("td",{children:[(s.specialTaxRate*100).toFixed(1),"%"]}),e.jsx("td",{}),r.map(t=>e.jsxs("td",{children:[(t.specialTaxRate*100).toFixed(1),"%"]},t.year)),e.jsx("td",{})]})]}),e.jsx("tfoot",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Annual Tax Expense"}),e.jsx("th",{children:s.annualTaxExpense.formatted}),e.jsx("th",{}),r.map(t=>e.jsx("th",{children:t.annualTaxExpense.formatted},t.year)),e.jsx("td",{})]})})]})})})};export{G as TaxReport};
@@ -1 +1 @@
1
- import{g as I,h as w,r as d,t as p,i as E,u as N,k as M,j as e,c as k,l as A,B as F,m as S,n as L,P as D,I as P,F as T,o as $,L as z,p as R,R as j,q as U,s as q}from"./index-W0pymfZB.js";import{u as v}from"./use-url-query-Bw2WqiC_.js";import{B as O}from"./business-header-CbO0kf2S.js";import{C as _,M as Q}from"./Checkbox-B9Jxe8oL.js";import{P as V}from"./page-layout-BB7wmuSc.js";import"./building-2-BL0OoCnC.js";const H="mergeBusinesses",K=()=>{const[{fetching:a},o]=I(w),u=d.useCallback(async c=>{const l=`Error merging into business ID [${c.targetBusinessId}]`,n=`${H}-${c.targetBusinessId}`;p.loading("Merging Businesses",{id:n});try{const r=await o(c),t=E(r,l,n);if(t)return p.success("Success",{id:n,description:"Businesses merged"}),t.mergeBusinesses.id}catch(r){console.error(`${l}: ${r}`),p.error("Error",{id:n,description:l,duration:1e5,closeButton:!0})}},[o]);return{fetching:a,mergeBusinesses:u}};function G({businessIds:a,onDone:o,resetMerge:u}){const{mergeBusinesses:c,fetching:l}=K(),n=Array.from(new Set(a)),[{data:r,fetching:t}]=N({query:M,variables:{businessIds:n}}),[x,h]=d.useState(r?.businesses[0]),s=r?.businesses.length!==n.length&&"Some businesses were not Found"||void 0,m=r?.businesses||[],b=d.useCallback(async()=>{if(!x){p.error("Error",{description:"No main business selected"});return}if(n.length<2){p.error("Error",{description:"At least 2 businesses are required to execute a merge"});return}return await c({targetBusinessId:x.id,businessIdsToMerge:n.filter(g=>g!==x.id)}),u(),o()},[x,n,c,o,u]);return e.jsxs(e.Fragment,{children:[t&&e.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:e.jsx(k,{})}),!t&&s&&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:s})}),!t&&!s&&e.jsxs(e.Fragment,{children:[e.jsxs("table",{children:[e.jsxs("tr",{children:[e.jsx("th",{children:"Main"}),m.map(g=>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(_,{checked:g.id===x?.id,size:"xl",onClick:()=>{h(g)}})})},g.id))]}),e.jsxs("tr",{children:[e.jsx("th",{children:"Name"}),m.map(g=>e.jsx("td",{children:g.name},g.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:t||l,onClick:b,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:o,children:"Cancel"}),e.jsx("button",{type:"button",className:" text-white bg-red-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-red-600 rounded-sm text-lg",onClick:()=>{u(),o()},children:"Reset Merge"})]})]})]})}function J(a){const[o,{close:u,open:c}]=A(!1),{selected:l,resetMerge:n}=a,r=new Set(l.map(({id:m})=>m)),t=r.size>=1,[x,h]=d.useState(t?"default":"outline");d.useEffect(()=>{h(t?"default":"outline")},[t]);const s=d.useCallback(()=>{u(),l.map(({onChange:m})=>m())},[l,u]);return e.jsxs(e.Fragment,{children:[e.jsx(F,{onClick:()=>{t&&c()},disabled:!t,variant:x,className:S("size-7.5",t?" bg-blue-500 hover:bg-blue-500/90":""),size:"icon",children:e.jsx(Q,{className:"size-5"})}),e.jsx(L,{opened:o,onClose:u,size:"auto",centered:!0,children:e.jsx(G,{businessIds:Array.from(r),onDone:s,resetMerge:n})})]})}function W({activePage:a,setPage:o,totalPages:u=1,businessName:c,setBusinessName:l}){const{get:n,set:r}=v(),[t,x]=d.useState(c);d.useEffect(()=>{const s=a>0?a.toFixed(0):void 0,m=n("page");s!==m&&s!=="0"&&r("page",s)},[a,n,r]),d.useEffect(()=>{const s=setTimeout(()=>{l(t)},600);return()=>{clearTimeout(s)}},[t,l]);const h=s=>{x(s)};return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(D,{className:"flex-fit w-fit mx-0",currentPageIndex:a,onChange:o,totalPages:u}),e.jsx(P,{className:"w-72",placeholder:"Business Name",defaultValue:c??void 0,onChange:s=>h(s.target.value===""?void 0:s.target.value)})]})}const ne=()=>{const{get:a}=v(),[o,u]=d.useState(a("page")?Number(a("page")):0),[c,l]=d.useState(a("name")?a("name"):void 0),{setFiltersContext:n}=d.useContext(T),[{data:r,fetching:t},x]=N({query:q,variables:{page:o,limit:100,name:c}}),h=$(),[s,m]=d.useState([]),b=d.useCallback((i,f)=>{s.map(B=>B.id).includes(i)?m(s.filter(B=>B.id!==i)):m([...s,{id:i,onChange:f}])},[s]);function g(){m([])}d.useEffect(()=>{n(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(W,{activePage:o,setPage:u,businessName:c,setBusinessName:l,totalPages:r?.allBusinesses?.pageInfo.totalPages}),e.jsx(J,{selected:s,resetMerge:g})]}))},[r,o,c,n,u,l,s]);const y=r?.allBusinesses?.nodes.filter(i=>i.__typename==="LtdFinancialEntity").sort((i,f)=>i.name.toLowerCase()>f.name.toLowerCase()?1:-1)??[],C=new Set(s.map(i=>i.id));return e.jsx(V,{title:`Businesses (${r?.allBusinesses?.pageInfo.totalRecords??""})`,description:"All businesses",headerActions:e.jsx("div",{className:"flex items-center py-4 gap-4",children:e.jsx(U,{description:"",onAdd:()=>x()})}),children:t?e.jsx("div",{className:"flex flex-row justify-center",children:e.jsx(z,{className:S("h-10 w-10 animate-spin mr-2")})}):e.jsx("div",{className:"space-y-2",children:y.map(i=>e.jsx("div",{className:"group relative border rounded-lg hover:shadow-md transition-shadow",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"pl-4 flex items-center",children:e.jsx(R,{checked:C.has(i.id),onCheckedChange:()=>{b(i.id,()=>{})},className:"h-4 w-4 rounded border-gray-300 cursor-pointer",onClick:f=>f.stopPropagation()})}),e.jsx("div",{role:"button",tabIndex:0,className:"flex-1 cursor-pointer",onClick:()=>{h(j.BUSINESSES.DETAIL(i.id),{state:{from:j.BUSINESSES.ALL}})},onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),h(j.BUSINESSES.DETAIL(i.id),{state:{from:j.BUSINESSES.ALL}}))},children:e.jsx(O,{data:i})})]})},i.id))})})};export{ne as Businesses};
1
+ import{g as I,h as w,r as d,t as p,i as E,u as N,k as M,j as e,c as k,l as A,B as F,m as S,n as L,P as D,I as P,F as T,o as $,L as z,p as R,R as j,q as U,s as q}from"./index-DFAq0WCG.js";import{u as v}from"./use-url-query-CmXUOAIe.js";import{B as O}from"./business-header-DOLi738f.js";import{C as _,M as Q}from"./Checkbox-CahIfM5W.js";import{P as V}from"./page-layout-C_LiLwTe.js";import"./building-2-BX_dGlZz.js";const H="mergeBusinesses",K=()=>{const[{fetching:a},o]=I(w),u=d.useCallback(async c=>{const l=`Error merging into business ID [${c.targetBusinessId}]`,n=`${H}-${c.targetBusinessId}`;p.loading("Merging Businesses",{id:n});try{const r=await o(c),t=E(r,l,n);if(t)return p.success("Success",{id:n,description:"Businesses merged"}),t.mergeBusinesses.id}catch(r){console.error(`${l}: ${r}`),p.error("Error",{id:n,description:l,duration:1e5,closeButton:!0})}},[o]);return{fetching:a,mergeBusinesses:u}};function G({businessIds:a,onDone:o,resetMerge:u}){const{mergeBusinesses:c,fetching:l}=K(),n=Array.from(new Set(a)),[{data:r,fetching:t}]=N({query:M,variables:{businessIds:n}}),[x,h]=d.useState(r?.businesses[0]),s=r?.businesses.length!==n.length&&"Some businesses were not Found"||void 0,m=r?.businesses||[],b=d.useCallback(async()=>{if(!x){p.error("Error",{description:"No main business selected"});return}if(n.length<2){p.error("Error",{description:"At least 2 businesses are required to execute a merge"});return}return await c({targetBusinessId:x.id,businessIdsToMerge:n.filter(g=>g!==x.id)}),u(),o()},[x,n,c,o,u]);return e.jsxs(e.Fragment,{children:[t&&e.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:e.jsx(k,{})}),!t&&s&&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:s})}),!t&&!s&&e.jsxs(e.Fragment,{children:[e.jsxs("table",{children:[e.jsxs("tr",{children:[e.jsx("th",{children:"Main"}),m.map(g=>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(_,{checked:g.id===x?.id,size:"xl",onClick:()=>{h(g)}})})},g.id))]}),e.jsxs("tr",{children:[e.jsx("th",{children:"Name"}),m.map(g=>e.jsx("td",{children:g.name},g.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:t||l,onClick:b,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:o,children:"Cancel"}),e.jsx("button",{type:"button",className:" text-white bg-red-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-red-600 rounded-sm text-lg",onClick:()=>{u(),o()},children:"Reset Merge"})]})]})]})}function J(a){const[o,{close:u,open:c}]=A(!1),{selected:l,resetMerge:n}=a,r=new Set(l.map(({id:m})=>m)),t=r.size>=1,[x,h]=d.useState(t?"default":"outline");d.useEffect(()=>{h(t?"default":"outline")},[t]);const s=d.useCallback(()=>{u(),l.map(({onChange:m})=>m())},[l,u]);return e.jsxs(e.Fragment,{children:[e.jsx(F,{onClick:()=>{t&&c()},disabled:!t,variant:x,className:S("size-7.5",t?" bg-blue-500 hover:bg-blue-500/90":""),size:"icon",children:e.jsx(Q,{className:"size-5"})}),e.jsx(L,{opened:o,onClose:u,size:"auto",centered:!0,children:e.jsx(G,{businessIds:Array.from(r),onDone:s,resetMerge:n})})]})}function W({activePage:a,setPage:o,totalPages:u=1,businessName:c,setBusinessName:l}){const{get:n,set:r}=v(),[t,x]=d.useState(c);d.useEffect(()=>{const s=a>0?a.toFixed(0):void 0,m=n("page");s!==m&&s!=="0"&&r("page",s)},[a,n,r]),d.useEffect(()=>{const s=setTimeout(()=>{l(t)},600);return()=>{clearTimeout(s)}},[t,l]);const h=s=>{x(s)};return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(D,{className:"flex-fit w-fit mx-0",currentPageIndex:a,onChange:o,totalPages:u}),e.jsx(P,{className:"w-72",placeholder:"Business Name",defaultValue:c??void 0,onChange:s=>h(s.target.value===""?void 0:s.target.value)})]})}const ne=()=>{const{get:a}=v(),[o,u]=d.useState(a("page")?Number(a("page")):0),[c,l]=d.useState(a("name")?a("name"):void 0),{setFiltersContext:n}=d.useContext(T),[{data:r,fetching:t},x]=N({query:q,variables:{page:o,limit:100,name:c}}),h=$(),[s,m]=d.useState([]),b=d.useCallback((i,f)=>{s.map(B=>B.id).includes(i)?m(s.filter(B=>B.id!==i)):m([...s,{id:i,onChange:f}])},[s]);function g(){m([])}d.useEffect(()=>{n(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(W,{activePage:o,setPage:u,businessName:c,setBusinessName:l,totalPages:r?.allBusinesses?.pageInfo.totalPages}),e.jsx(J,{selected:s,resetMerge:g})]}))},[r,o,c,n,u,l,s]);const y=r?.allBusinesses?.nodes.filter(i=>i.__typename==="LtdFinancialEntity").sort((i,f)=>i.name.toLowerCase()>f.name.toLowerCase()?1:-1)??[],C=new Set(s.map(i=>i.id));return e.jsx(V,{title:`Businesses (${r?.allBusinesses?.pageInfo.totalRecords??""})`,description:"All businesses",headerActions:e.jsx("div",{className:"flex items-center py-4 gap-4",children:e.jsx(U,{description:"",onAdd:()=>x()})}),children:t?e.jsx("div",{className:"flex flex-row justify-center",children:e.jsx(z,{className:S("h-10 w-10 animate-spin mr-2")})}):e.jsx("div",{className:"space-y-2",children:y.map(i=>e.jsx("div",{className:"group relative border rounded-lg hover:shadow-md transition-shadow",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"pl-4 flex items-center",children:e.jsx(R,{checked:C.has(i.id),onCheckedChange:()=>{b(i.id,()=>{})},className:"h-4 w-4 rounded border-gray-300 cursor-pointer",onClick:f=>f.stopPropagation()})}),e.jsx("div",{role:"button",tabIndex:0,className:"flex-1 cursor-pointer",onClick:()=>{h(j.BUSINESSES.DETAIL(i.id),{state:{from:j.BUSINESSES.ALL}})},onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),h(j.BUSINESSES.DETAIL(i.id),{state:{from:j.BUSINESSES.ALL}}))},children:e.jsx(O,{data:i})})]})},i.id))})})};export{ne as Businesses};
@@ -1 +1 @@
1
- import{j as n,r as x,B as g,G as h,gF as j,a as v,F as D,u as R,L as E,bB as y,dV as w,T as f,gG as T}from"./index-W0pymfZB.js";import{d as C}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{P as A}from"./page-layout-BB7wmuSc.js";import{P as F}from"./modal-r_uBjTC6.js";import{Y as b}from"./YearPickerInput-CCSx1WAA.js";import{F as N}from"./funnel-Bz95UZzU.js";import{T as I}from"./Table-BERLrufH.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,o]=x.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsx(F,{opened:r,onClose:()=>o(!1),withCloseButton:!0,content:n.jsx(b,{type:"multiple",label:"Pick years",value:a?.map(c=>new Date(c,0,1)),onChange:c=>t(c.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:()=>o(!0),children:n.jsx(N,{className:"size-5"})})]})}const u=({originalRuleData:a,diffRuleData:t})=>{const r=h(j,a),o=h(j,t),c=o?.isCompliant!==r.isCompliant||o?.percentage.formatted!==r.percentage.formatted;return!o||!c?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}),o&&n.jsx("div",{className:"border-2 border-yellow-500 rounded-md ".concat(o.isCompliant?"text-green-500":"text-red-500"),children:o.percentage.formatted})]})})},d=(a,t)=>w(t).format(a);function m(a,t){if(a.length!==0)return d(a.reduce((r,o)=>r+o,0),t)}const G=()=>{const{year:a}=v(),{setFiltersContext:t}=x.useContext(D),[r,o]=x.useState(a?[Number(a)]:[new Date().getFullYear()]),[{data:c,fetching:p}]=R({query:C(T),variables:{years:r}});x.useEffect(()=>{t(n.jsx("div",{className:"flex flex-row gap-2",children:n.jsx(P,{years:r,setYears:o})}))},[r,p,t]);const s=c?.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(I,{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(l=>l.year===e)?.differences,disabled:!!s.find(l=>l.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:d(s.map(e=>e.totalIncome.raw).reduce((e,l)=>e+l,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:d(s.map(e=>e.researchAndDevelopmentExpenses.raw).reduce((e,l)=>e+l,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(f,{content:s[0]?.rndRelativeToIncome.rule,className:"max-w-[220px] whitespace-normal",children:n.jsx("p",{children:"R&D Expenses out of Income"})})}),s.map(e=>n.jsx(u,{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:d(s.map(e=>e.localDevelopmentExpenses.raw).reduce((e,l)=>e+l,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(f,{content:s[0]?.localDevelopmentRelativeToRnd.rule,className:"max-w-[220px] whitespace-normal",children:n.jsx("p",{children:"Local Development out of R&D"})})}),s.map(e=>n.jsx(u,{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:d(s.map(e=>e.foreignDevelopmentExpenses.raw).reduce((e,l)=>e+l,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(f,{content:s[0]?.foreignDevelopmentRelativeToRnd.rule,className:"max-w-[220px] whitespace-normal",children:n.jsx("p",{children:"Foreign Development out of R&D"})})}),s.map(e=>n.jsx(u,{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:d(s.map(e=>e.businessTripRndExpenses.raw).reduce((e,l)=>e+l,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{G as CorporateTaxRulingComplianceReport};
1
+ import{j as n,r as x,B as g,G as h,gF as j,a as v,F as D,u as R,L as E,bB as y,dV as w,T as f,gG as T}from"./index-DFAq0WCG.js";import{d as C}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{P as A}from"./page-layout-C_LiLwTe.js";import{P as F}from"./modal-BOOpXH8o.js";import{Y as b}from"./YearPickerInput-D2YpbThb.js";import{F as N}from"./funnel-CJBtCNe7.js";import{T as I}from"./Table-DacHD1KC.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,o]=x.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsx(F,{opened:r,onClose:()=>o(!1),withCloseButton:!0,content:n.jsx(b,{type:"multiple",label:"Pick years",value:a?.map(c=>new Date(c,0,1)),onChange:c=>t(c.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:()=>o(!0),children:n.jsx(N,{className:"size-5"})})]})}const u=({originalRuleData:a,diffRuleData:t})=>{const r=h(j,a),o=h(j,t),c=o?.isCompliant!==r.isCompliant||o?.percentage.formatted!==r.percentage.formatted;return!o||!c?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}),o&&n.jsx("div",{className:"border-2 border-yellow-500 rounded-md ".concat(o.isCompliant?"text-green-500":"text-red-500"),children:o.percentage.formatted})]})})},d=(a,t)=>w(t).format(a);function m(a,t){if(a.length!==0)return d(a.reduce((r,o)=>r+o,0),t)}const G=()=>{const{year:a}=v(),{setFiltersContext:t}=x.useContext(D),[r,o]=x.useState(a?[Number(a)]:[new Date().getFullYear()]),[{data:c,fetching:p}]=R({query:C(T),variables:{years:r}});x.useEffect(()=>{t(n.jsx("div",{className:"flex flex-row gap-2",children:n.jsx(P,{years:r,setYears:o})}))},[r,p,t]);const s=c?.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(I,{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(l=>l.year===e)?.differences,disabled:!!s.find(l=>l.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:d(s.map(e=>e.totalIncome.raw).reduce((e,l)=>e+l,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:d(s.map(e=>e.researchAndDevelopmentExpenses.raw).reduce((e,l)=>e+l,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(f,{content:s[0]?.rndRelativeToIncome.rule,className:"max-w-[220px] whitespace-normal",children:n.jsx("p",{children:"R&D Expenses out of Income"})})}),s.map(e=>n.jsx(u,{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:d(s.map(e=>e.localDevelopmentExpenses.raw).reduce((e,l)=>e+l,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(f,{content:s[0]?.localDevelopmentRelativeToRnd.rule,className:"max-w-[220px] whitespace-normal",children:n.jsx("p",{children:"Local Development out of R&D"})})}),s.map(e=>n.jsx(u,{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:d(s.map(e=>e.foreignDevelopmentExpenses.raw).reduce((e,l)=>e+l,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(f,{content:s[0]?.foreignDevelopmentRelativeToRnd.rule,className:"max-w-[220px] whitespace-normal",children:n.jsx("p",{children:"Foreign Development out of R&D"})})}),s.map(e=>n.jsx(u,{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:d(s.map(e=>e.businessTripRndExpenses.raw).reduce((e,l)=>e+l,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{G as CorporateTaxRulingComplianceReport};
@@ -1 +1 @@
1
- import{u as b,r as o,j as a,B as D,b_ as R,gk as w,ag as i,bX as f,bN as y,bO as C,bP as s,bQ as N,c1 as d,bR as I,bS as r,d8 as v,fA as B,is as F,c4 as S,c5 as E}from"./index-W0pymfZB.js";import{D as T}from"./deposits-transactions-table-fTRP0dK3.js";function V(){const[{data:c,fetching:g},p]=b({query:B}),[u,x]=o.useState([{id:"openDate",desc:!1}]),m=o.useMemo(()=>(c?.allDeposits??[]).map(t=>({id:t.id,currency:t.currency,openDate:t.openDate,closeDate:t.closeDate??null,isOpen:t.isOpen,currencyError:t.currencyError??[],currentBalanceRaw:t.currentBalance?.raw??0,currentBalanceFormatted:t.currentBalance?.formatted??"",totalDepositRaw:t.totalDeposit?.raw??0,totalDepositFormatted:t.totalDeposit?.formatted??"",totalInterestRaw:t.totalInterest?.raw??0,totalInterestFormatted:t.totalInterest?.formatted??""})),[c]),n=o.useRef([{id:"expander",header:()=>null,cell:({row:e})=>a.jsx(D,{variant:"ghost",size:"icon",onClick:()=>e.toggleExpanded(),"aria-label":e.getIsExpanded()?"Collapse":"Expand",children:e.getIsExpanded()?a.jsx(R,{}):a.jsx(w,{})}),enableSorting:!1},{accessorKey:"id",header:"Deposit ID",cell:e=>a.jsx("span",{className:"font-mono text-xs",children:e.getValue()})},{accessorKey:"currency",header:"Currency"},{accessorKey:"isOpen",header:"Status",cell:e=>e.getValue()?a.jsx(i,{className:"bg-green-600 text-white",variant:"secondary",children:"Open"}):a.jsx(i,{variant:"secondary",children:"Closed"}),sortingFn:(e,t)=>Number(e.original.isOpen)-Number(t.original.isOpen)},{accessorKey:"openDate",header:"Open Date",cell:e=>a.jsx("span",{children:e.getValue()})},{accessorKey:"closeDate",header:"Close Date",cell:e=>a.jsx("span",{children:e.getValue()??"-"}),sortingFn:(e,t)=>{const h=e.original.closeDate??"",j=t.original.closeDate??"";return h.localeCompare(j)}},{id:"totalDeposit",header:"Total Deposit",accessorFn:e=>e.totalDepositRaw,cell:e=>a.jsx("span",{className:"tabular-nums",children:e.row.original.totalDepositFormatted}),sortingFn:(e,t)=>e.original.totalDepositRaw-t.original.totalDepositRaw},{id:"currentBalance",header:"Current Balance",accessorFn:e=>e.currentBalanceRaw,cell:e=>a.jsx("span",{className:"tabular-nums",children:e.row.original.currentBalanceFormatted}),sortingFn:(e,t)=>e.original.currentBalanceRaw-t.original.currentBalanceRaw},{id:"totalInterest",header:"Total Interest",accessorFn:e=>e.totalInterestRaw,cell:e=>a.jsx("span",{className:"tabular-nums",children:e.row.original.totalInterestFormatted}),sortingFn:(e,t)=>e.original.totalInterestRaw-t.original.totalInterestRaw}]).current,l=f({data:m,columns:n,state:{sorting:u},onSortingChange:x,getCoreRowModel:E(),getSortedRowModel:S(),getExpandedRowModel:F(),getRowCanExpand:()=>!0});return a.jsxs("div",{className:"max-w-[95vw]",children:[a.jsx("div",{className:"flex items-center justify-between",children:a.jsx("h1",{className:"text-2xl font-semibold",children:"Bank Deposits"})}),a.jsx("div",{className:"mt-6 overflow-hidden rounded-md border",children:a.jsxs(y,{children:[a.jsx(C,{children:l.getHeaderGroups().map(e=>a.jsx(s,{children:e.headers.map(t=>a.jsx(N,{colSpan:t.colSpan,children:t.isPlaceholder?null:d(t.column.columnDef.header,t.getContext())},t.id))},e.id))}),a.jsx(I,{children:g?a.jsx(s,{children:a.jsx(r,{colSpan:n.length,className:"h-24 text-center",children:"Loading..."})}):l.getRowModel().rows?.length?l.getRowModel().rows.map(e=>a.jsxs(a.Fragment,{children:[a.jsx(s,{"data-state":e.getIsSelected()&&"selected",children:e.getVisibleCells().map(t=>a.jsx(r,{children:d(t.column.columnDef.cell,t.getContext())},t.id))},e.id),e.getIsExpanded()?a.jsx(s,{children:a.jsxs(r,{colSpan:n.length,children:[e.original.currencyError.length>0&&a.jsxs("div",{className:"mb-3 flex items-center gap-2 rounded-md border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-800",children:[a.jsx(v,{className:"size-4"}),a.jsxs("div",{children:[a.jsx("div",{className:"font-medium",children:"Currency Conflict"}),a.jsxs("div",{className:"opacity-90",children:["Affected transaction IDs: ",e.original.currencyError.join(", ")]})]})]}),a.jsx(T,{depositId:e.original.id,enableReassign:!0,refetch:p})]})}):null]})):a.jsx(s,{children:a.jsx(r,{colSpan:n.length,className:"h-24 text-center",children:"No results."})})})]})})]})}export{V as DepositsScreen};
1
+ import{u as b,r as o,j as a,B as D,b_ as R,gk as w,ag as i,bX as f,bN as y,bO as C,bP as s,bQ as N,c1 as d,bR as I,bS as r,d8 as v,fA as B,is as F,c4 as S,c5 as E}from"./index-DFAq0WCG.js";import{D as T}from"./deposits-transactions-table-C6kOIrVi.js";function V(){const[{data:c,fetching:g},p]=b({query:B}),[u,x]=o.useState([{id:"openDate",desc:!1}]),m=o.useMemo(()=>(c?.allDeposits??[]).map(t=>({id:t.id,currency:t.currency,openDate:t.openDate,closeDate:t.closeDate??null,isOpen:t.isOpen,currencyError:t.currencyError??[],currentBalanceRaw:t.currentBalance?.raw??0,currentBalanceFormatted:t.currentBalance?.formatted??"",totalDepositRaw:t.totalDeposit?.raw??0,totalDepositFormatted:t.totalDeposit?.formatted??"",totalInterestRaw:t.totalInterest?.raw??0,totalInterestFormatted:t.totalInterest?.formatted??""})),[c]),n=o.useRef([{id:"expander",header:()=>null,cell:({row:e})=>a.jsx(D,{variant:"ghost",size:"icon",onClick:()=>e.toggleExpanded(),"aria-label":e.getIsExpanded()?"Collapse":"Expand",children:e.getIsExpanded()?a.jsx(R,{}):a.jsx(w,{})}),enableSorting:!1},{accessorKey:"id",header:"Deposit ID",cell:e=>a.jsx("span",{className:"font-mono text-xs",children:e.getValue()})},{accessorKey:"currency",header:"Currency"},{accessorKey:"isOpen",header:"Status",cell:e=>e.getValue()?a.jsx(i,{className:"bg-green-600 text-white",variant:"secondary",children:"Open"}):a.jsx(i,{variant:"secondary",children:"Closed"}),sortingFn:(e,t)=>Number(e.original.isOpen)-Number(t.original.isOpen)},{accessorKey:"openDate",header:"Open Date",cell:e=>a.jsx("span",{children:e.getValue()})},{accessorKey:"closeDate",header:"Close Date",cell:e=>a.jsx("span",{children:e.getValue()??"-"}),sortingFn:(e,t)=>{const h=e.original.closeDate??"",j=t.original.closeDate??"";return h.localeCompare(j)}},{id:"totalDeposit",header:"Total Deposit",accessorFn:e=>e.totalDepositRaw,cell:e=>a.jsx("span",{className:"tabular-nums",children:e.row.original.totalDepositFormatted}),sortingFn:(e,t)=>e.original.totalDepositRaw-t.original.totalDepositRaw},{id:"currentBalance",header:"Current Balance",accessorFn:e=>e.currentBalanceRaw,cell:e=>a.jsx("span",{className:"tabular-nums",children:e.row.original.currentBalanceFormatted}),sortingFn:(e,t)=>e.original.currentBalanceRaw-t.original.currentBalanceRaw},{id:"totalInterest",header:"Total Interest",accessorFn:e=>e.totalInterestRaw,cell:e=>a.jsx("span",{className:"tabular-nums",children:e.row.original.totalInterestFormatted}),sortingFn:(e,t)=>e.original.totalInterestRaw-t.original.totalInterestRaw}]).current,l=f({data:m,columns:n,state:{sorting:u},onSortingChange:x,getCoreRowModel:E(),getSortedRowModel:S(),getExpandedRowModel:F(),getRowCanExpand:()=>!0});return a.jsxs("div",{className:"max-w-[95vw]",children:[a.jsx("div",{className:"flex items-center justify-between",children:a.jsx("h1",{className:"text-2xl font-semibold",children:"Bank Deposits"})}),a.jsx("div",{className:"mt-6 overflow-hidden rounded-md border",children:a.jsxs(y,{children:[a.jsx(C,{children:l.getHeaderGroups().map(e=>a.jsx(s,{children:e.headers.map(t=>a.jsx(N,{colSpan:t.colSpan,children:t.isPlaceholder?null:d(t.column.columnDef.header,t.getContext())},t.id))},e.id))}),a.jsx(I,{children:g?a.jsx(s,{children:a.jsx(r,{colSpan:n.length,className:"h-24 text-center",children:"Loading..."})}):l.getRowModel().rows?.length?l.getRowModel().rows.map(e=>a.jsxs(a.Fragment,{children:[a.jsx(s,{"data-state":e.getIsSelected()&&"selected",children:e.getVisibleCells().map(t=>a.jsx(r,{children:d(t.column.columnDef.cell,t.getContext())},t.id))},e.id),e.getIsExpanded()?a.jsx(s,{children:a.jsxs(r,{colSpan:n.length,children:[e.original.currencyError.length>0&&a.jsxs("div",{className:"mb-3 flex items-center gap-2 rounded-md border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-800",children:[a.jsx(v,{className:"size-4"}),a.jsxs("div",{children:[a.jsx("div",{className:"font-medium",children:"Currency Conflict"}),a.jsxs("div",{className:"opacity-90",children:["Affected transaction IDs: ",e.original.currencyError.join(", ")]})]})]}),a.jsx(T,{depositId:e.original.id,enableReassign:!0,refetch:p})]})}):null]})):a.jsx(s,{children:a.jsx(r,{colSpan:n.length,className:"h-24 text-center",children:"No results."})})})]})})]})}export{V as DepositsScreen};