@accounter/client
Version:
Accounter client application
1 lines • 5.29 kB
JavaScript
import{t as e}from"./funnel-CDY9d08i.js";import{Al as t,Cu as n,Hi as r,Id as i,N as a,Td as o,Wl as s,Zu as c,er as l,jd as u,ln as d,rr as f,sc as p}from"./index-CSYTUOOk.js";import{t as m}from"./page-layout-DE94O32j.js";import{t as h}from"./report-commentary-row-BQltE-53.js";var g=i(u(),1),_=n();function v({year:t,setYear:n,referenceYears:r,setReferenceYears:i}){let[o,c]=(0,g.useState)(!1);return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(a,{opened:o,onClose:()=>c(!1),withCloseButton:!0,content:(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(d,{label:`Change report year`,value:new Date(t,0,1),onChange:e=>e&&n(e?.getFullYear()),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date}),(0,_.jsx)(d,{type:`multiple`,label:`Pick reference years`,value:r?.map(e=>new Date(e,0,1)),onChange:e=>i(e.map(e=>e.getFullYear()).filter(e=>t!==e)),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date})]})}),(0,_.jsx)(s,{variant:`outline`,size:`icon`,className:`size-7.5`,onClick:()=>c(!0),children:(0,_.jsx)(e,{className:`size-5`})})]})}var y=()=>{let{year:e}=o(),{setFiltersContext:n}=(0,g.useContext)(l),[i,a]=(0,g.useState)(e?Number(e):new Date().getFullYear()),[s,u]=(0,g.useState)([]),[{data:d,fetching:y}]=t({query:r(p),variables:{reportYear:i,referenceYears:s}});(0,g.useEffect)(()=>{n((0,_.jsx)(`div`,{className:`flex flex-row gap-2`,children:(0,_.jsx)(v,{year:i,setYear:a,referenceYears:s,setReferenceYears:u})}))},[i,y,n,s,u]);let b=d?.profitAndLossReport,x=b?.report,S=b?.reference??[];return(0,_.jsx)(m,{title:`Profit and Loss Report`,children:y?(0,_.jsx)(c,{className:`h-10 w-10 animate-spin mr-2 self-center`}):(0,_.jsx)(`div`,{className:`flex flex-col gap-4`,children:x&&(0,_.jsxs)(f,{highlightOnHover:!0,fontSize:`md`,children:[(0,_.jsx)(`thead`,{children:(0,_.jsxs)(`tr`,{children:[(0,_.jsx)(`th`,{}),(0,_.jsx)(`th`,{children:i},i),(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};