import{L as x,r as i,b as t,j as s,B as m,T as I,ax as b,bI as E,ay as R,R as h,A,e as F,H as L,Q as M,E as O,q as W}from"./index-ktJf6c6X.js";import{S as B}from"./StorageLocationPicker-vbXQqHIq.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:w}=P,D=["IN","OUT","TRANSFER_OUT","TRANSFER_IN","BLOCK","UNBLOCK","ADJUSTMENT","SCRAP","WRITE_OFF"],U={IN:"success",TRANSFER_IN:"success",UNBLOCK:"success",OUT:"error",TRANSFER_OUT:"error",BLOCK:"warning",SCRAP:"error",WRITE_OFF:"error",ADJUSTMENT:"info"};function K(){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:y,error:z}]=w(),g=()=>{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?L(e.value):""},{field:"movementType",headerName:"Type",flex:1,minWidth:130,renderCell:e=>t(O,{label:e.value,color:U[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(M,{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(E,{children:"Movement Type"}),s(R,{label:"Movement Type",value:o,onChange:e=>u(e.target.value),children:[t(h,{value:"",children:t("em",{children:"All"})}),D.map(e=>t(h,{value:e,children:e},e))]})]}),t(A,{btnType:"search",onClick:g,children:"Search"})]}),t(F,{columns:S,rows:C,loading:y,rowCount:N,autoPagination:"server",handlePaginationChange:e=>{v(e.page),p(e.pageSize)}})]})})}export{K as default};
