import{k as p,u as b,b as e,C as x,B as i,s as d,t as v,j as l,A as y,c as h,S as N,w as T,x as S,y as n,z as r,F as R}from"./index-CYy8zBsj.js";import{P as C,S as g}from"./SectionCard-DbNZN4L9.js";import{S as B}from"./StatusPill-Bjc5_kt-.js";import{D}from"./DetailGrid-lF9FR2JC.js";import{b as E}from"./StockTransferReceivedNoteApi-DN807MqL.js";const k={POSTED:"success",CANCELLED:"error",DRAFT:"default"},_=()=>{var o;const{id:u}=p(),c=b(),s=Number(u),{data:a,isLoading:m}=E(s,{skip:!s});if(m)return e(i,{p:4,display:"flex",justifyContent:"center",children:e(x,{})});if(!a)return e(i,{p:4,children:e(d,{children:"Received note not found."})});const f=[{label:"Doc No",value:a.docNo??"—"},{label:"Transfer No",value:a.transferNo??"—"},{label:"From Branch",value:a.fromBranchName??`#${a.fromBranchId??"—"}`},{label:"To Branch",value:a.toBranchName??`#${a.toBranchId??"—"}`},{label:"Received Date",value:a.receivedDate?v(a.receivedDate):"—"},{label:"Received By",value:a.receivedBy??"—"},{label:"Status",value:((o=a.status)==null?void 0:o.replace(/_/g," "))??"—"},{label:"Remarks",value:a.remarks??"—"}];return l(i,{sx:{width:"100%",minHeight:"calc(100vh - 64px)",bgcolor:t=>t.palette.mode==="dark"?t.palette.background.default:"#F8FAFC",px:{xs:2,md:3},py:{xs:2,md:2.5}},children:[e(C,{breadcrumbs:[{label:"Inventory"},{label:"Stock Received Note",onClick:()=>c(h.STOCK_RECEIVED_NOTE)},{label:a.docNo??`#${a.id}`}],title:a.docNo??`Received Note #${a.id}`,subtitle:`Receipt against transfer ${a.transferNo??"—"}`,badge:a.status?e(B,{label:a.status.replace(/_/g," "),tone:k[a.status]??"default",size:"medium"}):null,actions:e(y,{btnType:"back",onClick:()=>c(h.STOCK_RECEIVED_NOTE),children:"Back"})}),l(N,{spacing:2,children:[e(g,{title:"Summary",children:e(D,{items:f,columns:2})}),e(g,{title:"Items",noPadding:!0,children:e(i,{sx:{overflowX:"auto"},children:l(T,{size:"small",children:[e(S,{children:l(n,{sx:{bgcolor:"grey.50"},children:[e(r,{sx:{fontWeight:600},children:"Product"}),e(r,{align:"right",sx:{fontWeight:600},children:"Transferred"}),e(r,{align:"right",sx:{fontWeight:600},children:"Received"}),e(r,{align:"right",sx:{fontWeight:600},children:"Accepted"}),e(r,{align:"right",sx:{fontWeight:600},children:"Damaged"}),e(r,{align:"right",sx:{fontWeight:600},children:"Short"}),e(r,{align:"right",sx:{fontWeight:600},children:"Excess"}),e(r,{sx:{fontWeight:600},children:"Reason"})]})}),l(R,{children:[(a.items??[]).map(t=>l(n,{hover:!0,children:[l(r,{children:[e(i,{sx:{fontWeight:500},children:t.productName??`#${t.productId}`}),e(i,{sx:{fontSize:11,color:"text.secondary"},children:t.productCode??""})]}),e(r,{align:"right",children:t.transferredQty??0}),e(r,{align:"right",children:t.receivedQty??0}),e(r,{align:"right",children:t.acceptedQty??0}),e(r,{align:"right",children:t.damagedQty??0}),e(r,{align:"right",children:t.shortQty??0}),e(r,{align:"right",children:t.excessQty??0}),e(r,{children:t.discrepancyReason??"—"})]},t.id)),(a.items??[]).length===0&&e(n,{children:e(r,{colSpan:8,align:"center",children:e(d,{variant:"body2",color:"text.secondary",sx:{py:2},children:"No items recorded."})})})]})]})})})]})]})};export{_ as default};
