import{K as x,r as i,b as t,j as s,B as m,T as I,aO as b,aP as A,aQ as E,a6 as h,A as R,e as O,U as F,ae as M,H as L,s as W}from"./index-CYy8zBsj.js";import{S as B}from"./StorageLocationPicker-80qSrw4b.js";const P=x.injectEndpoints({endpoints:r=>({getMovements:r.query({query:({batchId:d,locationId:a,type:c,page:o,size:u})=>{const n={page:o,size:u};return d&&(n.batchId=d),a&&(n.locationId=a),c&&(n.type=c),{url:"inventory-movements",method:"GET",params:n}}})})}),{useLazyGetMovementsQuery:U}=P,w=["IN","OUT","TRANSFER_OUT","TRANSFER_IN","BLOCK","UNBLOCK","ADJUSTMENT","SCRAP","WRITE_OFF"],D={IN:"success",TRANSFER_IN:"success",UNBLOCK:"success",OUT:"error",TRANSFER_OUT:"error",BLOCK:"warning",SCRAP:"error",WRITE_OFF:"error",ADJUSTMENT:"info"};function j(){const[r,d]=i.useState(""),[a,c]=i.useState(null),[o,u]=i.useState(""),[n,v]=i.useState(0),[f,p]=i.useState(20),[T,{data:l,isLoading:g,error:z}]=U(),y=()=>{T({page:n,size:f,...r?{batchId:Number(r)}:{},...a!=null&&a.id?{locationId:a.id}:{},...o?{type:o}:{}})},C=(l==null?void 0:l.data)??[],N=(l==null?void 0:l.totalCount)??0,S=[{field:"createdDate",headerName:"Date",flex:1,minWidth:160,valueFormatter:e=>e.value?M(e.value):""},{field:"movementType",headerName:"Type",flex:1,minWidth:130,renderCell:e=>t(L,{label:e.value,color:D[e.value]??"default",size:"small"})},{field:"deltaQty",headerName:"Delta Qty",flex:1,minWidth:110,renderCell:e=>s(W,{variant:"body2",color:Number(e.value)>=0?"success.main":"error.main",fontWeight:600,children:[Number(e.value)>=0?"+":"",e.value]})},{field:"unitCost",headerName:"Unit Cost",flex:1,minWidth:110,valueFormatter:e=>e.value!=null?`₹${e.value}`:"-"},{field:"totalCost",headerName:"Total Cost",flex:1,minWidth:110,valueFormatter:e=>e.value!=null?`₹${e.value}`:"-"},{field:"referenceType",headerName:"Ref. Type",flex:1,minWidth:120},{field:"referenceId",headerName:"Ref. ID",flex:1,minWidth:90},{field:"createdBy",headerName:"Created By",flex:1,minWidth:130}];return t(m,{p:2,children:s(F,{children:[s(m,{display:"flex",gap:2,flexWrap:"wrap",alignItems:"flex-end",mb:2,children:[t(I,{label:"Batch ID",size:"small",type:"number",value:r,onChange:e=>d(e.target.value),sx:{width:150}}),t(m,{sx:{width:250},children:t(B,{value:a,onChange:c,label:"Location"})}),s(b,{size:"small",sx:{width:180},children:[t(A,{children:"Movement Type"}),s(E,{label:"Movement Type",value:o,onChange:e=>u(e.target.value),children:[t(h,{value:"",children:t("em",{children:"All"})}),w.map(e=>t(h,{value:e,children:e},e))]})]}),t(R,{btnType:"search",onClick:y,children:"Search"})]}),t(O,{columns:S,rows:C,loading:g,rowCount:N,autoPagination:"server",handlePaginationChange:e=>{v(e.page),p(e.pageSize)}})]})})}export{j as default};
