@silexpert/core 2.0.107 → 2.0.109

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 (77) hide show
  1. package/dist/api/resources/Commercial.d.ts.map +1 -1
  2. package/dist/api/resources/Commercial.js +12 -2
  3. package/dist/api/resources/Commercial.js.map +1 -1
  4. package/dist/api/resources/FinancialProjection.d.ts +8 -0
  5. package/dist/api/resources/FinancialProjection.d.ts.map +1 -0
  6. package/dist/api/resources/FinancialProjection.js +14 -0
  7. package/dist/api/resources/FinancialProjection.js.map +1 -0
  8. package/dist/api/resources.d.ts +2 -0
  9. package/dist/api/resources.d.ts.map +1 -1
  10. package/dist/api/resources.js +2 -0
  11. package/dist/api/resources.js.map +1 -1
  12. package/dist/index.d.ts +1 -0
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +1 -0
  15. package/dist/index.js.map +1 -1
  16. package/dist/types/Enum/EInvoicingReasonType.js +4 -4
  17. package/dist/types/Enum/EInvoicingReasonType.js.map +1 -1
  18. package/dist/types/Enum/NotificationType.d.ts +2 -1
  19. package/dist/types/Enum/NotificationType.d.ts.map +1 -1
  20. package/dist/types/Enum/NotificationType.js +6 -0
  21. package/dist/types/Enum/NotificationType.js.map +1 -1
  22. package/dist/types/Enum/SocietyApproval.js +2 -2
  23. package/dist/types/Enum/SocietyApproval.js.map +1 -1
  24. package/dist/types/Interface/api/SocietyApproval.d.ts +1 -0
  25. package/dist/types/Interface/api/SocietyApproval.d.ts.map +1 -1
  26. package/dist/types/Interface/api/SocietyApproval.js +7 -0
  27. package/dist/types/Interface/api/SocietyApproval.js.map +1 -1
  28. package/dist/types/Interface/api/acd/DeduplicateAccounts.d.ts +5 -0
  29. package/dist/types/Interface/api/acd/DeduplicateAccounts.d.ts.map +1 -0
  30. package/dist/types/Interface/api/acd/DeduplicateAccounts.js +34 -0
  31. package/dist/types/Interface/api/acd/DeduplicateAccounts.js.map +1 -0
  32. package/dist/types/Interface/api/acd/Vat.d.ts +6 -0
  33. package/dist/types/Interface/api/acd/Vat.d.ts.map +1 -1
  34. package/dist/types/Interface/api/acd/Vat.js.map +1 -1
  35. package/dist/types/Interface/api/commercialManagement/Create.d.ts +2 -0
  36. package/dist/types/Interface/api/commercialManagement/Create.d.ts.map +1 -1
  37. package/dist/types/Interface/api/commercialManagement/Create.js +1 -0
  38. package/dist/types/Interface/api/commercialManagement/Create.js.map +1 -1
  39. package/dist/types/Interface/api/docoon/Create.d.ts +4 -0
  40. package/dist/types/Interface/api/docoon/Create.d.ts.map +1 -1
  41. package/dist/types/Interface/api/docoon/Create.js +20 -3
  42. package/dist/types/Interface/api/docoon/Create.js.map +1 -1
  43. package/dist/types/Interface/models/ISocietyFinancialProjection.d.ts +12 -0
  44. package/dist/types/Interface/models/ISocietyFinancialProjection.d.ts.map +1 -0
  45. package/dist/types/Interface/models/ISocietyFinancialProjection.js +13 -0
  46. package/dist/types/Interface/models/ISocietyFinancialProjection.js.map +1 -0
  47. package/dist/types/index.d.ts +2 -0
  48. package/dist/types/index.d.ts.map +1 -1
  49. package/dist/types/index.js +2 -0
  50. package/dist/types/index.js.map +1 -1
  51. package/dist/utils/acdVat.d.ts +3 -3
  52. package/dist/utils/acdVat.d.ts.map +1 -1
  53. package/dist/utils/acdVat.js +55 -3
  54. package/dist/utils/acdVat.js.map +1 -1
  55. package/dist/utils/societyApproval.d.ts.map +1 -1
  56. package/dist/utils/societyApproval.js +4 -1
  57. package/dist/utils/societyApproval.js.map +1 -1
  58. package/dist/utils/tests/acdVat.spec.js +33 -0
  59. package/dist/utils/tests/acdVat.spec.js.map +1 -1
  60. package/package.json +1 -1
  61. package/ts/api/resources/Commercial.ts +12 -2
  62. package/ts/api/resources/FinancialProjection.ts +18 -0
  63. package/ts/api/resources.ts +2 -0
  64. package/ts/index.ts +1 -0
  65. package/ts/types/Enum/EInvoicingReasonType.ts +4 -4
  66. package/ts/types/Enum/NotificationType.ts +6 -0
  67. package/ts/types/Enum/SocietyApproval.ts +2 -2
  68. package/ts/types/Interface/api/SocietyApproval.ts +5 -0
  69. package/ts/types/Interface/api/acd/DeduplicateAccounts.ts +29 -0
  70. package/ts/types/Interface/api/acd/Vat.ts +7 -0
  71. package/ts/types/Interface/api/commercialManagement/Create.ts +2 -0
  72. package/ts/types/Interface/api/docoon/Create.ts +25 -3
  73. package/ts/types/Interface/models/ISocietyFinancialProjection.ts +12 -0
  74. package/ts/types/index.ts +2 -0
  75. package/ts/utils/acdVat.ts +82 -5
  76. package/ts/utils/societyApproval.ts +5 -1
  77. package/ts/utils/tests/acdVat.spec.ts +41 -0
@@ -1,17 +1,49 @@
1
- import { Vat } from '../types/Enum/Vat.js';
2
- import { AcdVatCode } from '../types/Interface/api/acd/Vat.js';
1
+ import { Vat, type VatType } from '../types/Enum/Vat.js';
2
+ import { AcdVatCode, type AcdVatAccount } from '../types/Interface/api/acd/Vat.js';
3
3
 
4
- export function idVatToAcdVatCode(idVat?: number | null): AcdVatCode | null {
4
+ export function idVatToAcdVatCode(
5
+ idVat?: number | null,
6
+ acdVatAccounts?: Array<Pick<AcdVatAccount, 'code' | 'rate'>> | null,
7
+ ): AcdVatCode | string | null {
5
8
  if (!idVat) {
6
9
  return null;
7
10
  }
8
11
 
9
- const vat = Object.values(Vat).find((currentVat) => currentVat.id === idVat);
12
+ const vatList = Object.values(Vat) as VatType[];
13
+ const vat = vatList.find((currentVat) => currentVat.id === idVat);
10
14
 
11
15
  if (!vat) {
12
16
  return AcdVatCode.NON_AFFECTE;
13
17
  }
14
18
 
19
+ if (acdVatAccounts && acdVatAccounts.length > 0) {
20
+ if (vat.isVatIntracom) {
21
+ const intracomEntry = acdVatAccounts.find((vatAccount) => vatAccount.code === AcdVatCode.INTRACOM);
22
+ if (intracomEntry) {
23
+ return intracomEntry.code as AcdVatCode;
24
+ }
25
+ return AcdVatCode.INTRACOM;
26
+ }
27
+
28
+ if (vat.isVatImportation) {
29
+ const autolEntry = acdVatAccounts.find((vatAccount) => vatAccount.code === AcdVatCode.AUTOL);
30
+ if (autolEntry) {
31
+ return autolEntry.code as AcdVatCode;
32
+ }
33
+ return AcdVatCode.AUTOL;
34
+ }
35
+
36
+ const matchingRateEntry = acdVatAccounts.find(
37
+ (vatAccount) =>
38
+ vatAccount.rate === vat.value &&
39
+ ![AcdVatCode.INTRACOM, AcdVatCode.AUTOL, AcdVatCode.NON_AFFECTE].includes(vatAccount.code as AcdVatCode),
40
+ );
41
+
42
+ if (matchingRateEntry) {
43
+ return matchingRateEntry.code as AcdVatCode;
44
+ }
45
+ }
46
+
15
47
  if (vat.isVatIntracom) {
16
48
  return AcdVatCode.INTRACOM;
17
49
  }
@@ -36,7 +68,51 @@ export function idVatToAcdVatCode(idVat?: number | null): AcdVatCode | null {
36
68
  }
37
69
  }
38
70
 
39
- export function acdVatCodeToIdVat(acdVatCode?: AcdVatCode | null): number | null {
71
+ export function acdVatCodeToIdVat(
72
+ acdVatCode?: AcdVatCode | string | null,
73
+ acdVatAccounts?: Array<Pick<AcdVatAccount, 'code' | 'rate'>> | null,
74
+ ): number | null {
75
+ if (!acdVatCode) {
76
+ return null;
77
+ }
78
+
79
+ const vatList = Object.values(Vat) as VatType[];
80
+
81
+ if (acdVatAccounts && acdVatAccounts.length > 0) {
82
+ const matchingVat = acdVatAccounts.find((vatAccount) => vatAccount.code === acdVatCode);
83
+
84
+ if (matchingVat && typeof matchingVat.rate === 'number') {
85
+ const rate = matchingVat.rate;
86
+
87
+ if (acdVatCode === AcdVatCode.INTRACOM) {
88
+ const intracomVat = vatList.find((v) => v.isVatIntracom && v.value === rate);
89
+ return intracomVat ? Number(intracomVat.id) : Number(Vat.INTRACOM_WITHOUT_TAXE.id);
90
+ }
91
+
92
+ if (acdVatCode === AcdVatCode.AUTOL) {
93
+ const autolVat = vatList.find((v) => v.isVatImportation && v.value === rate);
94
+ return autolVat ? Number(autolVat.id) : Number(Vat.IMPORTATION_WITHOUT_TAXE.id);
95
+ }
96
+
97
+ if (acdVatCode === AcdVatCode.NON_AFFECTE) {
98
+ return null;
99
+ }
100
+
101
+ const standardVat = vatList.find(
102
+ (v) =>
103
+ !v.isVatIntracom &&
104
+ !v.isVatImportation &&
105
+ v.id !== Vat.MARGE.id &&
106
+ v.id !== Vat.MANUAL.id &&
107
+ v.value === rate,
108
+ );
109
+
110
+ if (standardVat) {
111
+ return Number(standardVat.id);
112
+ }
113
+ }
114
+ }
115
+
40
116
  switch (acdVatCode) {
41
117
  case AcdVatCode.NORMAL:
42
118
  return Vat.TX_20.id;
@@ -58,6 +134,7 @@ export function acdVatCodeToIdVat(acdVatCode?: AcdVatCode | null): number | null
58
134
  case AcdVatCode.SPECIAL:
59
135
  case null:
60
136
  case undefined:
137
+ default:
61
138
  return null;
62
139
  }
63
140
  }
@@ -120,7 +120,7 @@ export function buildApprovalTemplateData(existingApproval: ISocietyApproval, st
120
120
  ECOrderCity: brand?.companyInformation?.ECOrderCity,
121
121
  },
122
122
  owner: {
123
- identity: `${existingApproval?.exercice?.society?.users?.[0]?.idCivility === 1 ? 'Monsieur' : 'Madame'} ${existingApproval?.exercice?.society?.users?.[0]?.firstname} ${existingApproval?.exercice?.society?.users?.[0]?.lastname} `,
123
+ identity: `${existingApproval?.exercice?.society?.users?.[0]?.idCivility === 1 ? 'Monsieur' : 'Madame'} ${existingApproval?.exercice?.society?.users?.[0]?.firstname} ${existingApproval?.exercice?.society?.users?.[0]?.lastname}`,
124
124
  quality: QualityList.find(
125
125
  (ql) => ql.id === existingApproval?.exercice?.society?.users?.[0]?.businessPartners?.[0]?.idQuality,
126
126
  )?.label,
@@ -129,6 +129,10 @@ export function buildApprovalTemplateData(existingApproval: ISocietyApproval, st
129
129
  ...existingApproval,
130
130
  generatingDatas: {
131
131
  ...existingApproval?.generatingDatas,
132
+ regulatedConventions:
133
+ existingApproval?.generatingDatas?.regulatedConventions ??
134
+ existingApproval?.generatingDatas?.conventionsList ??
135
+ [],
132
136
  ...(existingApproval?.generatingDatas?.approvalDate
133
137
  ? {
134
138
  approvalDate: dayjs(existingApproval?.generatingDatas?.approvalDate)
@@ -23,4 +23,45 @@ describe('acdVat utils', () => {
23
23
  expect(acdVatCodeToIdVat(AcdVatCode.AUTOL)).toBe(Vat.IMPORTATION_WITHOUT_TAXE.id);
24
24
  expect(acdVatCodeToIdVat(AcdVatCode.NON_AFFECTE)).toBeNull();
25
25
  });
26
+
27
+ test('should map ACD VAT codes with custom society VAT rates (e.g. DOM-TOM)', () => {
28
+ const domTomVatAccounts = [
29
+ { code: 'NON_AFFECTE', rate: 0 },
30
+ { code: 'TN', rate: 8.5 },
31
+ { code: 'TR1', rate: 2.1 },
32
+ ];
33
+
34
+ expect(acdVatCodeToIdVat('TN', domTomVatAccounts)).toBe(Vat.TX_8_5.id);
35
+ expect(acdVatCodeToIdVat('TR1', domTomVatAccounts)).toBe(Vat.TX_2_1.id);
36
+ expect(acdVatCodeToIdVat('NON_AFFECTE', domTomVatAccounts)).toBeNull();
37
+
38
+ expect(idVatToAcdVatCode(Vat.TX_8_5.id, domTomVatAccounts)).toBe('TN');
39
+ expect(idVatToAcdVatCode(Vat.TX_2_1.id, domTomVatAccounts)).toBe('TR1');
40
+ expect(idVatToAcdVatCode(Vat.WITHOUT_TAXE.id, domTomVatAccounts)).toBeNull();
41
+ });
42
+
43
+ test('should correctly handle 0% VAT codes (e.g. exoneration, intracom 0%, importation 0%)', () => {
44
+ const vatAccountsWithZeroRates = [
45
+ { code: 'NON_AFFECTE', rate: 0 },
46
+ { code: 'EXO', rate: 0 },
47
+ { code: 'INTRACOM', rate: 0 },
48
+ { code: 'AUTOL', rate: 0 },
49
+ { code: 'TN', rate: 20 },
50
+ ];
51
+
52
+ // Non affecté returns null
53
+ expect(acdVatCodeToIdVat('NON_AFFECTE', vatAccountsWithZeroRates)).toBeNull();
54
+
55
+ // Custom 0% code (e.g. EXO) maps to WITHOUT_TAXE
56
+ expect(acdVatCodeToIdVat('EXO', vatAccountsWithZeroRates)).toBe(Vat.WITHOUT_TAXE.id);
57
+ expect(idVatToAcdVatCode(Vat.WITHOUT_TAXE.id, vatAccountsWithZeroRates)).toBe('EXO');
58
+
59
+ // Intracom at 0%
60
+ expect(acdVatCodeToIdVat('INTRACOM', vatAccountsWithZeroRates)).toBe(Vat.INTRACOM_WITHOUT_TAXE.id);
61
+ expect(idVatToAcdVatCode(Vat.INTRACOM_WITHOUT_TAXE.id, vatAccountsWithZeroRates)).toBe(AcdVatCode.INTRACOM);
62
+
63
+ // Importation at 0%
64
+ expect(acdVatCodeToIdVat('AUTOL', vatAccountsWithZeroRates)).toBe(Vat.IMPORTATION_WITHOUT_TAXE.id);
65
+ expect(idVatToAcdVatCode(Vat.IMPORTATION_WITHOUT_TAXE.id, vatAccountsWithZeroRates)).toBe(AcdVatCode.AUTOL);
66
+ });
26
67
  });