import{_ as V}from"./Imprimer-CqTc6qE9.js";import{_ as N}from"./ComboDynamique-CzrtYPe1.js";import{f as B,o as _,c as D,b as l,a,q as I,z as F,av as j,ax as G,i as q,d as J,F as O,r as o}from"./vendor-0kGcmQpG.js";import{_ as P}from"./FavorisSwitch-DD6nTfzi.js";import{u as U,s as n,S as z,a as H}from"./index-Bn9WoKhP.js";import{_ as K}from"./DataGrid-tb6QVwpZ.js";import"./ReportViewer-1Jmo7TFF.js";import"./useAgGridConfig-DjXMc6wb.js";const Q={class:"flex min-w-full flex-col lg:flex-row lg:items-center lg:justify-between gap-2 p-1"},W={class:"btns flex items-center gap-2 py-2"},X={class:"flex items-center gap-3 whitespace-nowrap ml-auto"},Y={class:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4 mb-4"},Z={style:{height:"calc(100vh - 220px)",width:"100%"}},ce={__name:"EtatImpotRevenu",setup(ee){const{showInfo:d,showError:g}=U(),f=o(),u=o(!1),x=o(null),b=o({}),w=o(null),m=o(""),p=o(),L=o(),h=({row:t})=>{w.value=t},R=t=>{L.value=t.api},$=new Date().getMonth()+1,c=o([]),v=[{Id:"1",Libelle:"Janvier"},{Id:"2",Libelle:"Février"},{Id:"3",Libelle:"Mars"},{Id:"4",Libelle:"Avril"},{Id:"5",Libelle:"Mai"},{Id:"6",Libelle:"Juin"},{Id:"7",Libelle:"Juillet"},{Id:"8",Libelle:"Août"},{Id:"9",Libelle:"Septembre"},{Id:"10",Libelle:"Octobre"},{Id:"11",Libelle:"Novembre"},{Id:"12",Libelle:"Décembre"},{Id:"1,2,3",Libelle:"Trimestre 1"},{Id:"4,5,6",Libelle:"Trimestre 2"},{Id:"7,8,9",Libelle:"Trimestre 3"},{Id:"10,11,12",Libelle:"Trimestre 4"},{Id:"1,2,3,4,5,6,7,8,9,10,11,12",Libelle:"Annuelle"}],i=o(`${$}`);B(()=>{});const M=async()=>{n.state.afficher_in_progress=!0;try{const t=await H.post(`${n.lienApi}/EtatIR/${n.db}`,{Combo_Mois:i.value,annee_fiscale:n.state.annee_fiscale,Combo_Affaire:m.value},{headers:{"Content-Type":"application/json"}});c.value=t.data}catch(t){const e=t.response?.data?.message||t.message;g(`Une erreur est survenue : ${e}`)}finally{n.state.afficher_in_progress=!1}},E=()=>{const t=v.find(r=>r.Id===i.value),e=t?t.Libelle:i.value;b.value={Entete:c.value,Periode:`${e} ${n.state.annee_fiscale}`},u.value=!0},S=()=>{if(!p.value){d("Grille non initialisée");return}if(c.value.length===0){d("Aucune donnée à exporter");return}const e=new Date().toISOString().slice(0,19).replace(/[-:]/g,"").replace("T","_");p.value.exportToExcel(`Import sur le revenu_${n.state.enreg_societe.Nom}_${i.value}_${e}.xlsx`)};return(t,e)=>{const r=F,k=j,y=P,C=G,A=N,T=V;return _(),D(O,null,[l("div",Q,[l("div",W,[a(r,{icon:"pi pi-search",label:"Rechercher",onClick:e[0]||(e[0]=s=>M()),text:"",loading:I(n).state.afficher_in_progress},null,8,["loading"]),a(r,{icon:"pi pi-cog",label:"Actions",text:"",onClick:e[1]||(e[1]=s=>f.value.toggle(s))}),a(k,{ref_key:"actionsMenu",ref:f,model:[{label:"Exporter vers Excel",icon:"pi pi-file-excel",command:()=>S()},{label:"Imprimer",icon:"pi pi-print",command:()=>E()}],popup:!0},null,8,["model"]),a(r,{icon:"pi pi-times",label:"Fermer",text:"",onClick:e[2]||(e[2]=s=>I(z)("EtatImpotRevenu"))})]),l("div",X,[a(y,{fen:"EtatImpotRevenu",text:"État Impôt Revenu"})])]),l("div",Y,[l("div",null,[e[6]||(e[6]=l("label",{class:"block text-sm"},"Mois / Trimestre",-1)),a(C,{size:"small",modelValue:i.value,"onUpdate:modelValue":e[3]||(e[3]=s=>i.value=s),options:v,optionLabel:"Libelle",optionValue:"Id",placeholder:"Mois / Trimestre",class:"w-full"},null,8,["modelValue"])]),l("div",null,[e[7]||(e[7]=l("label",{class:"block text-sm"},"Affaire",-1)),a(A,{placeholder:"Affaire",table:"affaire",modelValue:m.value,"onUpdate:modelValue":e[4]||(e[4]=s=>m.value=s),class:"w-full"},null,8,["modelValue"])])]),e[8]||(e[8]=l("div",{class:"h-2"},null,-1)),l("div",Z,[a(K,{ref_key:"dataGrid",ref:p,"excel-file-name":"Etat impot revenu","excel-sheet-name":"Etat impot revenu","row-data":c.value,"excluded-columns":["GID"],"column-widths":{Matricule:120,nom:200,SituationFamiliale:160,Abattement:120,jours:100,s_base:140,s_brut:130,SBI:120,SNI:120,ir:120},"numeric-columns":["jours","s_base","s_brut","SBI","SNI","ir"],"enable-totals":!0,"totals-columns":["jours","s_base","s_brut","SBI","SNI","ir"],onRowClicked:h,onGridReady:R},null,8,["row-data"])]),u.value?(_(),q(T,{key:0,show:u.value,onClose:e[5]||(e[5]=s=>u.value=!1),Response:x.value,data:b.value,RapportName:"/classique/paie/EtatIR",nomFichier:"EtatImpotRevenu"},null,8,["show","Response","data"])):J("",!0)],64)}}};export{ce as default};
