import{_ as Y}from"./Imprimer-Bot4QNbk.js";import{u as Z,s as l,a as V,S as P,g as ee,j as te,h as D}from"./index-BSaHX2oa.js";import{r as o,f as ne,o as w,c as se,b as n,a as r,q as $,z as le,j as ae,av as oe,i as k,d as N,aP as re,M as ie,F as ue,e as ce,$ as E}from"./vendor-BDR7yMJi.js";import{_ as de}from"./ComboDynamique-DbhbUtR4.js";import{_ as me}from"./FavorisSwitch-DFHH_fud.js";import{_ as pe}from"./DataGrid-DbeHIyBR.js";import"./ReportViewer-Cmd4kpyP.js";import"./EnvoieDocumentsMail-P3u1QAl1.js";import"./useAgGridConfig-DxO2r97K.js";const fe={class:"flex min-w-full flex-col lg:flex-row lg:items-center lg:justify-between gap-2 p-1"},ve={class:"btns flex items-center gap-2"},ge={class:"flex items-center p-2"},be={class:"grid grid-cols-1 md:grid-cols-3 lg:grid-cols-6 gap-2 mb-2"},xe={style:{height:"calc(100vh - 260px)"}},ke={__name:"ListeDesPaiementsClientsParDocument",props:{masquerFermer:{type:Boolean,default:!1}},setup(M){const{showInfo:y,showError:_,showWarn:R}=Z(),d=o(""),m=o(l.state.dossier.dated),p=o(l.state.dossier.datef),f=o(l.state.dossier.dated),v=o(l.state.dossier.datef),g=o(""),i=o([]),u=o(!1),h=o(),b=o(),L=o(),A=o([]),F=ce(()=>["montantGlobal","montant"]),G=({event:t,ndoc:e})=>{},S=({selectedRows:t})=>{A.value=t},z=t=>{L.value=t.api},U=()=>t=>{if(!t.value)return"";const e=q(t.value),a={success:"bg-green-100 text-green-800",info:"bg-blue-100 text-blue-800",warning:"bg-orange-100 text-orange-800",secondary:"bg-gray-100 text-gray-800",contrast:"bg-purple-100 text-purple-800"};return`<span class="inline-block px-2 py-1 rounded text-xs font-medium ${a[e]||a.secondary}">${t.value}</span>`},B=()=>t=>{if(t.value==null||t.value===""||t.value==="null")return"";const e=parseFloat(t.value);if(isNaN(e))return"";const a=D(e);return t.node&&t.node?.rowPinned?`<span style="font-weight: 600;">${a}</span>`:`<span class="font-bold text-blue-600">${a}</span>`},I=()=>t=>{if(t.value==null||t.value===""||t.value==="null")return"";const e=parseFloat(t.value);if(isNaN(e))return"";const a=D(e);return t.node&&t.node?.rowPinned?`<span style="font-weight: 600;">${a}</span>`:`<span class="font-bold text-green-600">${a}</span>`},T=()=>t=>t.value?`<span class="text-sm ${j(t.value)?"text-red-600 font-medium":"text-gray-700"}">${te(t.value)}</span>`:"",q=t=>({Espèces:"success",Chèque:"info",Virement:"warning","Carte bancaire":"secondary",Prélèvement:"contrast"})[t]||"secondary",j=t=>t?E(t).isBefore(E(),"day"):!1;ne(async()=>{await O(),await x()});const O=async()=>{try{const e=(await V.post(`${l.lienApi}/verifierDroit/${l.state.dbCommun6}`,{id_utilisateur:l.userId,id_page:401,mail:l.state.userCloud.mail})).data;e&&Object.keys(e).length>0&&(e.lecture||(R("Vous n'avez pas le droit, veuillez consulter l'administrateur"),P("ListeDesPaiementsClientsParDocument")))}catch(t){_(`Une erreur s'est produite lors de la vérification des droits.
${t}`)}},x=async()=>{l.state.afficher_in_progress=!0;try{const t=await V.post(`${l.lienApi}/ListeDesPaiementsClientParDocument/${l.db}`,{dateDu:m.value,dateAu:p.value,dateEchDu:f.value||"",dateEchAu:v.value||"",code_client:g.value||"",rechercheString:d.value},{headers:{"Content-Type":"application/json"}});i.value=t.data}catch(t){const e=t.response?.data?.message||t.message;_(`Une erreur est survenue : ${e}`)}finally{l.state.afficher_in_progress=!1}},K=()=>{u.value=!0},W=()=>{if(!b.value){y("Grille non initialisée");return}if(i.value.length===0){y("Aucune donnée à exporter");return}const e=new Date().toISOString().slice(0,19).replace(/[-:]/g,"").replace("T","_");b.value.exportToExcel(`Liste des paiements clients par document_${l.state.enreg_societe.Nom}_${e}.xlsx`)};return(t,e)=>{const a=le,C=me,H=oe,J=de,Q=ie,c=ee,X=Y;return w(),se(ue,null,[n("div",fe,[n("div",ve,[r(a,{icon:"pi pi-search",label:"Rechercher",onClick:x,text:"",loading:$(l).state.afficher_in_progress},null,8,["loading"]),r(a,{icon:"pi pi-cog",label:"Actions",text:"",onClick:e[0]||(e[0]=s=>h.value?.toggle(s))}),r(H,{ref_key:"actionsMenu",ref:h,model:[{label:"Exporter vers Excel",icon:"pi pi-file-excel",command:()=>W()},{label:"Imprimer",icon:"pi pi-print",command:()=>K()},{label:"Favoris",icon:"pi pi-star",template:"favorisTemplate"}],popup:!0},{favorisTemplate:ae(()=>[n("div",ge,[r(C,{fen:"ListeDesPaiementsClientsParDocument",text:"Paiements Clients Par Document"}),e[10]||(e[10]=n("span",{class:"font-semibold ml-2 text-primary"},"Favoris",-1))])]),_:1},8,["model"]),M.masquerFermer?N("",!0):(w(),k(a,{key:0,icon:"pi pi-times",label:"Fermer",text:"",onClick:e[1]||(e[1]=s=>$(P)("ListeDesPaiementsClientsParDocument"))}))])]),n("div",be,[n("div",null,[e[11]||(e[11]=n("label",{class:"block text-sm"},"Client",-1)),r(J,{modelValue:g.value,"onUpdate:modelValue":e[2]||(e[2]=s=>g.value=s),placeholder:"Client",table:"client",class:"w-full"},null,8,["modelValue"])]),n("div",null,[e[12]||(e[12]=n("label",{class:"block text-sm"},"Recherche",-1)),r(Q,{size:"small",modelValue:d.value,"onUpdate:modelValue":e[3]||(e[3]=s=>d.value=s),placeholder:"Rechercher...",class:"w-full",onKeyup:e[4]||(e[4]=re(s=>x(),["enter"]))},null,8,["modelValue"])]),n("div",null,[e[13]||(e[13]=n("label",{class:"block text-sm"},"Paiement du",-1)),r(c,{size:"small",modelValue:m.value,"onUpdate:modelValue":e[5]||(e[5]=s=>m.value=s),placeholder:"Date debut","input-class":"w-full"},null,8,["modelValue"])]),n("div",null,[e[14]||(e[14]=n("label",{class:"block text-sm"},"Paiement au",-1)),r(c,{size:"small",modelValue:p.value,"onUpdate:modelValue":e[6]||(e[6]=s=>p.value=s),placeholder:"Date fin","input-class":"w-full"},null,8,["modelValue"])]),n("div",null,[e[15]||(e[15]=n("label",{class:"block text-sm"},"Echeance du",-1)),r(c,{size:"small",modelValue:f.value,"onUpdate:modelValue":e[7]||(e[7]=s=>f.value=s),placeholder:"Echeance debut","input-class":"w-full"},null,8,["modelValue"])]),n("div",null,[e[16]||(e[16]=n("label",{class:"block text-sm"},"Echeance au",-1)),r(c,{size:"small",modelValue:v.value,"onUpdate:modelValue":e[8]||(e[8]=s=>v.value=s),placeholder:"Echeance fin","input-class":"w-full"},null,8,["modelValue"])])]),e[17]||(e[17]=n("div",{class:"h-2"},null,-1)),n("div",xe,[r(pe,{ref_key:"dataGrid",ref:b,"excel-file-name":"Liste des paiements clients par document","excel-sheet-name":"Liste des paiements clients par document","row-data":i.value,"document-number-fields":["ndoc"],"excluded-columns":["ndoc","npaiementc"],"column-widths":{date:120,code_client:120,nom:300,ref_paiement:150,Mode:130,montantGlobal:130,montant:120,Nremise:110,ncontrole_b:110,Nbl:100,Nfacturec:110,Nbretourc:110,nbc:120,Navoirc:100,date_ech:120},"date-only":["date_ech"],"custom-renderers":{Mode:U(),montantGlobal:B(),montant:I(),date_ech:T()},"enable-totals":!0,"numeric-columns":F.value,"totals-columns":["montantGlobal","montant"],onRowClicked:G,onSelectionChanged:S,onGridReady:z},null,8,["row-data","custom-renderers","numeric-columns"])]),u.value?(w(),k(X,{key:0,show:u.value,onClose:e[9]||(e[9]=s=>u.value=!1),data:i.value,modeList:!0,RapportName:"/classique/commercial/ListeDesPaiementsClientsParDocument"},null,8,["show","data"])):N("",!0)],64)}}};export{ke as default};
