import{b as oe,B as ae,y as ne,v as ie}from"./primevue-CfIk0_DY.js";import{C as re}from"./ComboDynamique-BzWI4ISP.js";import{u as ue,s as a,b as z,S as h,f as P,j as de,o as ce}from"./index-BxIwIJfy.js";import{_ as me}from"./FavorisSwitch-BFqqA1tj.js";import{D as pe}from"./DataGrid-CoMfrBJA.js";import{a as n,o as fe,b as x,c as C,d as t,v as o,a7 as _,k as ve,p as k,l as be,y as i}from"./vue-core-Di3IuVqe.js";import"./cjs-helpers-psZwOBky.js";import"./vue-cal-DKMVGERa.js";import"./moment-BeHQNF8T.js";import"./useAgGridConfig-Dp3DkgaV.js";const ge={class:"page-wrapper"},xe={class:"flex min-w-full flex-col lg:flex-row lg:items-center lg:justify-between gap-2 p-1"},we={class:"btns flex items-center gap-2"},ye={class:"flex items-center gap-3 whitespace-nowrap ml-auto"},Ve={class:"hidden lg:flex flex-row gap-3 px-4 items-end"},Ce={class:"flex flex-col"},_e={class:"flex flex-col"},ke={class:"flex flex-col"},Ae={class:"flex flex-col"},Se={key:0,class:"flex flex-col"},De={class:"flex flex-col",style:{gap:"16px"}},$e={key:0},Fe={class:"grille-container"},Ge={__name:"CumulFacturesNonSoldeeParAnnee",props:["masquerFermer"],setup(R){const{showInfo:A,showError:S,showWarn:M}=ue(),G=R,w=n(),B=n(),E=n([]),D=n(),d=n([]),y=n([]),v=n(!1),q=()=>{v.value=!1,V()},c=n(a.state.dossier.dated),m=n(a.state.dossier.datef),p=n(""),f=n(""),u=n(0),j=i(()=>!!a.state.enreg_option_comm?.numerotation_par_agence),$=i(()=>a.state.userCommun6?.id_agence||0),O=i(()=>!!a.state.userCommun6?.Access_Agence),F=i(()=>$.value>0&&!O.value),L=i(()=>j.value),I=[{Id:"",Libelle:"Tous les clients"},{Id:"sommeil",Libelle:"Clients en sommeil"},{Id:"actif",Libelle:"Clients actifs"}],N=[{Id:"",Libelle:"Toutes les séries"},{Id:"1",Libelle:"Série 1"},{Id:"2",Libelle:"Série 2"}],T=i(()=>[...y.value,"total_general"]),W=i(()=>T.value),K=i(()=>{const s={Code:120,nom:250,total_general:140};return y.value.forEach(e=>{s[e]=130}),s}),Q=i(()=>({total_general:Y()})),H=({event:s,ndoc:e})=>{},J=({selectedRows:s})=>{E.value=s},X=s=>{B.value=s.api},Y=()=>s=>{if(s.value==null||s.value===""||s.value==="null")return"";const e=parseFloat(s.value);if(isNaN(e))return"";const r=ce(e);return s.node&&s.node?.rowPinned?`<span style="font-weight: 600;">${r}</span>`:`<span class="font-bold text-gray-800">${r}</span>`};fe(async()=>{await Z(),u.value=$.value,await V()});const Z=async()=>{try{const e=(await z.post(`${a.lienApi}/verifierDroit/${a.state.dbCommun6}`,{id_utilisateur:a.userId,id_page:810,mail:a.state.userCloud.mail})).data;e&&Object.keys(e).length>0&&(e.lecture||(M("Vous n'avez pas le droit, veuillez consulter l'administrateur"),h("CumulFacturesNonSoldeeParAnnee")))}catch(s){const e=s.response?.data?.message||s.message;S(`Une erreur est survenue : ${e}`)}},V=async()=>{a.state.afficher_in_progress=!0;try{const s=await z.post(`${a.lienApi}/CumulFacturesNonSoldeeParAnnee/${a.db}`,{dateDu:P(c.value),dateAu:P(m.value),typeClient:p.value,serie:f.value,id_agence:u.value});d.value=s.data,y.value=d.value.length>0?Object.keys(d.value[0]).filter(e=>!["nom","Code","total_general"].includes(e)):[]}catch(s){S(`Une erreur est survenue lors de l'affichage des factures non soldées
 ${s}`)}finally{a.state.afficher_in_progress=!1}},ee=()=>{if(!w.value){A("Grille non initialisée");return}if(d.value.length===0){A("Aucune donnée à exporter");return}const e=new Date().toISOString().slice(0,19).replace(/[-:]/g,"").replace("T","_");w.value.exportToExcel(`Cumul des factures non soldée par annee_${a.state.enreg_societe.Nom}_${e}.xlsx`)};return(s,e)=>{const r=oe,le=ae,te=me,b=de,g=ne,U=re,se=ie;return x(),C("div",ge,[t("div",xe,[t("div",we,[o(r,{icon:"pi pi-chart-bar",label:"Analyser",onClick:e[0]||(e[0]=l=>V()),text:"",loading:_(a).state.afficher_in_progress},null,8,["loading"]),o(r,{icon:"pi pi-cog",label:"Actions",text:"",onClick:e[1]||(e[1]=l=>D.value.toggle(l))}),o(le,{ref_key:"actionsMenu",ref:D,model:[{label:"Exporter vers Excel",icon:"pi pi-file-excel",command:()=>ee()}],popup:!0},null,8,["model"]),G.masquerFermer?k("",!0):(x(),ve(r,{key:0,icon:"pi pi-times",label:"Fermer",text:"",onClick:e[2]||(e[2]=l=>_(h)("CumulFacturesNonSoldeeParAnnee"))}))]),t("div",ye,[o(r,{icon:"pi pi-filter",text:"",class:"p-button lg:!hidden",onClick:e[3]||(e[3]=l=>v.value=!0),"aria-label":"Filtres"}),o(te,{fen:"CumulFacturesNonSoldeeParAnnee",text:"Cumul factures non soldées par année"})])]),t("div",Ve,[t("div",Ce,[e[16]||(e[16]=t("label",{class:"text-sm"},"Date de debut",-1)),o(b,{size:"small",modelValue:c.value,"onUpdate:modelValue":e[4]||(e[4]=l=>c.value=l),placeholder:"Date de debut","input-class":"w-64"},null,8,["modelValue"])]),t("div",_e,[e[17]||(e[17]=t("label",{class:"text-sm"},"Date de fin",-1)),o(b,{size:"small",modelValue:m.value,"onUpdate:modelValue":e[5]||(e[5]=l=>m.value=l),placeholder:"Date de fin","input-class":"w-64"},null,8,["modelValue"])]),t("div",ke,[e[18]||(e[18]=t("label",{class:"text-sm"},"Type de client",-1)),o(g,{size:"small",modelValue:p.value,"onUpdate:modelValue":e[6]||(e[6]=l=>p.value=l),options:I,optionLabel:"Libelle",optionValue:"Id",placeholder:"Sélectionner le type",class:"w-48"},null,8,["modelValue"])]),t("div",Ae,[e[19]||(e[19]=t("label",{class:"text-sm"},"Série facture",-1)),o(g,{size:"small",modelValue:f.value,"onUpdate:modelValue":e[7]||(e[7]=l=>f.value=l),options:N,optionLabel:"Libelle",optionValue:"Id",placeholder:"Sélectionner la série",class:"w-48"},null,8,["modelValue"])]),L.value?(x(),C("div",Se,[e[20]||(e[20]=t("label",{class:"text-sm"},"Agence",-1)),o(U,{modelValue:u.value,"onUpdate:modelValue":e[8]||(e[8]=l=>u.value=l),placeholder:"Toutes les agences",table:"agence",size:"small",disabled:F.value,class:"w-48"},null,8,["modelValue","disabled"])])):k("",!0)]),o(se,{visible:v.value,"onUpdate:visible":e[15]||(e[15]=l=>v.value=l),position:"right",header:"Filtres",style:{width:"90%","max-width":"360px"}},{default:be(()=>[t("div",De,[t("div",null,[e[21]||(e[21]=t("label",{class:"block",style:{"margin-bottom":"4px"}},"Date de debut",-1)),o(b,{size:"small",modelValue:c.value,"onUpdate:modelValue":e[9]||(e[9]=l=>c.value=l),placeholder:"Date de debut","input-class":"w-full"},null,8,["modelValue"])]),t("div",null,[e[22]||(e[22]=t("label",{class:"block",style:{"margin-bottom":"4px"}},"Date de fin",-1)),o(b,{size:"small",modelValue:m.value,"onUpdate:modelValue":e[10]||(e[10]=l=>m.value=l),placeholder:"Date de fin","input-class":"w-full"},null,8,["modelValue"])]),t("div",null,[e[23]||(e[23]=t("label",{class:"block",style:{"margin-bottom":"4px"}},"Type de client",-1)),o(g,{size:"small",modelValue:p.value,"onUpdate:modelValue":e[11]||(e[11]=l=>p.value=l),options:I,optionLabel:"Libelle",optionValue:"Id",placeholder:"Sélectionner le type",class:"w-full"},null,8,["modelValue"])]),t("div",null,[e[24]||(e[24]=t("label",{class:"block",style:{"margin-bottom":"4px"}},"Série facture",-1)),o(g,{size:"small",modelValue:f.value,"onUpdate:modelValue":e[12]||(e[12]=l=>f.value=l),options:N,optionLabel:"Libelle",optionValue:"Id",placeholder:"Sélectionner la série",class:"w-full"},null,8,["modelValue"])]),L.value?(x(),C("div",$e,[e[25]||(e[25]=t("label",{class:"block",style:{"margin-bottom":"4px"}},"Agence",-1)),o(U,{modelValue:u.value,"onUpdate:modelValue":e[13]||(e[13]=l=>u.value=l),placeholder:"Toutes les agences",table:"agence",class:"w-full",size:"small",disabled:F.value},null,8,["modelValue","disabled"])])):k("",!0),o(r,{icon:"pi pi-chart-bar",label:"Analyser",onClick:e[14]||(e[14]=l=>q()),loading:_(a).state.afficher_in_progress},null,8,["loading"])])]),_:1},8,["visible"]),e[26]||(e[26]=t("div",{class:"h-2"},null,-1)),t("div",Fe,[o(pe,{ref_key:"dataGrid",ref:w,"excel-file-name":"Cumul factures non soldee par annee","excel-sheet-name":"Cumul factures non soldee par annee","row-data":d.value,"document-number-fields":["Code"],"excluded-columns":["ndoc"],"column-widths":K.value,"custom-renderers":Q.value,"enable-totals":!0,"numeric-columns":T.value,"totals-columns":W.value,onRowClicked:H,onSelectionChanged:J,onGridReady:X},null,8,["row-data","column-widths","custom-renderers","numeric-columns","totals-columns"])])])}}};export{Ge as default};
