@silexpert/core 2.0.140 → 2.0.142

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.
@@ -769,5 +769,5 @@ class="signatureClementine">
769
769
  <style>
770
770
  ${T.styleWYSIWYG}
771
771
  </style>
772
- </html>`;function thirdPartyToReadThirdPartyEditing(e){return{...e,country:s(e?.idCountry)?i.find(t=>t.id===e.idCountry)?.name?.toUpperCase()??null:null,deliveryCountry:s(e?.deliveryIdCountry)?i.find(t=>t.id===e.deliveryIdCountry)?.name?.toUpperCase()??null:null}}function generateCommercialDocument(e,n,i=!1,a=void 0){let o=v(n.products.map(e=>p(e),`reorder`)),s=v(Object.values(_(o,`vatFormatted`)).map(e=>d(e),`value`)).filter(e=>e.id!==r.MARGE.id),u=thirdPartyToReadThirdPartyEditing(n.thirdParty),T;if(n.advanceProducts?.length){let e=Object.values(_(n.advanceProducts,`vatFormatted`)).map(e=>d(e),`value`).filter(e=>e.id!==r.MARGE.id);T=s.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:h(n),amountFormatted:h(r)}})}let D=b(s,e=>y(e.amount)),O=b(o,`totalTaxExcludedRounded`),k=O+D,A=n.language??`fr`,j=l[A],M=t.find(e=>e.id===n.accountingCategory)?.label??null,N=n.recoveryCost,P={...n,thirdParty:u,paymentLink:n.paymentLink??`#`,idEstimateInvoiceType:e,title:n.title??null,cgv:c(n.cgv)?null:n.cgv,areCgvOnNewPage:n.settings?.areCgvOnNewPage??!0,name:n.name??null,number:n.number??null,street:n.street??null,zipCode:n.zipCode??null,city:n.city??null,legalForm:n.legalForm??null,capital:n.capital??null,siren:n.siren??null,rcs:n.rcs??null,vatCode:n.vatCode??null,nafCode:n.nafCode??null,penalties:n.penalties?m(A,n.penalties,`penalties`)??n.penalties:null,termsOfPayment:n.termsOfPayment?m(A,n.termsOfPayment,`termsOfPayment`)??n.termsOfPayment:null,recoveryCost:N?m(A,N,`recoveryCost`)??N:null,discount:n.discount?m(A,n.discount,`discount`)??n.discount:null,vatMention:n.vatMention?m(A,n.vatMention,`vatMention`)??n.vatMention:null,phoneContact:n.settings?.phoneContact??null,products:o,vats:s,totalTaxExcluded:O,totalTaxIncluded:y(k),totalTaxAndDiscountIncluded:y(k),generalDiscountFormatted:n.generalDiscount2?h(n.generalDiscount2):null,depositFormatted:n.deposit?h(n.deposit):null,totalTaxExcludedFormatted:h(O),totalTaxIncludedFormatted:h(k),totalTaxAndDiscountIncludedFormatted:h(k-(n.generalDiscount2??0)-(n.deposit??0)),totalVatAmountFormatted:h(D),font:{id:n.settings?.idFont??1,name:f.find(e=>e.id===n.settings?.idFont)?.name??f[0].name,url:f.find(e=>e.id===n.settings?.idFont)?.link??f[0].link},capitalFormatted:n.capital?`${n.capital}`.split(``).reduceRight((e,t,n,{length:r})=>`${t}${(r-(n+1))%3==0?` `:``}${e}`,``).trim():null,dueDateFormatted:n.dueDate?S(n.dueDate).format(`DD/MM/YYYY`):null,expirationDateFormatted:n.expirationDate?S(n.expirationDate).format(`DD/MM/YYYY`):null,emissionDateFormatted:n.emissionDate?S(n.emissionDate).format(`DD/MM/YYYY`):null,shouldDisplayDiscountColumn:!!o.find(e=>e.discount2&&e.discount2>0),marginVats:x(o.filter(e=>e.marginVatFormatted!==null).map(e=>e.marginVatFormatted)),accountingCategoryFormatted:M?m(A,M,`accountingCategory`)??null:null,brandColors:g({objectWaited:`colors`,nodeEnv:a}),brandName:`${g({objectWaited:`name`,nodeEnv:a})}`,shouldHideBrandName:i,addressComplement:n.addressComplement??null,paymentType:n.paymentType?m(A,n.paymentType,`paymentType`)??n.paymentType:null,languageTemplate:j},F=new CommercialDocumentCommonHTML,I=[2,3].includes(e)?n?.settings?.freeEstimateText:n?.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??s},{}),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(t,n=!1,r=void 0){let i=t.payload.language??`fr`,a=l[i];S.locale(`fr`);let o={...t.payload,totalTaxExcludedFormatted:e(t.payload.totalTaxExcluded),totalTaxIncludedFormatted:e(t.payload.totalTaxIncluded),totalVatFormatted:e(t.payload.totalTaxIncluded-t.payload.totalTaxExcluded),dueDateFormatted:t.payload.dueDate?S(t.payload.dueDate).format(`DD MMMM YYYY`):null,hasVat:t.hasVat,hostS3:t.hostS3,logoUrl:t.logoUrl,companyName:t.companyName,fileUrl:t.fileUrl,brandColors:g({objectWaited:`colors`,nodeEnv:r}),shouldHideBrandName:n,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=[],i=v(e.products.map(e=>p(e),`reorder`)),a=v(Object.values(_(i,`vatFormatted`)).map(e=>d(e),`value`)).filter(e=>e.id!==r.MARGE.id),s=b(a,e=>y(e.amount)),c=b(i,e=>y(e.totalTaxExcluded)),l=y(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.`},...i.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.`},...a.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=n.find(t=>t.value===e.vatMention)?.taxType??`standard`;if([`margin`,`autoliquidation`,`export`,`exempt`].includes(f))for(let e of i)o(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};
772
+ </html>`;function thirdPartyToReadThirdPartyEditing(e){return{...e,country:s(e?.idCountry)?i.find(t=>t.id===e.idCountry)?.name?.toUpperCase()??null:null,deliveryCountry:s(e?.deliveryIdCountry)?i.find(t=>t.id===e.deliveryIdCountry)?.name?.toUpperCase()??null:null}}function generateCommercialDocument(e,n,i=!1,a=void 0){let o=v(n.products.map(e=>p(e),`reorder`)),s=v(Object.values(_(o,`vatFormatted`)).map(e=>d(e),`value`)).filter(e=>e.id!==r.MARGE.id),u=thirdPartyToReadThirdPartyEditing(n.thirdParty),T;if(n.advanceProducts?.length){let e=Object.values(_(n.advanceProducts,`vatFormatted`)).map(e=>d(e),`value`).filter(e=>e.id!==r.MARGE.id);T=s.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:h(n),amountFormatted:h(r)}})}let D=b(s,e=>y(e.amount)),O=b(o,`totalTaxExcludedRounded`),k=O+D,A=n.language??`fr`,j=l[A],M=t.find(e=>e.id===n.accountingCategory)?.label??null,N=n.recoveryCost,P={...n,thirdParty:u,paymentLink:n.paymentLink??`#`,idEstimateInvoiceType:e,title:n.title??null,cgv:c(n.cgv)?null:n.cgv,areCgvOnNewPage:n.settings?.areCgvOnNewPage??!0,name:n.name??null,number:n.number??null,street:n.street??null,zipCode:n.zipCode??null,city:n.city??null,legalForm:n.legalForm??null,capital:n.capital??null,siren:n.siren??null,rcs:n.rcs??null,vatCode:n.vatCode??null,nafCode:n.nafCode??null,penalties:n.penalties?m(A,n.penalties,`penalties`)??n.penalties:null,termsOfPayment:n.termsOfPayment?m(A,n.termsOfPayment,`termsOfPayment`)??n.termsOfPayment:null,recoveryCost:N?m(A,N,`recoveryCost`)??N:null,discount:n.discount?m(A,n.discount,`discount`)??n.discount:null,vatMention:n.vatMention?m(A,n.vatMention,`vatMention`)??n.vatMention:null,phoneContact:n.settings?.phoneContact??null,products:o,vats:s,totalTaxExcluded:O,totalTaxIncluded:y(k),totalTaxAndDiscountIncluded:y(k),generalDiscountFormatted:n.generalDiscount2?h(n.generalDiscount2):null,depositFormatted:n.deposit?h(n.deposit):null,totalTaxExcludedFormatted:h(O),totalTaxIncludedFormatted:h(k),totalTaxAndDiscountIncludedFormatted:h(k-(n.generalDiscount2??0)-(n.deposit??0)),totalVatAmountFormatted:h(D),font:{id:n.settings?.idFont??1,name:f.find(e=>e.id===n.settings?.idFont)?.name??f[0].name,url:f.find(e=>e.id===n.settings?.idFont)?.link??f[0].link},capitalFormatted:n.capital?`${n.capital}`.split(``).reduceRight((e,t,n,{length:r})=>`${t}${(r-(n+1))%3==0?` `:``}${e}`,``).trim():null,dueDateFormatted:n.dueDate?S(n.dueDate).format(`DD/MM/YYYY`):null,expirationDateFormatted:n.expirationDate?S(n.expirationDate).format(`DD/MM/YYYY`):null,emissionDateFormatted:n.emissionDate?S(n.emissionDate).format(`DD/MM/YYYY`):null,shouldDisplayDiscountColumn:!!o.find(e=>e.discount2&&e.discount2>0),marginVats:x(o.filter(e=>e.marginVatFormatted!==null).map(e=>e.marginVatFormatted)),accountingCategoryFormatted:M?m(A,M,`accountingCategory`)??null:null,brandColors:g({objectWaited:`colors`,nodeEnv:a}),brandName:`${g({objectWaited:`name`,nodeEnv:a})}`,shouldHideBrandName:i,addressComplement:n.addressComplement??null,paymentType:n.paymentType?m(A,n.paymentType,`paymentType`)??n.paymentType:null,languageTemplate:j},F=new CommercialDocumentCommonHTML,I=[2,3].includes(e)?n?.settings?.freeEstimateText:n?.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??s},{}),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(t,n=!1,r=void 0){let i=t.payload.language??`fr`,a=l[i];S.locale(`fr`);let o={...t.payload,totalTaxExcludedFormatted:e(t.payload.totalTaxExcluded),totalTaxIncludedFormatted:e(t.payload.totalTaxIncluded),totalVatFormatted:e(t.payload.totalTaxIncluded-t.payload.totalTaxExcluded),dueDateFormatted:t.payload.dueDate?S(t.payload.dueDate).format(`DD MMMM YYYY`):null,hasVat:t.hasVat,hostS3:t.hostS3,logoUrl:t.logoUrl,companyName:t.companyName,fileUrl:t.fileUrl,brandColors:g({objectWaited:`colors`,nodeEnv:r}),shouldHideBrandName:n,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}const D=`La date d’échéance ne peut pas être antérieure à la date d’émission.`;function checkCommercialDocumentInformation(e){let t=[],i=v(e.products.map(e=>p(e),`reorder`)),a=v(Object.values(_(i,`vatFormatted`)).map(e=>d(e),`value`)).filter(e=>e.id!==r.MARGE.id),s=b(a,e=>y(e.amount)),c=b(i,e=>y(e.totalTaxExcluded)),l=y(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.`},...i.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.`},...a.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=n.find(t=>t.value===e.vatMention)?.taxType??`standard`;if([`margin`,`autoliquidation`,`export`,`exempt`].includes(f))for(let e of i)o(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)),[1,5].includes(e.idEstimateInvoiceType)&&!isMissing(e.dueDate)&&!isMissing(e.emissionDate)&&S(e.dueDate).isBefore(e.emissionDate,`day`)&&t.push(D),{valid:t.length===0,errors:t.length>0?t:void 0}}export{D as DUE_DATE_BEFORE_EMISSION_DATE_ERROR,checkCommercialDocumentInformation,generateCommercialDocument,generateMailHeader,generateSignature,getHoraires};
773
773
  //# sourceMappingURL=index.mjs.map