avantgate 1.0.0 → 1.1.0

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.
@@ -0,0 +1,521 @@
1
+ // src/finance/strategies/french-pcg.strategy.ts
2
+ var FrenchPCGStrategy = class {
3
+ jurisdictionCode = "FR";
4
+ standard = "PCG";
5
+ defaultCurrency = "EUR";
6
+ cleanNumber(value) {
7
+ if (typeof value === "number") {
8
+ return Number.isFinite(value) ? value : 0;
9
+ }
10
+ if (!value || typeof value !== "string") {
11
+ return 0;
12
+ }
13
+ let str = value.trim();
14
+ let isNegative = false;
15
+ const parenMatch = str.match(/^\(\s*(.+?)\s*\)$/);
16
+ if (parenMatch) {
17
+ isNegative = true;
18
+ str = parenMatch[1];
19
+ } else if (str.startsWith("-")) {
20
+ isNegative = true;
21
+ str = str.substring(1).trim();
22
+ }
23
+ let multiplier = 1;
24
+ if (/[kK](?:€|eur)?\b/i.test(str)) {
25
+ multiplier = 1e3;
26
+ str = str.replace(/[kK](?:€|eur)?\b/gi, "").trim();
27
+ } else if (/[mM](?:€|eur)?\b/i.test(str)) {
28
+ multiplier = 1e6;
29
+ str = str.replace(/[mM](?:€|eur)?\b/gi, "").trim();
30
+ }
31
+ str = str.replace(/[€$£]/g, "").replace(/\s+/g, "").replace(/\u00A0/g, "").trim();
32
+ str = str.replace(",", ".");
33
+ const parsed = parseFloat(str);
34
+ if (isNaN(parsed)) {
35
+ return 0;
36
+ }
37
+ const finalValue = parsed * multiplier;
38
+ return isNegative ? -Math.abs(finalValue) : finalValue;
39
+ }
40
+ cleanJSON(rawText) {
41
+ let result = rawText;
42
+ result = result.replace(
43
+ /(:\s*)\(\s*([0-9][0-9\s.,]*(?:k€|k|keur|m€|m|meur|€)?)\s*\)/gi,
44
+ (_, prefix, amountStr) => {
45
+ const num = this.cleanNumber(`(${amountStr})`);
46
+ return `${prefix}${num}`;
47
+ }
48
+ );
49
+ result = result.replace(
50
+ /(:\s*)"\s*\(\s*([0-9][0-9\s.,]*(?:k€|k|keur|m€|m|meur|€)?)\s*\)\s*"/gi,
51
+ (_, prefix, amountStr) => {
52
+ const num = this.cleanNumber(`(${amountStr})`);
53
+ return `${prefix}${num}`;
54
+ }
55
+ );
56
+ result = result.replace(
57
+ /(:\s*)"\s*([+-]?[0-9][0-9\s.,]*(?:k€|k|keur|m€|m|meur|€))\s*"/gi,
58
+ (_, prefix, amountStr) => {
59
+ const num = this.cleanNumber(amountStr);
60
+ return `${prefix}${num}`;
61
+ }
62
+ );
63
+ result = result.replace(
64
+ /(:\s*)"\s*([+-]?(?:[0-9]{1,3}(?:\s+[0-9]{3})+(?:,[0-9]+)?|[0-9]+,[0-9]+))\s*"/g,
65
+ (_, prefix, amountStr) => {
66
+ const num = this.cleanNumber(amountStr);
67
+ return `${prefix}${num}`;
68
+ }
69
+ );
70
+ return result;
71
+ }
72
+ detect(text) {
73
+ const lower = text.toLowerCase();
74
+ const frPatterns = [
75
+ /\bcerfa\b/i,
76
+ /\bliasse\s+fiscale\b/i,
77
+ /\bbilan\s+(actif|passif)\b/i,
78
+ /\bcompte\s+de\s+r[ée]sultat\b/i,
79
+ /\bplan\s+comptable\s+g[ée]n[ée]ral\b/i,
80
+ /\bpcg\b/i,
81
+ /\bsiren\b/i,
82
+ /\bsiret\b/i,
83
+ /\b[0-9\s.,]+(?:k€|m€)\b/i,
84
+ /\beur\b/i,
85
+ /€/
86
+ ];
87
+ return frPatterns.some((pattern) => pattern.test(lower));
88
+ }
89
+ };
90
+
91
+ // src/finance/strategies/us-gaap.strategy.ts
92
+ var UsGAAPStrategy = class {
93
+ jurisdictionCode = "US";
94
+ standard = "US_GAAP";
95
+ defaultCurrency = "USD";
96
+ cleanNumber(value) {
97
+ if (typeof value === "number") {
98
+ return Number.isFinite(value) ? value : 0;
99
+ }
100
+ if (!value || typeof value !== "string") {
101
+ return 0;
102
+ }
103
+ let str = value.trim();
104
+ let isNegative = false;
105
+ const parenMatch = str.match(/^[(\[]\s*(.+?)\s*[)\]]$/);
106
+ if (parenMatch) {
107
+ isNegative = true;
108
+ str = parenMatch[1];
109
+ } else if (str.startsWith("-")) {
110
+ isNegative = true;
111
+ str = str.substring(1).trim();
112
+ }
113
+ let multiplier = 1;
114
+ if (/[kK]\b/.test(str)) {
115
+ multiplier = 1e3;
116
+ str = str.replace(/[kK]\b/g, "").trim();
117
+ } else if (/[mM]\b/.test(str)) {
118
+ multiplier = 1e6;
119
+ str = str.replace(/[mM]\b/g, "").trim();
120
+ } else if (/[bB]\b/.test(str)) {
121
+ multiplier = 1e9;
122
+ str = str.replace(/[bB]\b/g, "").trim();
123
+ }
124
+ str = str.replace(/[$]/g, "").replace(/\busd\b/gi, "").replace(/,/g, "").replace(/\s+/g, "").trim();
125
+ const parsed = parseFloat(str);
126
+ if (isNaN(parsed)) {
127
+ return 0;
128
+ }
129
+ const finalVal = parsed * multiplier;
130
+ return isNegative ? -Math.abs(finalVal) : finalVal;
131
+ }
132
+ cleanJSON(rawText) {
133
+ let result = rawText;
134
+ result = result.replace(
135
+ /(:\s*)[(\[]\s*([0-9][0-9,.]*(?:k|m|b|\$)?)\s*[)\]]/gi,
136
+ (_, prefix, amountStr) => {
137
+ const num = this.cleanNumber(`(${amountStr})`);
138
+ return `${prefix}${num}`;
139
+ }
140
+ );
141
+ result = result.replace(
142
+ /(:\s*)"\s*[(\[]\s*([0-9][0-9,.]*(?:k|m|b|\$)?)\s*[)\]]\s*"/gi,
143
+ (_, prefix, amountStr) => {
144
+ const num = this.cleanNumber(`(${amountStr})`);
145
+ return `${prefix}${num}`;
146
+ }
147
+ );
148
+ result = result.replace(
149
+ /(:\s*)"\s*([+-]?\$?\s*[0-9][0-9,.]*\s*(?:k|m|b|\$)?)\s*"/gi,
150
+ (_, prefix, amountStr) => {
151
+ if (!amountStr.includes("$") && !/[kmb]/i.test(amountStr)) {
152
+ return `${prefix}"${amountStr}"`;
153
+ }
154
+ const num = this.cleanNumber(amountStr);
155
+ return `${prefix}${num}`;
156
+ }
157
+ );
158
+ return result;
159
+ }
160
+ detect(text) {
161
+ const lower = text.toLowerCase();
162
+ const usPatterns = [
163
+ /\b10-[kq]\b/i,
164
+ /\bsec\s+filing\b/i,
165
+ /\bus[\s_-]?gaap\b/i,
166
+ /\bbalance\s+sheet\b/i,
167
+ /\bincome\s+statement\b/i,
168
+ /\bstatement\s+of\s+cash\s+flows\b/i,
169
+ /\$|usd/i
170
+ ];
171
+ return usPatterns.some((pattern) => pattern.test(lower));
172
+ }
173
+ };
174
+
175
+ // src/finance/strategies/uk-ifrs.strategy.ts
176
+ var UkIFRSStrategy = class {
177
+ jurisdictionCode = "UK";
178
+ standard = "IFRS";
179
+ defaultCurrency = "GBP";
180
+ cleanNumber(value) {
181
+ if (typeof value === "number") {
182
+ return Number.isFinite(value) ? value : 0;
183
+ }
184
+ if (!value || typeof value !== "string") {
185
+ return 0;
186
+ }
187
+ let str = value.trim();
188
+ let isNegative = false;
189
+ const parenMatch = str.match(/^\(\s*(.+?)\s*\)$/);
190
+ if (parenMatch) {
191
+ isNegative = true;
192
+ str = parenMatch[1];
193
+ } else if (str.startsWith("-")) {
194
+ isNegative = true;
195
+ str = str.substring(1).trim();
196
+ }
197
+ let multiplier = 1;
198
+ if (/[kK]\b/.test(str)) {
199
+ multiplier = 1e3;
200
+ str = str.replace(/[kK]\b/g, "").trim();
201
+ } else if (/[mM]\b/.test(str)) {
202
+ multiplier = 1e6;
203
+ str = str.replace(/[mM]\b/g, "").trim();
204
+ }
205
+ str = str.replace(/[£]/g, "").replace(/\bgbp\b/gi, "").replace(/,/g, "").replace(/\s+/g, "").trim();
206
+ const parsed = parseFloat(str);
207
+ if (isNaN(parsed)) {
208
+ return 0;
209
+ }
210
+ const finalVal = parsed * multiplier;
211
+ return isNegative ? -Math.abs(finalVal) : finalVal;
212
+ }
213
+ cleanJSON(rawText) {
214
+ let result = rawText;
215
+ result = result.replace(
216
+ /(:\s*)\(\s*([0-9][0-9,.]*(?:k|m|£)?)\s*\)/gi,
217
+ (_, prefix, amountStr) => {
218
+ const num = this.cleanNumber(`(${amountStr})`);
219
+ return `${prefix}${num}`;
220
+ }
221
+ );
222
+ result = result.replace(
223
+ /(:\s*)"\s*\(\s*([0-9][0-9,.]*(?:k|m|£)?)\s*\)\s*"/gi,
224
+ (_, prefix, amountStr) => {
225
+ const num = this.cleanNumber(`(${amountStr})`);
226
+ return `${prefix}${num}`;
227
+ }
228
+ );
229
+ result = result.replace(
230
+ /(:\s*)"\s*([+-]?£\s*[0-9][0-9,.]*\s*(?:k|m)?)\s*"/gi,
231
+ (_, prefix, amountStr) => {
232
+ const num = this.cleanNumber(amountStr);
233
+ return `${prefix}${num}`;
234
+ }
235
+ );
236
+ return result;
237
+ }
238
+ detect(text) {
239
+ const lower = text.toLowerCase();
240
+ const ukPatterns = [
241
+ /\bcompanies\s+house\b/i,
242
+ /\bfrs\s*102\b/i,
243
+ /\bhmrc\b/i,
244
+ /\bprofit\s+and\s+loss\b/i,
245
+ /£|\bgbp\b/i
246
+ ];
247
+ return ukPatterns.some((pattern) => pattern.test(lower));
248
+ }
249
+ };
250
+
251
+ // src/finance/strategies/swiss-co.strategy.ts
252
+ var SwissCOStrategy = class {
253
+ jurisdictionCode = "CH";
254
+ standard = "SWISS_CO";
255
+ defaultCurrency = "CHF";
256
+ cleanNumber(value) {
257
+ if (typeof value === "number") {
258
+ return Number.isFinite(value) ? value : 0;
259
+ }
260
+ if (!value || typeof value !== "string") {
261
+ return 0;
262
+ }
263
+ let str = value.trim();
264
+ let isNegative = false;
265
+ const parenMatch = str.match(/^\(\s*(.+?)\s*\)$/);
266
+ if (parenMatch) {
267
+ isNegative = true;
268
+ str = parenMatch[1];
269
+ } else if (str.startsWith("-")) {
270
+ isNegative = true;
271
+ str = str.substring(1).trim();
272
+ }
273
+ let multiplier = 1;
274
+ if (/[kK]\b/.test(str)) {
275
+ multiplier = 1e3;
276
+ str = str.replace(/[kK]\b/g, "").trim();
277
+ } else if (/[mM]\b/.test(str)) {
278
+ multiplier = 1e6;
279
+ str = str.replace(/[mM]\b/g, "").trim();
280
+ }
281
+ str = str.replace(/\bchf\b/gi, "").replace(/['’]/g, "").replace(/\s+/g, "").trim();
282
+ str = str.replace(",", ".");
283
+ const parsed = parseFloat(str);
284
+ if (isNaN(parsed)) {
285
+ return 0;
286
+ }
287
+ const finalVal = parsed * multiplier;
288
+ return isNegative ? -Math.abs(finalVal) : finalVal;
289
+ }
290
+ cleanJSON(rawText) {
291
+ let result = rawText;
292
+ result = result.replace(
293
+ /(:\s*)\(\s*([0-9][0-9'’.,\s]*(?:k|m|chf)?)\s*\)/gi,
294
+ (_, prefix, amountStr) => {
295
+ const num = this.cleanNumber(`(${amountStr})`);
296
+ return `${prefix}${num}`;
297
+ }
298
+ );
299
+ result = result.replace(
300
+ /(:\s*)"\s*\(\s*([0-9][0-9'’.,\s]*(?:k|m|chf)?)\s*\)\s*"/gi,
301
+ (_, prefix, amountStr) => {
302
+ const num = this.cleanNumber(`(${amountStr})`);
303
+ return `${prefix}${num}`;
304
+ }
305
+ );
306
+ result = result.replace(
307
+ /(:\s*)"\s*([+-]?[0-9][0-9'’.,\s]*(?:k|m|chf))\s*"/gi,
308
+ (_, prefix, amountStr) => {
309
+ const num = this.cleanNumber(amountStr);
310
+ return `${prefix}${num}`;
311
+ }
312
+ );
313
+ return result;
314
+ }
315
+ detect(text) {
316
+ const lower = text.toLowerCase();
317
+ const chPatterns = [
318
+ /\bcode\s+des\s+obligations\b/i,
319
+ /\bart\.?\s*725\b/i,
320
+ /\bche-[0-9]{3}\.[0-9]{3}\.[0-9]{3}\b/i,
321
+ /\bchf\b/i,
322
+ /\b[0-9]{1,3}(?:'[0-9]{3})+\b/
323
+ ];
324
+ return chPatterns.some((pattern) => pattern.test(lower));
325
+ }
326
+ };
327
+
328
+ // src/finance/strategies/international.strategy.ts
329
+ var InternationalAccountingStrategy = class {
330
+ jurisdictionCode = "INTERNATIONAL";
331
+ standard = "OTHER";
332
+ defaultCurrency = "EUR";
333
+ cleanNumber(value) {
334
+ if (typeof value === "number") {
335
+ return Number.isFinite(value) ? value : 0;
336
+ }
337
+ if (!value || typeof value !== "string") {
338
+ return 0;
339
+ }
340
+ let str = value.trim();
341
+ let isNegative = false;
342
+ const parenMatch = str.match(/^[(\[]\s*(.+?)\s*[)\]]$/);
343
+ if (parenMatch) {
344
+ isNegative = true;
345
+ str = parenMatch[1];
346
+ } else if (str.startsWith("-")) {
347
+ isNegative = true;
348
+ str = str.substring(1).trim();
349
+ }
350
+ let multiplier = 1;
351
+ if (/[kK]\b/.test(str)) {
352
+ multiplier = 1e3;
353
+ str = str.replace(/[kK]\b/g, "").trim();
354
+ } else if (/[mM]\b/.test(str)) {
355
+ multiplier = 1e6;
356
+ str = str.replace(/[mM]\b/g, "").trim();
357
+ }
358
+ str = str.replace(/[€$£]/g, "").replace(/\b(?:eur|usd|gbp|chf)\b/gi, "").trim();
359
+ if (str.includes(",") && str.includes(".")) {
360
+ if (str.lastIndexOf(",") > str.lastIndexOf(".")) {
361
+ str = str.replace(/\./g, "").replace(",", ".");
362
+ } else {
363
+ str = str.replace(/,/g, "");
364
+ }
365
+ } else if (str.includes(",")) {
366
+ if (/,\d{1,2}$/.test(str)) {
367
+ str = str.replace(",", ".");
368
+ } else {
369
+ str = str.replace(",", "");
370
+ }
371
+ }
372
+ str = str.replace(/\s+/g, "");
373
+ const parsed = parseFloat(str);
374
+ if (isNaN(parsed)) {
375
+ return 0;
376
+ }
377
+ const finalVal = parsed * multiplier;
378
+ return isNegative ? -Math.abs(finalVal) : finalVal;
379
+ }
380
+ cleanJSON(rawText) {
381
+ let result = rawText;
382
+ result = result.replace(
383
+ /(:\s*)[(\[]\s*([0-9][0-9,.\s]*(?:k|m|€|\$|£)?)\s*[)\]]/gi,
384
+ (_, prefix, amountStr) => {
385
+ const num = this.cleanNumber(`(${amountStr})`);
386
+ return `${prefix}${num}`;
387
+ }
388
+ );
389
+ result = result.replace(
390
+ /(:\s*)"\s*[(\[]\s*([0-9][0-9,.\s]*(?:k|m|€|\$|£)?)\s*[)\]]\s*"/gi,
391
+ (_, prefix, amountStr) => {
392
+ const num = this.cleanNumber(`(${amountStr})`);
393
+ return `${prefix}${num}`;
394
+ }
395
+ );
396
+ return result;
397
+ }
398
+ detect(_text) {
399
+ return true;
400
+ }
401
+ };
402
+
403
+ // src/finance/factory.ts
404
+ var AccountingFactory = class {
405
+ static strategies = /* @__PURE__ */ new Map();
406
+ static detectionOrder = [];
407
+ static {
408
+ this.initDefaults();
409
+ }
410
+ static initDefaults() {
411
+ const fr = new FrenchPCGStrategy();
412
+ const us = new UsGAAPStrategy();
413
+ const uk = new UkIFRSStrategy();
414
+ const ch = new SwissCOStrategy();
415
+ const intl = new InternationalAccountingStrategy();
416
+ this.registerStrategy(ch);
417
+ this.registerStrategy(uk);
418
+ this.registerStrategy(us);
419
+ this.registerStrategy(fr);
420
+ this.registerStrategy(intl);
421
+ }
422
+ static registerStrategy(strategy) {
423
+ this.strategies.set(strategy.jurisdictionCode, strategy);
424
+ this.detectionOrder = [
425
+ strategy,
426
+ ...this.detectionOrder.filter((s) => s.jurisdictionCode !== strategy.jurisdictionCode)
427
+ ];
428
+ }
429
+ static getStrategy(code) {
430
+ if (!code) {
431
+ return this.strategies.get("FR") || new FrenchPCGStrategy();
432
+ }
433
+ const strategy = this.strategies.get(code);
434
+ if (!strategy) {
435
+ return this.strategies.get("FR") || new FrenchPCGStrategy();
436
+ }
437
+ return strategy;
438
+ }
439
+ static detectStrategy(documentText) {
440
+ for (const strategy of this.detectionOrder) {
441
+ if (strategy.jurisdictionCode !== "INTERNATIONAL" && strategy.detect(documentText)) {
442
+ return strategy;
443
+ }
444
+ }
445
+ return this.getStrategy("FR");
446
+ }
447
+ static resetDefaults() {
448
+ this.strategies.clear();
449
+ this.detectionOrder = [];
450
+ this.initDefaults();
451
+ }
452
+ };
453
+
454
+ // src/response-validator.ts
455
+ function extractAndCleanJSON(rawText) {
456
+ let cleaned = rawText.trim();
457
+ cleaned = cleaned.replace(/<think>[\s\S]*?<\/think>/gi, "").trim();
458
+ const codeBlockMatch = cleaned.match(/```(?:json)?\s*([\s\S]*?)\s*```/i);
459
+ if (codeBlockMatch && codeBlockMatch[1]) {
460
+ cleaned = codeBlockMatch[1].trim();
461
+ }
462
+ const firstBrace = cleaned.indexOf("{");
463
+ const firstBracket = cleaned.indexOf("[");
464
+ let startIndex = -1;
465
+ if (firstBrace !== -1 && firstBracket !== -1) {
466
+ startIndex = Math.min(firstBrace, firstBracket);
467
+ } else if (firstBrace !== -1) {
468
+ startIndex = firstBrace;
469
+ } else if (firstBracket !== -1) {
470
+ startIndex = firstBracket;
471
+ }
472
+ const lastBrace = cleaned.lastIndexOf("}");
473
+ const lastBracket = cleaned.lastIndexOf("]");
474
+ const endIndex = Math.max(lastBrace, lastBracket);
475
+ if (startIndex !== -1 && endIndex !== -1 && endIndex > startIndex) {
476
+ cleaned = cleaned.slice(startIndex, endIndex + 1);
477
+ }
478
+ return cleaned;
479
+ }
480
+ function validateWithZod(rawText, schema, options) {
481
+ let jsonString = extractAndCleanJSON(rawText);
482
+ if (options?.normalizer) {
483
+ jsonString = options.normalizer(jsonString);
484
+ } else if (options?.financialNormalizer) {
485
+ jsonString = cleanFinancialJSON(jsonString, { jurisdiction: options.jurisdiction });
486
+ }
487
+ let parsed;
488
+ try {
489
+ parsed = JSON.parse(jsonString);
490
+ } catch (_error) {
491
+ const sanitized = jsonString.replace(/,\s*([}\]])/g, "$1").replace(/'/g, '"');
492
+ parsed = JSON.parse(sanitized);
493
+ }
494
+ return schema.parse(parsed);
495
+ }
496
+
497
+ // src/finance/normalizer.ts
498
+ function cleanFinancialJSON(rawText, options) {
499
+ if (!rawText) {
500
+ return "";
501
+ }
502
+ const jsonBlock = extractAndCleanJSON(rawText);
503
+ const strategy = options?.jurisdiction ? AccountingFactory.getStrategy(options.jurisdiction) : options?.autoDetect !== false ? AccountingFactory.detectStrategy(rawText) : AccountingFactory.getStrategy("FR");
504
+ return strategy.cleanJSON(jsonBlock);
505
+ }
506
+ function withFinancialNormalizer(options) {
507
+ return (rawText) => cleanFinancialJSON(rawText, options);
508
+ }
509
+
510
+ export {
511
+ FrenchPCGStrategy,
512
+ UsGAAPStrategy,
513
+ UkIFRSStrategy,
514
+ SwissCOStrategy,
515
+ InternationalAccountingStrategy,
516
+ AccountingFactory,
517
+ cleanFinancialJSON,
518
+ withFinancialNormalizer,
519
+ extractAndCleanJSON,
520
+ validateWithZod
521
+ };
@@ -0,0 +1,76 @@
1
+ import { I as IAccountingStrategy, F as FinancialJurisdictionCode, A as AccountingStandard, a as FinancialCurrency } from '../strategy.interface-CB4_ZAuk.mjs';
2
+
3
+ declare class AccountingFactory {
4
+ private static strategies;
5
+ private static detectionOrder;
6
+ private static initDefaults;
7
+ static registerStrategy(strategy: IAccountingStrategy): void;
8
+ static getStrategy(code?: FinancialJurisdictionCode): IAccountingStrategy;
9
+ static detectStrategy(documentText: string): IAccountingStrategy;
10
+ static resetDefaults(): void;
11
+ }
12
+
13
+ interface FinancialNormalizerOptions {
14
+ jurisdiction?: FinancialJurisdictionCode;
15
+ autoDetect?: boolean;
16
+ }
17
+ /**
18
+ * Assainit et répare une chaîne JSON contenant des données financières :
19
+ * - Notation comptable négative entre parenthèses : (150 000) -> -150000
20
+ * - Espaces et virgules décimales : "1 850 000,50 €" -> 1850000.50
21
+ * - Abréviations de grandeurs : "1 850 k€" -> 1850000, "2.4 M€" -> 2400000
22
+ * - Suppression des symboles de devises dans les positions numériques
23
+ * - Préservation stricte des chaînes descriptives normales contenant des parenthèses
24
+ */
25
+ declare function cleanFinancialJSON(rawText: string, options?: FinancialNormalizerOptions): string;
26
+ /**
27
+ * Crée une fonction de transformation financière réutilisable.
28
+ */
29
+ declare function withFinancialNormalizer(options?: FinancialNormalizerOptions): (rawText: string) => string;
30
+
31
+ declare class FrenchPCGStrategy implements IAccountingStrategy {
32
+ readonly jurisdictionCode: FinancialJurisdictionCode;
33
+ readonly standard: AccountingStandard;
34
+ readonly defaultCurrency: FinancialCurrency;
35
+ cleanNumber(value: string | number): number;
36
+ cleanJSON(rawText: string): string;
37
+ detect(text: string): boolean;
38
+ }
39
+
40
+ declare class UsGAAPStrategy implements IAccountingStrategy {
41
+ readonly jurisdictionCode: FinancialJurisdictionCode;
42
+ readonly standard: AccountingStandard;
43
+ readonly defaultCurrency: FinancialCurrency;
44
+ cleanNumber(value: string | number): number;
45
+ cleanJSON(rawText: string): string;
46
+ detect(text: string): boolean;
47
+ }
48
+
49
+ declare class UkIFRSStrategy implements IAccountingStrategy {
50
+ readonly jurisdictionCode: FinancialJurisdictionCode;
51
+ readonly standard: AccountingStandard;
52
+ readonly defaultCurrency: FinancialCurrency;
53
+ cleanNumber(value: string | number): number;
54
+ cleanJSON(rawText: string): string;
55
+ detect(text: string): boolean;
56
+ }
57
+
58
+ declare class SwissCOStrategy implements IAccountingStrategy {
59
+ readonly jurisdictionCode: FinancialJurisdictionCode;
60
+ readonly standard: AccountingStandard;
61
+ readonly defaultCurrency: FinancialCurrency;
62
+ cleanNumber(value: string | number): number;
63
+ cleanJSON(rawText: string): string;
64
+ detect(text: string): boolean;
65
+ }
66
+
67
+ declare class InternationalAccountingStrategy implements IAccountingStrategy {
68
+ readonly jurisdictionCode: FinancialJurisdictionCode;
69
+ readonly standard: AccountingStandard;
70
+ readonly defaultCurrency: FinancialCurrency;
71
+ cleanNumber(value: string | number): number;
72
+ cleanJSON(rawText: string): string;
73
+ detect(_text: string): boolean;
74
+ }
75
+
76
+ export { AccountingFactory, AccountingStandard, FinancialCurrency, FinancialJurisdictionCode, type FinancialNormalizerOptions, FrenchPCGStrategy, IAccountingStrategy, InternationalAccountingStrategy, SwissCOStrategy, UkIFRSStrategy, UsGAAPStrategy, cleanFinancialJSON, withFinancialNormalizer };
@@ -0,0 +1,76 @@
1
+ import { I as IAccountingStrategy, F as FinancialJurisdictionCode, A as AccountingStandard, a as FinancialCurrency } from '../strategy.interface-CB4_ZAuk.js';
2
+
3
+ declare class AccountingFactory {
4
+ private static strategies;
5
+ private static detectionOrder;
6
+ private static initDefaults;
7
+ static registerStrategy(strategy: IAccountingStrategy): void;
8
+ static getStrategy(code?: FinancialJurisdictionCode): IAccountingStrategy;
9
+ static detectStrategy(documentText: string): IAccountingStrategy;
10
+ static resetDefaults(): void;
11
+ }
12
+
13
+ interface FinancialNormalizerOptions {
14
+ jurisdiction?: FinancialJurisdictionCode;
15
+ autoDetect?: boolean;
16
+ }
17
+ /**
18
+ * Assainit et répare une chaîne JSON contenant des données financières :
19
+ * - Notation comptable négative entre parenthèses : (150 000) -> -150000
20
+ * - Espaces et virgules décimales : "1 850 000,50 €" -> 1850000.50
21
+ * - Abréviations de grandeurs : "1 850 k€" -> 1850000, "2.4 M€" -> 2400000
22
+ * - Suppression des symboles de devises dans les positions numériques
23
+ * - Préservation stricte des chaînes descriptives normales contenant des parenthèses
24
+ */
25
+ declare function cleanFinancialJSON(rawText: string, options?: FinancialNormalizerOptions): string;
26
+ /**
27
+ * Crée une fonction de transformation financière réutilisable.
28
+ */
29
+ declare function withFinancialNormalizer(options?: FinancialNormalizerOptions): (rawText: string) => string;
30
+
31
+ declare class FrenchPCGStrategy implements IAccountingStrategy {
32
+ readonly jurisdictionCode: FinancialJurisdictionCode;
33
+ readonly standard: AccountingStandard;
34
+ readonly defaultCurrency: FinancialCurrency;
35
+ cleanNumber(value: string | number): number;
36
+ cleanJSON(rawText: string): string;
37
+ detect(text: string): boolean;
38
+ }
39
+
40
+ declare class UsGAAPStrategy implements IAccountingStrategy {
41
+ readonly jurisdictionCode: FinancialJurisdictionCode;
42
+ readonly standard: AccountingStandard;
43
+ readonly defaultCurrency: FinancialCurrency;
44
+ cleanNumber(value: string | number): number;
45
+ cleanJSON(rawText: string): string;
46
+ detect(text: string): boolean;
47
+ }
48
+
49
+ declare class UkIFRSStrategy implements IAccountingStrategy {
50
+ readonly jurisdictionCode: FinancialJurisdictionCode;
51
+ readonly standard: AccountingStandard;
52
+ readonly defaultCurrency: FinancialCurrency;
53
+ cleanNumber(value: string | number): number;
54
+ cleanJSON(rawText: string): string;
55
+ detect(text: string): boolean;
56
+ }
57
+
58
+ declare class SwissCOStrategy implements IAccountingStrategy {
59
+ readonly jurisdictionCode: FinancialJurisdictionCode;
60
+ readonly standard: AccountingStandard;
61
+ readonly defaultCurrency: FinancialCurrency;
62
+ cleanNumber(value: string | number): number;
63
+ cleanJSON(rawText: string): string;
64
+ detect(text: string): boolean;
65
+ }
66
+
67
+ declare class InternationalAccountingStrategy implements IAccountingStrategy {
68
+ readonly jurisdictionCode: FinancialJurisdictionCode;
69
+ readonly standard: AccountingStandard;
70
+ readonly defaultCurrency: FinancialCurrency;
71
+ cleanNumber(value: string | number): number;
72
+ cleanJSON(rawText: string): string;
73
+ detect(_text: string): boolean;
74
+ }
75
+
76
+ export { AccountingFactory, AccountingStandard, FinancialCurrency, FinancialJurisdictionCode, type FinancialNormalizerOptions, FrenchPCGStrategy, IAccountingStrategy, InternationalAccountingStrategy, SwissCOStrategy, UkIFRSStrategy, UsGAAPStrategy, cleanFinancialJSON, withFinancialNormalizer };