@silexpert/core 2.0.123 → 2.0.124

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import { t as __name } from "../rolldown-runtime-BhWHdk3m.mjs";
2
- import { _W as IUser, aY as CreatePreSaleDocument, nY as CreateInvoiceDocument, oJ as ReadCommercialDocumentTemplate, rY as CreateMailHeader, sJ as ReadCommercialMailTemplate, wX as EstimateInvoiceType } from "../index-DY6JXj66.mjs";
2
+ import { TX as EstimateInvoiceType, cJ as ReadCommercialMailTemplate, iY as CreateMailHeader, oY as CreatePreSaleDocument, rY as CreateInvoiceDocument, sJ as ReadCommercialDocumentTemplate, vW as IUser } from "../index-CL2xcnsB.mjs";
3
3
  import "dayjs/locale/fr.js";
4
4
  //#region ts/utils/email.d.ts
5
5
  export declare function getHoraires(user: IUser): "Du lundi au vendredi de 9h à 18h" | "Du lundi au jeudi de 9h à 17h<br/>Le vendredi de 9h à 12h";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../ts/utils/email.ts","../../ts/utils/commercialManagement/document.ts"],"mappings":";;;;wBAmIgB,YAAY,MAAM;wBA2FlB,kBAAkB;;;wBCnLlB,2BACd,uBAAuB,qBACvB,SAAS,wBAAwB,uBACjC,+BACA,+BACC;wBAgNa,mBACd,QAAQ,kBACR,+BACA,+BACC;;;;wBAwCa,mCAAmC,SAAS,wBAAwB;EAClF;EACA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../ts/utils/email.ts","../../ts/utils/commercialManagement/document.ts"],"mappings":";;;;wBAmIgB,YAAY,MAAM;wBA2FlB,kBAAkB;;;wBClLlB,2BACd,uBAAuB,qBACvB,SAAS,wBAAwB,uBACjC,+BACA,+BACC;wBAgNa,mBACd,QAAQ,kBACR,+BACA,+BACC;;;;wBAwCa,mCAAmC,SAAS,wBAAwB;EAClF;EACA"}
@@ -1,4 +1,4 @@
1
- import"../rolldown-runtime-BhWHdk3m.mjs";import{B as e,F as t,G as n,Y as r,a as i,b as a,c as o,f as s,gt as c,mt as l,o as u,r as d,s as f,ut as p,x as m}from"../product-B35JCiip.mjs";import{groupBy as h,orderBy as g,round as _,sumBy as v,uniq as y}from"lodash-es";import{isDefined as b}from"class-validator";import x from"dayjs";import S from"ejs";import"dayjs/locale/fr.js";import C from"sanitize-html";function getRoleSignature(e){if(e.positionLabel)return e.positionLabel;let t=e.roles.map(e=>e.id).includes(44)||e.roles.map(e=>e.id).includes(45),n=e.roles.map(e=>e.id).includes(19),r=e.roles.map(e=>e.id).includes(11),i=e.roles.map(e=>e.id).includes(12),a=e.roles.map(e=>e.id).includes(34),o=e.roles.map(e=>e.id).includes(20),c=e.roles.map(e=>e.id).includes(10),l=e.roles.map(e=>e.id).includes(50),u=e.roles.map(e=>e.id).includes(41),d=e.roles.map(e=>e.id).includes(51),f=e.roles.map(e=>e.id).includes(9),p=e.roles.map(e=>e.id).includes(2),m=e.roles.map(e=>e.id).includes(55),h=!!s(e.roles.map(e=>e.id),[3,15]).length;return f&&n?`Responsable commercial`:f?`Chargé${e.idCivility===2?`e`:``} de clientèle`:c&&n?`Responsable relations clients`:c?`Conseill${e.idCivility===2?`ère`:`er`} comptable`:m?`Référent${e.idCivility===2?`e`:``} technique`:l&&n?`Responsable chargé${e.idCivility===2?`e`:``} accueil clients`:l?`Chargé${e.idCivility===2?`e`:``} accueil clients`:u&&n?`Responsable chargé${e.idCivility===2?`e`:``} de la satisfaction clients`:u?`Chargé${e.idCivility===2?`e`:``} de la satisfaction clients`:d&&n?`Responsable aide comptable`:d?`Aide comptable`:a&&t?`Assistant facturation`:a&&n?`Responsable facturation`:a?`Chargé${e.idCivility===2?`e`:``} de facturation`:i&&t?`Assistant juridique`:i&&n?`Responsable juridique`:i?`Juriste`:r&&t?`Assistant paie`:r&&n?`Responsable paie`:r?`Gestionnaire de paie`:o?`Expert${e.idCivility===2?`e`:``}-comptable`:p?`Développeur web`:h&&n?`Responsable comptable`:h&&t?`Assistant comptable`:`Comptable`}function getHoraires(e){return e?.roles?.map(e=>e.id).includes(9)?`Du lundi au vendredi de 9h à 18h`:`Du lundi au jeudi de 9h à 17h<br/>Le vendredi de 9h à 12h`}function getMailSignature(e,t){let n=c({...t?{idTypeBrand:t}:{},objectWaited:`listMails.informatique`}),r=c({...t?{idTypeBrand:t}:{},objectWaited:`listMails.bonjour`});return e.roles.map(e=>e.id).includes(2)?n:e&&s(e.roles.map(e=>e.id),[3,15,51,9,55]).length?e.email:r}function getPhoneSignature(e){return e.phone&&e.phone!==`0383931414`?e.phone.replace(/\B(?=(\d{2})+(?!\d))/g,`&nbsp;`):null}function generateSignature(e){let{fromAddress:t=null,idTypeBrand:n=1,calendlyUrl:r=null,...i}=e,{user:a,forceRole:o=null}=i,c=l({idTypeBrand:n}),u=c.urlS3,d=c.name,f=c.companyInformation?.city,p=c.companyInformation?.postalAddress||``,m=c.commercialName,h=c.bank?.IBAN,g=c.bank?.BIC,_=c.listMails?.bonjour||``,v=c.listMails?.social||``,y=c.listMails?.gestion||``,b=c.listMails?.satisfaction||``,x=c.listMails?.resiliation||``,C=c.listMails?.support||``,w=c.listMails?.juridique||``,T=c.listMails?.facturation||``,E=c.colors?.primary||``,D=c.listPhones?.contact||``,O=c.listPhones?.juridique||``,k=c.listPhones?.social||``,A=[{email:b,forceRole:`satisfaction`},{email:x,forceRole:`resiliation`},{email:T,forceRole:`facturation`}].find(e=>e.email===t);A&&(o=A.forceRole);let j,M,N,P;return[j,M,N,P]=[`Expert-Comptable`,_,null,`Du lundi au vendredi de 9h à 18h`],a?.roles&&a.roles.some(e=>e.id===51)?(a={firstname:`L'équipe ${m}`,isAll:!0},M=y,j=``):s((a?.roles??[]).map(e=>e.id),[3,54]).length===2?(a={firstname:`L'équipe ${m}`,isAll:!0},M=_,j=``):o===`satisfaction`?(a={firstname:`Service satisfaction clients`,isAll:!0},M=b,j=``,N=D):o===`resiliation`?(a={firstname:`Service satisfaction clients`,isAll:!0},M=x,j=``,N=D):o===`social`?(a={firstname:`Service social`,isAll:!0},M=v,j=``,N=k):o===`support`?(a={firstname:`Service Support`,isAll:!0},M=C,j=null):o===`juridique`?(a={firstname:`Service juridique`,isAll:!0},M=w,j=null,N=O):o===`facturation`?(a={firstname:`Service facturation`,isAll:!0},M=T,j=null,N=D):!a||o===`generique`?(a={firstname:`L'équipe ${m}`,isAll:!0},j=``):a!==0&&(j=getRoleSignature(a),M=getMailSignature(a,n),P=getHoraires(a),N=getPhoneSignature(a)),r&&(a.calendlyUrl=r),S.render(`<% if (commercialName === 'Clementine' && isFacturation) { %>
1
+ import"../rolldown-runtime-BhWHdk3m.mjs";import{C as e,H as t,L as n,S as r,Z as i,a,c as o,ft as s,gt as c,l,m as u,o as d,q as f,r as p,u as m,vt as h}from"../product-dgz1Fsg6.mjs";import{groupBy as g,orderBy as _,round as v,sumBy as y,uniq as b}from"lodash-es";import{isDefined as x}from"class-validator";import S from"dayjs";import C from"ejs";import"dayjs/locale/fr.js";import w from"sanitize-html";function getRoleSignature(e){if(e.positionLabel)return e.positionLabel;let t=e.roles.map(e=>e.id).includes(44)||e.roles.map(e=>e.id).includes(45),n=e.roles.map(e=>e.id).includes(19),r=e.roles.map(e=>e.id).includes(11),i=e.roles.map(e=>e.id).includes(12),a=e.roles.map(e=>e.id).includes(34),o=e.roles.map(e=>e.id).includes(20),s=e.roles.map(e=>e.id).includes(10),c=e.roles.map(e=>e.id).includes(50),l=e.roles.map(e=>e.id).includes(41),d=e.roles.map(e=>e.id).includes(51),f=e.roles.map(e=>e.id).includes(9),p=e.roles.map(e=>e.id).includes(2),m=e.roles.map(e=>e.id).includes(55),h=!!u(e.roles.map(e=>e.id),[3,15]).length;return f&&n?`Responsable commercial`:f?`Chargé${e.idCivility===2?`e`:``} de clientèle`:s&&n?`Responsable relations clients`:s?`Conseill${e.idCivility===2?`ère`:`er`} comptable`:m?`Référent${e.idCivility===2?`e`:``} technique`:c&&n?`Responsable chargé${e.idCivility===2?`e`:``} accueil clients`:c?`Chargé${e.idCivility===2?`e`:``} accueil clients`:l&&n?`Responsable chargé${e.idCivility===2?`e`:``} de la satisfaction clients`:l?`Chargé${e.idCivility===2?`e`:``} de la satisfaction clients`:d&&n?`Responsable aide comptable`:d?`Aide comptable`:a&&t?`Assistant facturation`:a&&n?`Responsable facturation`:a?`Chargé${e.idCivility===2?`e`:``} de facturation`:i&&t?`Assistant juridique`:i&&n?`Responsable juridique`:i?`Juriste`:r&&t?`Assistant paie`:r&&n?`Responsable paie`:r?`Gestionnaire de paie`:o?`Expert${e.idCivility===2?`e`:``}-comptable`:p?`Développeur web`:h&&n?`Responsable comptable`:h&&t?`Assistant comptable`:`Comptable`}function getHoraires(e){return e?.roles?.map(e=>e.id).includes(9)?`Du lundi au vendredi de 9h à 18h`:`Du lundi au jeudi de 9h à 17h<br/>Le vendredi de 9h à 12h`}function getMailSignature(e,t){let n=h({...t?{idTypeBrand:t}:{},objectWaited:`listMails.informatique`}),r=h({...t?{idTypeBrand:t}:{},objectWaited:`listMails.bonjour`});return e.roles.map(e=>e.id).includes(2)?n:e&&u(e.roles.map(e=>e.id),[3,15,51,9,55]).length?e.email:r}function getPhoneSignature(e){return e.phone&&e.phone!==`0383931414`?e.phone.replace(/\B(?=(\d{2})+(?!\d))/g,`&nbsp;`):null}function generateSignature(e){let{fromAddress:t=null,idTypeBrand:n=1,calendlyUrl:r=null,...i}=e,{user:a,forceRole:o=null}=i,s=c({idTypeBrand:n}),l=s.urlS3,d=s.name,f=s.companyInformation?.city,p=s.companyInformation?.postalAddress||``,m=s.commercialName,h=s.bank?.IBAN,g=s.bank?.BIC,_=s.listMails?.bonjour||``,v=s.listMails?.social||``,y=s.listMails?.gestion||``,b=s.listMails?.satisfaction||``,x=s.listMails?.resiliation||``,S=s.listMails?.support||``,w=s.listMails?.juridique||``,T=s.listMails?.facturation||``,E=s.colors?.primary||``,D=s.listPhones?.contact||``,O=s.listPhones?.juridique||``,k=s.listPhones?.social||``,A=[{email:b,forceRole:`satisfaction`},{email:x,forceRole:`resiliation`},{email:T,forceRole:`facturation`}].find(e=>e.email===t);A&&(o=A.forceRole);let j,M,N,P;return[j,M,N,P]=[`Expert-Comptable`,_,null,`Du lundi au vendredi de 9h à 18h`],a?.roles&&a.roles.some(e=>e.id===51)?(a={firstname:`L'équipe ${m}`,isAll:!0},M=y,j=``):u((a?.roles??[]).map(e=>e.id),[3,54]).length===2?(a={firstname:`L'équipe ${m}`,isAll:!0},M=_,j=``):o===`satisfaction`?(a={firstname:`Service satisfaction clients`,isAll:!0},M=b,j=``,N=D):o===`resiliation`?(a={firstname:`Service satisfaction clients`,isAll:!0},M=x,j=``,N=D):o===`social`?(a={firstname:`Service social`,isAll:!0},M=v,j=``,N=k):o===`support`?(a={firstname:`Service Support`,isAll:!0},M=S,j=null):o===`juridique`?(a={firstname:`Service juridique`,isAll:!0},M=w,j=null,N=O):o===`facturation`?(a={firstname:`Service facturation`,isAll:!0},M=T,j=null,N=D):!a||o===`generique`?(a={firstname:`L'équipe ${m}`,isAll:!0},j=``):a!==0&&(j=getRoleSignature(a),M=getMailSignature(a,n),P=getHoraires(a),N=getPhoneSignature(a)),r&&(a.calendlyUrl=r),C.render(`<% if (commercialName === 'Clementine' && isFacturation) { %>
2
2
  <p style="font-size: 15px; font-family: Arial; margin:0; padding:0px 0 4px; color:#6E6E71; margin-bottom: 10px; font-weight: bold;">
3
3
  <span style="color: #A0A0A0">Nos coordonnées bancaires </span>IBAN : <%= iban %> - BIC : <%= bic %>
4
4
  </p>
@@ -248,7 +248,7 @@ class="signatureClementine">
248
248
  Les informations contenues dans ce courrier électronique et ses pièces jointes sont confidentielles et couvertes par le secret professionnel. Si vous n'êtes pas le(s) destinataire(s) ou avez reçu ce courrier électronique par erreur, merci de bien vouloir supprimer l'email et d'en informer l'expéditeur dès que possible. Ce courrier électronique ne peut pas être divulgué, utilisé ou copié par quelqu'un d'autre que le(s) destinataire(s).
249
249
  </td>
250
250
  </tr>
251
- </table>`,{forceRole:o,isFacturation:a.roles?a.roles.some(e=>e.id===34):!1,isDataOfficer:!a.roles||a.roles.some(e=>e.id===51),brandName:d,brandPostalAddress:p,brandCity:f,idTypeBrand:n,commercialName:m,iban:h,bic:g,hostS3:u,user:a,roleSignature:j,mailSignature:M,phoneSignature:m!==`Comptalib`&&N?N.replace(/\s+/gm,`&nbsp;`):null,standardPhoneSignature:m===`Comptalib`?null:D.replace(/\s+/gm,`&nbsp;`),horaires:P,primaryColor:E,supportMail:C},{})}var CommercialDocumentCommonHTML=class{header=`<style>html {
251
+ </table>`,{forceRole:o,isFacturation:a.roles?a.roles.some(e=>e.id===34):!1,isDataOfficer:!a.roles||a.roles.some(e=>e.id===51),brandName:d,brandPostalAddress:p,brandCity:f,idTypeBrand:n,commercialName:m,iban:h,bic:g,hostS3:l,user:a,roleSignature:j,mailSignature:M,phoneSignature:m!==`Comptalib`&&N?N.replace(/\s+/gm,`&nbsp;`):null,standardPhoneSignature:m===`Comptalib`?null:D.replace(/\s+/gm,`&nbsp;`),horaires:P,primaryColor:E,supportMail:S},{})}var CommercialDocumentCommonHTML=class{header=`<style>html {
252
252
  -webkit-print-color-adjust: exact;
253
253
  }</style><% if (settings && settings.isEdgingDisplayed) { %>
254
254
  <span id="header-edging" style="position: absolute; top: 0; left: 0; width: 100vw; font-size: 10px !important; height: 15px; background-color: <%= settings && settings.edgingColor ? settings.edgingColor : '#333333' %>; margin-bottom: 20px;"></span>
@@ -640,19 +640,19 @@ class="signatureClementine">
640
640
  <% } %>
641
641
  </div>
642
642
  </div>
643
- `};const w=new CommercialDocumentCommonHTML,T=`<html class="pdf-content">
643
+ `};const T=new CommercialDocumentCommonHTML,E=`<html class="pdf-content">
644
644
 
645
645
  <body>
646
646
 
647
647
  ${`<div class="row space-between">
648
648
  <% if (settings && settings.logoAlignment === 'left') { %>
649
649
  <div class="society-informations">
650
- ${w.logo}
651
- ${w.company}
650
+ ${T.logo}
651
+ ${T.company}
652
652
  </div>
653
653
  <% } else { %>
654
- <div class="society-informations">${w.company}</div>
655
- ${w.logo}
654
+ <div class="society-informations">${T.company}</div>
655
+ ${T.logo}
656
656
  <% } %>
657
657
  </div>
658
658
 
@@ -711,12 +711,12 @@ class="signatureClementine">
711
711
  <% if (title) { %><%=languageTemplate.template.common.headers.title %> : <%= title %><% } %>
712
712
  </div>
713
713
 
714
- <div class="row mt-10">${w.products}</div>
714
+ <div class="row mt-10">${T.products}</div>
715
715
 
716
716
  <div class="row space-between mt-20">
717
717
  <div style="width: 55%;">
718
718
  <% if (disableVat !== true && vats.length) { %>
719
- ${w.vatRecapitulation}
719
+ ${T.vatRecapitulation}
720
720
  <% } %>
721
721
  <% if (vatMention && vatMention !== 'TVA: Non concerné') { %><div class="vat-mention <%= disableVat !== true ? 'mt-20' : ''%>"><%= vatMention %></div><% } %>
722
722
  <% if (comment) { %>
@@ -726,10 +726,10 @@ class="signatureClementine">
726
726
  </div>
727
727
 
728
728
  <div>
729
- ${w.amountRecapitulation}
729
+ ${T.amountRecapitulation}
730
730
 
731
731
  <% if (isStripeAllowed && ![3, 2].includes(idEstimateInvoiceType)) { %>
732
- <div style="text-align: right; margin-top: 30px;">${w.paymentButton}</div>
732
+ <div style="text-align: right; margin-top: 30px;">${T.paymentButton}</div>
733
733
  <% } %>
734
734
  </div>
735
735
 
@@ -755,17 +755,17 @@ class="signatureClementine">
755
755
  <br/><%= languageTemplate.template.common.options.approval %> : <br/><br/><br/><br/>
756
756
  <% } %>
757
757
 
758
- <% if (cgv && (settings && settings.invoiceCgv)) { %>
758
+ <% if (cgv && settings && settings.invoiceCgv) { %>
759
759
  <br><div style="page-break-after:always;"></div>
760
760
  <div id="WYSIWYG"><%- cgv %></div>
761
761
  <% } %>
762
762
  </body>
763
763
 
764
764
  <style>
765
- ${w.style}
765
+ ${T.style}
766
766
  </style>
767
767
  <style>
768
- ${w.styleWYSIWYG}
768
+ ${T.styleWYSIWYG}
769
769
  </style>
770
- </html>`;function thirdPartyToReadThirdPartyEditing(t){return{...t,country:b(t?.idCountry)?e.find(e=>e.id===t.idCountry)?.name?.toUpperCase()??null:null,deliveryCountry:b(t?.deliveryIdCountry)?e.find(e=>e.id===t.deliveryIdCountry)?.name?.toUpperCase()??null:null}}function generateCommercialDocument(e,r,i=!1,a=void 0){let s=g(r.products.map(e=>d(e),`reorder`)),l=g(Object.values(h(s,`vatFormatted`)).map(e=>u(e),`value`)).filter(e=>e.id!==t.MARGE.id),b=thirdPartyToReadThirdPartyEditing(r.thirdParty),w;if(r.advanceProducts?.length){let e=Object.values(h(r.advanceProducts,`vatFormatted`)).map(e=>u(e),`value`).filter(e=>e.id!==t.MARGE.id);w=l.map(t=>{let n=t.base-(e.find(e=>e.id===t.id)?.base??0),r=t.toPay-(e.find(e=>e.id===t.id)?.toPay??0);return{...t,baseFormatted:m(n),amountFormatted:m(r)}})}let E=v(l,e=>_(e.amount)),D=v(s,`totalTaxExcludedRounded`),O=D+E,k=r.language??`fr`,A=f[k],j=n.find(e=>e.id===r.accountingCategory)?.label??null,M=r.recoveryCost,N={...r,thirdParty:b,paymentLink:r.paymentLink??`#`,idEstimateInvoiceType:e,title:r.title??null,cgv:r.cgv??null,name:r.name??null,number:r.number??null,street:r.street??null,zipCode:r.zipCode??null,city:r.city??null,legalForm:r.legalForm??null,capital:r.capital??null,siren:r.siren??null,rcs:r.rcs??null,vatCode:r.vatCode??null,nafCode:r.nafCode??null,penalties:r.penalties?o(k,r.penalties,`penalties`)??r.penalties:null,termsOfPayment:r.termsOfPayment?o(k,r.termsOfPayment,`termsOfPayment`)??r.termsOfPayment:null,recoveryCost:M?o(k,M,`recoveryCost`)??M:null,discount:r.discount?o(k,r.discount,`discount`)??r.discount:null,vatMention:r.vatMention?o(k,r.vatMention,`vatMention`)??r.vatMention:null,phoneContact:r.settings?.phoneContact??null,products:s,vats:l,totalTaxExcluded:D,totalTaxIncluded:_(O),totalTaxAndDiscountIncluded:_(O),generalDiscountFormatted:r.generalDiscount2?m(r.generalDiscount2):null,depositFormatted:r.deposit?m(r.deposit):null,totalTaxExcludedFormatted:m(D),totalTaxIncludedFormatted:m(O),totalTaxAndDiscountIncludedFormatted:m(O-(r.generalDiscount2??0)-(r.deposit??0)),totalVatAmountFormatted:m(E),font:{id:r.settings?.idFont??1,name:p.find(e=>e.id===r.settings?.idFont)?.name??p[0].name,url:p.find(e=>e.id===r.settings?.idFont)?.link??p[0].link},capitalFormatted:r.capital?`${r.capital}`.split(``).reduceRight((e,t,n,{length:r})=>`${t}${(r-(n+1))%3==0?` `:``}${e}`,``).trim():null,dueDateFormatted:r.dueDate?x(r.dueDate).format(`DD/MM/YYYY`):null,expirationDateFormatted:r.expirationDate?x(r.expirationDate).format(`DD/MM/YYYY`):null,emissionDateFormatted:r.emissionDate?x(r.emissionDate).format(`DD/MM/YYYY`):null,shouldDisplayDiscountColumn:!!s.find(e=>e.discount2&&e.discount2>0),marginVats:y(s.filter(e=>e.marginVatFormatted!==null).map(e=>e.marginVatFormatted)),accountingCategoryFormatted:j?o(k,j,`accountingCategory`)??null:null,brandColors:c({objectWaited:`colors`,nodeEnv:a}),brandName:`${c({objectWaited:`name`,nodeEnv:a})}`,shouldHideBrandName:i,addressComplement:r.addressComplement??null,paymentType:r.paymentType?o(k,r.paymentType,`paymentType`)??r.paymentType:null,languageTemplate:A},P=new CommercialDocumentCommonHTML,F=[2,3].includes(e)?r?.settings?.freeEstimateText:r?.settings?.freeInvoiceText;return{header:S.render(P.header,N,{}),body:S.render(T,{...N,cgv:N.cgv&&typeof N.cgv==`string`?C(N.cgv,{allowedTags:[`b`,`i`,`em`,`br`,`strong`,`p`,`span`,`li`,`ul`,`ol`,`h1`,`h2`,`h3`,`u`,`s`,`a`,`blockquote`],allowedAttributes:{a:[`href`,`name`,`target`,`data-list`],li:[`data-list`],"*":[`class`,`style`,`dir`]},allowedClasses:{"*":[/^ql-/]},allowedStyles:{"*":{color:[/^[a-z]+$/i,/^#(?:[0-9a-f]{3}){1,2}$/i,/^rgb\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*\)$/i],"background-color":[/^[a-z]+$/i,/^#(?:[0-9a-f]{3}){1,2}$/i,/^rgb\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*\)$/i],"text-align":[/^left$/i,/^right$/i,/^center$/i,/^justify$/i],"white-space":[/^pre-wrap$/i]}}}):null,comment:N.comment&&typeof N.comment==`string`?C(N.comment?.replace(/\n/g,`<br/>`),{allowedTags:[`b`,`i`,`em`,`br`,`strong`]}):null,products:N.products.map(e=>({...e,comment:e.comment&&typeof e.comment==`string`?C(e.comment?.replace(/\n/g,`<br/>`),{allowedTags:[`b`,`i`,`em`,`br`,`strong`]}):null,unitFormatted:o(k,e.unitFormatted,`unit`)})),vats:w??l},{}),footer:S.render(P.footer,{...N,freeText:F&&typeof F==`string`?C(F?.replace(/\n/g,`<br/>`),{allowedTags:[`b`,`i`,`em`,`br`,`strong`,`p`]}):null},{}),data:N}}function generateMailHeader(e,t=!1,n=void 0){let r=e.payload.language??`fr`,i=f[r];x.locale(`fr`);let o={...e.payload,totalTaxExcludedFormatted:a(e.payload.totalTaxExcluded),totalTaxIncludedFormatted:a(e.payload.totalTaxIncluded),totalVatFormatted:a(e.payload.totalTaxIncluded-e.payload.totalTaxExcluded),dueDateFormatted:e.payload.dueDate?x(e.payload.dueDate).format(`DD MMMM YYYY`):null,hasVat:e.hasVat,hostS3:e.hostS3,logoUrl:e.logoUrl,companyName:e.companyName,fileUrl:e.fileUrl,brandColors:c({objectWaited:`colors`,nodeEnv:n}),shouldHideBrandName:t,languageMail:i},s=new CommercialDocumentMailHTML;return{header:S.render(s.header,o,{})}}function isMissing(e){return e==null?!0:typeof e==`string`?e.trim().length===0:Array.isArray(e)?e.length===0:!1}function checkCommercialDocumentInformation(e){let n=[],a=g(e.products.map(e=>d(e),`reorder`)),o=g(Object.values(h(a,`vatFormatted`)).map(e=>u(e),`value`)).filter(e=>e.id!==t.MARGE.id),s=v(o,e=>_(e.amount)),c=v(a,e=>_(e.totalTaxExcluded)),l=_(c+s),f=[{value:e.reference,error:`Le numéro de facture est obligatoire.`},{value:e.idEstimateInvoiceType,error:`Le type de document est obligatoire.`},{value:e.emissionDate,error:`La date d’émission est obligatoire.`},...a.flatMap((e,t)=>{let n=e.itemSaleName?.trim()?`"${e.itemSaleName}"`:`à la ligne ${t+1}`;return[{value:e.itemSaleName,error:`Le nom de l'article ${n} est obligatoire.`},{value:e.priceTaxExcluded,error:`Le prix net de l'article ${n} est obligatoire.`},{value:e.quantity,error:`La quantité de l'article ${n} est obligatoire.`},{value:e.unit,error:`Le code EN 16931 de l'article ${n} est obligatoire.`},{value:e.idVat,error:`Le type de TVA de l'article ${n} est obligatoire.`},{value:e.totalTaxExcluded,error:`Le montant net de l'article ${n} est obligatoire.`}]}),{value:e.name,error:`Le nom du vendeur est obligatoire.`},{value:e.siren,error:`Le SIREN du vendeur est obligatoire.`},{value:e.zipCode,error:`Le code postal du vendeur est obligatoire.`},{value:e.street,error:`L’adresse du vendeur est obligatoire.`},{value:e.city,error:`La ville du vendeur est obligatoire.`},{value:e.idCountry,error:`Le pays du vendeur est obligatoire.`},{value:e.thirdParty.company??e.thirdParty.fullname??`NA`,error:`Le nom de l’acheteur est obligatoire.`},{value:e.thirdParty?.idCountry,error:`Le pays de l’acheteur est obligatoire.`},...o.flatMap((e,t)=>[{value:e.amount,error:`Le montant de TVA à la ligne ${t+1} est obligatoire.`},{value:e.base,error:`La base d’imposition de la TVA à la ligne ${t+1} est obligatoire.`},{value:e.value,error:`Le type de TVA à la ligne ${t+1} est obligatoire.`}]),{value:c,error:`Le montant total hors taxe est obligatoire.`},{value:c,error:`La somme du montant net des lignes est obligatoire.`},{value:s,error:`Le montant total de TVA est obligatoire.`},{value:l,error:`Le montant total TTC est obligatoire.`}],p=r.find(t=>t.value===e.vatMention)?.taxType??`standard`;if([`margin`,`autoliquidation`,`export`,`exempt`].includes(p))for(let e of a)i(e.idVat)?.value!==0&&n.push(`L'article "${e.itemSaleName}" a une TVA non nulle alors que la mention légale de TVA est définie comme "${p}".`);return n.push(...f.filter(e=>isMissing(e.value)).map(e=>e.error)),{valid:n.length===0,errors:n.length>0?n:void 0}}export{checkCommercialDocumentInformation,generateCommercialDocument,generateMailHeader,generateSignature,getHoraires};
770
+ </html>`;function thirdPartyToReadThirdPartyEditing(e){return{...e,country:x(e?.idCountry)?t.find(t=>t.id===e.idCountry)?.name?.toUpperCase()??null:null,deliveryCountry:x(e?.deliveryIdCountry)?t.find(t=>t.id===e.deliveryIdCountry)?.name?.toUpperCase()??null:null}}function generateCommercialDocument(t,r,i=!1,a=void 0){let c=_(r.products.map(e=>p(e),`reorder`)),u=_(Object.values(g(c,`vatFormatted`)).map(e=>d(e),`value`)).filter(e=>e.id!==n.MARGE.id),x=thirdPartyToReadThirdPartyEditing(r.thirdParty),T;if(r.advanceProducts?.length){let t=Object.values(g(r.advanceProducts,`vatFormatted`)).map(e=>d(e),`value`).filter(e=>e.id!==n.MARGE.id);T=u.map(n=>{let r=n.base-(t.find(e=>e.id===n.id)?.base??0),i=n.toPay-(t.find(e=>e.id===n.id)?.toPay??0);return{...n,baseFormatted:e(r),amountFormatted:e(i)}})}let D=y(u,e=>v(e.amount)),O=y(c,`totalTaxExcludedRounded`),k=O+D,A=r.language??`fr`,j=l[A],M=f.find(e=>e.id===r.accountingCategory)?.label??null,N=r.recoveryCost,P={...r,thirdParty:x,paymentLink:r.paymentLink??`#`,idEstimateInvoiceType:t,title:r.title??null,cgv:o(r.cgv)?null:r.cgv,name:r.name??null,number:r.number??null,street:r.street??null,zipCode:r.zipCode??null,city:r.city??null,legalForm:r.legalForm??null,capital:r.capital??null,siren:r.siren??null,rcs:r.rcs??null,vatCode:r.vatCode??null,nafCode:r.nafCode??null,penalties:r.penalties?m(A,r.penalties,`penalties`)??r.penalties:null,termsOfPayment:r.termsOfPayment?m(A,r.termsOfPayment,`termsOfPayment`)??r.termsOfPayment:null,recoveryCost:N?m(A,N,`recoveryCost`)??N:null,discount:r.discount?m(A,r.discount,`discount`)??r.discount:null,vatMention:r.vatMention?m(A,r.vatMention,`vatMention`)??r.vatMention:null,phoneContact:r.settings?.phoneContact??null,products:c,vats:u,totalTaxExcluded:O,totalTaxIncluded:v(k),totalTaxAndDiscountIncluded:v(k),generalDiscountFormatted:r.generalDiscount2?e(r.generalDiscount2):null,depositFormatted:r.deposit?e(r.deposit):null,totalTaxExcludedFormatted:e(O),totalTaxIncludedFormatted:e(k),totalTaxAndDiscountIncludedFormatted:e(k-(r.generalDiscount2??0)-(r.deposit??0)),totalVatAmountFormatted:e(D),font:{id:r.settings?.idFont??1,name:s.find(e=>e.id===r.settings?.idFont)?.name??s[0].name,url:s.find(e=>e.id===r.settings?.idFont)?.link??s[0].link},capitalFormatted:r.capital?`${r.capital}`.split(``).reduceRight((e,t,n,{length:r})=>`${t}${(r-(n+1))%3==0?` `:``}${e}`,``).trim():null,dueDateFormatted:r.dueDate?S(r.dueDate).format(`DD/MM/YYYY`):null,expirationDateFormatted:r.expirationDate?S(r.expirationDate).format(`DD/MM/YYYY`):null,emissionDateFormatted:r.emissionDate?S(r.emissionDate).format(`DD/MM/YYYY`):null,shouldDisplayDiscountColumn:!!c.find(e=>e.discount2&&e.discount2>0),marginVats:b(c.filter(e=>e.marginVatFormatted!==null).map(e=>e.marginVatFormatted)),accountingCategoryFormatted:M?m(A,M,`accountingCategory`)??null:null,brandColors:h({objectWaited:`colors`,nodeEnv:a}),brandName:`${h({objectWaited:`name`,nodeEnv:a})}`,shouldHideBrandName:i,addressComplement:r.addressComplement??null,paymentType:r.paymentType?m(A,r.paymentType,`paymentType`)??r.paymentType:null,languageTemplate:j},F=new CommercialDocumentCommonHTML,I=[2,3].includes(t)?r?.settings?.freeEstimateText:r?.settings?.freeInvoiceText;return{header:C.render(F.header,P,{}),body:C.render(E,{...P,cgv:P.cgv&&typeof P.cgv==`string`?w(P.cgv,{allowedTags:[`b`,`i`,`em`,`br`,`strong`,`p`,`span`,`li`,`ul`,`ol`,`h1`,`h2`,`h3`,`u`,`s`,`a`,`blockquote`],allowedAttributes:{a:[`href`,`name`,`target`,`data-list`],li:[`data-list`],"*":[`class`,`style`,`dir`]},allowedClasses:{"*":[/^ql-/]},allowedStyles:{"*":{color:[/^[a-z]+$/i,/^#(?:[0-9a-f]{3}){1,2}$/i,/^rgb\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*\)$/i],"background-color":[/^[a-z]+$/i,/^#(?:[0-9a-f]{3}){1,2}$/i,/^rgb\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*\)$/i],"text-align":[/^left$/i,/^right$/i,/^center$/i,/^justify$/i],"white-space":[/^pre-wrap$/i]}}}):null,comment:P.comment&&typeof P.comment==`string`?w(P.comment?.replace(/\n/g,`<br/>`),{allowedTags:[`b`,`i`,`em`,`br`,`strong`]}):null,products:P.products.map(e=>({...e,comment:e.comment&&typeof e.comment==`string`?w(e.comment?.replace(/\n/g,`<br/>`),{allowedTags:[`b`,`i`,`em`,`br`,`strong`]}):null,unitFormatted:m(A,e.unitFormatted,`unit`)})),vats:T??u},{}),footer:C.render(F.footer,{...P,freeText:I&&typeof I==`string`?w(I?.replace(/\n/g,`<br/>`),{allowedTags:[`b`,`i`,`em`,`br`,`strong`,`p`]}):null},{}),data:P}}function generateMailHeader(e,t=!1,n=void 0){let i=e.payload.language??`fr`,a=l[i];S.locale(`fr`);let o={...e.payload,totalTaxExcludedFormatted:r(e.payload.totalTaxExcluded),totalTaxIncludedFormatted:r(e.payload.totalTaxIncluded),totalVatFormatted:r(e.payload.totalTaxIncluded-e.payload.totalTaxExcluded),dueDateFormatted:e.payload.dueDate?S(e.payload.dueDate).format(`DD MMMM YYYY`):null,hasVat:e.hasVat,hostS3:e.hostS3,logoUrl:e.logoUrl,companyName:e.companyName,fileUrl:e.fileUrl,brandColors:h({objectWaited:`colors`,nodeEnv:n}),shouldHideBrandName:t,languageMail:a},s=new CommercialDocumentMailHTML;return{header:C.render(s.header,o,{})}}function isMissing(e){return e==null?!0:typeof e==`string`?e.trim().length===0:Array.isArray(e)?e.length===0:!1}function checkCommercialDocumentInformation(e){let t=[],r=_(e.products.map(e=>p(e),`reorder`)),o=_(Object.values(g(r,`vatFormatted`)).map(e=>d(e),`value`)).filter(e=>e.id!==n.MARGE.id),s=y(o,e=>v(e.amount)),c=y(r,e=>v(e.totalTaxExcluded)),l=v(c+s),u=[{value:e.reference,error:`Le numéro de facture est obligatoire.`},{value:e.idEstimateInvoiceType,error:`Le type de document est obligatoire.`},{value:e.emissionDate,error:`La date d’émission est obligatoire.`},...r.flatMap((e,t)=>{let n=e.itemSaleName?.trim()?`"${e.itemSaleName}"`:`à la ligne ${t+1}`;return[{value:e.itemSaleName,error:`Le nom de l'article ${n} est obligatoire.`},{value:e.priceTaxExcluded,error:`Le prix net de l'article ${n} est obligatoire.`},{value:e.quantity,error:`La quantité de l'article ${n} est obligatoire.`},{value:e.unit,error:`Le code EN 16931 de l'article ${n} est obligatoire.`},{value:e.idVat,error:`Le type de TVA de l'article ${n} est obligatoire.`},{value:e.totalTaxExcluded,error:`Le montant net de l'article ${n} est obligatoire.`}]}),{value:e.name,error:`Le nom du vendeur est obligatoire.`},{value:e.siren,error:`Le SIREN du vendeur est obligatoire.`},{value:e.zipCode,error:`Le code postal du vendeur est obligatoire.`},{value:e.street,error:`L’adresse du vendeur est obligatoire.`},{value:e.city,error:`La ville du vendeur est obligatoire.`},{value:e.idCountry,error:`Le pays du vendeur est obligatoire.`},{value:e.thirdParty.company??e.thirdParty.fullname??`NA`,error:`Le nom de l’acheteur est obligatoire.`},{value:e.thirdParty?.idCountry,error:`Le pays de l’acheteur est obligatoire.`},...o.flatMap((e,t)=>[{value:e.amount,error:`Le montant de TVA à la ligne ${t+1} est obligatoire.`},{value:e.base,error:`La base d’imposition de la TVA à la ligne ${t+1} est obligatoire.`},{value:e.value,error:`Le type de TVA à la ligne ${t+1} est obligatoire.`}]),{value:c,error:`Le montant total hors taxe est obligatoire.`},{value:c,error:`La somme du montant net des lignes est obligatoire.`},{value:s,error:`Le montant total de TVA est obligatoire.`},{value:l,error:`Le montant total TTC est obligatoire.`}],f=i.find(t=>t.value===e.vatMention)?.taxType??`standard`;if([`margin`,`autoliquidation`,`export`,`exempt`].includes(f))for(let e of r)a(e.idVat)?.value!==0&&t.push(`L'article "${e.itemSaleName}" a une TVA non nulle alors que la mention légale de TVA est définie comme "${f}".`);return t.push(...u.filter(e=>isMissing(e.value)).map(e=>e.error)),{valid:t.length===0,errors:t.length>0?t:void 0}}export{checkCommercialDocumentInformation,generateCommercialDocument,generateMailHeader,generateSignature,getHoraires};
771
771
  //# sourceMappingURL=index.mjs.map