import{r as o,f as q,o as y,c as O,b as n,a,q as b,z as W,av as K,i as Q,d as H,ax as J,F as X,e as u}from"./vendor-0kGcmQpG.js";import{u as Y,s,a as h,S as k,f as V,g as Z,h as ee}from"./index-Bn9WoKhP.js";import{_ as te}from"./FavorisSwitch-DD6nTfzi.js";import{_ as ne}from"./DataGrid-tb6QVwpZ.js";import"./useAgGridConfig-DjXMc6wb.js";const se={class:"flex min-w-full flex-col lg:flex-row lg:items-center lg:justify-between gap-2 p-1"},le={class:"btns flex items-center gap-2"},oe={class:"flex items-center gap-3 whitespace-nowrap ml-auto"},ae={class:"flex flex-row gap-3 px-4 items-end"},re={class:"flex flex-col"},ie={class:"flex flex-col"},ue={class:"flex flex-col"},ce={style:{height:"calc(100vh - 220px)"}},ge={__name:"CumulFacturesNonSoldeeParAnnee",props:["masquerFermer"],setup($){const{showInfo:v,showError:g,showWarn:S}=Y(),A=$,c=o(),N=o(),F=o([]),_=o(),i=o([]),d=o([]),m=o(s.state.dossier.dated),p=o(s.state.dossier.datef),f=o(""),D=[{Id:"",Libelle:"Tous les clients"},{Id:"sommeil",Libelle:"Clients en sommeil"},{Id:"actif",Libelle:"Clients actifs"}],x=u(()=>[...d.value,"total_general"]),I=u(()=>x.value),R=u(()=>{const t={Code:120,nom:250,total_general:140};return d.value.forEach(e=>{t[e]=130}),t}),T=u(()=>({total_general:E()})),L=({event:t,ndoc:e})=>{},P=({selectedRows:t})=>{F.value=t},z=t=>{N.value=t.api},E=()=>t=>{if(t.value==null||t.value===""||t.value==="null")return"";const e=parseFloat(t.value);if(isNaN(e))return"";const r=ee(e);return t.node&&t.node.rowPinned?`<span style="font-weight: 600;">${r}</span>`:`<span class="font-bold text-gray-800">${r}</span>`};q(async()=>{await G(),await w()});const G=async()=>{try{const e=(await h.post(`${s.lienApi}/verifierDroit/${s.state.dbCommun6}`,{id_utilisateur:s.userId,id_page:810,mail:s.state.userCloud.mail})).data;e&&Object.keys(e).length>0&&(e.lecture||(S("Vous n'avez pas le droit, veuillez consulter l'administrateur"),k("CumulFacturesNonSoldeeParAnnee")))}catch(t){const e=t.response?.data?.message||t.message;g(`Une erreur est survenue : ${e}`)}},w=async()=>{s.state.afficher_in_progress=!0;try{const t=await h.post(`${s.lienApi}/CumulFacturesNonSoldeeParAnnee/${s.db}`,{dateDu:V(m.value),dateAu:V(p.value),typeClient:f.value});i.value=t.data,d.value=i.value.length>0?Object.keys(i.value[0]).filter(e=>!["nom","Code","total_general"].includes(e)):[]}catch(t){g(`Une erreur est survenue lors de l'affichage des factures non soldées
 ${t}`)}finally{s.state.afficher_in_progress=!1}},M=()=>{if(!c.value){v("Grille non initialisée");return}if(i.value.length===0){v("Aucune donnée à exporter");return}const e=new Date().toISOString().slice(0,19).replace(/[-:]/g,"").replace("T","_");c.value.exportToExcel(`Cumul des factures non soldée par annee_${s.state.enreg_societe.Nom}_${e}.xlsx`)};return(t,e)=>{const r=W,B=K,U=te,C=Z,j=J;return y(),O(X,null,[n("div",se,[n("div",le,[a(r,{icon:"pi pi-chart-bar",label:"Analyser",onClick:e[0]||(e[0]=l=>w()),text:"",loading:b(s).state.afficher_in_progress},null,8,["loading"]),a(r,{icon:"pi pi-cog",label:"Actions",text:"",onClick:e[1]||(e[1]=l=>_.value.toggle(l))}),a(B,{ref_key:"actionsMenu",ref:_,model:[{label:"Exporter vers Excel",icon:"pi pi-file-excel",command:()=>M()}],popup:!0},null,8,["model"]),A.masquerFermer?H("",!0):(y(),Q(r,{key:0,icon:"pi pi-times",label:"Fermer",text:"",onClick:e[2]||(e[2]=l=>b(k)("CumulFacturesNonSoldeeParAnnee"))}))]),n("div",oe,[a(U,{fen:"CumulFacturesNonSoldeeParAnnee",text:"Cumul factures non soldées par année"})])]),n("div",ae,[n("div",re,[e[6]||(e[6]=n("label",{class:"text-sm"},"Date de debut",-1)),a(C,{size:"small",modelValue:m.value,"onUpdate:modelValue":e[3]||(e[3]=l=>m.value=l),placeholder:"Date de debut","input-class":"w-64"},null,8,["modelValue"])]),n("div",ie,[e[7]||(e[7]=n("label",{class:"text-sm"},"Date de fin",-1)),a(C,{size:"small",modelValue:p.value,"onUpdate:modelValue":e[4]||(e[4]=l=>p.value=l),placeholder:"Date de fin","input-class":"w-64"},null,8,["modelValue"])]),n("div",ue,[e[8]||(e[8]=n("label",{class:"text-sm"},"Type de client",-1)),a(j,{size:"small",modelValue:f.value,"onUpdate:modelValue":e[5]||(e[5]=l=>f.value=l),options:D,optionLabel:"Libelle",optionValue:"Id",placeholder:"Sélectionner le type",class:"w-48"},null,8,["modelValue"])])]),e[9]||(e[9]=n("div",{class:"h-2"},null,-1)),n("div",ce,[a(ne,{ref_key:"dataGrid",ref:c,"excel-file-name":"Cumul factures non soldee par annee","excel-sheet-name":"Cumul factures non soldee par annee","row-data":i.value,"document-number-fields":["Code"],"excluded-columns":["ndoc"],"column-widths":R.value,"custom-renderers":T.value,"enable-totals":!0,"numeric-columns":x.value,"totals-columns":I.value,onRowClicked:L,onSelectionChanged:P,onGridReady:z},null,8,["row-data","column-widths","custom-renderers","numeric-columns","totals-columns"])])],64)}}};export{ge as default};
