UNPKG

@accounter/client

Version:
1 lines • 5.66 kB
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-Cawu7UJi.js";import{t as i}from"./loader-circle-CfW9jOIr.js";import{Gt as a,gt as o,kt as s,p as c}from"./common-D-vYt_Yl.js";import{c as l}from"./separator-BvKylNhK.js";import{t as u}from"./funnel-BrJTCiKR.js";import{t as d}from"./button-DUNsVBiu.js";import{Mi as f,Qo as p}from"./graphql-DC5GYCFE.js";import{t as m}from"./graphql-document-dedupe-fragments-C4jAugiJ.js";import{t as h}from"./page-layout-DfY10rJx.js";import{t as g}from"./report-commentary-row-aLpUDrKM.js";var _=e(n(),1),v=t();function y({year:e,setYear:t,referenceYears:n,setReferenceYears:r}){let[i,a]=(0,_.useState)(!1);return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(c,{opened:i,onClose:()=>a(!1),withCloseButton:!0,content:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o,{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,v.jsx)(o,{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,v.jsx)(d,{variant:`outline`,size:`icon`,className:`size-7.5`,onClick:()=>a(!0),children:(0,v.jsx)(u,{className:`size-5`})})]})}var b=()=>{let{year:e}=r(),{setFiltersContext:t}=(0,_.useContext)(l),[n,o]=(0,_.useState)(e?Number(e):new Date().getFullYear()),[c,u]=(0,_.useState)([]),[{data:d,fetching:b}]=p({query:m(f),variables:{reportYear:n,referenceYears:c}});(0,_.useEffect)(()=>{t((0,v.jsx)(`div`,{className:`flex flex-row gap-2`,children:(0,v.jsx)(y,{year:n,setYear:o,referenceYears:c,setReferenceYears:u})}))},[n,b,t,c,u]);let x=d?.profitAndLossReport,S=x?.report,C=x?.reference??[];return(0,v.jsx)(h,{title:`Profit and Loss Report`,headerActions:(0,v.jsx)(s,{filename:`profit_and_loss_${n}`}),children:b?(0,v.jsx)(i,{className:`h-10 w-10 animate-spin mr-2 self-center`}):(0,v.jsx)(`div`,{className:`flex flex-col gap-4`,children:S&&(0,v.jsxs)(a,{highlightOnHover:!0,fontSize:`md`,children:[(0,v.jsx)(`thead`,{children:(0,v.jsxs)(`tr`,{children:[(0,v.jsx)(`th`,{}),(0,v.jsx)(`th`,{children:n},n),(0,v.jsx)(`th`,{}),C.map(e=>(0,v.jsx)(`th`,{children:e.year},e.year))]})}),(0,v.jsxs)(`tbody`,{children:[(0,v.jsx)(g,{dataRow:e=>(0,v.jsxs)(`tr`,{children:[(0,v.jsx)(`th`,{children:`Revenue`}),(0,v.jsx)(`th`,{children:S.revenue.amount.formatted}),(0,v.jsx)(`th`,{children:e}),C.map(e=>(0,v.jsx)(`th`,{children:e.revenue.amount.formatted},e.year))]}),commentaryData:S.revenue}),(0,v.jsx)(g,{dataRow:e=>(0,v.jsxs)(`tr`,{children:[(0,v.jsx)(`td`,{children:`Cost of Sales`}),(0,v.jsx)(`td`,{children:S.costOfSales.amount.formatted}),(0,v.jsx)(`th`,{children:e}),C.map(e=>(0,v.jsx)(`td`,{children:e.costOfSales.amount.formatted},e.year))]}),commentaryData:S.costOfSales}),(0,v.jsxs)(`tr`,{children:[(0,v.jsx)(`th`,{children:`Gross Profit`}),(0,v.jsx)(`th`,{children:S.grossProfit.formatted}),(0,v.jsx)(`th`,{}),C.map(e=>(0,v.jsx)(`th`,{children:e.grossProfit.formatted},e.year))]}),(0,v.jsx)(g,{dataRow:e=>(0,v.jsxs)(`tr`,{children:[(0,v.jsx)(`td`,{children:`R&D Expenses`}),(0,v.jsx)(`td`,{children:S.researchAndDevelopmentExpenses.amount.formatted}),(0,v.jsx)(`th`,{children:e}),C.map(e=>(0,v.jsx)(`td`,{children:e.researchAndDevelopmentExpenses.amount.formatted},e.year))]}),commentaryData:S.researchAndDevelopmentExpenses}),(0,v.jsx)(g,{dataRow:e=>(0,v.jsxs)(`tr`,{children:[(0,v.jsx)(`td`,{children:`Marketing Expenses`}),(0,v.jsx)(`td`,{children:S.marketingExpenses.amount.formatted}),(0,v.jsx)(`th`,{children:e}),C.map(e=>(0,v.jsx)(`td`,{children:e.marketingExpenses.amount.formatted},e.year))]}),commentaryData:S.marketingExpenses}),(0,v.jsx)(g,{dataRow:e=>(0,v.jsxs)(`tr`,{children:[(0,v.jsx)(`td`,{children:`Management and General Expenses`}),(0,v.jsx)(`td`,{children:S.managementAndGeneralExpenses.amount.formatted}),(0,v.jsx)(`th`,{children:e}),C.map(e=>(0,v.jsx)(`td`,{children:e.managementAndGeneralExpenses.amount.formatted},e.year))]}),commentaryData:S.managementAndGeneralExpenses}),(0,v.jsxs)(`tr`,{children:[(0,v.jsx)(`th`,{children:`Operating Profit`}),(0,v.jsx)(`th`,{children:S.operatingProfit.formatted}),(0,v.jsx)(`th`,{}),C.map(e=>(0,v.jsx)(`th`,{children:e.operatingProfit.formatted},e.year))]}),(0,v.jsx)(g,{dataRow:e=>(0,v.jsxs)(`tr`,{children:[(0,v.jsx)(`td`,{children:`Financial Expenses`}),(0,v.jsx)(`td`,{children:S.financialExpenses.amount.formatted}),(0,v.jsx)(`th`,{children:e}),C.map(e=>(0,v.jsx)(`td`,{children:e.financialExpenses.amount.formatted},e.year))]}),commentaryData:S.financialExpenses}),(0,v.jsx)(g,{dataRow:e=>(0,v.jsxs)(`tr`,{children:[(0,v.jsx)(`td`,{children:`Other Income`}),(0,v.jsx)(`td`,{children:S.otherIncome.amount.formatted}),(0,v.jsx)(`th`,{children:e}),C.map(e=>(0,v.jsx)(`td`,{children:e.otherIncome.amount.formatted},e.year))]}),commentaryData:S.otherIncome}),(0,v.jsxs)(`tr`,{children:[(0,v.jsx)(`th`,{children:`Profit Before Tax`}),(0,v.jsx)(`th`,{children:S.profitBeforeTax.formatted}),(0,v.jsx)(`th`,{}),C.map(e=>(0,v.jsx)(`th`,{children:e.profitBeforeTax.formatted},e.year))]}),(0,v.jsxs)(`tr`,{children:[(0,v.jsx)(`td`,{children:`Tax`}),(0,v.jsx)(`td`,{children:S.tax.formatted}),(0,v.jsx)(`td`,{}),C.map(e=>(0,v.jsx)(`td`,{children:e.tax.formatted},e.year))]})]}),(0,v.jsx)(`tfoot`,{children:(0,v.jsxs)(`tr`,{children:[(0,v.jsx)(`th`,{children:`Net Profit`}),(0,v.jsx)(`th`,{children:S.netProfit.formatted}),(0,v.jsx)(`th`,{}),C.map(e=>(0,v.jsx)(`th`,{children:e.netProfit.formatted},e.year))]})})]})})})};export{b as ProfitAndLossReport};