import{b as C}from"./primevue-CfIk0_DY.js";import{u as D,s as t,b as l,S as m}from"./index-BxIwIJfy.js";import{D as T}from"./DataGrid-CoMfrBJA.js";import{a as s,o as E,b as u,c as $,d as n,v as f,a7 as p,k as B,p as V}from"./vue-core-Di3IuVqe.js";import"./cjs-helpers-psZwOBky.js";import"./vue-cal-DKMVGERa.js";import"./moment-BeHQNF8T.js";import"./useAgGridConfig-Dp3DkgaV.js";const N={class:"page-wrapper"},G={class:"flex min-w-full flex-col lg:flex-row lg:items-center lg:justify-between gap-2 p-1"},M={class:"btns flex items-center gap-2"},j={class:"grille-mobile-fix",style:{height:"calc(100vh - 180px)"}},Y={__name:"AchatsEtFrais",props:["masquerFermer"],setup(d){const{showError:r,showWarn:_}=D(),h=d,g=s(),o=s([]),v=s(t.state.annee_fiscale||new Date().getFullYear()),x=["type","date","num","tiers","reference","montant_ht","tva","montant_ttc","montant_frais","taux_frais"],y={type:"Type",date:"Date",num:"N° Doc",tiers:"Fournisseur / Frais",reference:"Référence",montant_ht:"Montant HT",tva:"TVA",montant_ttc:"Montant TTC (DH)",montant_frais:"Frais",taux_frais:"% Frais"},w={type:90,num:100,tiers:280,reference:160,montant_ht:140,tva:120,montant_ttc:160,montant_frais:140,taux_frais:100},b=["montant_ht","tva","montant_ttc","montant_frais","taux_frais"],A=["montant_ht","tva","montant_ttc","montant_frais"];E(async()=>{await F(),await i()});const F=async()=>{try{const a=(await l.post(`${t.lienApi}/verifierDroit/${t.state.dbCommun6}`,{id_utilisateur:t.userId,id_page:833,mail:t.state.userCloud.mail})).data;a&&Object.keys(a).length>0&&!a.lecture&&(_("Vous n'avez pas le droit, veuillez consulter l'administrateur"),m("AchatsEtFrais"))}catch(e){r(e.response?.data?.message||e.message)}},i=async()=>{t.state.afficher_in_progress=!0;try{const e=await l.post(`${t.lienApi}/achatsEtFraisAnnee/${t.db}`,{annee:v.value});o.value=e.data||[]}catch(e){r(e.response?.data?.message||e.message)}finally{t.state.afficher_in_progress=!1}};return(e,a)=>{const c=C;return u(),$("div",N,[n("div",G,[n("div",M,[f(c,{icon:"pi pi-refresh",label:"Actualiser",onClick:a[0]||(a[0]=k=>i()),text:"",loading:p(t).state.afficher_in_progress},null,8,["loading"]),h.masquerFermer?V("",!0):(u(),B(c,{key:0,icon:"pi pi-times",label:"Fermer",text:"",onClick:a[1]||(a[1]=k=>p(m)("AchatsEtFrais"))}))])]),n("div",j,[f(T,{ref_key:"dataGrid",ref:g,"excel-file-name":"Achats et frais","excel-sheet-name":"Achats et frais","row-data":o.value,"excluded-columns":[],"column-order":x,"column-titles":y,"column-widths":w,"numeric-columns":b,"totals-columns":A,"date-only":["date"],"enable-totals":!0,showCheckbox:!1,"empty-title":"Aucun achat sur cette année","empty-subtitle":"Aucune facture fournisseur validée pour l'année fiscale en cours"},null,8,["row-data"])])])}}};export{Y as default};
