@accounter/client
Version:
Accounter client application
1 lines • 2.34 kB
JavaScript
import{s as e}from"./dist-ypP48_Ax.js";import{i as t,o as n}from"./utils-CbS-oR5I.js";import{y as r}from"./routes-D0AKaVmS.js";import{Ht as i}from"./common-DLHrF4-C.js";import{c as a}from"./separator-CzGTi79B.js";import{tl as o}from"./table-CLAyk1Jz.js";import{In as s,pt as c,ss as l}from"./graphql-6oWwD3Rd.js";import{n as u,t as d}from"./business-ledger-filters-De85G3Px.js";import{t as f}from"./use-url-query-v8OHvuc2.js";import{t as p}from"./business-extended-info-9dM2Lo4r.js";var m=e(n(),1),h=t(),g=({businessId:e})=>{let{businessId:t}=r(),{get:n}=f(),{setFiltersContext:g}=(0,m.useContext)(a),v=e||t,[y,b]=(0,m.useState)(n(`ledgerRecordsFilters`)?{...JSON.parse(decodeURIComponent(n(`ledgerRecordsFilters`))),businessIDs:v?[v]:[]}:{businessIDs:v?[v]:[]}),[{data:x,fetching:S}]=l({query:c,variables:{filters:y}});(0,m.useEffect)(()=>{g((0,h.jsx)(d,{filter:y,setFilter:b}))},[x,y,g,b]);let C=x?.businessTransactionsSumFromLedgerRecords.__typename===`CommonError`?void 0:x?.businessTransactionsSumFromLedgerRecords.businessTransactionsSum,w=C?[...C].sort((e,t)=>e.business.name.localeCompare(t.business.name)):[];return S?(0,h.jsx)(o,{}):(0,h.jsx)(i,{moreInfo:e=>(0,h.jsx)(p,{businessID:e.business.id,filter:y}),striped:!0,highlightOnHover:!0,stickyHeader:!0,items:w,columns:[{title:`Business Name`,value:e=>e.business.name},{title:`Debit`,value:e=>e.debit.formatted,style:{whiteSpace:`nowrap`}},{title:`Credit`,value:e=>e.credit.formatted,style:{whiteSpace:`nowrap`}},{title:`Total`,value:e=>e.total.raw&&(e.total.raw<-1e-4||e.total.raw>1e-4)?(0,h.jsx)(u,{color:e.total.raw>0?`green`:`red`,children:e.total.formatted}):e.total.formatted,style:{whiteSpace:`nowrap`}},..._(s.Eur),..._(s.Usd),..._(s.Gbp),..._(s.Cad),..._(s.Jpy),..._(s.Aud),..._(s.Sek)]})};function _(e){return[{title:`${e} Debit`,value:t=>t.foreignCurrenciesSum.find(t=>t.currency===e)?.debit?.formatted,style:{whiteSpace:`nowrap`}},{title:`${e} Credit`,value:t=>t.foreignCurrenciesSum.find(t=>t.currency===e)?.credit?.formatted,style:{whiteSpace:`nowrap`}},{title:`${e} Total`,value:t=>{let n=t.foreignCurrenciesSum.find(t=>t.currency===e);return n?.total?.raw&&(n.total.raw<-1e-4||n.total.raw>1e-4)?(0,h.jsx)(u,{color:n.total.raw>0?`green`:`red`,children:n.total.formatted}):n?.total?.formatted},style:{whiteSpace:`nowrap`}}]}export{g as BusinessLedgerRecordsSingle};