@silexpert/core 1.1.270 → 1.1.271

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.
Files changed (64) hide show
  1. package/dist/cjs/api/resources/Transaction.d.ts +2 -2
  2. package/dist/cjs/api/resources/Transaction.d.ts.map +1 -1
  3. package/dist/cjs/api/resources/Transaction.js.map +1 -1
  4. package/dist/cjs/types/Enum/AccountType.d.ts +28 -0
  5. package/dist/cjs/types/Enum/AccountType.d.ts.map +1 -1
  6. package/dist/cjs/types/Enum/AccountType.js +28 -0
  7. package/dist/cjs/types/Enum/AccountType.js.map +1 -1
  8. package/dist/cjs/types/Interface/api/account/Create.d.ts +2 -0
  9. package/dist/cjs/types/Interface/api/account/Create.d.ts.map +1 -1
  10. package/dist/cjs/types/Interface/api/account/Create.js +12 -0
  11. package/dist/cjs/types/Interface/api/account/Create.js.map +1 -1
  12. package/dist/cjs/types/Interface/api/account/Update.d.ts +2 -0
  13. package/dist/cjs/types/Interface/api/account/Update.d.ts.map +1 -1
  14. package/dist/cjs/types/Interface/api/account/Update.js +12 -0
  15. package/dist/cjs/types/Interface/api/account/Update.js.map +1 -1
  16. package/dist/cjs/types/Interface/api/commercialManagement/Create.d.ts +3 -1
  17. package/dist/cjs/types/Interface/api/commercialManagement/Create.d.ts.map +1 -1
  18. package/dist/cjs/types/Interface/api/commercialManagement/Create.js.map +1 -1
  19. package/dist/cjs/types/Interface/api/commercialManagement/Read.d.ts +2 -0
  20. package/dist/cjs/types/Interface/api/commercialManagement/Read.d.ts.map +1 -1
  21. package/dist/cjs/types/Interface/api/commercialManagement/Read.js.map +1 -1
  22. package/dist/cjs/utils/commercialManagement/document.d.ts.map +1 -1
  23. package/dist/cjs/utils/commercialManagement/document.js +21 -11
  24. package/dist/cjs/utils/commercialManagement/document.js.map +1 -1
  25. package/dist/cjs/utils/commercialManagement/vat.d.ts.map +1 -1
  26. package/dist/cjs/utils/commercialManagement/vat.js +3 -1
  27. package/dist/cjs/utils/commercialManagement/vat.js.map +1 -1
  28. package/dist/mjs/api/resources/Transaction.d.ts +2 -2
  29. package/dist/mjs/api/resources/Transaction.d.ts.map +1 -1
  30. package/dist/mjs/api/resources/Transaction.js.map +1 -1
  31. package/dist/mjs/types/Enum/AccountType.d.ts +28 -0
  32. package/dist/mjs/types/Enum/AccountType.d.ts.map +1 -1
  33. package/dist/mjs/types/Enum/AccountType.js +28 -0
  34. package/dist/mjs/types/Enum/AccountType.js.map +1 -1
  35. package/dist/mjs/types/Interface/api/account/Create.d.ts +2 -0
  36. package/dist/mjs/types/Interface/api/account/Create.d.ts.map +1 -1
  37. package/dist/mjs/types/Interface/api/account/Create.js +15 -1
  38. package/dist/mjs/types/Interface/api/account/Create.js.map +1 -1
  39. package/dist/mjs/types/Interface/api/account/Update.d.ts +2 -0
  40. package/dist/mjs/types/Interface/api/account/Update.d.ts.map +1 -1
  41. package/dist/mjs/types/Interface/api/account/Update.js +15 -1
  42. package/dist/mjs/types/Interface/api/account/Update.js.map +1 -1
  43. package/dist/mjs/types/Interface/api/commercialManagement/Create.d.ts +3 -1
  44. package/dist/mjs/types/Interface/api/commercialManagement/Create.d.ts.map +1 -1
  45. package/dist/mjs/types/Interface/api/commercialManagement/Create.js +2 -0
  46. package/dist/mjs/types/Interface/api/commercialManagement/Create.js.map +1 -1
  47. package/dist/mjs/types/Interface/api/commercialManagement/Read.d.ts +2 -0
  48. package/dist/mjs/types/Interface/api/commercialManagement/Read.d.ts.map +1 -1
  49. package/dist/mjs/types/Interface/api/commercialManagement/Read.js.map +1 -1
  50. package/dist/mjs/utils/commercialManagement/document.d.ts.map +1 -1
  51. package/dist/mjs/utils/commercialManagement/document.js +14 -0
  52. package/dist/mjs/utils/commercialManagement/document.js.map +1 -1
  53. package/dist/mjs/utils/commercialManagement/vat.d.ts.map +1 -1
  54. package/dist/mjs/utils/commercialManagement/vat.js +2 -0
  55. package/dist/mjs/utils/commercialManagement/vat.js.map +1 -1
  56. package/package.json +1 -1
  57. package/ts/api/resources/Transaction.ts +2 -1
  58. package/ts/types/Enum/AccountType.ts +28 -0
  59. package/ts/types/Interface/api/account/Create.ts +11 -1
  60. package/ts/types/Interface/api/account/Update.ts +12 -1
  61. package/ts/types/Interface/api/commercialManagement/Create.ts +3 -1
  62. package/ts/types/Interface/api/commercialManagement/Read.ts +2 -0
  63. package/ts/utils/commercialManagement/document.ts +18 -1
  64. package/ts/utils/commercialManagement/vat.ts +2 -0
@@ -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,GAC1C,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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QACvB,aAAa;QACb,WAAW,EAAE,cAAc,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAmB;QAClF,mBAAmB;KACpB,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,\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 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,GAC1C,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,C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B,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, ReadVatEditing } from '../../types/Interface/api/commercialManagement/Read';\nimport {\n AccountingCategoryList, FontIds, fontList,\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 let forcedVats: ReadVatEditing[] | undefined = undefined;\n\n if (payload.advanceProducts?.length) {\n const advanceVats = Object.values(_groupBy(payload.advanceProducts, 'vatFormatted')).map((v) => (vatToReadVatEditing(v)), 'value').filter((v) => v.id !== Vat.MARGE.id);\n \n forcedVats = vats.map(v => {\n const base = v.base - (advanceVats.find(a => a.id === v.id)?.base ?? 0);\n const toPay = v.toPay - (advanceVats.find(a => a.id === v.id)?.toPay ?? 0);\n return {\n ...v,\n baseFormatted: integerToFormattedAmountString(base),\n amountFormatted: integerToFormattedAmountString(toPay),\n };\n });\n }\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 vats: forcedVats ?? vats,\n }),\n footer: ejs.render(commonTemplate.footer, {\n ...data,\n freeText: documentFreeText ?? 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 +1 @@
1
- {"version":3,"file":"vat.d.ts","sourceRoot":"","sources":["../../../../ts/utils/commercialManagement/vat.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEjE,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGzE;AAED,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAEvD;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,kBAAkB,EAAE,GAAG,cAAc,CAUlF"}
1
+ {"version":3,"file":"vat.d.ts","sourceRoot":"","sources":["../../../../ts/utils/commercialManagement/vat.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEjE,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGzE;AAED,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAEvD;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,kBAAkB,EAAE,GAAG,cAAc,CAYlF"}
@@ -17,6 +17,8 @@ export function vatToReadVatEditing(products) {
17
17
  value: getById(idVat)?.value ?? 0,
18
18
  baseFormatted: integerToFormattedAmountString(_sumBy(products, (p) => (p.totalTaxExcluded ? +p.totalTaxExcluded : 0))),
19
19
  amountFormatted: integerToFormattedAmountString((_sumBy(products, (p) => (p.totalTaxExcluded ? +p.totalTaxExcluded : 0)) * ((getById(idVat)?.value ?? 0))) / 100),
20
+ toPay: (_sumBy(products, (p) => (p.totalTaxExcluded ? +p.totalTaxExcluded : 0)) * ((getById(idVat)?.value ?? 0))) / 100,
21
+ base: _sumBy(products, (p) => (p.totalTaxExcluded ? +p.totalTaxExcluded : 0)),
20
22
  };
21
23
  }
22
24
  //# sourceMappingURL=vat.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"vat.js","sourceRoot":"","sources":["../../../../ts/utils/commercialManagement/vat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,MAAM,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,GAAG,EAAW,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,8BAA8B,EAAE,MAAM,WAAW,CAAC;AAG3D,MAAM,UAAU,SAAS,CAAC,MAAqB,EAAE,QAAgB;IAC/D,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,CAAC;IAC5B,OAAO,OAAO,GAAG,CAAC,QAAQ,GAAG,GAAG,CAAC,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,EAAU;IAChC,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;AACzD,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,QAA8B;IAChE,MAAM,EAAE,KAAK,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC9B,OAAO;QACL,EAAE,EAAE,KAAK;QACT,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,QAAQ,IAAI,EAAE;QACpC,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAgB,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,KAAK,IAAI,CAAC,CAAC,CAAC;QAC1F,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,KAAK,IAAI,CAAC;QACjC,aAAa,EAAE,8BAA8B,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACtH,eAAe,EAAE,8BAA8B,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;KAClK,CAAC;AACJ,CAAC","sourcesContent":["import { sumBy as _sumBy } from 'lodash';\nimport { Vat, VatType } from '../../types/Enum/Vat';\nimport { integerToFormattedAmountString } from '../amount';\nimport { ReadProductEditing, ReadVatEditing } from '../../types';\n\nexport function getAmount(amount: number | null, vatValue: number): number {\n const _amount = amount ?? 0;\n return _amount * (vatValue / 100);\n}\n\nexport function getById(id: number): VatType | undefined {\n return Object.values(Vat).find((vat) => vat.id === id);\n}\n\nexport function vatToReadVatEditing(products: ReadProductEditing[]): ReadVatEditing {\n const { idVat } = products[0];\n return {\n id: idVat,\n name: getById(idVat)?.saleName ?? '',\n amount: _sumBy(products, (p) => getAmount(p.totalTaxExcluded, getById(idVat)?.value ?? 0)),\n value: getById(idVat)?.value ?? 0,\n baseFormatted: integerToFormattedAmountString(_sumBy(products, (p) => (p.totalTaxExcluded ? +p.totalTaxExcluded : 0))),\n amountFormatted: integerToFormattedAmountString((_sumBy(products, (p) => (p.totalTaxExcluded ? +p.totalTaxExcluded : 0)) * ((getById(idVat)?.value ?? 0))) / 100),\n };\n}"]}
1
+ {"version":3,"file":"vat.js","sourceRoot":"","sources":["../../../../ts/utils/commercialManagement/vat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,MAAM,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,GAAG,EAAW,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,8BAA8B,EAAE,MAAM,WAAW,CAAC;AAG3D,MAAM,UAAU,SAAS,CAAC,MAAqB,EAAE,QAAgB;IAC/D,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,CAAC;IAC5B,OAAO,OAAO,GAAG,CAAC,QAAQ,GAAG,GAAG,CAAC,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,EAAU;IAChC,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;AACzD,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,QAA8B;IAChE,MAAM,EAAE,KAAK,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC9B,OAAO;QACL,EAAE,EAAE,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C,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAC9E,CAAC;AACJ,CAAC","sourcesContent":["import { sumBy as _sumBy } from 'lodash';\nimport { Vat, VatType } from '../../types/Enum/Vat';\nimport { integerToFormattedAmountString } from '../amount';\nimport { ReadProductEditing, ReadVatEditing } from '../../types';\n\nexport function getAmount(amount: number | null, vatValue: number): number {\n const _amount = amount ?? 0;\n return _amount * (vatValue / 100);\n}\n\nexport function getById(id: number): VatType | undefined {\n return Object.values(Vat).find((vat) => vat.id === id);\n}\n\nexport function vatToReadVatEditing(products: ReadProductEditing[]): ReadVatEditing {\n const { idVat } = products[0];\n return {\n id: idVat,\n name: getById(idVat)?.saleName ?? '',\n amount: _sumBy(products, (p) => getAmount(p.totalTaxExcluded, getById(idVat)?.value ?? 0)),\n value: getById(idVat)?.value ?? 0,\n baseFormatted: integerToFormattedAmountString(_sumBy(products, (p) => (p.totalTaxExcluded ? +p.totalTaxExcluded : 0))),\n amountFormatted: integerToFormattedAmountString((_sumBy(products, (p) => (p.totalTaxExcluded ? +p.totalTaxExcluded : 0)) * ((getById(idVat)?.value ?? 0))) / 100),\n toPay: (_sumBy(products, (p) => (p.totalTaxExcluded ? +p.totalTaxExcluded : 0)) * ((getById(idVat)?.value ?? 0))) / 100,\n base: _sumBy(products, (p) => (p.totalTaxExcluded ? +p.totalTaxExcluded : 0)),\n };\n}"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@silexpert/core",
3
- "version": "1.1.270",
3
+ "version": "1.1.271",
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": "dist/cjs/index.js",
@@ -2,6 +2,7 @@ import { Resource } from '../Resource';
2
2
  import {
3
3
  BasePaginate,
4
4
  ReadFormattedAccountingTransaction, UpdateAccountingTransaction, DeleteTransactions, QueryUnexport, QueryGetAllTransactions, IAccountingTransaction, ReadAccountantBalance, CreateManualEntry, IAccountingEntry, QueryDeleteInvoices, ReadDeletedInvoices, QuerySocietyTransactionCount, ReadSocietyTransactionCount, ReadBankAccountSum, QueryBankAccountSum, QueryTransaction, ReadPartnerTransactionType, DuplicateAccountingTransaction, CreateWithMasterEntry,
5
+ QueryExport,
5
6
  } from '../../types';
6
7
 
7
8
  export class Transaction extends Resource {
@@ -32,7 +33,7 @@ export class Transaction extends Resource {
32
33
  return this.axios.$put(`/society/${idSociety}/transactions/unexport`, params);
33
34
  }
34
35
 
35
- export(idSociety: number, params: QueryUnexport): Promise<number> {
36
+ export(idSociety: number, params: QueryExport): Promise<number> {
36
37
  return this.axios.$put(`/society/${idSociety}/transactions/export`, params);
37
38
  }
38
39
  annotate(id: number, data: UpdateAccountingTransaction): Promise<ReadFormattedAccountingTransaction> {
@@ -3,140 +3,168 @@ export const AccountType = {
3
3
  id: 1,
4
4
  color: '#8765D0',
5
5
  icon: 'TravelExpenses',
6
+ name: 'Déplacement',
6
7
  },
7
8
  BANQUES: {
8
9
  id: 2,
9
10
  color: '#FF7E3C',
10
11
  icon: 'BankFees',
12
+ name: 'Banque',
11
13
  },
12
14
  DEPENSES_DIVERSES: {
13
15
  id: 3,
14
16
  color: '#FFB13C',
15
17
  icon: 'MiscExpenses',
18
+ name: 'Dépenses diverses',
16
19
  },
17
20
  SOUS_TRAITANCES: {
18
21
  id: 4,
19
22
  color: '#A35305',
20
23
  icon: 'ServicesAndSubcontracting',
24
+ name: 'Sous-traitances',
21
25
  },
22
26
  ACHAT_MARCHANDISES: {
23
27
  id: 5,
24
28
  color: '#FFB13C',
25
29
  icon: 'Buyings',
30
+ name: 'Achat marchandises',
26
31
  },
27
32
  CHARGES_SOCIALES: {
28
33
  id: 6,
29
34
  color: '#C72B16',
30
35
  icon: 'SalariesAndSocialCharges',
36
+ name: 'charges sociales',
31
37
  },
32
38
  TAXES: {
33
39
  id: 8,
34
40
  color: '#C72B16',
35
41
  icon: 'Taxes',
42
+ name: 'Taxes',
36
43
  },
37
44
  FONCTIONNEMENT: {
38
45
  id: 9,
39
46
  color: '#84908D',
40
47
  icon: 'FixedChargesAndSubscriptions',
48
+ name: 'Fonctionnement',
41
49
  },
42
50
  RECETTES_PRODUCTION: {
43
51
  id: 10,
44
52
  color: '#65D09A',
45
53
  icon: 'ProductionIncomes',
54
+ name: 'Recettes production',
46
55
  },
47
56
  RECETTES_NEGOCE: {
48
57
  id: 11,
49
58
  color: '#65D09A',
50
59
  icon: 'TradingIncomes',
60
+ name: 'recettes négoce',
51
61
  },
52
62
  RECETTES_DIVERSES: {
53
63
  id: 12,
54
64
  color: '#65D09A',
55
65
  icon: 'MiscIncomes',
66
+ name: 'Recettes diverses',
56
67
  },
57
68
  AUTRES: {
58
69
  id: 13,
59
70
  color: '#FFB13C',
60
71
  icon: 'Others',
72
+ name: 'Autres',
61
73
  },
62
74
  ACHATS: {
63
75
  id: 14,
64
76
  color: '#FFB13C',
65
77
  icon: 'Buyings',
78
+ name: 'Achats',
66
79
  },
67
80
  SALAIRES: {
68
81
  id: 15,
69
82
  color: '#C72B16',
70
83
  icon: 'SalariesAndSocialCharges',
84
+ name: 'Salaires',
71
85
  },
72
86
  IMMOBILIER: {
73
87
  id: 16,
74
88
  color: '#088C4A',
75
89
  icon: 'RealEstate',
90
+ name: 'Immobilier',
76
91
  },
77
92
  SERVICES: {
78
93
  id: 17,
79
94
  color: '#A35305',
80
95
  icon: 'ServicesAndSubcontracting',
96
+ name: 'Services',
81
97
  },
82
98
  ABONNEMENTS: {
83
99
  id: 18,
84
100
  color: '#E74242',
85
101
  icon: 'FixedChargesAndSubscriptions',
102
+ name: 'Abonnements',
86
103
  },
87
104
  DEPENSES_COURANTES: {
88
105
  id: 19,
89
106
  color: '#FFB13C',
90
107
  icon: 'MiscExpenses',
108
+ name: 'Dépenses courantes',
91
109
  },
92
110
  TRANSPORTS: {
93
111
  id: 20,
94
112
  color: '#8765D0',
95
113
  icon: 'FreightTransport',
114
+ name: 'Transports',
96
115
  },
97
116
  ADMINISTRATIF: {
98
117
  id: 21,
99
118
  color: '#5894EF',
100
119
  icon: 'Administrative',
120
+ name: 'Administratif',
101
121
  },
102
122
  PUBLICITES_ET_MISSIONS: {
103
123
  id: 22,
104
124
  color: '#088C4A',
105
125
  icon: 'AdvertisingCommunication',
126
+ name: 'Publicités et missions',
106
127
  },
107
128
  DIVERS: {
108
129
  id: 23,
109
130
  color: '#FFB13C',
110
131
  icon: 'Others',
132
+ name: 'Divers',
111
133
  },
112
134
  FINANCES: {
113
135
  id: 24,
114
136
  color: '#FF7E3C',
115
137
  icon: 'Finances',
138
+ name: 'Finances',
116
139
  },
117
140
  IMMOBILISATIONS: {
118
141
  id: 25,
119
142
  color: '#5894EF',
120
143
  icon: 'CapitalAssets',
144
+ name: 'Immobilisations',
121
145
  },
122
146
  TIERS: {
123
147
  id: 27,
124
148
  color: '#26D395',
125
149
  icon: 'Tiers',
150
+ name: 'Tiers',
126
151
  },
127
152
  STOCKS: {
128
153
  id: 28,
129
154
  color: '#C2C1C1',
130
155
  icon: 'Stocks',
156
+ name: 'Stocks',
131
157
  },
132
158
  ACHATS_MATIERE_PREMIERE: {
133
159
  id: 29,
134
160
  color: '#FFB13C',
135
161
  icon: 'Buyings',
162
+ name: 'Achats matière première',
136
163
  },
137
164
  ACHATS_EXTERNES: {
138
165
  id: 30,
139
166
  color: '#FFB13C',
140
167
  icon: 'Buyings',
168
+ name: 'Achars Externes',
141
169
  },
142
170
  };
@@ -1,4 +1,4 @@
1
- import { IsOptional, IsString } from 'class-validator';
1
+ import { IsArray, IsNumber, IsOptional, IsString } from 'class-validator';
2
2
  import { IAccount } from '../../..';
3
3
  import { ApiProperty, ApiPropertyOptional } from '../../../../utils';
4
4
 
@@ -20,6 +20,11 @@ export class CreateAccountSociety {
20
20
  export class CreateAccount {
21
21
  @ApiProperty()
22
22
  account: Partial<IAccount>;
23
+
24
+ @ApiPropertyOptional()
25
+ @IsNumber()
26
+ @IsOptional()
27
+ idSociety?: number;
23
28
 
24
29
  @ApiPropertyOptional()
25
30
  @IsString()
@@ -30,4 +35,9 @@ export class CreateAccount {
30
35
  @IsString({ each: true })
31
36
  @IsOptional()
32
37
  tags?: string[];
38
+
39
+ @ApiPropertyOptional()
40
+ @IsOptional()
41
+ @IsArray()
42
+ idSectors?: Array<number>;
33
43
  }
@@ -1,4 +1,4 @@
1
- import { IsOptional, IsString } from 'class-validator';
1
+ import { IsArray, IsNumber, IsOptional, IsString } from 'class-validator';
2
2
  import { ApiProperty, ApiPropertyOptional } from '../../../../utils';
3
3
  import { IAccount } from '../../..';
4
4
 
@@ -26,6 +26,11 @@ export class UpdateAccount {
26
26
  @ApiProperty()
27
27
  account: Partial<IAccount>;
28
28
 
29
+ @ApiPropertyOptional()
30
+ @IsNumber()
31
+ @IsOptional()
32
+ idSociety?: number;
33
+
29
34
  @ApiPropertyOptional()
30
35
  @IsString()
31
36
  @IsOptional()
@@ -40,4 +45,10 @@ export class UpdateAccount {
40
45
  @IsString({ each: true })
41
46
  @IsOptional()
42
47
  tagsToRemove?: string[];
48
+
49
+ @ApiPropertyOptional()
50
+ @IsOptional()
51
+ @IsArray()
52
+ idSectors?: Array<number>;
53
+
43
54
  }
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  IsArray, IsBoolean, IsDateString, IsEnum, IsNumber, IsOptional, IsString, Min,
3
3
  } from 'class-validator';
4
- import { IFile } from '../../..';
4
+ import { IFile, ReadProductEditing } from '../../..';
5
5
  import { ApiProperty, ApiPropertyOptional } from '../../../../utils';
6
6
  import { ToBoolean } from '../../../../utils/transforms/boolean.transform';
7
7
  import { AccountingCategoryId, FontIds, LogoAlignment } from '../../../Enum/CommercialManagement';
@@ -384,6 +384,7 @@ export class CreatePreSaleDocument extends CommercialDocumentInputs {
384
384
  deposit?: undefined;
385
385
  fromEstimateId: undefined;
386
386
  assetMarginVatIds?: [];
387
+ advanceProducts?: [];
387
388
  }
388
389
  export class CreateInvoiceDocument extends CommercialDocumentInputs {
389
390
  paymentLink?: string;
@@ -391,6 +392,7 @@ export class CreateInvoiceDocument extends CommercialDocumentInputs {
391
392
  fromInvoiceId?: number | null; // Nécessaire lors de la création d'un avoir à partir d'une facture
392
393
  fromEstimateId: number | null; // Nécessaire lors du passage d'un devis à facture
393
394
  assetMarginVatIds?: number[]; // Laisser vide côté front, utilisé pour l'affichage des tva sur marge sur les acomptes
395
+ advanceProducts?: ReadProductEditing[]; // Laisser vide côté front, utilisé pour l'affichage des bases TVA sur les acomptes
394
396
  }
395
397
 
396
398
  export class CreateCgv {
@@ -36,6 +36,8 @@ export type ReadVatEditing = {
36
36
  value: number;
37
37
  baseFormatted: string;
38
38
  amountFormatted: string;
39
+ toPay: number;
40
+ base: number;
39
41
  };
40
42
 
41
43
  export type ReadPreview = { idFile: number; };
@@ -2,7 +2,7 @@ import {
2
2
  orderBy as _orderBy, groupBy as _groupBy, sumBy as _sumBy, uniq as _uniq,
3
3
  } from 'lodash';
4
4
  import * as dayjs from 'dayjs';
5
- import { ReadCommercialDocumentTemplate, ReadDocumentEditing } from '../../types/Interface/api/commercialManagement/Read';
5
+ import { ReadCommercialDocumentTemplate, ReadDocumentEditing, ReadVatEditing } from '../../types/Interface/api/commercialManagement/Read';
6
6
  import {
7
7
  AccountingCategoryList, FontIds, fontList,
8
8
  } from '../../types/Enum/CommercialManagement';
@@ -36,6 +36,22 @@ export function generateCommercialDocument(idEstimateInvoiceType: EstimateInvoic
36
36
  const vats = _orderBy(Object.values(_groupBy(products, 'vatFormatted')).map((v) => (vatToReadVatEditing(v)), 'value')).filter((v) => v.id !== Vat.MARGE.id);
37
37
  const thirdParty = thirdPartyToReadThirdPartyEditing(payload.thirdParty);
38
38
 
39
+ let forcedVats: ReadVatEditing[] | undefined = undefined;
40
+
41
+ if (payload.advanceProducts?.length) {
42
+ const advanceVats = Object.values(_groupBy(payload.advanceProducts, 'vatFormatted')).map((v) => (vatToReadVatEditing(v)), 'value').filter((v) => v.id !== Vat.MARGE.id);
43
+
44
+ forcedVats = vats.map(v => {
45
+ const base = v.base - (advanceVats.find(a => a.id === v.id)?.base ?? 0);
46
+ const toPay = v.toPay - (advanceVats.find(a => a.id === v.id)?.toPay ?? 0);
47
+ return {
48
+ ...v,
49
+ baseFormatted: integerToFormattedAmountString(base),
50
+ amountFormatted: integerToFormattedAmountString(toPay),
51
+ };
52
+ });
53
+ }
54
+
39
55
  const data: ReadDocumentEditing & { brandColors: brandColorType, brandName: string, shouldHideBrandName: boolean } = {
40
56
  ...payload,
41
57
  thirdParty,
@@ -113,6 +129,7 @@ export function generateCommercialDocument(idEstimateInvoiceType: EstimateInvoic
113
129
  ? p.comment?.replace(/\n/g, '<br/>')
114
130
  : null,
115
131
  })),
132
+ vats: forcedVats ?? vats,
116
133
  }),
117
134
  footer: ejs.render(commonTemplate.footer, {
118
135
  ...data,
@@ -21,5 +21,7 @@ export function vatToReadVatEditing(products: ReadProductEditing[]): ReadVatEdit
21
21
  value: getById(idVat)?.value ?? 0,
22
22
  baseFormatted: integerToFormattedAmountString(_sumBy(products, (p) => (p.totalTaxExcluded ? +p.totalTaxExcluded : 0))),
23
23
  amountFormatted: integerToFormattedAmountString((_sumBy(products, (p) => (p.totalTaxExcluded ? +p.totalTaxExcluded : 0)) * ((getById(idVat)?.value ?? 0))) / 100),
24
+ toPay: (_sumBy(products, (p) => (p.totalTaxExcluded ? +p.totalTaxExcluded : 0)) * ((getById(idVat)?.value ?? 0))) / 100,
25
+ base: _sumBy(products, (p) => (p.totalTaxExcluded ? +p.totalTaxExcluded : 0)),
24
26
  };
25
27
  }