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-aa25c5ff.js";import{C as U}from"./index-06082cde.js";import{P as X}from"./index-ea190582.js";import{v as w}from"./View-afd49d05.js";import{T as D}from"./Tooltip-c7f6fe40.js";import{Z as S}from"./Zoom-01fed3dd.js";import{P as ee}from"./Select-b8388c2f.js";import{C as g}from"./Chip-844542f9.js";import"./Grow-53c7e965.js";import"./componentStyles-e32842f3.js";import"./TableRow-ee82d902.js";import"./TableContainer-150455ba.js";import"./TableHead-7918647e.js";import"./TablePagination-7f533723.js";import"./KeyboardArrowRight-207c2b3b.js";import"./LastPage-cc741249.js";import"./Toolbar-aae1a453.js";import"./MenuItem-6f39aa2e.js";import"./dividerClasses-ce522944.js";import"./listItemTextClasses-88140258.js";import"./listItemIconClasses-31a870c1.js";import"./Add-dbe1ab7b.js";import"./Tabs-53ac51f5.js";import"./index-e5978b8b.js";import"./Badge-9e87965d.js";import"./yup-72cc4918.js";import"./index.esm-a7f661dc.js";import"./Breadcrumbs-ac850034.js";import"./Link-6a2f86f0.js";import"./Divider-52e89c7e.js";import"./TextField-55b66d20.js";import"./isMuiElement-1b254892.js";import"./InputAdornment-1e7eea92.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};
