@silexpert/core 1.1.15 → 1.1.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":["getAmountByAccountNumber","exports","getTaxAmountByAccountNumber","textFormatting","_lodash","require","_Vat","accountingEntries","accountsNumber","precision","accountingEntriesUniq","_uniqBy","_round","reduce","acc","accountingEntry","accTmp","some","number","account","toString","startsWith","debit","credit","_b","_a","Object","values","Vat","find","v","id","idVat","value","length","formattedValue","replace","slice"],"sources":["../../../ts/utils/vat/utils.ts"],"sourcesContent":["import { round as _round, uniqBy as _uniqBy } from 'lodash';\nimport { IAccountingEntry } from '../../types/Interface/models/IAccountingEntry';\nimport { Vat } from '../../types/Enum/Vat';\n\nexport function getAmountByAccountNumber(accountingEntries: IAccountingEntry[], accountsNumber: string[], precision = 0): number {\n const accountingEntriesUniq = _uniqBy(accountingEntries, 'id');\n return _round(accountingEntriesUniq.reduce((acc, accountingEntry) => {\n let accTmp = acc;\n accountsNumber.some((number) => {\n if (accountingEntry.account && accountingEntry.account.number && accountingEntry.account.number.toString().startsWith(number)) {\n accTmp += (accountingEntry.debit - accountingEntry.credit);\n return true;\n }\n return false;\n });\n return accTmp;\n }, 0), precision);\n}\n\nexport function getTaxAmountByAccountNumber(accountingEntries: IAccountingEntry[], accountsNumber: string[], precision = 0): number {\n const accountingEntriesUniq = _uniqBy(accountingEntries, 'id');\n return _round(accountingEntriesUniq.reduce((acc, accountingEntry) => {\n let accTmp = acc;\n accountsNumber.some((number) => {\n if (accountingEntry.account && accountingEntry.account.number && accountingEntry.account.number.toString().startsWith(number)) {\n accTmp += ((accountingEntry.debit - accountingEntry.credit) * (((Object.values(Vat).find((v) => v.id === accountingEntry.idVat)?.value ?? 0) / 100)));\n return true;\n }\n return false;\n });\n return accTmp;\n }, precision));\n}\n\nexport function textFormatting(value: any, length: number | null = null): string | null {\n if (value && typeof value === 'string') {\n let formattedValue = value.replace(/[\\u2018\\u2019]/g, '\\''); // Suppression des \"Curly Quotes\"\n formattedValue = formattedValue.replace(/&/g, ''); // Suppression des &\n formattedValue = formattedValue.replace(/!/g, ''); // Suppression des !\n formattedValue = formattedValue.replace(/[\\t]/g, ''); // Suppression des tabulations\n formattedValue = formattedValue.replace(/`/g, '\\''); // Suppression des `\n formattedValue = formattedValue.replace(/\"/g, ''); // Suppression des \"\n formattedValue = formattedValue.replace(/^ */, ''); // Suppression des espaces de début\n formattedValue = formattedValue.replace(/ *$/, ''); // Suppression des espaces de fin\n if (length) formattedValue = formattedValue.slice(0, length);\n return formattedValue;\n }\n return null;\n}"],"mappings":";;;;;QAIgBA,wBAAwB,GAAxBA,wBAAwB;AAAAC,OAAA,CAexBC,2BAA2B,GAA3BA,2BAA2B;AAAAD,OAAA,CAe3BE,cAAc,GAAdA,cAAc;AAlC9B,IAAAC,OAAA,GAAAC,OAAA;AAEA,IAAAC,IAAA,GAAAD,OAAA;AAEM,SAAUL,wBAAwBA,CAACO,iBAAqC,EAAEC,cAAwB,EAAEC,SAAS,GAAG,CAAC;EACrH,MAAMC,qBAAqB,GAAG,IAAAC,cAAO,EAACJ,iBAAiB,EAAE,IAAI,CAAC;EAC9D,OAAO,IAAAK,aAAM,EAACF,qBAAqB,CAACG,MAAM,CAAC,CAACC,GAAG,EAAEC,eAAe,KAAI;IAClE,IAAIC,MAAM,GAAGF,GAAG;IAChBN,cAAc,CAACS,IAAI,CAAEC,MAAM,IAAI;MAC7B,IAAIH,eAAe,CAACI,OAAO,IAAIJ,eAAe,CAACI,OAAO,CAACD,MAAM,IAAIH,eAAe,CAACI,OAAO,CAACD,MAAM,CAACE,QAAQ,EAAE,CAACC,UAAU,CAACH,MAAM,CAAC,EAAE;QAC7HF,MAAM,IAAKD,eAAe,CAACO,KAAK,GAAGP,eAAe,CAACQ,MAAO;QAC1D,OAAO,IAAI;;MAEb,OAAO,KAAK;IACd,CAAC,CAAC;IACF,OAAOP,MAAM;EACf,CA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C,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;IACnDD,cAAc,GAAGA,cAAc,CAACC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;IACnDD,cAAc,GAAGA,cAAc,CAACC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IACtDD,cAAc,GAAGA,cAAc,CAACC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IACrDD,cAAc,GAAGA,cAAc,CAACC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;IACnDD,cAAc,GAAGA,cAAc,CAACC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;IACpDD,cAAc,GAAGA,cAAc,CAACC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;IACpD,IAAIF,MAAM,EAAEC,cAAc,GAAGA,cAAc,CAACE,KAAK,CAAC,CAAC,EAAEH,MAAM,CAAC;IAC5D,OAAOC,cAAc;;EAEvB,OAAO,IAAI;AACb"}
1
+ {"version":3,"file":"utils.js","names":["getAmountByAccountNumber","exports","getTaxAmountByAccountNumber","textFormatting","_lodash","require","_Vat","accountingEntries","accountsNumber","precision","isCredit","accountingEntriesUniq","_uniqBy","_round","reduce","acc","accountingEntry","accTmp","some","number","account","toString","startsWith","credit","debit","_b","_a","Object","values","Vat","find","v","id","idVat","value","length","formattedValue","replace","slice"],"sources":["../../../ts/utils/vat/utils.ts"],"sourcesContent":["import { round as _round, uniqBy as _uniqBy } from 'lodash';\nimport { IAccountingEntry } from '../../types/Interface/models/IAccountingEntry';\nimport { Vat } from '../../types/Enum/Vat';\n\nexport function getAmountByAccountNumber(accountingEntries: IAccountingEntry[], accountsNumber: string[], precision = 0, isCredit = false): number {\n const accountingEntriesUniq = _uniqBy(accountingEntries, 'id');\n return _round(accountingEntriesUniq.reduce((acc, accountingEntry) => {\n let accTmp = acc;\n accountsNumber.some((number) => {\n if (accountingEntry.account && accountingEntry.account.number && accountingEntry.account.number.toString().startsWith(number)) {\n if (isCredit) {\n accTmp += (accountingEntry.credit - accountingEntry.debit);\n } else {\n accTmp += (accountingEntry.debit - accountingEntry.credit);\n }\n return true;\n }\n return false;\n });\n return accTmp;\n }, 0), precision);\n}\n\nexport function getTaxAmountByAccountNumber(accountingEntries: IAccountingEntry[], accountsNumber: string[], precision = 0): number {\n const accountingEntriesUniq = _uniqBy(accountingEntries, 'id');\n return _round(accountingEntriesUniq.reduce((acc, accountingEntry) => {\n let accTmp = acc;\n accountsNumber.some((number) => {\n if (accountingEntry.account && accountingEntry.account.number && accountingEntry.account.number.toString().startsWith(number)) {\n accTmp += ((accountingEntry.debit - accountingEntry.credit) * (((Object.values(Vat).find((v) => v.id === accountingEntry.idVat)?.value ?? 0) / 100)));\n return true;\n }\n return false;\n });\n return accTmp;\n }, precision));\n}\n\nexport function textFormatting(value: any, length: number | null = null): string | null {\n if (value && typeof value === 'string') {\n let formattedValue = value.replace(/[\\u2018\\u2019]/g, '\\''); // Suppression des \"Curly Quotes\"\n formattedValue = formattedValue.replace(/&/g, ''); // Suppression des &\n formattedValue = formattedValue.replace(/!/g, ''); // Suppression des !\n formattedValue = formattedValue.replace(/[\\t]/g, ''); // Suppression des tabulations\n formattedValue = formattedValue.replace(/`/g, '\\''); // Suppression des `\n formattedValue = formattedValue.replace(/\"/g, ''); // Suppression des \"\n formattedValue = formattedValue.replace(/^ */, ''); // Suppression des espaces de début\n formattedValue = formattedValue.replace(/ *$/, ''); // Suppression des espaces de fin\n if (length) formattedValue = formattedValue.slice(0, length);\n return formattedValue;\n }\n return null;\n}"],"mappings":";;;;;QAIgBA,wBAAwB,GAAxBA,wBAAwB;AAAAC,OAAA,CAmBxBC,2BAA2B,GAA3BA,2BAA2B;AAAAD,OAAA,CAe3BE,cAAc,GAAdA,cAAc;AAtC9B,IAAAC,OAAA,GAAAC,OAAA;AAEA,IAAAC,IAAA,GAAAD,OAAA;AAEM,SAAUL,wBAAwB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AE,CAAC,CAAC,CAAC;IACpD,IAAIF,MAAM,EAAEC,cAAc,GAAGA,cAAc,CAACE,KAAK,CAAC,CAAC,EAAEH,MAAM,CAAC;IAC5D,OAAOC,cAAc;;EAEvB,OAAO,IAAI;AACb"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@silexpert/core",
3
- "version": "1.1.15",
3
+ "version": "1.1.17",
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",
@@ -21,54 +21,54 @@ export function getCerfa3310Century23Payload(accountingEntries: IAccountingEntry
21
21
 
22
22
  // Opérations taxées
23
23
  const taxedServicesEntries = vatEntries.filter((ae) => frenchVat.includes(ae.idVat) && withTaxVat.includes(ae.idVat));
24
- const servicesAccounts = ['701', '702', '703', '704', '705', '706', '707', '708'];
25
- const taxedServicesFromFrance = getAmountByAccountNumber(taxedServicesEntries, servicesAccounts);
26
- const taxedOther = getAmountByAccountNumber(vatEntries.filter((ae) => withTaxVat.includes(ae.idVat)), ['775']);
24
+ const servicesAccounts = ['701', '702', '703', '704', '705', '706', '707', '708', '472'];
25
+ const taxedServicesFromFrance = getAmountByAccountNumber(taxedServicesEntries, servicesAccounts, 0, true);
26
+ const taxedOther = getAmountByAccountNumber(vatEntries.filter((ae) => withTaxVat.includes(ae.idVat)), ['775'], 0, true);
27
27
  const intracommunityServiceAccounts = ['604', '611', '612', '613', '614', '615', '616', '617', '618', '619', '62'];
28
28
  const intracommunityServiceEntries = vatEntries.filter((ae) => withTaxVat.includes(ae.idVat) && intracomVat.includes(ae.idVat));
29
- const taxedPurchaseOfIntracommunityService = getAmountByAccountNumber(intracommunityServiceEntries, intracommunityServiceAccounts);
29
+ const taxedPurchaseOfIntracommunityService = getAmountByAccountNumber(intracommunityServiceEntries, intracommunityServiceAccounts, 0, true);
30
30
  const taxedImportEntries = vatEntries.filter((ae) => importationVat.includes(ae.idVat) && withTaxVat.includes(ae.idVat));
31
31
  const taxedImportAccounts = ['6'];
32
- const taxedImport = getAmountByAccountNumber(taxedImportEntries, taxedImportAccounts);
33
- const taxedIntracommunityAcquisitions = getAmountByAccountNumber(vatEntries.filter((ae) => intracomVat.includes(ae.idVat) && withTaxVat.includes(ae.idVat)), ['601', '602', '603', '605', '606', '607']);
32
+ const taxedImport = getAmountByAccountNumber(taxedImportEntries, taxedImportAccounts, 0, true);
33
+ const taxedIntracommunityAcquisitions = getAmountByAccountNumber(vatEntries.filter((ae) => intracomVat.includes(ae.idVat) && withTaxVat.includes(ae.idVat)), ['601', '602', '603', '605', '606', '607'], 0, true);
34
34
  // Opérations non taxées
35
- const untaxedExportationNotInEurope = getAmountByAccountNumber(vatEntries.filter((ae) => importationVat.includes(ae.idVat) && withoutTaxVat.includes(ae.idVat)), servicesAccounts);
36
- const untaxedOther = getAmountByAccountNumber(vatEntries.filter((ae) => frenchVat.includes(ae.idVat) && withoutTaxVat.includes(ae.idVat)), ['7']);
37
- const untaxedImport = getAmountByAccountNumber(vatEntries.filter((ae) => importationVat.includes(ae.idVat) && withoutTaxVat.includes(ae.idVat)), ['6']);
38
- const untaxedIntracomunity = getAmountByAccountNumber(vatEntries.filter((ae) => intracomVat.includes(ae.idVat) && withoutTaxVat.includes(ae.idVat)), ['601', '602', '603', '605', '606', '607']);
39
- const untaxedIntracommunityDelivery = getAmountByAccountNumber(vatEntries.filter((ae) => withoutTaxVat.includes(ae.idVat) && intracomVat.includes(ae.idVat)), ['701', '707']);
35
+ const untaxedExportationNotInEurope = getAmountByAccountNumber(vatEntries.filter((ae) => importationVat.includes(ae.idVat) && withoutTaxVat.includes(ae.idVat)), servicesAccounts, 0, true);
36
+ const untaxedOther = getAmountByAccountNumber(vatEntries.filter((ae) => frenchVat.includes(ae.idVat) && withoutTaxVat.includes(ae.idVat)), ['7'], 0, true);
37
+ const untaxedImport = getAmountByAccountNumber(vatEntries.filter((ae) => importationVat.includes(ae.idVat) && withoutTaxVat.includes(ae.idVat)), ['6'], 0, true);
38
+ const untaxedIntracomunity = getAmountByAccountNumber(vatEntries.filter((ae) => intracomVat.includes(ae.idVat) && withoutTaxVat.includes(ae.idVat)), ['601', '602', '603', '605', '606', '607'], 0, true);
39
+ const untaxedIntracommunityDelivery = getAmountByAccountNumber(vatEntries.filter((ae) => withoutTaxVat.includes(ae.idVat) && intracomVat.includes(ae.idVat)), ['701', '707'], 0, true);
40
40
  // TVA brute
41
- const normalRate = getAmountByAccountNumber(taxedServicesEntries.filter((e) => vats.filter((v) => v.value === 20).map((v) => v.id).includes(e.idVat)), servicesAccounts)
42
- + getAmountByAccountNumber(intracommunityServiceEntries.filter((e) => vats.filter((v) => v.value === 20).map((v) => v.id).includes(e.idVat)), intracommunityServiceAccounts);
41
+ const normalRate = getAmountByAccountNumber(taxedServicesEntries.filter((e) => vats.filter((v) => v.value === 20).map((v) => v.id).includes(e.idVat)), servicesAccounts, 0, true)
42
+ + getAmountByAccountNumber(intracommunityServiceEntries.filter((e) => vats.filter((v) => v.value === 20).map((v) => v.id).includes(e.idVat)), ['6'], 0, true);
43
43
  const normalRateTax = _round(normalRate * 0.2);
44
44
 
45
- const reducedRate5Dot5 = getAmountByAccountNumber(taxedServicesEntries.filter((e) => vats.filter((v) => v.value === 5.5).map((v) => v.id).includes(e.idVat)), servicesAccounts)
46
- + getAmountByAccountNumber(intracommunityServiceEntries.filter((e) => vats.filter((v) => v.value === 5.5).map((v) => v.id).includes(e.idVat)), intracommunityServiceAccounts);
45
+ const reducedRate5Dot5 = getAmountByAccountNumber(taxedServicesEntries.filter((e) => vats.filter((v) => v.value === 5.5).map((v) => v.id).includes(e.idVat)), servicesAccounts, 0, true)
46
+ + getAmountByAccountNumber(intracommunityServiceEntries.filter((e) => vats.filter((v) => v.value === 5.5).map((v) => v.id).includes(e.idVat)), ['6'], 0, true);
47
47
  const reducedRate5Dot5Tax = _round(reducedRate5Dot5 * 0.055);
48
48
 
49
- const reducedRate10 = getAmountByAccountNumber(taxedServicesEntries.filter((e) => vats.filter((v) => v.value === 10).map((v) => v.id).includes(e.idVat)), servicesAccounts)
50
- + getAmountByAccountNumber(intracommunityServiceEntries.filter((e) => vats.filter((v) => v.value === 10).map((v) => v.id).includes(e.idVat)), intracommunityServiceAccounts);
49
+ const reducedRate10 = getAmountByAccountNumber(taxedServicesEntries.filter((e) => vats.filter((v) => v.value === 10).map((v) => v.id).includes(e.idVat)), servicesAccounts, 0, true)
50
+ + getAmountByAccountNumber(intracommunityServiceEntries.filter((e) => vats.filter((v) => v.value === 10).map((v) => v.id).includes(e.idVat)), ['6'], 0, true);
51
51
  const reducedRate10Tax = _round(reducedRate10 * 0.1);
52
52
 
53
- const reducedRate8Dot5 = getAmountByAccountNumber(taxedServicesEntries.filter((e) => vats.filter((v) => v.value === 8.5).map((v) => v.id).includes(e.idVat)), servicesAccounts)
54
- + getAmountByAccountNumber(intracommunityServiceEntries.filter((e) => vats.filter((v) => v.value === 8.5).map((v) => v.id).includes(e.idVat)), intracommunityServiceAccounts);
53
+ const reducedRate8Dot5 = getAmountByAccountNumber(taxedServicesEntries.filter((e) => vats.filter((v) => v.value === 8.5).map((v) => v.id).includes(e.idVat)), servicesAccounts, 0, true)
54
+ + getAmountByAccountNumber(intracommunityServiceEntries.filter((e) => vats.filter((v) => v.value === 8.5).map((v) => v.id).includes(e.idVat)), ['6'], 0, true);
55
55
  const reducedRate8Dot5Tax = _round(reducedRate8Dot5 * 0.085);
56
56
 
57
- const reducedRate2Dot1 = getAmountByAccountNumber(taxedServicesEntries.filter((e) => vats.filter((v) => v.value === 2.1).map((v) => v.id).includes(e.idVat)), servicesAccounts)
58
- + getAmountByAccountNumber(intracommunityServiceEntries.filter((e) => vats.filter((v) => v.value === 2.1).map((v) => v.id).includes(e.idVat)), intracommunityServiceAccounts);
57
+ const reducedRate2Dot1 = getAmountByAccountNumber(taxedServicesEntries.filter((e) => vats.filter((v) => v.value === 2.1).map((v) => v.id).includes(e.idVat)), servicesAccounts, 0, true)
58
+ + getAmountByAccountNumber(intracommunityServiceEntries.filter((e) => vats.filter((v) => v.value === 2.1).map((v) => v.id).includes(e.idVat)), ['6'], 0, true);
59
59
  const reducedRate2Dot1Tax = _round(reducedRate2Dot1 * 0.021);
60
60
 
61
- const importNormalRate = getAmountByAccountNumber(taxedImportEntries.filter((e) => vats.filter((v) => v.value === 20).map((v) => v.id).includes(e.idVat)), taxedImportAccounts);
61
+ const importNormalRate = getAmountByAccountNumber(taxedImportEntries.filter((e) => vats.filter((v) => v.value === 20).map((v) => v.id).includes(e.idVat)), taxedImportAccounts, 0, true);
62
62
  const importNormalRateTax = _round(importNormalRate * 0.2);
63
- const importReducedRate10 = getAmountByAccountNumber(taxedImportEntries.filter((e) => vats.filter((v) => v.value === 10).map((v) => v.id).includes(e.idVat)), taxedImportAccounts);
63
+ const importReducedRate10 = getAmountByAccountNumber(taxedImportEntries.filter((e) => vats.filter((v) => v.value === 10).map((v) => v.id).includes(e.idVat)), taxedImportAccounts, 0, true);
64
64
  const importReducedRate10Tax = _round(importReducedRate10 * 0.1);
65
- const importReducedRate8Dot5 = getAmountByAccountNumber(taxedImportEntries.filter((e) => vats.filter((v) => v.value === 8.5).map((v) => v.id).includes(e.idVat)), taxedImportAccounts);
65
+ const importReducedRate8Dot5 = getAmountByAccountNumber(taxedImportEntries.filter((e) => vats.filter((v) => v.value === 8.5).map((v) => v.id).includes(e.idVat)), taxedImportAccounts, 0, true);
66
66
  const importReducedRate8Dot5Tax = _round(importReducedRate8Dot5 * 0.085);
67
- const importReducedRate5Dot5 = getAmountByAccountNumber(taxedImportEntries.filter((e) => vats.filter((v) => v.value === 5.5).map((v) => v.id).includes(e.idVat)), taxedImportAccounts);
67
+ const importReducedRate5Dot5 = getAmountByAccountNumber(taxedImportEntries.filter((e) => vats.filter((v) => v.value === 5.5).map((v) => v.id).includes(e.idVat)), taxedImportAccounts, 0, true);
68
68
  const importReducedRate5Dot5Tax = _round(importReducedRate8Dot5 * 0.055);
69
- const importReducedRate2Dot1 = getAmountByAccountNumber(taxedImportEntries.filter((e) => vats.filter((v) => v.value === 2.1).map((v) => v.id).includes(e.idVat)), taxedImportAccounts);
69
+ const importReducedRate2Dot1 = getAmountByAccountNumber(taxedImportEntries.filter((e) => vats.filter((v) => v.value === 2.1).map((v) => v.id).includes(e.idVat)), taxedImportAccounts, 0, true);
70
70
  const importReducedRate2Dot1Tax = _round(importReducedRate2Dot1 * 0.021);
71
- const importReducedRate1Dot05 = getAmountByAccountNumber(taxedImportEntries.filter((e) => vats.filter((v) => v.value === 1.05).map((v) => v.id).includes(e.idVat)), taxedImportAccounts);
71
+ const importReducedRate1Dot05 = getAmountByAccountNumber(taxedImportEntries.filter((e) => vats.filter((v) => v.value === 1.05).map((v) => v.id).includes(e.idVat)), taxedImportAccounts, 0, true);
72
72
  const importReducedRate1Dot05Tax = _round(importReducedRate1Dot05 * 0.0105);
73
73
  const intracommunityTax = getTaxAmountByAccountNumber(intracommunityServiceEntries, intracommunityServiceAccounts);
74
74
 
@@ -82,8 +82,8 @@ export function getCerfa3310Century23Payload(accountingEntries: IAccountingEntry
82
82
  const isNil = payload.isNil === true;
83
83
  const isHolidayDeposit = payload.isHolidayDeposit === true;
84
84
 
85
- const sumToAdd = isNil ? 0 : isHolidayDeposit ? (_round((payload.previousVatDeclaration?.toPay?.total ?? 0) * 0.8, 2)) : _round(payload.vat?.sumToAdd ?? 0);
86
- const comment = isHolidayDeposit ? `ACOMPTE CONGES ${payload.comment}` : (payload.comment ?? null);
85
+ const sumToAdd = isNil ? 0 : isHolidayDeposit ? (_round((payload.previousVatDeclaration?.toPay?.total ?? 0) * 0.8, 2)) : _round(payload.vat?.sumToAdd ?? 0) + _round(payload.vat?.deductible?.toImpute ?? 0);
86
+ const comment = isHolidayDeposit ? `ACOMPTE CONGES ${payload.comment ?? ''}` : (payload.comment ?? null);
87
87
 
88
88
  const initialPayload: Cerfa3310_2023 = {
89
89
  isNil,
@@ -249,7 +249,7 @@ export function getCerfa3310Century23Payload(accountingEntries: IAccountingEntry
249
249
  total: isNil || isHolidayDeposit ? 0 : otherDeductibles,
250
250
  },
251
251
  report,
252
- toImpute: isNil || isHolidayDeposit ? 0 : _round(payload.vat?.deductible?.toImpute ?? 0),
252
+ toImpute: isNil || isHolidayDeposit ? 0 : _round(payload.vat?.deductible?.toImpute ?? 0) + _round(payload.vat?.sumToAdd ?? 0),
253
253
  total: 0, // Calculé plus bas
254
254
  onImportOtherThanOilProducts: isNil || isHolidayDeposit ? 0 : otherDeductibles,
255
255
  coefficient: isNil || isHolidayDeposit ? 100 : coefficient,
@@ -2,13 +2,17 @@ import { round as _round, uniqBy as _uniqBy } from 'lodash';
2
2
  import { IAccountingEntry } from '../../types/Interface/models/IAccountingEntry';
3
3
  import { Vat } from '../../types/Enum/Vat';
4
4
 
5
- export function getAmountByAccountNumber(accountingEntries: IAccountingEntry[], accountsNumber: string[], precision = 0): number {
5
+ export function getAmountByAccountNumber(accountingEntries: IAccountingEntry[], accountsNumber: string[], precision = 0, isCredit = false): number {
6
6
  const accountingEntriesUniq = _uniqBy(accountingEntries, 'id');
7
7
  return _round(accountingEntriesUniq.reduce((acc, accountingEntry) => {
8
8
  let accTmp = acc;
9
9
  accountsNumber.some((number) => {
10
10
  if (accountingEntry.account && accountingEntry.account.number && accountingEntry.account.number.toString().startsWith(number)) {
11
- accTmp += (accountingEntry.debit - accountingEntry.credit);
11
+ if (isCredit) {
12
+ accTmp += (accountingEntry.credit - accountingEntry.debit);
13
+ } else {
14
+ accTmp += (accountingEntry.debit - accountingEntry.credit);
15
+ }
12
16
  return true;
13
17
  }
14
18
  return false;