import{_ as R}from"./Imprimer-Bot4QNbk.js";import{_ as V}from"./ComboDynamique-DbhbUtR4.js";import{f as I,o as b,c as N,b as a,a as n,z as M,q as g,av as B,i as F,d as G,F as S,r as t}from"./vendor-BDR7yMJi.js";import{u as T,s,a as j,S as L}from"./index-BSaHX2oa.js";import{_ as q}from"./DataGrid-DbeHIyBR.js";import"./ReportViewer-Cmd4kpyP.js";import"./EnvoieDocumentsMail-P3u1QAl1.js";import"./useAgGridConfig-DxO2r97K.js";const P={class:"flex flex-row justify-start gap-3"},U={class:"flex flex-col gap-4"},z={class:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-8 gap-4 mx-3"},O={class:"field"},H={class:"field"},K={style:{height:"calc(100vh - 200px)"}},le={__name:"JournauxComptables",setup(Q){const{showError:w,showInfo:d}=T(),v=t(),C=t(),p=t(),i=t(!1),h=[{label:"Imprimer",icon:"pi pi-print",command:()=>$()},{label:"Exporter vers Excel",icon:"pi pi-file-excel",command:()=>D()}],u=t(""),c=t(""),m=t(""),r=t([]),y=t(null),k=({event:o})=>{y.value=o?.data},J=o=>{p.value=o.api};I(async()=>{await _()});const _=async()=>{s.state.afficher_in_progress=!0,m.value="",u.value&&(m.value+=` and Ecriture.CodeJournal= '${u.value}'`),c.value&&(m.value+=` and month(Ecriture.Date)= '${c.value}'`);try{const o=await j.post(`${s.lienApi}/journauxComptable/${s.db}`,{annee_fiscale:s.state.annee_fiscale,condition1:m.value},{headers:{"Content-Type":"application/json"}});r.value=o.data}catch(o){w(`Erreur lors de l'affichage des journaux comptables
 ${o}`)}finally{s.state.afficher_in_progress=!1}},D=()=>{if(!p.value){d("Grille non initialisée");return}if(r.value.length===0){d("Aucune donnée à exporter");return}const e=new Date().toISOString().slice(0,19).replace(/[-:]/g,"").replace("T","_");p.value.exportDataAsExcel({fileName:`Journaux_${s.state.enreg_societe.Nom}_${e}.xlsx`,sheetName:"Journaux",exportedRows:"all",onlySelected:!1,suppressTextAsCDATA:!0})},$=()=>{if(r.value.length===0){d("Aucune donnée à imprimer");return}i.value=!0};return(o,e)=>{const f=M,A=B,x=V,E=R;return b(),N(S,null,[a("div",P,[n(f,{icon:"pi pi-refresh",label:"Afficher",text:"",onClick:_}),a("span",null,[n(f,{icon:"pi pi-cog",label:"Actions",text:"",onClick:e[0]||(e[0]=l=>v.value.toggle(l))}),n(f,{icon:"pi pi-times",label:"Fermer",text:"",onClick:e[1]||(e[1]=l=>g(L)("JournauxComptables"))}),n(A,{ref_key:"menu",ref:v,model:h,popup:!0},null,512)])]),a("div",U,[a("div",z,[a("div",O,[e[5]||(e[5]=a("label",{class:"block mb-1"},"Journal",-1)),n(x,{modelValue:u.value,"onUpdate:modelValue":e[2]||(e[2]=l=>u.value=l),table:"Journal",class:"w-full"},null,8,["modelValue"])]),a("div",H,[e[6]||(e[6]=a("label",{class:"block mb-1"},"Mois",-1)),n(x,{modelValue:c.value,"onUpdate:modelValue":e[3]||(e[3]=l=>c.value=l),table:"MoisFiscalePeriode",class:"w-full"},null,8,["modelValue"])])]),a("div",K,[n(q,{ref_key:"dataGrid",ref:C,"excel-file-name":"Journaux","excel-sheet-name":"Journaux","row-data":r.value,"numeric-columns":["Débit","Crédit"],"date-columns":["Date"],"date-only":["Date"],"totals-columns":["Débit","Crédit"],"excluded-columns":["CodeJournal"],"show-checkbox":!1,"column-widths":{Date:90,Référence:120,Pièce:100,Compte:120,Intitulé:350,Libellé:350,Journal:120,Débit:90,Crédit:90},onRowClicked:k,onGridReady:J},null,8,["row-data"])])]),i.value?(b(),F(E,{key:0,show:i.value,onClose:e[4]||(e[4]=l=>i.value=!1),data:{Entete:r.value,Periode:"Exercice "+g(s).state.annee_fiscale},modeList:!0,RapportName:"/classique/compta/JournauxComptables"},null,8,["show","data"])):G("",!0)],64)}}};export{le as default};
