import{l as n,m as o,n as i,p as c,t as g,q as p}from"./index-Cc987VYg.js";const s={getAgingReport:async e=>{const{data:t}=await n.get(o.AP_AGING,{params:e});return t.data},getVendorAgingDetail:async(e,t)=>{const{data:a}=await n.get(`${o.AP_AGING}${e}/`,{params:t});return a.data},exportAgingReport:async(e,t)=>{const{data:a}=await n.get(`${o.AP_AGING}/export/`,{params:{...t,format:e},responseType:"blob"});return a}},d=e=>i({queryKey:["apAging",JSON.stringify(e)],queryFn:()=>s.getAgingReport(e),staleTime:60*1e3}),A=(e,t)=>i({queryKey:["apAging","vendor",e,JSON.stringify(t)],queryFn:()=>s.getVendorAgingDetail(e,t),enabled:!!e,staleTime:60*1e3}),y=()=>c({mutationFn:({format:e,filters:t})=>s.exportAgingReport(e,t),onSuccess:(e,t)=>{const a=window.URL.createObjectURL(e),r=document.createElement("a");r.href=a,r.download=`ap-aging-report.${t.format}`,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.URL.revokeObjectURL(a),g.success("Report exported successfully")},onError:e=>{g.error(p(e))}});export{d as a,y as b,s as c,A as u};
