import{_ as M}from"./Imprimer-CqTc6qE9.js";import{f as N,g as z,o as C,c as B,b as p,a as u,z as L,av as G,q as E,i as I,d as q,F as V,r as a}from"./vendor-0kGcmQpG.js";import{u as P,s as r,a as W,S as j,h as f}from"./index-Bn9WoKhP.js";import"./ReportViewer-1Jmo7TFF.js";const H={class:"w-full flex flex-row items-center gap-3 p-1"},O={style:"height: calc(100vh - 240px)",class:"mt-2 ag-theme-quartz"},Y={__name:"anomalies",setup(U){const{showError:x,showInfo:g}=P(),d=a([]),h=a(),b=a(),i=a(),m=a(!1),w=a([{headerName:"Anomalies",field:"libelle",width:300,cellRenderer:e=>{if(!e.data)return"";const t=S(e.data.icon),o=e.data.icon?"font-bold":"",n=e.data.icon?"":"pl-5";return`
        <div class="flex gap-1 items-center h-1">
          <i class="pi ${t} text-lg"></i>
          <p class="${o} ${n}">${e.value||""}</p>
        </div>
      `},sortable:!0,resizable:!0},{headerName:"Debit",field:"debit",width:150,type:"numericColumn",valueFormatter:e=>e.value?f(e.value):"",cellStyle:{textAlign:"right"},headerClass:"numeric-header-custom",sortable:!0,resizable:!0},{headerName:"Credit",field:"credit",width:150,type:"numericColumn",valueFormatter:e=>e.value?f(e.value):"",cellStyle:{textAlign:"right"},headerClass:"numeric-header-custom",sortable:!0,resizable:!0},{headerName:"Solde",field:"solde",width:150,type:"numericColumn",valueFormatter:e=>e.value?f(e.value):"",cellStyle:{textAlign:"right"},headerClass:"numeric-header-custom",sortable:!0,resizable:!0}]),y=a({sortable:!0,resizable:!0,filter:!1,suppressHeaderMenuButton:!0}),_=a({mode:"singleRow",checkboxes:!1,enableClickSelection:!1}),k=[{label:"Exporter vers Excel",icon:"pi pi-file-excel",command:()=>A()},{label:"Imprimer",icon:"pi pi-print",command:()=>$()},{label:"Libérer le lettrage déséquilibré de l'exercice en-cours",icon:"pi pi-cog",command:()=>R()},{label:"Régénérer le lettrage des fournisseurs (4411*)",icon:"pi pi-cog",command:()=>F()},{label:"Régénérer le lettrage des clients (3421*)",icon:"pi pi-cog",command:()=>T()}],S=e=>e?e.includes("mdi-check-bold text-green")?"pi-check-circle text-green-500":e.includes("mdi-close-thick text-red")?"pi-times-circle text-red-500":e.includes("mdi-alert text-orange")?"pi-exclamation-triangle text-orange-500":e.includes("mdi-alert text-yellow")?"pi-exclamation-triangle text-yellow-600":"":"",D=e=>{i.value=e.api,setTimeout(()=>{i.value&&i.value.sizeColumnsToFit()},100)};N(async()=>{v()});const v=async()=>{r.state.afficher_in_progress=!0;try{const t=(await W.post(`${r.lienApi}/SP_AnomaliesComptable/${r.db}`,{annee_fiscale:r.state.annee_fiscale},{headers:{"Content-Type":"application/json"}})).data;let o=[],n=!1,s=!1;for(let c=t.length-1;c>=0;c--){const l=t[c];l.titre==0&&(n=!0),l.titre==-1&&(s=!0),l.titre==1&&(n?l.icon="mdi-close-thick text-red":l.icon="mdi-check-bold text-green",n=!1),l.titre==2&&(s?l.icon="mdi-alert text-yellow":l.icon="mdi-check-bold text-green",s=!1),o.push(l)}d.value=o.reverse()}catch(e){const t=e.response?.data?.message||e.message;x(`Une erreur est survenue :  ${t}`)}finally{r.state.afficher_in_progress=!1}},A=()=>{if(!i.value){g("Grille non initialisée");return}if(d.value.length===0){g("Aucune donnée à exporter");return}const t=new Date().toISOString().slice(0,19).replace(/[-:]/g,"").replace("T","_");i.value.exportDataAsExcel({fileName:`Anomalies_${r.state.enreg_societe.Nom}_${t}.xlsx`,sheetName:"Liste des anomalies",exportedRows:"all",onlySelected:!1,suppressTextAsCDATA:!0})},$=()=>{m.value=!0},R=async()=>{},F=async()=>{},T=async()=>{};return(e,t)=>{const o=L,n=G,s=z("ag-grid-vue"),c=M;return C(),B(V,null,[p("div",H,[u(o,{icon:"pi pi-refresh",label:"Afficher",text:"",onClick:t[0]||(t[0]=l=>v())}),u(o,{icon:"pi pi-cog",label:"Actions",text:"",onClick:t[1]||(t[1]=l=>h.value.toggle(l))}),u(n,{ref_key:"actionsMenu",ref:h,model:k,popup:!0},null,512),u(o,{icon:"pi pi-times",label:"Fermer",text:"",onClick:t[2]||(t[2]=l=>E(j)("anomalies"))})]),p("div",null,[p("div",O,[u(s,{ref_key:"agGrid",ref:b,localeText:e.$agGridLocale,rowData:d.value,columnDefs:w.value,defaultColDef:y.value,theme:e.$agGridTheme,rowSelection:_.value,suppressRowClickSelection:!1,pinnedBottomRowData:e.pinnedBottomRowData,getContextMenuItems:e.getContextMenuItems,onGridReady:D,onRowClicked:e.onRowClick,onSelectionChanged:e.onSelectionChanged,onFilterChanged:e.onFilterChanged,onSortChanged:e.onFilterChanged,class:"ag-theme-quartz",style:{height:"100%",width:"100%"}},null,8,["localeText","rowData","columnDefs","defaultColDef","theme","rowSelection","pinnedBottomRowData","getContextMenuItems","onRowClicked","onSelectionChanged","onFilterChanged","onSortChanged"])])]),m.value?(C(),I(c,{key:0,show:m.value,onClose:t[3]||(t[3]=l=>m.value=!1),data:d.value,showModelSelector:!0,listeModelType:"Anomalies comptables",modeList:!0},null,8,["show","data"])):q("",!0)],64)}}};export{Y as default};
