@accounter/client 0.0.8-alpha-20251029152834-4e95d9a4cd7f292ec1789163f46763388b63a377 → 0.0.8-alpha-20251029232510-4bc0c8b8c08a26f0c27788725ae584e515236d20

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 (94) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/assets/{Checkbox-qIwbw1Vm.js → Checkbox-Cmx4P-eR.js} +2 -2
  3. package/dist/assets/{MultiSelect-Uj0K1auE.js → MultiSelect-tfWMeMsf.js} +1 -1
  4. package/dist/assets/{Pagination-D9TkQfLt.js → Pagination-p2BVFuhf.js} +1 -1
  5. package/dist/assets/{Progress-lLgzD5SX.js → Progress-BwoJerOb.js} +1 -1
  6. package/dist/assets/{Table-Cr3nIx5M.js → Table-Cve82Lq5.js} +1 -1
  7. package/dist/assets/{Typography-D8eUZCfX.js → Typography-CAgQOS4U.js} +1 -1
  8. package/dist/assets/{YearPickerInput-BdNLRDw_.js → YearPickerInput-BPVLgEAY.js} +1 -1
  9. package/dist/assets/{accordion-DwkOqBRF.js → accordion-Ca5XgpUz.js} +1 -1
  10. package/dist/assets/accountant-approvals-BXTzXE96.js +1 -0
  11. package/dist/assets/{accounter-table-R92v4QWf.js → accounter-table-CBlUbpQl.js} +1 -1
  12. package/dist/assets/{addDays-CHr5nY3e.js → addDays-ClGDfhvI.js} +1 -1
  13. package/dist/assets/{all-charges-DVKRQLII.js → all-charges-DV7V8QJ6.js} +1 -1
  14. package/dist/assets/{arrow-up-down-CTxePA5K.js → arrow-up-down-DMdWvrmz.js} +1 -1
  15. package/dist/assets/{building-2-B6TvGHom.js → building-2-Y3dys8Pf.js} +1 -1
  16. package/dist/assets/business-CRd0ns94.js +37 -0
  17. package/dist/assets/{business-extended-info-tkrkodR7.js → business-extended-info-BKVk3weU.js} +2 -2
  18. package/dist/assets/{business-header-Dx4N1uVn.js → business-header-S5R7Fq8P.js} +1 -1
  19. package/dist/assets/{business-ledger-filters-GmMxns0y.js → business-ledger-filters-C_x4y5uJ.js} +1 -1
  20. package/dist/assets/{business-ledger-single-BeO0VVgy.js → business-ledger-single-Dku8gbU9.js} +1 -1
  21. package/dist/assets/business-trip-CB51p6xt.js +1 -0
  22. package/dist/assets/{charge-DPnVzmY7.js → charge-C79C95t6.js} +1 -1
  23. package/dist/assets/{charges-filters-BSbPgdun.js → charges-filters-RFRXF1Oa.js} +1 -1
  24. package/dist/assets/{charges-ledger-validation-zkS0soMY.js → charges-ledger-validation-DTglElRA.js} +1 -1
  25. package/dist/assets/{charges-table-BIpECr1x.js → charges-table-D3WwcB50.js} +7 -7
  26. package/dist/assets/{chart-Caa1VlDy.js → chart-2MG3qLL8.js} +1 -1
  27. package/dist/assets/{data-table-pagination-psKhAMGL.js → data-table-pagination-Dhmbf7BR.js} +1 -1
  28. package/dist/assets/{download-csv-button-B1TMXv92.js → download-csv-button-BQSz29rY.js} +1 -1
  29. package/dist/assets/{editable-business-trip-CCy91YvH.js → editable-business-trip-BlqinsvU.js} +2 -2
  30. package/dist/assets/{funnel-DP2XBopJ.js → funnel-B2plvroD.js} +1 -1
  31. package/dist/assets/{index-BsxEk8Re.js → index--xgmdJzW.js} +1 -1
  32. package/dist/assets/{index-CvxMeW9Y.js → index-5R7-0kTp.js} +1 -1
  33. package/dist/assets/{index-lk_kdDxO.js → index-BRNnfzgV.js} +2 -2
  34. package/dist/assets/{index-D9OJexEV.js → index-BdRubi2c.js} +1 -1
  35. package/dist/assets/{index-CY-XVbUJ.js → index-BgLtHIxa.js} +1 -1
  36. package/dist/assets/{index-CV2QxRmK.js → index-Bs4RBq4h.js} +1 -1
  37. package/dist/assets/{index-PfXGaCrc.js → index-C0ZATVhv.js} +1 -1
  38. package/dist/assets/{index-xJNjwngg.js → index-C4gCwrJJ.js} +1 -1
  39. package/dist/assets/{index-fZcP3X7C.js → index-C6OmHOHr.js} +191 -191
  40. package/dist/assets/index-CIdZZL-X.js +1 -0
  41. package/dist/assets/{index-BfV_NJXM.js → index-CSEktEoZ.js} +7 -7
  42. package/dist/assets/{index-CDhroLKu.js → index-Cn4t95Q9.js} +1 -1
  43. package/dist/assets/{index-dsDfIa4Y.js → index-Csdsjvrl.js} +2 -2
  44. package/dist/assets/{index-4ge3Am6D.js → index-DA3Ccstm.js} +1 -1
  45. package/dist/assets/{index-CdGH-wdf.js → index-DKZGNBg3.js} +2 -2
  46. package/dist/assets/{index-BiaDwWnW.js → index-DZ6Bqs7R.js} +1 -1
  47. package/dist/assets/{index-CFIvwwkB.js → index-DemO-kJJ.js} +2 -2
  48. package/dist/assets/index-DhRIY5eN.js +1 -0
  49. package/dist/assets/{index-DtwTITCT.js → index-HG5RXBPG.js} +1 -1
  50. package/dist/assets/{index-CRuhKIVD.js → index-P9_YuS6e.js} +1 -1
  51. package/dist/assets/index-aEEtRfbo.js +1 -0
  52. package/dist/assets/{index-DjTdlXK_.js → index-arYAg9nt.js} +1 -1
  53. package/dist/assets/{index-PaMjwOfa.js → index-eIVAASqp.js} +1 -1
  54. package/dist/assets/index-nshyF-PE.js +6 -0
  55. package/dist/assets/{index-CeSVmmFv.js → index-qMYyjtmt.js} +1 -1
  56. package/dist/assets/{index.es-tIpBPUgx.js → index.es-BrfHJ6Yj.js} +1 -1
  57. package/dist/assets/{insert-business-trip-modal-qIM7A1Dw.js → insert-business-trip-modal-COXHjjIY.js} +2 -2
  58. package/dist/assets/issue-document-CBKTg1VC.js +1 -0
  59. package/dist/assets/{list-plus-ZIHrrCaO.js → list-plus-DbuCDPM8.js} +1 -1
  60. package/dist/assets/{login-page-z7UM7kNz.js → login-page-ChNFTZLU.js} +1 -1
  61. package/dist/assets/{match-document-modal-CpUhpMJc.js → match-document-modal-Cp2DKG3j.js} +4 -4
  62. package/dist/assets/{missing-info-charges-C1tPzMqU.js → missing-info-charges-IUzXIDY1.js} +1 -1
  63. package/dist/assets/{modal-B_jJz-4Z.js → modal-CCAYjiOC.js} +1 -1
  64. package/dist/assets/{page-layout-DUgx8eXl.js → page-layout-DpwpZHY3.js} +1 -1
  65. package/dist/assets/{page-not-found-D8UJ6_C9.js → page-not-found-NbOMK1Jv.js} +1 -1
  66. package/dist/assets/{panel-top-open-CcWXXds7.js → panel-top-open-CNX1-h4c.js} +1 -1
  67. package/dist/assets/{pencil-zApPUfTb.js → pencil-Z4i9z0vF.js} +1 -1
  68. package/dist/assets/{report-commentary-row-BonuPEAK.js → report-commentary-row-C4I-ATEX.js} +1 -1
  69. package/dist/assets/{save-tZoVFUtG.js → save-D0kOxdMh.js} +1 -1
  70. package/dist/assets/similar-transactions-modal-DgD48GZ2.js +1 -0
  71. package/dist/assets/{sub-zRppNrG0.js → sub-BAZr7Qdd.js} +1 -1
  72. package/dist/assets/subMonths-Df-03cZk.js +1 -0
  73. package/dist/assets/{summary-yiqSbK4V.js → summary-CkpRtdVA.js} +1 -1
  74. package/dist/assets/{toggle-expansion-button-pWLCCDmM.js → toggle-expansion-button-Babot8nj.js} +1 -1
  75. package/dist/assets/tooltip-DStdzzhK.js +1 -0
  76. package/dist/assets/{use-url-query-DyJg_rMw.js → use-url-query-BSUiacze.js} +1 -1
  77. package/dist/index.html +1 -1
  78. package/package.json +1 -1
  79. package/src/components/business/admin-business-section.tsx +299 -103
  80. package/src/gql/gql.ts +3 -3
  81. package/src/gql/graphql.ts +53 -17
  82. package/src/providers/index.ts +4 -0
  83. package/dist/assets/accountant-approvals-DX9vcA7l.js +0 -1
  84. package/dist/assets/business-CCLPxEIP.js +0 -37
  85. package/dist/assets/business-trip-D3REiwV6.js +0 -1
  86. package/dist/assets/index-8gQaTQhF.js +0 -6
  87. package/dist/assets/index-CLvGPwjT.js +0 -1
  88. package/dist/assets/index-CmRnzPuP.js +0 -1
  89. package/dist/assets/index-DkgLEg6I.js +0 -1
  90. package/dist/assets/issue-document-CAewRj6P.js +0 -1
  91. package/dist/assets/similar-transactions-modal-Cdv2FmQ8.js +0 -1
  92. package/dist/assets/subMonths-CLe-U48r.js +0 -1
  93. package/dist/assets/tooltip-r34BEIrK.js +0 -1
  94. package/src/providers/index.tsx +0 -56
@@ -1 +1 @@
1
- import{j as e,cX as D,c$ as a,x as f,cw as n,J as N,f_ as v,r as d,bv as E,D as T,aO as A,B as w,z as I,bo as O,G as V,cQ as M,V as P,X as y,Y as C,Z as F,_ as B,as as L,a0 as R,al as _,aT as U,F as $,a8 as k,u as q,c as Q,cV as z,cW as G,cY as o,c_ as J,f$ as H}from"./index-fZcP3X7C.js";import{u as S}from"./use-url-query-DyJg_rMw.js";import{P as X}from"./page-layout-DUgx8eXl.js";import{F as W}from"./funnel-DP2XBopJ.js";const Z=({record:s})=>{const t=N(v,s);return e.jsxs(D,{children:[e.jsx(a,{children:s.description}),e.jsx(a,{children:f(new Date(s.purchaseDate),"dd/MM/yyyy")}),e.jsx(a,{children:s.activationDate?f(new Date(s.activationDate),"dd/MM/yyyy"):void 0}),e.jsx(a,{children:t.originalCost?n(t.originalCost,0):void 0}),e.jsx(a,{children:t.reportYearDelta?n(t.reportYearDelta,0):void 0}),e.jsx(a,{children:n(t.totalDepreciableCosts,0)}),e.jsxs(a,{children:[n(s.statutoryDepreciationRate,0),"%"]}),e.jsx(a,{children:s.claimedDepreciationRate?`${n(s.claimedDepreciationRate,1)}%`:"-"}),e.jsx(a,{children:t.reportYearClaimedDepreciation?n(t.reportYearClaimedDepreciation,0):"-"}),e.jsx(a,{children:t.pastYearsAccumulatedDepreciation?n(t.pastYearsAccumulatedDepreciation,0):"-"}),e.jsx(a,{children:t.totalDepreciation?n(t.totalDepreciation,0):"-"}),e.jsx(a,{children:t.netValue?n(t.netValue,0):"-"})]})};function K(s){return!s||O(s)?null:encodeURIComponent(JSON.stringify(s))}const b="depreciationReportFilters";function ee({filter:s,setFilter:t,close:r}){const m=V({defaultValues:{...s}}),{control:c,handleSubmit:x}=m,{selectableFinancialEntities:u,fetching:l}=M(),j=i=>{t({...i,year:Number(i.year)}),r()};return e.jsx(P,{...m,children:e.jsxs("form",{onSubmit:x(j),className:"space-y-4",children:[e.jsx(y,{name:"year",control:c,rules:{required:"Year is required",validate:i=>{const p=Number(i);return Number.isNaN(p)||p<2e3||p>2100?"Invalid year":!0}},render:({field:i})=>e.jsxs(C,{children:[e.jsx(F,{children:"Year"}),e.jsx(B,{children:e.jsx(L,{...i,hideControls:!0,decimalScale:0})}),e.jsx(R,{})]})}),e.jsx(y,{name:"financialEntityId",defaultValue:s?.financialEntityId,control:c,render:({field:i})=>e.jsxs(C,{children:[e.jsx(F,{children:"Owner"}),e.jsx(_,{...i,data:u,value:i.value??void 0,disabled:l,placeholder:"Select a financial entity",formPart:!0}),e.jsx(R,{})]})}),e.jsx(U,{children:e.jsx(w,{type:"submit",disabled:l,children:"Filter"})})]})})}function ae({filter:s,setFilter:t}){const[r,m]=d.useState(!1),{get:c,set:x}=S();d.useEffect(()=>{const l=K(s),j=c(b);l!==j&&x(b,l)},[s,c,x]);const u=d.useCallback(l=>{E(l,s)||t(l)},[s,t]);return e.jsxs(T,{open:r,onOpenChange:m,children:[e.jsx(A,{asChild:!0,children:e.jsx(w,{variant:"outline",size:"icon",children:e.jsx(W,{size:20})})}),e.jsx(I,{className:"sm:max-w-[425px]",children:e.jsx(ee,{filter:s,setFilter:u,close:()=>m(!1)})})]})}const g=({data:s,groupName:t})=>{const r=N(v,s);return e.jsxs(D,{className:"font-bold border-b border-black",children:[e.jsx(a,{children:t?"Group Total":"Overall Total"}),e.jsx(a,{colSpan:2,children:t}),e.jsx(a,{children:r.originalCost?n(r.originalCost,0):void 0}),e.jsx(a,{children:r.reportYearDelta?n(r.reportYearDelta,0):void 0}),e.jsx(a,{children:r.totalDepreciableCosts?n(r.totalDepreciableCosts,0):void 0}),e.jsx(a,{}),e.jsx(a,{}),e.jsx(a,{children:r.reportYearClaimedDepreciation?n(r.reportYearClaimedDepreciation,0):void 0}),e.jsx(a,{children:r.pastYearsAccumulatedDepreciation?n(r.pastYearsAccumulatedDepreciation,0):void 0}),e.jsx(a,{children:r.totalDepreciation?n(r.totalDepreciation,0):void 0}),e.jsx(a,{children:r.netValue?n(r.netValue,0):void 0})]})},ne=()=>{const{setFiltersContext:s}=d.useContext($),{userContext:t}=d.useContext(k),{get:r}=S(),m=d.useMemo(()=>{const i={financialEntityId:t?.context.adminBusinessId,year:new Date().getFullYear()},p=r(b);if(p)try{return JSON.parse(decodeURIComponent(p))}catch(h){console.error("Failed to parse depreciation report filters from URL",h)}return i},[t?.context.adminBusinessId]),[c,x]=d.useState(m),[{data:u,fetching:l}]=q({query:H,variables:{filters:c}});d.useEffect(()=>{s(e.jsx("div",{className:"flex flex-row gap-x-5",children:e.jsx(ae,{filter:c,setFilter:x})}))},[c,s,x]);const j=d.useMemo(()=>`Depreciation Report for ${c.year}`,[c.year]);return e.jsx(X,{title:"Depreciation Report",description:j,children:l?e.jsx(Q,{}):e.jsxs(z,{children:[e.jsxs(G,{children:[e.jsxs(D,{className:"font-bold text-xl",children:[e.jsx(o,{colSpan:6,className:"text-center border-x",children:"List of Assets and Costs"}),e.jsx(o,{colSpan:5,className:"text-center border-x",children:"Depreciation"}),e.jsx(o,{className:"text-center border-x",children:"Remaining"})]}),e.jsxs(D,{className:"border-b border-black",children:[e.jsx(o,{className:"whitespace-normal",children:"Assets List and Descriptions"}),e.jsx(o,{className:"whitespace-normal",children:"Date of Purchase"}),e.jsx(o,{className:"whitespace-normal",children:"Activation Date"}),e.jsx(o,{className:"whitespace-normal",children:"Original Cost"}),e.jsx(o,{className:"whitespace-normal",children:"Changes During the Year"}),e.jsx(o,{className:"whitespace-normal",children:"Total Depreciable Assets"}),e.jsx(o,{className:"whitespace-normal",children:"Statutory Depreciation Rate"}),e.jsx(o,{className:"whitespace-normal",children:"Claimed Depreciation Rate"}),e.jsx(o,{className:"whitespace-normal",children:"Depreciation Claimed This Year"}),e.jsx(o,{className:"whitespace-normal",children:"Previous Tax Years Accumulated Depreciation"}),e.jsx(o,{className:"whitespace-normal",children:"Total Depreciation"}),e.jsx(o,{className:"whitespace-normal",children:"Net Book Value"})]})]}),e.jsx(J,{children:u?.depreciationReport&&e.jsxs(e.Fragment,{children:[u.depreciationReport.categories.map((i,p)=>e.jsxs(d.Fragment,{children:[e.jsxs(D,{className:"font-bold",children:[e.jsx(a,{children:`Category ${p+1}`}),e.jsx(a,{colSpan:2,children:i.category.name}),e.jsx(a,{colSpan:3}),e.jsxs(a,{children:[n(i.category.percentage,0),"%"]}),e.jsx(a,{colSpan:5})]}),i.records.sort((h,Y)=>h.purchaseDate.localeCompare(Y.purchaseDate)).map(h=>e.jsx(Z,{record:h},h.id)),e.jsx(g,{data:i.summary,groupName:i.category.name})]},i.id)),e.jsx(g,{data:u.depreciationReport.summary})]})})]})})};export{ne as DepreciationReport};
1
+ import{j as e,cX as D,c$ as a,x as f,cw as n,J as N,f_ as v,r as d,bw as E,D as T,aR as A,B as w,z as I,bp as O,G as M,cQ as P,W as V,Y as y,Z as C,_ as F,$ as B,ay as L,a1 as R,ar as _,aW as U,F as $,ae as k,u as q,c as Q,cV as z,cW as G,cY as o,c_ as J,f$ as W}from"./index-C6OmHOHr.js";import{u as S}from"./use-url-query-BSUiacze.js";import{P as H}from"./page-layout-DpwpZHY3.js";import{F as X}from"./funnel-B2plvroD.js";const Z=({record:s})=>{const t=N(v,s);return e.jsxs(D,{children:[e.jsx(a,{children:s.description}),e.jsx(a,{children:f(new Date(s.purchaseDate),"dd/MM/yyyy")}),e.jsx(a,{children:s.activationDate?f(new Date(s.activationDate),"dd/MM/yyyy"):void 0}),e.jsx(a,{children:t.originalCost?n(t.originalCost,0):void 0}),e.jsx(a,{children:t.reportYearDelta?n(t.reportYearDelta,0):void 0}),e.jsx(a,{children:n(t.totalDepreciableCosts,0)}),e.jsxs(a,{children:[n(s.statutoryDepreciationRate,0),"%"]}),e.jsx(a,{children:s.claimedDepreciationRate?`${n(s.claimedDepreciationRate,1)}%`:"-"}),e.jsx(a,{children:t.reportYearClaimedDepreciation?n(t.reportYearClaimedDepreciation,0):"-"}),e.jsx(a,{children:t.pastYearsAccumulatedDepreciation?n(t.pastYearsAccumulatedDepreciation,0):"-"}),e.jsx(a,{children:t.totalDepreciation?n(t.totalDepreciation,0):"-"}),e.jsx(a,{children:t.netValue?n(t.netValue,0):"-"})]})};function K(s){return!s||O(s)?null:encodeURIComponent(JSON.stringify(s))}const b="depreciationReportFilters";function ee({filter:s,setFilter:t,close:r}){const m=M({defaultValues:{...s}}),{control:c,handleSubmit:x}=m,{selectableFinancialEntities:u,fetching:l}=P(),j=i=>{t({...i,year:Number(i.year)}),r()};return e.jsx(V,{...m,children:e.jsxs("form",{onSubmit:x(j),className:"space-y-4",children:[e.jsx(y,{name:"year",control:c,rules:{required:"Year is required",validate:i=>{const p=Number(i);return Number.isNaN(p)||p<2e3||p>2100?"Invalid year":!0}},render:({field:i})=>e.jsxs(C,{children:[e.jsx(F,{children:"Year"}),e.jsx(B,{children:e.jsx(L,{...i,hideControls:!0,decimalScale:0})}),e.jsx(R,{})]})}),e.jsx(y,{name:"financialEntityId",defaultValue:s?.financialEntityId,control:c,render:({field:i})=>e.jsxs(C,{children:[e.jsx(F,{children:"Owner"}),e.jsx(_,{...i,data:u,value:i.value??void 0,disabled:l,placeholder:"Select a financial entity",formPart:!0}),e.jsx(R,{})]})}),e.jsx(U,{children:e.jsx(w,{type:"submit",disabled:l,children:"Filter"})})]})})}function ae({filter:s,setFilter:t}){const[r,m]=d.useState(!1),{get:c,set:x}=S();d.useEffect(()=>{const l=K(s),j=c(b);l!==j&&x(b,l)},[s,c,x]);const u=d.useCallback(l=>{E(l,s)||t(l)},[s,t]);return e.jsxs(T,{open:r,onOpenChange:m,children:[e.jsx(A,{asChild:!0,children:e.jsx(w,{variant:"outline",size:"icon",children:e.jsx(X,{size:20})})}),e.jsx(I,{className:"sm:max-w-[425px]",children:e.jsx(ee,{filter:s,setFilter:u,close:()=>m(!1)})})]})}const g=({data:s,groupName:t})=>{const r=N(v,s);return e.jsxs(D,{className:"font-bold border-b border-black",children:[e.jsx(a,{children:t?"Group Total":"Overall Total"}),e.jsx(a,{colSpan:2,children:t}),e.jsx(a,{children:r.originalCost?n(r.originalCost,0):void 0}),e.jsx(a,{children:r.reportYearDelta?n(r.reportYearDelta,0):void 0}),e.jsx(a,{children:r.totalDepreciableCosts?n(r.totalDepreciableCosts,0):void 0}),e.jsx(a,{}),e.jsx(a,{}),e.jsx(a,{children:r.reportYearClaimedDepreciation?n(r.reportYearClaimedDepreciation,0):void 0}),e.jsx(a,{children:r.pastYearsAccumulatedDepreciation?n(r.pastYearsAccumulatedDepreciation,0):void 0}),e.jsx(a,{children:r.totalDepreciation?n(r.totalDepreciation,0):void 0}),e.jsx(a,{children:r.netValue?n(r.netValue,0):void 0})]})},ne=()=>{const{setFiltersContext:s}=d.useContext($),{userContext:t}=d.useContext(k),{get:r}=S(),m=d.useMemo(()=>{const i={financialEntityId:t?.context.adminBusinessId,year:new Date().getFullYear()},p=r(b);if(p)try{return JSON.parse(decodeURIComponent(p))}catch(h){console.error("Failed to parse depreciation report filters from URL",h)}return i},[t?.context.adminBusinessId]),[c,x]=d.useState(m),[{data:u,fetching:l}]=q({query:W,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(H,{title:"Depreciation Report",description:j,children:l?e.jsx(Q,{}):e.jsxs(z,{children:[e.jsxs(G,{children:[e.jsxs(D,{className:"font-bold text-xl",children:[e.jsx(o,{colSpan:6,className:"text-center border-x",children:"List of Assets and Costs"}),e.jsx(o,{colSpan:5,className:"text-center border-x",children:"Depreciation"}),e.jsx(o,{className:"text-center border-x",children:"Remaining"})]}),e.jsxs(D,{className:"border-b border-black",children:[e.jsx(o,{className:"whitespace-normal",children:"Assets List and Descriptions"}),e.jsx(o,{className:"whitespace-normal",children:"Date of Purchase"}),e.jsx(o,{className:"whitespace-normal",children:"Activation Date"}),e.jsx(o,{className:"whitespace-normal",children:"Original Cost"}),e.jsx(o,{className:"whitespace-normal",children:"Changes During the Year"}),e.jsx(o,{className:"whitespace-normal",children:"Total Depreciable Assets"}),e.jsx(o,{className:"whitespace-normal",children:"Statutory Depreciation Rate"}),e.jsx(o,{className:"whitespace-normal",children:"Claimed Depreciation Rate"}),e.jsx(o,{className:"whitespace-normal",children:"Depreciation Claimed This Year"}),e.jsx(o,{className:"whitespace-normal",children:"Previous Tax Years Accumulated Depreciation"}),e.jsx(o,{className:"whitespace-normal",children:"Total Depreciation"}),e.jsx(o,{className:"whitespace-normal",children:"Net Book Value"})]})]}),e.jsx(J,{children:u?.depreciationReport&&e.jsxs(e.Fragment,{children:[u.depreciationReport.categories.map((i,p)=>e.jsxs(d.Fragment,{children:[e.jsxs(D,{className:"font-bold",children:[e.jsx(a,{children:`Category ${p+1}`}),e.jsx(a,{colSpan:2,children:i.category.name}),e.jsx(a,{colSpan:3}),e.jsxs(a,{children:[n(i.category.percentage,0),"%"]}),e.jsx(a,{colSpan:5})]}),i.records.sort((h,Y)=>h.purchaseDate.localeCompare(Y.purchaseDate)).map(h=>e.jsx(Z,{record:h},h.id)),e.jsx(g,{data:i.summary,groupName:i.category.name})]},i.id)),e.jsx(g,{data:u.depreciationReport.summary})]})})]})})};export{ne as DepreciationReport};
@@ -1,4 +1,4 @@
1
- import{v as G,r as d,j as e,J as p,B as g,dT as q,dU as H,dV as _,cw as F,dW as M,dX as Q,dY as J,dZ as $,d_ as Y,d$ as K,e0 as W,u as T,t as X,e1 as Z,T as ee,e2 as te,a8 as E,bo as se,G as ae,cQ as ne,br as A,bu as S,e3 as N,cK as re,x as D,bv as oe,F as ie,L as ce,e4 as le}from"./index-fZcP3X7C.js";import{d as R}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{u as V}from"./use-url-query-DyJg_rMw.js";import{M as de}from"./index-CeSVmmFv.js";import{E as he,I as me,M as xe}from"./match-document-modal-CpUhpMJc.js";import{P as ue}from"./page-layout-DUgx8eXl.js";import{C as I,u as pe,a as z,b as O}from"./charges-table-BIpECr1x.js";import{P as w,a as y}from"./panel-top-open-CcWXXds7.js";import{T as k}from"./toggle-expansion-button-pWLCCDmM.js";import{T as P}from"./Table-Cr3nIx5M.js";import{c as ge}from"./charges-filters-BSbPgdun.js";import{P as je}from"./modal-B_jJz-4Z.js";import{F as fe}from"./funnel-DP2XBopJ.js";import"./Checkbox-qIwbw1Vm.js";import"./YearPickerInput-BdNLRDw_.js";import"./list-plus-ZIHrrCaO.js";import"./insert-business-trip-modal-qIM7A1Dw.js";import"./accounter-table-R92v4QWf.js";import"./Pagination-D9TkQfLt.js";import"./create-event-handler-BiA-1lGu.js";import"./index-8gQaTQhF.js";import"./similar-transactions-modal-Cdv2FmQ8.js";import"./addDays-CHr5nY3e.js";import"./tooltip-r34BEIrK.js";import"./summary-yiqSbK4V.js";import"./sub-zRppNrG0.js";import"./subMonths-CLe-U48r.js";import"./MultiSelect-Uj0K1auE.js";/**
1
+ import{v as G,r as d,j as e,J as p,B as g,dT as q,dU as H,dV as _,cw as F,dW as M,dX as Q,dY as J,dZ as $,d_ as Y,d$ as K,e0 as W,u as T,t as X,e1 as Z,T as ee,e2 as te,ae as E,bp as se,G as ae,cQ as ne,bs as A,bv as S,e3 as N,cK as re,x as D,bw as oe,F as ie,L as ce,e4 as le}from"./index-C6OmHOHr.js";import{d as R}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{u as V}from"./use-url-query-BSUiacze.js";import{M as de}from"./index-qMYyjtmt.js";import{E as he,I as me,M as xe}from"./match-document-modal-Cp2DKG3j.js";import{P as ue}from"./page-layout-DpwpZHY3.js";import{C as I,u as pe,a as z,b as O}from"./charges-table-D3WwcB50.js";import{P as w,a as y}from"./panel-top-open-CNX1-h4c.js";import{T as k}from"./toggle-expansion-button-Babot8nj.js";import{T as P}from"./Table-Cve82Lq5.js";import{c as ge}from"./charges-filters-RFRXF1Oa.js";import{P as je}from"./modal-CCAYjiOC.js";import{F as fe}from"./funnel-B2plvroD.js";import"./Checkbox-Cmx4P-eR.js";import"./YearPickerInput-BPVLgEAY.js";import"./list-plus-DbuCDPM8.js";import"./insert-business-trip-modal-COXHjjIY.js";import"./accounter-table-CBlUbpQl.js";import"./Pagination-p2BVFuhf.js";import"./create-event-handler-BiA-1lGu.js";import"./index-nshyF-PE.js";import"./similar-transactions-modal-DgD48GZ2.js";import"./addDays-ClGDfhvI.js";import"./tooltip-DStdzzhK.js";import"./summary-CkpRtdVA.js";import"./sub-BAZr7Qdd.js";import"./subMonths-Df-03cZk.js";import"./MultiSelect-tfWMeMsf.js";/**
2
2
  * @license lucide-react v0.548.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{r,bo as w,bv as O,j as e,bp as U,B as c,a8 as K,G as _,x as b,cQ as z,V as B,cR as H,br as D,bs as M,bt as I,X as L,Y as G,Z as Q,_ as X,ah as q,F as J,u as Y,cS as Z,L as W,cT as $,cU as ee,cV as te,cW as se,cX as S,cY as ae,cZ as T,c_ as ne,c$ as k,d0 as re,d1 as ie,d2 as le,d3 as oe,d4 as ce,d5 as de,d6 as me,d7 as ue}from"./index-fZcP3X7C.js";import{u as P}from"./use-url-query-DyJg_rMw.js";import{a as ge}from"./accounter-table-R92v4QWf.js";import{D as he}from"./data-table-pagination-psKhAMGL.js";import{P as V}from"./modal-B_jJz-4Z.js";import{P as xe}from"./page-layout-DUgx8eXl.js";import{F as pe}from"./funnel-DP2XBopJ.js";import{M as R}from"./MultiSelect-Uj0K1auE.js";import{s as je}from"./sub-zRppNrG0.js";import{A as v}from"./arrow-up-down-CTxePA5K.js";import"./Pagination-D9TkQfLt.js";import"./create-event-handler-BiA-1lGu.js";import"./Table-Cr3nIx5M.js";import"./addDays-CHr5nY3e.js";import"./subMonths-CLe-U48r.js";function fe({filter:t,setFilter:s,closeModal:x}){const{userContext:p}=r.useContext(K),h=_({defaultValues:{ownerIDs:p?.context.adminBusinessId?[p.context.adminBusinessId]:void 0,toDate:b(new Date,"yyyy-MM-dd"),fromDate:b(je(new Date,{years:1}),"yyyy-MM-dd"),...t}}),{control:o,handleSubmit:y}=h,{selectableFinancialEntities:i,fetching:d}=z(),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:b(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:b(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(G,{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(Q,{children:"Unmatched only"})}),e.jsx(X,{children:e.jsx(q,{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 ve({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(U,{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(v,{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(v,{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:b(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(v,{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(v,{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(v,{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(v,{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(v,{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?b(new Date(s.eventDate),"dd/MM/yy"):null},{title:"Transaction Effective Date",value:s=>s?.effectiveDate?b(new Date(s.effectiveDate),"dd/MM/yy"):null},{title:"Transaction Description",value:s=>s?.sourceDescription}]}):"No Related Transaction"}],Ve=()=>{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(J),[{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(ve,{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(W,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs(e.Fragment,{children:[e.jsx($,{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{Ve as DocumentsReport,E as columns};
1
+ import{r,bp as w,bw as O,j as e,bq as U,B as c,ae as K,G as _,x as b,cQ as z,W as B,cR as H,bs as D,bt as M,bu as I,Y as L,Z as G,_ as q,$ as Q,an as J,F as W,u as X,cS as Y,L as Z,cT as $,cU as ee,cV as te,cW as se,cX as S,cY as ae,cZ as T,c_ as ne,c$ as k,d0 as re,d1 as ie,d2 as le,d3 as oe,d4 as ce,d5 as de,d6 as me,d7 as ue}from"./index-C6OmHOHr.js";import{u as P}from"./use-url-query-BSUiacze.js";import{a as ge}from"./accounter-table-CBlUbpQl.js";import{D as xe}from"./data-table-pagination-Dhmbf7BR.js";import{P as V}from"./modal-CCAYjiOC.js";import{P as he}from"./page-layout-DpwpZHY3.js";import{F as pe}from"./funnel-B2plvroD.js";import{M as R}from"./MultiSelect-tfWMeMsf.js";import{s as je}from"./sub-BAZr7Qdd.js";import{A as v}from"./arrow-up-down-DMdWvrmz.js";import"./Pagination-p2BVFuhf.js";import"./create-event-handler-BiA-1lGu.js";import"./Table-Cve82Lq5.js";import"./addDays-ClGDfhvI.js";import"./subMonths-Df-03cZk.js";function fe({filter:t,setFilter:s,closeModal:h}){const{userContext:p}=r.useContext(K),x=_({defaultValues:{ownerIDs:p?.context.adminBusinessId?[p.context.adminBusinessId]:void 0,toDate:b(new Date,"yyyy-MM-dd"),fromDate:b(je(new Date,{years:1}),"yyyy-MM-dd"),...t}}),{control:o,handleSubmit:y}=x,{selectableFinancialEntities:i,fetching:d}=z(),C=a=>{s(a),h()};function m(){s({}),h()}return e.jsxs(e.Fragment,{children:[d?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsx(B,{...x,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:b(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:b(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(G,{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(q,{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:h,children:"Cancel"})]})]})})]})}function ve({filter:t={},setFilter:s,initiallyOpened:h=!1}){const[p,x]=r.useState(h),[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:()=>x(!1),content:e.jsx(fe,{filter:t,setFilter:C,closeModal:()=>x(!1)}),modalSize:"xl"}),e.jsx(U,{inline:!0,size:16,disabled:!o,children:e.jsx(c,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>x(!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(v,{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(v,{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:b(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(v,{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(v,{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(v,{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(v,{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(v,{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?b(new Date(s.eventDate),"dd/MM/yy"):null},{title:"Transaction Effective Date",value:s=>s?.effectiveDate?b(new Date(s.effectiveDate),"dd/MM/yy"):null},{title:"Transaction Description",value:s=>s?.sourceDescription}]}):"No Related Transaction"}],Ve=()=>{const[t,s]=r.useState(null),[h,p]=r.useState(!1),{get:x}=P(),o=x("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(W),[{data:j,fetching:F},N]=X({query:ce,variables:{filters:i??{}},pause:!0});r.useEffect(()=>{i&&N()},[i,N]);const f=Y({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(xe,{table:f}),e.jsx(ve,{filter:i,setFilter:d,initiallyOpened:!i})]}))},[f,F,i,l,d,y,A]),e.jsx(he,{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(Z,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs(e.Fragment,{children:[e.jsx($,{open:h,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{Ve as DocumentsReport,E as columns};