import{r as o,j as t,e as s,T as g}from"./index-B1H8BCL7.js";import{q as p}from"./stockApi-D1nxeMJU.js";import{R as d}from"./ReportPageShell-B7ORyOeG.js";import{G as i}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 x=[{key:"machineId",header:"Machine #",width:110,align:"right"},{key:"itemCode",header:"Reagent Code",width:130},{key:"itemName",header:"Reagent"},{key:"totalConsumed",header:"Consumed",align:"right",format:f},{key:"totalValue",header:"Value",align:"right",format:y},{key:"entriesCount",header:"Entries",align:"right"}],L=()=>{const[e,m]=o.useState(b()),[a,l]=o.useState(S()),{data:r,isFetching:u,refetch:c}=p({from:e,to:a}),h=(r==null?void 0:r.list)??[];return t.jsx(d,{title:"Machine-wise Reagent Usage",subtitle:"Reagent / control / calibrator consumption attributed to machine_id via test_item_consumption_mapping. Skips ledger rows that have no machine attribution.",filters:t.jsxs(i,{container:!0,spacing:1.5,children:[t.jsx(i,{item:!0,xs:6,sm:3,children:t.jsx(s,{label:"From",type:"date",size:"small",fullWidth:!0,InputLabelProps:{shrink:!0},value:e,onChange:n=>m(n.target.value)})}),t.jsx(i,{item:!0,xs:6,sm:3,children:t.jsx(s,{label:"To",type:"date",size:"small",fullWidth:!0,InputLabelProps:{shrink:!0},value:a,onChange:n=>l(n.target.value)})}),t.jsx(i,{item:!0,xs:12,sm:6,sx:{display:"flex",alignItems:"center"},children:t.jsx(g,{sx:{fontSize:"0.72rem",color:"#94a3b8"},children:"Set machine_id on Test Consumption mappings to populate this report."})})]}),columns:x,rows:h,isFetching:u,refetch:c,csvFilenameStem:"machine-reagent-usage"})};function f(e){return e==null?"0":Number(e).toLocaleString("en-IN",{minimumFractionDigits:0,maximumFractionDigits:3})}function y(e){return e==null?"0.00":Number(e).toLocaleString("en-IN",{minimumFractionDigits:2,maximumFractionDigits:2})}function S(){return new Date().toISOString().slice(0,10)}function b(){const e=new Date;return e.setDate(e.getDate()-30),e.toISOString().slice(0,10)}export{L as default};
