import{M as x,r as i,b as t,j as s,B as m,T as b,be as I,bf as R,bg as A,Q as h,A as E,e as F,J as M,R as O,F as L,s as W}from"./index-BiWH3VAt.js";import{S as B}from"./StorageLocationPicker-D54jMOa2.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:g,error:z}]=w(),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: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(O,{children:[s(m,{display:"flex",gap:2,flexWrap:"wrap",alignItems:"flex-end",mb:2,children:[t(b,{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(I,{size:"small",sx:{width:180},children:[t(R,{children:"Movement Type"}),s(A,{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(E,{btnType:"search",onClick:y,children:"Search"})]}),t(F,{columns:S,rows:C,loading:g,rowCount:N,autoPagination:"server",handlePaginationChange:e=>{v(e.page),p(e.pageSize)}})]})})}export{K as default};
