import{k as f,u as b,b as e,C as v,B as i,q as d,t as x,j as l,A as y,c as h,S as N,v as T,w as S,x as n,y as r,z as R}from"./index-DlNZgIG9.js";import{P as C,S as g}from"./SectionCard-B9NQMt5U.js";import{S as B}from"./StatusPill-D_6cE8ZH.js";import{D}from"./DetailGrid-DZHO-YE5.js";import{b as E}from"./StockTransferReceivedNoteApi-D-TjFQqv.js";import"./Breadcrumbs-C2b52YrP.js";const k={POSTED:"success",CANCELLED:"error",DRAFT:"default"},O=()=>{var o;const{id:u}=f(),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(v,{})});if(!a)return e(i,{p:4,children:e(d,{children:"Received note not found."})});const p=[{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?x(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:p,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{O as default};
