@accounter/client 0.0.9-alpha-20251229163220-252c5796c2f16716efd535b2f16af7fbda5c96ca → 0.0.9-alpha-20251231083050-a0e737863ca2a9fa68506d15357e55d9287972cb
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/dist/assets/{Checkbox-BvYKsSPz.js → Checkbox-DQnX-IHw.js} +1 -1
- package/dist/assets/{MultiSelect-D3SvkAY7.js → MultiSelect-1WINlkTu.js} +1 -1
- package/dist/assets/{Progress-Lo_B0euu.js → Progress-CP4CpjLB.js} +1 -1
- package/dist/assets/{Table-9QP-vc-X.js → Table-3LUzGF-Y.js} +1 -1
- package/dist/assets/{Typography-CPg11j2x.js → Typography-DjNQi5FL.js} +1 -1
- package/dist/assets/{YearPickerInput-CjPL53OR.js → YearPickerInput-B4UXt2Dq.js} +1 -1
- package/dist/assets/{accordion-332bwqF-.js → accordion-3APui6eL.js} +1 -1
- package/dist/assets/{accountant-approvals-B4Pf4p4g.js → accountant-approvals-CBdRRVCx.js} +1 -1
- package/dist/assets/{accounter-table-CKI-wnyb.js → accounter-table-DZctE2Ds.js} +1 -1
- package/dist/assets/{addDays-DPF5RtoL.js → addDays-B6KOnr9d.js} +1 -1
- package/dist/assets/{all-charges-CItPSz5c.js → all-charges-EZZPjoH1.js} +1 -1
- package/dist/assets/{arrow-up-down-Bc57K9FU.js → arrow-up-down-DAgx4j1v.js} +1 -1
- package/dist/assets/{building-2-wQNjhrqC.js → building-2-DeX_sgix.js} +1 -1
- package/dist/assets/{business-BGfF9JwW.js → business-BzUivfwE.js} +1 -1
- package/dist/assets/{business-extended-info-DksXyVff.js → business-extended-info-B2Xyih3c.js} +1 -1
- package/dist/assets/{business-header-C2aZ6ADs.js → business-header-CLdljOB4.js} +1 -1
- package/dist/assets/{business-ledger-filters-BvHRchkx.js → business-ledger-filters-DSuUAhpz.js} +1 -1
- package/dist/assets/{business-ledger-single-C4gfMYob.js → business-ledger-single-CbRGarkQ.js} +1 -1
- package/dist/assets/{business-trip-9QYsM0Wz.js → business-trip-BGoFPcCG.js} +1 -1
- package/dist/assets/{charge-DUBMW_VS.js → charge-8pPIe-1K.js} +1 -1
- package/dist/assets/{charges-filters-DY8PlVOu.js → charges-filters-DX5qB120.js} +1 -1
- package/dist/assets/{charges-ledger-validation-Cl0tCR0E.js → charges-ledger-validation-CsvcJrF1.js} +1 -1
- package/dist/assets/{charges-table-CxqehZsM.js → charges-table-BqKHuWkm.js} +1 -1
- package/dist/assets/{chart-Dprup89Z.js → chart-DEoAP57x.js} +1 -1
- package/dist/assets/{contracts-DGeW1WzO.js → contracts-DiTPYe_K.js} +1 -1
- package/dist/assets/{data-table-column-header-CSxC7ltI.js → data-table-column-header-B3XsejWx.js} +1 -1
- package/dist/assets/{data-table-pagination-CN-pMPBS.js → data-table-pagination-Dnwks2up.js} +1 -1
- package/dist/assets/{deposits-transactions-table-DTZENoQ4.js → deposits-transactions-table-u4MVVhDE.js} +1 -1
- package/dist/assets/{download-csv-button-BBrwd5Ig.js → download-csv-button-Cd0rXY7Z.js} +1 -1
- package/dist/assets/{editable-business-trip-CZVuyFIf.js → editable-business-trip-CFtHoHgD.js} +1 -1
- package/dist/assets/{eye-off-ByAlEmCd.js → eye-off-CqyrLNH2.js} +1 -1
- package/dist/assets/{funnel-DfkSd8MP.js → funnel-Cq2G1Do_.js} +1 -1
- package/dist/assets/{index-C9t4Spsw.js → index-B11eQ9zE.js} +1 -1
- package/dist/assets/{index-CBusg7iL.js → index-B4C4roog.js} +1 -1
- package/dist/assets/{index-Bhr9DBNP.js → index-B5cZSJnv.js} +1 -1
- package/dist/assets/{index-BioaoPC3.js → index-B6b9Rw5K.js} +1 -1
- package/dist/assets/{index-C2ogr58h.js → index-BWWXDa6R.js} +1 -1
- package/dist/assets/{index-DWdZ98tc.js → index-B_k8HoAb.js} +1 -1
- package/dist/assets/{index-BLILe36K.js → index-BglNOY-K.js} +1 -1
- package/dist/assets/{index-BLlk3ioj.js → index-BnQa9D-p.js} +1 -1
- package/dist/assets/{index-CDgy2E8q.js → index-BpEJ93C0.js} +1 -1
- package/dist/assets/{index-jaEBNO7r.js → index-C-IbD3J_.js} +1 -1
- package/dist/assets/{index-DPl7-2lj.js → index-CHXDfsUO.js} +118 -101
- package/dist/assets/{index-C4ELC-6H.js → index-CJ8ooPTa.js} +1 -1
- package/dist/assets/{index-gXqWDC1A.js → index-CNjMTN0Q.js} +1 -1
- package/dist/assets/{index-D82ZjK6i.js → index-CP2Qb-hO.js} +1 -1
- package/dist/assets/{index-BJ2DsmzW.js → index-D33ZDOgR.js} +1 -1
- package/dist/assets/{index-BMdgIjgQ.js → index-D6-auP1L.js} +1 -1
- package/dist/assets/{index-D4mUilGh.js → index-DNrPzTVq.js} +1 -1
- package/dist/assets/{index-D0XEyBJ5.js → index-DU027pPm.js} +1 -1
- package/dist/assets/{index-DA3e_X_e.js → index-DVgehknF.js} +1 -1
- package/dist/assets/{index-CdpLAr3U.js → index-Dh8bLiLk.js} +1 -1
- package/dist/assets/{index-Czt03QAZ.js → index-Dnh3vQj-.js} +1 -1
- package/dist/assets/{index-DGdJjAce.js → index-DrZ1x-RS.js} +1 -1
- package/dist/assets/{index-Bm7Ey_uj.js → index-MwNvVanh.js} +1 -1
- package/dist/assets/{index-fSGwICur.js → index-O1zv8-qd.js} +1 -1
- package/dist/assets/{index-BFAdPd7J.js → index-iIbhlXwt.js} +1 -1
- package/dist/assets/{index-5NRdGGEF.js → index-sbjskCmO.js} +1 -1
- package/dist/assets/{index.es-Blv4LI7U.js → index.es-_6Kbkkwx.js} +1 -1
- package/dist/assets/{insert-business-trip-modal-BUhwQLU3.js → insert-business-trip-modal-K2wc3hgW.js} +1 -1
- package/dist/assets/issue-document-BCOsBdUg.js +1 -0
- package/dist/assets/{list-plus-BQ2uDu4U.js → list-plus-B1XUUi79.js} +1 -1
- package/dist/assets/{login-page-pRqqahH8.js → login-page-lqDJk0_E.js} +1 -1
- package/dist/assets/{match-document-modal-DV5QgP9r.js → match-document-modal-CtJxEQcv.js} +1 -1
- package/dist/assets/{missing-info-charges-BGYn4gvi.js → missing-info-charges-CK_ic2ZJ.js} +1 -1
- package/dist/assets/{modal-B8VWOErJ.js → modal-CmNyWfb_.js} +1 -1
- package/dist/assets/{modify-contract-dialog-DRcS3aO9.js → modify-contract-dialog-C-wdFvim.js} +1 -1
- package/dist/assets/{page-layout-TLx4BlfR.js → page-layout-ClvS18JI.js} +1 -1
- package/dist/assets/{page-not-found-CM1j3HiZ.js → page-not-found-Bu7CSbYq.js} +1 -1
- package/dist/assets/{panel-top-open-CYZjCIwy.js → panel-top-open-ZI73OpgC.js} +1 -1
- package/dist/assets/{report-commentary-row-ACfwSw4k.js → report-commentary-row-DYuYv4BH.js} +1 -1
- package/dist/assets/{save-C86duuZc.js → save-BDQNsoKR.js} +1 -1
- package/dist/assets/{similar-transactions-modal-NWsMovPt.js → similar-transactions-modal-DVKLWVDl.js} +1 -1
- package/dist/assets/{sub-QnKigTbd.js → sub-Cl3G90K_.js} +1 -1
- package/dist/assets/subMonths-SBqdI_BY.js +1 -0
- package/dist/assets/{summary-Dfk-pO3i.js → summary-3HnUK0c0.js} +1 -1
- package/dist/assets/{toggle-expansion-button-CwQXYYlU.js → toggle-expansion-button-B4wRWu9m.js} +1 -1
- package/dist/assets/{use-issue-monthly-documents-DAaVu4cF.js → use-issue-monthly-documents-BuvBKJJJ.js} +1 -1
- package/dist/assets/{use-url-query-CXxOA1KN.js → use-url-query-Cy2jrPOP.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +3 -3
- package/dist/assets/issue-document-rJl8tgEw.js +0 -1
- package/dist/assets/subMonths-CfU8nlXz.js +0 -1
|
@@ -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-
|
|
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-CHXDfsUO.js";import{u as v}from"./use-url-query-Cy2jrPOP.js";import{B as O}from"./business-header-CLdljOB4.js";import{C as _,M as Q}from"./Checkbox-DQnX-IHw.js";import{P as V}from"./page-layout-ClvS18JI.js";import"./building-2-DeX_sgix.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{v as j,r as l,F as C,u as S,j as e,T as f,B as g,bu as m,ay as n,L as N,bv as v,bw as R}from"./index-
|
|
1
|
+
import{v as j,r as l,F as C,u as S,j as e,T as f,B as g,bu as m,ay as n,L as N,bv as v,bw as R}from"./index-CHXDfsUO.js";import{u as T}from"./use-url-query-Cy2jrPOP.js";import{A as E}from"./accounter-table-DZctE2Ds.js";import{P as L}from"./page-layout-ClvS18JI.js";import{B as k}from"./business-extended-info-B2Xyih3c.js";import{B as F,M as z}from"./business-ledger-filters-DSuUAhpz.js";import{P as B,a as I}from"./panel-top-open-ZI73OpgC.js";import{T as A}from"./Table-3LUzGF-Y.js";import"./data-table-column-header-B3XsejWx.js";import"./eye-off-CqyrLNH2.js";import"./download-csv-button-Cd0rXY7Z.js";import"./modal-CmNyWfb_.js";import"./funnel-Cq2G1Do_.js";import"./MultiSelect-1WINlkTu.js";const M=[["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"m17 7 5 5-5 5",key:"1xlxn0"}],["path",{d:"m7 7-5 5 5 5",key:"19njba"}],["path",{d:"M8 12h.01",key:"czm47f"}]],_=j("chevrons-left-right-ellipsis",M);const O=[["path",{d:"m20 17-5-5 5-5",key:"30x0n2"}],["path",{d:"m4 17 5-5-5-5",key:"16spf4"}]],P=j("chevrons-right-left",O),se=()=>{const{get:t}=T(),{setFiltersContext:i}=l.useContext(C),[r,o]=l.useState(!1),[p,w]=l.useState(!1),[u,x]=l.useState(t("ledgerRecordsFilters")?JSON.parse(decodeURIComponent(t("ledgerRecordsFilters"))):{}),[{data:c,fetching:b}]=S({query:v,variables:{filters:u}});l.useEffect(()=>{i(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(F,{filter:u,setFilter:x}),e.jsx(f,{content:"Expand all accounts",asChild:!0,children:e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>o(s=>!s),children:r?e.jsx(B,{className:"size-5"}):e.jsx(I,{className:"size-5"})})}),e.jsx(f,{content:"Expand all currencies",asChild:!0,children:e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>w(s=>!s),children:p?e.jsx(P,{className:"size-5"}):e.jsx(_,{className:"size-5"})})})]}))},[c,u,i,x,r,o,p]);const y=l.useMemo(()=>c?.businessTransactionsSumFromLedgerRecords.__typename==="CommonError"?[]:c?.businessTransactionsSumFromLedgerRecords.businessTransactionsSum?c.businessTransactionsSumFromLedgerRecords.businessTransactionsSum.sort((s,d)=>s.business.name.localeCompare(d.business.name)):[],[c?.businessTransactionsSumFromLedgerRecords]),h=[{title:"Business Name",value:s=>s.business.name},{title:"Debit / Credit",value:s=>e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("p",{className:"flex flex-row gap-2 whitespace-nowrap",children:e.jsx(m,{c:"red",children:s.debit.formatted})}),e.jsx("p",{className:"flex flex-row gap-2 whitespace-nowrap",children:e.jsx(m,{c:"green",children:s.credit.formatted})})]}),style:{whiteSpace:"nowrap"}},{title:"Total",value:s=>e.jsx(m,{c:s.total.raw<-1e-4?"red":s.total.raw>1e-4?"green":void 0,fw:700,children:s.total.formatted}),style:{whiteSpace:"nowrap"}},...a(n.Eur),...a(n.Usd),...a(n.Gbp),...a(n.Cad),...a(n.Jpy),...a(n.Aud),...a(n.Sek),...D(p)];return e.jsx(L,{title:"Business Ledger Records",description:"Business Ledger Records Summary",children:b?e.jsx(N,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs(A,{striped:!0,highlightOnHover:!0,children:[e.jsx("thead",{className:"sticky top-0 z-20",children:e.jsxs("tr",{className:"tracking-wider font-medium text-gray-900 text-sm bg-gray-100",children:[h.map((s,d)=>s.disabled?null:e.jsx("th",{children:s.title},String(d))),e.jsx("th",{children:"More Info"})]})}),e.jsx("tbody",{children:y.map((s,d)=>e.jsx(E,{columns:h,item:s,moreInfo:()=>e.jsx(k,{businessID:s.business.id,filter:u}),isShowAll:r},d))})]})})};function a(t){return[{title:`${t} Debit / Credit`,value:i=>{const r=i.foreignCurrenciesSum.find(o=>o.currency===t);return r?e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("p",{className:"flex flex-row gap-2 whitespace-nowrap",children:e.jsx(m,{c:"red",children:r.debit.formatted})}),e.jsx("p",{className:"flex flex-row gap-2 whitespace-nowrap",children:e.jsx(m,{c:"green",children:r.credit.formatted})})]}):null},style:{whiteSpace:"nowrap"}},{title:`${t} Total`,value:i=>{const r=i.foreignCurrenciesSum.find(o=>o.currency===t);return r?.total?.raw&&(r.total.raw<-1e-4||r.total.raw>1e-4)?e.jsx(z,{color:r.total.raw>0?"green":"red",children:r.total.formatted}):r?.total?.formatted},style:{whiteSpace:"nowrap"}}]}function D(t){return t?Object.values(n).filter(r=>!R.includes(r)).map(a).flat():[]}export{se as BusinessLedgerRecordsSummery};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{v as Ge,r as m,dg as Nc,aF as V,dk as kc,aG as ae,j as v,dj as vn,dI as It,dJ as ge,dK as Ho,dl as Lc,dL as Vc,dM as nn,dN as jc,bA as Fi,D as _r,aL as zr,bB as Fc,B as ee,x as $r,al as Ur,am as Hr,z as Wo,bC as Bc,aC as _c,bD as An,bE as Bi,bF as _i,w as rn,at as Go,a2 as Ko,bH as zc,g as qo,dO as $c,t as Pe,i as Yo,T as yn,u as rr,dP as Uc,bX as Hc,c2 as Wc,c4 as Gc,c3 as Kc,c5 as qc,L as Xo,I as Wr,bN as Yc,bO as Xc,bP as Nn,bQ as Zc,c1 as zi,bR as Jc,bS as $i,bY as Zo,bZ as Jo,b$ as Qo,dQ as Qc,dR as eu,dS as sn,dT as tu,E as nu,a7 as ru,V as iu,Y as su,Z as ou,_ as au,$ as lu,a1 as cu,au as uu,ab as Ui,dU as du,e as hu,a4 as fu,ag as Hi,dV as pu,dW as gu,dX as Wi,cv as mu,ay as vu,F as yu,b3 as bu,dY as Tu,dZ as xu}from"./index-
|
|
1
|
+
import{v as Ge,r as m,dg as Nc,aF as V,dk as kc,aG as ae,j as v,dj as vn,dI as It,dJ as ge,dK as Ho,dl as Lc,dL as Vc,dM as nn,dN as jc,bA as Fi,D as _r,aL as zr,bB as Fc,B as ee,x as $r,al as Ur,am as Hr,z as Wo,bC as Bc,aC as _c,bD as An,bE as Bi,bF as _i,w as rn,at as Go,a2 as Ko,bH as zc,g as qo,dO as $c,t as Pe,i as Yo,T as yn,u as rr,dP as Uc,bX as Hc,c2 as Wc,c4 as Gc,c3 as Kc,c5 as qc,L as Xo,I as Wr,bN as Yc,bO as Xc,bP as Nn,bQ as Zc,c1 as zi,bR as Jc,bS as $i,bY as Zo,bZ as Jo,b$ as Qo,dQ as Qc,dR as eu,dS as sn,dT as tu,E as nu,a7 as ru,V as iu,Y as su,Z as ou,_ as au,$ as lu,a1 as cu,au as uu,ab as Ui,dU as du,e as hu,a4 as fu,ag as Hi,dV as pu,dW as gu,dX as Wi,cv as mu,ay as vu,F as yu,b3 as bu,dY as Tu,dZ as xu}from"./index-CHXDfsUO.js";import{u as ea}from"./use-url-query-Cy2jrPOP.js";import{A as Gi}from"./arrow-up-down-DAgx4j1v.js";import{D as Su}from"./download-csv-button-Cd0rXY7Z.js";import{B as wu}from"./business-extended-info-B2Xyih3c.js";import{_ as Du,a as bn,s as we,g as Gr,u as Ki,c as Kr,m as wt,d as ir,T as sr}from"./Typography-DjNQi5FL.js";import{P as Cu,a as Eu}from"./panel-top-open-ZI73OpgC.js";import{F as Ou}from"./funnel-Cq2G1Do_.js";import{M as Pu}from"./MultiSelect-1WINlkTu.js";import"./data-table-column-header-B3XsejWx.js";import"./eye-off-CqyrLNH2.js";const Mu=[["path",{d:"m10.852 19.772-.383.924",key:"r7sl7d"}],["path",{d:"m13.148 14.228.383-.923",key:"1d5zpm"}],["path",{d:"M13.148 19.772a3 3 0 1 0-2.296-5.544l-.383-.923",key:"1ydik7"}],["path",{d:"m13.53 20.696-.382-.924a3 3 0 1 1-2.296-5.544",key:"1m1vsf"}],["path",{d:"m14.772 15.852.923-.383",key:"660p6e"}],["path",{d:"m14.772 18.148.923.383",key:"hrcpis"}],["path",{d:"M4.2 15.1a7 7 0 1 1 9.93-9.858A7 7 0 0 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.2",key:"j2q98n"}],["path",{d:"m9.228 15.852-.923-.383",key:"1p9ong"}],["path",{d:"m9.228 18.148-.923.383",key:"6558rz"}]],Iu=Ge("cloud-cog",Mu);const Ru=[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]],Au=Ge("cloud-upload",Ru);const Nu=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],ta=Ge("ellipsis",Nu);const ku=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],Lu=Ge("folder-open",ku);const Vu=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],ju=Ge("folder-plus",Vu);const Fu=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],Bu=Ge("folder",Fu);const _u=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],zu=Ge("pencil",_u);function Gt(t){const e=m.useRef(t);return Nc(()=>{e.current=t}),m.useRef((...n)=>(0,e.current)(...n)).current}function or(t,e){return or=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},or(t,e)}function $u(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,or(t,e)}const qi=V.createContext(null);function Uu(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function qr(t,e){var n=function(s){return e&&m.isValidElement(s)?e(s):s},r=Object.create(null);return t&&m.Children.map(t,function(i){return i}).forEach(function(i){r[i.key]=n(i)}),r}function Hu(t,e){t=t||{},e=e||{};function n(u){return u in e?e[u]:t[u]}var r=Object.create(null),i=[];for(var s in t)s in e?i.length&&(r[s]=i,i=[]):i.push(s);var o,a={};for(var l in e){if(r[l])for(o=0;o<r[l].length;o++){var c=r[l][o];a[r[l][o]]=n(c)}a[l]=n(l)}for(o=0;o<i.length;o++)a[i[o]]=n(i[o]);return a}function _e(t,e,n){return n[e]!=null?n[e]:t.props[e]}function Wu(t,e){return qr(t.children,function(n){return m.cloneElement(n,{onExited:e.bind(null,n),in:!0,appear:_e(n,"appear",t),enter:_e(n,"enter",t),exit:_e(n,"exit",t)})})}function Gu(t,e,n){var r=qr(t.children),i=Hu(e,r);return Object.keys(i).forEach(function(s){var o=i[s];if(m.isValidElement(o)){var a=s in e,l=s in r,c=e[s],u=m.isValidElement(c)&&!c.props.in;l&&(!a||u)?i[s]=m.cloneElement(o,{onExited:n.bind(null,o),in:!0,exit:_e(o,"exit",t),enter:_e(o,"enter",t)}):!l&&a&&!u?i[s]=m.cloneElement(o,{in:!1}):l&&a&&m.isValidElement(c)&&(i[s]=m.cloneElement(o,{onExited:n.bind(null,o),in:c.props.in,exit:_e(o,"exit",t),enter:_e(o,"enter",t)}))}}),i}var Ku=Object.values||function(t){return Object.keys(t).map(function(e){return t[e]})},qu={component:"div",childFactory:function(e){return e}},Yr=(function(t){$u(e,t);function e(r,i){var s;s=t.call(this,r,i)||this;var o=s.handleExited.bind(Uu(s));return s.state={contextValue:{isMounting:!0},handleExited:o,firstRender:!0},s}var n=e.prototype;return n.componentDidMount=function(){this.mounted=!0,this.setState({contextValue:{isMounting:!1}})},n.componentWillUnmount=function(){this.mounted=!1},e.getDerivedStateFromProps=function(i,s){var o=s.children,a=s.handleExited,l=s.firstRender;return{children:l?Wu(i,a):Gu(i,o,a),firstRender:!1}},n.handleExited=function(i,s){var o=qr(this.props.children);i.key in o||(i.props.onExited&&i.props.onExited(s),this.mounted&&this.setState(function(a){var l=kc({},a.children);return delete l[i.key],{children:l}}))},n.render=function(){var i=this.props,s=i.component,o=i.childFactory,a=Du(i,["component","childFactory"]),l=this.state.contextValue,c=Ku(this.state.children).map(o);return delete a.appear,delete a.enter,delete a.exit,s===null?V.createElement(qi.Provider,{value:l},c):V.createElement(qi.Provider,{value:l},V.createElement(s,a,c))},e})(V.Component);Yr.propTypes={};Yr.defaultProps=qu;const Yi={};function na(t,e){const n=m.useRef(Yi);return n.current===Yi&&(n.current=t(e)),n}const Yu=[];function Xu(t){m.useEffect(t,Yu)}class Xr{static create(){return new Xr}currentId=null;start(e,n){this.clear(),this.currentId=setTimeout(()=>{this.currentId=null,n()},e)}clear=()=>{this.currentId!==null&&(clearTimeout(this.currentId),this.currentId=null)};disposeEffect=()=>this.clear}function Zu(){const t=na(Xr.create).current;return Xu(t.disposeEffect),t}function Xi(t){try{return t.matches(":focus-visible")}catch{}return!1}class on{static create(){return new on}static use(){const e=na(on.create).current,[n,r]=m.useState(!1);return e.shouldMount=n,e.setShouldMount=r,m.useEffect(e.mountEffect,[n]),e}constructor(){this.ref={current:null},this.mounted=null,this.didMount=!1,this.shouldMount=!1,this.setShouldMount=null}mount(){return this.mounted||(this.mounted=Qu(),this.shouldMount=!0,this.setShouldMount(this.shouldMount)),this.mounted}mountEffect=()=>{this.shouldMount&&!this.didMount&&this.ref.current!==null&&(this.didMount=!0,this.mounted.resolve())};start(...e){this.mount().then(()=>this.ref.current?.start(...e))}stop(...e){this.mount().then(()=>this.ref.current?.stop(...e))}pulsate(...e){this.mount().then(()=>this.ref.current?.pulsate(...e))}}function Ju(){return on.use()}function Qu(){let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n}function ed(t){const{className:e,classes:n,pulsate:r=!1,rippleX:i,rippleY:s,rippleSize:o,in:a,onExited:l,timeout:c}=t,[u,d]=m.useState(!1),h=ae(e,n.ripple,n.rippleVisible,r&&n.ripplePulsate),f={width:o,height:o,top:-(o/2)+s,left:-(o/2)+i},p=ae(n.child,u&&n.childLeaving,r&&n.childPulsate);return!a&&!u&&d(!0),m.useEffect(()=>{if(!a&&l!=null){const g=setTimeout(l,c);return()=>{clearTimeout(g)}}},[l,a,c]),v.jsx("span",{className:h,style:f,children:v.jsx("span",{className:p})})}const le=bn("MuiTouchRipple",["root","ripple","rippleVisible","ripplePulsate","child","childLeaving","childPulsate"]),ar=550,td=80,nd=It`
|
|
2
2
|
0% {
|
|
3
3
|
transform: scale(0);
|
|
4
4
|
opacity: 0.1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as c,j as e,B as u,a as y,F as g,u as P,L as D,gd as w}from"./index-
|
|
1
|
+
import{r as c,j as e,B as u,a as y,F as g,u as P,L as D,gd as w}from"./index-CHXDfsUO.js";import{d as R}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{P as E}from"./page-layout-ClvS18JI.js";import{R as d}from"./report-commentary-row-DYuYv4BH.js";import{P as v}from"./modal-CmNyWfb_.js";import{Y as p}from"./YearPickerInput-B4UXt2Dq.js";import{F}from"./funnel-Cq2G1Do_.js";import{T as C}from"./Table-3LUzGF-Y.js";import"./toggle-expansion-button-B4wRWu9m.js";import"./panel-top-open-ZI73OpgC.js";function A({year:l,setYear:h,referenceYears:o,setReferenceYears:j}){const[m,x]=c.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(v,{opened:m,onClose:()=>x(!1),withCloseButton:!0,content:e.jsxs(e.Fragment,{children:[e.jsx(p,{label:"Change report year",value:new Date(l,0,1),onChange:n=>n&&h(n?.getFullYear()),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date}),e.jsx(p,{type:"multiple",label:"Pick reference years",value:o?.map(n=>new Date(n,0,1)),onChange:n=>j(n.map(i=>i.getFullYear()).filter(i=>l!==i)),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date})]})}),e.jsx(u,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>x(!0),children:e.jsx(F,{className:"size-5"})})]})}const I=()=>{const{year:l}=y(),{setFiltersContext:h}=c.useContext(g),[o,j]=c.useState(l?Number(l):new Date().getFullYear()),[m,x]=c.useState([]),[{data:n,fetching:i}]=P({query:R(w),variables:{reportYear:o,referenceYears:m}});c.useEffect(()=>{h(e.jsx("div",{className:"flex flex-row gap-2",children:e.jsx(A,{year:o,setYear:j,referenceYears:m,setReferenceYears:x})}))},[o,i,h,m,x]);const f=n?.profitAndLossReport,r=f?.report,s=f?.reference??[];return e.jsx(E,{title:"Profit and Loss Report",children:i?e.jsx(D,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsx("div",{className:"flex flex-col gap-4",children:r&&e.jsxs(C,{highlightOnHover:!0,fontSize:"md",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{}),e.jsx("th",{children:o},o),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.year},t.year))]})}),e.jsxs("tbody",{children:[e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("th",{children:"Revenue"}),e.jsx("th",{children:r.revenue.amount.formatted}),e.jsx("th",{children:t}),s.map(a=>e.jsx("th",{children:a.revenue.amount.formatted},a.year))]}),commentaryData:r.revenue}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Cost of Sales"}),e.jsx("td",{children:r.costOfSales.amount.formatted}),e.jsx("th",{children:t}),s.map(a=>e.jsx("td",{children:a.costOfSales.amount.formatted},a.year))]}),commentaryData:r.costOfSales}),e.jsxs("tr",{children:[e.jsx("th",{children:"Gross Profit"}),e.jsx("th",{children:r.grossProfit.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.grossProfit.formatted},t.year))]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"R&D Expenses"}),e.jsx("td",{children:r.researchAndDevelopmentExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(a=>e.jsx("td",{children:a.researchAndDevelopmentExpenses.amount.formatted},a.year))]}),commentaryData:r.researchAndDevelopmentExpenses}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Marketing Expenses"}),e.jsx("td",{children:r.marketingExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(a=>e.jsx("td",{children:a.marketingExpenses.amount.formatted},a.year))]}),commentaryData:r.marketingExpenses}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Management and General Expenses"}),e.jsx("td",{children:r.managementAndGeneralExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(a=>e.jsx("td",{children:a.managementAndGeneralExpenses.amount.formatted},a.year))]}),commentaryData:r.managementAndGeneralExpenses}),e.jsxs("tr",{children:[e.jsx("th",{children:"Operating Profit"}),e.jsx("th",{children:r.operatingProfit.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.operatingProfit.formatted},t.year))]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Financial Expenses"}),e.jsx("td",{children:r.financialExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(a=>e.jsx("td",{children:a.financialExpenses.amount.formatted},a.year))]}),commentaryData:r.financialExpenses}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Other Income"}),e.jsx("td",{children:r.otherIncome.amount.formatted}),e.jsx("th",{children:t}),s.map(a=>e.jsx("td",{children:a.otherIncome.amount.formatted},a.year))]}),commentaryData:r.otherIncome}),e.jsxs("tr",{children:[e.jsx("th",{children:"Profit Before Tax"}),e.jsx("th",{children:r.profitBeforeTax.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.profitBeforeTax.formatted},t.year))]}),e.jsxs("tr",{children:[e.jsx("td",{children:"Tax"}),e.jsx("td",{children:r.tax.formatted}),e.jsx("td",{}),s.map(t=>e.jsx("td",{children:t.tax.formatted},t.year))]})]}),e.jsx("tfoot",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Net Profit"}),e.jsx("th",{children:r.netProfit.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.netProfit.formatted},t.year))]})})]})})})};export{I as ProfitAndLossReport};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as h,bA as D,j as e,bB as N,B as y,z as $,bC as k,aC as R,V as O,bD as f,bE as S,bF as C,w as F,Y as A,Z as E,_ as z,$ as P,at as M,bH as _,bu as w,T as B,aP as j,ay as p,G as L,dF as V,d6 as v,F as G,u as q,dG as U,b_ as Z,L as H,dH as J}from"./index-
|
|
1
|
+
import{r as h,bA as D,j as e,bB as N,B as y,z as $,bC as k,aC as R,V as O,bD as f,bE as S,bF as C,w as F,Y as A,Z as E,_ as z,$ as P,at as M,bH as _,bu as w,T as B,aP as j,ay as p,G as L,dF as V,d6 as v,F as G,u as q,dG as U,b_ as Z,L as H,dH as J}from"./index-CHXDfsUO.js";import{u as I}from"./use-url-query-Cy2jrPOP.js";import{P as Q}from"./page-layout-ClvS18JI.js";import{P as K}from"./modal-CmNyWfb_.js";import{F as W}from"./funnel-Cq2G1Do_.js";import{M as T}from"./MultiSelect-1WINlkTu.js";import{D as X}from"./download-csv-button-Cd0rXY7Z.js";import{B as Y}from"./business-extended-info-B2Xyih3c.js";import{P as ee,a as te}from"./panel-top-open-ZI73OpgC.js";import{T as se}from"./Table-3LUzGF-Y.js";import"./data-table-column-header-B3XsejWx.js";import"./eye-off-CqyrLNH2.js";function re({filter:t,setFilter:s,closeModal:i}){const n=$({defaultValues:{...t}}),{control:a,handleSubmit:o}=n,{selectableBusinesses:r,fetching:u}=k(),{userContext:m}=h.useContext(R),c=l=>{l.fromDate?.trim()===""&&(l.fromDate=void 0),l.toDate?.trim()===""&&(l.toDate=void 0),s(l),i()};function d(){s({}),i()}return e.jsxs(e.Fragment,{children:[u?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsx(O,{...n,children:e.jsxs("form",{onSubmit:o(c),className:"space-y-2",children:[e.jsx(f,{name:"ownerIds",control:a,defaultValue:void 0,render:({field:l,fieldState:b})=>e.jsx(T,{...l,data:r,value:l.value??(m?.context.adminBusinessId?[m?.context.adminBusinessId]:void 0),disabled:u,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:b.error?.message})}),e.jsx(f,{name:"businessIDs",control:a,defaultValue:void 0,render:({field:l,fieldState:b})=>e.jsx(T,{...l,data:r,value:l.value??void 0,disabled:u,label:"Businesses",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:b.error?.message})}),e.jsx(f,{name:"fromDate",control:a,defaultValue:t.fromDate,rules:{required:"Required",pattern:{value:S,message:"Date must be im format yyyy-mm-dd"}},render:({field:l,fieldState:b})=>e.jsx(C,{...l,onChange:x=>{const g=x?typeof x=="string"?x:F(x,"yyyy-MM-dd"):void 0;g!==l.value&&l.onChange(g)},value:l.value?new Date(l.value):void 0,label:"From Date",error:b.error?.message,required:!0,popoverProps:{withinPortal:!0}})}),e.jsx(f,{name:"toDate",control:a,defaultValue:t.toDate,rules:{pattern:{value:S,message:"Date must be im format yyyy-mm-dd"}},render:({field:l,fieldState:b})=>e.jsx(C,{...l,onChange:x=>{const g=x?typeof x=="string"?x:F(x,"yyyy-MM-dd"):void 0;g!==l.value&&l.onChange(g)},value:l.value?new Date(l.value):void 0,label:"To Date",error:b.error?.message,required:!0,popoverProps:{withinPortal:!0}})}),e.jsx(A,{name:"isShowZeroedAccounts",control:a,render:({field:l})=>e.jsxs(E,{className:"flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(z,{children:"Show zeroed accounts"})}),e.jsxs("div",{className:"flex flex-row items-center gap-1",children:[e.jsx(P,{children:e.jsx(M,{defaultChecked:t.isShowZeroedAccounts??!1,onCheckedChange:l.onChange,checked:l.value===!0})}),e.jsx("span",{children:l.value?"show":"remove"})]})]})}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Filter"}),e.jsx("button",{type:"button",className:"text-white bg-orange-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-orange-600 rounded-sm text-lg",onClick:d,children:"Clear"}),e.jsx("button",{type:"button",className:"text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:i,children:"Cancel"})]})]})})]})}function ae({filter:t,setFilter:s}){const[i,n]=h.useState(!1),[a,o]=h.useState(!D(t)),{get:r,set:u}=I();function m(d){return Object.entries(d??{}).filter(([b,x])=>x!==void 0&&Array.isArray(x)&&x.length>0).length>0}function c(d){_(d,t)||(s(d),o(m(d)))}return h.useEffect(()=>{const d=D(t)?null:encodeURIComponent(JSON.stringify(t)),l=r("trialBalanceReportFilters");d!==l&&u("trialBalanceReportFilters",d)},[t,r,u]),e.jsxs(e.Fragment,{children:[e.jsx(K,{opened:i,onClose:()=>n(!1),content:e.jsx(re,{filter:t,setFilter:c,closeModal:()=>n(!1)})}),e.jsx(N,{inline:!0,size:16,disabled:!a,children:e.jsx(y,{variant:"outline",onClick:()=>n(!0),className:"p-2",children:e.jsx(W,{size:20})})})]})}const ne=({data:t,fromDate:s,toDate:i})=>{const n=h.useCallback(async()=>{const a=oe(t),o=`trial_balance_report${s?`_${s}`:""}${i?`_${i}`:""}`;return{fileContent:a,fileName:o}},[t,s,i]);return e.jsx(X,{createFileVariables:n})},oe=t=>{let s="";s+=`Sort Code,Account Name,Debit,Credit,Balance\r
|
|
2
2
|
`;for(const[i,n]of Object.entries(t)){const a=ie(i,n);s+=a}return s+=`Report total:,,${Object.values(t).reduce((i,n)=>i+n.totalDebit,0)},${Object.values(t).reduce((i,n)=>i+n.totalCredit,0)},${Object.values(t).reduce((i,n)=>i+n.sum,0)}\r
|
|
3
3
|
`,s};function ie(t,s){let i="";return Object.values(s.sortCodes).sort((n,a)=>n.key-a.key).map(n=>{const a=le(n);i+=a}),i+=`${t.replaceAll("0","*")},Group Total:,${s.totalDebit??""},${s.totalCredit??""},${s.sum}\r
|
|
4
4
|
`,i}function le(t){let s="";s+=`${t.name}\r
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as x,cd as h,G as T,r,j as s,bB as g,ce as j,F as B,T as w,at as C,L as v,a3 as E,cf as P}from"./index-
|
|
1
|
+
import{u as x,cd as h,G as T,r,j as s,bB as g,ce as j,F as B,T as w,at as C,L as v,a3 as E,cf as P}from"./index-CHXDfsUO.js";import{E as y,P as L,C as b}from"./editable-business-trip-CFtHoHgD.js";import{I as F}from"./insert-business-trip-modal-K2wc3hgW.js";import{P as I}from"./page-layout-ClvS18JI.js";import{A as m}from"./summary-3HnUK0c0.js";import"./list-plus-B1XUUi79.js";import"./Table-3LUzGF-Y.js";import"./toggle-expansion-button-B4wRWu9m.js";import"./panel-top-open-ZI73OpgC.js";import"./MultiSelect-1WINlkTu.js";import"./similar-transactions-modal-DVKLWVDl.js";const S=({data:d,isOpened:o,shouldValidate:l})=>{const e=T(j,d),[{data:i,fetching:a}]=x({pause:!l,query:h,variables:{id:e.id}}),c=r.useMemo(()=>l?i?.businessTrip&&(i.businessTrip.uncategorizedTransactions?.length||i?.businessTrip.summary?.errors?.length):!1,[i]),u=c||e?.accountantApproval!=="APPROVED";return s.jsxs(m.Item,{value:e.id,children:[s.jsx(m.Control,{children:s.jsx(g,{inline:!0,size:12,processing:a,disabled:!u,color:c?"red":"yellow",zIndex:"auto",children:e.name})}),s.jsx(m.Panel,{children:o&&s.jsx(y,{tripId:e.id,isExtended:!0},e.id)})]})},Q=()=>{const{setFiltersContext:d}=r.useContext(B),[o,l]=r.useState([]),[e,i]=r.useState(!1),[{data:a,fetching:c}]=x({query:P});r.useEffect(()=>{if(!a?.allBusinessTrips?.length){l([]);return}const t=a.allBusinessTrips.sort((n,p)=>n.dates?.start&&p.dates?.start?n.dates.start<p.dates.start?1:-1:n.dates?.start?-1:p.dates?.start?1:n.name.toLocaleLowerCase()<p.name.toLocaleLowerCase()?-1:1);l(t)},[a?.allBusinessTrips]);const[u,f]=r.useState([]);return r.useEffect(()=>{d(s.jsxs("div",{className:"flex flex-row gap-x-5",children:[s.jsx(F,{}),s.jsx(w,{content:"Toggle business trips validation",children:s.jsxs("div",{className:"flex flex-row items-center gap-x-2",children:[s.jsx(C,{checked:e??!1,onCheckedChange:t=>i(t)}),s.jsx("span",{className:"text-sm text-gray-500",children:"Validate"})]})}),s.jsx(L,{filename:"business_trips"})]}))},[a,c,d,e]),s.jsx(I,{title:"Business Trips",description:"Manage business trips",children:o.length===0&&c?s.jsx(v,{className:"h-10 w-10 animate-spin mr-2 self-center"}):s.jsx(b,{children:s.jsx(m,{className:"w-full",multiple:!0,value:u,onChange:f,chevron:s.jsx(E,{size:"1rem"}),styles:{chevron:{"&[data-rotate]":{transform:"rotate(45deg)"}}},children:o?.map(t=>s.jsx(S,{data:o.find(n=>n.id===t.id),shouldValidate:e,isOpened:u.includes(t.id)},t.id))})})})};export{Q as BusinessTrips};
|
|
@@ -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-
|
|
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-CHXDfsUO.js";import{D as re}from"./data-table-pagination-Dnwks2up.js";import{P as ne}from"./page-layout-ClvS18JI.js";import{A as D}from"./arrow-up-down-DAgx4j1v.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 as m,bH as _,j as e,bB as k,B as I,bA as V,z as Q,bC as G,dq as q,b4 as K,dr as z,bD as y,bG as L,bE as F,bF as B,w as S,u as R,gN as X,J as P,c as U,K as $,O as J,a4 as W,W as O,F as Z,aC as ee,b8 as ae,Q as se,dV as te,gO as re,ay as ne}from"./index-DPl7-2lj.js";import{u as Y}from"./use-url-query-CXxOA1KN.js";import{P as oe}from"./page-layout-TLx4BlfR.js";import{k as ie,B as w,X as H,Y as le,l as ce,m as de,n as ue,o as me,p as pe,q as xe,r as ge}from"./chart-Dprup89Z.js";import{P as he}from"./modal-B8VWOErJ.js";import{F as fe}from"./funnel-DfkSd8MP.js";import{M as E}from"./MultiSelect-D3SvkAY7.js";import{T as be}from"./index-fSGwICur.js";import{s as je}from"./sub-QnKigTbd.js";import"./sequential-CAnleQny.js";import"./similar-transactions-modal-NWsMovPt.js";import"./addDays-DPF5RtoL.js";import"./list-plus-BQ2uDu4U.js";import"./subMonths-CfU8nlXz.js";var ye=ie({chartName:"BarChart",GraphicalChild:w,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:H},{axisType:"yAxis",AxisComp:le}],formatAxisMap:ce});function ve(s){return!s||V(s)?null:encodeURIComponent(JSON.stringify(s))}const A="balanceReportFilters",x={MONTHLY:"Monthly",BI_MONTHLY:"Bi-monthly",QUARTERLY:"Quarterly",SEMI_ANNUALLY:"Semi-Annually",ANNUALLY:"Annually"};function Ce({filter:s,setFilter:i,closeModal:c}){const{control:t,handleSubmit:r,watch:g}=Q({defaultValues:{...s}}),{selectableBusinesses:b,fetching:h}=G(),{selectableFinancialEntities:f,fetching:v}=q(),{selectableTags:p,fetching:j}=K(),M=a=>{i(a),c()},C=g("excludedTags"),o=m.useMemo(()=>p.filter(a=>!C.includes(a.value)),[C,p]),d=g("includedTags"),n=m.useMemo(()=>p.filter(a=>!d.includes(a.value)),[d,p]);return e.jsxs("form",{onSubmit:r(M),children:[e.jsxs(z,{cols:2,children:[e.jsx(y,{name:"ownerId",control:t,defaultValue:s?.ownerId,render:({field:a,fieldState:l})=>e.jsx(L,{...a,data:b,value:a.value,disabled:h,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:l.error?.message,withinPortal:!0})}),e.jsx(y,{name:"fromDate",control:t,defaultValue:s?.fromDate,rules:{pattern:{value:F,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:l})=>e.jsx(B,{...a,onChange:u=>{const T=u?typeof u=="string"?u:S(u,"yyyy-MM-dd"):void 0;T!==a.value&&a.onChange(T)},value:a.value?new Date(a.value):void 0,error:l.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(y,{name:"toDate",control:t,defaultValue:s?.toDate,rules:{pattern:{value:F,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:l})=>e.jsx(B,{...a,onChange:u=>{const T=u?typeof u=="string"?u:S(u,"yyyy-MM-dd"):void 0;T!==a.value&&a.onChange(T)},value:a.value?new Date(a.value):void 0,error:l.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(y,{name:"period",control:t,defaultValue:x.MONTHLY,render:({field:a,fieldState:l})=>e.jsx(L,{...a,data:Object.values(x).map(u=>({value:u,label:u})),value:a.value,label:"Period",maxDropdownHeight:160,error:l.error?.message,withinPortal:!0})}),e.jsx(y,{name:"excludedCounterparties",control:t,defaultValue:s.excludedCounterparties,render:({field:a,fieldState:l})=>e.jsx(E,{...a,data:f,value:a.value??[],disabled:v,label:"Excluded Counterparties",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:l.error?.message,withinPortal:!0})}),e.jsx(y,{name:"includedTags",control:t,defaultValue:s.includedTags,render:({field:a,fieldState:l})=>e.jsx(E,{...a,data:o,value:a.value??[],disabled:j,label:"Included Tags",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:l.error?.message,withinPortal:!0})}),e.jsx(y,{name:"excludedTags",control:t,defaultValue:s.excludedTags,render:({field:a,fieldState:l})=>e.jsx(E,{...a,data:n,value:a.value??[],disabled:j,label:"Excluded Tags",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:l.error?.message,withinPortal:!0})})]}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",disabled:h,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-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:c,children:"Cancel"})]})]})}function Te({filter:s,setFilter:i,initiallyOpened:c=!1}){const[t,r]=m.useState(c),[g,b]=m.useState(!!s),{get:h,set:f}=Y();m.useEffect(()=>{const p=ve(s),j=h(A);p!==j&&f(A,p)},[s,h,f]);const v=m.useCallback(p=>{_(p,s)||(i(p),b(!!p))},[s,i]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(he,{opened:t,onClose:()=>r(!1),content:e.jsx(Ce,{filter:s,setFilter:v,closeModal:()=>r(!1)}),modalSize:"xl"}),e.jsx(k,{inline:!0,size:16,disabled:!g,children:e.jsx(I,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>r(!0),children:e.jsx(fe,{className:"size-5"})})})]})}const Ne=({period:s,transactionIDs:i,onCloseExtendedTransactions:c})=>{const[{data:t,fetching:r}]=R({query:X,variables:{transactionIDs:i}}),g=m.useMemo(()=>t?.transactionsByIDs?i.map(b=>t?.transactionsByIDs.find(h=>h.id===b)).filter(Boolean):[],[t,i]);return e.jsx(P,{className:"mt-5 w-full",children:r?e.jsx(U,{}):e.jsxs(e.Fragment,{children:[e.jsx($,{children:e.jsxs(J,{className:"flex justify-between",children:[e.jsxs("span",{children:[s," Transactions"]}),e.jsx(I,{variant:"link",onClick:c,children:e.jsx(W,{className:"h-4 w-4"})})]})}),e.jsx(O,{children:e.jsx(be,{transactionsProps:g})})]})})},N={income:{label:"Income",color:"rgba(0, 255, 50, 0.5)"},expense:{label:"Expense",color:"rgba(255, 0, 0, 0.5)"},delta:{label:"Delta",color:"rgba(0, 30, 255, 0.5)"},cumulative:{label:"Cumulative Balance",color:"rgba(100, 0, 255, 0.5)"}};function we(s,i,c){switch(c){case x.MONTHLY:{const t=String(i).padStart(2,"0");return`${s}-${t}`}case x.BI_MONTHLY:{const t=i%2===0?i-1:i,r=String(t).padStart(2,"0");return`${s}-${r}`}case x.QUARTERLY:{const t=Math.ceil(i/3);return`${s}-Q${t}`}case x.SEMI_ANNUALLY:{const t=i>6?2:1;return`${s}-H${t}`}case x.ANNUALLY:return String(s)}}function Me(s,i){switch(i){case x.MONTHLY:{const[c,t]=s.split("-");return`${t}/${c}`}case x.BI_MONTHLY:{const[c,t]=s.split("-"),r=Number(t)+1,g=String(r).padStart(2,"0");return`${t}-${g}/${c}`}case x.QUARTERLY:{const[c,t]=s.split("-");return`${t}, ${c}`}case x.SEMI_ANNUALLY:{const[c,t]=s.split("-");return`${t}, ${c}`}case x.ANNUALLY:return s}}const D=te(ne.Usd),He=()=>{const{setFiltersContext:s}=m.useContext(Z),{userContext:i}=m.useContext(ee),{get:c}=Y(),t=m.useMemo(()=>{const o={ownerId:i?.context.adminBusinessId,toDate:S(new Date,"yyyy-MM-dd"),period:x.MONTHLY,fromDate:S(je(new Date,{years:1}),"yyyy-MM-dd"),excludedCounterparties:[],includedTags:[],excludedTags:[]},d=c(A);if(d)try{return JSON.parse(decodeURIComponent(d))}catch(n){console.log("Error parsing balance report filters from URL:",n)}return o},[i?.context.adminBusinessId,c]),[r,g]=m.useState(t),[b,h]=m.useState(void 0),[f,v]=m.useState(Object.keys(N)),p=m.useMemo(()=>{const{ownerId:o,fromDate:d,toDate:n}=r;return{ownerId:o,fromDate:d,toDate:n}},[r]),[{data:j,fetching:M}]=R({query:re,variables:p,pause:!r});m.useEffect(()=>{s(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(Te,{filter:r,setFilter:g,initiallyOpened:!r}),e.jsx(ae,{options:Object.entries(N).map(([o,d])=>({label:d.label,value:o})),onValueChange:v,defaultValue:f,placeholder:"Select Data Sets",variant:"default",maxCount:1})]})),h(void 0)},[j,M,r,s,g,f]),m.useEffect(()=>{g(o=>({...o,ownerId:i?.context.adminBusinessId}))},[i]);const C=m.useMemo(()=>{if(!j?.transactionsForBalanceReport)return[];const o=new Map;j.transactionsForBalanceReport.map(n=>{if(n.counterparty?.id&&(!n.isFee&&i?.context.financialAccountsBusinessesIds?.includes(n.counterparty.id)||r.excludedCounterparties?.includes(n.counterparty.id))||r.includedTags.length>0&&(!n.charge?.tags||n.charge.tags.length===0||!n.charge.tags.some(u=>r.includedTags.includes(u.id)))||r.excludedTags.length>0&&n.charge?.tags.length&&n.charge.tags.some(u=>r.excludedTags.includes(u.id)))return;const a=we(n.year,n.month,r.period);o.has(a)||o.set(a,{income:0,expense:0,delta:0,transactions:[]});const l=o.get(a);n.amountUsd.raw>0?l.income+=n.amountUsd.raw:l.expense+=n.amountUsd.raw,l.delta+=n.amountUsd.raw,l.transactions.push(n)});let d=0;return Array.from(o.entries()).sort((n,a)=>n[0].localeCompare(a[0])).map(([n,a])=>(d+=a.delta,{period:n,income:a.income,expense:a.expense,delta:a.delta,cumulative:d,transactions:a.transactions.sort((l,u)=>Math.abs(u.amountUsd.raw)-Math.abs(l.amountUsd.raw))}))},[j,r.period,r.excludedCounterparties,i?.context.financialAccountsBusinessesIds,r.includedTags,r.excludedTags]);return e.jsx(oe,{title:"Balance Report",description:"Accounts periodical balance",children:M?e.jsx(U,{}):e.jsxs(e.Fragment,{children:[e.jsxs(P,{className:"w-full",children:[e.jsx($,{children:e.jsx(se,{children:"Click specific period to expand it's transactions data"})}),e.jsx(O,{children:e.jsx(de,{config:N,className:"h-150 w-full",children:e.jsxs(ye,{accessibilityLayer:!0,data:C,onClick:o=>h(o.activeLabel),children:[e.jsx(ue,{vertical:!1}),e.jsx(H,{dataKey:"period",tickLine:!1,tickMargin:10,axisLine:!1,tickFormatter:o=>Me(o,r.period)}),e.jsx(me,{content:e.jsx(pe,{formatter:(o,d,n,a)=>{const l=`bg-[var(--color-${d})]`;return a<2?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`${l} h-2.5 w-2.5 shrink-0 rounded-[2px]`}),N[d]?.label||d,e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:D.format(Number(o))})]}):e.jsxs("div",{className:"mt-1.5 flex basis-full items-center border-t pt-1.5 text-xs font-medium text-foreground",children:[e.jsx("div",{className:`h-2.5 w-2.5 shrink-0 rounded-[2px] mr-2 ${l}`}),N[d]?.label||d,e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:D.format(Number(o))})]})}})}),e.jsx(xe,{content:e.jsx(ge,{})}),f.includes("income")&&e.jsx(w,{dataKey:"income",fill:"var(--color-income)",radius:4}),f.includes("expense")&&e.jsx(w,{dataKey:"expense",fill:"var(--color-expense)",radius:4}),f.includes("delta")&&e.jsx(w,{dataKey:"delta",fill:"var(--color-delta)",radius:4}),f.includes("cumulative")&&e.jsx(w,{dataKey:"cumulative",fill:"var(--color-cumulative)",radius:4})]})})})]}),b&&e.jsx(Ne,{period:b,onCloseExtendedTransactions:()=>h(void 0),transactionIDs:C.find(o=>o.period===b)?.transactions.map(o=>o.id)??[]})]})})};export{He as BalanceReport};
|
|
1
|
+
import{r as m,bH as _,j as e,bB as k,B as I,bA as V,z as Q,bC as G,dq as q,b4 as K,dr as z,bD as y,bG as L,bE as F,bF as B,w as S,u as R,gN as X,J as P,c as U,K as $,O as J,a4 as W,W as O,F as Z,aC as ee,b8 as ae,Q as se,dV as te,gO as re,ay as ne}from"./index-CHXDfsUO.js";import{u as Y}from"./use-url-query-Cy2jrPOP.js";import{P as oe}from"./page-layout-ClvS18JI.js";import{k as ie,B as w,X as H,Y as le,l as ce,m as de,n as ue,o as me,p as pe,q as xe,r as ge}from"./chart-DEoAP57x.js";import{P as he}from"./modal-CmNyWfb_.js";import{F as fe}from"./funnel-Cq2G1Do_.js";import{M as E}from"./MultiSelect-1WINlkTu.js";import{T as be}from"./index-O1zv8-qd.js";import{s as je}from"./sub-Cl3G90K_.js";import"./sequential-CAnleQny.js";import"./similar-transactions-modal-DVKLWVDl.js";import"./addDays-B6KOnr9d.js";import"./list-plus-B1XUUi79.js";import"./subMonths-SBqdI_BY.js";var ye=ie({chartName:"BarChart",GraphicalChild:w,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:H},{axisType:"yAxis",AxisComp:le}],formatAxisMap:ce});function ve(s){return!s||V(s)?null:encodeURIComponent(JSON.stringify(s))}const A="balanceReportFilters",x={MONTHLY:"Monthly",BI_MONTHLY:"Bi-monthly",QUARTERLY:"Quarterly",SEMI_ANNUALLY:"Semi-Annually",ANNUALLY:"Annually"};function Ce({filter:s,setFilter:i,closeModal:c}){const{control:t,handleSubmit:r,watch:g}=Q({defaultValues:{...s}}),{selectableBusinesses:b,fetching:h}=G(),{selectableFinancialEntities:f,fetching:v}=q(),{selectableTags:p,fetching:j}=K(),M=a=>{i(a),c()},C=g("excludedTags"),o=m.useMemo(()=>p.filter(a=>!C.includes(a.value)),[C,p]),d=g("includedTags"),n=m.useMemo(()=>p.filter(a=>!d.includes(a.value)),[d,p]);return e.jsxs("form",{onSubmit:r(M),children:[e.jsxs(z,{cols:2,children:[e.jsx(y,{name:"ownerId",control:t,defaultValue:s?.ownerId,render:({field:a,fieldState:l})=>e.jsx(L,{...a,data:b,value:a.value,disabled:h,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:l.error?.message,withinPortal:!0})}),e.jsx(y,{name:"fromDate",control:t,defaultValue:s?.fromDate,rules:{pattern:{value:F,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:l})=>e.jsx(B,{...a,onChange:u=>{const T=u?typeof u=="string"?u:S(u,"yyyy-MM-dd"):void 0;T!==a.value&&a.onChange(T)},value:a.value?new Date(a.value):void 0,error:l.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(y,{name:"toDate",control:t,defaultValue:s?.toDate,rules:{pattern:{value:F,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:l})=>e.jsx(B,{...a,onChange:u=>{const T=u?typeof u=="string"?u:S(u,"yyyy-MM-dd"):void 0;T!==a.value&&a.onChange(T)},value:a.value?new Date(a.value):void 0,error:l.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(y,{name:"period",control:t,defaultValue:x.MONTHLY,render:({field:a,fieldState:l})=>e.jsx(L,{...a,data:Object.values(x).map(u=>({value:u,label:u})),value:a.value,label:"Period",maxDropdownHeight:160,error:l.error?.message,withinPortal:!0})}),e.jsx(y,{name:"excludedCounterparties",control:t,defaultValue:s.excludedCounterparties,render:({field:a,fieldState:l})=>e.jsx(E,{...a,data:f,value:a.value??[],disabled:v,label:"Excluded Counterparties",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:l.error?.message,withinPortal:!0})}),e.jsx(y,{name:"includedTags",control:t,defaultValue:s.includedTags,render:({field:a,fieldState:l})=>e.jsx(E,{...a,data:o,value:a.value??[],disabled:j,label:"Included Tags",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:l.error?.message,withinPortal:!0})}),e.jsx(y,{name:"excludedTags",control:t,defaultValue:s.excludedTags,render:({field:a,fieldState:l})=>e.jsx(E,{...a,data:n,value:a.value??[],disabled:j,label:"Excluded Tags",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:l.error?.message,withinPortal:!0})})]}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",disabled:h,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-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:c,children:"Cancel"})]})]})}function Te({filter:s,setFilter:i,initiallyOpened:c=!1}){const[t,r]=m.useState(c),[g,b]=m.useState(!!s),{get:h,set:f}=Y();m.useEffect(()=>{const p=ve(s),j=h(A);p!==j&&f(A,p)},[s,h,f]);const v=m.useCallback(p=>{_(p,s)||(i(p),b(!!p))},[s,i]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(he,{opened:t,onClose:()=>r(!1),content:e.jsx(Ce,{filter:s,setFilter:v,closeModal:()=>r(!1)}),modalSize:"xl"}),e.jsx(k,{inline:!0,size:16,disabled:!g,children:e.jsx(I,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>r(!0),children:e.jsx(fe,{className:"size-5"})})})]})}const Ne=({period:s,transactionIDs:i,onCloseExtendedTransactions:c})=>{const[{data:t,fetching:r}]=R({query:X,variables:{transactionIDs:i}}),g=m.useMemo(()=>t?.transactionsByIDs?i.map(b=>t?.transactionsByIDs.find(h=>h.id===b)).filter(Boolean):[],[t,i]);return e.jsx(P,{className:"mt-5 w-full",children:r?e.jsx(U,{}):e.jsxs(e.Fragment,{children:[e.jsx($,{children:e.jsxs(J,{className:"flex justify-between",children:[e.jsxs("span",{children:[s," Transactions"]}),e.jsx(I,{variant:"link",onClick:c,children:e.jsx(W,{className:"h-4 w-4"})})]})}),e.jsx(O,{children:e.jsx(be,{transactionsProps:g})})]})})},N={income:{label:"Income",color:"rgba(0, 255, 50, 0.5)"},expense:{label:"Expense",color:"rgba(255, 0, 0, 0.5)"},delta:{label:"Delta",color:"rgba(0, 30, 255, 0.5)"},cumulative:{label:"Cumulative Balance",color:"rgba(100, 0, 255, 0.5)"}};function we(s,i,c){switch(c){case x.MONTHLY:{const t=String(i).padStart(2,"0");return`${s}-${t}`}case x.BI_MONTHLY:{const t=i%2===0?i-1:i,r=String(t).padStart(2,"0");return`${s}-${r}`}case x.QUARTERLY:{const t=Math.ceil(i/3);return`${s}-Q${t}`}case x.SEMI_ANNUALLY:{const t=i>6?2:1;return`${s}-H${t}`}case x.ANNUALLY:return String(s)}}function Me(s,i){switch(i){case x.MONTHLY:{const[c,t]=s.split("-");return`${t}/${c}`}case x.BI_MONTHLY:{const[c,t]=s.split("-"),r=Number(t)+1,g=String(r).padStart(2,"0");return`${t}-${g}/${c}`}case x.QUARTERLY:{const[c,t]=s.split("-");return`${t}, ${c}`}case x.SEMI_ANNUALLY:{const[c,t]=s.split("-");return`${t}, ${c}`}case x.ANNUALLY:return s}}const D=te(ne.Usd),He=()=>{const{setFiltersContext:s}=m.useContext(Z),{userContext:i}=m.useContext(ee),{get:c}=Y(),t=m.useMemo(()=>{const o={ownerId:i?.context.adminBusinessId,toDate:S(new Date,"yyyy-MM-dd"),period:x.MONTHLY,fromDate:S(je(new Date,{years:1}),"yyyy-MM-dd"),excludedCounterparties:[],includedTags:[],excludedTags:[]},d=c(A);if(d)try{return JSON.parse(decodeURIComponent(d))}catch(n){console.log("Error parsing balance report filters from URL:",n)}return o},[i?.context.adminBusinessId,c]),[r,g]=m.useState(t),[b,h]=m.useState(void 0),[f,v]=m.useState(Object.keys(N)),p=m.useMemo(()=>{const{ownerId:o,fromDate:d,toDate:n}=r;return{ownerId:o,fromDate:d,toDate:n}},[r]),[{data:j,fetching:M}]=R({query:re,variables:p,pause:!r});m.useEffect(()=>{s(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(Te,{filter:r,setFilter:g,initiallyOpened:!r}),e.jsx(ae,{options:Object.entries(N).map(([o,d])=>({label:d.label,value:o})),onValueChange:v,defaultValue:f,placeholder:"Select Data Sets",variant:"default",maxCount:1})]})),h(void 0)},[j,M,r,s,g,f]),m.useEffect(()=>{g(o=>({...o,ownerId:i?.context.adminBusinessId}))},[i]);const C=m.useMemo(()=>{if(!j?.transactionsForBalanceReport)return[];const o=new Map;j.transactionsForBalanceReport.map(n=>{if(n.counterparty?.id&&(!n.isFee&&i?.context.financialAccountsBusinessesIds?.includes(n.counterparty.id)||r.excludedCounterparties?.includes(n.counterparty.id))||r.includedTags.length>0&&(!n.charge?.tags||n.charge.tags.length===0||!n.charge.tags.some(u=>r.includedTags.includes(u.id)))||r.excludedTags.length>0&&n.charge?.tags.length&&n.charge.tags.some(u=>r.excludedTags.includes(u.id)))return;const a=we(n.year,n.month,r.period);o.has(a)||o.set(a,{income:0,expense:0,delta:0,transactions:[]});const l=o.get(a);n.amountUsd.raw>0?l.income+=n.amountUsd.raw:l.expense+=n.amountUsd.raw,l.delta+=n.amountUsd.raw,l.transactions.push(n)});let d=0;return Array.from(o.entries()).sort((n,a)=>n[0].localeCompare(a[0])).map(([n,a])=>(d+=a.delta,{period:n,income:a.income,expense:a.expense,delta:a.delta,cumulative:d,transactions:a.transactions.sort((l,u)=>Math.abs(u.amountUsd.raw)-Math.abs(l.amountUsd.raw))}))},[j,r.period,r.excludedCounterparties,i?.context.financialAccountsBusinessesIds,r.includedTags,r.excludedTags]);return e.jsx(oe,{title:"Balance Report",description:"Accounts periodical balance",children:M?e.jsx(U,{}):e.jsxs(e.Fragment,{children:[e.jsxs(P,{className:"w-full",children:[e.jsx($,{children:e.jsx(se,{children:"Click specific period to expand it's transactions data"})}),e.jsx(O,{children:e.jsx(de,{config:N,className:"h-150 w-full",children:e.jsxs(ye,{accessibilityLayer:!0,data:C,onClick:o=>h(o.activeLabel),children:[e.jsx(ue,{vertical:!1}),e.jsx(H,{dataKey:"period",tickLine:!1,tickMargin:10,axisLine:!1,tickFormatter:o=>Me(o,r.period)}),e.jsx(me,{content:e.jsx(pe,{formatter:(o,d,n,a)=>{const l=`bg-[var(--color-${d})]`;return a<2?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`${l} h-2.5 w-2.5 shrink-0 rounded-[2px]`}),N[d]?.label||d,e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:D.format(Number(o))})]}):e.jsxs("div",{className:"mt-1.5 flex basis-full items-center border-t pt-1.5 text-xs font-medium text-foreground",children:[e.jsx("div",{className:`h-2.5 w-2.5 shrink-0 rounded-[2px] mr-2 ${l}`}),N[d]?.label||d,e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:D.format(Number(o))})]})}})}),e.jsx(xe,{content:e.jsx(ge,{})}),f.includes("income")&&e.jsx(w,{dataKey:"income",fill:"var(--color-income)",radius:4}),f.includes("expense")&&e.jsx(w,{dataKey:"expense",fill:"var(--color-expense)",radius:4}),f.includes("delta")&&e.jsx(w,{dataKey:"delta",fill:"var(--color-delta)",radius:4}),f.includes("cumulative")&&e.jsx(w,{dataKey:"cumulative",fill:"var(--color-cumulative)",radius:4})]})})})]}),b&&e.jsx(Ne,{period:b,onCloseExtendedTransactions:()=>h(void 0),transactionIDs:C.find(o=>o.period===b)?.transactions.map(o=>o.id)??[]})]})})};export{He as BalanceReport};
|
|
@@ -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-
|
|
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-CHXDfsUO.js";import{D as T}from"./deposits-transactions-table-u4MVVhDE.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 +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-DPl7-2lj.js";import{d as R}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{u as z}from"./use-url-query-CXxOA1KN.js";import{C as F,u as de,a as V,b as k,M as he}from"./charges-table-CxqehZsM.js";import{E as me,I as xe,M as ue}from"./match-document-modal-DV5QgP9r.js";import{P as pe}from"./page-layout-TLx4BlfR.js";import{P as v,a as w}from"./panel-top-open-CYZjCIwy.js";import{T as O}from"./toggle-expansion-button-CwQXYYlU.js";import{T as B}from"./Table-9QP-vc-X.js";import{c as ge}from"./charges-filters-DY8PlVOu.js";import{P as je}from"./modal-B8VWOErJ.js";import{F as fe}from"./funnel-DfkSd8MP.js";import"./index-fSGwICur.js";import"./similar-transactions-modal-NWsMovPt.js";import"./addDays-DPF5RtoL.js";import"./list-plus-BQ2uDu4U.js";import"./summary-Dfk-pO3i.js";import"./deposits-transactions-table-DTZENoQ4.js";import"./Checkbox-BvYKsSPz.js";import"./accordion-332bwqF-.js";import"./data-table-column-header-CSxC7ltI.js";import"./eye-off-ByAlEmCd.js";import"./YearPickerInput-CjPL53OR.js";import"./insert-business-trip-modal-BUhwQLU3.js";import"./accounter-table-CKI-wnyb.js";import"./sub-QnKigTbd.js";import"./subMonths-CfU8nlXz.js";import"./MultiSelect-D3SvkAY7.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-CHXDfsUO.js";import{d as R}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{u as z}from"./use-url-query-Cy2jrPOP.js";import{C as F,u as de,a as V,b as k,M as he}from"./charges-table-BqKHuWkm.js";import{E as me,I as xe,M as ue}from"./match-document-modal-CtJxEQcv.js";import{P as pe}from"./page-layout-ClvS18JI.js";import{P as v,a as w}from"./panel-top-open-ZI73OpgC.js";import{T as O}from"./toggle-expansion-button-B4wRWu9m.js";import{T as B}from"./Table-3LUzGF-Y.js";import{c as ge}from"./charges-filters-DX5qB120.js";import{P as je}from"./modal-CmNyWfb_.js";import{F as fe}from"./funnel-Cq2G1Do_.js";import"./index-O1zv8-qd.js";import"./similar-transactions-modal-DVKLWVDl.js";import"./addDays-B6KOnr9d.js";import"./list-plus-B1XUUi79.js";import"./summary-3HnUK0c0.js";import"./deposits-transactions-table-u4MVVhDE.js";import"./Checkbox-DQnX-IHw.js";import"./accordion-3APui6eL.js";import"./data-table-column-header-B3XsejWx.js";import"./eye-off-CqyrLNH2.js";import"./YearPickerInput-B4UXt2Dq.js";import"./insert-business-trip-modal-K2wc3hgW.js";import"./accounter-table-DZctE2Ds.js";import"./sub-Cl3G90K_.js";import"./subMonths-SBqdI_BY.js";import"./MultiSelect-1WINlkTu.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{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-
|
|
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-CHXDfsUO.js";import{u as S}from"./use-url-query-Cy2jrPOP.js";import{P as Z}from"./page-layout-ClvS18JI.js";import{F as K}from"./funnel-Cq2G1Do_.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};
|