@accounter/client 0.0.9-alpha-20251209151133-429317b45715945095bf1dd8e549512af3722d03 → 0.0.9-alpha-20251209170231-980cc730914111644c9194dac5ac995a09e28c74
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-BHVKlxRj.js → Checkbox-CoEj3QSE.js} +1 -1
- package/dist/assets/{MultiSelect-DY08OexD.js → MultiSelect-DRJD_QDr.js} +1 -1
- package/dist/assets/{Progress-CkBW27DM.js → Progress-CU1fWOjF.js} +1 -1
- package/dist/assets/{Table-bhKB4PFK.js → Table-C5b9rbOB.js} +1 -1
- package/dist/assets/{Typography-DclIL89E.js → Typography-CJ6IUHKs.js} +1 -1
- package/dist/assets/{YearPickerInput-DgK0Ih6X.js → YearPickerInput-DD-O605S.js} +1 -1
- package/dist/assets/{accordion-CAxRDsFz.js → accordion-Csw2mWiO.js} +1 -1
- package/dist/assets/{accountant-approvals-Dgsw0WDb.js → accountant-approvals-BeUBLtnd.js} +1 -1
- package/dist/assets/{accounter-table-DIm6Wedu.js → accounter-table-CLNNqdXm.js} +1 -1
- package/dist/assets/{addDays-CpwSVE6j.js → addDays-oqtNz11p.js} +1 -1
- package/dist/assets/{all-charges-CS_0zCEZ.js → all-charges-BK_c2XcZ.js} +1 -1
- package/dist/assets/{arrow-up-down-BCKzoFzo.js → arrow-up-down-BepSQkkk.js} +1 -1
- package/dist/assets/{building-2-Cp2Es1mt.js → building-2-DoYjr9zp.js} +1 -1
- package/dist/assets/{business-B1WVYc0i.js → business-C49SW3ik.js} +2 -2
- package/dist/assets/{business-extended-info-NwMS1Rj6.js → business-extended-info-CaoOYPT8.js} +1 -1
- package/dist/assets/{business-header-D7w2Xzis.js → business-header-gf-FUFaN.js} +1 -1
- package/dist/assets/{business-ledger-filters-BBCKjVgu.js → business-ledger-filters-Clr_J6Pb.js} +1 -1
- package/dist/assets/{business-ledger-single-CjmguyFq.js → business-ledger-single-CeMmKYhH.js} +1 -1
- package/dist/assets/{business-trip-BljjobKa.js → business-trip-DNDWlM8w.js} +1 -1
- package/dist/assets/charge-NQDW3QqJ.js +1 -0
- package/dist/assets/{charges-filters-D_ruML4x.js → charges-filters-nFUpOOgf.js} +1 -1
- package/dist/assets/{charges-ledger-validation-RNuvPfFo.js → charges-ledger-validation-zMQsg1pC.js} +1 -1
- package/dist/assets/{charges-table-Dmz1Fxim.js → charges-table-CTMLwet4.js} +1 -1
- package/dist/assets/{chart-MqLuc9m0.js → chart-CcwcQbqJ.js} +1 -1
- package/dist/assets/{contracts-DCmvv-5I.js → contracts-CAZC6d8B.js} +1 -1
- package/dist/assets/{data-table-column-header-CT7O7uRT.js → data-table-column-header-BxsKrjBX.js} +1 -1
- package/dist/assets/{data-table-pagination-Bn6-S7wX.js → data-table-pagination-wIOuSOqc.js} +1 -1
- package/dist/assets/{deposits-transactions-table-BAObjoYX.js → deposits-transactions-table-jhVmfuNs.js} +1 -1
- package/dist/assets/{download-csv-button-BsXK9P76.js → download-csv-button-CxFM5ZN1.js} +1 -1
- package/dist/assets/{edit-issue-document-modal-CG9FH4t_.js → edit-issue-document-modal-CI2VPVkB.js} +1 -1
- package/dist/assets/{editable-business-trip-CH61WHL7.js → editable-business-trip-B388mlUw.js} +1 -1
- package/dist/assets/{eye-off-Cc-ssiRk.js → eye-off-CfHy9jRk.js} +1 -1
- package/dist/assets/{funnel-4UXATjU3.js → funnel-Cn1E8rCW.js} +1 -1
- package/dist/assets/{index-JJZ0k_k8.js → index-2Ym7mPTf.js} +1 -1
- package/dist/assets/{index-CPuaqVQw.js → index-BM4xRMf6.js} +1 -1
- package/dist/assets/{index-D8HuUMKu.js → index-BWtxBLCR.js} +1 -1
- package/dist/assets/{index-CFrclniY.js → index-BYgtjSMY.js} +1 -1
- package/dist/assets/{index-BHTel4x6.js → index-BbVwSP6k.js} +1 -1
- package/dist/assets/{index-DYUcGCvp.js → index-Bcc1EVhw.js} +1 -1
- package/dist/assets/{index-Cz49agDK.js → index-BcxhLoO7.js} +1 -1
- package/dist/assets/{index-lpyXbMDd.js → index-Bq4ew9mE.js} +1 -1
- package/dist/assets/{index-De4VpPkV.js → index-BvTcJJXh.js} +1 -1
- package/dist/assets/{index-DQsGXPYg.js → index-CM5jGkPB.js} +1 -1
- package/dist/assets/{index-DVU7w2C4.js → index-D0scMlrm.js} +1 -1
- package/dist/assets/{index-Cw81Wg3b.js → index-DAjmDqPJ.js} +1 -1
- package/dist/assets/{index-CFOw7tWS.js → index-DBLC9vCJ.js} +1 -1
- package/dist/assets/{index-D42PKeAo.js → index-DHYVY3Bq.js} +1 -1
- package/dist/assets/{index-YQXRLoVL.js → index-DrY2LoBX.js} +1 -1
- package/dist/assets/{index-CjcufnQY.js → index-DuJJkBba.js} +1 -1
- package/dist/assets/{index-BNMU0DUr.js → index-ITLfbYgx.js} +1 -1
- package/dist/assets/{index-qyF0HH0t.js → index-MvqJWvoO.js} +1 -1
- package/dist/assets/{index-BNGi9a78.js → index-U9BN8IFT.js} +1 -1
- package/dist/assets/{index-C3pJ0CeY.js → index-W0j_QNs_.js} +1 -1
- package/dist/assets/{index-DPzHTlTo.js → index-bfQMiA8o.js} +1 -1
- package/dist/assets/{index-BWtniMl1.js → index-lzDrXIqE.js} +1 -1
- package/dist/assets/{index-xOkwbA9z.js → index-oJIMvEL1.js} +1 -1
- package/dist/assets/{index-CHtpNrAW.js → index-qAF5sGRO.js} +4 -4
- package/dist/assets/{index-C9bDcLJk.js → index-ultzcMfl.js} +1 -1
- package/dist/assets/{index-SV9JUpu6.js → index-vQiKHr5F.js} +1 -1
- package/dist/assets/{index.es-DnF4r6Dk.js → index.es-Cbmre-3y.js} +1 -1
- package/dist/assets/{insert-business-trip-modal-CQv_ZpxL.js → insert-business-trip-modal-_imZNOPq.js} +1 -1
- package/dist/assets/issue-document-BbxmF4sT.js +1 -0
- package/dist/assets/{list-plus-DsfXaxO5.js → list-plus-DEqGGtBU.js} +1 -1
- package/dist/assets/{login-page-DKeixPVN.js → login-page-CUSymIR_.js} +1 -1
- package/dist/assets/{match-document-modal-LhAEyv1y.js → match-document-modal-CQ8I-zEU.js} +1 -1
- package/dist/assets/{missing-info-charges-DCVKrfEr.js → missing-info-charges-CFt2F-LA.js} +1 -1
- package/dist/assets/{modal-YTgF-R03.js → modal-D_KAAYCr.js} +1 -1
- package/dist/assets/{modify-contract-dialog-D7Z8bOws.js → modify-contract-dialog-DSwRl9du.js} +1 -1
- package/dist/assets/{page-layout-Cs7LzhPs.js → page-layout-7iCtDTzs.js} +1 -1
- package/dist/assets/{page-not-found-Cs086tZP.js → page-not-found-CsSbBsPd.js} +1 -1
- package/dist/assets/{panel-top-open-DfXV4xoB.js → panel-top-open-CVvVnpDH.js} +1 -1
- package/dist/assets/{pencil-3H1z0dQ2.js → pencil-CpYjq1NY.js} +1 -1
- package/dist/assets/{report-commentary-row-DNTsFgf_.js → report-commentary-row-CgmMnDJu.js} +1 -1
- package/dist/assets/{save-D2KnX2aJ.js → save-C6S-RD-9.js} +1 -1
- package/dist/assets/{similar-transactions-modal-DN6pAqBR.js → similar-transactions-modal-Dn4dMAAO.js} +1 -1
- package/dist/assets/{sub-UiWBdxTZ.js → sub-DgacWlyb.js} +1 -1
- package/dist/assets/subMonths-oKYDpkY2.js +1 -0
- package/dist/assets/{summary-DLRjO19t.js → summary-ZTGFg2Jz.js} +1 -1
- package/dist/assets/{toggle-expansion-button-ByfnT_sn.js → toggle-expansion-button-DYABrNZG.js} +1 -1
- package/dist/assets/tooltip-Br1wJ5zm.js +1 -0
- package/dist/assets/{use-url-query-DMunwqS4.js → use-url-query-CYeryni6.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/src/components/business/admin/financial-account-section.tsx +2 -0
- package/src/components/financial-accounts/financial-account-card.tsx +4 -0
- package/src/components/financial-accounts/modify-financial-account-dialog.tsx +19 -0
- package/src/components/financial-accounts/types.ts +1 -0
- package/src/gql/gql.ts +3 -3
- package/src/gql/graphql.ts +5 -2
- package/dist/assets/charge-ChPubJah.js +0 -1
- package/dist/assets/issue-document-DJMGPj2s.js +0 -1
- package/dist/assets/subMonths-DZvdAXT7.js +0 -1
- package/dist/assets/tooltip-0-bix6mQ.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{v as j,r as l,F as S,u as C,j as e,T as h,B as g,bq as m,ay as n,L as N,br as v,bs as R}from"./index-
|
|
1
|
+
import{v as j,r as l,F as S,u as C,j as e,T as h,B as g,bq as m,ay as n,L as N,br as v,bs as R}from"./index-qAF5sGRO.js";import{u as T}from"./use-url-query-CYeryni6.js";import{A as E}from"./accounter-table-CLNNqdXm.js";import{P as L}from"./page-layout-7iCtDTzs.js";import{B as k}from"./business-extended-info-CaoOYPT8.js";import{B as F,M as z}from"./business-ledger-filters-Clr_J6Pb.js";import{P as B,a as I}from"./panel-top-open-CVvVnpDH.js";import{T as A}from"./Table-C5b9rbOB.js";import"./data-table-column-header-BxsKrjBX.js";import"./eye-off-CfHy9jRk.js";import"./download-csv-button-CxFM5ZN1.js";import"./modal-D_KAAYCr.js";import"./funnel-Cn1E8rCW.js";import"./MultiSelect-DRJD_QDr.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(S),[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}]=C({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(h,{label:"Expand all accounts",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(h,{label:"Expand all currencies",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]),f=[{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:[f.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:f,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 +1 @@
|
|
|
1
|
-
import{u as b,r as o,j as a,B as D,bX as R,gj as w,ag as i,bU as f,bK as y,bL as C,bM as s,bN as N,b_ as d,bO as I,bP as r,d5 as v,fy as B,i8 as F,c1 as E,c2 as S}from"./index-
|
|
1
|
+
import{u as b,r as o,j as a,B as D,bX as R,gj as w,ag as i,bU as f,bK as y,bL as C,bM as s,bN as N,b_ as d,bO as I,bP as r,d5 as v,fy as B,i8 as F,c1 as E,c2 as S}from"./index-qAF5sGRO.js";import{D as T}from"./deposits-transactions-table-jhVmfuNs.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:S(),getSortedRowModel:E(),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,4 +1,4 @@
|
|
|
1
|
-
import{v as it,r as m,dd as Nc,aF as V,dh as kc,aG as ae,j as v,dg as vn,dG as It,dH as ge,dI as Ho,di as Lc,dJ as Vc,dK as nn,dL as jc,bw as Fi,D as _r,aU as zr,bx as Fc,B as ee,x as $r,al as Ur,am as Hr,y as Wo,by as Bc,aC as _c,bz as An,bA as Bi,bB as _i,w as rn,at as Go,a2 as Ko,bD as zc,g as qo,dM as $c,t as Pe,i as Yo,u as rr,dN as Uc,bU as Hc,b$ as Wc,c1 as Gc,c0 as Kc,c2 as qc,L as Xo,I as Wr,bK as Yc,bL as Xc,bM as Nn,bN as Zc,b_ as zi,bO as Jc,bP as $i,bV as Zo,bW as Jo,bY as Qo,dO as Qc,dP as eu,dQ as sn,dR as tu,z 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,dS as du,e as hu,a4 as fu,ag as Hi,dT as pu,dU as gu,dV as Wi,cs as mu,ay as vu,F as yu,a$ as bu,dW as Tu,dX as xu}from"./index-
|
|
1
|
+
import{v as it,r as m,dd as Nc,aF as V,dh as kc,aG as ae,j as v,dg as vn,dG as It,dH as ge,dI as Ho,di as Lc,dJ as Vc,dK as nn,dL as jc,bw as Fi,D as _r,aU as zr,bx as Fc,B as ee,x as $r,al as Ur,am as Hr,y as Wo,by as Bc,aC as _c,bz as An,bA as Bi,bB as _i,w as rn,at as Go,a2 as Ko,bD as zc,g as qo,dM as $c,t as Pe,i as Yo,u as rr,dN as Uc,bU as Hc,b$ as Wc,c1 as Gc,c0 as Kc,c2 as qc,L as Xo,I as Wr,bK as Yc,bL as Xc,bM as Nn,bN as Zc,b_ as zi,bO as Jc,bP as $i,bV as Zo,bW as Jo,bY as Qo,dO as Qc,dP as eu,dQ as sn,dR as tu,z 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,dS as du,e as hu,a4 as fu,ag as Hi,dT as pu,dU as gu,dV as Wi,cs as mu,ay as vu,F as yu,a$ as bu,dW as Tu,dX as xu}from"./index-qAF5sGRO.js";import{u as ea}from"./use-url-query-CYeryni6.js";import{T as yn}from"./tooltip-Br1wJ5zm.js";import{A as Gi}from"./arrow-up-down-BepSQkkk.js";import{D as Su}from"./download-csv-button-CxFM5ZN1.js";import{B as wu}from"./business-extended-info-CaoOYPT8.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-CJ6IUHKs.js";import{P as Cu}from"./pencil-CpYjq1NY.js";import{P as Eu,a as Ou}from"./panel-top-open-CVvVnpDH.js";import{F as Pu}from"./funnel-Cn1E8rCW.js";import{M as Mu}from"./MultiSelect-DRJD_QDr.js";import"./data-table-column-header-BxsKrjBX.js";import"./eye-off-CfHy9jRk.js";const Iu=[["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"}]],Ru=it("cloud-cog",Iu);const Au=[["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"}]],Nu=it("cloud-upload",Au);const ku=[["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=it("ellipsis",ku);const Lu=[["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"}]],Vu=it("folder-open",Lu);const ju=[["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"}]],Fu=it("folder-plus",ju);const Bu=[["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"}]],_u=it("folder",Bu);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 zu(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,or(t,e)}const qi=V.createContext(null);function $u(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 Uu(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 Hu(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 Wu(t,e,n){var r=qr(t.children),i=Uu(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 Gu=Object.values||function(t){return Object.keys(t).map(function(e){return t[e]})},Ku={component:"div",childFactory:function(e){return e}},Yr=(function(t){zu(e,t);function e(r,i){var s;s=t.call(this,r,i)||this;var o=s.handleExited.bind($u(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?Hu(i,a):Wu(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=Gu(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=Ku;const Yi={};function na(t,e){const n=m.useRef(Yi);return n.current===Yi&&(n.current=t(e)),n}const qu=[];function Yu(t){m.useEffect(t,qu)}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 Xu(){const t=na(Xr.create).current;return Yu(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=Ju(),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 Zu(){return on.use()}function Ju(){let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n}function Qu(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,ed=80,td=It`
|
|
2
2
|
0% {
|
|
3
3
|
transform: scale(0);
|
|
4
4
|
opacity: 0.1;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as u,j as e,w as b,G as R,gB as M,F as $,u as k,bU as B,L as P,bK as T,bL as L,bM as d,bN as V,b_ as C,bO as S,bP as t,gC as Y,c0 as K,c2 as O,dT as H,ay as z}from"./index-
|
|
1
|
+
import{r as u,j as e,w as b,G as R,gB as M,F as $,u as k,bU as B,L as P,bK as T,bL as L,bM as d,bN as V,b_ as C,bO as S,bP as t,gC as Y,c0 as K,c2 as O,dT as H,ay as z}from"./index-qAF5sGRO.js";import{D as A}from"./data-table-pagination-wIOuSOqc.js";import{P as _}from"./page-layout-7iCtDTzs.js";import{D as q}from"./download-csv-button-CxFM5ZN1.js";import{Y as G}from"./YearPickerInput-DD-O605S.js";const Q=({data:a,year:s})=>{const n=u.useCallback(async()=>{if(!a)return{fileContent:"",fileName:""};const x=R(M,a),m=U(x),l=`${s}_ledger`;return{fileContent:m,fileName:l}},[a,s]);return a?e.jsx(q,{createFileVariables:n}):e.jsx("div",{})},F=[{key:"",valueFn:()=>""},{key:"",valueFn:()=>""},{key:"Counterparty",valueFn:a=>j(a.counterParty?.name??"")},{key:"Invoice Date",valueFn:a=>b(a.invoiceDate,"yyyy-MM-dd")},{key:"Value Date",valueFn:a=>b(a.valueDate,"yyyy-MM-dd")},{key:"Reference",valueFn:a=>a.reference?`"${j(a.reference)}"`:""},{key:"Description",valueFn:a=>a.description?`"${j(a.description)}"`:""},{key:"Debit Amount",valueFn:a=>a.amount.raw<0?Math.abs(a.amount.raw).toFixed(2):""},{key:"Credit Amount",valueFn:a=>a.amount.raw>=0?a.amount.raw.toFixed(2):""},{key:"Balance",valueFn:a=>a.balance.toFixed(2)}],U=a=>{const s=[F.map(({key:n})=>n).join(",")];return a.financialEntitiesInfo.map(n=>{const x=`${j(n.entity.name)},${n.entity.sortCode?.key}`,m=`,Opening Balance,,,,,,,,${n.openingBalance.raw.toFixed(2)}`,l=`Total,${j(n.entity.name)},,,,,,,${Math.abs(n.totalDebit.raw).toFixed(2)} Debit,`,g=`,,,,,,,,${n.totalCredit.raw.toFixed(2)} Credit,${n.closingBalance.raw.toFixed(2)}`,v=`,,,,,,,,${(n.totalCredit.raw-n.totalDebit.raw).toFixed(2)} Diff,`;s.push(x,m,...n.records.map(o=>F.map(({valueFn:D})=>D(o)).join(",")),l,g,v)}),s.join(`\r
|
|
2
2
|
`)};function j(a){return a.replace(/"/g,'""').replace(/,/g,".")}const c=H(z.Ils),E=[{id:"placeholder",header:"",cell:()=>null},{id:"counterparty",accessorKey:"counterparty",header:"Counterparty",cell:({row:a})=>e.jsx("div",{className:"font-medium",children:a.original.counterParty?.name})},{id:"invoiceDate",accessorKey:"invoiceDate",header:"Invoice Date",cell:({row:a})=>{const s=new Date(a.getValue("invoiceDate")),n=b(s,"yyyy-MM-dd");return e.jsx("div",{className:"font-medium",children:n})}},{id:"valueDate",accessorKey:"valueDate",header:"Value Date",cell:({row:a})=>{const s=new Date(a.getValue("valueDate")),n=b(s,"yyyy-MM-dd");return e.jsx("div",{className:"font-medium",children:n})}},{id:"reference",accessorKey:"reference",header:"Reference"},{id:"description",accessorKey:"description",header:"Description"},{id:"debit",header:"Debit",cell:({row:a})=>{const s=a.original.amount.raw;return s<0?e.jsx("div",{className:"font-medium",children:c.format(s*-1)}):null}},{id:"credit",header:"Credit",cell:({row:a})=>{const s=a.original.amount.raw;return s>=0?e.jsx("div",{className:"font-medium",children:c.format(s)}):null}},{id:"balance",accessorKey:"balance",header:"Balance",cell:({row:a})=>e.jsx("div",{className:"font-medium",children:c.format(a.getValue("balance"))})}],te=()=>{const{setFiltersContext:a}=u.useContext($),[s,n]=u.useState(new Date().getFullYear()-1),[{data:x,fetching:m}]=k({query:Y,variables:{year:s}}),l=x?.yearlyLedgerReport,{financialEntitiesInfo:g}=l??{},v=u.useMemo(()=>g?.flatMap(r=>{const{entity:i,openingBalance:y,closingBalance:h,totalCredit:p,totalDebit:w}=r;return r.records.map(N=>({entity:i,openingBalance:y,closingBalance:h,totalCredit:p,totalDebit:w,...N}))})??[],[g]),o=B({data:v,columns:E,getCoreRowModel:O(),getPaginationRowModel:K(),initialState:{pagination:{pageSize:100}}}),D=o.getState().pagination.pageIndex;return u.useEffect(()=>{a(e.jsxs("div",{className:"flex items-center justify-end gap-10 space-x-2 py-4",children:[e.jsx("div",{className:"flex items-center justify-between px-2",children:e.jsx(A,{table:o})}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(G,{value:new Date(s,0,1),onChange:r=>r&&n(r?.getFullYear()),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date}),e.jsx(Q,{data:l,year:s})]})]}))},[s,m,a,l,o,D]),e.jsx(_,{title:"Yearly Ledger Report",children:m?e.jsx(P,{className:"h-10 w-10 animate-spin mr-2 self-center"}):l?e.jsx("div",{className:"flex flex-col gap-4 rounded-md border",children:e.jsxs(T,{children:[e.jsx(L,{children:o.getHeaderGroups().map(r=>e.jsx(d,{children:r.headers.map(i=>e.jsx(V,{children:i.isPlaceholder?null:C(i.column.columnDef.header,i.getContext())},i.id))},r.id))}),e.jsx(S,{children:o.getRowModel().rows.map((r,i)=>{const y=o.getRowModel().rows[i-1],h=o.getRowModel().rows[i+1],p=!y||y.original.entity.id!==r.original.entity.id,w=!h||h.original.entity.id!==r.original.entity.id;return e.jsxs(e.Fragment,{children:[p&&i!==0&&e.jsx(d,{className:"border-y-2 border-t-gray-300 border-b-gray-500",children:e.jsx(t,{})}),p&&e.jsx(J,{row:r}),e.jsx(d,{children:r.getVisibleCells().map(f=>e.jsx(t,{children:C(f.column.columnDef.cell,f.getContext())},f.id))},r.id),w&&e.jsx(W,{row:r})]})})})]})}):e.jsx("div",{className:"rounded-md border h-24 text-center",children:"No results."})})};function J({row:a}){return e.jsxs(e.Fragment,{children:[e.jsxs(d,{className:"bg-gray-300",children:[e.jsx(t,{children:e.jsx("div",{className:"font-medium",children:a.original.entity.name})}),e.jsx(t,{children:e.jsx("div",{className:"font-medium",children:a.original.entity.sortCode?.key})}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{})]},`${a.id}-opening1`),e.jsxs(d,{className:"bg-gray-200",children:[e.jsx(t,{}),e.jsx(t,{children:e.jsx("div",{className:"font-medium",children:"Opening Balance"})}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{children:e.jsx("div",{className:"font-medium",children:c.format(a.original.openingBalance.raw)})})]},`${a.id}-opening2`)]})}function W({row:a}){return e.jsxs(e.Fragment,{children:[e.jsxs(d,{className:"bg-gray-200",children:[e.jsx(t,{children:e.jsx("div",{className:"font-medium",children:"Total"})}),e.jsx(t,{children:e.jsx("div",{className:"font-medium",children:a.original.entity.name})}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{children:e.jsxs("div",{className:"font-medium",children:[c.format(a.original.totalDebit.raw)," Debit"]})}),e.jsx(t,{})]},`${a.id}-totals1`),e.jsxs(d,{className:"bg-gray-200",children:[e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{children:e.jsxs("div",{className:"font-medium",children:[c.format(a.original.totalCredit.raw)," Credit"]})}),e.jsx(t,{children:e.jsx("div",{className:"font-medium",children:c.format(a.original.closingBalance.raw)})})]},`${a.id}-totals2`),e.jsxs(d,{className:"bg-gray-200",children:[e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{children:e.jsxs("div",{className:"font-medium",children:[c.format(a.original.totalCredit.raw-a.original.totalDebit.raw)," Diff"]})}),e.jsx(t,{})]},`${a.id}-totals3`)]})}export{te as YearlyLedgerReport};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as p,hS as N,r as u,t as l,i as f,y,G as b,j as e,V as C,el as $,Y as D,Z as F,_ as w,$ as k,I as j,a1 as E,hT as v,hU as S,a9 as A,l as z,T as L,B as T,ah as M,n as O,hV as P,hW as B,F as q,u as U,hX as _,L as V,cl as G,hY as R}from"./index-
|
|
1
|
+
import{g as p,hS as N,r as u,t as l,i as f,y,G as b,j as e,V as C,el as $,Y as D,Z as F,_ as w,$ as k,I as j,a1 as E,hT as v,hU as S,a9 as A,l as z,T as L,B as T,ah as M,n as O,hV as P,hW as B,F as q,u as U,hX as _,L as V,cl as G,hY as R}from"./index-qAF5sGRO.js";import{P as Y}from"./page-layout-7iCtDTzs.js";import{L as Q}from"./list-plus-DEqGGtBU.js";const W="updateTag",X=()=>{const[{fetching:c},r]=p(N),i=u.useCallback(async t=>{const a=`Error updating tag ID [${t.tagId}]`,s=`${W}-${t.tagId}`;l.loading("Updating Tag...",{id:s});try{const n=await r(t),d=f(n,a,s,"updateTag");if(d)return l.success("Success",{id:s,description:"Tag updated"}),d.updateTag}catch(n){console.error(`${a}: ${n}`),l.error("Error",{id:s,description:a,duration:1e5,closeButton:!0})}return!1},[r]);return{fetching:c,updateTag:i}},Z=({onDone:c,data:r,close:i})=>{const{updateTag:t,fetching:a}=X(),s=b(S,r),n=y({defaultValues:{name:s.name,parentId:s.parent?.id}}),{control:d,handleSubmit:m,formState:{dirtyFields:h}}=n,x=o=>{const g=A(o,h);i(),g&&Object.keys(g).length>0&&t({tagId:s.id,fields:g}).then(()=>c?.())};return e.jsx(C,{...n,children:e.jsxs("form",{onSubmit:m(x),children:[e.jsx("div",{className:"flex-row px-10 h-max justify-start block",children:e.jsxs($,{cols:3,children:[e.jsx(D,{name:"name",control:d,defaultValue:s.name,rules:{required:"Required",minLength:{value:2,message:"Must be at least 2 characters"}},render:({field:o})=>e.jsxs(F,{children:[e.jsx(w,{children:"Name"}),e.jsx(k,{children:e.jsx(j,{...o,value:o.value??void 0})}),e.jsx(E,{})]})}),e.jsx(v,{formManager:n,tagsPath:"parentId",label:"Parent Tag"})]})}),e.jsxs("div",{className:"mt-10 mb-5 flex justify-center gap-5",children:[e.jsx("button",{type:"submit",onClick:()=>m(x),className:"mt-8 text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",disabled:a||Object.keys(h).length===0,children:"Accept"}),e.jsx("button",{type:"button",className:"mt-8 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"})]})]})})},H=({onDone:c,data:r})=>{const[i,{open:t,close:a}]=z(!1);function s(){a(),c?.()}return e.jsxs(e.Fragment,{children:[e.jsx(L,{label:"Edit Tag",children:e.jsx(T,{variant:"ghost",size:"icon",className:"size-7.5",onClick:t,children:e.jsx(M,{className:"size-5"})})}),e.jsx(O,{centered:!0,opened:i,onClose:a,title:"Insert Business Trip",children:e.jsx(Z,{close:a,onDone:s,data:r})})]})},J="addTag",K=()=>{const[{fetching:c},r]=p(P),i=u.useCallback(async t=>{const a=`Error adding new tag [${t.tagName}]`,s=`${J}-${t.tagName}`;l.loading("Adding tag",{id:s});try{const n=await r(t);f(n,a,s)&&l.success("Success",{id:s,description:`"${t.tagName}" tag was successfully added`})}catch(n){console.error(`${a}: ${n}`),l.error("Error",{id:s,description:a,duration:1e5,closeButton:!0})}},[r]);return{fetching:c,addTag:i}},ee="deleteTag",se=()=>{const[{fetching:c},r]=p(B),i=u.useCallback(async t=>{const a=`Error deleting new tag [${t.name}]`,s=`${ee}-${t.tagId}`;l.loading(`Deleting tag [${t.name}]`,{id:s});try{const n=await r(t);f(n,a,s)&&l.success("Tag Deleted",{id:s,description:`[${t.name}] tag was successfully removed`})}catch(n){console.error(`${a}: ${n}`),l.error("Error",{id:s,description:a,duration:1e5,closeButton:!0})}},[r]);return{fetching:c,deleteTag:i}},oe=()=>{const{setFiltersContext:c}=u.useContext(q),[r,i]=u.useState(""),[{data:t,fetching:a},s]=U({query:R}),{addTag:n}=K(),{deleteTag:d}=se();u.useEffect(()=>{c(null)},[c]);const m=_(t?.allTags??[]),h=u.useCallback(o=>{o.length>2&&n({tagName:o}).then(()=>{s()})},[n,s]),x=u.useCallback((o,g)=>{d({tagId:o,name:g}).then(()=>{s()})},[d,s]);return e.jsx(Y,{title:"Tags",description:"Manage tags for your bookmarks.",children:a?e.jsx(V,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[m?.map(o=>e.jsxs("div",{className:"flex items-center gap-2 text-gray-600 mb-2",children:[e.jsxs("div",{className:"w-full mt-1 relative rounded-md shadow-xs",children:[o.namePath?.map((g,I)=>e.jsx("span",{className:"ms-2"},I)),o.name]}),e.jsx(H,{data:o}),e.jsx(T,{variant:"ghost",size:"icon",className:"size-7.5",onClick:()=>x(o.id,o.name),children:e.jsx(G,{className:"size-5"})})]},o.id)),e.jsxs("div",{className:"flex justify-start items-center gap-2 text-gray-600 mb-2",children:[e.jsx(j,{className:"w-80",value:r,onChange:o=>i(o.currentTarget.value),placeholder:"Add new tag",required:!0}),e.jsx(T,{variant:"ghost",size:"icon",className:"size-7.5",disabled:r.length<2,onClick:()=>h(r),children:e.jsx(Q,{className:"size-5"})})]})]})})};export{oe as TagsManager};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{v as U,r as d,j as e,G as p,B as g,e5 as H,e6 as _,e7 as q,d3 as D,e8 as M,e9 as J,ea as Q,eb as $,ec as Y,ed as K,ee as W,u as E,t as X,ef as Z,T as ee,eg as te,aC as T,bw as se,y as ae,dm as ne,bz as A,bC as S,eh as F,bJ as re,w as N,bD as oe,F as ie,L as ce,ei as le}from"./index-CHtpNrAW.js";import{d as R}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{u as z}from"./use-url-query-DMunwqS4.js";import{C as I,u as de,a as V,b as O,M as he}from"./charges-table-Dmz1Fxim.js";import{E as me,I as xe,M as ue}from"./match-document-modal-LhAEyv1y.js";import{P as pe}from"./page-layout-Cs7LzhPs.js";import{P as w,a as y}from"./panel-top-open-DfXV4xoB.js";import{T as k}from"./toggle-expansion-button-ByfnT_sn.js";import{T as P}from"./Table-bhKB4PFK.js";import{c as ge}from"./charges-filters-D_ruML4x.js";import{P as je}from"./modal-YTgF-R03.js";import{F as fe}from"./funnel-4UXATjU3.js";import"./index-YQXRLoVL.js";import"./similar-transactions-modal-DN6pAqBR.js";import"./addDays-CpwSVE6j.js";import"./list-plus-DsfXaxO5.js";import"./tooltip-0-bix6mQ.js";import"./summary-DLRjO19t.js";import"./deposits-transactions-table-BAObjoYX.js";import"./Checkbox-BHVKlxRj.js";import"./accordion-CAxRDsFz.js";import"./data-table-column-header-CT7O7uRT.js";import"./eye-off-Cc-ssiRk.js";import"./YearPickerInput-DgK0Ih6X.js";import"./insert-business-trip-modal-CQv_ZpxL.js";import"./accounter-table-DIm6Wedu.js";import"./sub-UiWBdxTZ.js";import"./subMonths-DZvdAXT7.js";import"./MultiSelect-DY08OexD.js";const ve=[["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"}]],we=U("file-digit",ve),ye=({data:a,setEditCharge:c,setInsertDocument:l,setMatchDocuments:r,toggleMergeCharge:o,mergeSelectedCharges:n})=>{const s=p(H,a),[t,i]=d.useState(!0);return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-lg font-semibold whitespace-nowrap flex flex-row gap-4",children:[e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>i(h=>!h),children:t?e.jsx(w,{className:"size-5"}):e.jsx(y,{className:"size-5"})}),"Business Trips"]}),t&&s&&e.jsx(I,{setEditChargeId:c,setInsertDocument:l,setMatchDocuments:r,data:s.businessTrips,isAllOpened:!1,toggleMergeCharge:o,mergeSelectedCharges:n})]})};function B({data:a}){const{chargeId:c,chargeAccountantStatus:l}=p(_,a),{updateChargeAccountantApproval:r}=de();return e.jsx("td",{children:e.jsx(q,{value:l??void 0,onChange:o=>r({chargeId:c,status:o})})})}const be=({data:a,toggleMergeCharge:c,mergeSelectedCharges:l,cumulativeVat:r,cumulativeAmount:o})=>{const[n,s]=d.useState(!1),t=p(J,a);return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"bg-gray-100",children:[e.jsxs("td",{className:"flex flex-col gap-1",children:[t.business?.name,t.vatNumber&&e.jsx("span",{style:{fontSize:"10px",color:"darkGray"},children:t.vatNumber})]}),e.jsx("td",{children:t.image&&e.jsx("a",{href:t.image,target:"_blank",rel:"noreferrer",children:e.jsx("img",{alt:"missing img",src:t.image,height:80,width:80})})}),e.jsx("td",{children:t.documentSerial}),e.jsx("td",{children:t.documentDate}),e.jsx("td",{children:t.chargeDate}),e.jsx("td",{className:"whitespace-nowrap",children:t.amount.formatted}),e.jsx("td",{className:"whitespace-nowrap",children:t.localAmount?.formatted}),e.jsx("td",{className:"whitespace-nowrap",children:t.localVat?.formatted}),e.jsx("td",{className:"whitespace-nowrap",children:t.localVatAfterDeduction?.formatted}),e.jsx("td",{className:"whitespace-nowrap",children:t.foreignVatAfterDeduction?.formatted}),e.jsx("td",{className:"whitespace-nowrap",children:t.roundedLocalVatAfterDeduction?.formatted}),e.jsxs("td",{className:"whitespace-nowrap",children:["₪ ",D(r,0)]}),e.jsxs("td",{className:"whitespace-nowrap",children:["₪ ",D(o,0)]}),e.jsx(B,{data:t}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx(k,{toggleExpansion:s,isExpanded:n})})}),e.jsx("td",{children:e.jsx(V,{toggleMergeSelected:()=>c(t.chargeId),mergeSelected:l.includes(t.chargeId)})})]}),n&&e.jsx("tr",{children:e.jsx("td",{colSpan:17,children:e.jsx(M,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:e.jsx(O,{chargeID:t.chargeId,fetching:!!t})})})})]})},Ce=({data:a,toggleMergeCharge:c,mergeSelectedCharges:l})=>{const{expenses:r}=p(Q,a)??{expenses:[]},[o,n]=d.useState(!0);let s=0,t=0;return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-lg font-semibold whitespace-nowrap flex flex-row gap-4",children:[e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>n(i=>!i),children:o?e.jsx(w,{className:"size-5"}):e.jsx(y,{className:"size-5"})}),"Expenses"]}),o&&e.jsxs(P,{highlightOnHover:!0,children:[e.jsx("thead",{style:{position:"sticky",top:0,zIndex:20},children:e.jsxs("tr",{className:"bg-gray-300",children:[e.jsx("th",{children:"Business"}),e.jsx("th",{children:"Invoice"}),e.jsx("th",{children:"Invoice Serial#"}),e.jsx("th",{children:"Invoice Date"}),e.jsx("th",{children:"Transaction Date"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Amount ₪"}),e.jsx("th",{children:"VAT"}),e.jsx("th",{children:"VAT ₪"}),e.jsx("th",{children:"Actual VAT"}),e.jsx("th",{children:"Rounded VAT"}),e.jsx("th",{children:"Cumulative VAT"}),e.jsx("th",{children:"Amount without VAT ₪"}),e.jsx("th",{children:"Cumulative Amount without VAT ₪"}),e.jsx("th",{children:"Accountant Approval"}),e.jsx("th",{colSpan:2,children:"Edit"})]})}),e.jsx("tbody",{children:r.map((i,h)=>{s+=i.taxReducedLocalAmount?.raw??0;const u=s;t+=i.roundedLocalVatAfterDeduction?.raw??0;const m=t;return e.jsx(be,{data:i,toggleMergeCharge:c,mergeSelectedCharges:l,cumulativeVat:m,cumulativeAmount:u},h)})})]})]})},De=({data:a,toggleMergeCharge:c,mergeSelectedCharges:l,cumulativeAmount:r})=>{const[o,n]=d.useState(!1),s=p($,a);return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"bg-gray-100",children:[e.jsxs("td",{className:"flex flex-col gap-1",children:[s.business?.name,s.vatNumber&&e.jsx("span",{style:{fontSize:"10px",color:"darkGray"},children:s.vatNumber})]}),e.jsx("td",{children:s.image&&e.jsx("a",{href:s.image,target:"_blank",rel:"noreferrer",children:e.jsx("img",{alt:"missing img",src:s.image,height:80,width:80})})}),e.jsx("td",{children:s.documentSerial}),e.jsx("td",{children:s.documentDate}),e.jsx("td",{children:s.chargeDate}),e.jsx("td",{children:s.taxReducedForeignAmount?.formatted}),e.jsx("td",{children:s.taxReducedLocalAmount?.formatted}),e.jsx("td",{children:"₪ "+D(r,0)}),e.jsx(B,{data:s}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx(k,{toggleExpansion:n,isExpanded:o})})}),e.jsx("td",{children:e.jsx(V,{toggleMergeSelected:()=>c(s.chargeId),mergeSelected:l.includes(s.chargeId)})})]}),o&&e.jsx("tr",{children:e.jsx("td",{colSpan:11,children:e.jsx(M,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:e.jsx(O,{chargeID:s.chargeId,fetching:!!s})})})})]})},Fe=({data:a,toggleMergeCharge:c,mergeSelectedCharges:l})=>{const{income:r}=p(Y,a)??{income:[]},[o,n]=d.useState(!0);let s=0;return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-lg font-semibold whitespace-nowrap flex flex-row gap-4",children:[e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>n(t=>!t),children:o?e.jsx(w,{className:"size-5"}):e.jsx(y,{className:"size-5"})}),"Income"]}),o&&e.jsxs(P,{highlightOnHover:!0,children:[e.jsx("thead",{style:{position:"sticky",top:0,zIndex:20},children:e.jsxs("tr",{className:"bg-gray-300",children:[e.jsx("th",{children:"Business"}),e.jsx("th",{children:"Invoice"}),e.jsx("th",{children:"Invoice Serial#"}),e.jsx("th",{children:"Invoice Date"}),e.jsx("th",{children:"Transaction Date"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Amount ₪"}),e.jsx("th",{children:"Cumulative Amount ₪"}),e.jsx("th",{children:"Accountant Approval"}),e.jsx("th",{colSpan:2,children:"Edit"})]})}),e.jsx("tbody",{children:r.map((t,i)=>{s+=t.taxReducedLocalAmount?.raw??0;const h=s;return e.jsx(De,{data:t,toggleMergeCharge:c,mergeSelectedCharges:l,cumulativeAmount:h},i)})})]})]})},Ne=({data:a,setEditCharge:c,setInsertDocument:l,setMatchDocuments:r,toggleMergeCharge:o,mergeSelectedCharges:n})=>{const s=p(K,a),[t,i]=d.useState(!0);return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-lg font-semibold whitespace-nowrap flex flex-row gap-4",children:[e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>i(h=>!h),children:t?e.jsx(w,{className:"size-5"}):e.jsx(y,{className:"size-5"})}),"Misc Charges (which are not on the above tables)"]}),t&&s&&e.jsx(I,{setEditChargeId:c,setInsertDocument:l,setMatchDocuments:r,data:s.differentMonthDoc,isAllOpened:!1,toggleMergeCharge:o,mergeSelectedCharges:n})]})},Ie=({data:a,setEditCharge:c,setInsertDocument:l,setMatchDocuments:r,toggleMergeCharge:o,mergeSelectedCharges:n})=>{const s=p(W,a),[t,i]=d.useState(!0);return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-lg font-semibold whitespace-nowrap flex flex-row gap-4",children:[e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>i(h=>!h),children:t?e.jsx(w,{className:"size-5"}):e.jsx(y,{className:"size-5"})}),"Missing Info"]}),t&&s&&e.jsx(I,{setEditChargeId:c,setInsertDocument:l,setMatchDocuments:r,data:s.missingInfo,isAllOpened:!1,toggleMergeCharge:o,mergeSelectedCharges:n})]})},Ae=({filter:{monthDate:a,financialEntityId:c},isLoading:l})=>{const[{data:r,fetching:o,error:n},s]=E({query:R(te),pause:!0,variables:{monthDate:a,financialEntityId:c}});return d.useEffect(()=>{if(n){const t="Error generating PCN874 file";console.error(`${t}: ${n}`),X.error("Error",{description:t,duration:5e3,closeButton:!0})}},[n]),d.useEffect(()=>{if(r){const t=new File([r.pcnFile.reportContent],"pcn874.txt",{type:"text/plain"});Z(t)}},[r]),e.jsx(ee,{label:"Generate and Download PCN874 File",children:e.jsx(g,{disabled:o||l,variant:"outline",size:"icon",className:"size-7.5",onClick:s,children:e.jsx(we,{className:"size-5"})})})};function Se({filter:a,setFilter:c,closeModal:l}){const{control:r,handleSubmit:o,setValue:n}=ae({defaultValues:{...a}}),{selectableFinancialEntities:s,fetching:t}=ne(),i=m=>{c(m),l()};function h(){c(),l()}function u(m){const x=new Date(m.getFullYear(),m.getMonth(),15);n("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:o(i),children:[e.jsx(A,{name:"financialEntityId",control:r,defaultValue:void 0,render:({field:m,fieldState:x})=>e.jsx(S,{...m,data:s,value:m.value,disabled:t,label:"Financial Entities",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:x.error?.message})}),e.jsx(A,{name:"chargesType",control:r,defaultValue:a.chargesType,render:({field:m,fieldState:x})=>e.jsx(S,{...m,data:ge,value:m.value??F.All,label:"Charge Type",placeholder:"Filter income/expense",maxDropdownHeight:160,error:x.error?.message})}),e.jsx(re,{defaultValue:a?.monthDate?new Date(a.monthDate):new Date,defaultDate:a?.monthDate?new Date(a.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:l,children:"Cancel"})]})]})]})}function Me({filter:a,setFilter:c}){const[l,r]=d.useState(!1),{get:o,set:n}=z(),{userContext:s}=d.useContext(T);function t(i){i||={financialEntityId:s?.context.adminBusinessId??a.financialEntityId,monthDate:N(new Date,"yyyy-MM-15")},oe(i,a)||c(i)}return d.useEffect(()=>{const i=se(a??{})?null:encodeURIComponent(JSON.stringify(a)),h=o("vatMonthlyReportFilters");i!==h&&n("vatMonthlyReportFilters",i)},[a,o,n]),e.jsxs(e.Fragment,{children:[e.jsx(je,{opened:l,onClose:()=>r(!1),content:e.jsx(Se,{filter:a,setFilter:t,closeModal:()=>r(!1)})}),e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>r(!0),children:e.jsx(fe,{className:"size-5"})})]})}const ot=()=>{const{get:a}=z(),{setFiltersContext:c}=d.useContext(ie),{userContext:l}=d.useContext(T),[r,o]=d.useState(a("vatMonthlyReportFilters")?JSON.parse(decodeURIComponent(a("vatMonthlyReportFilters"))):{financialEntityId:l?.context.adminBusinessId??"",monthDate:N(new Date,"yyyy-MM-15")}),[n,s]=d.useState([]),[t,i]=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:r}}),f=d.useCallback(v=>{n.includes(v)?s(n.filter(G=>G!==v)):s([...n,v])},[n]);function L(){s([])}d.useEffect(()=>{c(e.jsxs("div",{className:"flex flex-row gap-2",children:[e.jsx(Ae,{filter:r,isLoading:b}),e.jsx(Me,{filter:{...r},setFilter:o}),e.jsx(he,{selected:n.map(v=>({id:v,onChange:()=>{}})),resetMerge:L})]}))},[j,r,b,c,n]);const C=d.useMemo(()=>new Set(n),[n]);return e.jsx(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:[r.chargesType!==F.Expense&&e.jsx(Fe,{data:j?.vatReport,toggleMergeCharge:f,mergeSelectedCharges:n}),r.chargesType!==F.Income&&e.jsx(Ce,{data:j?.vatReport,toggleMergeCharge:f,mergeSelectedCharges:n}),e.jsx(Ie,{data:j?.vatReport,setEditCharge:x,setInsertDocument:i,setMatchDocuments:u,toggleMergeCharge:f,mergeSelectedCharges:C}),e.jsx(ye,{data:j?.vatReport,setEditCharge:x,setInsertDocument:i,setMatchDocuments:u,toggleMergeCharge:f,mergeSelectedCharges:C}),e.jsx(Ne,{data:j?.vatReport,setEditCharge:x,setInsertDocument:i,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:()=>i(void 0)}),h&&e.jsx(ue,{chargeId:h.id,ownerId:h.ownerId,setMatchDocuments:()=>u(void 0)})]})})};export{ot as VatMonthlyReport};
|
|
1
|
+
import{v as U,r as d,j as e,G as p,B as g,e5 as H,e6 as _,e7 as q,d3 as D,e8 as M,e9 as J,ea as Q,eb as $,ec as Y,ed as K,ee as W,u as E,t as X,ef as Z,T as ee,eg as te,aC as T,bw as se,y as ae,dm as ne,bz as A,bC as S,eh as F,bJ as re,w as N,bD as oe,F as ie,L as ce,ei as le}from"./index-qAF5sGRO.js";import{d as R}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{u as z}from"./use-url-query-CYeryni6.js";import{C as I,u as de,a as V,b as O,M as he}from"./charges-table-CTMLwet4.js";import{E as me,I as xe,M as ue}from"./match-document-modal-CQ8I-zEU.js";import{P as pe}from"./page-layout-7iCtDTzs.js";import{P as w,a as y}from"./panel-top-open-CVvVnpDH.js";import{T as k}from"./toggle-expansion-button-DYABrNZG.js";import{T as P}from"./Table-C5b9rbOB.js";import{c as ge}from"./charges-filters-nFUpOOgf.js";import{P as je}from"./modal-D_KAAYCr.js";import{F as fe}from"./funnel-Cn1E8rCW.js";import"./index-DrY2LoBX.js";import"./similar-transactions-modal-Dn4dMAAO.js";import"./addDays-oqtNz11p.js";import"./list-plus-DEqGGtBU.js";import"./tooltip-Br1wJ5zm.js";import"./summary-ZTGFg2Jz.js";import"./deposits-transactions-table-jhVmfuNs.js";import"./Checkbox-CoEj3QSE.js";import"./accordion-Csw2mWiO.js";import"./data-table-column-header-BxsKrjBX.js";import"./eye-off-CfHy9jRk.js";import"./YearPickerInput-DD-O605S.js";import"./insert-business-trip-modal-_imZNOPq.js";import"./accounter-table-CLNNqdXm.js";import"./sub-DgacWlyb.js";import"./subMonths-oKYDpkY2.js";import"./MultiSelect-DRJD_QDr.js";const ve=[["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"}]],we=U("file-digit",ve),ye=({data:a,setEditCharge:c,setInsertDocument:l,setMatchDocuments:r,toggleMergeCharge:o,mergeSelectedCharges:n})=>{const s=p(H,a),[t,i]=d.useState(!0);return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-lg font-semibold whitespace-nowrap flex flex-row gap-4",children:[e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>i(h=>!h),children:t?e.jsx(w,{className:"size-5"}):e.jsx(y,{className:"size-5"})}),"Business Trips"]}),t&&s&&e.jsx(I,{setEditChargeId:c,setInsertDocument:l,setMatchDocuments:r,data:s.businessTrips,isAllOpened:!1,toggleMergeCharge:o,mergeSelectedCharges:n})]})};function B({data:a}){const{chargeId:c,chargeAccountantStatus:l}=p(_,a),{updateChargeAccountantApproval:r}=de();return e.jsx("td",{children:e.jsx(q,{value:l??void 0,onChange:o=>r({chargeId:c,status:o})})})}const be=({data:a,toggleMergeCharge:c,mergeSelectedCharges:l,cumulativeVat:r,cumulativeAmount:o})=>{const[n,s]=d.useState(!1),t=p(J,a);return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"bg-gray-100",children:[e.jsxs("td",{className:"flex flex-col gap-1",children:[t.business?.name,t.vatNumber&&e.jsx("span",{style:{fontSize:"10px",color:"darkGray"},children:t.vatNumber})]}),e.jsx("td",{children:t.image&&e.jsx("a",{href:t.image,target:"_blank",rel:"noreferrer",children:e.jsx("img",{alt:"missing img",src:t.image,height:80,width:80})})}),e.jsx("td",{children:t.documentSerial}),e.jsx("td",{children:t.documentDate}),e.jsx("td",{children:t.chargeDate}),e.jsx("td",{className:"whitespace-nowrap",children:t.amount.formatted}),e.jsx("td",{className:"whitespace-nowrap",children:t.localAmount?.formatted}),e.jsx("td",{className:"whitespace-nowrap",children:t.localVat?.formatted}),e.jsx("td",{className:"whitespace-nowrap",children:t.localVatAfterDeduction?.formatted}),e.jsx("td",{className:"whitespace-nowrap",children:t.foreignVatAfterDeduction?.formatted}),e.jsx("td",{className:"whitespace-nowrap",children:t.roundedLocalVatAfterDeduction?.formatted}),e.jsxs("td",{className:"whitespace-nowrap",children:["₪ ",D(r,0)]}),e.jsxs("td",{className:"whitespace-nowrap",children:["₪ ",D(o,0)]}),e.jsx(B,{data:t}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx(k,{toggleExpansion:s,isExpanded:n})})}),e.jsx("td",{children:e.jsx(V,{toggleMergeSelected:()=>c(t.chargeId),mergeSelected:l.includes(t.chargeId)})})]}),n&&e.jsx("tr",{children:e.jsx("td",{colSpan:17,children:e.jsx(M,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:e.jsx(O,{chargeID:t.chargeId,fetching:!!t})})})})]})},Ce=({data:a,toggleMergeCharge:c,mergeSelectedCharges:l})=>{const{expenses:r}=p(Q,a)??{expenses:[]},[o,n]=d.useState(!0);let s=0,t=0;return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-lg font-semibold whitespace-nowrap flex flex-row gap-4",children:[e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>n(i=>!i),children:o?e.jsx(w,{className:"size-5"}):e.jsx(y,{className:"size-5"})}),"Expenses"]}),o&&e.jsxs(P,{highlightOnHover:!0,children:[e.jsx("thead",{style:{position:"sticky",top:0,zIndex:20},children:e.jsxs("tr",{className:"bg-gray-300",children:[e.jsx("th",{children:"Business"}),e.jsx("th",{children:"Invoice"}),e.jsx("th",{children:"Invoice Serial#"}),e.jsx("th",{children:"Invoice Date"}),e.jsx("th",{children:"Transaction Date"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Amount ₪"}),e.jsx("th",{children:"VAT"}),e.jsx("th",{children:"VAT ₪"}),e.jsx("th",{children:"Actual VAT"}),e.jsx("th",{children:"Rounded VAT"}),e.jsx("th",{children:"Cumulative VAT"}),e.jsx("th",{children:"Amount without VAT ₪"}),e.jsx("th",{children:"Cumulative Amount without VAT ₪"}),e.jsx("th",{children:"Accountant Approval"}),e.jsx("th",{colSpan:2,children:"Edit"})]})}),e.jsx("tbody",{children:r.map((i,h)=>{s+=i.taxReducedLocalAmount?.raw??0;const u=s;t+=i.roundedLocalVatAfterDeduction?.raw??0;const m=t;return e.jsx(be,{data:i,toggleMergeCharge:c,mergeSelectedCharges:l,cumulativeVat:m,cumulativeAmount:u},h)})})]})]})},De=({data:a,toggleMergeCharge:c,mergeSelectedCharges:l,cumulativeAmount:r})=>{const[o,n]=d.useState(!1),s=p($,a);return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"bg-gray-100",children:[e.jsxs("td",{className:"flex flex-col gap-1",children:[s.business?.name,s.vatNumber&&e.jsx("span",{style:{fontSize:"10px",color:"darkGray"},children:s.vatNumber})]}),e.jsx("td",{children:s.image&&e.jsx("a",{href:s.image,target:"_blank",rel:"noreferrer",children:e.jsx("img",{alt:"missing img",src:s.image,height:80,width:80})})}),e.jsx("td",{children:s.documentSerial}),e.jsx("td",{children:s.documentDate}),e.jsx("td",{children:s.chargeDate}),e.jsx("td",{children:s.taxReducedForeignAmount?.formatted}),e.jsx("td",{children:s.taxReducedLocalAmount?.formatted}),e.jsx("td",{children:"₪ "+D(r,0)}),e.jsx(B,{data:s}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx(k,{toggleExpansion:n,isExpanded:o})})}),e.jsx("td",{children:e.jsx(V,{toggleMergeSelected:()=>c(s.chargeId),mergeSelected:l.includes(s.chargeId)})})]}),o&&e.jsx("tr",{children:e.jsx("td",{colSpan:11,children:e.jsx(M,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:e.jsx(O,{chargeID:s.chargeId,fetching:!!s})})})})]})},Fe=({data:a,toggleMergeCharge:c,mergeSelectedCharges:l})=>{const{income:r}=p(Y,a)??{income:[]},[o,n]=d.useState(!0);let s=0;return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-lg font-semibold whitespace-nowrap flex flex-row gap-4",children:[e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>n(t=>!t),children:o?e.jsx(w,{className:"size-5"}):e.jsx(y,{className:"size-5"})}),"Income"]}),o&&e.jsxs(P,{highlightOnHover:!0,children:[e.jsx("thead",{style:{position:"sticky",top:0,zIndex:20},children:e.jsxs("tr",{className:"bg-gray-300",children:[e.jsx("th",{children:"Business"}),e.jsx("th",{children:"Invoice"}),e.jsx("th",{children:"Invoice Serial#"}),e.jsx("th",{children:"Invoice Date"}),e.jsx("th",{children:"Transaction Date"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Amount ₪"}),e.jsx("th",{children:"Cumulative Amount ₪"}),e.jsx("th",{children:"Accountant Approval"}),e.jsx("th",{colSpan:2,children:"Edit"})]})}),e.jsx("tbody",{children:r.map((t,i)=>{s+=t.taxReducedLocalAmount?.raw??0;const h=s;return e.jsx(De,{data:t,toggleMergeCharge:c,mergeSelectedCharges:l,cumulativeAmount:h},i)})})]})]})},Ne=({data:a,setEditCharge:c,setInsertDocument:l,setMatchDocuments:r,toggleMergeCharge:o,mergeSelectedCharges:n})=>{const s=p(K,a),[t,i]=d.useState(!0);return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-lg font-semibold whitespace-nowrap flex flex-row gap-4",children:[e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>i(h=>!h),children:t?e.jsx(w,{className:"size-5"}):e.jsx(y,{className:"size-5"})}),"Misc Charges (which are not on the above tables)"]}),t&&s&&e.jsx(I,{setEditChargeId:c,setInsertDocument:l,setMatchDocuments:r,data:s.differentMonthDoc,isAllOpened:!1,toggleMergeCharge:o,mergeSelectedCharges:n})]})},Ie=({data:a,setEditCharge:c,setInsertDocument:l,setMatchDocuments:r,toggleMergeCharge:o,mergeSelectedCharges:n})=>{const s=p(W,a),[t,i]=d.useState(!0);return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-lg font-semibold whitespace-nowrap flex flex-row gap-4",children:[e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>i(h=>!h),children:t?e.jsx(w,{className:"size-5"}):e.jsx(y,{className:"size-5"})}),"Missing Info"]}),t&&s&&e.jsx(I,{setEditChargeId:c,setInsertDocument:l,setMatchDocuments:r,data:s.missingInfo,isAllOpened:!1,toggleMergeCharge:o,mergeSelectedCharges:n})]})},Ae=({filter:{monthDate:a,financialEntityId:c},isLoading:l})=>{const[{data:r,fetching:o,error:n},s]=E({query:R(te),pause:!0,variables:{monthDate:a,financialEntityId:c}});return d.useEffect(()=>{if(n){const t="Error generating PCN874 file";console.error(`${t}: ${n}`),X.error("Error",{description:t,duration:5e3,closeButton:!0})}},[n]),d.useEffect(()=>{if(r){const t=new File([r.pcnFile.reportContent],"pcn874.txt",{type:"text/plain"});Z(t)}},[r]),e.jsx(ee,{label:"Generate and Download PCN874 File",children:e.jsx(g,{disabled:o||l,variant:"outline",size:"icon",className:"size-7.5",onClick:s,children:e.jsx(we,{className:"size-5"})})})};function Se({filter:a,setFilter:c,closeModal:l}){const{control:r,handleSubmit:o,setValue:n}=ae({defaultValues:{...a}}),{selectableFinancialEntities:s,fetching:t}=ne(),i=m=>{c(m),l()};function h(){c(),l()}function u(m){const x=new Date(m.getFullYear(),m.getMonth(),15);n("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:o(i),children:[e.jsx(A,{name:"financialEntityId",control:r,defaultValue:void 0,render:({field:m,fieldState:x})=>e.jsx(S,{...m,data:s,value:m.value,disabled:t,label:"Financial Entities",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:x.error?.message})}),e.jsx(A,{name:"chargesType",control:r,defaultValue:a.chargesType,render:({field:m,fieldState:x})=>e.jsx(S,{...m,data:ge,value:m.value??F.All,label:"Charge Type",placeholder:"Filter income/expense",maxDropdownHeight:160,error:x.error?.message})}),e.jsx(re,{defaultValue:a?.monthDate?new Date(a.monthDate):new Date,defaultDate:a?.monthDate?new Date(a.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:l,children:"Cancel"})]})]})]})}function Me({filter:a,setFilter:c}){const[l,r]=d.useState(!1),{get:o,set:n}=z(),{userContext:s}=d.useContext(T);function t(i){i||={financialEntityId:s?.context.adminBusinessId??a.financialEntityId,monthDate:N(new Date,"yyyy-MM-15")},oe(i,a)||c(i)}return d.useEffect(()=>{const i=se(a??{})?null:encodeURIComponent(JSON.stringify(a)),h=o("vatMonthlyReportFilters");i!==h&&n("vatMonthlyReportFilters",i)},[a,o,n]),e.jsxs(e.Fragment,{children:[e.jsx(je,{opened:l,onClose:()=>r(!1),content:e.jsx(Se,{filter:a,setFilter:t,closeModal:()=>r(!1)})}),e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>r(!0),children:e.jsx(fe,{className:"size-5"})})]})}const ot=()=>{const{get:a}=z(),{setFiltersContext:c}=d.useContext(ie),{userContext:l}=d.useContext(T),[r,o]=d.useState(a("vatMonthlyReportFilters")?JSON.parse(decodeURIComponent(a("vatMonthlyReportFilters"))):{financialEntityId:l?.context.adminBusinessId??"",monthDate:N(new Date,"yyyy-MM-15")}),[n,s]=d.useState([]),[t,i]=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:r}}),f=d.useCallback(v=>{n.includes(v)?s(n.filter(G=>G!==v)):s([...n,v])},[n]);function L(){s([])}d.useEffect(()=>{c(e.jsxs("div",{className:"flex flex-row gap-2",children:[e.jsx(Ae,{filter:r,isLoading:b}),e.jsx(Me,{filter:{...r},setFilter:o}),e.jsx(he,{selected:n.map(v=>({id:v,onChange:()=>{}})),resetMerge:L})]}))},[j,r,b,c,n]);const C=d.useMemo(()=>new Set(n),[n]);return e.jsx(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:[r.chargesType!==F.Expense&&e.jsx(Fe,{data:j?.vatReport,toggleMergeCharge:f,mergeSelectedCharges:n}),r.chargesType!==F.Income&&e.jsx(Ce,{data:j?.vatReport,toggleMergeCharge:f,mergeSelectedCharges:n}),e.jsx(Ie,{data:j?.vatReport,setEditCharge:x,setInsertDocument:i,setMatchDocuments:u,toggleMergeCharge:f,mergeSelectedCharges:C}),e.jsx(ye,{data:j?.vatReport,setEditCharge:x,setInsertDocument:i,setMatchDocuments:u,toggleMergeCharge:f,mergeSelectedCharges:C}),e.jsx(Ne,{data:j?.vatReport,setEditCharge:x,setInsertDocument:i,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:()=>i(void 0)}),h&&e.jsx(ue,{chargeId:h.id,ownerId:h.ownerId,setMatchDocuments:()=>u(void 0)})]})})};export{ot as VatMonthlyReport};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as x,ca as h,G as T,r,j as s,bx as g,cb as j,F as B,T as w,at as C,L as v,a3 as E,cc as P}from"./index-
|
|
1
|
+
import{u as x,ca as h,G as T,r,j as s,bx as g,cb as j,F as B,T as w,at as C,L as v,a3 as E,cc as P}from"./index-qAF5sGRO.js";import{E as b,P as y,C as L}from"./editable-business-trip-B388mlUw.js";import{I as F}from"./insert-business-trip-modal-_imZNOPq.js";import{P as I}from"./page-layout-7iCtDTzs.js";import{A as m}from"./summary-ZTGFg2Jz.js";import"./list-plus-DEqGGtBU.js";import"./Table-C5b9rbOB.js";import"./toggle-expansion-button-DYABrNZG.js";import"./panel-top-open-CVvVnpDH.js";import"./MultiSelect-DRJD_QDr.js";import"./similar-transactions-modal-Dn4dMAAO.js";import"./tooltip-Br1wJ5zm.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(b,{tripId:e.id,isExtended:!0},e.id)})]})},U=()=>{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,{label:"Toggle business trips validation",children:s.jsxs("div",{className:"flex flex-row items-center gap-x-2",children:[s.jsx(C,{checked:e??!1,onCheckedChange:t=>i(t)}),s.jsx("span",{className:"text-sm text-gray-500",children:"Validate"})]})}),s.jsx(y,{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(L,{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{U as BusinessTrips};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as m,bD as _,j as e,bx as k,B as I,bw as V,y as Q,by as G,dm as K,b0 as q,dn as z,bz as y,bC as L,bA as F,bB as B,w as S,u as R,gM as X,J as P,c as U,K as $,O as J,a4 as W,W as Y,F as Z,aC as ee,b4 as ae,Q as se,dT as te,gN as re,ay as ne}from"./index-CHtpNrAW.js";import{u as O}from"./use-url-query-DMunwqS4.js";import{P as oe}from"./page-layout-Cs7LzhPs.js";import{k as ie,B as N,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-MqLuc9m0.js";import{P as he}from"./modal-YTgF-R03.js";import{F as fe}from"./funnel-4UXATjU3.js";import{M as A}from"./MultiSelect-DY08OexD.js";import{T as be}from"./index-YQXRLoVL.js";import{s as je}from"./sub-UiWBdxTZ.js";import"./sequential-CAnleQny.js";import"./similar-transactions-modal-DN6pAqBR.js";import"./addDays-CpwSVE6j.js";import"./list-plus-DsfXaxO5.js";import"./tooltip-0-bix6mQ.js";import"./subMonths-DZvdAXT7.js";var ye=ie({chartName:"BarChart",GraphicalChild:N,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 E="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}=K(),{selectableTags:p,fetching:j}=q(),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(A,{...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(A,{...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(A,{...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}=O();m.useEffect(()=>{const p=ve(s),j=h(E);p!==j&&f(E,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 we=({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(Y,{children:e.jsx(be,{transactionsProps:g})})]})})},w={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 Ne(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),_e=()=>{const{setFiltersContext:s}=m.useContext(Z),{userContext:i}=m.useContext(ee),{get:c}=O(),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(E);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(w)),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(w).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=Ne(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(Y,{children:e.jsx(de,{config:w,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]`}),w[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}`}),w[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(N,{dataKey:"income",fill:"var(--color-income)",radius:4}),f.includes("expense")&&e.jsx(N,{dataKey:"expense",fill:"var(--color-expense)",radius:4}),f.includes("delta")&&e.jsx(N,{dataKey:"delta",fill:"var(--color-delta)",radius:4}),f.includes("cumulative")&&e.jsx(N,{dataKey:"cumulative",fill:"var(--color-cumulative)",radius:4})]})})})]}),b&&e.jsx(we,{period:b,onCloseExtendedTransactions:()=>h(void 0),transactionIDs:C.find(o=>o.period===b)?.transactions.map(o=>o.id)??[]})]})})};export{_e as BalanceReport};
|
|
1
|
+
import{r as m,bD as _,j as e,bx as k,B as I,bw as V,y as Q,by as G,dm as K,b0 as q,dn as z,bz as y,bC as L,bA as F,bB as B,w as S,u as R,gM as X,J as P,c as U,K as $,O as J,a4 as W,W as Y,F as Z,aC as ee,b4 as ae,Q as se,dT as te,gN as re,ay as ne}from"./index-qAF5sGRO.js";import{u as O}from"./use-url-query-CYeryni6.js";import{P as oe}from"./page-layout-7iCtDTzs.js";import{k as ie,B as N,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-CcwcQbqJ.js";import{P as he}from"./modal-D_KAAYCr.js";import{F as fe}from"./funnel-Cn1E8rCW.js";import{M as A}from"./MultiSelect-DRJD_QDr.js";import{T as be}from"./index-DrY2LoBX.js";import{s as je}from"./sub-DgacWlyb.js";import"./sequential-CAnleQny.js";import"./similar-transactions-modal-Dn4dMAAO.js";import"./addDays-oqtNz11p.js";import"./list-plus-DEqGGtBU.js";import"./tooltip-Br1wJ5zm.js";import"./subMonths-oKYDpkY2.js";var ye=ie({chartName:"BarChart",GraphicalChild:N,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 E="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}=K(),{selectableTags:p,fetching:j}=q(),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(A,{...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(A,{...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(A,{...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}=O();m.useEffect(()=>{const p=ve(s),j=h(E);p!==j&&f(E,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 we=({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(Y,{children:e.jsx(be,{transactionsProps:g})})]})})},w={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 Ne(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),_e=()=>{const{setFiltersContext:s}=m.useContext(Z),{userContext:i}=m.useContext(ee),{get:c}=O(),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(E);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(w)),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(w).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=Ne(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(Y,{children:e.jsx(de,{config:w,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]`}),w[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}`}),w[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(N,{dataKey:"income",fill:"var(--color-income)",radius:4}),f.includes("expense")&&e.jsx(N,{dataKey:"expense",fill:"var(--color-expense)",radius:4}),f.includes("delta")&&e.jsx(N,{dataKey:"delta",fill:"var(--color-delta)",radius:4}),f.includes("cumulative")&&e.jsx(N,{dataKey:"cumulative",fill:"var(--color-cumulative)",radius:4})]})})})]}),b&&e.jsx(we,{period:b,onCloseExtendedTransactions:()=>h(void 0),transactionIDs:C.find(o=>o.period===b)?.transactions.map(o=>o.id)??[]})]})})};export{_e as BalanceReport};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as n,u as y,dt as L,G as b,bI as C,j as e,D as O,aU as P,B as M,a3 as q,x as V,al as H,am as U,ao as z,ap as Q,aq as $,ar as G,as as J,w as S,du as F,y as K,dv as X,H as Y,bF as _,V as W,a2 as Z,bJ as ee,bK as se,bL as te,bM as N,bN as h,bO as ne,bP as x,ai as ae,R as E,bQ as le,bR as re,a4 as oe,bS as ce,bT as ie,F as ue,c as de}from"./index-
|
|
1
|
+
import{r as n,u as y,dt as L,G as b,bI as C,j as e,D as O,aU as P,B as M,a3 as q,x as V,al as H,am as U,ao as z,ap as Q,aq as $,ar as G,as as J,w as S,du as F,y as K,dv as X,H as Y,bF as _,V as W,a2 as Z,bJ as ee,bK as se,bL as te,bM as N,bN as h,bO as ne,bP as x,ai as ae,R as E,bQ as le,bR as re,a4 as oe,bS as ce,bT as ie,F as ue,c as de}from"./index-qAF5sGRO.js";import{u as me,E as he}from"./edit-issue-document-modal-CI2VPVkB.js";import{s as w}from"./subMonths-oKYDpkY2.js";function xe({issueMonth:u,clients:r,onAdd:o}){const[f,c]=n.useState(!1),[j,d]=n.useState(""),[{data:m},a]=y({query:L,variables:{issueMonth:u,clientId:j},pause:!f}),p=n.useCallback(l=>{d(l),a()},[a,d]);return n.useEffect(()=>{j!==""&&m&&(o(b(C,m.clientMonthlyChargeDraft)),c(!1))},[j,m,o]),e.jsxs(O,{open:f,onOpenChange:c,children:[e.jsx(P,{asChild:!0,children:e.jsx(M,{variant:"outline",size:"icon",children:e.jsx(q,{})})}),e.jsxs(V,{className:"w-[400px] max-w-screen-md",children:[e.jsx(H,{children:e.jsx(U,{children:"Select document recipient"})}),e.jsxs(z,{onValueChange:p,children:[e.jsx(Q,{children:e.jsx($,{placeholder:"Recipient"})}),e.jsx(G,{children:r.map(l=>e.jsx(J,{value:l.id,children:l.name},l.id))})]})]})]})}const je=({drafts:u})=>{const[r,o]=n.useState(u.map(s=>b(C,s))),f=S(w(new Date,1),"yyyy-MM-dd"),[c,j]=n.useState(f),[{data:d},m]=y({query:F,variables:{issueMonth:c},pause:!0});n.useEffect(()=>{d?.clientMonthlyChargesDrafts&&o(d.clientMonthlyChargesDrafts.map(s=>b(C,s)))},[d,o]),n.useEffect(()=>{m()},[c,m]);const a=K({values:{generateDocumentsInfo:r}}),{issueDocuments:p}=me(),[{data:l}]=y({query:X}),{fields:I,append:A,remove:B,update:k}=Y({control:a.control,name:"generateDocumentsInfo"}),T=a.watch("generateDocumentsInfo"),D=n.useMemo(()=>I.map((s,t)=>({...s,...T[t],id:s.client?.businessId})),[I,T]),v=n.useCallback(s=>{p(s)},[p]),R=n.useMemo(()=>l?.allOpenContracts.filter(s=>s.billingCycle===_.Monthly&&!D.some(t=>t.client?.businessId===s.client.originalBusiness.id)),[D,l]);return e.jsx("div",{className:"p-2",children:e.jsx(W,{...a,children:e.jsxs("form",{onSubmit:a.handleSubmit(v),children:[e.jsxs("div",{className:"flex gap-2 items-center mb-4",children:[e.jsx(Z,{children:"Issue Month:"}),e.jsx(ee,{value:new Date(c),onChange:s=>{const t=new Date(s.getFullYear(),s.getMonth(),15);j(S(t,"yyyy-MM-dd"))},popoverProps:{withinPortal:!0}})]}),e.jsxs(se,{children:[e.jsx(te,{children:e.jsxs(N,{children:[e.jsx(h,{children:"Name"}),e.jsx(h,{children:"Document"}),e.jsx(h,{children:"Amount"}),e.jsx(h,{children:"Remark"}),e.jsx(h,{children:"Recipients"}),e.jsx(h,{})]})}),e.jsx(ne,{children:D.map(({id:s,...t},g)=>e.jsxs(N,{children:[e.jsx(x,{children:e.jsx(ae,{to:s?E.BUSINESSES.DETAIL(s):E.BUSINESSES.ALL,target:"_blank",rel:"noreferrer",onClick:i=>i.stopPropagation(),className:"inline-flex items-center font-semibold",children:t.client?.name})}),e.jsx(x,{children:t.type}),e.jsxs(x,{children:[t.income?.[0]?.price," ",t.income?.[0]?.currency]}),e.jsx(x,{children:e.jsx("span",{className:"text-sm text-gray-500 whitespace-normal max-w-50",children:t.remarks})}),e.jsx(x,{children:e.jsx("div",{className:"flex flex-col",children:t.client?.emails?.map(i=>e.jsx("span",{className:"text-sm text-gray-500",children:i},i))})}),e.jsx(x,{children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs(le,{children:[e.jsx(re,{asChild:!0,type:"button",children:e.jsx(M,{className:"size-7.5",variant:"secondary",onClick:()=>B(g),children:e.jsx(oe,{size:16})})}),e.jsx(ce,{children:e.jsx("p",{children:"Remove document"})})]}),e.jsx(he,{draft:t,onApprove:i=>{a.setValue(`generateDocumentsInfo.${g}`,i,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0}),k(g,{...i})}})]})})]},s))})]}),e.jsxs("div",{className:"flex justify-between items-center mt-4",children:[e.jsx(xe,{clients:R?.map(s=>({id:s.client.originalBusiness.id,name:s.client.originalBusiness.name}))??[],onAdd:A,issueMonth:c}),e.jsx(ie,{onConfirm:a.handleSubmit(v),title:`Are you sure you want to issue ${D.length} documents?`,children:e.jsx(M,{children:"Issue"})})]})]})})})},ye=()=>{const{setFiltersContext:u}=n.useContext(ue),[{data:r,fetching:o}]=y({query:F,variables:{issueMonth:S(w(new Date,1),"yyyy-MM-dd")}});return n.useEffect(()=>{r?.clientMonthlyChargesDrafts||u(null)},[r,u]),o?e.jsx(de,{}):e.jsx(je,{drafts:r?.clientMonthlyChargesDrafts??[]})};export{ye as IssueDocuments};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as x,j as e,B as u,a as y,F as g,u as P,L as D,gc as w}from"./index-
|
|
1
|
+
import{r as x,j as e,B as u,a as y,F as g,u as P,L as D,gc as w}from"./index-qAF5sGRO.js";import{d as R}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{P as E}from"./page-layout-7iCtDTzs.js";import{R as d}from"./report-commentary-row-CgmMnDJu.js";import{P as v}from"./modal-D_KAAYCr.js";import{Y as p}from"./YearPickerInput-DD-O605S.js";import{F}from"./funnel-Cn1E8rCW.js";import{T as C}from"./Table-C5b9rbOB.js";import"./toggle-expansion-button-DYABrNZG.js";import"./panel-top-open-CVvVnpDH.js";function A({year:l,setYear:h,referenceYears:o,setReferenceYears:j}){const[m,c]=x.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(v,{opened:m,onClose:()=>c(!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:()=>c(!0),children:e.jsx(F,{className:"size-5"})})]})}const I=()=>{const{year:l}=y(),{setFiltersContext:h}=x.useContext(g),[o,j]=x.useState(l?Number(l):new Date().getFullYear()),[m,c]=x.useState([]),[{data:n,fetching:i}]=P({query:R(w),variables:{reportYear:o,referenceYears:m}});x.useEffect(()=>{h(e.jsx("div",{className:"flex flex-row gap-2",children:e.jsx(A,{year:o,setYear:j,referenceYears:m,setReferenceYears:c})}))},[o,i,h,m,c]);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 +1 @@
|
|
|
1
|
-
import{r as m,j as e,B as u,a as y,F as R,u as T,L as D,gd as E}from"./index-
|
|
1
|
+
import{r as m,j as e,B as u,a as y,F as R,u as T,L as D,gd as E}from"./index-qAF5sGRO.js";import{d as b}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{P as w}from"./page-layout-7iCtDTzs.js";import{R as d}from"./report-commentary-row-CgmMnDJu.js";import{P as F}from"./modal-D_KAAYCr.js";import{Y as f}from"./YearPickerInput-DD-O605S.js";import{F as g}from"./funnel-Cn1E8rCW.js";import{T as v}from"./Table-C5b9rbOB.js";import"./toggle-expansion-button-DYABrNZG.js";import"./panel-top-open-CVvVnpDH.js";function B({year:i,setYear:h,referenceYears:x,setReferenceYears:j}){const[l,c]=m.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(F,{opened:l,onClose:()=>c(!1),withCloseButton:!0,content:e.jsxs(e.Fragment,{children:[e.jsx(f,{label:"Change report year",value:new Date(i,0,1),onChange:n=>n&&h(n?.getFullYear()),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date}),e.jsx(f,{type:"multiple",label:"Pick reference years",value:x?.map(n=>new Date(n,0,1)),onChange:n=>j(n.map(o=>o.getFullYear()).filter(o=>i!==o)),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date})]})}),e.jsx(u,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>c(!0),children:e.jsx(g,{className:"size-5"})})]})}const G=()=>{const{year:i}=y(),{setFiltersContext:h}=m.useContext(R),[x,j]=m.useState(i?Number(i):new Date().getFullYear()),[l,c]=m.useState([]),[{data:n,fetching:o}]=T({query:b(E),variables:{reportYear:x,referenceYears:l}});m.useEffect(()=>{h(e.jsx("div",{className:"flex flex-row gap-2",children:e.jsx(B,{year:x,setYear:j,referenceYears:l,setReferenceYears:c})}))},[x,o,h,l,c]);const p=n?.taxReport,s=p?.report,r=p?.reference??[];return e.jsx(w,{title:"Tax Report",children:o?e.jsx(D,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsx("div",{className:"flex flex-col gap-4",children:s&&e.jsxs(v,{highlightOnHover:!0,fontSize:"md",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{}),e.jsx("th",{children:x},x),e.jsx("th",{}),r.map(t=>e.jsx("th",{children:t.year},t.year))]})}),e.jsxs("tbody",{children:[e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("th",{children:"Profit Before Tax"}),e.jsx("th",{children:s.profitBeforeTax.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("th",{children:a.profitBeforeTax.amount.formatted},a.year))]}),commentaryData:s.profitBeforeTax}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"R&D Expenses By Records"}),e.jsx("td",{children:s.researchAndDevelopmentExpensesByRecords.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.researchAndDevelopmentExpensesByRecords.amount.formatted},a.year))]}),commentaryData:s.researchAndDevelopmentExpensesByRecords}),e.jsxs("tr",{children:[e.jsx("td",{children:"R&D Expenses For Tax"}),e.jsx("td",{children:s.researchAndDevelopmentExpensesForTax.formatted}),e.jsx("td",{}),r.map(t=>e.jsx("td",{children:t.researchAndDevelopmentExpensesForTax.formatted},t.year)),e.jsx("td",{})]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Fines"}),e.jsx("td",{children:s.fines.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.fines.amount.formatted},a.year))]}),commentaryData:s.fines}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Untaxable Gifts"}),e.jsx("td",{children:s.untaxableGifts.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.untaxableGifts.amount.formatted},a.year))]}),commentaryData:s.untaxableGifts}),e.jsxs("tr",{children:[e.jsx("td",{children:"Business Trips Excess Expenses"}),e.jsx("td",{children:s.businessTripsExcessExpensesAmount.formatted}),e.jsx("td",{}),r.map(t=>e.jsx("td",{children:t.businessTripsExcessExpensesAmount.formatted},t.year)),e.jsx("td",{})]}),e.jsxs("tr",{children:[e.jsx("td",{children:"Salary Excess Expenses"}),e.jsx("td",{children:s.salaryExcessExpensesAmount.formatted}),e.jsx("td",{}),r.map(t=>e.jsx("td",{children:t.salaryExcessExpensesAmount.formatted},t.year)),e.jsx("td",{})]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Reserves"}),e.jsx("td",{children:s.reserves.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.reserves.amount.formatted},a.year))]}),commentaryData:s.reserves}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Nontaxable Linkage"}),e.jsx("td",{children:s.nontaxableLinkage.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.nontaxableLinkage.amount.formatted},a.year))]}),commentaryData:s.nontaxableLinkage}),e.jsxs("tr",{children:[e.jsx("th",{children:"Taxable Income"}),e.jsx("th",{children:s.taxableIncome.formatted}),e.jsx("th",{}),r.map(t=>e.jsx("th",{children:t.taxableIncome.formatted},t.year)),e.jsx("td",{})]}),e.jsxs("tr",{children:[e.jsx("td",{children:"Tax Rate"}),e.jsxs("td",{children:[(s.taxRate*100).toFixed(1),"%"]}),e.jsx("td",{}),r.map(t=>e.jsxs("td",{children:[(t.taxRate*100).toFixed(1),"%"]},t.year)),e.jsx("td",{})]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Income with Special Tax Rate"}),e.jsx("td",{children:s.specialTaxableIncome.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.specialTaxableIncome.amount.formatted},a.year))]}),commentaryData:s.specialTaxableIncome}),e.jsxs("tr",{children:[e.jsx("td",{children:"Special Tax Rate"}),e.jsxs("td",{children:[(s.specialTaxRate*100).toFixed(1),"%"]}),e.jsx("td",{}),r.map(t=>e.jsxs("td",{children:[(t.specialTaxRate*100).toFixed(1),"%"]},t.year)),e.jsx("td",{})]})]}),e.jsx("tfoot",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Annual Tax Expense"}),e.jsx("th",{children:s.annualTaxExpense.formatted}),e.jsx("th",{}),r.map(t=>e.jsx("th",{children:t.annualTaxExpense.formatted},t.year)),e.jsx("td",{})]})})]})})})};export{G as TaxReport};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{dT as S,j as e,ai as w,R as C,ay as d,G as v,gi as R,r as c,bX as j,gj as b,gk as I,J as L,gl as y,u as U,F as k,B as A,gm as $,c as E,gn as T}from"./index-
|
|
1
|
+
import{dT as S,j as e,ai as w,R as C,ay as d,G as v,gi as R,r as c,bX as j,gj as b,gk as I,J as L,gl as y,u as U,F as k,B as A,gm as $,c as E,gn as T}from"./index-qAF5sGRO.js";import{P}from"./page-layout-7iCtDTzs.js";import{Y as z}from"./YearPickerInput-DD-O605S.js";const o=(s,a)=>S(a,{minimumFractionDigits:0}).format(s);function O(s){return{id:s.id,chargeId:s.chargeId,date:s.date,description:s.description??"",reference:s.reference??"",amountILS:s.revenueLocal.raw,amountUSD:s.revenueDefaultForeign.raw,originalAmount:s.revenueOriginal.formatted}}const Y=({recordData:s})=>{const a=v(R,s),n=O(a);return e.jsx("div",{className:"p-2 bg-background rounded-lg border border-border/30 text-sm",children:e.jsxs(w,{to:C.CHARGES.DETAIL(n.chargeId),target:"_blank",rel:"noreferrer",onClick:h=>h.stopPropagation(),className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium text-foreground",children:n.reference}),e.jsx("p",{className:"font-medium text-foreground",children:n.description}),e.jsxs("div",{className:"flex gap-4 mt-1 text-xs text-muted-foreground",children:[e.jsx("span",{children:n.chargeId}),e.jsx("span",{children:n.date})]})]}),e.jsxs("div",{className:"invisible md:visible md:text-right flex-shrink-0",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:o(n.amountILS,d.Ils)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:o(n.amountUSD,d.Usd)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n.originalAmount})]}),e.jsx("div",{className:"md:invisible ml-2 text-right",children:e.jsx("p",{className:"text-xs font-medium text-foreground",children:o(n.amountILS,d.Ils)})})]})})};function M(s){return{id:s.id,name:s.name,revenueILS:s.revenueLocal.raw,revenueUSD:s.revenueDefaultForeign.raw,records:s.records.map(a=>({id:a.id,data:a}))}}const B=({clientData:s})=>{const[a,n]=c.useState(!1),h=v(I,s),r=M(h),g=()=>{n(i=>!i)},u=c.useMemo(()=>r.records.slice().sort((i,t)=>i.data.date.localeCompare(t.data.date)),[r.records]);return e.jsxs("div",{children:[e.jsxs("button",{onClick:g,className:"w-full flex items-center justify-between p-2 bg-background rounded-lg border border-border/50 hover:bg-accent/5 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[a?e.jsx(j,{className:"size-4 text-muted-foreground flex-shrink-0"}):e.jsx(b,{className:"size-4 text-muted-foreground flex-shrink-0"}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-medium text-foreground text-sm",children:r.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[r.records?.length||0," record",r.records?.length===1?"":"s"]})]})]}),e.jsxs("div",{className:"hidden md:grid grid-cols-2 gap-4 text-right flex-shrink-0",children:[e.jsx("div",{children:e.jsx("p",{className:"text-xs text-muted-foreground",children:o(r.revenueILS,d.Ils)})}),e.jsx("div",{children:e.jsx("p",{className:"text-xs text-muted-foreground",children:o(r.revenueUSD,d.Usd)})})]}),e.jsxs("div",{className:"md:hidden ml-4 text-right",children:[e.jsx("p",{className:"text-xs font-medium text-foreground",children:o(r.revenueILS,d.Ils)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:o(r.revenueUSD,d.Usd)})]})]}),a&&u&&e.jsx("div",{className:"mt-3 ml-2 space-y-3 border-l-2 border-border/50 pl-2",children:u.map(i=>e.jsx(Y,{recordData:i.data},i.id))})]})};function G(s){return{code:s.code,name:s.name,revenues:{ILS:s.revenueLocal.raw,USD:s.revenueDefaultForeign.raw},clients:s.clients.map(a=>({id:a.id,data:a}))}}const V=({countryData:s})=>{const[a,n]=c.useState(!1),h=v(y,s),r=G(h),g=()=>{n(t=>!t)},u={ILS:r.revenues.ILS,USD:r.revenues.USD},i=c.useMemo(()=>r.clients.slice().sort((t,f)=>f.data.revenueDefaultForeign.raw-t.data.revenueDefaultForeign.raw),[r.clients]);return e.jsxs(L,{className:"border border-border",children:[e.jsxs("button",{onClick:()=>g(),className:"w-full px-4 py-2 hover:bg-accent/5 transition-colors flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[a?e.jsx(j,{className:"size-5 text-muted-foreground flex-shrink-0"}):e.jsx(b,{className:"size-5 text-muted-foreground flex-shrink-0"}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-semibold text-foreground text-lg",children:r.name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[r.clients.length," clients"]})]})]}),e.jsxs("div",{className:"hidden md:grid grid-cols-2 gap-4 text-right flex-shrink-0",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"ILS"}),e.jsx("p",{className:"font-semibold text-foreground",children:o(r.revenues.ILS,d.Ils)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"USD"}),e.jsx("p",{className:"font-semibold text-foreground",children:o(r.revenues.USD,d.Usd)})]})]})]}),e.jsxs("div",{className:"md:hidden px-2 py-2 bg-accent/5 border-t border-border flex gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"ILS"}),e.jsx("p",{className:"font-semibold text-foreground",children:o(r.revenues.ILS,d.Ils)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"USD"}),e.jsx("p",{className:"font-semibold text-foreground",children:o(r.revenues.USD,d.Usd)})]})]}),a&&e.jsx("div",{className:"border-t border-border",children:e.jsxs("div",{className:"space-y-2 p-3 bg-muted/30",children:[i.map(t=>e.jsx(B,{clientData:t.data},t.id)),e.jsx("div",{className:"pt-2 border-t border-border/50 mt-4",children:e.jsxs("div",{className:"flex items-center justify-between p-2",children:[e.jsx("p",{className:"font-semibold text-foreground text-sm",children:"Clients Subtotal"}),e.jsxs("div",{className:"hidden md:grid grid-cols-2 gap-4 text-right",children:[e.jsx("div",{children:e.jsx("p",{className:"font-semibold text-foreground",children:o(u.ILS,d.Ils)})}),e.jsx("div",{children:e.jsx("p",{className:"font-semibold text-foreground",children:o(u.USD,d.Usd)})})]}),e.jsxs("div",{className:"md:hidden ml-4 text-right",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:o(u.ILS,d.Ils)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:o(u.USD,d.Usd)})]})]})})]})})]},r.code)},Q=()=>{const[s,a]=c.useState(new Date().getFullYear()-1),[{data:n,fetching:h}]=U({query:T,variables:{filters:{year:s}}}),r=c.useCallback(()=>{const t=[];t.push("Country,Client,charge ID,Date,Description,Revenue ILS,Revenue USD"),n?.annualRevenueReport.countries.sort((x,l)=>l.revenueDefaultForeign.raw-x.revenueDefaultForeign.raw).map(x=>{t.push(`${x.name},,,,TOTAL,${x.revenueLocal.raw.toFixed(2)},${x.revenueDefaultForeign.raw.toFixed(2)}`),x.clients.sort((l,m)=>m.revenueDefaultForeign.raw-l.revenueDefaultForeign.raw).map(l=>{l.records&&l.records.length>0?(t.push(`${x.name},${l.name},,,TOTAL,${l.revenueLocal.raw.toFixed(2)},${l.revenueDefaultForeign.raw.toFixed(2)}`),l.records.sort((m,F)=>m.date.localeCompare(F.date)).map(m=>{t.push(`${x.name},${l.name},${m.chargeId},${m.date},${m.description},${m.revenueLocal.raw.toFixed(2)},${m.revenueDefaultForeign.raw.toFixed(2)}`)})):t.push(`${x.name},${l.name},,,,,`)})});const f=t.join(`
|
|
2
2
|
`),N=new Blob([f],{type:"text/csv;charset=utf-8;"}),p=document.createElement("a"),D=URL.createObjectURL(N);p.setAttribute("href",D),p.setAttribute("download",`annual-revenue-${s}.csv`),p.style.visibility="hidden",document.body.appendChild(p),p.click(),document.body.removeChild(p)},[n,s]),{setFiltersContext:g}=c.useContext(k);c.useEffect(()=>{g(e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(z,{value:new Date(s,0,1),onChange:t=>t&&a(t?.getFullYear()),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date}),e.jsxs(A,{onClick:r,variant:"outline",size:"sm",className:"flex items-center gap-2 bg-transparent",children:[e.jsx($,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Export CSV"})]})]}))},[s,h,g,r]);const u=c.useMemo(()=>`Annual Revenue Report for ${s}`,[s]),i=c.useMemo(()=>n?.annualRevenueReport.countries.slice().sort((t,f)=>f.revenueDefaultForeign.raw-t.revenueDefaultForeign.raw),[n]);return e.jsx(P,{title:"Annual Revenue Report",description:u,children:h?e.jsx(E,{}):e.jsx("div",{className:"min-h-screen bg-background",children:e.jsx("main",{className:"container mx-auto px-2 py-2 max-w-7xl",children:e.jsx("div",{className:"space-y-2",children:i?.map(t=>e.jsx(V,{countryData:t},t.id))})})})})};export{Q as AnnualRevenueReport};
|