@silexpert/core 1.0.150 → 1.0.151
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.
- package/es/utils/commercialManagement/document.d.ts.map +1 -1
- package/es/utils/commercialManagement/document.js +1 -1
- package/es/utils/commercialManagement/document.js.map +1 -1
- package/es/utils/commercialManagement/templates/body.js +2 -2
- package/es/utils/commercialManagement/templates/body.js.map +1 -1
- package/es/utils/documents.js +1 -1
- package/es/utils/documents.js.map +1 -1
- package/es/utils/siretValidation.d.ts +1 -0
- package/es/utils/siretValidation.d.ts.map +1 -1
- package/es/utils/siretValidation.js +22 -3
- package/es/utils/siretValidation.js.map +1 -1
- package/js/utils/commercialManagement/document.js +2 -1
- package/js/utils/commercialManagement/document.js.map +1 -1
- package/js/utils/commercialManagement/templates/body.js +2 -2
- package/js/utils/commercialManagement/templates/body.js.map +1 -1
- package/js/utils/documents.js +1 -1
- package/js/utils/documents.js.map +1 -1
- package/js/utils/siretValidation.js +21 -3
- package/js/utils/siretValidation.js.map +1 -1
- package/package.json +1 -1
- package/ts/utils/commercialManagement/document.ts +1 -0
- package/ts/utils/commercialManagement/templates/body.ts +2 -2
- package/ts/utils/documents.ts +1 -1
- package/ts/utils/siretValidation.ts +23 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../../ts/utils/commercialManagement/document.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,8BAA8B,EAAuB,MAAM,qDAAqD,CAAC;AAI1H,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAOvE,OAAO,EACL,qBAAqB,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,0BAA0B,EAC3F,MAAM,aAAa,CAAC;AAgBrB,wBAAgB,0BAA0B,CAAC,qBAAqB,EAAE,mBAAmB,EAAE,OAAO,EAAE,qBAAqB,GAAG,qBAAqB,EAAE,mBAAmB,UAAQ,EAAE,OAAO,GAAE,MAAM,GAAG,SAAqB,GAAG,8BAA8B,
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../../ts/utils/commercialManagement/document.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,8BAA8B,EAAuB,MAAM,qDAAqD,CAAC;AAI1H,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAOvE,OAAO,EACL,qBAAqB,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,0BAA0B,EAC3F,MAAM,aAAa,CAAC;AAgBrB,wBAAgB,0BAA0B,CAAC,qBAAqB,EAAE,mBAAmB,EAAE,OAAO,EAAE,qBAAqB,GAAG,qBAAqB,EAAE,mBAAmB,UAAQ,EAAE,OAAO,GAAE,MAAM,GAAG,SAAqB,GAAG,8BAA8B,CAyFnP;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,UAAQ,EAAE,OAAO,GAAE,MAAM,GAAG,SAAqB,GAAG,8BAA8B,CA0F5K;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,gBAAgB,EAAE,mBAAmB,UAAQ,EAAE,OAAO,GAAE,MAAM,GAAG,SAAqB,GAAG,0BAA0B,CAuB7J"}
|
|
@@ -32,7 +32,7 @@ export function generateCommercialDocument(idEstimateInvoiceType, payload, shoul
|
|
|
32
32
|
.filter((p) => p.marginVatFormatted !== null)
|
|
33
33
|
.map((p) => p.marginVatFormatted)), accountingCategoryFormatted: (_t = (_s = AccountingCategoryList.find((a) => a.id === payload.accountingCategory)) === null || _s === void 0 ? void 0 : _s.label) !== null && _t !== void 0 ? _t : null,
|
|
34
34
|
// @ts-ignore
|
|
35
|
-
brandColors: getBrandConfig({ objectWaited: 'colors', nodeEnv }), brandName: `${getBrandConfig({ objectWaited: 'name', nodeEnv })}`, shouldHideBrandName });
|
|
35
|
+
brandColors: getBrandConfig({ objectWaited: 'colors', nodeEnv }), brandName: `${getBrandConfig({ objectWaited: 'name', nodeEnv })}`, shouldHideBrandName, paymentType: payload.paymentType });
|
|
36
36
|
const commonTemplate = new CommercialDocumentCommonHTML();
|
|
37
37
|
const documentFreeText = [
|
|
38
38
|
EstimateInvoiceType.DEVIS,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.js","sourceRoot":"","sources":["../../../ts/utils/commercialManagement/document.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,IAAI,QAAQ,EAAE,OAAO,IAAI,QAAQ,EAAE,KAAK,IAAI,MAAM,EAAE,IAAI,IAAI,KAAK,GACzE,MAAM,QAAQ,CAAC;AAChB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EACL,sBAAsB,EAAE,OAAO,EAAE,QAAQ,EAAE,mBAAmB,GAC/D,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,8BAA8B,EAAE,8BAA8B,EAAE,MAAM,WAAW,CAAC;AAC3F,OAAO,EAAE,4BAA4B,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAC9F,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,2BAA2B,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAI5C,OAAO,EAAE,iCAAiC,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;AAC3B,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAW3B,MAAM,UAAU,0BAA0B,CAAC,qBAA0C,EAAE,OAAsD,EAAE,mBAAmB,GAAG,KAAK,EAAE,UAA8B,SAAS;;IACjN,MAAM,QAAQ,GAAG,QAAQ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C,gBAAgB,CAAC,EAC1F,iBAAiB,EAAE,8BAA8B,CAAC,MAAM,CAAC,OAAO,CAAC,gBAAgB,GAAG,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,EACpH,gBAAgB,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,IAAI,EACtG,MAAM,EAAE,MAAM,CAAC,MAAM,EACrB,MAAM,EAAE,MAAM,CAAC,MAAM,EACrB,OAAO,EAAE,MAAM,CAAC,OAAO,EACvB,WAAW,EAAE,MAAM,CAAC,WAAW,EAC/B,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,aAAa;QACb,WAAW,EAAE,cAAc,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAmB,EAClF,mBAAmB,GACpB,CAAC;IAEF,MAAM,YAAY,GAAG,IAAI,0BAA0B,EAAE,CAAC;IAEtD,OAAO;QACL,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC;KAC9C,CAAC;AACJ,CAAC","sourcesContent":["import {\n orderBy as _orderBy, groupBy as _groupBy, sumBy as _sumBy, uniq as _uniq,\n} from 'lodash';\nimport * as dayjs from 'dayjs';\nimport { ReadCommercialDocumentTemplate, ReadDocumentEditing } from '../../types/Interface/api/commercialManagement/Read';\nimport {\n AccountingCategoryList, FontIds, fontList, VatMarginCategyList,\n} from '../../types/Enum/CommercialManagement';\nimport { EstimateInvoiceType } from '../../types/Enum/EstimateInvoice';\nimport { Vat } from '../../types/Enum/Vat';\nimport { integerToFormattedAmountString, integerToFormattedAmountObject } from '../amount';\nimport { CommercialDocumentCommonHTML, CommercialDocumentMailHTML } from './templates/common';\nimport { bodyTemplate } from './templates/body';\nimport { productToReadProductEditing } from './product';\nimport { vatToReadVatEditing } from './vat';\nimport {\n CreateInvoiceDocument, CreateMailHeader, CreatePreSaleDocument, ReadCommercialMailTemplate,\n} from '../../types';\nimport { thirdPartyToReadThirdPartyEditing } from './thirdParty';\nimport { getBrandConfig } from '../brands';\n\nconst ejs = require('ejs');\nrequire('dayjs/locale/fr');\n\ntype brandColorType = {\n primary: string,\n primary50: string,\n primary100: string,\n primary300: string,\n primary500: string,\n primary700: string\n};\n\nexport function generateCommercialDocument(idEstimateInvoiceType: EstimateInvoiceType, payload: CreateInvoiceDocument | CreatePreSaleDocument, shouldHideBrandName = false, nodeEnv: string | undefined = undefined): ReadCommercialDocumentTemplate {\n const products = _orderBy(payload.products.map((product) => productToReadProductEditing(product), 'reorder'));\n const vats = _orderBy(Object.values(_groupBy(products, 'vatFormatted')).map((v) => (vatToReadVatEditing(v)), 'value')).filter((v) => v.id !== Vat.MARGE.id);\n const thirdParty = thirdPartyToReadThirdPartyEditing(payload.thirdParty);\n\n const data: ReadDocumentEditing & { brandColors: brandColorType, brandName: string, shouldHideBrandName: boolean } = {\n ...payload,\n thirdParty,\n paymentLink: payload.paymentLink ?? '#',\n idEstimateInvoiceType,\n title: payload.title ?? null,\n penalties: payload.penalties ?? null,\n compensation: payload.compensation ?? null,\n discount: payload.discount ?? null,\n vatMention: payload.vatMention ?? null,\n phoneContact: payload.settings?.phoneContact ?? null,\n products,\n vats,\n totalTaxExcluded: _sumBy(products, 'totalTaxExcluded'),\n totalTaxIncluded: _sumBy(products, 'totalTaxExcluded') + _sumBy(vats, 'amount'),\n totalTaxAndDiscountIncluded: _sumBy(products, 'totalTaxExcluded') + _sumBy(vats, 'amount'),\n generalDiscountFormatted: payload.generalDiscount2 ? integerToFormattedAmountString(payload.generalDiscount2) : null,\n depositFormatted: payload.deposit ? integerToFormattedAmountString(payload.deposit) : null,\n totalTaxExcludedFormatted: integerToFormattedAmountString(_sumBy(products, 'totalTaxExcluded')),\n totalTaxIncludedFormatted: integerToFormattedAmountString(_sumBy(products, 'totalTaxExcluded') + _sumBy(vats, 'amount')),\n totalTaxAndDiscountIncludedFormatted: integerToFormattedAmountString(_sumBy(products, 'totalTaxExcluded') + _sumBy(vats, 'amount') - (payload.generalDiscount2 ?? 0) - (payload.deposit ?? 0)),\n totalVatAmountFormatted: integerToFormattedAmountString(_sumBy(vats, 'amount')),\n font: {\n id: payload.settings?.idFont ?? FontIds.CIRCULAR_STD,\n name: fontList.find((f) => f.id === payload.settings?.idFont)?.name ?? fontList[0].name,\n url: fontList.find((f) => f.id === payload.settings?.idFont)?.link ?? fontList[0].link,\n },\n capitalFormatted: payload.capital\n ? `${payload.capital}`.split('')\n .reduceRight((acc, char, i, { length }) => `${char}${(length - (i + 1)) % 3 === 0 ? ' ' : ''}${acc}`, '')\n .trim()\n : null,\n dueDateFormatted: payload.dueDate ? dayjs(payload.dueDate).format('DD/MM/YYYY') : null,\n expirationDateFormatted: payload.expirationDate ? dayjs(payload.expirationDate).format('DD/MM/YYYY') : null,\n emissionDateFormatted: payload.emissionDate ? dayjs(payload.emissionDate).format('DD/MM/YYYY') : null,\n shouldDisplayDiscountColumn: !!products.find(\n (p) => p.discount2 && p.discount2 > 0,\n ),\n // @ts-ignore\n marginVats: _uniq(\n products\n .filter((p) => p.marginVatFormatted !== null)\n .map((p) => p.marginVatFormatted),\n ),\n accountingCategoryFormatted:\n AccountingCategoryList.find((a) => a.id === payload.accountingCategory)\n ?.label ?? null,\n // @ts-ignore\n brandColors: getBrandConfig({ objectWaited: 'colors', nodeEnv }) as brandColorType,\n brandName: `${getBrandConfig({ objectWaited: 'name', nodeEnv })}`,\n shouldHideBrandName,\n };\n\n const commonTemplate = new CommercialDocumentCommonHTML();\n const documentFreeText = [\n EstimateInvoiceType.DEVIS,\n EstimateInvoiceType.BON,\n ].includes(idEstimateInvoiceType)\n ? payload?.settings?.freeEstimateText\n : payload?.settings?.freeInvoiceText;\n\n return {\n header: ejs.render(commonTemplate.header, data),\n body: ejs.render(bodyTemplate, {\n ...data,\n comment:\n data.comment && typeof data.comment === 'string'\n ? data.comment?.replace(/\\n/g, '<br/>')\n : null,\n products: data.products.map((p) => ({\n ...p,\n comment:\n p.comment && typeof p.comment === 'string'\n ? p.comment?.replace(/\\n/g, '<br/>')\n : null,\n })),\n }),\n footer: ejs.render(commonTemplate.footer, {\n ...data,\n freeText: documentFreeText ?? null,\n }),\n data,\n };\n}\n\nexport function generateAdvanceDocument(payload: CreateInvoiceDocument, shouldHideBrandName = false, nodeEnv: string | undefined = undefined): ReadCommercialDocumentTemplate {\n if (!payload.deposit) throw new Error('Aucun acompte défini');\n\n const data: ReadDocumentEditing & { brandColors: brandColorType, brandName: string, shouldHideBrandName: boolean } = {\n ...payload,\n title: payload.title ?? null,\n paymentLink: payload.paymentLink ?? '#',\n idEstimateInvoiceType: EstimateInvoiceType.ACOMPTE,\n phoneContact: payload.settings?.phoneContact ?? null,\n products: [],\n vats: [],\n totalTaxExcluded: payload.deposit,\n totalTaxIncluded: payload.deposit,\n totalTaxAndDiscountIncluded: payload.deposit,\n generalDiscountFormatted: null,\n depositFormatted: integerToFormattedAmountString(payload.deposit),\n totalTaxExcludedFormatted: integerToFormattedAmountString(payload.deposit),\n totalTaxIncludedFormatted: integerToFormattedAmountString(payload.deposit),\n totalTaxAndDiscountIncludedFormatted: integerToFormattedAmountString(\n payload.deposit,\n ),\n totalVatAmountFormatted: integerToFormattedAmountString(0),\n font: {\n id: payload.settings?.idFont ?? FontIds.CIRCULAR_STD,\n name:\n fontList.find((f) => f.id === payload.settings?.idFont)?.name\n ?? fontList[0].name,\n url:\n fontList.find((f) => f.id === payload.settings?.idFont)?.link\n ?? fontList[0].link,\n },\n capitalFormatted: payload.capital\n ? `${payload.capital}`\n .split('')\n .reduceRight(\n (acc, char, i, { length }) => `${char}${(length - (i + 1)) % 3 === 0 ? ' ' : ''}${acc}`,\n '',\n )\n .trim()\n : null,\n dueDateFormatted: payload.dueDate\n ? dayjs(payload.dueDate).format('DD/MM/YYYY')\n : null,\n expirationDateFormatted: payload.expirationDate\n ? dayjs(payload.expirationDate).format('DD/MM/YYYY')\n : null,\n emissionDateFormatted: payload.emissionDate\n ? dayjs(payload.emissionDate).format('DD/MM/YYYY')\n : null,\n shouldDisplayDiscountColumn: false,\n disableVat: true,\n // @ts-ignore\n marginVats: _uniq(\n (payload.assetMarginVatIds ?? []).map(\n (m) => VatMarginCategyList.find((c) => c.id === m)?.label ?? null,\n ),\n ),\n accountingCategoryFormatted:\n AccountingCategoryList.find((a) => a.id === payload.accountingCategory)\n ?.label ?? null,\n // @ts-ignore\n brandColors: getBrandConfig({ objectWaited: 'colors', nodeEnv }) as brandColorType,\n brandName: `${getBrandConfig({ objectWaited: 'name', nodeEnv })}`,\n shouldHideBrandName,\n };\n\n const commonTemplate = new CommercialDocumentCommonHTML();\n\n return {\n header: ejs?.render(commonTemplate.header, data),\n body: ejs?.render(bodyTemplate, {\n ...data,\n comment:\n data.comment && typeof data.comment === 'string'\n ? data.comment?.replace(/\\n/g, '<br/>')\n : null,\n products: data.products.map((p) => ({\n ...p,\n comment:\n p.comment && typeof p.comment === 'string'\n ? p.comment?.replace(/\\n/g, '<br/>')\n : null,\n })),\n }),\n footer: ejs?.render(commonTemplate.footer, {\n ...data,\n freeText: payload?.settings?.freeInvoiceText ?? null,\n }),\n data,\n };\n}\n\nexport function generateMailHeader(params: CreateMailHeader, shouldHideBrandName = false, nodeEnv: string | undefined = undefined): ReadCommercialMailTemplate {\n dayjs.locale('fr');\n const data = {\n ...params.payload,\n totalTaxExcludedFormatted: integerToFormattedAmountObject(params.payload.totalTaxExcluded),\n totalTaxIncludedFormatted: integerToFormattedAmountObject(params.payload.totalTaxIncluded),\n totalVatFormatted: integerToFormattedAmountObject(params.payload.totalTaxIncluded - params.payload.totalTaxExcluded),\n dueDateFormatted: params.payload.dueDate ? dayjs(params.payload.dueDate).format('DD MMMM YYYY') : null,\n hasVat: params.hasVat,\n hostS3: params.hostS3,\n logoUrl: params.logoUrl,\n companyName: params.companyName,\n fileUrl: params.fileUrl,\n // @ts-ignore\n brandColors: getBrandConfig({ objectWaited: 'colors', nodeEnv }) as brandColorType,\n shouldHideBrandName,\n };\n\n const mailTemplate = new CommercialDocumentMailHTML();\n\n return {\n header: ejs.render(mailTemplate.header, data),\n };\n}"]}
|
|
1
|
+
{"version":3,"file":"document.js","sourceRoot":"","sources":["../../../ts/utils/commercialManagement/document.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,IAAI,QAAQ,EAAE,OAAO,IAAI,QAAQ,EAAE,KAAK,IAAI,MAAM,EAAE,IAAI,IAAI,KAAK,GACzE,MAAM,QAAQ,CAAC;AAChB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EACL,sBAAsB,EAAE,OAAO,EAAE,QAAQ,EAAE,mBAAmB,GAC/D,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,8BAA8B,EAAE,8BAA8B,EAAE,MAAM,WAAW,CAAC;AAC3F,OAAO,EAAE,4BAA4B,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAC9F,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,2BAA2B,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAI5C,OAAO,EAAE,iCAAiC,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;AAC3B,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAW3B,MAAM,UAAU,0BAA0B,CAAC,qBAA0C,EAAE,OAAsD,EAAE,mBAAmB,GAAG,KAAK,EAAE,UAA8B,SAAS;;IACjN,MAAM,QAAQ,GAAG,QAAQ,C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AA8B,CAAC,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAC1F,iBAAiB,EAAE,8BAA8B,CAAC,MAAM,CAAC,OAAO,CAAC,gBAAgB,GAAG,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,EACpH,gBAAgB,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,IAAI,EACtG,MAAM,EAAE,MAAM,CAAC,MAAM,EACrB,MAAM,EAAE,MAAM,CAAC,MAAM,EACrB,OAAO,EAAE,MAAM,CAAC,OAAO,EACvB,WAAW,EAAE,MAAM,CAAC,WAAW,EAC/B,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,aAAa;QACb,WAAW,EAAE,cAAc,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAmB,EAClF,mBAAmB,GACpB,CAAC;IAEF,MAAM,YAAY,GAAG,IAAI,0BAA0B,EAAE,CAAC;IAEtD,OAAO;QACL,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC;KAC9C,CAAC;AACJ,CAAC","sourcesContent":["import {\n orderBy as _orderBy, groupBy as _groupBy, sumBy as _sumBy, uniq as _uniq,\n} from 'lodash';\nimport * as dayjs from 'dayjs';\nimport { ReadCommercialDocumentTemplate, ReadDocumentEditing } from '../../types/Interface/api/commercialManagement/Read';\nimport {\n AccountingCategoryList, FontIds, fontList, VatMarginCategyList,\n} from '../../types/Enum/CommercialManagement';\nimport { EstimateInvoiceType } from '../../types/Enum/EstimateInvoice';\nimport { Vat } from '../../types/Enum/Vat';\nimport { integerToFormattedAmountString, integerToFormattedAmountObject } from '../amount';\nimport { CommercialDocumentCommonHTML, CommercialDocumentMailHTML } from './templates/common';\nimport { bodyTemplate } from './templates/body';\nimport { productToReadProductEditing } from './product';\nimport { vatToReadVatEditing } from './vat';\nimport {\n CreateInvoiceDocument, CreateMailHeader, CreatePreSaleDocument, ReadCommercialMailTemplate,\n} from '../../types';\nimport { thirdPartyToReadThirdPartyEditing } from './thirdParty';\nimport { getBrandConfig } from '../brands';\n\nconst ejs = require('ejs');\nrequire('dayjs/locale/fr');\n\ntype brandColorType = {\n primary: string,\n primary50: string,\n primary100: string,\n primary300: string,\n primary500: string,\n primary700: string\n};\n\nexport function generateCommercialDocument(idEstimateInvoiceType: EstimateInvoiceType, payload: CreateInvoiceDocument | CreatePreSaleDocument, shouldHideBrandName = false, nodeEnv: string | undefined = undefined): ReadCommercialDocumentTemplate {\n const products = _orderBy(payload.products.map((product) => productToReadProductEditing(product), 'reorder'));\n const vats = _orderBy(Object.values(_groupBy(products, 'vatFormatted')).map((v) => (vatToReadVatEditing(v)), 'value')).filter((v) => v.id !== Vat.MARGE.id);\n const thirdParty = thirdPartyToReadThirdPartyEditing(payload.thirdParty);\n\n const data: ReadDocumentEditing & { brandColors: brandColorType, brandName: string, shouldHideBrandName: boolean } = {\n ...payload,\n thirdParty,\n paymentLink: payload.paymentLink ?? '#',\n idEstimateInvoiceType,\n title: payload.title ?? null,\n penalties: payload.penalties ?? null,\n compensation: payload.compensation ?? null,\n discount: payload.discount ?? null,\n vatMention: payload.vatMention ?? null,\n phoneContact: payload.settings?.phoneContact ?? null,\n products,\n vats,\n totalTaxExcluded: _sumBy(products, 'totalTaxExcluded'),\n totalTaxIncluded: _sumBy(products, 'totalTaxExcluded') + _sumBy(vats, 'amount'),\n totalTaxAndDiscountIncluded: _sumBy(products, 'totalTaxExcluded') + _sumBy(vats, 'amount'),\n generalDiscountFormatted: payload.generalDiscount2 ? integerToFormattedAmountString(payload.generalDiscount2) : null,\n depositFormatted: payload.deposit ? integerToFormattedAmountString(payload.deposit) : null,\n totalTaxExcludedFormatted: integerToFormattedAmountString(_sumBy(products, 'totalTaxExcluded')),\n totalTaxIncludedFormatted: integerToFormattedAmountString(_sumBy(products, 'totalTaxExcluded') + _sumBy(vats, 'amount')),\n totalTaxAndDiscountIncludedFormatted: integerToFormattedAmountString(_sumBy(products, 'totalTaxExcluded') + _sumBy(vats, 'amount') - (payload.generalDiscount2 ?? 0) - (payload.deposit ?? 0)),\n totalVatAmountFormatted: integerToFormattedAmountString(_sumBy(vats, 'amount')),\n font: {\n id: payload.settings?.idFont ?? FontIds.CIRCULAR_STD,\n name: fontList.find((f) => f.id === payload.settings?.idFont)?.name ?? fontList[0].name,\n url: fontList.find((f) => f.id === payload.settings?.idFont)?.link ?? fontList[0].link,\n },\n capitalFormatted: payload.capital\n ? `${payload.capital}`.split('')\n .reduceRight((acc, char, i, { length }) => `${char}${(length - (i + 1)) % 3 === 0 ? ' ' : ''}${acc}`, '')\n .trim()\n : null,\n dueDateFormatted: payload.dueDate ? dayjs(payload.dueDate).format('DD/MM/YYYY') : null,\n expirationDateFormatted: payload.expirationDate ? dayjs(payload.expirationDate).format('DD/MM/YYYY') : null,\n emissionDateFormatted: payload.emissionDate ? dayjs(payload.emissionDate).format('DD/MM/YYYY') : null,\n shouldDisplayDiscountColumn: !!products.find(\n (p) => p.discount2 && p.discount2 > 0,\n ),\n // @ts-ignore\n marginVats: _uniq(\n products\n .filter((p) => p.marginVatFormatted !== null)\n .map((p) => p.marginVatFormatted),\n ),\n accountingCategoryFormatted:\n AccountingCategoryList.find((a) => a.id === payload.accountingCategory)\n ?.label ?? null,\n // @ts-ignore\n brandColors: getBrandConfig({ objectWaited: 'colors', nodeEnv }) as brandColorType,\n brandName: `${getBrandConfig({ objectWaited: 'name', nodeEnv })}`,\n shouldHideBrandName,\n paymentType: payload.paymentType,\n };\n\n const commonTemplate = new CommercialDocumentCommonHTML();\n const documentFreeText = [\n EstimateInvoiceType.DEVIS,\n EstimateInvoiceType.BON,\n ].includes(idEstimateInvoiceType)\n ? payload?.settings?.freeEstimateText\n : payload?.settings?.freeInvoiceText;\n\n return {\n header: ejs.render(commonTemplate.header, data),\n body: ejs.render(bodyTemplate, {\n ...data,\n comment:\n data.comment && typeof data.comment === 'string'\n ? data.comment?.replace(/\\n/g, '<br/>')\n : null,\n products: data.products.map((p) => ({\n ...p,\n comment:\n p.comment && typeof p.comment === 'string'\n ? p.comment?.replace(/\\n/g, '<br/>')\n : null,\n })),\n }),\n footer: ejs.render(commonTemplate.footer, {\n ...data,\n freeText: documentFreeText ?? null,\n }),\n data,\n };\n}\n\nexport function generateAdvanceDocument(payload: CreateInvoiceDocument, shouldHideBrandName = false, nodeEnv: string | undefined = undefined): ReadCommercialDocumentTemplate {\n if (!payload.deposit) throw new Error('Aucun acompte défini');\n\n const data: ReadDocumentEditing & { brandColors: brandColorType, brandName: string, shouldHideBrandName: boolean } = {\n ...payload,\n title: payload.title ?? null,\n paymentLink: payload.paymentLink ?? '#',\n idEstimateInvoiceType: EstimateInvoiceType.ACOMPTE,\n phoneContact: payload.settings?.phoneContact ?? null,\n products: [],\n vats: [],\n totalTaxExcluded: payload.deposit,\n totalTaxIncluded: payload.deposit,\n totalTaxAndDiscountIncluded: payload.deposit,\n generalDiscountFormatted: null,\n depositFormatted: integerToFormattedAmountString(payload.deposit),\n totalTaxExcludedFormatted: integerToFormattedAmountString(payload.deposit),\n totalTaxIncludedFormatted: integerToFormattedAmountString(payload.deposit),\n totalTaxAndDiscountIncludedFormatted: integerToFormattedAmountString(\n payload.deposit,\n ),\n totalVatAmountFormatted: integerToFormattedAmountString(0),\n font: {\n id: payload.settings?.idFont ?? FontIds.CIRCULAR_STD,\n name:\n fontList.find((f) => f.id === payload.settings?.idFont)?.name\n ?? fontList[0].name,\n url:\n fontList.find((f) => f.id === payload.settings?.idFont)?.link\n ?? fontList[0].link,\n },\n capitalFormatted: payload.capital\n ? `${payload.capital}`\n .split('')\n .reduceRight(\n (acc, char, i, { length }) => `${char}${(length - (i + 1)) % 3 === 0 ? ' ' : ''}${acc}`,\n '',\n )\n .trim()\n : null,\n dueDateFormatted: payload.dueDate\n ? dayjs(payload.dueDate).format('DD/MM/YYYY')\n : null,\n expirationDateFormatted: payload.expirationDate\n ? dayjs(payload.expirationDate).format('DD/MM/YYYY')\n : null,\n emissionDateFormatted: payload.emissionDate\n ? dayjs(payload.emissionDate).format('DD/MM/YYYY')\n : null,\n shouldDisplayDiscountColumn: false,\n disableVat: true,\n // @ts-ignore\n marginVats: _uniq(\n (payload.assetMarginVatIds ?? []).map(\n (m) => VatMarginCategyList.find((c) => c.id === m)?.label ?? null,\n ),\n ),\n accountingCategoryFormatted:\n AccountingCategoryList.find((a) => a.id === payload.accountingCategory)\n ?.label ?? null,\n // @ts-ignore\n brandColors: getBrandConfig({ objectWaited: 'colors', nodeEnv }) as brandColorType,\n brandName: `${getBrandConfig({ objectWaited: 'name', nodeEnv })}`,\n shouldHideBrandName,\n };\n\n const commonTemplate = new CommercialDocumentCommonHTML();\n\n return {\n header: ejs?.render(commonTemplate.header, data),\n body: ejs?.render(bodyTemplate, {\n ...data,\n comment:\n data.comment && typeof data.comment === 'string'\n ? data.comment?.replace(/\\n/g, '<br/>')\n : null,\n products: data.products.map((p) => ({\n ...p,\n comment:\n p.comment && typeof p.comment === 'string'\n ? p.comment?.replace(/\\n/g, '<br/>')\n : null,\n })),\n }),\n footer: ejs?.render(commonTemplate.footer, {\n ...data,\n freeText: payload?.settings?.freeInvoiceText ?? null,\n }),\n data,\n };\n}\n\nexport function generateMailHeader(params: CreateMailHeader, shouldHideBrandName = false, nodeEnv: string | undefined = undefined): ReadCommercialMailTemplate {\n dayjs.locale('fr');\n const data = {\n ...params.payload,\n totalTaxExcludedFormatted: integerToFormattedAmountObject(params.payload.totalTaxExcluded),\n totalTaxIncludedFormatted: integerToFormattedAmountObject(params.payload.totalTaxIncluded),\n totalVatFormatted: integerToFormattedAmountObject(params.payload.totalTaxIncluded - params.payload.totalTaxExcluded),\n dueDateFormatted: params.payload.dueDate ? dayjs(params.payload.dueDate).format('DD MMMM YYYY') : null,\n hasVat: params.hasVat,\n hostS3: params.hostS3,\n logoUrl: params.logoUrl,\n companyName: params.companyName,\n fileUrl: params.fileUrl,\n // @ts-ignore\n brandColors: getBrandConfig({ objectWaited: 'colors', nodeEnv }) as brandColorType,\n shouldHideBrandName,\n };\n\n const mailTemplate = new CommercialDocumentMailHTML();\n\n return {\n header: ejs.render(mailTemplate.header, data),\n };\n}"]}
|
|
@@ -96,10 +96,10 @@ export const bodyTemplate = `<html class="pdf-content">
|
|
|
96
96
|
|
|
97
97
|
</div>
|
|
98
98
|
|
|
99
|
-
<% if (settings && (settings.iban || settings.bic || settings.bank || paymentType)
|
|
99
|
+
<% if ((settings && (settings.iban || settings.bic || settings.bank)) || paymentType) { %>
|
|
100
100
|
<div class="row mt-30 space-between" style="page-break-inside: avoid !important;">
|
|
101
101
|
<div>
|
|
102
|
-
<% if (settings && (settings.iban || settings.bic || settings.bank || paymentType)
|
|
102
|
+
<% if ((settings && (settings.iban || settings.bic || settings.bank)) || paymentType) { %>
|
|
103
103
|
<% if(paymentType) { %>Mode de paiement : <%= paymentType %><br/><% } %>
|
|
104
104
|
<% if(settings.bank) { %>BANQUE : <%= settings.bank %><br/><% } %>
|
|
105
105
|
<% if(settings.iban) { %>IBAN : <%= settings.iban %><br/><% } %>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"body.js","sourceRoot":"","sources":["../../../../ts/utils/commercialManagement/templates/body.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAExD,MAAM,cAAc,GAAG,IAAI,4BAA4B,EAAE,CAAC;AAE1D,MAAM,cAAc,GAAG;;;YAGX,cAAc,CAAC,IAAI;YACnB,cAAc,CAAC,OAAO;;;4CAGU,cAAc,CAAC,OAAO;UACxD,cAAc,CAAC,IAAI;;;;;;;yCAOY,mBAAmB,CAAC,GAAG;;gDAEhB,mBAAmB,CAAC,KAAK;;gDAEzB,mBAAmB,CAAC,OAAO;;gDAE3B,mBAAmB,CAAC,KAAK;;gDAEzB,mBAAmB,CAAC,KAAK;;gDAEzB,mBAAmB,CAAC,OAAO;;;;;mDAKxB,mBAAmB,CAAC,OAAO;;oBAE1D,mBAAmB,CAAC,GAAG,KAAK,mBAAmB,CAAC,KAAK;;;;;;;2DAOd,mBAAmB,CAAC,OAAO;;;;mDAInC,mBAAmB,CAAC,GAAG,KAAK,mBAAmB,CAAC,KAAK;;;;;;;;;;;;;;;;;SAiB/F,CAAC;AAEV,MAAM,CAAC,MAAM,YAAY,GAAG;;;;IAIxB,cAAc;;;;;;6BAMW,cAAc,CAAC,QAAQ;;;;;YAKxC,cAAc,CAAC,iBAAiB;;;;;;;;;;UAUlC,cAAc,CAAC,oBAAoB;;;8DAGiB,cAAc,CAAC,aAAa;;;;;;;;;;;;;;;;;;wEAkBlB,mBAAmB,CAAC,KAAK,iCAAiC,mBAAmB,CAAC,GAAG;;;;oFAIrE,mBAAmB,CAAC,KAAK,iCAAiC,mBAAmB,CAAC,GAAG;;;;;;;QAO7J,cAAc,CAAC,KAAK;;;QAGpB,cAAc,CAAC,YAAY;;QAE3B,CAAC","sourcesContent":["import { EstimateInvoiceType } from '../../../types/Enum/EstimateInvoice';\nimport { CommercialDocumentCommonHTML } from './common';\n\nconst commonTemplate = new CommercialDocumentCommonHTML();\n\nconst headOfDocument = `<div class=\"row space-between\">\n <% if (settings && settings.logoAlignment === 'left') { %>\n <div class=\"society-informations\">\n ${commonTemplate.logo}\n ${commonTemplate.company}\n </div>\n <% } else { %>\n <div class=\"society-informations\">${commonTemplate.company}</div>\n ${commonTemplate.logo}\n <% } %>\n </div>\n\n <div class=\"row space-between items-end\" style=\"margin-top: 10px\">\n <div style=\"width: 45%; margin-top: auto;\">\n <span class=\"document-reference\">\n <% if (idEstimateInvoiceType === ${EstimateInvoiceType.BON}) { %>\n Bon de commande\n <% } else if (idEstimateInvoiceType === ${EstimateInvoiceType.DEVIS}) { %>\n Devis\n <% } else if (idEstimateInvoiceType === ${EstimateInvoiceType.FACTURE}) { %>\n Facture\n <% } else if (idEstimateInvoiceType === ${EstimateInvoiceType.AVOIR}) { %>\n Avoir\n <% } else if (idEstimateInvoiceType === ${EstimateInvoiceType.RESTE}) { %>\n Facture de solde\n <% } else if (idEstimateInvoiceType === ${EstimateInvoiceType.ACOMPTE}) { %>\n Facture d'acompte\n <% } %>\n <%= reference %></span><br/>\n <% if(emissionDate) {%><span class=\"document-emission-date\">Date d’émission : <%= emissionDateFormatted %></span><br/><% } %>\n <% if(dueDate && idEstimateInvoiceType !== ${EstimateInvoiceType.ACOMPTE}) {%>\n <span class=\"document-due-date\">\n <% if ([${EstimateInvoiceType.BON}, ${EstimateInvoiceType.DEVIS}].includes(idEstimateInvoiceType)) {%>\n Valide jusqu'au :\n <% } else { %>\n Date d'échéance :\n <% } %>\n <%= dueDateFormatted %></span>\n <% } %>\n <% if (expirationDate && idEstimateInvoiceType === ${EstimateInvoiceType.ACOMPTE}) {%>\n <span class=\"document-due-date\">Date d'expiration : <%= expirationDateFormatted %></span>\n <% } %>\n <% if(termsOfPayment) { %>\n <br/><p style=\"margin-bottom: 0px;\"><%= [${EstimateInvoiceType.BON}, ${EstimateInvoiceType.DEVIS}].includes(idEstimateInvoiceType) ? 'Conditions de règlement' : 'Date limite de règlement' %> : <%= termsOfPayment %></p>\n <% } %>\n </div>\n <div style=\"width: 40%; margin-top: auto;\">\n <p></p>\n <% if (thirdParty) { %>\n <div class=\"<%= settings && settings.isCoordinatesFrameDisplayed ? 'customer-border' : '' %>\">\n <% if(thirdParty.company) {%><b><%= thirdParty.company %></b><br/><% } %>\n <% if(thirdParty.fullname) {%><%= thirdParty.fullname %><br/><% } %>\n <% if(thirdParty.address) {%><%= thirdParty.address %><br/><% } %>\n <% if(thirdParty.zipCode) {%><%= thirdParty.zipCode + ' ' %><% } %><%= thirdParty.city %> <%= thirdParty.country %><br/>\n <% if(thirdParty.deliveryAddress && thirdParty.deliveryCity && thirdParty.deliveryZipCode) {%>Adresse de livraison : <%= thirdParty.deliveryAddress %> <%= thirdParty.deliveryZipCode %> <%= thirdParty.deliveryCity %> <%= thirdParty.deliveryCountry %><br/><% } %>\n <% if(thirdParty.nSiret) {%>SIRET : <%= thirdParty.nSiret %><br/><% } %>\n <% if(thirdParty.nTva) {%>N° TVA : <%= thirdParty.nTva %><% } %>\n </div>\n <% } %>\n </div>\n </div>`;\n\nexport const bodyTemplate = `<html class=\"pdf-content\">\n\n <body>\n\n ${headOfDocument}\n\n <div class=\"row mt-25\">\n <% if (title) { %>Titre : <%= title %><% } %>\n </div>\n\n <div class=\"row mt-10\">${commonTemplate.products}</div>\n\n <div class=\"row space-between mt-20\">\n <div style=\"width: 55%;\">\n <% if (disableVat !== true && vats.length) { %>\n ${commonTemplate.vatRecapitulation}\n <% } %>\n <% if (vatMention) { %><div class=\"vat-mention <%= disableVat !== true ? 'mt-20' : ''%>\"><%= vatMention %></div><% } %>\n <% if (comment) { %>\n <p class=\"mt-20\">Commentaire :<br/>\n <%- comment %>\n <% } %>\n </div>\n\n <div>\n ${commonTemplate.amountRecapitulation}\n\n <% if (isStripeAllowed) { %>\n <div style=\"text-align: right; margin-top: 30px;\">${commonTemplate.paymentButton}</div>\n <% } %>\n </div>\n \n </div>\n\n <% if (settings && (settings.iban || settings.bic || settings.bank || paymentType)
|
|
1
|
+
{"version":3,"file":"body.js","sourceRoot":"","sources":["../../../../ts/utils/commercialManagement/templates/body.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAExD,MAAM,cAAc,GAAG,IAAI,4BAA4B,EAAE,CAAC;AAE1D,MAAM,cAAc,GAAG;;;YAGX,cAAc,CAAC,IAAI;YACnB,cAAc,CAAC,OAAO;;;4CAGU,cAAc,CAAC,OAAO;UACxD,cAAc,CAAC,IAAI;;;;;;;yCAOY,mBAAmB,CAAC,GAAG;;gDAEhB,mBAAmB,CAAC,KAAK;;gDAEzB,mBAAmB,CAAC,OAAO;;gDAE3B,mBAAmB,CAAC,KAAK;;gDAEzB,mBAAmB,CAAC,KAAK;;gDAEzB,mBAAmB,CAAC,OAAO;;;;;mDAKxB,mBAAmB,CAAC,OAAO;;oBAE1D,mBAAmB,CAAC,GAAG,KAAK,mBAAmB,CAAC,KAAK;;;;;;;2DAOd,mBAAmB,CAAC,OAAO;;;;mDAInC,mBAAmB,CAAC,GAAG,KAAK,mBAAmB,CAAC,KAAK;;;;;;;;;;;;;;;;;SAiB/F,CAAC;AAEV,MAAM,CAAC,MAAM,YAAY,GAAG;;;;IAIxB,cAAc;;;;;;6BAMW,cAAc,CAAC,QAAQ;;;;;YAKxC,cAAc,CAAC,iBAAiB;;;;;;;;;;UAUlC,cAAc,CAAC,oBAAoB;;;8DAGiB,cAAc,CAAC,aAAa;;;;;;;;;;;;;;;;;;wEAkBlB,mBAAmB,CAAC,KAAK,iCAAiC,mBAAmB,CAAC,GAAG;;;;oFAIrE,mBAAmB,CAAC,KAAK,iCAAiC,mBAAmB,CAAC,GAAG;;;;;;;QAO7J,cAAc,CAAC,KAAK;;;QAGpB,cAAc,CAAC,YAAY;;QAE3B,CAAC","sourcesContent":["import { EstimateInvoiceType } from '../../../types/Enum/EstimateInvoice';\nimport { CommercialDocumentCommonHTML } from './common';\n\nconst commonTemplate = new CommercialDocumentCommonHTML();\n\nconst headOfDocument = `<div class=\"row space-between\">\n <% if (settings && settings.logoAlignment === 'left') { %>\n <div class=\"society-informations\">\n ${commonTemplate.logo}\n ${commonTemplate.company}\n </div>\n <% } else { %>\n <div class=\"society-informations\">${commonTemplate.company}</div>\n ${commonTemplate.logo}\n <% } %>\n </div>\n\n <div class=\"row space-between items-end\" style=\"margin-top: 10px\">\n <div style=\"width: 45%; margin-top: auto;\">\n <span class=\"document-reference\">\n <% if (idEstimateInvoiceType === ${EstimateInvoiceType.BON}) { %>\n Bon de commande\n <% } else if (idEstimateInvoiceType === ${EstimateInvoiceType.DEVIS}) { %>\n Devis\n <% } else if (idEstimateInvoiceType === ${EstimateInvoiceType.FACTURE}) { %>\n Facture\n <% } else if (idEstimateInvoiceType === ${EstimateInvoiceType.AVOIR}) { %>\n Avoir\n <% } else if (idEstimateInvoiceType === ${EstimateInvoiceType.RESTE}) { %>\n Facture de solde\n <% } else if (idEstimateInvoiceType === ${EstimateInvoiceType.ACOMPTE}) { %>\n Facture d'acompte\n <% } %>\n <%= reference %></span><br/>\n <% if(emissionDate) {%><span class=\"document-emission-date\">Date d’émission : <%= emissionDateFormatted %></span><br/><% } %>\n <% if(dueDate && idEstimateInvoiceType !== ${EstimateInvoiceType.ACOMPTE}) {%>\n <span class=\"document-due-date\">\n <% if ([${EstimateInvoiceType.BON}, ${EstimateInvoiceType.DEVIS}].includes(idEstimateInvoiceType)) {%>\n Valide jusqu'au :\n <% } else { %>\n Date d'échéance :\n <% } %>\n <%= dueDateFormatted %></span>\n <% } %>\n <% if (expirationDate && idEstimateInvoiceType === ${EstimateInvoiceType.ACOMPTE}) {%>\n <span class=\"document-due-date\">Date d'expiration : <%= expirationDateFormatted %></span>\n <% } %>\n <% if(termsOfPayment) { %>\n <br/><p style=\"margin-bottom: 0px;\"><%= [${EstimateInvoiceType.BON}, ${EstimateInvoiceType.DEVIS}].includes(idEstimateInvoiceType) ? 'Conditions de règlement' : 'Date limite de règlement' %> : <%= termsOfPayment %></p>\n <% } %>\n </div>\n <div style=\"width: 40%; margin-top: auto;\">\n <p></p>\n <% if (thirdParty) { %>\n <div class=\"<%= settings && settings.isCoordinatesFrameDisplayed ? 'customer-border' : '' %>\">\n <% if(thirdParty.company) {%><b><%= thirdParty.company %></b><br/><% } %>\n <% if(thirdParty.fullname) {%><%= thirdParty.fullname %><br/><% } %>\n <% if(thirdParty.address) {%><%= thirdParty.address %><br/><% } %>\n <% if(thirdParty.zipCode) {%><%= thirdParty.zipCode + ' ' %><% } %><%= thirdParty.city %> <%= thirdParty.country %><br/>\n <% if(thirdParty.deliveryAddress && thirdParty.deliveryCity && thirdParty.deliveryZipCode) {%>Adresse de livraison : <%= thirdParty.deliveryAddress %> <%= thirdParty.deliveryZipCode %> <%= thirdParty.deliveryCity %> <%= thirdParty.deliveryCountry %><br/><% } %>\n <% if(thirdParty.nSiret) {%>SIRET : <%= thirdParty.nSiret %><br/><% } %>\n <% if(thirdParty.nTva) {%>N° TVA : <%= thirdParty.nTva %><% } %>\n </div>\n <% } %>\n </div>\n </div>`;\n\nexport const bodyTemplate = `<html class=\"pdf-content\">\n\n <body>\n\n ${headOfDocument}\n\n <div class=\"row mt-25\">\n <% if (title) { %>Titre : <%= title %><% } %>\n </div>\n\n <div class=\"row mt-10\">${commonTemplate.products}</div>\n\n <div class=\"row space-between mt-20\">\n <div style=\"width: 55%;\">\n <% if (disableVat !== true && vats.length) { %>\n ${commonTemplate.vatRecapitulation}\n <% } %>\n <% if (vatMention) { %><div class=\"vat-mention <%= disableVat !== true ? 'mt-20' : ''%>\"><%= vatMention %></div><% } %>\n <% if (comment) { %>\n <p class=\"mt-20\">Commentaire :<br/>\n <%- comment %>\n <% } %>\n </div>\n\n <div>\n ${commonTemplate.amountRecapitulation}\n\n <% if (isStripeAllowed) { %>\n <div style=\"text-align: right; margin-top: 30px;\">${commonTemplate.paymentButton}</div>\n <% } %>\n </div>\n \n </div>\n\n <% if ((settings && (settings.iban || settings.bic || settings.bank)) || paymentType) { %>\n <div class=\"row mt-30 space-between\" style=\"page-break-inside: avoid !important;\">\n <div>\n <% if ((settings && (settings.iban || settings.bic || settings.bank)) || paymentType) { %>\n <% if(paymentType) { %>Mode de paiement : <%= paymentType %><br/><% } %>\n <% if(settings.bank) { %>BANQUE : <%= settings.bank %><br/><% } %>\n <% if(settings.iban) { %>IBAN : <%= settings.iban %><br/><% } %>\n <% if(settings.bic) { %>BIC : <%= settings.bic %><% } %>\n <% } %>\n </div>\n </div>\n <% } %>\n <% if (settings && settings.bonPour && (idEstimateInvoiceType === ${EstimateInvoiceType.DEVIS} || idEstimateInvoiceType === ${EstimateInvoiceType.BON})) { %>\n <br/>Bon pour accord : <br/><br/><br/><br/>\n <% } %>\n\n <% if (cgv && ((settings && settings.invoiceCgv) || idEstimateInvoiceType === ${EstimateInvoiceType.DEVIS} || idEstimateInvoiceType === ${EstimateInvoiceType.BON})) { %>\n <br><div style=\"page-break-after:always;\"></div>\n <div id=\"WYSIWYG\"><%- cgv %></div>\n <% } %>\n </body>\n\n <style>\n ${commonTemplate.style}\n </style>\n <style>\n ${commonTemplate.styleWYSIWYG}\n </style>\n</html>`;\n"]}
|
package/es/utils/documents.js
CHANGED
|
@@ -11,7 +11,7 @@ const requiredListDocs = (idLegalForm, isOnlyPrevi, isOnlyJuridic, isOnlySocial,
|
|
|
11
11
|
if ([LegalForm.SAS.id, LegalForm.SA.id].includes(idLegalForm)) {
|
|
12
12
|
generique.push(GedFileType.DISTRIBUTION_OF_SHARE);
|
|
13
13
|
}
|
|
14
|
-
if ([LegalForm.EURL.id, LegalForm.SASU.id, LegalForm.SA.id, LegalForm.SAS.id, LegalForm.SARL.id, LegalForm.SCI.id].includes(idLegalForm)) {
|
|
14
|
+
if ([LegalForm.EURL.id, LegalForm.SASU.id, LegalForm.SA.id, LegalForm.SAS.id, LegalForm.SARL.id, LegalForm.SCI.id, LegalForm.EARL.id].includes(idLegalForm)) {
|
|
15
15
|
return [...generique, GedFileType.KBIS, GedFileType.STATUTES, GedFileType.DBE2, GedFileType.SEPA];
|
|
16
16
|
}
|
|
17
17
|
if ([LegalForm.SELARL.id].includes(idLegalForm)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documents.js","sourceRoot":"","sources":["../../ts/utils/documents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,MAAM,gBAAgB,GAAG,CAAC,WAAmB,EAAE,WAAqB,EAAE,a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,EAAE,CAAC,EAAE,EAAE,SAAS,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;QAC3E,OAAO,CAAC,GAAG,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;KAC7D;IACD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;QAC7C,OAAO,CAAC,GAAG,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;KACpF;IACD,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;QACpD,OAAO,CAAC,GAAG,SAAS,EAAE,WAAW,CAAC,kBAAkB,EAAE,WAAW,CAAC,iDAAiD,EAAE,WAAW,CAAC,iCAAiC,CAAC,CAAC;KACrK;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF,OAAO,EACL,gBAAgB,GACjB,CAAC","sourcesContent":["import { GedFileType } from '../types/Enum/Ged';\nimport { LegalForm } from '../types/Enum/LegalForm';\n\nconst requiredListDocs = (idLegalForm: number, isOnlyPrevi?: boolean, isOnlyJuridic?: boolean, isOnlySocial?: boolean, isCreation?: boolean): GedFileType[] => {\n if (isOnlyPrevi) {\n return [GedFileType.IDENTITY_CARD, GedFileType.PLAQUETTE, GedFileType.RIB, GedFileType.SEPA];\n }\n if (isCreation || isOnlyJuridic || isOnlySocial) {\n return [GedFileType.RIB, GedFileType.PLAQUETTE];\n }\n\n const generique = [GedFileType.IDENTITY_CARD, GedFileType.RIB, GedFileType.PLAQUETTE];\n\n if ([LegalForm.SAS.id, LegalForm.SA.id].includes(idLegalForm)) {\n generique.push(GedFileType.DISTRIBUTION_OF_SHARE);\n }\n\n if ([LegalForm.EURL.id, LegalForm.SASU.id, LegalForm.SA.id, LegalForm.SAS.id, LegalForm.SARL.id, LegalForm.SCI.id, LegalForm.EARL.id].includes(idLegalForm)) {\n return [...generique, GedFileType.KBIS, GedFileType.STATUTES, GedFileType.DBE2, GedFileType.SEPA];\n }\n if ([LegalForm.SELARL.id].includes(idLegalForm)) {\n return [...generique, GedFileType.KBIS, GedFileType.STATUTES, GedFileType.SEPA];\n }\n if ([LegalForm.EI.id, LegalForm.AUTO_ENTREPRENEUR.id].includes(idLegalForm)) {\n return [...generique, GedFileType.SIRENE, GedFileType.SEPA];\n }\n if ([LegalForm.EIRL.id].includes(idLegalForm)) {\n return [...generique, GedFileType.SIRENE, GedFileType.SEPA, GedFileType.PATRIMONY];\n }\n if ([LegalForm.ASSOCIATION.id].includes(idLegalForm)) {\n return [...generique, GedFileType.RULES_OF_PROCEDURE, GedFileType.REGISTRATION_OF_THE_ASSOCIATION_AT_THE_PREFECTURE, GedFileType.REPRESENTATIVE_OF_THE_ASSOCIATION];\n }\n return generique;\n};\n\nexport {\n requiredListDocs,\n};"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export declare function validateSiren(siren: string): void;
|
|
1
2
|
export declare function validateSiret(siret: string): void;
|
|
2
3
|
export declare function getVatCodeBySiren(siren: string, countryCode?: string): string;
|
|
3
4
|
export declare function siretToSiren(siret: string, idCountry?: number): string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"siretValidation.d.ts","sourceRoot":"","sources":["../../ts/utils/siretValidation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"siretValidation.d.ts","sourceRoot":"","sources":["../../ts/utils/siretValidation.ts"],"names":[],"mappings":"AAIA,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,QAiB1C;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,QA2B1C;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,SAAO,GAAG,MAAM,CAI3E;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQ7E"}
|
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
import { isDefined } from 'class-validator';
|
|
2
2
|
import { CountryId } from '../types/Enum/Country';
|
|
3
|
+
// Function to validate SIREN (9 digits)
|
|
4
|
+
export function validateSiren(siren) {
|
|
5
|
+
if (!/^\d{9}$/.test(siren))
|
|
6
|
+
throw new Error('Format du SIREN invalide');
|
|
7
|
+
const sirenArray = Array.from(siren).map(Number).reverse();
|
|
8
|
+
const luhnSum = sirenArray.reduce((acc, v, i) => {
|
|
9
|
+
if (i % 2 === 1) {
|
|
10
|
+
const currentVal = v * 2;
|
|
11
|
+
if (currentVal > 9) {
|
|
12
|
+
const array = Array.from(currentVal.toString());
|
|
13
|
+
return acc + Number(array[0]) + Number(array[1]);
|
|
14
|
+
}
|
|
15
|
+
return acc + currentVal;
|
|
16
|
+
}
|
|
17
|
+
return acc + v;
|
|
18
|
+
}, 0);
|
|
19
|
+
if (luhnSum % 10 !== 0)
|
|
20
|
+
throw new Error('SIREN invalide');
|
|
21
|
+
}
|
|
3
22
|
export function validateSiret(siret) {
|
|
4
23
|
if (!/^\d{14}$/.test(siret))
|
|
5
|
-
throw new Error('
|
|
24
|
+
throw new Error('Format du SIRET invalide');
|
|
6
25
|
const siretArray = Array.from(siret).map(Number).reverse();
|
|
7
26
|
const luhnSum = siretArray.reduce((acc, v, i) => {
|
|
8
27
|
if (i % 2 === 1) {
|
|
@@ -20,11 +39,11 @@ export function validateSiret(siret) {
|
|
|
20
39
|
if (siret.startsWith('356000000')) {
|
|
21
40
|
const sum = siretArray.reduce((acc, v) => acc + v, 0);
|
|
22
41
|
if (sum % 5 !== 0) {
|
|
23
|
-
throw new Error('
|
|
42
|
+
throw new Error('SIRET invalide');
|
|
24
43
|
}
|
|
25
44
|
}
|
|
26
45
|
else {
|
|
27
|
-
throw new Error('
|
|
46
|
+
throw new Error('SIRET invalide');
|
|
28
47
|
}
|
|
29
48
|
}
|
|
30
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"siretValidation.js","sourceRoot":"","sources":["../../ts/utils/siretValidation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,MAAM,UAAU,aAAa,CAAC,KAAa;IACzC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"siretValidation.js","sourceRoot":"","sources":["../../ts/utils/siretValidation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,wCAAwC;AACxC,MAAM,UAAU,aAAa,CAAC,KAAa;IACzC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAExE,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC;IAC3D,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE;QAC9C,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;YACf,MAAM,UAAU,GAAG,CAAC,GAAG,CAAC,CAAC;YACzB,IAAI,UAAU,GAAG,CAAC,EAAE;gBAClB,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC;gBAChD,OAAO,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CA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,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;YACtD,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,EAAE;gBACjB,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;aACnC;SACF;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;SACnC;KACF;AACH,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,KAAa,EAAE,WAAW,GAAG,IAAI;IACjE,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC5C,aAAa;IACb,OAAO,GAAG,WAAW,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,UAAU,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,UAAU,EAAE,CAAC;AAC3E,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAa,EAAE,SAAkB;IAC5D,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3C,IAAI,SAAS,CAAC,SAAS,CAAC,IAAI,SAAS,KAAK,SAAS,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IACzE,IAAI,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACrC,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;QAC7B,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;KAC/B;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { isDefined } from 'class-validator';\nimport { CountryId } from '../types/Enum/Country';\n\n// Function to validate SIREN (9 digits)\nexport function validateSiren(siren: string) {\n if (!/^\\d{9}$/.test(siren)) throw new Error('Format du SIREN invalide');\n\n const sirenArray = Array.from(siren).map(Number).reverse();\n const luhnSum = sirenArray.reduce((acc, v, i) => {\n if (i % 2 === 1) {\n const currentVal = v * 2;\n if (currentVal > 9) {\n const array = Array.from(currentVal.toString());\n return acc + Number(array[0]) + Number(array[1]);\n }\n return acc + currentVal;\n }\n return acc + v;\n }, 0);\n\n if (luhnSum % 10 !== 0) throw new Error('SIREN invalide');\n}\n\nexport function validateSiret(siret: string) {\n if (!/^\\d{14}$/.test(siret)) throw new Error('Format du SIRET invalide');\n\n const siretArray = Array.from(siret).map(Number).reverse();\n const luhnSum = siretArray.reduce((acc, v, i) => {\n if (i % 2 === 1) {\n const currentVal = v * 2;\n if (currentVal > 9) {\n const array = Array.from(currentVal.toString());\n return acc + Number(array[0]) + Number(array[1]);\n }\n return acc + currentVal;\n }\n return acc + v;\n }, 0);\n\n if (luhnSum % 10 !== 0) {\n // Specific rule for some La Poste SIRET\n if (siret.startsWith('356000000')) {\n const sum = siretArray.reduce((acc, v) => acc + v, 0);\n if (sum % 5 !== 0) {\n throw new Error('SIRET invalide');\n }\n } else {\n throw new Error('SIRET invalide');\n }\n }\n}\n\nexport function getVatCodeBySiren(siren: string, countryCode = 'FR'): string {\n const validSiren = siren.replace(/\\s/g, '');\n // @ts-ignore\n return `${countryCode}${[12 + 3 * (validSiren % 97)] % 97}${validSiren}`;\n}\n\nexport function siretToSiren(siret: string, idCountry?: number): string | null {\n if (typeof siret !== 'string') return null;\n if (isDefined(idCountry) && idCountry !== CountryId.FRANCE) return siret;\n let siren = siret.replace(/ */g, '');\n if (siren && siren.length > 9) {\n siren = siren.substring(0, 9);\n }\n return siren;\n}"]}
|
|
@@ -79,7 +79,8 @@ function generateCommercialDocument(idEstimateInvoiceType, payload, shouldHideBr
|
|
|
79
79
|
objectWaited: 'name',
|
|
80
80
|
nodeEnv
|
|
81
81
|
})}`,
|
|
82
|
-
shouldHideBrandName
|
|
82
|
+
shouldHideBrandName,
|
|
83
|
+
paymentType: payload.paymentType
|
|
83
84
|
});
|
|
84
85
|
const commonTemplate = new _common.CommercialDocumentCommonHTML();
|
|
85
86
|
const documentFreeText = [_EstimateInvoice.EstimateInvoiceType.DEVIS, _EstimateInvoice.EstimateInvoiceType.BON].includes(idEstimateInvoiceType) ? (_u = payload === null || payload === void 0 ? void 0 : payload.settings) === null || _u === void 0 ? void 0 : _u.freeEstimateText : (_v = payload === null || payload === void 0 ? void 0 : payload.settings) === null || _v === void 0 ? void 0 : _v.freeInvoiceText;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.js","names":["generateCommercialDocument","exports","generateAdvanceDocument","generateMailHeader","_lodash","require","_dayjs","dayjs","_interopRequireWildcard","_CommercialManagement","_EstimateInvoice","_Vat","_amount","_common","_body","_product","_vat","_thirdParty","_brands","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","ejs","idEstimateInvoiceType","payload","shouldHideBrandName","nodeEnv","undefined","products","_orderBy","map","product","productToReadProductEditing","vats","values","_groupBy","v","vatToReadVatEditing","filter","id","Vat","MARGE","thirdParty","thirdPartyToReadThirdPartyEditing","data","assign","paymentLink","_a","title","_b","penalties","_c","compensation","_d","discount","_e","vatMention","_f","phoneContact","_h","_g","settings","totalTaxExcluded","_sumBy","totalTaxIncluded","totalTaxAndDiscountIncluded","generalDiscountFormatted","generalDiscount2","integerToFormattedAmountString","depositFormatted","deposit","totalTaxExcludedFormatted","totalTaxIncludedFormatted","totalTaxAndDiscountIncludedFormatted","_j","_k","totalVatAmountFormatted","font","_m","_l","idFont","FontIds","CIRCULAR_STD","name","_p","_o","fontList","find","f","url","_r","_q","link","capitalFormatted","capital","split","reduceRight","acc","char","i","length","trim","dueDateFormatted","dueDate","format","expirationDateFormatted","expirationDate","emissionDateFormatted","emissionDate","shouldDisplayDiscountColumn","p","discount2","marginVats","_uniq","marginVatFormatted","accountingCategoryFormatted","_t","_s","AccountingCategoryList","a","accountingCategory","label","brandColors","getBrandConfig","objectWaited","brandName","commonTemplate","CommercialDocumentCommonHTML","documentFreeText","EstimateInvoiceType","DEVIS","BON","includes","_u","freeEstimateText","_v","freeInvoiceText","header","render","body","bodyTemplate","comment","_w","replace","footer","freeText","Error","ACOMPTE","disableVat","assetMarginVatIds","m","VatMarginCategyList","c","params","locale","integerToFormattedAmountObject","totalVatFormatted","hasVat","hostS3","logoUrl","companyName","fileUrl","mailTemplate","CommercialDocumentMailHTML"],"sources":["../../../ts/utils/commercialManagement/document.ts"],"sourcesContent":["import {\n orderBy as _orderBy, groupBy as _groupBy, sumBy as _sumBy, uniq as _uniq,\n} from 'lodash';\nimport * as dayjs from 'dayjs';\nimport { ReadCommercialDocumentTemplate, ReadDocumentEditing } from '../../types/Interface/api/commercialManagement/Read';\nimport {\n AccountingCategoryList, FontIds, fontList, VatMarginCategyList,\n} from '../../types/Enum/CommercialManagement';\nimport { EstimateInvoiceType } from '../../types/Enum/EstimateInvoice';\nimport { Vat } from '../../types/Enum/Vat';\nimport { integerToFormattedAmountString, integerToFormattedAmountObject } from '../amount';\nimport { CommercialDocumentCommonHTML, CommercialDocumentMailHTML } from './templates/common';\nimport { bodyTemplate } from './templates/body';\nimport { productToReadProductEditing } from './product';\nimport { vatToReadVatEditing } from './vat';\nimport {\n CreateInvoiceDocument, CreateMailHeader, CreatePreSaleDocument, ReadCommercialMailTemplate,\n} from '../../types';\nimport { thirdPartyToReadThirdPartyEditing } from './thirdParty';\nimport { getBrandConfig } from '../brands';\n\nconst ejs = require('ejs');\nrequire('dayjs/locale/fr');\n\ntype brandColorType = {\n primary: string,\n primary50: string,\n primary100: string,\n primary300: string,\n primary500: string,\n primary700: string\n};\n\nexport function generateCommercialDocument(idEstimateInvoiceType: EstimateInvoiceType, payload: CreateInvoiceDocument | CreatePreSaleDocument, shouldHideBrandName = false, nodeEnv: string | undefined = undefined): ReadCommercialDocumentTemplate {\n const products = _orderBy(payload.products.map((product) => productToReadProductEditing(product), 'reorder'));\n const vats = _orderBy(Object.values(_groupBy(products, 'vatFormatted')).map((v) => (vatToReadVatEditing(v)), 'value')).filter((v) => v.id !== Vat.MARGE.id);\n const thirdParty = thirdPartyToReadThirdPartyEditing(payload.thirdParty);\n\n const data: ReadDocumentEditing & { brandColors: brandColorType, brandName: string, shouldHideBrandName: boolean } = {\n ...payload,\n thirdParty,\n paymentLink: payload.paymentLink ?? '#',\n idEstimateInvoiceType,\n title: payload.title ?? null,\n penalties: payload.penalties ?? null,\n compensation: payload.compensation ?? null,\n discount: payload.discount ?? null,\n vatMention: payload.vatMention ?? null,\n phoneContact: payload.settings?.phoneContact ?? null,\n products,\n vats,\n totalTaxExcluded: _sumBy(products, 'totalTaxExcluded'),\n totalTaxIncluded: _sumBy(products, 'totalTaxExcluded') + _sumBy(vats, 'amount'),\n totalTaxAndDiscountIncluded: _sumBy(products, 'totalTaxExcluded') + _sumBy(vats, 'amount'),\n generalDiscountFormatted: payload.generalDiscount2 ? integerToFormattedAmountString(payload.generalDiscount2) : null,\n depositFormatted: payload.deposit ? integerToFormattedAmountString(payload.deposit) : null,\n totalTaxExcludedFormatted: integerToFormattedAmountString(_sumBy(products, 'totalTaxExcluded')),\n totalTaxIncludedFormatted: integerToFormattedAmountString(_sumBy(products, 'totalTaxExcluded') + _sumBy(vats, 'amount')),\n totalTaxAndDiscountIncludedFormatted: integerToFormattedAmountString(_sumBy(products, 'totalTaxExcluded') + _sumBy(vats, 'amount') - (payload.generalDiscount2 ?? 0) - (payload.deposit ?? 0)),\n totalVatAmountFormatted: integerToFormattedAmountString(_sumBy(vats, 'amount')),\n font: {\n id: payload.settings?.idFont ?? FontIds.CIRCULAR_STD,\n name: fontList.find((f) => f.id === payload.settings?.idFont)?.name ?? fontList[0].name,\n url: fontList.find((f) => f.id === payload.settings?.idFont)?.link ?? fontList[0].link,\n },\n capitalFormatted: payload.capital\n ? `${payload.capital}`.split('')\n .reduceRight((acc, char, i, { length }) => `${char}${(length - (i + 1)) % 3 === 0 ? ' ' : ''}${acc}`, '')\n .trim()\n : null,\n dueDateFormatted: payload.dueDate ? dayjs(payload.dueDate).format('DD/MM/YYYY') : null,\n expirationDateFormatted: payload.expirationDate ? dayjs(payload.expirationDate).format('DD/MM/YYYY') : null,\n emissionDateFormatted: payload.emissionDate ? dayjs(payload.emissionDate).format('DD/MM/YYYY') : null,\n shouldDisplayDiscountColumn: !!products.find(\n (p) => p.discount2 && p.discount2 > 0,\n ),\n // @ts-ignore\n marginVats: _uniq(\n products\n .filter((p) => p.marginVatFormatted !== null)\n .map((p) => p.marginVatFormatted),\n ),\n accountingCategoryFormatted:\n AccountingCategoryList.find((a) => a.id === payload.accountingCategory)\n ?.label ?? null,\n // @ts-ignore\n brandColors: getBrandConfig({ objectWaited: 'colors', nodeEnv }) as brandColorType,\n brandName: `${getBrandConfig({ objectWaited: 'name', nodeEnv })}`,\n shouldHideBrandName,\n };\n\n const commonTemplate = new CommercialDocumentCommonHTML();\n const documentFreeText = [\n EstimateInvoiceType.DEVIS,\n EstimateInvoiceType.BON,\n ].includes(idEstimateInvoiceType)\n ? payload?.settings?.freeEstimateText\n : payload?.settings?.freeInvoiceText;\n\n return {\n header: ejs.render(commonTemplate.header, data),\n body: ejs.render(bodyTemplate, {\n ...data,\n comment:\n data.comment && typeof data.comment === 'string'\n ? data.comment?.replace(/\\n/g, '<br/>')\n : null,\n products: data.products.map((p) => ({\n ...p,\n comment:\n p.comment && typeof p.comment === 'string'\n ? p.comment?.replace(/\\n/g, '<br/>')\n : null,\n })),\n }),\n footer: ejs.render(commonTemplate.footer, {\n ...data,\n freeText: documentFreeText ?? null,\n }),\n data,\n };\n}\n\nexport function generateAdvanceDocument(payload: CreateInvoiceDocument, shouldHideBrandName = false, nodeEnv: string | undefined = undefined): ReadCommercialDocumentTemplate {\n if (!payload.deposit) throw new Error('Aucun acompte défini');\n\n const data: ReadDocumentEditing & { brandColors: brandColorType, brandName: string, shouldHideBrandName: boolean } = {\n ...payload,\n title: payload.title ?? null,\n paymentLink: payload.paymentLink ?? '#',\n idEstimateInvoiceType: EstimateInvoiceType.ACOMPTE,\n phoneContact: payload.settings?.phoneContact ?? null,\n products: [],\n vats: [],\n totalTaxExcluded: payload.deposit,\n totalTaxIncluded: payload.deposit,\n totalTaxAndDiscountIncluded: payload.deposit,\n generalDiscountFormatted: null,\n depositFormatted: integerToFormattedAmountString(payload.deposit),\n totalTaxExcludedFormatted: integerToFormattedAmountString(payload.deposit),\n totalTaxIncludedFormatted: integerToFormattedAmountString(payload.deposit),\n totalTaxAndDiscountIncludedFormatted: integerToFormattedAmountString(\n payload.deposit,\n ),\n totalVatAmountFormatted: integerToFormattedAmountString(0),\n font: {\n id: payload.settings?.idFont ?? FontIds.CIRCULAR_STD,\n name:\n fontList.find((f) => f.id === payload.settings?.idFont)?.name\n ?? fontList[0].name,\n url:\n fontList.find((f) => f.id === payload.settings?.idFont)?.link\n ?? fontList[0].link,\n },\n capitalFormatted: payload.capital\n ? `${payload.capital}`\n .split('')\n .reduceRight(\n (acc, char, i, { length }) => `${char}${(length - (i + 1)) % 3 === 0 ? ' ' : ''}${acc}`,\n '',\n )\n .trim()\n : null,\n dueDateFormatted: payload.dueDate\n ? dayjs(payload.dueDate).format('DD/MM/YYYY')\n : null,\n expirationDateFormatted: payload.expirationDate\n ? dayjs(payload.expirationDate).format('DD/MM/YYYY')\n : null,\n emissionDateFormatted: payload.emissionDate\n ? dayjs(payload.emissionDate).format('DD/MM/YYYY')\n : null,\n shouldDisplayDiscountColumn: false,\n disableVat: true,\n // @ts-ignore\n marginVats: _uniq(\n (payload.assetMarginVatIds ?? []).map(\n (m) => VatMarginCategyList.find((c) => c.id === m)?.label ?? null,\n ),\n ),\n accountingCategoryFormatted:\n AccountingCategoryList.find((a) => a.id === payload.accountingCategory)\n ?.label ?? null,\n // @ts-ignore\n brandColors: getBrandConfig({ objectWaited: 'colors', nodeEnv }) as brandColorType,\n brandName: `${getBrandConfig({ objectWaited: 'name', nodeEnv })}`,\n shouldHideBrandName,\n };\n\n const commonTemplate = new CommercialDocumentCommonHTML();\n\n return {\n header: ejs?.render(commonTemplate.header, data),\n body: ejs?.render(bodyTemplate, {\n ...data,\n comment:\n data.comment && typeof data.comment === 'string'\n ? data.comment?.replace(/\\n/g, '<br/>')\n : null,\n products: data.products.map((p) => ({\n ...p,\n comment:\n p.comment && typeof p.comment === 'string'\n ? p.comment?.replace(/\\n/g, '<br/>')\n : null,\n })),\n }),\n footer: ejs?.render(commonTemplate.footer, {\n ...data,\n freeText: payload?.settings?.freeInvoiceText ?? null,\n }),\n data,\n };\n}\n\nexport function generateMailHeader(params: CreateMailHeader, shouldHideBrandName = false, nodeEnv: string | undefined = undefined): ReadCommercialMailTemplate {\n dayjs.locale('fr');\n const data = {\n ...params.payload,\n totalTaxExcludedFormatted: integerToFormattedAmountObject(params.payload.totalTaxExcluded),\n totalTaxIncludedFormatted: integerToFormattedAmountObject(params.payload.totalTaxIncluded),\n totalVatFormatted: integerToFormattedAmountObject(params.payload.totalTaxIncluded - params.payload.totalTaxExcluded),\n dueDateFormatted: params.payload.dueDate ? dayjs(params.payload.dueDate).format('DD MMMM YYYY') : null,\n hasVat: params.hasVat,\n hostS3: params.hostS3,\n logoUrl: params.logoUrl,\n companyName: params.companyName,\n fileUrl: params.fileUrl,\n // @ts-ignore\n brandColors: getBrandConfig({ objectWaited: 'colors', nodeEnv }) as brandColorType,\n shouldHideBrandName,\n };\n\n const mailTemplate = new CommercialDocumentMailHTML();\n\n return {\n header: ejs.render(mailTemplate.header, data),\n };\n}"],"mappings":";;;;;QAiCgBA,0BAA0B,GAA1BA,0BAA0B;AAAAC,OAAA,CA0F1BC,uBAAuB,GAAvBA,uBAAuB;AAAAD,OAAA,CA4FvBE,kBAAkB,GAAlBA,kBAAkB;AAvNlC,IAAAC,OAAA,GAAAC,OAAA;AAGA,IAAAC,MAAA,GAAAD,OAAA;AAA+B,IAAnBE,KAAK,GAAAC,uBAAA,CAAAF,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AK,EAAEC,OAAA,GAA8BC,SAAS;EAC/HvC,KAAK,CAACsK,MAAM,CAAC,IAAI,CAAC;EAClB,MAAM9G,IAAI,GAAA/B,MAAA,CAAAgC,MAAA,CAAAhC,MAAA,CAAAgC,MAAA,KACL4G,MAAM,CAACjI,OAAO;IACjB+C,yBAAyB,EAAE,IAAAoF,sCAA8B,EAACF,MAAM,CAACjI,OAAO,CAACsC,gBAAgB,CAAC;IAC1FU,yBAAyB,EAAE,IAAAmF,sCAA8B,EAACF,MAAM,CAACjI,OAAO,CAACwC,gBAAgB,CAAC;IAC1F4F,iBAAiB,EAAE,IAAAD,sCAA8B,EAACF,MAAM,CAACjI,OAAO,CAACwC,gBAAgB,GAAGyF,MAAM,CAACjI,OAAO,CAACsC,gBAAgB,CAAC;IACpHwC,gBAAgB,EAAEmD,MAAM,CAACjI,OAAO,CAAC+E,OAAO,GAAGnH,KAAK,CAACqK,MAAM,CAACjI,OAAO,CAAC+E,OAAO,CAAC,CAACC,MAAM,CAAC,cAAc,CAAC,GAAG,IAAI;IACtGqD,MAAM,EAAEJ,MAAM,CAACI,MAAM;IACrBC,MAAM,EAAEL,MAAM,CAACK,MAAM;IACrBC,OAAO,EAAEN,MAAM,CAACM,OAAO;IACvBC,WAAW,EAAEP,MAAM,CAACO,WAAW;IAC/BC,OAAO,EAAER,MAAM,CAACQ,OAAO;IACvB;IACAvC,WAAW,EAAE,IAAAC,sBAAc,EAAC;MAAEC,YAAY,EAAE,QAAQ;MAAElG;IAAO,CAAE,CAAmB;IAClFD;EAAmB,EACpB;EAED,MAAMyI,YAAY,GAAG,IAAIC,kCAA0B,EAAE;EAErD,OAAO;IACL1B,MAAM,EAAEnH,GAAG,CAACoH,MAAM,CAACwB,YAAY,CAACzB,MAAM,EAAE7F,IAAI;GAC7C;AACH"}
|
|
1
|
+
{"version":3,"file":"document.js","names":["generateCommercialDocument","exports","generateAdvanceDocument","generateMailHeader","_lodash","require","_dayjs","dayjs","_interopRequireWildcard","_CommercialManagement","_EstimateInvoice","_Vat","_amount","_common","_body","_product","_vat","_thirdParty","_brands","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","ejs","idEstimateInvoiceType","payload","shouldHideBrandName","nodeEnv","undefined","products","_orderBy","map","product","productToReadProductEditing","vats","values","_groupBy","v","vatToReadVatEditing","filter","id","Vat","MARGE","thirdParty","thirdPartyToReadThirdPartyEditing","data","assign","paymentLink","_a","title","_b","penalties","_c","compensation","_d","discount","_e","vatMention","_f","phoneContact","_h","_g","settings","totalTaxExcluded","_sumBy","totalTaxIncluded","totalTaxAndDiscountIncluded","generalDiscountFormatted","generalDiscount2","integerToFormattedAmountString","depositFormatted","deposit","totalTaxExcludedFormatted","totalTaxIncludedFormatted","totalTaxAndDiscountIncludedFormatted","_j","_k","totalVatAmountFormatted","font","_m","_l","idFont","FontIds","CIRCULAR_STD","name","_p","_o","fontList","find","f","url","_r","_q","link","capitalFormatted","capital","split","reduceRight","acc","char","i","length","trim","dueDateFormatted","dueDate","format","expirationDateFormatted","expirationDate","emissionDateFormatted","emissionDate","shouldDisplayDiscountColumn","p","discount2","marginVats","_uniq","marginVatFormatted","accountingCategoryFormatted","_t","_s","AccountingCategoryList","a","accountingCategory","label","brandColors","getBrandConfig","objectWaited","brandName","paymentType","commonTemplate","CommercialDocumentCommonHTML","documentFreeText","EstimateInvoiceType","DEVIS","BON","includes","_u","freeEstimateText","_v","freeInvoiceText","header","render","body","bodyTemplate","comment","_w","replace","footer","freeText","Error","ACOMPTE","disableVat","assetMarginVatIds","m","VatMarginCategyList","c","params","locale","integerToFormattedAmountObject","totalVatFormatted","hasVat","hostS3","logoUrl","companyName","fileUrl","mailTemplate","CommercialDocumentMailHTML"],"sources":["../../../ts/utils/commercialManagement/document.ts"],"sourcesContent":["import {\n orderBy as _orderBy, groupBy as _groupBy, sumBy as _sumBy, uniq as _uniq,\n} from 'lodash';\nimport * as dayjs from 'dayjs';\nimport { ReadCommercialDocumentTemplate, ReadDocumentEditing } from '../../types/Interface/api/commercialManagement/Read';\nimport {\n AccountingCategoryList, FontIds, fontList, VatMarginCategyList,\n} from '../../types/Enum/CommercialManagement';\nimport { EstimateInvoiceType } from '../../types/Enum/EstimateInvoice';\nimport { Vat } from '../../types/Enum/Vat';\nimport { integerToFormattedAmountString, integerToFormattedAmountObject } from '../amount';\nimport { CommercialDocumentCommonHTML, CommercialDocumentMailHTML } from './templates/common';\nimport { bodyTemplate } from './templates/body';\nimport { productToReadProductEditing } from './product';\nimport { vatToReadVatEditing } from './vat';\nimport {\n CreateInvoiceDocument, CreateMailHeader, CreatePreSaleDocument, ReadCommercialMailTemplate,\n} from '../../types';\nimport { thirdPartyToReadThirdPartyEditing } from './thirdParty';\nimport { getBrandConfig } from '../brands';\n\nconst ejs = require('ejs');\nrequire('dayjs/locale/fr');\n\ntype brandColorType = {\n primary: string,\n primary50: string,\n primary100: string,\n primary300: string,\n primary500: string,\n primary700: string\n};\n\nexport function generateCommercialDocument(idEstimateInvoiceType: EstimateInvoiceType, payload: CreateInvoiceDocument | CreatePreSaleDocument, shouldHideBrandName = false, nodeEnv: string | undefined = undefined): ReadCommercialDocumentTemplate {\n const products = _orderBy(payload.products.map((product) => productToReadProductEditing(product), 'reorder'));\n const vats = _orderBy(Object.values(_groupBy(products, 'vatFormatted')).map((v) => (vatToReadVatEditing(v)), 'value')).filter((v) => v.id !== Vat.MARGE.id);\n const thirdParty = thirdPartyToReadThirdPartyEditing(payload.thirdParty);\n\n const data: ReadDocumentEditing & { brandColors: brandColorType, brandName: string, shouldHideBrandName: boolean } = {\n ...payload,\n thirdParty,\n paymentLink: payload.paymentLink ?? '#',\n idEstimateInvoiceType,\n title: payload.title ?? null,\n penalties: payload.penalties ?? null,\n compensation: payload.compensation ?? null,\n discount: payload.discount ?? null,\n vatMention: payload.vatMention ?? null,\n phoneContact: payload.settings?.phoneContact ?? null,\n products,\n vats,\n totalTaxExcluded: _sumBy(products, 'totalTaxExcluded'),\n totalTaxIncluded: _sumBy(products, 'totalTaxExcluded') + _sumBy(vats, 'amount'),\n totalTaxAndDiscountIncluded: _sumBy(products, 'totalTaxExcluded') + _sumBy(vats, 'amount'),\n generalDiscountFormatted: payload.generalDiscount2 ? integerToFormattedAmountString(payload.generalDiscount2) : null,\n depositFormatted: payload.deposit ? integerToFormattedAmountString(payload.deposit) : null,\n totalTaxExcludedFormatted: integerToFormattedAmountString(_sumBy(products, 'totalTaxExcluded')),\n totalTaxIncludedFormatted: integerToFormattedAmountString(_sumBy(products, 'totalTaxExcluded') + _sumBy(vats, 'amount')),\n totalTaxAndDiscountIncludedFormatted: integerToFormattedAmountString(_sumBy(products, 'totalTaxExcluded') + _sumBy(vats, 'amount') - (payload.generalDiscount2 ?? 0) - (payload.deposit ?? 0)),\n totalVatAmountFormatted: integerToFormattedAmountString(_sumBy(vats, 'amount')),\n font: {\n id: payload.settings?.idFont ?? FontIds.CIRCULAR_STD,\n name: fontList.find((f) => f.id === payload.settings?.idFont)?.name ?? fontList[0].name,\n url: fontList.find((f) => f.id === payload.settings?.idFont)?.link ?? fontList[0].link,\n },\n capitalFormatted: payload.capital\n ? `${payload.capital}`.split('')\n .reduceRight((acc, char, i, { length }) => `${char}${(length - (i + 1)) % 3 === 0 ? ' ' : ''}${acc}`, '')\n .trim()\n : null,\n dueDateFormatted: payload.dueDate ? dayjs(payload.dueDate).format('DD/MM/YYYY') : null,\n expirationDateFormatted: payload.expirationDate ? dayjs(payload.expirationDate).format('DD/MM/YYYY') : null,\n emissionDateFormatted: payload.emissionDate ? dayjs(payload.emissionDate).format('DD/MM/YYYY') : null,\n shouldDisplayDiscountColumn: !!products.find(\n (p) => p.discount2 && p.discount2 > 0,\n ),\n // @ts-ignore\n marginVats: _uniq(\n products\n .filter((p) => p.marginVatFormatted !== null)\n .map((p) => p.marginVatFormatted),\n ),\n accountingCategoryFormatted:\n AccountingCategoryList.find((a) => a.id === payload.accountingCategory)\n ?.label ?? null,\n // @ts-ignore\n brandColors: getBrandConfig({ objectWaited: 'colors', nodeEnv }) as brandColorType,\n brandName: `${getBrandConfig({ objectWaited: 'name', nodeEnv })}`,\n shouldHideBrandName,\n paymentType: payload.paymentType,\n };\n\n const commonTemplate = new CommercialDocumentCommonHTML();\n const documentFreeText = [\n EstimateInvoiceType.DEVIS,\n EstimateInvoiceType.BON,\n ].includes(idEstimateInvoiceType)\n ? payload?.settings?.freeEstimateText\n : payload?.settings?.freeInvoiceText;\n\n return {\n header: ejs.render(commonTemplate.header, data),\n body: ejs.render(bodyTemplate, {\n ...data,\n comment:\n data.comment && typeof data.comment === 'string'\n ? data.comment?.replace(/\\n/g, '<br/>')\n : null,\n products: data.products.map((p) => ({\n ...p,\n comment:\n p.comment && typeof p.comment === 'string'\n ? p.comment?.replace(/\\n/g, '<br/>')\n : null,\n })),\n }),\n footer: ejs.render(commonTemplate.footer, {\n ...data,\n freeText: documentFreeText ?? null,\n }),\n data,\n };\n}\n\nexport function generateAdvanceDocument(payload: CreateInvoiceDocument, shouldHideBrandName = false, nodeEnv: string | undefined = undefined): ReadCommercialDocumentTemplate {\n if (!payload.deposit) throw new Error('Aucun acompte défini');\n\n const data: ReadDocumentEditing & { brandColors: brandColorType, brandName: string, shouldHideBrandName: boolean } = {\n ...payload,\n title: payload.title ?? null,\n paymentLink: payload.paymentLink ?? '#',\n idEstimateInvoiceType: EstimateInvoiceType.ACOMPTE,\n phoneContact: payload.settings?.phoneContact ?? null,\n products: [],\n vats: [],\n totalTaxExcluded: payload.deposit,\n totalTaxIncluded: payload.deposit,\n totalTaxAndDiscountIncluded: payload.deposit,\n generalDiscountFormatted: null,\n depositFormatted: integerToFormattedAmountString(payload.deposit),\n totalTaxExcludedFormatted: integerToFormattedAmountString(payload.deposit),\n totalTaxIncludedFormatted: integerToFormattedAmountString(payload.deposit),\n totalTaxAndDiscountIncludedFormatted: integerToFormattedAmountString(\n payload.deposit,\n ),\n totalVatAmountFormatted: integerToFormattedAmountString(0),\n font: {\n id: payload.settings?.idFont ?? FontIds.CIRCULAR_STD,\n name:\n fontList.find((f) => f.id === payload.settings?.idFont)?.name\n ?? fontList[0].name,\n url:\n fontList.find((f) => f.id === payload.settings?.idFont)?.link\n ?? fontList[0].link,\n },\n capitalFormatted: payload.capital\n ? `${payload.capital}`\n .split('')\n .reduceRight(\n (acc, char, i, { length }) => `${char}${(length - (i + 1)) % 3 === 0 ? ' ' : ''}${acc}`,\n '',\n )\n .trim()\n : null,\n dueDateFormatted: payload.dueDate\n ? dayjs(payload.dueDate).format('DD/MM/YYYY')\n : null,\n expirationDateFormatted: payload.expirationDate\n ? dayjs(payload.expirationDate).format('DD/MM/YYYY')\n : null,\n emissionDateFormatted: payload.emissionDate\n ? dayjs(payload.emissionDate).format('DD/MM/YYYY')\n : null,\n shouldDisplayDiscountColumn: false,\n disableVat: true,\n // @ts-ignore\n marginVats: _uniq(\n (payload.assetMarginVatIds ?? []).map(\n (m) => VatMarginCategyList.find((c) => c.id === m)?.label ?? null,\n ),\n ),\n accountingCategoryFormatted:\n AccountingCategoryList.find((a) => a.id === payload.accountingCategory)\n ?.label ?? null,\n // @ts-ignore\n brandColors: getBrandConfig({ objectWaited: 'colors', nodeEnv }) as brandColorType,\n brandName: `${getBrandConfig({ objectWaited: 'name', nodeEnv })}`,\n shouldHideBrandName,\n };\n\n const commonTemplate = new CommercialDocumentCommonHTML();\n\n return {\n header: ejs?.render(commonTemplate.header, data),\n body: ejs?.render(bodyTemplate, {\n ...data,\n comment:\n data.comment && typeof data.comment === 'string'\n ? data.comment?.replace(/\\n/g, '<br/>')\n : null,\n products: data.products.map((p) => ({\n ...p,\n comment:\n p.comment && typeof p.comment === 'string'\n ? p.comment?.replace(/\\n/g, '<br/>')\n : null,\n })),\n }),\n footer: ejs?.render(commonTemplate.footer, {\n ...data,\n freeText: payload?.settings?.freeInvoiceText ?? null,\n }),\n data,\n };\n}\n\nexport function generateMailHeader(params: CreateMailHeader, shouldHideBrandName = false, nodeEnv: string | undefined = undefined): ReadCommercialMailTemplate {\n dayjs.locale('fr');\n const data = {\n ...params.payload,\n totalTaxExcludedFormatted: integerToFormattedAmountObject(params.payload.totalTaxExcluded),\n totalTaxIncludedFormatted: integerToFormattedAmountObject(params.payload.totalTaxIncluded),\n totalVatFormatted: integerToFormattedAmountObject(params.payload.totalTaxIncluded - params.payload.totalTaxExcluded),\n dueDateFormatted: params.payload.dueDate ? dayjs(params.payload.dueDate).format('DD MMMM YYYY') : null,\n hasVat: params.hasVat,\n hostS3: params.hostS3,\n logoUrl: params.logoUrl,\n companyName: params.companyName,\n fileUrl: params.fileUrl,\n // @ts-ignore\n brandColors: getBrandConfig({ objectWaited: 'colors', nodeEnv }) as brandColorType,\n shouldHideBrandName,\n };\n\n const mailTemplate = new CommercialDocumentMailHTML();\n\n return {\n header: ejs.render(mailTemplate.header, data),\n };\n}"],"mappings":";;;;;QAiCgBA,0BAA0B,GAA1BA,0BAA0B;AAAAC,OAAA,CA2F1BC,uBAAuB,GAAvBA,uBAAuB;AAAAD,OAAA,CA4FvBE,kBAAkB,GAAlBA,kBAAkB;AAxNlC,IAAAC,OAAA,GAAAC,OAAA;AAGA,IAAAC,MAAA,GAAAD,OAAA;AAA+B,IAAnBE,KAAK,GAAAC,uBAAA,CAAAF,MAAA;AAEjB,IAAAG,qBAAA,GAAAJ,OAAA;AAGA,IAAAK,gBAAA,GAAAL,OAAA;AACA,IAAAM,IAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AACA,IAAAS,KAAA,GAAAT,OAAA;AACA,IAAAU,QAAA,GAAAV,OAAA;AACA,IAAAW,IAAA,GAAAX,OAAA;AAIA,IAAAY,WAAA,GAAAZ,OAAA;AACA,IAAAa,OAAA,GAAAb,OAAA;AAA2C,SAAAc,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC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AgB,CAAC;IAC1F6F,iBAAiB,EAAE,IAAAD,sCAA8B,EAACF,MAAM,CAAClI,OAAO,CAACwC,gBAAgB,GAAG0F,MAAM,CAAClI,OAAO,CAACsC,gBAAgB,CAAC;IACpHwC,gBAAgB,EAAEoD,MAAM,CAAClI,OAAO,CAAC+E,OAAO,GAAGnH,KAAK,CAACsK,MAAM,CAAClI,OAAO,CAAC+E,OAAO,CAAC,CAACC,MAAM,CAAC,cAAc,CAAC,GAAG,IAAI;IACtGsD,MAAM,EAAEJ,MAAM,CAACI,MAAM;IACrBC,MAAM,EAAEL,MAAM,CAACK,MAAM;IACrBC,OAAO,EAAEN,MAAM,CAACM,OAAO;IACvBC,WAAW,EAAEP,MAAM,CAACO,WAAW;IAC/BC,OAAO,EAAER,MAAM,CAACQ,OAAO;IACvB;IACAxC,WAAW,EAAE,IAAAC,sBAAc,EAAC;MAAEC,YAAY,EAAE,QAAQ;MAAElG;IAAO,CAAE,CAAmB;IAClFD;EAAmB,EACpB;EAED,MAAM0I,YAAY,GAAG,IAAIC,kCAA0B,EAAE;EAErD,OAAO;IACL1B,MAAM,EAAEpH,GAAG,CAACqH,MAAM,CAACwB,YAAY,CAACzB,MAAM,EAAE9F,IAAI;GAC7C;AACH"}
|
|
@@ -102,10 +102,10 @@ const bodyTemplate = exports.bodyTemplate = `<html class="pdf-content">
|
|
|
102
102
|
|
|
103
103
|
</div>
|
|
104
104
|
|
|
105
|
-
<% if (settings && (settings.iban || settings.bic || settings.bank || paymentType)
|
|
105
|
+
<% if ((settings && (settings.iban || settings.bic || settings.bank)) || paymentType) { %>
|
|
106
106
|
<div class="row mt-30 space-between" style="page-break-inside: avoid !important;">
|
|
107
107
|
<div>
|
|
108
|
-
<% if (settings && (settings.iban || settings.bic || settings.bank || paymentType)
|
|
108
|
+
<% if ((settings && (settings.iban || settings.bic || settings.bank)) || paymentType) { %>
|
|
109
109
|
<% if(paymentType) { %>Mode de paiement : <%= paymentType %><br/><% } %>
|
|
110
110
|
<% if(settings.bank) { %>BANQUE : <%= settings.bank %><br/><% } %>
|
|
111
111
|
<% if(settings.iban) { %>IBAN : <%= settings.iban %><br/><% } %>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"body.js","names":["_EstimateInvoice","require","_common","commonTemplate","CommercialDocumentCommonHTML","headOfDocument","logo","company","EstimateInvoiceType","BON","DEVIS","FACTURE","AVOIR","RESTE","ACOMPTE","bodyTemplate","exports","products","vatRecapitulation","amountRecapitulation","paymentButton","style","styleWYSIWYG"],"sources":["../../../../ts/utils/commercialManagement/templates/body.ts"],"sourcesContent":["import { EstimateInvoiceType } from '../../../types/Enum/EstimateInvoice';\nimport { CommercialDocumentCommonHTML } from './common';\n\nconst commonTemplate = new CommercialDocumentCommonHTML();\n\nconst headOfDocument = `<div class=\"row space-between\">\n <% if (settings && settings.logoAlignment === 'left') { %>\n <div class=\"society-informations\">\n ${commonTemplate.logo}\n ${commonTemplate.company}\n </div>\n <% } else { %>\n <div class=\"society-informations\">${commonTemplate.company}</div>\n ${commonTemplate.logo}\n <% } %>\n </div>\n\n <div class=\"row space-between items-end\" style=\"margin-top: 10px\">\n <div style=\"width: 45%; margin-top: auto;\">\n <span class=\"document-reference\">\n <% if (idEstimateInvoiceType === ${EstimateInvoiceType.BON}) { %>\n Bon de commande\n <% } else if (idEstimateInvoiceType === ${EstimateInvoiceType.DEVIS}) { %>\n Devis\n <% } else if (idEstimateInvoiceType === ${EstimateInvoiceType.FACTURE}) { %>\n Facture\n <% } else if (idEstimateInvoiceType === ${EstimateInvoiceType.AVOIR}) { %>\n Avoir\n <% } else if (idEstimateInvoiceType === ${EstimateInvoiceType.RESTE}) { %>\n Facture de solde\n <% } else if (idEstimateInvoiceType === ${EstimateInvoiceType.ACOMPTE}) { %>\n Facture d'acompte\n <% } %>\n <%= reference %></span><br/>\n <% if(emissionDate) {%><span class=\"document-emission-date\">Date d’émission : <%= emissionDateFormatted %></span><br/><% } %>\n <% if(dueDate && idEstimateInvoiceType !== ${EstimateInvoiceType.ACOMPTE}) {%>\n <span class=\"document-due-date\">\n <% if ([${EstimateInvoiceType.BON}, ${EstimateInvoiceType.DEVIS}].includes(idEstimateInvoiceType)) {%>\n Valide jusqu'au :\n <% } else { %>\n Date d'échéance :\n <% } %>\n <%= dueDateFormatted %></span>\n <% } %>\n <% if (expirationDate && idEstimateInvoiceType === ${EstimateInvoiceType.ACOMPTE}) {%>\n <span class=\"document-due-date\">Date d'expiration : <%= expirationDateFormatted %></span>\n <% } %>\n <% if(termsOfPayment) { %>\n <br/><p style=\"margin-bottom: 0px;\"><%= [${EstimateInvoiceType.BON}, ${EstimateInvoiceType.DEVIS}].includes(idEstimateInvoiceType) ? 'Conditions de règlement' : 'Date limite de règlement' %> : <%= termsOfPayment %></p>\n <% } %>\n </div>\n <div style=\"width: 40%; margin-top: auto;\">\n <p></p>\n <% if (thirdParty) { %>\n <div class=\"<%= settings && settings.isCoordinatesFrameDisplayed ? 'customer-border' : '' %>\">\n <% if(thirdParty.company) {%><b><%= thirdParty.company %></b><br/><% } %>\n <% if(thirdParty.fullname) {%><%= thirdParty.fullname %><br/><% } %>\n <% if(thirdParty.address) {%><%= thirdParty.address %><br/><% } %>\n <% if(thirdParty.zipCode) {%><%= thirdParty.zipCode + ' ' %><% } %><%= thirdParty.city %> <%= thirdParty.country %><br/>\n <% if(thirdParty.deliveryAddress && thirdParty.deliveryCity && thirdParty.deliveryZipCode) {%>Adresse de livraison : <%= thirdParty.deliveryAddress %> <%= thirdParty.deliveryZipCode %> <%= thirdParty.deliveryCity %> <%= thirdParty.deliveryCountry %><br/><% } %>\n <% if(thirdParty.nSiret) {%>SIRET : <%= thirdParty.nSiret %><br/><% } %>\n <% if(thirdParty.nTva) {%>N° TVA : <%= thirdParty.nTva %><% } %>\n </div>\n <% } %>\n </div>\n </div>`;\n\nexport const bodyTemplate = `<html class=\"pdf-content\">\n\n <body>\n\n ${headOfDocument}\n\n <div class=\"row mt-25\">\n <% if (title) { %>Titre : <%= title %><% } %>\n </div>\n\n <div class=\"row mt-10\">${commonTemplate.products}</div>\n\n <div class=\"row space-between mt-20\">\n <div style=\"width: 55%;\">\n <% if (disableVat !== true && vats.length) { %>\n ${commonTemplate.vatRecapitulation}\n <% } %>\n <% if (vatMention) { %><div class=\"vat-mention <%= disableVat !== true ? 'mt-20' : ''%>\"><%= vatMention %></div><% } %>\n <% if (comment) { %>\n <p class=\"mt-20\">Commentaire :<br/>\n <%- comment %>\n <% } %>\n </div>\n\n <div>\n ${commonTemplate.amountRecapitulation}\n\n <% if (isStripeAllowed) { %>\n <div style=\"text-align: right; margin-top: 30px;\">${commonTemplate.paymentButton}</div>\n <% } %>\n </div>\n \n </div>\n\n <% if (settings && (settings.iban || settings.bic || settings.bank || paymentType)
|
|
1
|
+
{"version":3,"file":"body.js","names":["_EstimateInvoice","require","_common","commonTemplate","CommercialDocumentCommonHTML","headOfDocument","logo","company","EstimateInvoiceType","BON","DEVIS","FACTURE","AVOIR","RESTE","ACOMPTE","bodyTemplate","exports","products","vatRecapitulation","amountRecapitulation","paymentButton","style","styleWYSIWYG"],"sources":["../../../../ts/utils/commercialManagement/templates/body.ts"],"sourcesContent":["import { EstimateInvoiceType } from '../../../types/Enum/EstimateInvoice';\nimport { CommercialDocumentCommonHTML } from './common';\n\nconst commonTemplate = new CommercialDocumentCommonHTML();\n\nconst headOfDocument = `<div class=\"row space-between\">\n <% if (settings && settings.logoAlignment === 'left') { %>\n <div class=\"society-informations\">\n ${commonTemplate.logo}\n ${commonTemplate.company}\n </div>\n <% } else { %>\n <div class=\"society-informations\">${commonTemplate.company}</div>\n ${commonTemplate.logo}\n <% } %>\n </div>\n\n <div class=\"row space-between items-end\" style=\"margin-top: 10px\">\n <div style=\"width: 45%; margin-top: auto;\">\n <span class=\"document-reference\">\n <% if (idEstimateInvoiceType === ${EstimateInvoiceType.BON}) { %>\n Bon de commande\n <% } else if (idEstimateInvoiceType === ${EstimateInvoiceType.DEVIS}) { %>\n Devis\n <% } else if (idEstimateInvoiceType === ${EstimateInvoiceType.FACTURE}) { %>\n Facture\n <% } else if (idEstimateInvoiceType === ${EstimateInvoiceType.AVOIR}) { %>\n Avoir\n <% } else if (idEstimateInvoiceType === ${EstimateInvoiceType.RESTE}) { %>\n Facture de solde\n <% } else if (idEstimateInvoiceType === ${EstimateInvoiceType.ACOMPTE}) { %>\n Facture d'acompte\n <% } %>\n <%= reference %></span><br/>\n <% if(emissionDate) {%><span class=\"document-emission-date\">Date d’émission : <%= emissionDateFormatted %></span><br/><% } %>\n <% if(dueDate && idEstimateInvoiceType !== ${EstimateInvoiceType.ACOMPTE}) {%>\n <span class=\"document-due-date\">\n <% if ([${EstimateInvoiceType.BON}, ${EstimateInvoiceType.DEVIS}].includes(idEstimateInvoiceType)) {%>\n Valide jusqu'au :\n <% } else { %>\n Date d'échéance :\n <% } %>\n <%= dueDateFormatted %></span>\n <% } %>\n <% if (expirationDate && idEstimateInvoiceType === ${EstimateInvoiceType.ACOMPTE}) {%>\n <span class=\"document-due-date\">Date d'expiration : <%= expirationDateFormatted %></span>\n <% } %>\n <% if(termsOfPayment) { %>\n <br/><p style=\"margin-bottom: 0px;\"><%= [${EstimateInvoiceType.BON}, ${EstimateInvoiceType.DEVIS}].includes(idEstimateInvoiceType) ? 'Conditions de règlement' : 'Date limite de règlement' %> : <%= termsOfPayment %></p>\n <% } %>\n </div>\n <div style=\"width: 40%; margin-top: auto;\">\n <p></p>\n <% if (thirdParty) { %>\n <div class=\"<%= settings && settings.isCoordinatesFrameDisplayed ? 'customer-border' : '' %>\">\n <% if(thirdParty.company) {%><b><%= thirdParty.company %></b><br/><% } %>\n <% if(thirdParty.fullname) {%><%= thirdParty.fullname %><br/><% } %>\n <% if(thirdParty.address) {%><%= thirdParty.address %><br/><% } %>\n <% if(thirdParty.zipCode) {%><%= thirdParty.zipCode + ' ' %><% } %><%= thirdParty.city %> <%= thirdParty.country %><br/>\n <% if(thirdParty.deliveryAddress && thirdParty.deliveryCity && thirdParty.deliveryZipCode) {%>Adresse de livraison : <%= thirdParty.deliveryAddress %> <%= thirdParty.deliveryZipCode %> <%= thirdParty.deliveryCity %> <%= thirdParty.deliveryCountry %><br/><% } %>\n <% if(thirdParty.nSiret) {%>SIRET : <%= thirdParty.nSiret %><br/><% } %>\n <% if(thirdParty.nTva) {%>N° TVA : <%= thirdParty.nTva %><% } %>\n </div>\n <% } %>\n </div>\n </div>`;\n\nexport const bodyTemplate = `<html class=\"pdf-content\">\n\n <body>\n\n ${headOfDocument}\n\n <div class=\"row mt-25\">\n <% if (title) { %>Titre : <%= title %><% } %>\n </div>\n\n <div class=\"row mt-10\">${commonTemplate.products}</div>\n\n <div class=\"row space-between mt-20\">\n <div style=\"width: 55%;\">\n <% if (disableVat !== true && vats.length) { %>\n ${commonTemplate.vatRecapitulation}\n <% } %>\n <% if (vatMention) { %><div class=\"vat-mention <%= disableVat !== true ? 'mt-20' : ''%>\"><%= vatMention %></div><% } %>\n <% if (comment) { %>\n <p class=\"mt-20\">Commentaire :<br/>\n <%- comment %>\n <% } %>\n </div>\n\n <div>\n ${commonTemplate.amountRecapitulation}\n\n <% if (isStripeAllowed) { %>\n <div style=\"text-align: right; margin-top: 30px;\">${commonTemplate.paymentButton}</div>\n <% } %>\n </div>\n \n </div>\n\n <% if ((settings && (settings.iban || settings.bic || settings.bank)) || paymentType) { %>\n <div class=\"row mt-30 space-between\" style=\"page-break-inside: avoid !important;\">\n <div>\n <% if ((settings && (settings.iban || settings.bic || settings.bank)) || paymentType) { %>\n <% if(paymentType) { %>Mode de paiement : <%= paymentType %><br/><% } %>\n <% if(settings.bank) { %>BANQUE : <%= settings.bank %><br/><% } %>\n <% if(settings.iban) { %>IBAN : <%= settings.iban %><br/><% } %>\n <% if(settings.bic) { %>BIC : <%= settings.bic %><% } %>\n <% } %>\n </div>\n </div>\n <% } %>\n <% if (settings && settings.bonPour && (idEstimateInvoiceType === ${EstimateInvoiceType.DEVIS} || idEstimateInvoiceType === ${EstimateInvoiceType.BON})) { %>\n <br/>Bon pour accord : <br/><br/><br/><br/>\n <% } %>\n\n <% if (cgv && ((settings && settings.invoiceCgv) || idEstimateInvoiceType === ${EstimateInvoiceType.DEVIS} || idEstimateInvoiceType === ${EstimateInvoiceType.BON})) { %>\n <br><div style=\"page-break-after:always;\"></div>\n <div id=\"WYSIWYG\"><%- cgv %></div>\n <% } %>\n </body>\n\n <style>\n ${commonTemplate.style}\n </style>\n <style>\n ${commonTemplate.styleWYSIWYG}\n </style>\n</html>`;\n"],"mappings":";;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEA,MAAME,cAAc,GAAG,IAAIC,oCAA4B,EAAE;AAEzD,MAAMC,cAAc,GAAG;;;YAGXF,cAAc,CAACG,IAAI;YACnBH,cAAc,CAACI,OAAO;;;4CAGUJ,cAAc,CAACI,OAAO;UACxDJ,cAAc,CAACG,IAAI;;;;;;;yCAOYE,oCAAmB,CAACC,GAAG;;gDAEhBD,oCAAmB,CAACE,KAAK;;gDAEzBF,oCAAmB,CAACG,OAAO;;gDAE3BH,oCAAmB,CAACI,KAAK;;gDAEzBJ,oCAAmB,CAACK,KAAK;;gDAEzBL,oCAAmB,CAACM,OAAO;;;;;mDAKxBN,oCAAmB,CAACM,OAAO;;oBAE1DN,oCAAmB,CAACC,GAAG,KAAKD,oCAAmB,CAACE,KAAK;;;;;;;2DAOdF,oCAAmB,CAACM,OAAO;;;;mDAInCN,oCAAmB,CAACC,GAAG,KAAKD,oCAAmB,CAACE,KAAK;;;;;;;;;;;;;;;;;SAiB/F;AAEF,MAAMK,YAAY,GAAAC,OAAA,CAAZD,YAAY,GAAG;;;;IAIxBV,cAAc;;;;;;6BAMWF,cAAc,CAACc,QAAQ;;;;;YAKxCd,cAAc,CAACe,iBAAiB;;;;;;;;;;UAUlCf,cAAc,CAACgB,oBAAoB;;;8DAGiBhB,cAAc,CAACiB,aAAa;;;;;;;;;;;;;;;;;;wEAkBlBZ,oCAAmB,CAACE,KAAK,iCAAiCF,oCAAmB,CAACC,GAAG;;;;oFAIrED,oCAAmB,CAACE,KAAK,iCAAiCF,oCAAmB,CAACC,GAAG;;;;;;;QAO7JN,cAAc,CAACkB,KAAK;;;QAGpBlB,cAAc,CAACmB,YAAY;;QAE3B"}
|
package/js/utils/documents.js
CHANGED
|
@@ -17,7 +17,7 @@ const requiredListDocs = (idLegalForm, isOnlyPrevi, isOnlyJuridic, isOnlySocial,
|
|
|
17
17
|
if ([_LegalForm.LegalForm.SAS.id, _LegalForm.LegalForm.SA.id].includes(idLegalForm)) {
|
|
18
18
|
generique.push(_Ged.GedFileType.DISTRIBUTION_OF_SHARE);
|
|
19
19
|
}
|
|
20
|
-
if ([_LegalForm.LegalForm.EURL.id, _LegalForm.LegalForm.SASU.id, _LegalForm.LegalForm.SA.id, _LegalForm.LegalForm.SAS.id, _LegalForm.LegalForm.SARL.id, _LegalForm.LegalForm.SCI.id].includes(idLegalForm)) {
|
|
20
|
+
if ([_LegalForm.LegalForm.EURL.id, _LegalForm.LegalForm.SASU.id, _LegalForm.LegalForm.SA.id, _LegalForm.LegalForm.SAS.id, _LegalForm.LegalForm.SARL.id, _LegalForm.LegalForm.SCI.id, _LegalForm.LegalForm.EARL.id].includes(idLegalForm)) {
|
|
21
21
|
return [...generique, _Ged.GedFileType.KBIS, _Ged.GedFileType.STATUTES, _Ged.GedFileType.DBE2, _Ged.GedFileType.SEPA];
|
|
22
22
|
}
|
|
23
23
|
if ([_LegalForm.LegalForm.SELARL.id].includes(idLegalForm)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documents.js","names":["_Ged","require","_LegalForm","requiredListDocs","idLegalForm","isOnlyPrevi","isOnlyJuridic","isOnlySocial","isCreation","GedFileType","IDENTITY_CARD","PLAQUETTE","RIB","SEPA","generique","LegalForm","SAS","id","SA","includes","push","DISTRIBUTION_OF_SHARE","EURL","SASU","SARL","SCI","KBIS","STATUTES","DBE2","SELARL","EI","AUTO_ENTREPRENEUR","SIRENE","EIRL","PATRIMONY","ASSOCIATION","RULES_OF_PROCEDURE","REGISTRATION_OF_THE_ASSOCIATION_AT_THE_PREFECTURE","REPRESENTATIVE_OF_THE_ASSOCIATION","exports"],"sources":["../../ts/utils/documents.ts"],"sourcesContent":["import { GedFileType } from '../types/Enum/Ged';\nimport { LegalForm } from '../types/Enum/LegalForm';\n\nconst requiredListDocs = (idLegalForm: number, isOnlyPrevi?: boolean, isOnlyJuridic?: boolean, isOnlySocial?: boolean, isCreation?: boolean): GedFileType[] => {\n if (isOnlyPrevi) {\n return [GedFileType.IDENTITY_CARD, GedFileType.PLAQUETTE, GedFileType.RIB, GedFileType.SEPA];\n }\n if (isCreation || isOnlyJuridic || isOnlySocial) {\n return [GedFileType.RIB, GedFileType.PLAQUETTE];\n }\n\n const generique = [GedFileType.IDENTITY_CARD, GedFileType.RIB, GedFileType.PLAQUETTE];\n\n if ([LegalForm.SAS.id, LegalForm.SA.id].includes(idLegalForm)) {\n generique.push(GedFileType.DISTRIBUTION_OF_SHARE);\n }\n\n if ([LegalForm.EURL.id, LegalForm.SASU.id, LegalForm.SA.id, LegalForm.SAS.id, LegalForm.SARL.id, LegalForm.SCI.id].includes(idLegalForm)) {\n return [...generique, GedFileType.KBIS, GedFileType.STATUTES, GedFileType.DBE2, GedFileType.SEPA];\n }\n if ([LegalForm.SELARL.id].includes(idLegalForm)) {\n return [...generique, GedFileType.KBIS, GedFileType.STATUTES, GedFileType.SEPA];\n }\n if ([LegalForm.EI.id, LegalForm.AUTO_ENTREPRENEUR.id].includes(idLegalForm)) {\n return [...generique, GedFileType.SIRENE, GedFileType.SEPA];\n }\n if ([LegalForm.EIRL.id].includes(idLegalForm)) {\n return [...generique, GedFileType.SIRENE, GedFileType.SEPA, GedFileType.PATRIMONY];\n }\n if ([LegalForm.ASSOCIATION.id].includes(idLegalForm)) {\n return [...generique, GedFileType.RULES_OF_PROCEDURE, GedFileType.REGISTRATION_OF_THE_ASSOCIATION_AT_THE_PREFECTURE, GedFileType.REPRESENTATIVE_OF_THE_ASSOCIATION];\n }\n return generique;\n};\n\nexport {\n requiredListDocs,\n};"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAEA,MAAME,gBAAgB,GAAGA,CAACC,WAAmB,EAAEC,WAAqB,EAAEC,aAAuB,EAAEC,YAAsB,EAAEC,UAAoB,KAAmB;EAC5J,IAAIH,WAAW,EAAE;IACf,OAAO,CAACI,gBAAW,CAACC,aAAa,EAAED,gBAAW,CAACE,SAAS,EAAEF,gBAAW,CAACG,GAAG,EAAEH,gBAAW,CAACI,IAAI,CAAC;;EAE9F,IAAIL,UAAU,IAAIF,aAAa,IAAIC,YAAY,EAAE;IAC/C,OAAO,CAACE,gBAAW,CAACG,GAAG,EAAEH,gBAAW,CAACE,SAAS,CAAC;;EAGjD,MAAMG,SAAS,GAAG,CAACL,gBAAW,CAACC,aAAa,EAAED,gBAAW,CAACG,GAAG,EAAEH,gBAAW,CAACE,SAAS,CAAC;EAErF,IAAI,CAACI,oBAAS,CAACC,GAAG,CAACC,EAAE,EAAEF,oBAAS,CAACG,EAAE,CAACD,EAAE,CAAC,CAACE,QAAQ,CAACf,WAAW,CAAC,EAAE;IAC7DU,SAAS,CAACM,IAAI,CAACX,gBAAW,CAACY,qBAAqB,CAAC;;EAGnD,IAAI,CAACN,oBAAS,CAACO,IAAI,CAACL,EAAE,EAAEF,oBAAS,CAACQ,IAAI,CAACN,EAAE,EAAEF,oBAAS,CAACG,EAAE,CAACD,EAAE,EAAEF,oBAAS,CAACC,GAAG,CAACC,EAAE,EAAEF,oBAAS,CAACS,IAAI,CAACP,EAAE,EAAEF,oBAAS,CAACU,GAAG,CAACR,EAAE,CAAC,CAACE,QAAQ,CAACf,WAAW,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"documents.js","names":["_Ged","require","_LegalForm","requiredListDocs","idLegalForm","isOnlyPrevi","isOnlyJuridic","isOnlySocial","isCreation","GedFileType","IDENTITY_CARD","PLAQUETTE","RIB","SEPA","generique","LegalForm","SAS","id","SA","includes","push","DISTRIBUTION_OF_SHARE","EURL","SASU","SARL","SCI","EARL","KBIS","STATUTES","DBE2","SELARL","EI","AUTO_ENTREPRENEUR","SIRENE","EIRL","PATRIMONY","ASSOCIATION","RULES_OF_PROCEDURE","REGISTRATION_OF_THE_ASSOCIATION_AT_THE_PREFECTURE","REPRESENTATIVE_OF_THE_ASSOCIATION","exports"],"sources":["../../ts/utils/documents.ts"],"sourcesContent":["import { GedFileType } from '../types/Enum/Ged';\nimport { LegalForm } from '../types/Enum/LegalForm';\n\nconst requiredListDocs = (idLegalForm: number, isOnlyPrevi?: boolean, isOnlyJuridic?: boolean, isOnlySocial?: boolean, isCreation?: boolean): GedFileType[] => {\n if (isOnlyPrevi) {\n return [GedFileType.IDENTITY_CARD, GedFileType.PLAQUETTE, GedFileType.RIB, GedFileType.SEPA];\n }\n if (isCreation || isOnlyJuridic || isOnlySocial) {\n return [GedFileType.RIB, GedFileType.PLAQUETTE];\n }\n\n const generique = [GedFileType.IDENTITY_CARD, GedFileType.RIB, GedFileType.PLAQUETTE];\n\n if ([LegalForm.SAS.id, LegalForm.SA.id].includes(idLegalForm)) {\n generique.push(GedFileType.DISTRIBUTION_OF_SHARE);\n }\n\n if ([LegalForm.EURL.id, LegalForm.SASU.id, LegalForm.SA.id, LegalForm.SAS.id, LegalForm.SARL.id, LegalForm.SCI.id, LegalForm.EARL.id].includes(idLegalForm)) {\n return [...generique, GedFileType.KBIS, GedFileType.STATUTES, GedFileType.DBE2, GedFileType.SEPA];\n }\n if ([LegalForm.SELARL.id].includes(idLegalForm)) {\n return [...generique, GedFileType.KBIS, GedFileType.STATUTES, GedFileType.SEPA];\n }\n if ([LegalForm.EI.id, LegalForm.AUTO_ENTREPRENEUR.id].includes(idLegalForm)) {\n return [...generique, GedFileType.SIRENE, GedFileType.SEPA];\n }\n if ([LegalForm.EIRL.id].includes(idLegalForm)) {\n return [...generique, GedFileType.SIRENE, GedFileType.SEPA, GedFileType.PATRIMONY];\n }\n if ([LegalForm.ASSOCIATION.id].includes(idLegalForm)) {\n return [...generique, GedFileType.RULES_OF_PROCEDURE, GedFileType.REGISTRATION_OF_THE_ASSOCIATION_AT_THE_PREFECTURE, GedFileType.REPRESENTATIVE_OF_THE_ASSOCIATION];\n }\n return generique;\n};\n\nexport {\n requiredListDocs,\n};"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAEA,MAAME,gBAAgB,GAAGA,CAACC,WAAmB,EAAEC,WAAqB,EAAEC,aAAuB,EAAEC,YAAsB,EAAEC,UAAoB,KAAmB;EAC5J,IAAIH,WAAW,EAAE;IACf,OAAO,CAACI,gBAAW,CAACC,aAAa,EAAED,gBAAW,CAACE,SAAS,EAAEF,gBAAW,CAACG,GAAG,EAAEH,gBAAW,CAACI,IAAI,CAAC;;EAE9F,IAAIL,UAAU,IAAIF,aAAa,IAAIC,YAAY,EAAE;IAC/C,OAAO,CAACE,gBAAW,CAACG,GAAG,EAAEH,gBAAW,CAACE,SAAS,CAAC;;EAGjD,MAAMG,SAAS,GAAG,CAACL,gBAAW,CAACC,aAAa,EAAED,gBAAW,CAACG,GAAG,EAAEH,gBAAW,CAACE,SAAS,CAAC;EAErF,IAAI,CAACI,oBAAS,CAACC,GAAG,CAACC,EAAE,EAAEF,oBAAS,CAACG,EAAE,CAACD,EAAE,CAAC,CAACE,QAAQ,CAACf,WAAW,CAAC,EAAE;IAC7DU,SAAS,CAACM,IAAI,CAACX,gBAAW,CAACY,qBAAqB,CAAC;;EAGnD,IAAI,CAACN,oBAAS,CAACO,IAAI,CAACL,EAAE,EAAEF,oBAAS,CAACQ,IAAI,CAACN,EAAE,EAAEF,oBAAS,CAACG,EAAE,CAACD,EAAE,EAAEF,oBAAS,CAACC,GAAG,CAACC,EAAE,EAAEF,oBAAS,CAACS,IAAI,CAAC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GArC,gBAAgB,GAAhBA,gBAAgB"}
|
|
@@ -3,13 +3,31 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.validateSiren = validateSiren;
|
|
6
7
|
exports.validateSiret = validateSiret;
|
|
7
8
|
exports.getVatCodeBySiren = getVatCodeBySiren;
|
|
8
9
|
exports.siretToSiren = siretToSiren;
|
|
9
10
|
var _classValidator = require("class-validator");
|
|
10
11
|
var _Country = require("../types/Enum/Country");
|
|
12
|
+
// Function to validate SIREN (9 digits)
|
|
13
|
+
function validateSiren(siren) {
|
|
14
|
+
if (!/^\d{9}$/.test(siren)) throw new Error('Format du SIREN invalide');
|
|
15
|
+
const sirenArray = Array.from(siren).map(Number).reverse();
|
|
16
|
+
const luhnSum = sirenArray.reduce((acc, v, i) => {
|
|
17
|
+
if (i % 2 === 1) {
|
|
18
|
+
const currentVal = v * 2;
|
|
19
|
+
if (currentVal > 9) {
|
|
20
|
+
const array = Array.from(currentVal.toString());
|
|
21
|
+
return acc + Number(array[0]) + Number(array[1]);
|
|
22
|
+
}
|
|
23
|
+
return acc + currentVal;
|
|
24
|
+
}
|
|
25
|
+
return acc + v;
|
|
26
|
+
}, 0);
|
|
27
|
+
if (luhnSum % 10 !== 0) throw new Error('SIREN invalide');
|
|
28
|
+
}
|
|
11
29
|
function validateSiret(siret) {
|
|
12
|
-
if (!/^\d{14}$/.test(siret)) throw new Error('
|
|
30
|
+
if (!/^\d{14}$/.test(siret)) throw new Error('Format du SIRET invalide');
|
|
13
31
|
const siretArray = Array.from(siret).map(Number).reverse();
|
|
14
32
|
const luhnSum = siretArray.reduce((acc, v, i) => {
|
|
15
33
|
if (i % 2 === 1) {
|
|
@@ -27,10 +45,10 @@ function validateSiret(siret) {
|
|
|
27
45
|
if (siret.startsWith('356000000')) {
|
|
28
46
|
const sum = siretArray.reduce((acc, v) => acc + v, 0);
|
|
29
47
|
if (sum % 5 !== 0) {
|
|
30
|
-
throw new Error('
|
|
48
|
+
throw new Error('SIRET invalide');
|
|
31
49
|
}
|
|
32
50
|
} else {
|
|
33
|
-
throw new Error('
|
|
51
|
+
throw new Error('SIRET invalide');
|
|
34
52
|
}
|
|
35
53
|
}
|
|
36
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"siretValidation.js","names":["
|
|
1
|
+
{"version":3,"file":"siretValidation.js","names":["validateSiren","exports","validateSiret","getVatCodeBySiren","siretToSiren","_classValidator","require","_Country","siren","test","Error","sirenArray","Array","from","map","Number","reverse","luhnSum","reduce","acc","v","i","currentVal","array","toString","siret","siretArray","startsWith","sum","countryCode","validSiren","replace","idCountry","isDefined","CountryId","FRANCE","length","substring"],"sources":["../../ts/utils/siretValidation.ts"],"sourcesContent":["import { isDefined } from 'class-validator';\nimport { CountryId } from '../types/Enum/Country';\n\n// Function to validate SIREN (9 digits)\nexport function validateSiren(siren: string) {\n if (!/^\\d{9}$/.test(siren)) throw new Error('Format du SIREN invalide');\n\n const sirenArray = Array.from(siren).map(Number).reverse();\n const luhnSum = sirenArray.reduce((acc, v, i) => {\n if (i % 2 === 1) {\n const currentVal = v * 2;\n if (currentVal > 9) {\n const array = Array.from(currentVal.toString());\n return acc + Number(array[0]) + Number(array[1]);\n }\n return acc + currentVal;\n }\n return acc + v;\n }, 0);\n\n if (luhnSum % 10 !== 0) throw new Error('SIREN invalide');\n}\n\nexport function validateSiret(siret: string) {\n if (!/^\\d{14}$/.test(siret)) throw new Error('Format du SIRET invalide');\n\n const siretArray = Array.from(siret).map(Number).reverse();\n const luhnSum = siretArray.reduce((acc, v, i) => {\n if (i % 2 === 1) {\n const currentVal = v * 2;\n if (currentVal > 9) {\n const array = Array.from(currentVal.toString());\n return acc + Number(array[0]) + Number(array[1]);\n }\n return acc + currentVal;\n }\n return acc + v;\n }, 0);\n\n if (luhnSum % 10 !== 0) {\n // Specific rule for some La Poste SIRET\n if (siret.startsWith('356000000')) {\n const sum = siretArray.reduce((acc, v) => acc + v, 0);\n if (sum % 5 !== 0) {\n throw new Error('SIRET invalide');\n }\n } else {\n throw new Error('SIRET invalide');\n }\n }\n}\n\nexport function getVatCodeBySiren(siren: string, countryCode = 'FR'): string {\n const validSiren = siren.replace(/\\s/g, '');\n // @ts-ignore\n return `${countryCode}${[12 + 3 * (validSiren % 97)] % 97}${validSiren}`;\n}\n\nexport function siretToSiren(siret: string, idCountry?: number): string | null {\n if (typeof siret !== 'string') return null;\n if (isDefined(idCountry) && idCountry !== CountryId.FRANCE) return siret;\n let siren = siret.replace(/ */g, '');\n if (siren && siren.length > 9) {\n siren = siren.substring(0, 9);\n }\n return siren;\n}"],"mappings":";;;;;QAIgBA,aAAa,GAAbA,aAAa;AAAAC,OAAA,CAmBbC,aAAa,GAAbA,aAAa;AAAAD,OAAA,CA6BbE,iBAAiB,GAAjBA,iBAAiB;AAAAF,OAAA,CAMjBG,YAAY,GAAZA,YAAY;AA1D5B,IAAAC,eAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA;AACM,SAAUN,aAAaA,CAACQ,KAAa;EACzC,IAAI,CAAC,SAAS,CAACC,IAAI,CAACD,KAAK,CAAC,EAAE,MAAM,IAAIE,KAAK,CAAC,0BAA0B,CAAC;EAEvE,MAAMC,UAAU,GAAGC,KAAK,CAACC,IAAI,CAACL,KAAK,CAAC,CAACM,GAAG,CAACC,MAAM,CAAC,CAACC,OAAO,EAAE;EAC1D,MAAMC,OAAO,GAAGN,UAAU,CAACO,MAAM,CAAC,CAACC,GAAG,EAAEC,CAAC,EAAEC,CAAC,KAAI;IAC9C,IAAIA,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;MACf,MAAMC,UAAU,GAAGF,CAAC,GAAG,CAAC;MACxB,IAAIE,UAAU,GAAG,CAAC,EAAE;QAClB,MAAMC,KAAK,GAAGX,KAAK,CAACC,IAAI,CAACS,UAAU,CAACE,QAAQ,EAAE,CAAC;QAC/C,OAAOL,GAAG,GA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AAC,CAACC,GAAG,EAAEC,CAAC,KAAKD,GAAG,GAAGC,CAAC,EAAE,CAAC,CAAC;MACrD,IAAIQ,GAAG,GAAG,CAAC,KAAK,CAAC,EAAE;QACjB,MAAM,IAAIlB,KAAK,CAAC,gBAAgB,CAAC;;KAEpC,MAAM;MACL,MAAM,IAAIA,KAAK,CAAC,gBAAgB,CAAC;;;AAGvC;AAEM,SAAUP,iBAAiBA,CAACK,KAAa,EAAEqB,WAAW,GAAG,IAAI;EACjE,MAAMC,UAAU,GAAGtB,KAAK,CAACuB,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;EAC3C;EACA,OAAO,GAAGF,WAAW,GAAG,CAAC,EAAE,GAAG,CAAC,IAAIC,UAAU,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,GAAGA,UAAU,EAAE;AAC1E;AAEM,SAAU1B,YAAYA,CAACqB,KAAa,EAAEO,SAAkB;EAC5D,IAAI,OAAOP,KAAK,KAAK,QAAQ,EAAE,OAAO,IAAI;EAC1C,IAAI,IAAAQ,yBAAS,EAACD,SAAS,CAAC,IAAIA,SAAS,KAAKE,kBAAS,CAACC,MAAM,EAAE,OAAOV,KAAK;EACxE,IAAIjB,KAAK,GAAGiB,KAAK,CAACM,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;EACpC,IAAIvB,KAAK,IAAIA,KAAK,CAAC4B,MAAM,GAAG,CAAC,EAAE;IAC7B5B,KAAK,GAAGA,KAAK,CAAC6B,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC;;EAE/B,OAAO7B,KAAK;AACd"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@silexpert/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.151",
|
|
4
4
|
"description": "Silex Core perform HTTP Request and object binding. Silex core helps developers to retrieve and return formatted object",
|
|
5
5
|
"homepage": "https://gitlab.compta-clementine.fr/dev/silex-api",
|
|
6
6
|
"main": "js/index.js",
|
|
@@ -87,6 +87,7 @@ export function generateCommercialDocument(idEstimateInvoiceType: EstimateInvoic
|
|
|
87
87
|
brandColors: getBrandConfig({ objectWaited: 'colors', nodeEnv }) as brandColorType,
|
|
88
88
|
brandName: `${getBrandConfig({ objectWaited: 'name', nodeEnv })}`,
|
|
89
89
|
shouldHideBrandName,
|
|
90
|
+
paymentType: payload.paymentType,
|
|
90
91
|
};
|
|
91
92
|
|
|
92
93
|
const commonTemplate = new CommercialDocumentCommonHTML();
|
|
@@ -99,10 +99,10 @@ export const bodyTemplate = `<html class="pdf-content">
|
|
|
99
99
|
|
|
100
100
|
</div>
|
|
101
101
|
|
|
102
|
-
<% if (settings && (settings.iban || settings.bic || settings.bank || paymentType)
|
|
102
|
+
<% if ((settings && (settings.iban || settings.bic || settings.bank)) || paymentType) { %>
|
|
103
103
|
<div class="row mt-30 space-between" style="page-break-inside: avoid !important;">
|
|
104
104
|
<div>
|
|
105
|
-
<% if (settings && (settings.iban || settings.bic || settings.bank || paymentType)
|
|
105
|
+
<% if ((settings && (settings.iban || settings.bic || settings.bank)) || paymentType) { %>
|
|
106
106
|
<% if(paymentType) { %>Mode de paiement : <%= paymentType %><br/><% } %>
|
|
107
107
|
<% if(settings.bank) { %>BANQUE : <%= settings.bank %><br/><% } %>
|
|
108
108
|
<% if(settings.iban) { %>IBAN : <%= settings.iban %><br/><% } %>
|
package/ts/utils/documents.ts
CHANGED
|
@@ -15,7 +15,7 @@ const requiredListDocs = (idLegalForm: number, isOnlyPrevi?: boolean, isOnlyJuri
|
|
|
15
15
|
generique.push(GedFileType.DISTRIBUTION_OF_SHARE);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
if ([LegalForm.EURL.id, LegalForm.SASU.id, LegalForm.SA.id, LegalForm.SAS.id, LegalForm.SARL.id, LegalForm.SCI.id].includes(idLegalForm)) {
|
|
18
|
+
if ([LegalForm.EURL.id, LegalForm.SASU.id, LegalForm.SA.id, LegalForm.SAS.id, LegalForm.SARL.id, LegalForm.SCI.id, LegalForm.EARL.id].includes(idLegalForm)) {
|
|
19
19
|
return [...generique, GedFileType.KBIS, GedFileType.STATUTES, GedFileType.DBE2, GedFileType.SEPA];
|
|
20
20
|
}
|
|
21
21
|
if ([LegalForm.SELARL.id].includes(idLegalForm)) {
|
|
@@ -1,8 +1,28 @@
|
|
|
1
1
|
import { isDefined } from 'class-validator';
|
|
2
2
|
import { CountryId } from '../types/Enum/Country';
|
|
3
3
|
|
|
4
|
+
// Function to validate SIREN (9 digits)
|
|
5
|
+
export function validateSiren(siren: string) {
|
|
6
|
+
if (!/^\d{9}$/.test(siren)) throw new Error('Format du SIREN invalide');
|
|
7
|
+
|
|
8
|
+
const sirenArray = Array.from(siren).map(Number).reverse();
|
|
9
|
+
const luhnSum = sirenArray.reduce((acc, v, i) => {
|
|
10
|
+
if (i % 2 === 1) {
|
|
11
|
+
const currentVal = v * 2;
|
|
12
|
+
if (currentVal > 9) {
|
|
13
|
+
const array = Array.from(currentVal.toString());
|
|
14
|
+
return acc + Number(array[0]) + Number(array[1]);
|
|
15
|
+
}
|
|
16
|
+
return acc + currentVal;
|
|
17
|
+
}
|
|
18
|
+
return acc + v;
|
|
19
|
+
}, 0);
|
|
20
|
+
|
|
21
|
+
if (luhnSum % 10 !== 0) throw new Error('SIREN invalide');
|
|
22
|
+
}
|
|
23
|
+
|
|
4
24
|
export function validateSiret(siret: string) {
|
|
5
|
-
if (!/^\d{14}$/.test(siret)) throw new Error('
|
|
25
|
+
if (!/^\d{14}$/.test(siret)) throw new Error('Format du SIRET invalide');
|
|
6
26
|
|
|
7
27
|
const siretArray = Array.from(siret).map(Number).reverse();
|
|
8
28
|
const luhnSum = siretArray.reduce((acc, v, i) => {
|
|
@@ -22,10 +42,10 @@ export function validateSiret(siret: string) {
|
|
|
22
42
|
if (siret.startsWith('356000000')) {
|
|
23
43
|
const sum = siretArray.reduce((acc, v) => acc + v, 0);
|
|
24
44
|
if (sum % 5 !== 0) {
|
|
25
|
-
throw new Error('
|
|
45
|
+
throw new Error('SIRET invalide');
|
|
26
46
|
}
|
|
27
47
|
} else {
|
|
28
|
-
throw new Error('
|
|
48
|
+
throw new Error('SIRET invalide');
|
|
29
49
|
}
|
|
30
50
|
}
|
|
31
51
|
}
|