import{r as l,j as e,e as m}from"./index-B1H8BCL7.js";import{o as f}from"./stockApi-D1nxeMJU.js";import{R as x}from"./ReportPageShell-B7ORyOeG.js";import{G as a}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 y=[{key:"vendorCode",header:"Vendor Code",width:110},{key:"vendorName",header:"Vendor"},{key:"grnCount",header:"GRNs",align:"right"},{key:"distinctItemCount",header:"Items",align:"right"},{key:"totalQty",header:"Total Qty",align:"right",format:S},{key:"totalTax",header:"Tax",align:"right",format:i},{key:"totalValue",header:"Total Value",align:"right",format:i}],w=()=>{const[t,u]=l.useState(v()),[n,c]=l.useState(k()),{data:o,isFetching:d,refetch:h}=f({from:t,to:n}),s=(o==null?void 0:o.list)??[],g=s.reduce((r,p)=>r+(Number(p.totalValue)||0),0);return e.jsx(x,{title:"Vendor-wise Purchase",subtitle:`Aggregated from POSTED Goods Receipts. Total purchase value: ${i(g)}`,filters:e.jsxs(a,{container:!0,spacing:1.5,children:[e.jsx(a,{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(a,{item:!0,xs:6,sm:3,children:e.jsx(m,{label:"To",type:"date",size:"small",fullWidth:!0,InputLabelProps:{shrink:!0},value:n,onChange:r=>c(r.target.value)})})]}),columns:y,rows:s,isFetching:d,refetch:h,csvFilenameStem:"vendor-purchase"})};function S(t){return t==null?"0":Number(t).toLocaleString("en-IN",{minimumFractionDigits:0,maximumFractionDigits:3})}function i(t){return t==null?"0.00":Number(t).toLocaleString("en-IN",{minimumFractionDigits:2,maximumFractionDigits:2})}function k(){return new Date().toISOString().slice(0,10)}function v(){const t=new Date;return t.setDate(1),t.toISOString().slice(0,10)}export{w as default};
