@accounter/client
Version:
Accounter client application
1 lines • 5.49 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,Si as i}from"./error-handling-Dpfd9svJ.js";import{y as a}from"./routes-DUvpW9-n.js";import{ft as o}from"./select-CrsvQyhZ.js";import{t as s}from"./funnel-BFbxpUGW.js";import{t as c}from"./button-Dzp2INW0.js";import{P as l,Pt as u,cn as d,gr as f,ln as p}from"./index-CL8-JoMZ.js";import{t as m}from"./page-layout-DoLDsSrs.js";import{t as h}from"./report-commentary-row-CXrND4Xq.js";var g=e(n(),1),_=t();function v({year:e,setYear:t,referenceYears:n,setReferenceYears:r}){let[i,a]=(0,g.useState)(!1);return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(l,{opened:i,onClose:()=>a(!1),withCloseButton:!0,content:(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(u,{label:`Change report year`,value:new Date(e,0,1),onChange:e=>e&&t(e?.getFullYear()),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date}),(0,_.jsx)(u,{type:`multiple`,label:`Pick reference years`,value:n?.map(e=>new Date(e,0,1)),onChange:t=>r(t.map(e=>e.getFullYear()).filter(t=>e!==t)),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date})]})}),(0,_.jsx)(c,{variant:`outline`,size:`icon`,className:`size-7.5`,onClick:()=>a(!0),children:(0,_.jsx)(s,{className:`size-5`})})]})}var y=()=>{let{year:e}=a(),{setFiltersContext:t}=(0,g.useContext)(d),[n,s]=(0,g.useState)(e?Number(e):new Date().getFullYear()),[c,l]=(0,g.useState)([]),[{data:u,fetching:y}]=r({query:f(i),variables:{reportYear:n,referenceYears:c}});(0,g.useEffect)(()=>{t((0,_.jsx)(`div`,{className:`flex flex-row gap-2`,children:(0,_.jsx)(v,{year:n,setYear:s,referenceYears:c,setReferenceYears:l})}))},[n,y,t,c,l]);let b=u?.profitAndLossReport,x=b?.report,S=b?.reference??[];return(0,_.jsx)(m,{title:`Profit and Loss Report`,children:y?(0,_.jsx)(o,{className:`h-10 w-10 animate-spin mr-2 self-center`}):(0,_.jsx)(`div`,{className:`flex flex-col gap-4`,children:x&&(0,_.jsxs)(p,{highlightOnHover:!0,fontSize:`md`,children:[(0,_.jsx)(`thead`,{children:(0,_.jsxs)(`tr`,{children:[(0,_.jsx)(`th`,{}),(0,_.jsx)(`th`,{children:n},n),(0,_.jsx)(`th`,{}),S.map(e=>(0,_.jsx)(`th`,{children:e.year},e.year))]})}),(0,_.jsxs)(`tbody`,{children:[(0,_.jsx)(h,{dataRow:e=>(0,_.jsxs)(`tr`,{children:[(0,_.jsx)(`th`,{children:`Revenue`}),(0,_.jsx)(`th`,{children:x.revenue.amount.formatted}),(0,_.jsx)(`th`,{children:e}),S.map(e=>(0,_.jsx)(`th`,{children:e.revenue.amount.formatted},e.year))]}),commentaryData:x.revenue}),(0,_.jsx)(h,{dataRow:e=>(0,_.jsxs)(`tr`,{children:[(0,_.jsx)(`td`,{children:`Cost of Sales`}),(0,_.jsx)(`td`,{children:x.costOfSales.amount.formatted}),(0,_.jsx)(`th`,{children:e}),S.map(e=>(0,_.jsx)(`td`,{children:e.costOfSales.amount.formatted},e.year))]}),commentaryData:x.costOfSales}),(0,_.jsxs)(`tr`,{children:[(0,_.jsx)(`th`,{children:`Gross Profit`}),(0,_.jsx)(`th`,{children:x.grossProfit.formatted}),(0,_.jsx)(`th`,{}),S.map(e=>(0,_.jsx)(`th`,{children:e.grossProfit.formatted},e.year))]}),(0,_.jsx)(h,{dataRow:e=>(0,_.jsxs)(`tr`,{children:[(0,_.jsx)(`td`,{children:`R&D Expenses`}),(0,_.jsx)(`td`,{children:x.researchAndDevelopmentExpenses.amount.formatted}),(0,_.jsx)(`th`,{children:e}),S.map(e=>(0,_.jsx)(`td`,{children:e.researchAndDevelopmentExpenses.amount.formatted},e.year))]}),commentaryData:x.researchAndDevelopmentExpenses}),(0,_.jsx)(h,{dataRow:e=>(0,_.jsxs)(`tr`,{children:[(0,_.jsx)(`td`,{children:`Marketing Expenses`}),(0,_.jsx)(`td`,{children:x.marketingExpenses.amount.formatted}),(0,_.jsx)(`th`,{children:e}),S.map(e=>(0,_.jsx)(`td`,{children:e.marketingExpenses.amount.formatted},e.year))]}),commentaryData:x.marketingExpenses}),(0,_.jsx)(h,{dataRow:e=>(0,_.jsxs)(`tr`,{children:[(0,_.jsx)(`td`,{children:`Management and General Expenses`}),(0,_.jsx)(`td`,{children:x.managementAndGeneralExpenses.amount.formatted}),(0,_.jsx)(`th`,{children:e}),S.map(e=>(0,_.jsx)(`td`,{children:e.managementAndGeneralExpenses.amount.formatted},e.year))]}),commentaryData:x.managementAndGeneralExpenses}),(0,_.jsxs)(`tr`,{children:[(0,_.jsx)(`th`,{children:`Operating Profit`}),(0,_.jsx)(`th`,{children:x.operatingProfit.formatted}),(0,_.jsx)(`th`,{}),S.map(e=>(0,_.jsx)(`th`,{children:e.operatingProfit.formatted},e.year))]}),(0,_.jsx)(h,{dataRow:e=>(0,_.jsxs)(`tr`,{children:[(0,_.jsx)(`td`,{children:`Financial Expenses`}),(0,_.jsx)(`td`,{children:x.financialExpenses.amount.formatted}),(0,_.jsx)(`th`,{children:e}),S.map(e=>(0,_.jsx)(`td`,{children:e.financialExpenses.amount.formatted},e.year))]}),commentaryData:x.financialExpenses}),(0,_.jsx)(h,{dataRow:e=>(0,_.jsxs)(`tr`,{children:[(0,_.jsx)(`td`,{children:`Other Income`}),(0,_.jsx)(`td`,{children:x.otherIncome.amount.formatted}),(0,_.jsx)(`th`,{children:e}),S.map(e=>(0,_.jsx)(`td`,{children:e.otherIncome.amount.formatted},e.year))]}),commentaryData:x.otherIncome}),(0,_.jsxs)(`tr`,{children:[(0,_.jsx)(`th`,{children:`Profit Before Tax`}),(0,_.jsx)(`th`,{children:x.profitBeforeTax.formatted}),(0,_.jsx)(`th`,{}),S.map(e=>(0,_.jsx)(`th`,{children:e.profitBeforeTax.formatted},e.year))]}),(0,_.jsxs)(`tr`,{children:[(0,_.jsx)(`td`,{children:`Tax`}),(0,_.jsx)(`td`,{children:x.tax.formatted}),(0,_.jsx)(`td`,{}),S.map(e=>(0,_.jsx)(`td`,{children:e.tax.formatted},e.year))]})]}),(0,_.jsx)(`tfoot`,{children:(0,_.jsxs)(`tr`,{children:[(0,_.jsx)(`th`,{children:`Net Profit`}),(0,_.jsx)(`th`,{children:x.netProfit.formatted}),(0,_.jsx)(`th`,{}),S.map(e=>(0,_.jsx)(`th`,{children:e.netProfit.formatted},e.year))]})})]})})})};export{y as ProfitAndLossReport};