import{d as G,z as H,a as L,eD as W,r as o,eE as n,j as t,T as b,M as v,B as h,a2 as J,R as z,eF as K,eG as Q}from"./index-6f149d0c.js";import{C as U}from"./index-123bf5f6.js";import{P as X}from"./index-2a0afaa0.js";import{v as w}from"./View-afd49d05.js";import{T as D}from"./Tooltip-0754c119.js";import{Z as S}from"./Zoom-0a60304c.js";import{P as ee}from"./Select-70a66099.js";import{C as g}from"./Chip-f8ae6358.js";import"./Grow-aea427ae.js";import"./componentStyles-d6393a0a.js";import"./TableRow-1e254c97.js";import"./TableContainer-98fd6e5d.js";import"./TableHead-483470b3.js";import"./TablePagination-40662a32.js";import"./KeyboardArrowRight-1f33e1ff.js";import"./LastPage-de948385.js";import"./Toolbar-7b4b233b.js";import"./MenuItem-8bc5d37f.js";import"./dividerClasses-aa25d579.js";import"./listItemTextClasses-6dace016.js";import"./listItemIconClasses-4d219f9a.js";import"./Add-ce44d30e.js";import"./Tabs-8b68d3cc.js";import"./index-e5978b8b.js";import"./Badge-806f3b3c.js";import"./yup-7ebcc99d.js";import"./index.esm-88773116.js";import"./Breadcrumbs-bd9f634d.js";import"./Link-ac51a1d2.js";import"./Divider-79e55221.js";import"./TextField-a5af71e6.js";import"./isMuiElement-36ccba67.js";import"./InputAdornment-ca5e29e7.js";import"./popper-f3391c26.js";function te(i,m){const s=m??"--";return i===1?t.jsx(g,{label:s,color:"warning",size:"small"}):i===2?t.jsx(g,{label:s,color:"info",size:"small"}):i===3?t.jsx(g,{label:s,color:"success",size:"small"}):t.jsx(g,{label:s,size:"small"})}function ke(){const i=G(),m=H(),{payments:{paymentsList:s,pageParams:a,paymentsCount:P,loading:A}}=L(e=>W(e)),[T,Y]=o.useState(null),[B,F]=o.useState(!1),[O,I]=o.useState(null),x=()=>{F(!1),Y(null),I(null)},N=e=>{e&&i(K({id:e,params:a})),x()};o.useEffect(()=>{i(n({...a,search:"",page:1,page_size:10}))},[]);const k=({search:e})=>{i(n({...a,search:e??"",page:1,page_size:10}))},E=(e,l)=>{i(n({...a,page:l+1}))},M=e=>{i(n({...a,page:1,page_size:parseInt(e.target.value)}))},R=e=>{i(n({...a,ordering:a.ordering===`-${e}`?e:`-${e}`,page:1}))},q=e=>{i(Q(e))},$=[{title:"S.No",width:60},{title:"Code",width:120,sortable:!0,field:"code"},{title:"PO / SO",width:120},{title:"Payment Term",width:160},{title:"Vendor",width:160},{title:"Amount",width:110},{title:"Paid Amount",width:120},{title:"Balance Amount",width:130},{title:"Due Date",width:110},{title:"Status",width:110},{title:"Created On",width:120,sortable:!0,field:"created_on"},{title:"Actions",width:80}];function V(e,l,f,y,_,C,j,r,p,c,d,u){return{index:e,code:l,poSo:f,paymentTerm:y,vendor:_,amount:C,paidAmount:j,balanceAmount:r,dueDate:p,status:c,createdOn:d,actions:u}}const Z=o.useMemo(()=>s==null?void 0:s.map((e,l)=>{var r,p,c,d,u;const f=(a.page-1)*a.page_size+(l+1),y=((r=e==null?void 0:e.purchaseorder)==null?void 0:r.code)??((p=e==null?void 0:e.serviceorder)==null?void 0:p.code)??"--",_=((c=e==null?void 0:e.po_payment_term)==null?void 0:c.payment_term)??((d=e==null?void 0:e.so_payment_term)==null?void 0:d.payment_term)??"--",C=t.jsx(D,{TransitionComponent:S,title:"Click to view details",children:t.jsx(b,{sx:{color:"primary.main",cursor:"pointer",fontWeight:500},onClick:()=>m(`/pages/sidemenu/payment_request/view/${e.id}`),children:(e==null?void 0:e.code)??(e==null?void 0:e.id)})}),j=t.jsx(h,{sx:{display:"flex",gap:1,alignItems:"center"},children:t.jsx(D,{TransitionComponent:S,title:"View",children:t.jsx(h,{sx:{cursor:"pointer",display:"flex",alignItems:"center"},onClick:()=>m(`/pages/sidemenu/payment_request/view/${e.id}`),children:t.jsx("img",{src:w,alt:"view",style:{width:18,height:18}})})})});return V(f,C,y,_,((u=e==null?void 0:e.vendor)==null?void 0:u.name)??"--",e!=null&&e.amount?Number(e.amount).toFixed(2):"--",e!=null&&e.paid_amount?Number(e.paid_amount).toFixed(2):"--",e!=null&&e.balance_amount?Number(e.balance_amount).toFixed(2):"--",e!=null&&e.due_date?v(e.due_date).format("DD-MM-YYYY"):"--",te(e==null?void 0:e.status,e==null?void 0:e.status_name),e!=null&&e.created_on?v(e.created_on).format("DD-MM-YYYY"):"--",j)}),[s,a]);return t.jsxs(h,{sx:{display:"grid",gap:.5,mt:-1.7},children:[t.jsx(X,{title:"Payment Requests",addButtonLabel:"",breadcrumbs:[],showAddButton:!1,applabel:"Payments",model:"payment",count:P,handleSearch:k,fetchapi:n,showFilterButton:!1,openFilter:q,pageParams:a,buttons:{list:!0,thumbnail:!1,grid:!1}}),t.jsx(J,{children:t.jsx(U,{showPagination:!0,columns:$,rows:Z??[],count:P,page:a.page,pageSize:a.page_size,loading:A,handleSort:R,handleChangePage:E,handleChangeRowsPerPage:M})}),t.jsx(ee,{open:B,anchorEl:T,onClose:x,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:t.jsxs(h,{sx:{p:2},children:[t.jsx(b,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure you want to delete this record?"}),t.jsx(z,{variant:"contained",color:"primary",onClick:()=>N(O),children:"Yes"}),t.jsx(z,{variant:"outlined",size:"small",onClick:x,sx:{ml:2},children:"No"})]})})]})}export{ke as default};
