@silexpert/core 2.0.68-4 → 2.0.68

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 (98) hide show
  1. package/dist/api/resources/Account.d.ts +0 -1
  2. package/dist/api/resources/Account.d.ts.map +1 -1
  3. package/dist/api/resources/Account.js +0 -3
  4. package/dist/api/resources/Account.js.map +1 -1
  5. package/dist/api/resources/Acd.d.ts +1 -2
  6. package/dist/api/resources/Acd.d.ts.map +1 -1
  7. package/dist/api/resources/Acd.js +0 -3
  8. package/dist/api/resources/Acd.js.map +1 -1
  9. package/dist/index.d.ts +0 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +0 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/types/Enum/MailAuto.d.ts +11 -11
  14. package/dist/types/Enum/MailAuto.d.ts.map +1 -1
  15. package/dist/types/Enum/MailAuto.js +48 -0
  16. package/dist/types/Enum/MailAuto.js.map +1 -1
  17. package/dist/types/Interface/api/account/Create.d.ts +1 -5
  18. package/dist/types/Interface/api/account/Create.d.ts.map +1 -1
  19. package/dist/types/Interface/api/account/Create.js +4 -38
  20. package/dist/types/Interface/api/account/Create.js.map +1 -1
  21. package/dist/types/Interface/api/accountingTransaction/QueryTransaction.js +1 -1
  22. package/dist/types/Interface/api/accountingTransaction/QueryTransaction.js.map +1 -1
  23. package/dist/types/Interface/api/commercialManagement/Create.d.ts +2 -1
  24. package/dist/types/Interface/api/commercialManagement/Create.d.ts.map +1 -1
  25. package/dist/types/Interface/api/commercialManagement/Create.js +5 -0
  26. package/dist/types/Interface/api/commercialManagement/Create.js.map +1 -1
  27. package/dist/types/Interface/api/product/CreateProduct.d.ts +0 -1
  28. package/dist/types/Interface/api/product/CreateProduct.d.ts.map +1 -1
  29. package/dist/types/Interface/api/product/CreateProduct.js +1 -8
  30. package/dist/types/Interface/api/product/CreateProduct.js.map +1 -1
  31. package/dist/types/Interface/api/registration/DeclareRegistration.d.ts +0 -1
  32. package/dist/types/Interface/api/registration/DeclareRegistration.d.ts.map +1 -1
  33. package/dist/types/Interface/api/registration/DeclareRegistration.js +0 -8
  34. package/dist/types/Interface/api/registration/DeclareRegistration.js.map +1 -1
  35. package/dist/types/Interface/api/user/RegisterProspect.d.ts +1 -0
  36. package/dist/types/Interface/api/user/RegisterProspect.d.ts.map +1 -1
  37. package/dist/types/Interface/api/user/RegisterProspect.js.map +1 -1
  38. package/dist/types/Interface/models/IAccount.d.ts +0 -1
  39. package/dist/types/Interface/models/IAccount.d.ts.map +1 -1
  40. package/dist/types/Interface/models/IAccount.js +0 -1
  41. package/dist/types/Interface/models/IAccount.js.map +1 -1
  42. package/dist/types/Interface/models/IProduct.d.ts +0 -3
  43. package/dist/types/Interface/models/IProduct.d.ts.map +1 -1
  44. package/dist/types/Interface/models/IProduct.js +0 -2
  45. package/dist/types/Interface/models/IProduct.js.map +1 -1
  46. package/dist/types/Interface/models/IProductInvoice.d.ts +0 -3
  47. package/dist/types/Interface/models/IProductInvoice.d.ts.map +1 -1
  48. package/dist/types/Interface/models/IProductInvoice.js +0 -2
  49. package/dist/types/Interface/models/IProductInvoice.js.map +1 -1
  50. package/dist/types/Interface/models/ISocietyGescom.d.ts +0 -1
  51. package/dist/types/Interface/models/ISocietyGescom.d.ts.map +1 -1
  52. package/dist/types/Interface/models/ISocietyGescom.js +0 -2
  53. package/dist/types/Interface/models/ISocietyGescom.js.map +1 -1
  54. package/dist/types/index.d.ts +0 -1
  55. package/dist/types/index.d.ts.map +1 -1
  56. package/dist/types/index.js +0 -1
  57. package/dist/types/index.js.map +1 -1
  58. package/dist/utils/commercialManagement/document.d.ts +7 -0
  59. package/dist/utils/commercialManagement/document.d.ts.map +1 -1
  60. package/dist/utils/commercialManagement/document.js +129 -2
  61. package/dist/utils/commercialManagement/document.js.map +1 -1
  62. package/dist/utils/index.d.ts +0 -1
  63. package/dist/utils/index.d.ts.map +1 -1
  64. package/dist/utils/index.js +0 -1
  65. package/dist/utils/index.js.map +1 -1
  66. package/package.json +1 -1
  67. package/ts/api/resources/Account.ts +0 -4
  68. package/ts/api/resources/Acd.ts +1 -5
  69. package/ts/index.ts +0 -1
  70. package/ts/types/Enum/MailAuto.ts +66 -1
  71. package/ts/types/Interface/api/account/Create.ts +3 -29
  72. package/ts/types/Interface/api/accountingTransaction/QueryTransaction.ts +1 -1
  73. package/ts/types/Interface/api/commercialManagement/Create.ts +4 -1
  74. package/ts/types/Interface/api/product/CreateProduct.ts +1 -6
  75. package/ts/types/Interface/api/registration/DeclareRegistration.ts +0 -6
  76. package/ts/types/Interface/api/user/RegisterProspect.ts +1 -0
  77. package/ts/types/Interface/models/IAccount.ts +0 -1
  78. package/ts/types/Interface/models/IProduct.ts +0 -3
  79. package/ts/types/Interface/models/IProductInvoice.ts +0 -3
  80. package/ts/types/Interface/models/ISocietyGescom.ts +0 -2
  81. package/ts/types/index.ts +0 -1
  82. package/ts/utils/commercialManagement/document.ts +147 -2
  83. package/ts/utils/index.ts +0 -1
  84. package/dist/types/Interface/api/acd/Vat.d.ts +0 -52
  85. package/dist/types/Interface/api/acd/Vat.d.ts.map +0 -1
  86. package/dist/types/Interface/api/acd/Vat.js +0 -14
  87. package/dist/types/Interface/api/acd/Vat.js.map +0 -1
  88. package/dist/utils/acdVat.d.ts +0 -4
  89. package/dist/utils/acdVat.d.ts.map +0 -1
  90. package/dist/utils/acdVat.js +0 -57
  91. package/dist/utils/acdVat.js.map +0 -1
  92. package/dist/utils/tests/acdVat.spec.d.ts +0 -2
  93. package/dist/utils/tests/acdVat.spec.d.ts.map +0 -1
  94. package/dist/utils/tests/acdVat.spec.js +0 -25
  95. package/dist/utils/tests/acdVat.spec.js.map +0 -1
  96. package/ts/types/Interface/api/acd/Vat.ts +0 -52
  97. package/ts/utils/acdVat.ts +0 -63
  98. package/ts/utils/tests/acdVat.spec.ts +0 -26
@@ -4,14 +4,20 @@ import {
4
4
  ReadDocumentEditing,
5
5
  ReadVatEditing,
6
6
  } from '../../types/Interface/api/commercialManagement/Read.js';
7
- import { AccountingCategoryList, FontIds, fontList, InvoiceLanguage } from '../../types/Enum/CommercialManagement.js';
7
+ import {
8
+ AccountingCategoryList,
9
+ CommercialVatMentionList,
10
+ FontIds,
11
+ fontList,
12
+ InvoiceLanguage,
13
+ } from '../../types/Enum/CommercialManagement.js';
8
14
  import { EstimateInvoiceType } from '../../types/Enum/EstimateInvoice.js';
9
15
  import { Vat } from '../../types/Enum/Vat.js';
10
16
  import { integerToFormattedAmountString, integerToFormattedAmountObject } from '../amount.js';
11
17
  import { CommercialDocumentCommonHTML, CommercialDocumentMailHTML } from './templates/common.js';
12
18
  import { bodyTemplate } from './templates/body.js';
13
19
  import { productToReadProductEditing } from './product.js';
14
- import { vatToReadVatEditing } from './vat.js';
20
+ import { getById, vatToReadVatEditing } from './vat.js';
15
21
  import {
16
22
  CreateInvoiceDocument,
17
23
  CreateMailHeader,
@@ -210,3 +216,142 @@ export function generateMailHeader(
210
216
  header: ejs.render(mailTemplate.header, data),
211
217
  };
212
218
  }
219
+
220
+ function isMissing(value: unknown): boolean {
221
+ if (value === null || value === undefined) return true;
222
+ if (typeof value === 'string') return value.trim().length === 0;
223
+ if (Array.isArray(value)) return value.length === 0;
224
+ return false;
225
+ }
226
+
227
+ /**
228
+ * @description Si cette fonction est modifiée, penser à check si la fonction `checkErrors` de `emission.service.ts` du core doit être modifiée aussi
229
+ */
230
+ export function checkCommercialDocumentInformation(payload: CreateInvoiceDocument | CreatePreSaleDocument): {
231
+ valid: boolean;
232
+ errors?: string[];
233
+ } {
234
+ const errors: string[] = [];
235
+
236
+ const products = orderBy(payload.products.map((product) => productToReadProductEditing(product), 'reorder'));
237
+ const vats = orderBy(
238
+ Object.values(groupBy(products, 'vatFormatted')).map((v) => vatToReadVatEditing(v), 'value'),
239
+ ).filter((v) => v.id !== Vat.MARGE.id);
240
+
241
+ const totalVats = sumBy(vats, (v) => round(v.amount));
242
+ const totalTaxExcluded = sumBy(products, (p) => round(p.totalTaxExcluded));
243
+ const totalTaxIncluded = round(totalTaxExcluded + totalVats);
244
+
245
+ const requiredData: Array<{ value: unknown; error: string }> = [
246
+ // Invoice
247
+ { value: payload.reference, error: 'Le numéro de facture est obligatoire.' },
248
+ { value: payload.idEstimateInvoiceType, error: 'Le type de document est obligatoire.' },
249
+ { value: payload.emissionDate, error: 'La date d’émission est obligatoire.' },
250
+ // Items
251
+ ...products.flatMap((product, index) => {
252
+ const productLabel = product.itemSaleName?.trim() ? `"${product.itemSaleName}"` : `à la ligne ${index + 1}`;
253
+
254
+ return [
255
+ {
256
+ value: product.itemSaleName,
257
+ error: `Le nom de l'article ${productLabel} est obligatoire.`,
258
+ },
259
+ {
260
+ value: product.priceTaxExcluded,
261
+ error: `Le prix net de l'article ${productLabel} est obligatoire.`,
262
+ },
263
+ {
264
+ value: product.quantity,
265
+ error: `La quantité de l'article ${productLabel} est obligatoire.`,
266
+ },
267
+ {
268
+ value: product.unit,
269
+ error: `Le code EN 16931 de l'article ${productLabel} est obligatoire.`,
270
+ },
271
+ {
272
+ value: product.idVat,
273
+ error: `Le type de TVA de l'article ${productLabel} est obligatoire.`,
274
+ },
275
+ {
276
+ value: product.totalTaxExcluded,
277
+ error: `Le montant net de l'article ${productLabel} est obligatoire.`,
278
+ },
279
+ ];
280
+ }),
281
+ // Seller
282
+ { value: payload.name, error: 'Le nom du vendeur est obligatoire.' },
283
+ { value: payload.siren, error: 'Le SIREN du vendeur est obligatoire.' },
284
+ {
285
+ value: payload.zipCode,
286
+ error: 'Le code postal du vendeur est obligatoire.',
287
+ },
288
+ {
289
+ value: payload.street,
290
+ error: 'L’adresse du vendeur est obligatoire.',
291
+ },
292
+ {
293
+ value: payload.city,
294
+ error: 'La ville du vendeur est obligatoire.',
295
+ },
296
+ {
297
+ value: payload.idCountry,
298
+ error: 'Le pays du vendeur est obligatoire.',
299
+ },
300
+ {
301
+ value: payload.settings?.mailContact,
302
+ error: 'L’email du vendeur est obligatoire.',
303
+ },
304
+ // Customer
305
+ {
306
+ value: payload.thirdParty.company ?? payload.thirdParty.fullname ?? 'NA',
307
+ error: 'Le nom de l’acheteur est obligatoire.',
308
+ },
309
+ {
310
+ value: payload.thirdParty?.idCountry,
311
+ error: 'Le pays de l’acheteur est obligatoire.',
312
+ },
313
+ // Vats
314
+ ...vats.flatMap((vat, index) => [
315
+ {
316
+ value: vat.amount,
317
+ error: `Le montant de TVA à la ligne ${index + 1} est obligatoire.`,
318
+ },
319
+ {
320
+ value: vat.base,
321
+ error: `La base d’imposition de la TVA à la ligne ${index + 1} est obligatoire.`,
322
+ },
323
+ {
324
+ value: vat.value,
325
+ error: `Le type de TVA à la ligne ${index + 1} est obligatoire.`,
326
+ },
327
+ ]),
328
+ // Totals
329
+ { value: totalTaxExcluded, error: 'Le montant total hors taxe est obligatoire.' },
330
+ {
331
+ value: totalTaxExcluded,
332
+ error: 'La somme du montant net des lignes est obligatoire.',
333
+ },
334
+ { value: totalVats, error: 'Le montant total de TVA est obligatoire.' },
335
+ {
336
+ value: totalTaxIncluded,
337
+ error: 'Le montant total TTC est obligatoire.',
338
+ },
339
+ ];
340
+
341
+ // Check des mentions de tva
342
+ const vatType = CommercialVatMentionList.find((v) => v.value === payload.vatMention)?.taxType ?? 'standard';
343
+
344
+ // Si le type de tva est margin, autoliquidation, export ou exempt,
345
+ // aucun produit ne doit avoir de tva > 0
346
+ if (['margin', 'autoliquidation', 'export', 'exempt'].includes(vatType)) {
347
+ for (const product of products) {
348
+ if (getById(product.idVat)?.value !== 0) {
349
+ errors.push(`L'article ${product.itemSaleName} a une TVA non nulle alors que le type de TVA est ${vatType}.`);
350
+ }
351
+ }
352
+ }
353
+
354
+ errors.push(...requiredData.filter((data) => isMissing(data.value)).map((data) => data.error));
355
+
356
+ return { valid: errors.length === 0, errors: errors.length > 0 ? errors : undefined };
357
+ }
package/ts/utils/index.ts CHANGED
@@ -20,6 +20,5 @@ export * from './bankAccount.js';
20
20
  export * from './commercialOffer.js';
21
21
  export * from './societyApproval.js';
22
22
  export * from './commercialManagement/saleEmail.js';
23
- export * from './acdVat.js';
24
23
  export * from './transforms/boolean.transform.js';
25
24
  export * from './transforms/number.transform.js';
@@ -1,52 +0,0 @@
1
- export declare enum AcdVatCode {
2
- AUTOL = "AUTOL",
3
- INTRACOM = "INTRACOM",
4
- NON_AFFECTE = "NON_AFFECTE",
5
- ONI = "ONI",
6
- SUR_IMMOBILISATION = "TI",
7
- NORMAL = "TN",
8
- REDUIT_5_5 = "TR1",
9
- REDUIT_10 = "TR2",
10
- REDUIT_2_1 = "TSR",
11
- SPECIAL = "TS"
12
- }
13
- export type AcdCompte = {
14
- Code: string | null;
15
- Categ: string | null;
16
- Lib: string | null;
17
- Let: string | null;
18
- RegEc: string | null;
19
- Qte: string | null;
20
- Coll: boolean;
21
- CptCptCol: string | null;
22
- CodeTVA: string | null;
23
- CompteHorsTaxe: string | null;
24
- CptInactif: boolean;
25
- UniteQte1: Array<string> | null;
26
- UniteQte2: Array<string> | null;
27
- ActivationAnalytique: boolean;
28
- CleRepartition: {
29
- Code: string | null;
30
- Lib: string | null;
31
- Auto: boolean;
32
- } | null;
33
- Tiers: {
34
- Code: number;
35
- RaisonSociale: string | null;
36
- Siren: string | null;
37
- Siret: string | null;
38
- Telephone: string | null;
39
- Email: string | null;
40
- Fax: string | null;
41
- NumeroIntracom: string | null;
42
- Adresse?: {
43
- Numero: string | null;
44
- Nature: string | null;
45
- Complement: string | null;
46
- Hameau: string | null;
47
- CodePostal: string | null;
48
- Pays: string | null;
49
- };
50
- } | null;
51
- };
52
- //# sourceMappingURL=Vat.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Vat.d.ts","sourceRoot":"","sources":["../../../../../ts/types/Interface/api/acd/Vat.ts"],"names":[],"mappings":"AAAA,oBAAY,UAAU;IACpB,KAAK,UAAU;IACf,QAAQ,aAAa;IACrB,WAAW,gBAAgB;IAC3B,GAAG,QAAQ;IACX,kBAAkB,OAAO;IACzB,MAAM,OAAO;IACb,UAA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AM,GAAG,IAAI,CAAC;YACtB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;YACtB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;YAC1B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;YACtB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;YAC1B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;SACrB,CAAC;KACH,GAAG,IAAI,CAAC;CACV,CAAC"}
@@ -1,14 +0,0 @@
1
- export var AcdVatCode;
2
- (function (AcdVatCode) {
3
- AcdVatCode["AUTOL"] = "AUTOL";
4
- AcdVatCode["INTRACOM"] = "INTRACOM";
5
- AcdVatCode["NON_AFFECTE"] = "NON_AFFECTE";
6
- AcdVatCode["ONI"] = "ONI";
7
- AcdVatCode["SUR_IMMOBILISATION"] = "TI";
8
- AcdVatCode["NORMAL"] = "TN";
9
- AcdVatCode["REDUIT_5_5"] = "TR1";
10
- AcdVatCode["REDUIT_10"] = "TR2";
11
- AcdVatCode["REDUIT_2_1"] = "TSR";
12
- AcdVatCode["SPECIAL"] = "TS";
13
- })(AcdVatCode || (AcdVatCode = {}));
14
- //# sourceMappingURL=Vat.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Vat.js","sourceRoot":"","sources":["../../../../../ts/types/Interface/api/acd/Vat.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,UAWX;AAXD,WAAY,UAAU;IACpB,6BAAe,CAAA;IACf,mCAAqB,CAAA;IACrB,yCAA2B,CAAA;IAC3B,yBAAW,CAAA;IACX,uCAAyB,CAAA;IACzB,2BAAa,CAAA;IACb,gCAAkB,CAAA;IAClB,+BAAiB,CAAA;IACjB,gCAAkB,CAAA;IAClB,4BAAc,CAAA;AAChB,CAAC,EAXW,UAAU,KAAV,UAAU,QAWrB","sourcesContent":["export enum AcdVatCode {\n AUTOL = 'AUTOL',\n INTRACOM = 'INTRACOM',\n NON_AFFECTE = 'NON_AFFECTE',\n ONI = 'ONI',\n SUR_IMMOBILISATION = 'TI',\n NORMAL = 'TN',\n REDUIT_5_5 = 'TR1',\n REDUIT_10 = 'TR2',\n REDUIT_2_1 = 'TSR',\n SPECIAL = 'TS',\n}\n\nexport type AcdCompte = {\n Code: string | null;\n Categ: string | null;\n Lib: string | null;\n Let: string | null;\n RegEc: string | null;\n Qte: string | null;\n Coll: boolean;\n CptCptCol: string | null;\n CodeTVA: string | null;\n CompteHorsTaxe: string | null;\n CptInactif: boolean;\n UniteQte1: Array<string> | null;\n UniteQte2: Array<string> | null;\n ActivationAnalytique: boolean;\n CleRepartition: {\n Code: string | null;\n Lib: string | null;\n Auto: boolean;\n } | null;\n Tiers: {\n Code: number;\n RaisonSociale: string | null;\n Siren: string | null;\n Siret: string | null;\n Telephone: string | null;\n Email: string | null;\n Fax: string | null;\n NumeroIntracom: string | null;\n Adresse?: {\n Numero: string | null;\n Nature: string | null;\n Complement: string | null;\n Hameau: string | null;\n CodePostal: string | null;\n Pays: string | null;\n };\n } | null;\n};\n"]}
@@ -1,4 +0,0 @@
1
- import { AcdVatCode } from '../types/Interface/api/acd/Vat.js';
2
- export declare function idVatToAcdVatCode(idVat?: number | null): AcdVatCode | null;
3
- export declare function acdVatCodeToIdVat(acdVatCode?: AcdVatCode | null): number | null;
4
- //# sourceMappingURL=acdVat.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"acdVat.d.ts","sourceRoot":"","sources":["../../ts/utils/acdVat.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAE/D,wBAAgB,iBAAiB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,UAAU,GAAG,IAAI,CAiC1E;AAED,wBAAgB,iBAAiB,CAAC,UAAU,CAAC,EAAE,UAAU,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAwB/E"}
@@ -1,57 +0,0 @@
1
- import { Vat } from '../types/Enum/Vat.js';
2
- import { AcdVatCode } from '../types/Interface/api/acd/Vat.js';
3
- export function idVatToAcdVatCode(idVat) {
4
- if (!idVat) {
5
- return null;
6
- }
7
- const vat = Object.values(Vat).find((currentVat) => currentVat.id === idVat);
8
- if (!vat) {
9
- return AcdVatCode.NON_AFFECTE;
10
- }
11
- if (vat.isVatIntracom) {
12
- return AcdVatCode.INTRACOM;
13
- }
14
- if (vat.isVatImportation) {
15
- return AcdVatCode.AUTOL;
16
- }
17
- switch (vat.value) {
18
- case 2.1:
19
- return AcdVatCode.REDUIT_2_1;
20
- case 5.5:
21
- return AcdVatCode.REDUIT_5_5;
22
- case 10:
23
- return AcdVatCode.REDUIT_10;
24
- case 20:
25
- return AcdVatCode.NORMAL;
26
- case 0:
27
- return null;
28
- default:
29
- return AcdVatCode.NON_AFFECTE;
30
- }
31
- }
32
- export function acdVatCodeToIdVat(acdVatCode) {
33
- switch (acdVatCode) {
34
- case AcdVatCode.NORMAL:
35
- return Vat.TX_20.id;
36
- case AcdVatCode.REDUIT_10:
37
- return Vat.TX_10.id;
38
- case AcdVatCode.REDUIT_5_5:
39
- return Vat.TX_5_5.id;
40
- case AcdVatCode.REDUIT_2_1:
41
- return Vat.TX_2_1.id;
42
- case AcdVatCode.INTRACOM:
43
- // L'information de taux est perdue dans le code ACD, on retombe sur l'intracom a 20% par defaut.
44
- return Vat.INTRACOM_TX_20.id;
45
- case AcdVatCode.AUTOL:
46
- // L'information de taux est perdue dans le code ACD, on retombe sur l'importation a 20% par defaut.
47
- return Vat.IMPORTATION_TX_20.id;
48
- case AcdVatCode.NON_AFFECTE:
49
- case AcdVatCode.ONI:
50
- case AcdVatCode.SUR_IMMOBILISATION:
51
- case AcdVatCode.SPECIAL:
52
- case null:
53
- case undefined:
54
- return null;
55
- }
56
- }
57
- //# sourceMappingURL=acdVat.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"acdVat.js","sourceRoot":"","sources":["../../ts/utils/acdVat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,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,CAAC,MAAM,CAAC,EAAE,CAAC;QACvB,KAAK,UAAU,CAAC,UAAU;YACxB,OAAO,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;QACvB,KAAK,UAAU,CAAC,QAAQ;YACtB,iGAAiG;YACjG,OAAO,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC;QAC/B,KAAK,UAAU,CAAC,KAAK;YACnB,oGAAoG;YACpG,OAAO,GAAG,CAAC,iBAAiB,CAAC,EAAE,CAAC;QAClC,KAAK,UAAU,CAAC,WAAW,CAAC;QAC5B,KAAK,UAAU,CAAC,GAAG,CAAC;QACpB,KAAK,UAAU,CAAC,kBAAkB,CAAC;QACnC,KAAK,UAAU,CAAC,OAAO,CAAC;QACxB,KAAK,IAAI,CAAC;QACV,KAAK,SAAS;YACZ,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC","sourcesContent":["import { Vat } from '../types/Enum/Vat.js';\nimport { AcdVatCode } from '../types/Interface/api/acd/Vat.js';\n\nexport function idVatToAcdVatCode(idVat?: number | null): AcdVatCode | null {\n if (!idVat) {\n return null;\n }\n\n const vat = Object.values(Vat).find((currentVat) => currentVat.id === idVat);\n\n if (!vat) {\n return AcdVatCode.NON_AFFECTE;\n }\n\n if (vat.isVatIntracom) {\n return AcdVatCode.INTRACOM;\n }\n\n if (vat.isVatImportation) {\n return AcdVatCode.AUTOL;\n }\n\n switch (vat.value) {\n case 2.1:\n return AcdVatCode.REDUIT_2_1;\n case 5.5:\n return AcdVatCode.REDUIT_5_5;\n case 10:\n return AcdVatCode.REDUIT_10;\n case 20:\n return AcdVatCode.NORMAL;\n case 0:\n return null;\n default:\n return AcdVatCode.NON_AFFECTE;\n }\n}\n\nexport function acdVatCodeToIdVat(acdVatCode?: AcdVatCode | null): number | null {\n switch (acdVatCode) {\n case AcdVatCode.NORMAL:\n return Vat.TX_20.id;\n case AcdVatCode.REDUIT_10:\n return Vat.TX_10.id;\n case AcdVatCode.REDUIT_5_5:\n return Vat.TX_5_5.id;\n case AcdVatCode.REDUIT_2_1:\n return Vat.TX_2_1.id;\n case AcdVatCode.INTRACOM:\n // L'information de taux est perdue dans le code ACD, on retombe sur l'intracom a 20% par defaut.\n return Vat.INTRACOM_TX_20.id;\n case AcdVatCode.AUTOL:\n // L'information de taux est perdue dans le code ACD, on retombe sur l'importation a 20% par defaut.\n return Vat.IMPORTATION_TX_20.id;\n case AcdVatCode.NON_AFFECTE:\n case AcdVatCode.ONI:\n case AcdVatCode.SUR_IMMOBILISATION:\n case AcdVatCode.SPECIAL:\n case null:\n case undefined:\n return null;\n }\n}\n"]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=acdVat.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"acdVat.spec.d.ts","sourceRoot":"","sources":["../../../ts/utils/tests/acdVat.spec.ts"],"names":[],"mappings":""}
@@ -1,25 +0,0 @@
1
- import { describe, expect, test } from 'vitest';
2
- import { Vat } from '../../types/Enum/Vat.js';
3
- import { AcdVatCode } from '../../types/Interface/api/acd/Vat.js';
4
- import { acdVatCodeToIdVat, idVatToAcdVatCode } from '../acdVat.js';
5
- describe('acdVat utils', () => {
6
- test('should map internal VAT ids to ACD VAT codes', () => {
7
- expect(idVatToAcdVatCode(Vat.TX_20.id)).toBe(AcdVatCode.NORMAL);
8
- expect(idVatToAcdVatCode(Vat.TX_10.id)).toBe(AcdVatCode.REDUIT_10);
9
- expect(idVatToAcdVatCode(Vat.TX_5_5.id)).toBe(AcdVatCode.REDUIT_5_5);
10
- expect(idVatToAcdVatCode(Vat.TX_2_1.id)).toBe(AcdVatCode.REDUIT_2_1);
11
- expect(idVatToAcdVatCode(Vat.INTRACOM_TX_20.id)).toBe(AcdVatCode.INTRACOM);
12
- expect(idVatToAcdVatCode(Vat.IMPORTATION_TX_20.id)).toBe(AcdVatCode.AUTOL);
13
- expect(idVatToAcdVatCode(Vat.WITHOUT_TAXE.id)).toBeNull();
14
- });
15
- test('should map ACD VAT codes back to internal VAT ids', () => {
16
- expect(acdVatCodeToIdVat(AcdVatCode.NORMAL)).toBe(Vat.TX_20.id);
17
- expect(acdVatCodeToIdVat(AcdVatCode.REDUIT_10)).toBe(Vat.TX_10.id);
18
- expect(acdVatCodeToIdVat(AcdVatCode.REDUIT_5_5)).toBe(Vat.TX_5_5.id);
19
- expect(acdVatCodeToIdVat(AcdVatCode.REDUIT_2_1)).toBe(Vat.TX_2_1.id);
20
- expect(acdVatCodeToIdVat(AcdVatCode.INTRACOM)).toBe(Vat.INTRACOM_TX_20.id);
21
- expect(acdVatCodeToIdVat(AcdVatCode.AUTOL)).toBe(Vat.IMPORTATION_TX_20.id);
22
- expect(acdVatCodeToIdVat(AcdVatCode.NON_AFFECTE)).toBeNull();
23
- });
24
- });
25
- //# sourceMappingURL=acdVat.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"acdVat.spec.js","sourceRoot":"","sources":["../../../ts/utils/tests/acdVat.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEpE,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,IAAI,CAAC,8CAA8C,EAAE,GAAG,EAAE;QACxD,MAAM,CAAC,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAChE,MAAM,CAAC,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QACnE,MAAM,CAAC,iBAAiB,CAAC,GAAG,CAAC,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CAAC;QAC3E,MAAM,CAAC,iBAAiB,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;QAC3E,MAAM,CAAC,iBAAiB,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC/D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, test } from 'vitest';\nimport { Vat } from '../../types/Enum/Vat.js';\nimport { AcdVatCode } from '../../types/Interface/api/acd/Vat.js';\nimport { acdVatCodeToIdVat, idVatToAcdVatCode } from '../acdVat.js';\n\ndescribe('acdVat utils', () => {\n test('should map internal VAT ids to ACD VAT codes', () => {\n expect(idVatToAcdVatCode(Vat.TX_20.id)).toBe(AcdVatCode.NORMAL);\n expect(idVatToAcdVatCode(Vat.TX_10.id)).toBe(AcdVatCode.REDUIT_10);\n expect(idVatToAcdVatCode(Vat.TX_5_5.id)).toBe(AcdVatCode.REDUIT_5_5);\n expect(idVatToAcdVatCode(Vat.TX_2_1.id)).toBe(AcdVatCode.REDUIT_2_1);\n expect(idVatToAcdVatCode(Vat.INTRACOM_TX_20.id)).toBe(AcdVatCode.INTRACOM);\n expect(idVatToAcdVatCode(Vat.IMPORTATION_TX_20.id)).toBe(AcdVatCode.AUTOL);\n expect(idVatToAcdVatCode(Vat.WITHOUT_TAXE.id)).toBeNull();\n });\n\n test('should map ACD VAT codes back to internal VAT ids', () => {\n expect(acdVatCodeToIdVat(AcdVatCode.NORMAL)).toBe(Vat.TX_20.id);\n expect(acdVatCodeToIdVat(AcdVatCode.REDUIT_10)).toBe(Vat.TX_10.id);\n expect(acdVatCodeToIdVat(AcdVatCode.REDUIT_5_5)).toBe(Vat.TX_5_5.id);\n expect(acdVatCodeToIdVat(AcdVatCode.REDUIT_2_1)).toBe(Vat.TX_2_1.id);\n expect(acdVatCodeToIdVat(AcdVatCode.INTRACOM)).toBe(Vat.INTRACOM_TX_20.id);\n expect(acdVatCodeToIdVat(AcdVatCode.AUTOL)).toBe(Vat.IMPORTATION_TX_20.id);\n expect(acdVatCodeToIdVat(AcdVatCode.NON_AFFECTE)).toBeNull();\n });\n});\n"]}
@@ -1,52 +0,0 @@
1
- export enum AcdVatCode {
2
- AUTOL = 'AUTOL',
3
- INTRACOM = 'INTRACOM',
4
- NON_AFFECTE = 'NON_AFFECTE',
5
- ONI = 'ONI',
6
- SUR_IMMOBILISATION = 'TI',
7
- NORMAL = 'TN',
8
- REDUIT_5_5 = 'TR1',
9
- REDUIT_10 = 'TR2',
10
- REDUIT_2_1 = 'TSR',
11
- SPECIAL = 'TS',
12
- }
13
-
14
- export type AcdCompte = {
15
- Code: string | null;
16
- Categ: string | null;
17
- Lib: string | null;
18
- Let: string | null;
19
- RegEc: string | null;
20
- Qte: string | null;
21
- Coll: boolean;
22
- CptCptCol: string | null;
23
- CodeTVA: string | null;
24
- CompteHorsTaxe: string | null;
25
- CptInactif: boolean;
26
- UniteQte1: Array<string> | null;
27
- UniteQte2: Array<string> | null;
28
- ActivationAnalytique: boolean;
29
- CleRepartition: {
30
- Code: string | null;
31
- Lib: string | null;
32
- Auto: boolean;
33
- } | null;
34
- Tiers: {
35
- Code: number;
36
- RaisonSociale: string | null;
37
- Siren: string | null;
38
- Siret: string | null;
39
- Telephone: string | null;
40
- Email: string | null;
41
- Fax: string | null;
42
- NumeroIntracom: string | null;
43
- Adresse?: {
44
- Numero: string | null;
45
- Nature: string | null;
46
- Complement: string | null;
47
- Hameau: string | null;
48
- CodePostal: string | null;
49
- Pays: string | null;
50
- };
51
- } | null;
52
- };
@@ -1,63 +0,0 @@
1
- import { Vat } from '../types/Enum/Vat.js';
2
- import { AcdVatCode } from '../types/Interface/api/acd/Vat.js';
3
-
4
- export function idVatToAcdVatCode(idVat?: number | null): AcdVatCode | null {
5
- if (!idVat) {
6
- return null;
7
- }
8
-
9
- const vat = Object.values(Vat).find((currentVat) => currentVat.id === idVat);
10
-
11
- if (!vat) {
12
- return AcdVatCode.NON_AFFECTE;
13
- }
14
-
15
- if (vat.isVatIntracom) {
16
- return AcdVatCode.INTRACOM;
17
- }
18
-
19
- if (vat.isVatImportation) {
20
- return AcdVatCode.AUTOL;
21
- }
22
-
23
- switch (vat.value) {
24
- case 2.1:
25
- return AcdVatCode.REDUIT_2_1;
26
- case 5.5:
27
- return AcdVatCode.REDUIT_5_5;
28
- case 10:
29
- return AcdVatCode.REDUIT_10;
30
- case 20:
31
- return AcdVatCode.NORMAL;
32
- case 0:
33
- return null;
34
- default:
35
- return AcdVatCode.NON_AFFECTE;
36
- }
37
- }
38
-
39
- export function acdVatCodeToIdVat(acdVatCode?: AcdVatCode | null): number | null {
40
- switch (acdVatCode) {
41
- case AcdVatCode.NORMAL:
42
- return Vat.TX_20.id;
43
- case AcdVatCode.REDUIT_10:
44
- return Vat.TX_10.id;
45
- case AcdVatCode.REDUIT_5_5:
46
- return Vat.TX_5_5.id;
47
- case AcdVatCode.REDUIT_2_1:
48
- return Vat.TX_2_1.id;
49
- case AcdVatCode.INTRACOM:
50
- // L'information de taux est perdue dans le code ACD, on retombe sur l'intracom a 20% par defaut.
51
- return Vat.INTRACOM_TX_20.id;
52
- case AcdVatCode.AUTOL:
53
- // L'information de taux est perdue dans le code ACD, on retombe sur l'importation a 20% par defaut.
54
- return Vat.IMPORTATION_TX_20.id;
55
- case AcdVatCode.NON_AFFECTE:
56
- case AcdVatCode.ONI:
57
- case AcdVatCode.SUR_IMMOBILISATION:
58
- case AcdVatCode.SPECIAL:
59
- case null:
60
- case undefined:
61
- return null;
62
- }
63
- }
@@ -1,26 +0,0 @@
1
- import { describe, expect, test } from 'vitest';
2
- import { Vat } from '../../types/Enum/Vat.js';
3
- import { AcdVatCode } from '../../types/Interface/api/acd/Vat.js';
4
- import { acdVatCodeToIdVat, idVatToAcdVatCode } from '../acdVat.js';
5
-
6
- describe('acdVat utils', () => {
7
- test('should map internal VAT ids to ACD VAT codes', () => {
8
- expect(idVatToAcdVatCode(Vat.TX_20.id)).toBe(AcdVatCode.NORMAL);
9
- expect(idVatToAcdVatCode(Vat.TX_10.id)).toBe(AcdVatCode.REDUIT_10);
10
- expect(idVatToAcdVatCode(Vat.TX_5_5.id)).toBe(AcdVatCode.REDUIT_5_5);
11
- expect(idVatToAcdVatCode(Vat.TX_2_1.id)).toBe(AcdVatCode.REDUIT_2_1);
12
- expect(idVatToAcdVatCode(Vat.INTRACOM_TX_20.id)).toBe(AcdVatCode.INTRACOM);
13
- expect(idVatToAcdVatCode(Vat.IMPORTATION_TX_20.id)).toBe(AcdVatCode.AUTOL);
14
- expect(idVatToAcdVatCode(Vat.WITHOUT_TAXE.id)).toBeNull();
15
- });
16
-
17
- test('should map ACD VAT codes back to internal VAT ids', () => {
18
- expect(acdVatCodeToIdVat(AcdVatCode.NORMAL)).toBe(Vat.TX_20.id);
19
- expect(acdVatCodeToIdVat(AcdVatCode.REDUIT_10)).toBe(Vat.TX_10.id);
20
- expect(acdVatCodeToIdVat(AcdVatCode.REDUIT_5_5)).toBe(Vat.TX_5_5.id);
21
- expect(acdVatCodeToIdVat(AcdVatCode.REDUIT_2_1)).toBe(Vat.TX_2_1.id);
22
- expect(acdVatCodeToIdVat(AcdVatCode.INTRACOM)).toBe(Vat.INTRACOM_TX_20.id);
23
- expect(acdVatCodeToIdVat(AcdVatCode.AUTOL)).toBe(Vat.IMPORTATION_TX_20.id);
24
- expect(acdVatCodeToIdVat(AcdVatCode.NON_AFFECTE)).toBeNull();
25
- });
26
- });