import{b as T,s as r}from"./index-BxIwIJfy.js";const s=e=>e?new Date(e).toLocaleDateString("fr-FR"):"",c=e=>(parseFloat(e)||0).toLocaleString("fr-FR",{minimumFractionDigits:2,maximumFractionDigits:2});function C(){const e=async(t,n)=>{if(!n)return"";const o=t==="fournisseur"?"unfournisseur":"unclient";try{return(await T.post(`${r.lienApi}/${o}/${r.db}/${n}`)).data?.mail||""}catch{return""}};return{construireContexteMail:async t=>{const n=t.lignes||[],o=n.reduce((a,i)=>a+(parseFloat(i.Total_HT)||0),0),m=n.reduce((a,i)=>a+(parseFloat(i.Total_TTC)||0),0),u={client:t.nomTiers?(t.nomTiers.split("|")[1]||t.nomTiers).trim():"",numero:t.numero??"",date:s(t.date),montant_ht:c(o),montant_ttc:c(m),echeance:s(t.echeance),societe:r.state.enreg_societe?.Nom||"",commercial:r.state.userCommun6?.nom||r.state.userCloud?.Nom||""},l=await e(t.tiers,t.code);return{contexte:u,email:l}},recupererMailTiers:e,fmtDate:s,fmtMontant:c}}export{C as u};
