import{r as l,j as t,e as g,T as u}from"./index-B1H8BCL7.js";import{m as y}from"./stockApi-D1nxeMJU.js";import{R as p}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 h=[{key:"itemCode",header:"Item Code",width:110},{key:"itemName",header:"Item"},{key:"availableQty",header:"On Hand",align:"right",format:r},{key:"reorderLevel",header:"Reorder Lvl",align:"right",format:r},{key:"averageDailyConsumption",header:"Daily Avg",align:"right",format:r},{key:"vendorLeadTimeDays",header:"Lead (d)",align:"right"},{key:"maximumStockLevel",header:"Max Lvl",align:"right",format:r},{key:"suggestedOrderQty",header:"Suggested",align:"right",format:e=>r(e)},{key:"defaultVendorId",header:"Vendor #",width:90}],w=()=>{const[e,o]=l.useState(30),{data:i,isFetching:s,refetch:m}=y({daysHistory:e}),d=(i==null?void 0:i.list)??[];return t.jsx(p,{title:"Reorder Suggestions",subtitle:"Items at or below reorder level. Suggested qty = max(reorder gap, daily-avg × lead time × 1.5 safety, max-stock gap).",filters:t.jsxs(a,{container:!0,spacing:1.5,children:[t.jsx(a,{item:!0,xs:6,sm:3,children:t.jsx(g,{label:"Consumption window (days)",type:"number",size:"small",fullWidth:!0,value:e,onChange:n=>o(Number(n.target.value)||30),inputProps:{min:1,max:365}})}),t.jsx(a,{item:!0,xs:12,sm:9,sx:{display:"flex",alignItems:"center"},children:t.jsxs(u,{sx:{fontSize:"0.72rem",color:"#94a3b8"},children:["Daily-avg is computed from stock_ledger.out_qty over the last ",e," days. Vendor lead-time defaults to 7 if no default vendor configured."]})})]}),columns:h,rows:d,isFetching:s,refetch:m,csvFilenameStem:"reorder-suggestions"})};function r(e){return e==null?"0":Number(e).toLocaleString("en-IN",{minimumFractionDigits:0,maximumFractionDigits:3})}export{w as default};
