@accounter/client
Version:
Accounter client application
1 lines • 2.31 kB
JavaScript
import{s as e}from"./dist-C51EwTaa.js";import{i as t,o as n}from"./utils-DdVdMk8X.js";import{Lo as r,Rn as i,pt as a}from"./error-handling-Dpfd9svJ.js";import{y as o}from"./routes-DUvpW9-n.js";import{J as s}from"./table--bF0wbxq.js";import{n as c,t as l}from"./business-ledger-filters-C9wweYyi.js";import{cn as u,on as d}from"./index-CL8-JoMZ.js";import{t as f}from"./use-url-query-BCNbSvLg.js";import{t as p}from"./business-extended-info-BGuAmkTk.js";var m=e(n(),1),h=t(),g=({businessId:e})=>{let{businessId:t}=o(),{get:n}=f(),{setFiltersContext:g}=(0,m.useContext)(u),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}]=r({query:a,variables:{filters:y}});(0,m.useEffect)(()=>{g((0,h.jsx)(l,{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)(s,{}):(0,h.jsx)(d,{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)(c,{color:e.total.raw>0?`green`:`red`,children:e.total.formatted}):e.total.formatted,style:{whiteSpace:`nowrap`}},..._(i.Eur),..._(i.Usd),..._(i.Gbp),..._(i.Cad),..._(i.Jpy),..._(i.Aud),..._(i.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)(c,{color:n.total.raw>0?`green`:`red`,children:n.total.formatted}):n?.total?.formatted},style:{whiteSpace:`nowrap`}}]}export{g as BusinessLedgerRecordsSingle};