import{r as a,j as e,e as m,T as x}from"./index-B1H8BCL7.js";import{j as f}from"./stockApi-D1nxeMJU.js";import{R as C}from"./ReportPageShell-B7ORyOeG.js";import{G as o}from"./Grid-CTEl0Elf.js";import"./FileDownloadOutlined-B1TjRPKt.js";import"./Refresh-942gtAB1.js";import"./Stack-BIAbaqpj.js";import"./useThemeProps-DL_l3A7P.js";import"./TableContainer-CXAjhAg6.js";import"./TableRow-BfKE_xn9.js";import"./TableCell-D8CotAsC.js";const S=[{key:"itemCode",header:"Item Code",width:110},{key:"itemName",header:"Item Name"},{key:"stockPurpose",header:"Purpose",width:160},{key:"totalConsumed",header:"Consumed",align:"right",format:T},{key:"totalValue",header:"Total Value",align:"right",format:l},{key:"entriesCount",header:"Txn Count",align:"right"}],M=()=>{const[t,u]=a.useState(I()),[i,c]=a.useState(N()),{data:s,isFetching:p,refetch:d}=f({from:t,to:i}),n=(s==null?void 0:s.list)??[],g=n.reduce((r,h)=>r+(Number(h.totalValue)||0),0);return e.jsx(C,{title:"Test-wise Consumption",subtitle:`Sample collection + test processing + QC + calibration usage. Total cost: ${l(g)}`,filters:e.jsxs(o,{container:!0,spacing:1.5,children:[e.jsx(o,{item:!0,xs:6,sm:3,children:e.jsx(m,{label:"From",type:"date",size:"small",fullWidth:!0,InputLabelProps:{shrink:!0},value:t,onChange:r=>u(r.target.value)})}),e.jsx(o,{item:!0,xs:6,sm:3,children:e.jsx(m,{label:"To",type:"date",size:"small",fullWidth:!0,InputLabelProps:{shrink:!0},value:i,onChange:r=>c(r.target.value)})}),e.jsx(o,{item:!0,xs:12,sm:6,sx:{display:"flex",alignItems:"center"},children:e.jsx(x,{sx:{fontSize:"0.72rem",color:"#94a3b8"},children:"Sums stock_ledger.out_qty for SAMPLE_COLLECTION_CONSUMPTION + TEST_CONSUMPTION + QC_CONSUMPTION + CALIBRATION_CONSUMPTION rows."})})]}),columns:S,rows:n,isFetching:p,refetch:d,csvFilenameStem:"test-consumption"})};function T(t){return t==null?"0":Number(t).toLocaleString("en-IN",{minimumFractionDigits:0,maximumFractionDigits:3})}function l(t){return t==null?"0.00":Number(t).toLocaleString("en-IN",{minimumFractionDigits:2,maximumFractionDigits:2})}function N(){return new Date().toISOString().slice(0,10)}function I(){const t=new Date;return t.setDate(t.getDate()-30),t.toISOString().slice(0,10)}export{M as default};
