@taxora/sdk 1.0.6 → 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.
- package/README.md +297 -0
- package/dist/index.cjs +1889 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +905 -2
- package/dist/index.d.ts +905 -2
- package/dist/index.js +1856 -23
- package/dist/index.js.map +1 -1
- package/package.json +10 -5
package/dist/index.js
CHANGED
|
@@ -223,6 +223,1779 @@ var CompanyEndpoint = class {
|
|
|
223
223
|
}
|
|
224
224
|
};
|
|
225
225
|
|
|
226
|
+
// src/enums/ComplianceEnrollmentStatus.ts
|
|
227
|
+
var ComplianceEnrollmentStatus = {
|
|
228
|
+
PENDING_DATA: "pending_data",
|
|
229
|
+
ACCOUNT_CREATED: "account_created",
|
|
230
|
+
REGIME_ACTIVATED: "regime_activated",
|
|
231
|
+
READY: "ready",
|
|
232
|
+
SUSPENDED: "suspended",
|
|
233
|
+
ERROR_ACCOUNT: "error_account",
|
|
234
|
+
ERROR_ACTIVATION: "error_activation",
|
|
235
|
+
UNKNOWN: "unknown"
|
|
236
|
+
};
|
|
237
|
+
var VALUES = Object.values(ComplianceEnrollmentStatus);
|
|
238
|
+
function toComplianceEnrollmentStatus(value) {
|
|
239
|
+
if (typeof value === "string") {
|
|
240
|
+
const normalized = value.trim().toLowerCase();
|
|
241
|
+
if (VALUES.includes(normalized)) {
|
|
242
|
+
return normalized;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return ComplianceEnrollmentStatus.UNKNOWN;
|
|
246
|
+
}
|
|
247
|
+
var DESCRIPTIONS = {
|
|
248
|
+
[ComplianceEnrollmentStatus.PENDING_DATA]: "Awaiting merchant data before provisioning can start.",
|
|
249
|
+
[ComplianceEnrollmentStatus.ACCOUNT_CREATED]: "Provider account exists. Regime not yet activated.",
|
|
250
|
+
[ComplianceEnrollmentStatus.REGIME_ACTIVATED]: "Compliance regime activated at provider. Ready to submit transactions.",
|
|
251
|
+
[ComplianceEnrollmentStatus.READY]: "Enrollment fully active and reporting.",
|
|
252
|
+
[ComplianceEnrollmentStatus.SUSPENDED]: "Enrollment temporarily suspended.",
|
|
253
|
+
[ComplianceEnrollmentStatus.ERROR_ACCOUNT]: "Provider account creation failed.",
|
|
254
|
+
[ComplianceEnrollmentStatus.ERROR_ACTIVATION]: "Regime activation at provider failed.",
|
|
255
|
+
[ComplianceEnrollmentStatus.UNKNOWN]: "Unknown status."
|
|
256
|
+
};
|
|
257
|
+
function describeComplianceEnrollmentStatus(status) {
|
|
258
|
+
return DESCRIPTIONS[status];
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// src/dto/ComplianceEnrollment.ts
|
|
262
|
+
function asString(value, fallback = "") {
|
|
263
|
+
return typeof value === "string" ? value : fallback;
|
|
264
|
+
}
|
|
265
|
+
function asNullableString(value) {
|
|
266
|
+
return typeof value === "string" ? value : null;
|
|
267
|
+
}
|
|
268
|
+
function asNumber(value) {
|
|
269
|
+
return typeof value === "number" ? value : Number(value ?? 0) || 0;
|
|
270
|
+
}
|
|
271
|
+
var ComplianceEnrollment = class _ComplianceEnrollment {
|
|
272
|
+
constructor(id, companyId, country, regime, provider, status, statusLabel, statusError, providerAccountId, taxId, companyRegisterId, companyRegisterScheme, regimeConfig, reportingStartDate, notificationEmail, autoSend, createdAt, updatedAt) {
|
|
273
|
+
this.id = id;
|
|
274
|
+
this.companyId = companyId;
|
|
275
|
+
this.country = country;
|
|
276
|
+
this.regime = regime;
|
|
277
|
+
this.provider = provider;
|
|
278
|
+
this.status = status;
|
|
279
|
+
this.statusLabel = statusLabel;
|
|
280
|
+
this.statusError = statusError;
|
|
281
|
+
this.providerAccountId = providerAccountId;
|
|
282
|
+
this.taxId = taxId;
|
|
283
|
+
this.companyRegisterId = companyRegisterId;
|
|
284
|
+
this.companyRegisterScheme = companyRegisterScheme;
|
|
285
|
+
this.regimeConfig = regimeConfig;
|
|
286
|
+
this.reportingStartDate = reportingStartDate;
|
|
287
|
+
this.notificationEmail = notificationEmail;
|
|
288
|
+
this.autoSend = autoSend;
|
|
289
|
+
this.createdAt = createdAt;
|
|
290
|
+
this.updatedAt = updatedAt;
|
|
291
|
+
}
|
|
292
|
+
id;
|
|
293
|
+
companyId;
|
|
294
|
+
country;
|
|
295
|
+
regime;
|
|
296
|
+
provider;
|
|
297
|
+
status;
|
|
298
|
+
statusLabel;
|
|
299
|
+
statusError;
|
|
300
|
+
providerAccountId;
|
|
301
|
+
taxId;
|
|
302
|
+
companyRegisterId;
|
|
303
|
+
companyRegisterScheme;
|
|
304
|
+
regimeConfig;
|
|
305
|
+
reportingStartDate;
|
|
306
|
+
notificationEmail;
|
|
307
|
+
autoSend;
|
|
308
|
+
createdAt;
|
|
309
|
+
updatedAt;
|
|
310
|
+
static fromArray(data) {
|
|
311
|
+
const regimeConfig = typeof data["regime_config"] === "object" && data["regime_config"] !== null && !Array.isArray(data["regime_config"]) ? data["regime_config"] : null;
|
|
312
|
+
return new _ComplianceEnrollment(
|
|
313
|
+
asNumber(data["id"]),
|
|
314
|
+
asNumber(data["company_id"]),
|
|
315
|
+
asString(data["country"]),
|
|
316
|
+
asString(data["regime"]),
|
|
317
|
+
asString(data["provider"]),
|
|
318
|
+
toComplianceEnrollmentStatus(data["status"]),
|
|
319
|
+
asString(data["status_label"]),
|
|
320
|
+
asNullableString(data["status_error"]),
|
|
321
|
+
asNullableString(data["provider_account_id"]),
|
|
322
|
+
asNullableString(data["tax_id"]),
|
|
323
|
+
asNullableString(data["company_register_id"]),
|
|
324
|
+
asNullableString(data["company_register_scheme"]),
|
|
325
|
+
regimeConfig,
|
|
326
|
+
asNullableString(data["reporting_start_date"]),
|
|
327
|
+
asNullableString(data["notification_email"]),
|
|
328
|
+
data["auto_send"] === true,
|
|
329
|
+
asNullableString(data["created_at"]),
|
|
330
|
+
asNullableString(data["updated_at"])
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
// src/dto/ComplianceEnrollmentPage.ts
|
|
336
|
+
var ComplianceEnrollmentPage = class _ComplianceEnrollmentPage {
|
|
337
|
+
constructor(rows, currentPage, perPage, total, lastPage) {
|
|
338
|
+
this.rows = rows;
|
|
339
|
+
this.currentPage = currentPage;
|
|
340
|
+
this.perPage = perPage;
|
|
341
|
+
this.total = total;
|
|
342
|
+
this.lastPage = lastPage;
|
|
343
|
+
}
|
|
344
|
+
rows;
|
|
345
|
+
currentPage;
|
|
346
|
+
perPage;
|
|
347
|
+
total;
|
|
348
|
+
lastPage;
|
|
349
|
+
static fromResponse(payload) {
|
|
350
|
+
const obj = payload !== null && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
|
|
351
|
+
const rows = Array.isArray(obj["data"]) ? obj["data"].filter((row) => typeof row === "object" && row !== null).map(ComplianceEnrollment.fromArray) : [];
|
|
352
|
+
const meta = obj["meta"] !== null && typeof obj["meta"] === "object" && !Array.isArray(obj["meta"]) ? obj["meta"] : {};
|
|
353
|
+
const num = (value, fallback) => typeof value === "number" ? value : fallback;
|
|
354
|
+
return new _ComplianceEnrollmentPage(
|
|
355
|
+
rows,
|
|
356
|
+
num(meta["current_page"], 1),
|
|
357
|
+
num(meta["per_page"], rows.length),
|
|
358
|
+
num(meta["total"], rows.length),
|
|
359
|
+
num(meta["last_page"], 1)
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
[Symbol.iterator]() {
|
|
363
|
+
return this.rows[Symbol.iterator]();
|
|
364
|
+
}
|
|
365
|
+
get length() {
|
|
366
|
+
return this.rows.length;
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
// src/enums/ComplianceTaxReportState.ts
|
|
371
|
+
var ComplianceTaxReportState = {
|
|
372
|
+
NEW: "new",
|
|
373
|
+
SENT: "sent",
|
|
374
|
+
ACKNOWLEDGED: "acknowledged",
|
|
375
|
+
REGISTERED: "registered",
|
|
376
|
+
REFUSED: "refused",
|
|
377
|
+
ERROR: "error",
|
|
378
|
+
UNKNOWN: "unknown"
|
|
379
|
+
};
|
|
380
|
+
var VALUES2 = Object.values(ComplianceTaxReportState);
|
|
381
|
+
function toComplianceTaxReportState(value) {
|
|
382
|
+
if (typeof value === "string") {
|
|
383
|
+
const normalized = value.trim().toLowerCase();
|
|
384
|
+
if (VALUES2.includes(normalized)) {
|
|
385
|
+
return normalized;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
return ComplianceTaxReportState.UNKNOWN;
|
|
389
|
+
}
|
|
390
|
+
var DESCRIPTIONS2 = {
|
|
391
|
+
[ComplianceTaxReportState.NEW]: "Created at provider, waiting for the daily ledger batch.",
|
|
392
|
+
[ComplianceTaxReportState.SENT]: "Ledger transmitted to PPF.",
|
|
393
|
+
[ComplianceTaxReportState.ACKNOWLEDGED]: "PPF acknowledged receipt of the ledger.",
|
|
394
|
+
[ComplianceTaxReportState.REGISTERED]: "Accepted by DGFiP (CDV 300).",
|
|
395
|
+
[ComplianceTaxReportState.REFUSED]: "Rejected by DGFiP (CDV 301).",
|
|
396
|
+
[ComplianceTaxReportState.ERROR]: "Transmission or PPF error.",
|
|
397
|
+
[ComplianceTaxReportState.UNKNOWN]: "Unknown state."
|
|
398
|
+
};
|
|
399
|
+
function describeComplianceTaxReportState(state) {
|
|
400
|
+
return DESCRIPTIONS2[state];
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
// src/dto/ComplianceTaxReport.ts
|
|
404
|
+
function asString2(value, fallback = "") {
|
|
405
|
+
return typeof value === "string" ? value : fallback;
|
|
406
|
+
}
|
|
407
|
+
function asNullableString2(value) {
|
|
408
|
+
return typeof value === "string" ? value : null;
|
|
409
|
+
}
|
|
410
|
+
function asNumber2(value) {
|
|
411
|
+
return typeof value === "number" ? value : Number(value ?? 0) || 0;
|
|
412
|
+
}
|
|
413
|
+
function asNullableNumber(value) {
|
|
414
|
+
return typeof value === "number" ? value : null;
|
|
415
|
+
}
|
|
416
|
+
function asMoney(value) {
|
|
417
|
+
if (typeof value === "string") return value;
|
|
418
|
+
if (typeof value === "number" && Number.isFinite(value)) return String(value);
|
|
419
|
+
return "0.00";
|
|
420
|
+
}
|
|
421
|
+
var ComplianceTaxReport = class _ComplianceTaxReport {
|
|
422
|
+
constructor(id, companyId, complianceTransactionId, ledgerId, country, regime, state, stateLabel, isTerminal, providerTaxReportId, providerLedgerId, baseAmount, taxAmount, totalAmount, refusalReason, registeredAt, refusedAt, createdAt, updatedAt) {
|
|
423
|
+
this.id = id;
|
|
424
|
+
this.companyId = companyId;
|
|
425
|
+
this.complianceTransactionId = complianceTransactionId;
|
|
426
|
+
this.ledgerId = ledgerId;
|
|
427
|
+
this.country = country;
|
|
428
|
+
this.regime = regime;
|
|
429
|
+
this.state = state;
|
|
430
|
+
this.stateLabel = stateLabel;
|
|
431
|
+
this.isTerminal = isTerminal;
|
|
432
|
+
this.providerTaxReportId = providerTaxReportId;
|
|
433
|
+
this.providerLedgerId = providerLedgerId;
|
|
434
|
+
this.baseAmount = baseAmount;
|
|
435
|
+
this.taxAmount = taxAmount;
|
|
436
|
+
this.totalAmount = totalAmount;
|
|
437
|
+
this.refusalReason = refusalReason;
|
|
438
|
+
this.registeredAt = registeredAt;
|
|
439
|
+
this.refusedAt = refusedAt;
|
|
440
|
+
this.createdAt = createdAt;
|
|
441
|
+
this.updatedAt = updatedAt;
|
|
442
|
+
}
|
|
443
|
+
id;
|
|
444
|
+
companyId;
|
|
445
|
+
complianceTransactionId;
|
|
446
|
+
ledgerId;
|
|
447
|
+
country;
|
|
448
|
+
regime;
|
|
449
|
+
state;
|
|
450
|
+
stateLabel;
|
|
451
|
+
isTerminal;
|
|
452
|
+
providerTaxReportId;
|
|
453
|
+
providerLedgerId;
|
|
454
|
+
baseAmount;
|
|
455
|
+
taxAmount;
|
|
456
|
+
totalAmount;
|
|
457
|
+
refusalReason;
|
|
458
|
+
registeredAt;
|
|
459
|
+
refusedAt;
|
|
460
|
+
createdAt;
|
|
461
|
+
updatedAt;
|
|
462
|
+
static fromArray(data) {
|
|
463
|
+
return new _ComplianceTaxReport(
|
|
464
|
+
asNumber2(data["id"]),
|
|
465
|
+
asNumber2(data["company_id"]),
|
|
466
|
+
asNullableNumber(data["compliance_transaction_id"]),
|
|
467
|
+
asNullableNumber(data["ledger_id"]),
|
|
468
|
+
asString2(data["country"]),
|
|
469
|
+
asString2(data["regime"]),
|
|
470
|
+
toComplianceTaxReportState(data["state"]),
|
|
471
|
+
asString2(data["state_label"]),
|
|
472
|
+
data["is_terminal"] === true,
|
|
473
|
+
asNullableString2(data["provider_tax_report_id"]),
|
|
474
|
+
asNullableString2(data["provider_ledger_id"]),
|
|
475
|
+
asMoney(data["base_amount"]),
|
|
476
|
+
asMoney(data["tax_amount"]),
|
|
477
|
+
asMoney(data["total_amount"]),
|
|
478
|
+
asNullableString2(data["refusal_reason"]),
|
|
479
|
+
asNullableString2(data["registered_at"]),
|
|
480
|
+
asNullableString2(data["refused_at"]),
|
|
481
|
+
asNullableString2(data["created_at"]),
|
|
482
|
+
asNullableString2(data["updated_at"])
|
|
483
|
+
);
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
// src/dto/ComplianceTaxReportPage.ts
|
|
488
|
+
var ComplianceTaxReportPage = class _ComplianceTaxReportPage {
|
|
489
|
+
constructor(rows, currentPage, perPage, total, lastPage) {
|
|
490
|
+
this.rows = rows;
|
|
491
|
+
this.currentPage = currentPage;
|
|
492
|
+
this.perPage = perPage;
|
|
493
|
+
this.total = total;
|
|
494
|
+
this.lastPage = lastPage;
|
|
495
|
+
}
|
|
496
|
+
rows;
|
|
497
|
+
currentPage;
|
|
498
|
+
perPage;
|
|
499
|
+
total;
|
|
500
|
+
lastPage;
|
|
501
|
+
static fromResponse(payload) {
|
|
502
|
+
const obj = payload !== null && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
|
|
503
|
+
const rows = Array.isArray(obj["data"]) ? obj["data"].filter((row) => typeof row === "object" && row !== null).map(ComplianceTaxReport.fromArray) : [];
|
|
504
|
+
const meta = obj["meta"] !== null && typeof obj["meta"] === "object" && !Array.isArray(obj["meta"]) ? obj["meta"] : {};
|
|
505
|
+
const num = (value, fallback) => typeof value === "number" ? value : fallback;
|
|
506
|
+
return new _ComplianceTaxReportPage(
|
|
507
|
+
rows,
|
|
508
|
+
num(meta["current_page"], 1),
|
|
509
|
+
num(meta["per_page"], rows.length),
|
|
510
|
+
num(meta["total"], rows.length),
|
|
511
|
+
num(meta["last_page"], 1)
|
|
512
|
+
);
|
|
513
|
+
}
|
|
514
|
+
[Symbol.iterator]() {
|
|
515
|
+
return this.rows[Symbol.iterator]();
|
|
516
|
+
}
|
|
517
|
+
get length() {
|
|
518
|
+
return this.rows.length;
|
|
519
|
+
}
|
|
520
|
+
};
|
|
521
|
+
|
|
522
|
+
// src/enums/ComplianceTransactionState.ts
|
|
523
|
+
var ComplianceTransactionState = {
|
|
524
|
+
PENDING: "pending",
|
|
525
|
+
SENDING: "sending",
|
|
526
|
+
SUBMITTED: "submitted",
|
|
527
|
+
ERROR: "error",
|
|
528
|
+
UNKNOWN: "unknown"
|
|
529
|
+
};
|
|
530
|
+
var VALUES3 = Object.values(ComplianceTransactionState);
|
|
531
|
+
function toComplianceTransactionState(value) {
|
|
532
|
+
if (typeof value === "string") {
|
|
533
|
+
const normalized = value.trim().toLowerCase();
|
|
534
|
+
if (VALUES3.includes(normalized)) {
|
|
535
|
+
return normalized;
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
return ComplianceTransactionState.UNKNOWN;
|
|
539
|
+
}
|
|
540
|
+
var DESCRIPTIONS3 = {
|
|
541
|
+
[ComplianceTransactionState.PENDING]: "Recorded locally, not yet submitted to the provider.",
|
|
542
|
+
[ComplianceTransactionState.SENDING]: "Submission to the provider in progress.",
|
|
543
|
+
[ComplianceTransactionState.SUBMITTED]: "Successfully submitted to the provider.",
|
|
544
|
+
[ComplianceTransactionState.ERROR]: "Submission failed. See submissionError.",
|
|
545
|
+
[ComplianceTransactionState.UNKNOWN]: "Unknown state."
|
|
546
|
+
};
|
|
547
|
+
function describeComplianceTransactionState(state) {
|
|
548
|
+
return DESCRIPTIONS3[state];
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
// src/enums/ComplianceTransactionType.ts
|
|
552
|
+
var ComplianceTransactionType = {
|
|
553
|
+
B2C_OUTBOUND: "b2c_outbound",
|
|
554
|
+
B2B_DOMESTIC_OUTBOUND: "b2b_domestic_outbound",
|
|
555
|
+
B2B_DOMESTIC_INBOUND: "b2b_domestic_inbound",
|
|
556
|
+
CROSSBORDER_OUTBOUND: "crossborder_outbound",
|
|
557
|
+
CROSSBORDER_INBOUND: "crossborder_inbound",
|
|
558
|
+
UNKNOWN: "unknown"
|
|
559
|
+
};
|
|
560
|
+
var VALUES4 = Object.values(ComplianceTransactionType);
|
|
561
|
+
function toComplianceTransactionType(value) {
|
|
562
|
+
if (typeof value === "string") {
|
|
563
|
+
const normalized = value.trim().toLowerCase();
|
|
564
|
+
if (VALUES4.includes(normalized)) {
|
|
565
|
+
return normalized;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
return ComplianceTransactionType.UNKNOWN;
|
|
569
|
+
}
|
|
570
|
+
var DESCRIPTIONS4 = {
|
|
571
|
+
[ComplianceTransactionType.B2C_OUTBOUND]: "Sale to a private person in the merchant country (DGFiP Flux 10.3).",
|
|
572
|
+
[ComplianceTransactionType.B2B_DOMESTIC_OUTBOUND]: "Sale to a domestic business (DGFiP Flux 1, Phase 2).",
|
|
573
|
+
[ComplianceTransactionType.B2B_DOMESTIC_INBOUND]: "Purchase from a domestic business (DGFiP Flux 1, Phase 2).",
|
|
574
|
+
[ComplianceTransactionType.CROSSBORDER_OUTBOUND]: "Sale to a non-domestic business (DGFiP Flux 10.1).",
|
|
575
|
+
[ComplianceTransactionType.CROSSBORDER_INBOUND]: "Purchase from a non-domestic supplier (DGFiP Flux 10.1).",
|
|
576
|
+
[ComplianceTransactionType.UNKNOWN]: "Unknown transaction type."
|
|
577
|
+
};
|
|
578
|
+
function describeComplianceTransactionType(type) {
|
|
579
|
+
return DESCRIPTIONS4[type];
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
// src/dto/ComplianceTransaction.ts
|
|
583
|
+
function asString3(value, fallback = "") {
|
|
584
|
+
return typeof value === "string" ? value : fallback;
|
|
585
|
+
}
|
|
586
|
+
function asNullableString3(value) {
|
|
587
|
+
return typeof value === "string" ? value : null;
|
|
588
|
+
}
|
|
589
|
+
function asNumber3(value) {
|
|
590
|
+
return typeof value === "number" ? value : Number(value ?? 0) || 0;
|
|
591
|
+
}
|
|
592
|
+
function asMoney2(value) {
|
|
593
|
+
if (typeof value === "string") return value;
|
|
594
|
+
if (typeof value === "number" && Number.isFinite(value)) return String(value);
|
|
595
|
+
return "0.00";
|
|
596
|
+
}
|
|
597
|
+
var ComplianceTransaction = class _ComplianceTransaction {
|
|
598
|
+
constructor(id, companyId, complianceEnrollmentId, country, regime, transactionType, transactionTypeLabel, state, stateLabel, invoiceNumber, invoiceDate, dueDate, currency, subtotal, taxAmount, total, counterpartyName, counterpartyCountry, counterpartyVatNumber, isPaid, paidAt, providerInvoiceId, submissionError, reportedAt, taxReport, createdAt, updatedAt) {
|
|
599
|
+
this.id = id;
|
|
600
|
+
this.companyId = companyId;
|
|
601
|
+
this.complianceEnrollmentId = complianceEnrollmentId;
|
|
602
|
+
this.country = country;
|
|
603
|
+
this.regime = regime;
|
|
604
|
+
this.transactionType = transactionType;
|
|
605
|
+
this.transactionTypeLabel = transactionTypeLabel;
|
|
606
|
+
this.state = state;
|
|
607
|
+
this.stateLabel = stateLabel;
|
|
608
|
+
this.invoiceNumber = invoiceNumber;
|
|
609
|
+
this.invoiceDate = invoiceDate;
|
|
610
|
+
this.dueDate = dueDate;
|
|
611
|
+
this.currency = currency;
|
|
612
|
+
this.subtotal = subtotal;
|
|
613
|
+
this.taxAmount = taxAmount;
|
|
614
|
+
this.total = total;
|
|
615
|
+
this.counterpartyName = counterpartyName;
|
|
616
|
+
this.counterpartyCountry = counterpartyCountry;
|
|
617
|
+
this.counterpartyVatNumber = counterpartyVatNumber;
|
|
618
|
+
this.isPaid = isPaid;
|
|
619
|
+
this.paidAt = paidAt;
|
|
620
|
+
this.providerInvoiceId = providerInvoiceId;
|
|
621
|
+
this.submissionError = submissionError;
|
|
622
|
+
this.reportedAt = reportedAt;
|
|
623
|
+
this.taxReport = taxReport;
|
|
624
|
+
this.createdAt = createdAt;
|
|
625
|
+
this.updatedAt = updatedAt;
|
|
626
|
+
}
|
|
627
|
+
id;
|
|
628
|
+
companyId;
|
|
629
|
+
complianceEnrollmentId;
|
|
630
|
+
country;
|
|
631
|
+
regime;
|
|
632
|
+
transactionType;
|
|
633
|
+
transactionTypeLabel;
|
|
634
|
+
state;
|
|
635
|
+
stateLabel;
|
|
636
|
+
invoiceNumber;
|
|
637
|
+
invoiceDate;
|
|
638
|
+
dueDate;
|
|
639
|
+
currency;
|
|
640
|
+
subtotal;
|
|
641
|
+
taxAmount;
|
|
642
|
+
total;
|
|
643
|
+
counterpartyName;
|
|
644
|
+
counterpartyCountry;
|
|
645
|
+
counterpartyVatNumber;
|
|
646
|
+
isPaid;
|
|
647
|
+
paidAt;
|
|
648
|
+
providerInvoiceId;
|
|
649
|
+
submissionError;
|
|
650
|
+
reportedAt;
|
|
651
|
+
taxReport;
|
|
652
|
+
createdAt;
|
|
653
|
+
updatedAt;
|
|
654
|
+
static fromArray(data) {
|
|
655
|
+
const taxReport = typeof data["tax_report"] === "object" && data["tax_report"] !== null && !Array.isArray(data["tax_report"]) ? ComplianceTaxReport.fromArray(data["tax_report"]) : void 0;
|
|
656
|
+
return new _ComplianceTransaction(
|
|
657
|
+
asNumber3(data["id"]),
|
|
658
|
+
asNumber3(data["company_id"]),
|
|
659
|
+
asNumber3(data["compliance_enrollment_id"]),
|
|
660
|
+
asString3(data["country"]),
|
|
661
|
+
asString3(data["regime"]),
|
|
662
|
+
toComplianceTransactionType(data["transaction_type"]),
|
|
663
|
+
asString3(data["transaction_type_label"]),
|
|
664
|
+
toComplianceTransactionState(data["state"]),
|
|
665
|
+
asString3(data["state_label"]),
|
|
666
|
+
asString3(data["invoice_number"]),
|
|
667
|
+
asNullableString3(data["invoice_date"]),
|
|
668
|
+
asNullableString3(data["due_date"]),
|
|
669
|
+
asString3(data["currency"], "EUR"),
|
|
670
|
+
asMoney2(data["subtotal"]),
|
|
671
|
+
asMoney2(data["tax_amount"]),
|
|
672
|
+
asMoney2(data["total"]),
|
|
673
|
+
asNullableString3(data["counterparty_name"]),
|
|
674
|
+
asNullableString3(data["counterparty_country"]),
|
|
675
|
+
asNullableString3(data["counterparty_vat_number"]),
|
|
676
|
+
data["is_paid"] === true,
|
|
677
|
+
asNullableString3(data["paid_at"]),
|
|
678
|
+
asNullableString3(data["provider_invoice_id"]),
|
|
679
|
+
asNullableString3(data["submission_error"]),
|
|
680
|
+
asNullableString3(data["reported_at"]),
|
|
681
|
+
taxReport,
|
|
682
|
+
asNullableString3(data["created_at"]),
|
|
683
|
+
asNullableString3(data["updated_at"])
|
|
684
|
+
);
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
|
|
688
|
+
// src/dto/ComplianceTransactionPage.ts
|
|
689
|
+
var ComplianceTransactionPage = class _ComplianceTransactionPage {
|
|
690
|
+
constructor(rows, currentPage, perPage, total, lastPage) {
|
|
691
|
+
this.rows = rows;
|
|
692
|
+
this.currentPage = currentPage;
|
|
693
|
+
this.perPage = perPage;
|
|
694
|
+
this.total = total;
|
|
695
|
+
this.lastPage = lastPage;
|
|
696
|
+
}
|
|
697
|
+
rows;
|
|
698
|
+
currentPage;
|
|
699
|
+
perPage;
|
|
700
|
+
total;
|
|
701
|
+
lastPage;
|
|
702
|
+
static fromResponse(payload) {
|
|
703
|
+
const obj = payload !== null && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
|
|
704
|
+
const rows = Array.isArray(obj["data"]) ? obj["data"].filter((row) => typeof row === "object" && row !== null).map(ComplianceTransaction.fromArray) : [];
|
|
705
|
+
const meta = obj["meta"] !== null && typeof obj["meta"] === "object" && !Array.isArray(obj["meta"]) ? obj["meta"] : {};
|
|
706
|
+
const num = (value, fallback) => typeof value === "number" ? value : fallback;
|
|
707
|
+
return new _ComplianceTransactionPage(
|
|
708
|
+
rows,
|
|
709
|
+
num(meta["current_page"], 1),
|
|
710
|
+
num(meta["per_page"], rows.length),
|
|
711
|
+
num(meta["total"], rows.length),
|
|
712
|
+
num(meta["last_page"], 1)
|
|
713
|
+
);
|
|
714
|
+
}
|
|
715
|
+
[Symbol.iterator]() {
|
|
716
|
+
return this.rows[Symbol.iterator]();
|
|
717
|
+
}
|
|
718
|
+
get length() {
|
|
719
|
+
return this.rows.length;
|
|
720
|
+
}
|
|
721
|
+
};
|
|
722
|
+
|
|
723
|
+
// src/dto/ImportResult.ts
|
|
724
|
+
var ImportResult = class _ImportResult {
|
|
725
|
+
constructor(created, skippedDuplicates, errors) {
|
|
726
|
+
this.created = created;
|
|
727
|
+
this.skippedDuplicates = skippedDuplicates;
|
|
728
|
+
this.errors = errors;
|
|
729
|
+
}
|
|
730
|
+
created;
|
|
731
|
+
skippedDuplicates;
|
|
732
|
+
errors;
|
|
733
|
+
static fromArray(data) {
|
|
734
|
+
const errors = (Array.isArray(data["errors"]) ? data["errors"] : []).filter(
|
|
735
|
+
(row) => typeof row === "string"
|
|
736
|
+
);
|
|
737
|
+
const num = (value) => typeof value === "number" ? value : 0;
|
|
738
|
+
return new _ImportResult(num(data["created"]), num(data["skipped_duplicates"]), errors);
|
|
739
|
+
}
|
|
740
|
+
};
|
|
741
|
+
|
|
742
|
+
// src/dto/RevenueStatistics.ts
|
|
743
|
+
function asString4(value, fallback = "") {
|
|
744
|
+
return typeof value === "string" ? value : fallback;
|
|
745
|
+
}
|
|
746
|
+
function asNumber4(value) {
|
|
747
|
+
return typeof value === "number" ? value : Number(value ?? 0) || 0;
|
|
748
|
+
}
|
|
749
|
+
function asMoney3(value) {
|
|
750
|
+
return typeof value === "string" ? value : "0.0000";
|
|
751
|
+
}
|
|
752
|
+
function asRecords(value) {
|
|
753
|
+
if (!Array.isArray(value)) return [];
|
|
754
|
+
return value.filter((row) => typeof row === "object" && row !== null);
|
|
755
|
+
}
|
|
756
|
+
function toTotals(data) {
|
|
757
|
+
return {
|
|
758
|
+
count: asNumber4(data["count"]),
|
|
759
|
+
subtotal: asMoney3(data["subtotal"]),
|
|
760
|
+
taxAmount: asMoney3(data["tax_amount"]),
|
|
761
|
+
total: asMoney3(data["total"])
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
var RevenueStatistics = class _RevenueStatistics {
|
|
765
|
+
constructor(dateFrom, dateTo, interval, primaryCurrency, isMultiCurrency, totals, timeSeries, byType, byCountry, byState, byCurrency) {
|
|
766
|
+
this.dateFrom = dateFrom;
|
|
767
|
+
this.dateTo = dateTo;
|
|
768
|
+
this.interval = interval;
|
|
769
|
+
this.primaryCurrency = primaryCurrency;
|
|
770
|
+
this.isMultiCurrency = isMultiCurrency;
|
|
771
|
+
this.totals = totals;
|
|
772
|
+
this.timeSeries = timeSeries;
|
|
773
|
+
this.byType = byType;
|
|
774
|
+
this.byCountry = byCountry;
|
|
775
|
+
this.byState = byState;
|
|
776
|
+
this.byCurrency = byCurrency;
|
|
777
|
+
}
|
|
778
|
+
dateFrom;
|
|
779
|
+
dateTo;
|
|
780
|
+
interval;
|
|
781
|
+
primaryCurrency;
|
|
782
|
+
isMultiCurrency;
|
|
783
|
+
totals;
|
|
784
|
+
timeSeries;
|
|
785
|
+
byType;
|
|
786
|
+
byCountry;
|
|
787
|
+
byState;
|
|
788
|
+
byCurrency;
|
|
789
|
+
static fromArray(data) {
|
|
790
|
+
const range = typeof data["range"] === "object" && data["range"] !== null ? data["range"] : {};
|
|
791
|
+
const totals = toTotals(
|
|
792
|
+
typeof data["totals"] === "object" && data["totals"] !== null ? data["totals"] : {}
|
|
793
|
+
);
|
|
794
|
+
const timeSeries = asRecords(data["time_series"]).map((row) => ({
|
|
795
|
+
bucket: asString4(row["bucket"]),
|
|
796
|
+
...toTotals(row)
|
|
797
|
+
}));
|
|
798
|
+
const byType = asRecords(data["by_type"]).map((row) => ({
|
|
799
|
+
type: asString4(row["type"]),
|
|
800
|
+
typeLabel: asString4(row["type_label"]),
|
|
801
|
+
count: asNumber4(row["count"]),
|
|
802
|
+
total: asMoney3(row["total"])
|
|
803
|
+
}));
|
|
804
|
+
const byCountry = asRecords(data["by_country"]).map((row) => ({
|
|
805
|
+
country: asString4(row["country"], "unknown"),
|
|
806
|
+
count: asNumber4(row["count"]),
|
|
807
|
+
total: asMoney3(row["total"])
|
|
808
|
+
}));
|
|
809
|
+
const byState = asRecords(data["by_state"]).map((row) => ({
|
|
810
|
+
state: asString4(row["state"]),
|
|
811
|
+
stateLabel: asString4(row["state_label"]),
|
|
812
|
+
count: asNumber4(row["count"]),
|
|
813
|
+
total: asMoney3(row["total"])
|
|
814
|
+
}));
|
|
815
|
+
const byCurrency = asRecords(data["by_currency"]).map((row) => ({
|
|
816
|
+
currency: asString4(row["currency"]),
|
|
817
|
+
...toTotals(row)
|
|
818
|
+
}));
|
|
819
|
+
return new _RevenueStatistics(
|
|
820
|
+
asString4(range["date_from"]) || void 0,
|
|
821
|
+
asString4(range["date_to"]) || void 0,
|
|
822
|
+
asString4(range["interval"]) || void 0,
|
|
823
|
+
asString4(data["primary_currency"], "EUR"),
|
|
824
|
+
data["is_multi_currency"] === true,
|
|
825
|
+
totals,
|
|
826
|
+
timeSeries,
|
|
827
|
+
byType,
|
|
828
|
+
byCountry,
|
|
829
|
+
byState,
|
|
830
|
+
byCurrency
|
|
831
|
+
);
|
|
832
|
+
}
|
|
833
|
+
};
|
|
834
|
+
|
|
835
|
+
// src/dto/SireneLookupResult.ts
|
|
836
|
+
function asString5(value, fallback = "") {
|
|
837
|
+
return typeof value === "string" ? value : fallback;
|
|
838
|
+
}
|
|
839
|
+
function asNullableString4(value) {
|
|
840
|
+
return typeof value === "string" ? value : null;
|
|
841
|
+
}
|
|
842
|
+
var SireneLookupResult = class _SireneLookupResult {
|
|
843
|
+
constructor(companyName, siren, siret, nafCode, nafFull, enterpriseSize, address, city, postalcode) {
|
|
844
|
+
this.companyName = companyName;
|
|
845
|
+
this.siren = siren;
|
|
846
|
+
this.siret = siret;
|
|
847
|
+
this.nafCode = nafCode;
|
|
848
|
+
this.nafFull = nafFull;
|
|
849
|
+
this.enterpriseSize = enterpriseSize;
|
|
850
|
+
this.address = address;
|
|
851
|
+
this.city = city;
|
|
852
|
+
this.postalcode = postalcode;
|
|
853
|
+
}
|
|
854
|
+
companyName;
|
|
855
|
+
siren;
|
|
856
|
+
siret;
|
|
857
|
+
nafCode;
|
|
858
|
+
nafFull;
|
|
859
|
+
enterpriseSize;
|
|
860
|
+
address;
|
|
861
|
+
city;
|
|
862
|
+
postalcode;
|
|
863
|
+
static fromArray(data) {
|
|
864
|
+
return new _SireneLookupResult(
|
|
865
|
+
asString5(data["company_name"]),
|
|
866
|
+
asString5(data["siren"]),
|
|
867
|
+
asNullableString4(data["siret"]),
|
|
868
|
+
asNullableString4(data["naf_code"]),
|
|
869
|
+
asNullableString4(data["naf_full"]),
|
|
870
|
+
asNullableString4(data["enterprise_size"]),
|
|
871
|
+
asNullableString4(data["address"]),
|
|
872
|
+
asNullableString4(data["city"]),
|
|
873
|
+
asNullableString4(data["postalcode"])
|
|
874
|
+
);
|
|
875
|
+
}
|
|
876
|
+
};
|
|
877
|
+
|
|
878
|
+
// src/dto/VatRates.ts
|
|
879
|
+
function asString6(value, fallback = "") {
|
|
880
|
+
return typeof value === "string" ? value : fallback;
|
|
881
|
+
}
|
|
882
|
+
function asNumber5(value) {
|
|
883
|
+
return typeof value === "number" ? value : Number(value ?? 0) || 0;
|
|
884
|
+
}
|
|
885
|
+
var VatRates = class _VatRates {
|
|
886
|
+
constructor(country, currency, rates) {
|
|
887
|
+
this.country = country;
|
|
888
|
+
this.currency = currency;
|
|
889
|
+
this.rates = rates;
|
|
890
|
+
}
|
|
891
|
+
country;
|
|
892
|
+
currency;
|
|
893
|
+
rates;
|
|
894
|
+
static fromArray(data) {
|
|
895
|
+
const rates = (Array.isArray(data["rates"]) ? data["rates"] : []).filter((row) => typeof row === "object" && row !== null).map((row) => ({
|
|
896
|
+
percent: asNumber5(row["percent"]),
|
|
897
|
+
category: asString6(row["category"]),
|
|
898
|
+
labelKey: asString6(row["label_key"]),
|
|
899
|
+
taxName: asString6(row["tax_name"]),
|
|
900
|
+
requiresVatex: row["requires_vatex"] === true
|
|
901
|
+
}));
|
|
902
|
+
return new _VatRates(asString6(data["country"]), asString6(data["currency"], "EUR"), rates);
|
|
903
|
+
}
|
|
904
|
+
};
|
|
905
|
+
|
|
906
|
+
// src/exceptions/ValidationException.ts
|
|
907
|
+
var ValidationException = class extends TaxoraException {
|
|
908
|
+
statusCode = 422;
|
|
909
|
+
errors;
|
|
910
|
+
constructor(message, errors, context = {}) {
|
|
911
|
+
super(message, context);
|
|
912
|
+
this.name = "ValidationException";
|
|
913
|
+
this.errors = errors;
|
|
914
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
915
|
+
}
|
|
916
|
+
getErrors() {
|
|
917
|
+
return this.errors;
|
|
918
|
+
}
|
|
919
|
+
};
|
|
920
|
+
|
|
921
|
+
// src/endpoints/EReportingEndpoint.ts
|
|
922
|
+
var DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
|
|
923
|
+
var NAF_CODE_REGEX = /^\d{2}$/;
|
|
924
|
+
var INTERVALS = ["day", "week", "month"];
|
|
925
|
+
var ENTERPRISE_SIZES = ["micro", "pme", "eti", "ge"];
|
|
926
|
+
var TYPE_OPERATIONS = ["services", "goods", "mixed"];
|
|
927
|
+
var TRANSACTION_TYPES = [
|
|
928
|
+
"b2c_outbound",
|
|
929
|
+
"b2b_domestic_outbound",
|
|
930
|
+
"b2b_domestic_inbound",
|
|
931
|
+
"crossborder_outbound",
|
|
932
|
+
"crossborder_inbound"
|
|
933
|
+
];
|
|
934
|
+
var EReportingEndpoint = class {
|
|
935
|
+
constructor(baseUrl, apiKey, tokenStorage, httpClient) {
|
|
936
|
+
this.baseUrl = baseUrl;
|
|
937
|
+
this.apiKey = apiKey;
|
|
938
|
+
this.tokenStorage = tokenStorage;
|
|
939
|
+
this.httpClient = httpClient;
|
|
940
|
+
}
|
|
941
|
+
baseUrl;
|
|
942
|
+
apiKey;
|
|
943
|
+
tokenStorage;
|
|
944
|
+
httpClient;
|
|
945
|
+
// ---------------------------------------------------------------------
|
|
946
|
+
// Enrollments
|
|
947
|
+
// ---------------------------------------------------------------------
|
|
948
|
+
/**
|
|
949
|
+
* Create a compliance enrollment and provision the provider account. By
|
|
950
|
+
* default the DGFiP regime is activated right away; pass `autoActivate: false`
|
|
951
|
+
* to only create the account.
|
|
952
|
+
*
|
|
953
|
+
* On provider failure the API responds 502 (mapped to an HttpException) and
|
|
954
|
+
* the enrollment is persisted in `error_account`/`error_activation` state so
|
|
955
|
+
* provisioning can be retried.
|
|
956
|
+
*/
|
|
957
|
+
async createEnrollment(input) {
|
|
958
|
+
this.validateEnrollmentInput(input);
|
|
959
|
+
const body = {
|
|
960
|
+
email: input.email,
|
|
961
|
+
naf_code: input.nafCode,
|
|
962
|
+
enterprise_size: input.enterpriseSize,
|
|
963
|
+
type_operation: input.typeOperation,
|
|
964
|
+
reporting_start_date: this.formatDate(input.reportingStartDate)
|
|
965
|
+
};
|
|
966
|
+
if (input.country !== void 0) body["country"] = input.country;
|
|
967
|
+
if (input.regime !== void 0) body["regime"] = input.regime;
|
|
968
|
+
if (input.siret !== void 0) body["siret"] = input.siret;
|
|
969
|
+
if (input.siren !== void 0) body["siren"] = input.siren;
|
|
970
|
+
if (input.vatNumber !== void 0) body["vat_number"] = input.vatNumber;
|
|
971
|
+
if (input.companyName !== void 0) body["company_name"] = input.companyName;
|
|
972
|
+
if (input.address !== void 0) body["address"] = input.address;
|
|
973
|
+
if (input.city !== void 0) body["city"] = input.city;
|
|
974
|
+
if (input.postalcode !== void 0) body["postalcode"] = input.postalcode;
|
|
975
|
+
if (input.province !== void 0) body["province"] = input.province;
|
|
976
|
+
if (input.autoActivate !== void 0) body["auto_activate"] = input.autoActivate;
|
|
977
|
+
const response = await this.sendRequest("POST", `${this.baseUrl}/compliance/enrollments`, body);
|
|
978
|
+
const data = await this.parseJsonResponse(response);
|
|
979
|
+
return ComplianceEnrollment.fromArray(data);
|
|
980
|
+
}
|
|
981
|
+
/** Paginated list of the company's enrollments (newest first). `perPage` is capped at 100 server-side. */
|
|
982
|
+
async listEnrollments(page = 1, perPage = 25) {
|
|
983
|
+
const params = new URLSearchParams();
|
|
984
|
+
params.set("page", String(page));
|
|
985
|
+
params.set("per_page", String(perPage));
|
|
986
|
+
const response = await this.sendRequest("GET", `${this.baseUrl}/compliance/enrollments?${params.toString()}`);
|
|
987
|
+
return ComplianceEnrollmentPage.fromResponse(await this.parseJsonResponse(response));
|
|
988
|
+
}
|
|
989
|
+
/** Get a single enrollment by id. */
|
|
990
|
+
async getEnrollment(id) {
|
|
991
|
+
this.validateId(id, "id");
|
|
992
|
+
const response = await this.sendRequest("GET", `${this.baseUrl}/compliance/enrollments/${id}`);
|
|
993
|
+
const data = await this.parseJsonResponse(response);
|
|
994
|
+
return ComplianceEnrollment.fromArray(data);
|
|
995
|
+
}
|
|
996
|
+
/**
|
|
997
|
+
* Look up company data by SIRET, SIREN or French VAT number via the French
|
|
998
|
+
* SIRENE registry — ideal for prefilling createEnrollment().
|
|
999
|
+
*
|
|
1000
|
+
* Rate-limited to 3 requests/minute per user (protects the external French
|
|
1001
|
+
* government API); exceeding it yields a 429 (mapped to an HttpException).
|
|
1002
|
+
*/
|
|
1003
|
+
async sireneLookup(q) {
|
|
1004
|
+
if (q.trim() === "") {
|
|
1005
|
+
throw new TaxoraException("q must not be empty.");
|
|
1006
|
+
}
|
|
1007
|
+
const params = new URLSearchParams();
|
|
1008
|
+
params.set("q", q);
|
|
1009
|
+
const response = await this.sendRequest("GET", `${this.baseUrl}/compliance/sirene-lookup?${params.toString()}`);
|
|
1010
|
+
const data = await this.parseJsonResponse(response);
|
|
1011
|
+
return SireneLookupResult.fromArray(data);
|
|
1012
|
+
}
|
|
1013
|
+
// ---------------------------------------------------------------------
|
|
1014
|
+
// Transactions
|
|
1015
|
+
// ---------------------------------------------------------------------
|
|
1016
|
+
/**
|
|
1017
|
+
* Record and (by default) submit a Flux 10 transaction. Pass `submitNow: false`
|
|
1018
|
+
* to only record it — submission can be triggered later via submitTransaction().
|
|
1019
|
+
*
|
|
1020
|
+
* Immediate per-invoice submission requires the e-invoicing feature on the
|
|
1021
|
+
* account; in pure e-reporting mode the transaction is only recorded and
|
|
1022
|
+
* reported via the aggregated daily ledgers.
|
|
1023
|
+
*
|
|
1024
|
+
* Creation is idempotent on the invoice's natural key (enrollment, type,
|
|
1025
|
+
* invoice number, invoice date, counterparty VAT): a re-sent create returns
|
|
1026
|
+
* the existing transaction with HTTP 200 instead of creating a duplicate.
|
|
1027
|
+
*
|
|
1028
|
+
* On provider failure the API responds 502 (mapped to an HttpException).
|
|
1029
|
+
*/
|
|
1030
|
+
async createTransaction(input) {
|
|
1031
|
+
this.validateId(input.complianceEnrollmentId, "complianceEnrollmentId");
|
|
1032
|
+
this.validateTransactionType(input.transactionType);
|
|
1033
|
+
this.validateInvoiceNumber(input.invoiceNumber);
|
|
1034
|
+
this.validateInvoiceLines(input.invoiceLines);
|
|
1035
|
+
this.validateOptionalCodes(input);
|
|
1036
|
+
const body = {
|
|
1037
|
+
compliance_enrollment_id: input.complianceEnrollmentId,
|
|
1038
|
+
transaction_type: input.transactionType,
|
|
1039
|
+
invoice_number: input.invoiceNumber,
|
|
1040
|
+
invoice_date: this.formatDate(input.invoiceDate),
|
|
1041
|
+
subtotal: input.subtotal,
|
|
1042
|
+
total: input.total,
|
|
1043
|
+
invoice_lines_attributes: this.buildInvoiceLines(input.invoiceLines)
|
|
1044
|
+
};
|
|
1045
|
+
this.applyOptionalTransactionFields(body, input);
|
|
1046
|
+
if (input.submitNow !== void 0) body["submit_now"] = input.submitNow;
|
|
1047
|
+
const response = await this.sendRequest("POST", `${this.baseUrl}/compliance/transactions`, body);
|
|
1048
|
+
const data = await this.parseJsonResponse(response);
|
|
1049
|
+
return ComplianceTransaction.fromArray(data);
|
|
1050
|
+
}
|
|
1051
|
+
/** Paginated list of the company's transactions (newest invoice date first), filterable by date / state / type. */
|
|
1052
|
+
async listTransactions(filters = {}) {
|
|
1053
|
+
const params = new URLSearchParams();
|
|
1054
|
+
if (filters.dateFrom !== void 0) params.set("date_from", this.formatDate(filters.dateFrom));
|
|
1055
|
+
if (filters.dateTo !== void 0) params.set("date_to", this.formatDate(filters.dateTo));
|
|
1056
|
+
if (filters.state !== void 0) params.set("state", filters.state);
|
|
1057
|
+
if (filters.transactionType !== void 0) params.set("transaction_type", filters.transactionType);
|
|
1058
|
+
if (filters.page !== void 0) params.set("page", String(filters.page));
|
|
1059
|
+
if (filters.perPage !== void 0) params.set("per_page", String(filters.perPage));
|
|
1060
|
+
const queryString = params.toString();
|
|
1061
|
+
const url = `${this.baseUrl}/compliance/transactions${queryString ? `?${queryString}` : ""}`;
|
|
1062
|
+
const response = await this.sendRequest("GET", url);
|
|
1063
|
+
return ComplianceTransactionPage.fromResponse(await this.parseJsonResponse(response));
|
|
1064
|
+
}
|
|
1065
|
+
/** Get a single transaction by id (includes its tax report when one exists). */
|
|
1066
|
+
async getTransaction(id) {
|
|
1067
|
+
this.validateId(id, "id");
|
|
1068
|
+
const response = await this.sendRequest("GET", `${this.baseUrl}/compliance/transactions/${id}`);
|
|
1069
|
+
const data = await this.parseJsonResponse(response);
|
|
1070
|
+
return ComplianceTransaction.fromArray(data);
|
|
1071
|
+
}
|
|
1072
|
+
/** Update a still-pending transaction. Only the provided fields are sent; already-submitted transactions are rejected with 422. */
|
|
1073
|
+
async updateTransaction(id, input) {
|
|
1074
|
+
this.validateId(id, "id");
|
|
1075
|
+
if (input.transactionType !== void 0) this.validateTransactionType(input.transactionType);
|
|
1076
|
+
if (input.invoiceNumber !== void 0) this.validateInvoiceNumber(input.invoiceNumber);
|
|
1077
|
+
if (input.invoiceLines !== void 0) this.validateInvoiceLines(input.invoiceLines);
|
|
1078
|
+
this.validateOptionalCodes(input);
|
|
1079
|
+
const body = {};
|
|
1080
|
+
if (input.transactionType !== void 0) body["transaction_type"] = input.transactionType;
|
|
1081
|
+
if (input.invoiceNumber !== void 0) body["invoice_number"] = input.invoiceNumber;
|
|
1082
|
+
if (input.invoiceDate !== void 0) body["invoice_date"] = this.formatDate(input.invoiceDate);
|
|
1083
|
+
if (input.subtotal !== void 0) body["subtotal"] = input.subtotal;
|
|
1084
|
+
if (input.total !== void 0) body["total"] = input.total;
|
|
1085
|
+
if (input.invoiceLines !== void 0) body["invoice_lines_attributes"] = this.buildInvoiceLines(input.invoiceLines);
|
|
1086
|
+
this.applyOptionalTransactionFields(body, input);
|
|
1087
|
+
const response = await this.sendRequest("PUT", `${this.baseUrl}/compliance/transactions/${id}`, body);
|
|
1088
|
+
const data = await this.parseJsonResponse(response);
|
|
1089
|
+
return ComplianceTransaction.fromArray(data);
|
|
1090
|
+
}
|
|
1091
|
+
/** Delete a still-pending transaction. Already-submitted transactions are rejected with 422. */
|
|
1092
|
+
async deleteTransaction(id) {
|
|
1093
|
+
this.validateId(id, "id");
|
|
1094
|
+
const response = await this.sendRequest("DELETE", `${this.baseUrl}/compliance/transactions/${id}`);
|
|
1095
|
+
await this.assertNoContentResponse(response);
|
|
1096
|
+
}
|
|
1097
|
+
/**
|
|
1098
|
+
* Submit (or retry) an existing `pending`/`error` transaction to the provider.
|
|
1099
|
+
* Replays the invoice lines stored at creation, so they don't have to be re-sent.
|
|
1100
|
+
*
|
|
1101
|
+
* Requires the e-invoicing feature on the account — pure e-reporting customers
|
|
1102
|
+
* get a 422 (transactions are reported via the aggregated daily ledgers instead).
|
|
1103
|
+
*
|
|
1104
|
+
* On provider failure the API responds 502 (mapped to an HttpException);
|
|
1105
|
+
* already-submitted transactions are rejected with 422.
|
|
1106
|
+
*/
|
|
1107
|
+
async submitTransaction(id) {
|
|
1108
|
+
this.validateId(id, "id");
|
|
1109
|
+
const response = await this.sendRequest("POST", `${this.baseUrl}/compliance/transactions/${id}/submit`);
|
|
1110
|
+
const data = await this.parseJsonResponse(response);
|
|
1111
|
+
return ComplianceTransaction.fromArray(data);
|
|
1112
|
+
}
|
|
1113
|
+
/**
|
|
1114
|
+
* Bulk-import transactions from a semicolon-separated CSV (one row per invoice
|
|
1115
|
+
* line; rows sharing an invoice_number are grouped into one transaction).
|
|
1116
|
+
* Required columns: invoice_number, invoice_date, transaction_type, subtotal,
|
|
1117
|
+
* total, line_description, line_quantity, line_price, tax_name, tax_percent,
|
|
1118
|
+
* tax_category.
|
|
1119
|
+
*
|
|
1120
|
+
* The import is idempotent: re-uploading the same file skips rows whose
|
|
1121
|
+
* invoice already exists (reported via `skippedDuplicates`).
|
|
1122
|
+
*/
|
|
1123
|
+
async importTransactions(enrollmentId, csvContent, filename = "transactions.csv") {
|
|
1124
|
+
this.validateId(enrollmentId, "enrollmentId");
|
|
1125
|
+
if (csvContent.trim() === "") {
|
|
1126
|
+
throw new TaxoraException("csvContent must not be empty.");
|
|
1127
|
+
}
|
|
1128
|
+
const form = new FormData();
|
|
1129
|
+
form.set("compliance_enrollment_id", String(enrollmentId));
|
|
1130
|
+
form.set("file", new Blob([csvContent], { type: "text/csv" }), filename);
|
|
1131
|
+
const response = await this.sendMultipartRequest("POST", `${this.baseUrl}/compliance/transactions/import`, form);
|
|
1132
|
+
const data = await this.parseJsonResponse(response);
|
|
1133
|
+
return ImportResult.fromArray(data);
|
|
1134
|
+
}
|
|
1135
|
+
// ---------------------------------------------------------------------
|
|
1136
|
+
// Analytics, configuration & reports
|
|
1137
|
+
// ---------------------------------------------------------------------
|
|
1138
|
+
/**
|
|
1139
|
+
* Aggregated turnover statistics for the authenticated company's e-reporting
|
|
1140
|
+
* transactions. All arguments are optional — the API defaults to the last 12
|
|
1141
|
+
* months and a monthly interval.
|
|
1142
|
+
*/
|
|
1143
|
+
async getRevenueStatistics(filters = {}) {
|
|
1144
|
+
if (filters.interval !== void 0 && !INTERVALS.includes(filters.interval)) {
|
|
1145
|
+
throw new TaxoraException(
|
|
1146
|
+
`Invalid statistics interval "${String(filters.interval)}". Expected one of: ${INTERVALS.join(", ")}.`
|
|
1147
|
+
);
|
|
1148
|
+
}
|
|
1149
|
+
const params = new URLSearchParams();
|
|
1150
|
+
if (filters.dateFrom !== void 0) params.set("date_from", this.formatDate(filters.dateFrom));
|
|
1151
|
+
if (filters.dateTo !== void 0) params.set("date_to", this.formatDate(filters.dateTo));
|
|
1152
|
+
if (filters.interval !== void 0) params.set("interval", filters.interval);
|
|
1153
|
+
if (filters.transactionType !== void 0) params.set("transaction_type", filters.transactionType);
|
|
1154
|
+
if (filters.state !== void 0) params.set("state", filters.state);
|
|
1155
|
+
const queryString = params.toString();
|
|
1156
|
+
const url = `${this.baseUrl}/compliance/revenue-statistics${queryString ? `?${queryString}` : ""}`;
|
|
1157
|
+
const response = await this.sendRequest("GET", url);
|
|
1158
|
+
const data = await this.parseJsonResponse(response);
|
|
1159
|
+
return RevenueStatistics.fromArray(data);
|
|
1160
|
+
}
|
|
1161
|
+
/**
|
|
1162
|
+
* The canonical VAT rates & DGFiP tax categories for a reporting country
|
|
1163
|
+
* (the seller's reporting-country rates, not the counterparty's). Falls back
|
|
1164
|
+
* to the configured default country (FR) when none/unknown is given.
|
|
1165
|
+
*/
|
|
1166
|
+
async getVatRates(country) {
|
|
1167
|
+
const params = new URLSearchParams();
|
|
1168
|
+
if (country !== void 0) params.set("country", country);
|
|
1169
|
+
const queryString = params.toString();
|
|
1170
|
+
const url = `${this.baseUrl}/compliance/vat-rates${queryString ? `?${queryString}` : ""}`;
|
|
1171
|
+
const response = await this.sendRequest("GET", url);
|
|
1172
|
+
const data = await this.parseJsonResponse(response);
|
|
1173
|
+
return VatRates.fromArray(data);
|
|
1174
|
+
}
|
|
1175
|
+
/** Paginated list of the company's tax reports (newest first), optionally filtered by state. */
|
|
1176
|
+
async listTaxReports(page = 1, perPage = 25, state) {
|
|
1177
|
+
const params = new URLSearchParams();
|
|
1178
|
+
params.set("page", String(page));
|
|
1179
|
+
params.set("per_page", String(perPage));
|
|
1180
|
+
if (state !== void 0) params.set("state", state);
|
|
1181
|
+
const response = await this.sendRequest("GET", `${this.baseUrl}/compliance/tax-reports?${params.toString()}`);
|
|
1182
|
+
return ComplianceTaxReportPage.fromResponse(await this.parseJsonResponse(response));
|
|
1183
|
+
}
|
|
1184
|
+
/** Get a single tax report by id. */
|
|
1185
|
+
async getTaxReport(id) {
|
|
1186
|
+
this.validateId(id, "id");
|
|
1187
|
+
const response = await this.sendRequest("GET", `${this.baseUrl}/compliance/tax-reports/${id}`);
|
|
1188
|
+
const data = await this.parseJsonResponse(response);
|
|
1189
|
+
return ComplianceTaxReport.fromArray(data);
|
|
1190
|
+
}
|
|
1191
|
+
/**
|
|
1192
|
+
* Request activation of the E-Reporting feature for the account. This route
|
|
1193
|
+
* is deliberately NOT gated by compliance access — it exists precisely for
|
|
1194
|
+
* accounts that do not have the feature yet. The authenticated user's
|
|
1195
|
+
* name/email take precedence over the form values server-side.
|
|
1196
|
+
*
|
|
1197
|
+
* Note: unlike the other compliance routes, validation failures here are
|
|
1198
|
+
* returned as HTTP 400 (surfaced as HttpException), not 422.
|
|
1199
|
+
*/
|
|
1200
|
+
async requestEReportingAccess(input = {}) {
|
|
1201
|
+
const body = {};
|
|
1202
|
+
if (input.name !== void 0) body["name"] = input.name;
|
|
1203
|
+
if (input.email !== void 0) body["email"] = input.email;
|
|
1204
|
+
if (input.company !== void 0) body["company"] = input.company;
|
|
1205
|
+
if (input.phone !== void 0) body["phone"] = input.phone;
|
|
1206
|
+
if (input.message !== void 0) body["message"] = input.message;
|
|
1207
|
+
if (input.language !== void 0) body["language"] = input.language;
|
|
1208
|
+
const response = await this.sendRequest("POST", `${this.baseUrl}/compliance/e-reporting-request`, body);
|
|
1209
|
+
await this.parseJsonResponse(response);
|
|
1210
|
+
}
|
|
1211
|
+
// ---------------------------------------------------------------------
|
|
1212
|
+
// Input validation (fail fast, before any request is sent)
|
|
1213
|
+
// ---------------------------------------------------------------------
|
|
1214
|
+
validateEnrollmentInput(input) {
|
|
1215
|
+
if (input.siret === void 0 && input.siren === void 0) {
|
|
1216
|
+
throw new TaxoraException("Either siret or siren is required.");
|
|
1217
|
+
}
|
|
1218
|
+
if (input.siret !== void 0 && input.siret.length !== 14) {
|
|
1219
|
+
throw new TaxoraException("siret must be exactly 14 characters.");
|
|
1220
|
+
}
|
|
1221
|
+
if (input.siren !== void 0 && input.siren.length !== 9) {
|
|
1222
|
+
throw new TaxoraException("siren must be exactly 9 characters.");
|
|
1223
|
+
}
|
|
1224
|
+
if (input.email.trim() === "" || !input.email.includes("@")) {
|
|
1225
|
+
throw new TaxoraException("email must be a valid email address.");
|
|
1226
|
+
}
|
|
1227
|
+
if (!NAF_CODE_REGEX.test(input.nafCode)) {
|
|
1228
|
+
throw new TaxoraException('nafCode must be exactly 2 digits, e.g. "47".');
|
|
1229
|
+
}
|
|
1230
|
+
if (!ENTERPRISE_SIZES.includes(input.enterpriseSize)) {
|
|
1231
|
+
throw new TaxoraException(
|
|
1232
|
+
`Invalid enterpriseSize "${String(input.enterpriseSize)}". Expected one of: ${ENTERPRISE_SIZES.join(", ")}.`
|
|
1233
|
+
);
|
|
1234
|
+
}
|
|
1235
|
+
if (!TYPE_OPERATIONS.includes(input.typeOperation)) {
|
|
1236
|
+
throw new TaxoraException(
|
|
1237
|
+
`Invalid typeOperation "${String(input.typeOperation)}". Expected one of: ${TYPE_OPERATIONS.join(", ")}.`
|
|
1238
|
+
);
|
|
1239
|
+
}
|
|
1240
|
+
if (input.country !== void 0 && input.country.length !== 2) {
|
|
1241
|
+
throw new TaxoraException("country must be a 2-character ISO 3166-1 alpha-2 code.");
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
validateId(id, name) {
|
|
1245
|
+
if (!Number.isInteger(id) || id <= 0) {
|
|
1246
|
+
throw new TaxoraException(`${name} must be a positive integer.`);
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
validateTransactionType(type) {
|
|
1250
|
+
if (!TRANSACTION_TYPES.includes(type)) {
|
|
1251
|
+
throw new TaxoraException(
|
|
1252
|
+
`Invalid transactionType "${String(type)}". Expected one of: ${TRANSACTION_TYPES.join(", ")}.`
|
|
1253
|
+
);
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
validateInvoiceNumber(invoiceNumber) {
|
|
1257
|
+
if (invoiceNumber.trim() === "") {
|
|
1258
|
+
throw new TaxoraException("invoiceNumber must not be empty.");
|
|
1259
|
+
}
|
|
1260
|
+
if (invoiceNumber.length > 50) {
|
|
1261
|
+
throw new TaxoraException("invoiceNumber must not exceed 50 characters.");
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
validateInvoiceLines(lines) {
|
|
1265
|
+
if (lines.length === 0) {
|
|
1266
|
+
throw new TaxoraException("invoiceLines must contain at least one line.");
|
|
1267
|
+
}
|
|
1268
|
+
lines.forEach((line, index) => {
|
|
1269
|
+
if (line.taxes.length === 0) {
|
|
1270
|
+
throw new TaxoraException(`invoiceLines[${index}].taxes must contain at least one tax.`);
|
|
1271
|
+
}
|
|
1272
|
+
});
|
|
1273
|
+
}
|
|
1274
|
+
validateOptionalCodes(input) {
|
|
1275
|
+
if (input.currency !== void 0 && input.currency.length !== 3) {
|
|
1276
|
+
throw new TaxoraException("currency must be a 3-character ISO 4217 code.");
|
|
1277
|
+
}
|
|
1278
|
+
if (input.counterpartyCountry !== void 0 && input.counterpartyCountry.length !== 2) {
|
|
1279
|
+
throw new TaxoraException("counterpartyCountry must be a 2-character ISO 3166-1 alpha-2 code.");
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
// ---------------------------------------------------------------------
|
|
1283
|
+
// Body building (camelCase input → snake_case wire format)
|
|
1284
|
+
// ---------------------------------------------------------------------
|
|
1285
|
+
buildInvoiceLines(lines) {
|
|
1286
|
+
return lines.map((line) => {
|
|
1287
|
+
const built = {
|
|
1288
|
+
description: line.description,
|
|
1289
|
+
quantity: line.quantity,
|
|
1290
|
+
price: line.price,
|
|
1291
|
+
taxes_attributes: line.taxes.map((tax) => {
|
|
1292
|
+
const taxBuilt = {
|
|
1293
|
+
name: tax.name,
|
|
1294
|
+
percent: tax.percent,
|
|
1295
|
+
category: tax.category
|
|
1296
|
+
};
|
|
1297
|
+
if (tax.comment !== void 0) taxBuilt["comment"] = tax.comment;
|
|
1298
|
+
return taxBuilt;
|
|
1299
|
+
})
|
|
1300
|
+
};
|
|
1301
|
+
if (line.unit !== void 0) built["unit"] = line.unit;
|
|
1302
|
+
return built;
|
|
1303
|
+
});
|
|
1304
|
+
}
|
|
1305
|
+
/** Applies the optional scalar fields shared by create and update. */
|
|
1306
|
+
applyOptionalTransactionFields(body, input) {
|
|
1307
|
+
if (input.dueDate !== void 0) body["due_date"] = this.formatDate(input.dueDate);
|
|
1308
|
+
if (input.currency !== void 0) body["currency"] = input.currency;
|
|
1309
|
+
if (input.taxAmount !== void 0) body["tax_amount"] = input.taxAmount;
|
|
1310
|
+
if (input.counterpartyName !== void 0) body["counterparty_name"] = input.counterpartyName;
|
|
1311
|
+
if (input.counterpartyCountry !== void 0) body["counterparty_country"] = input.counterpartyCountry;
|
|
1312
|
+
if (input.counterpartyVatNumber !== void 0) body["counterparty_vat_number"] = input.counterpartyVatNumber;
|
|
1313
|
+
if (input.providerContactId !== void 0) body["provider_contact_id"] = input.providerContactId;
|
|
1314
|
+
if (input.paymentMethod !== void 0) body["payment_method"] = input.paymentMethod;
|
|
1315
|
+
if (input.remittanceInformation !== void 0) body["remittance_information"] = input.remittanceInformation;
|
|
1316
|
+
if (input.paymentMethodText !== void 0) body["payment_method_text"] = input.paymentMethodText;
|
|
1317
|
+
if (input.paymentTerms !== void 0) body["payment_terms"] = input.paymentTerms;
|
|
1318
|
+
}
|
|
1319
|
+
// ---------------------------------------------------------------------
|
|
1320
|
+
// HTTP plumbing (kept in sync with SmartEnrichmentEndpoint)
|
|
1321
|
+
// ---------------------------------------------------------------------
|
|
1322
|
+
buildHeaders(withJsonContentType = true) {
|
|
1323
|
+
const headers = {
|
|
1324
|
+
"x-api-key": this.apiKey
|
|
1325
|
+
};
|
|
1326
|
+
if (withJsonContentType) {
|
|
1327
|
+
headers["Content-Type"] = "application/json";
|
|
1328
|
+
}
|
|
1329
|
+
const token = this.tokenStorage.get();
|
|
1330
|
+
if (token) {
|
|
1331
|
+
headers["Authorization"] = `Bearer ${token.accessToken}`;
|
|
1332
|
+
}
|
|
1333
|
+
return headers;
|
|
1334
|
+
}
|
|
1335
|
+
async sendRequest(method, url, body) {
|
|
1336
|
+
const options = { headers: this.buildHeaders() };
|
|
1337
|
+
if (body) options.body = JSON.stringify(body);
|
|
1338
|
+
return this.httpClient.request(method, url, options);
|
|
1339
|
+
}
|
|
1340
|
+
/** Multipart upload: Content-Type is left to fetch so the boundary is set correctly. */
|
|
1341
|
+
async sendMultipartRequest(method, url, form) {
|
|
1342
|
+
return this.httpClient.request(method, url, { headers: this.buildHeaders(false), body: form });
|
|
1343
|
+
}
|
|
1344
|
+
/** Accepts any 2xx response (e.g. 201 on create, 200 on idempotent replay). */
|
|
1345
|
+
async parseJsonResponse(response) {
|
|
1346
|
+
const responseText = await response.text();
|
|
1347
|
+
if (response.status === 422) {
|
|
1348
|
+
throw this.buildValidationException(responseText);
|
|
1349
|
+
}
|
|
1350
|
+
if (!response.ok) {
|
|
1351
|
+
throw new HttpException(`HTTP error ${response.status}`, response.status, responseText);
|
|
1352
|
+
}
|
|
1353
|
+
let parsed;
|
|
1354
|
+
try {
|
|
1355
|
+
parsed = JSON.parse(responseText);
|
|
1356
|
+
} catch {
|
|
1357
|
+
throw new HttpException("Invalid JSON response", 0, responseText);
|
|
1358
|
+
}
|
|
1359
|
+
if (typeof parsed !== "object" || parsed === null) {
|
|
1360
|
+
throw new HttpException("Unexpected response format", 0, responseText);
|
|
1361
|
+
}
|
|
1362
|
+
const obj = parsed;
|
|
1363
|
+
if (obj["data"] !== void 0 && typeof obj["data"] === "object" && obj["data"] !== null) {
|
|
1364
|
+
return obj["data"];
|
|
1365
|
+
}
|
|
1366
|
+
return obj;
|
|
1367
|
+
}
|
|
1368
|
+
/** For the 204 delete: keeps the shared 422/HTTP error mapping but never parses a body. */
|
|
1369
|
+
async assertNoContentResponse(response) {
|
|
1370
|
+
if (response.status === 204) {
|
|
1371
|
+
return;
|
|
1372
|
+
}
|
|
1373
|
+
const responseText = await response.text();
|
|
1374
|
+
if (response.status === 422) {
|
|
1375
|
+
throw this.buildValidationException(responseText);
|
|
1376
|
+
}
|
|
1377
|
+
if (!response.ok) {
|
|
1378
|
+
throw new HttpException(`HTTP error ${response.status}`, response.status, responseText);
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
/**
|
|
1382
|
+
* The backend emits two 422 shapes: Laravel FormRequest failures as
|
|
1383
|
+
* `{message, errors: {field: [...]}}` and state-guard errors via returnError()
|
|
1384
|
+
* as `{error: "reason"}`. Preserve the reason in both cases.
|
|
1385
|
+
*/
|
|
1386
|
+
buildValidationException(responseText) {
|
|
1387
|
+
let message = "Validation failed";
|
|
1388
|
+
let errors = {};
|
|
1389
|
+
try {
|
|
1390
|
+
const parsed = JSON.parse(responseText);
|
|
1391
|
+
if (parsed["errors"] !== null && typeof parsed["errors"] === "object" && !Array.isArray(parsed["errors"])) {
|
|
1392
|
+
errors = parsed["errors"];
|
|
1393
|
+
}
|
|
1394
|
+
if (typeof parsed["message"] === "string" && parsed["message"] !== "") {
|
|
1395
|
+
message = parsed["message"];
|
|
1396
|
+
} else if (typeof parsed["error"] === "string" && parsed["error"] !== "") {
|
|
1397
|
+
message = parsed["error"];
|
|
1398
|
+
}
|
|
1399
|
+
} catch {
|
|
1400
|
+
}
|
|
1401
|
+
return new ValidationException(message, errors, { responseBody: responseText });
|
|
1402
|
+
}
|
|
1403
|
+
/**
|
|
1404
|
+
* Date objects are serialized from their LOCAL date parts — construct them as
|
|
1405
|
+
* `new Date('2026-09-01T00:00:00')` (local midnight); a bare `new Date('2026-09-01')`
|
|
1406
|
+
* is UTC midnight and shifts a day back in UTC-negative timezones.
|
|
1407
|
+
*/
|
|
1408
|
+
formatDate(date) {
|
|
1409
|
+
if (date instanceof Date) {
|
|
1410
|
+
const year = date.getFullYear();
|
|
1411
|
+
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
1412
|
+
const day = String(date.getDate()).padStart(2, "0");
|
|
1413
|
+
return `${year}-${month}-${day}`;
|
|
1414
|
+
}
|
|
1415
|
+
if (!DATE_REGEX.test(date)) {
|
|
1416
|
+
throw new TaxoraException(`Invalid date format: "${date}". Expected YYYY-MM-DD.`);
|
|
1417
|
+
}
|
|
1418
|
+
return date;
|
|
1419
|
+
}
|
|
1420
|
+
};
|
|
1421
|
+
|
|
1422
|
+
// src/enums/SmartEnrichmentStatus.ts
|
|
1423
|
+
var SmartEnrichmentStatus = {
|
|
1424
|
+
FOUND: "found",
|
|
1425
|
+
NO_VAT_EXISTS: "no_vat_exists",
|
|
1426
|
+
NOT_FOUND: "not_found",
|
|
1427
|
+
PROCESSING: "processing",
|
|
1428
|
+
QUEUED: "queued",
|
|
1429
|
+
COMPLETED: "completed",
|
|
1430
|
+
FAILED: "failed",
|
|
1431
|
+
UNKNOWN: "unknown"
|
|
1432
|
+
};
|
|
1433
|
+
var VALUES5 = Object.values(SmartEnrichmentStatus);
|
|
1434
|
+
function toSmartEnrichmentStatus(value) {
|
|
1435
|
+
if (typeof value === "string") {
|
|
1436
|
+
const normalized = value.trim().toLowerCase();
|
|
1437
|
+
if (VALUES5.includes(normalized)) {
|
|
1438
|
+
return normalized;
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
return SmartEnrichmentStatus.UNKNOWN;
|
|
1442
|
+
}
|
|
1443
|
+
var DESCRIPTIONS5 = {
|
|
1444
|
+
[SmartEnrichmentStatus.FOUND]: "A VAT number was resolved and confirmed.",
|
|
1445
|
+
[SmartEnrichmentStatus.NO_VAT_EXISTS]: "The company was identified but has no VAT number.",
|
|
1446
|
+
[SmartEnrichmentStatus.NOT_FOUND]: "No sufficiently-confident match could be resolved.",
|
|
1447
|
+
[SmartEnrichmentStatus.PROCESSING]: "The lookup is still being processed.",
|
|
1448
|
+
[SmartEnrichmentStatus.QUEUED]: "The job is queued.",
|
|
1449
|
+
[SmartEnrichmentStatus.COMPLETED]: "The job has completed.",
|
|
1450
|
+
[SmartEnrichmentStatus.FAILED]: "The job failed.",
|
|
1451
|
+
[SmartEnrichmentStatus.UNKNOWN]: "Unknown status."
|
|
1452
|
+
};
|
|
1453
|
+
function describeSmartEnrichmentStatus(status) {
|
|
1454
|
+
return DESCRIPTIONS5[status];
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1457
|
+
// src/dto/SmartEnrichmentResource.ts
|
|
1458
|
+
var SmartEnrichmentResource = class _SmartEnrichmentResource {
|
|
1459
|
+
constructor(status, vatNumber, vatType, confidence, matchedCompanyName, matchedAddress, country, source) {
|
|
1460
|
+
this.status = status;
|
|
1461
|
+
this.vatNumber = vatNumber;
|
|
1462
|
+
this.vatType = vatType;
|
|
1463
|
+
this.confidence = confidence;
|
|
1464
|
+
this.matchedCompanyName = matchedCompanyName;
|
|
1465
|
+
this.matchedAddress = matchedAddress;
|
|
1466
|
+
this.country = country;
|
|
1467
|
+
this.source = source;
|
|
1468
|
+
}
|
|
1469
|
+
status;
|
|
1470
|
+
vatNumber;
|
|
1471
|
+
vatType;
|
|
1472
|
+
confidence;
|
|
1473
|
+
matchedCompanyName;
|
|
1474
|
+
matchedAddress;
|
|
1475
|
+
country;
|
|
1476
|
+
source;
|
|
1477
|
+
static fromArray(data) {
|
|
1478
|
+
const str = (key) => {
|
|
1479
|
+
const v = data[key];
|
|
1480
|
+
return typeof v === "string" ? v : void 0;
|
|
1481
|
+
};
|
|
1482
|
+
const num = (key) => {
|
|
1483
|
+
const v = data[key];
|
|
1484
|
+
return typeof v === "number" ? v : void 0;
|
|
1485
|
+
};
|
|
1486
|
+
return new _SmartEnrichmentResource(
|
|
1487
|
+
toSmartEnrichmentStatus(data["status"]),
|
|
1488
|
+
str("vatNumber"),
|
|
1489
|
+
str("vatType"),
|
|
1490
|
+
num("confidence"),
|
|
1491
|
+
str("matchedCompanyName"),
|
|
1492
|
+
str("matchedAddress"),
|
|
1493
|
+
str("country"),
|
|
1494
|
+
str("source")
|
|
1495
|
+
);
|
|
1496
|
+
}
|
|
1497
|
+
toArray() {
|
|
1498
|
+
return {
|
|
1499
|
+
status: this.status,
|
|
1500
|
+
vatNumber: this.vatNumber ?? null,
|
|
1501
|
+
vatType: this.vatType ?? null,
|
|
1502
|
+
confidence: this.confidence ?? null,
|
|
1503
|
+
matchedCompanyName: this.matchedCompanyName ?? null,
|
|
1504
|
+
matchedAddress: this.matchedAddress ?? null,
|
|
1505
|
+
country: this.country ?? null,
|
|
1506
|
+
source: this.source ?? null
|
|
1507
|
+
};
|
|
1508
|
+
}
|
|
1509
|
+
};
|
|
1510
|
+
|
|
1511
|
+
// src/dto/SmartEnrichmentJob.ts
|
|
1512
|
+
var SmartEnrichmentJob = class _SmartEnrichmentJob {
|
|
1513
|
+
constructor(jobId, status, itemCount, completedCount, foundCount, results) {
|
|
1514
|
+
this.jobId = jobId;
|
|
1515
|
+
this.status = status;
|
|
1516
|
+
this.itemCount = itemCount;
|
|
1517
|
+
this.completedCount = completedCount;
|
|
1518
|
+
this.foundCount = foundCount;
|
|
1519
|
+
this.results = results;
|
|
1520
|
+
}
|
|
1521
|
+
jobId;
|
|
1522
|
+
status;
|
|
1523
|
+
itemCount;
|
|
1524
|
+
completedCount;
|
|
1525
|
+
foundCount;
|
|
1526
|
+
results;
|
|
1527
|
+
static fromArray(data) {
|
|
1528
|
+
const num = (key) => {
|
|
1529
|
+
const v = data[key];
|
|
1530
|
+
return typeof v === "number" ? v : void 0;
|
|
1531
|
+
};
|
|
1532
|
+
let results = [];
|
|
1533
|
+
if (Array.isArray(data["results"])) {
|
|
1534
|
+
results = data["results"].filter((row) => typeof row === "object" && row !== null).map(SmartEnrichmentResource.fromArray);
|
|
1535
|
+
} else if (data["vatNumber"] !== void 0 || _SmartEnrichmentJob.looksLikeItem(data["status"])) {
|
|
1536
|
+
results = [SmartEnrichmentResource.fromArray(data)];
|
|
1537
|
+
}
|
|
1538
|
+
return new _SmartEnrichmentJob(
|
|
1539
|
+
typeof data["jobId"] === "string" ? data["jobId"] : "",
|
|
1540
|
+
toSmartEnrichmentStatus(data["status"]),
|
|
1541
|
+
num("itemCount"),
|
|
1542
|
+
num("completedCount"),
|
|
1543
|
+
num("foundCount"),
|
|
1544
|
+
results
|
|
1545
|
+
);
|
|
1546
|
+
}
|
|
1547
|
+
isProcessing() {
|
|
1548
|
+
return this.status === SmartEnrichmentStatus.PROCESSING || this.status === SmartEnrichmentStatus.QUEUED;
|
|
1549
|
+
}
|
|
1550
|
+
/** Convenience for single lookups: the first (or only) result, if any. */
|
|
1551
|
+
result() {
|
|
1552
|
+
return this.results[0];
|
|
1553
|
+
}
|
|
1554
|
+
static looksLikeItem(status) {
|
|
1555
|
+
const s = toSmartEnrichmentStatus(status);
|
|
1556
|
+
return s === SmartEnrichmentStatus.FOUND || s === SmartEnrichmentStatus.NO_VAT_EXISTS || s === SmartEnrichmentStatus.NOT_FOUND;
|
|
1557
|
+
}
|
|
1558
|
+
};
|
|
1559
|
+
|
|
1560
|
+
// src/dto/SmartEnrichmentHistoryRow.ts
|
|
1561
|
+
var SmartEnrichmentHistoryRow = class _SmartEnrichmentHistoryRow {
|
|
1562
|
+
constructor(jobId, status, isBulk, itemCount, foundCount, queryCompanyName, queryCountry, queryCity, input, result, createdAt, finishedAt) {
|
|
1563
|
+
this.jobId = jobId;
|
|
1564
|
+
this.status = status;
|
|
1565
|
+
this.isBulk = isBulk;
|
|
1566
|
+
this.itemCount = itemCount;
|
|
1567
|
+
this.foundCount = foundCount;
|
|
1568
|
+
this.queryCompanyName = queryCompanyName;
|
|
1569
|
+
this.queryCountry = queryCountry;
|
|
1570
|
+
this.queryCity = queryCity;
|
|
1571
|
+
this.input = input;
|
|
1572
|
+
this.result = result;
|
|
1573
|
+
this.createdAt = createdAt;
|
|
1574
|
+
this.finishedAt = finishedAt;
|
|
1575
|
+
}
|
|
1576
|
+
jobId;
|
|
1577
|
+
status;
|
|
1578
|
+
isBulk;
|
|
1579
|
+
itemCount;
|
|
1580
|
+
foundCount;
|
|
1581
|
+
queryCompanyName;
|
|
1582
|
+
queryCountry;
|
|
1583
|
+
queryCity;
|
|
1584
|
+
input;
|
|
1585
|
+
result;
|
|
1586
|
+
createdAt;
|
|
1587
|
+
finishedAt;
|
|
1588
|
+
static fromArray(data) {
|
|
1589
|
+
const str = (value) => typeof value === "string" ? value : void 0;
|
|
1590
|
+
const query = data["query"] !== null && typeof data["query"] === "object" && !Array.isArray(data["query"]) ? data["query"] : {};
|
|
1591
|
+
const inputRaw = data["input"] !== null && typeof data["input"] === "object" && !Array.isArray(data["input"]) ? data["input"] : void 0;
|
|
1592
|
+
const input = inputRaw ? {
|
|
1593
|
+
companyName: str(inputRaw["companyName"]),
|
|
1594
|
+
street: str(inputRaw["street"]),
|
|
1595
|
+
postalCode: str(inputRaw["postalCode"]),
|
|
1596
|
+
city: str(inputRaw["city"]),
|
|
1597
|
+
country: str(inputRaw["country"])
|
|
1598
|
+
} : void 0;
|
|
1599
|
+
const result = data["result"] !== null && typeof data["result"] === "object" && !Array.isArray(data["result"]) ? SmartEnrichmentResource.fromArray(data["result"]) : void 0;
|
|
1600
|
+
return new _SmartEnrichmentHistoryRow(
|
|
1601
|
+
str(data["jobId"]) ?? "",
|
|
1602
|
+
toSmartEnrichmentStatus(data["status"]),
|
|
1603
|
+
data["isBulk"] === true,
|
|
1604
|
+
typeof data["itemCount"] === "number" ? data["itemCount"] : 0,
|
|
1605
|
+
typeof data["foundCount"] === "number" ? data["foundCount"] : 0,
|
|
1606
|
+
str(query["companyName"]),
|
|
1607
|
+
str(query["country"]),
|
|
1608
|
+
str(query["city"]),
|
|
1609
|
+
input,
|
|
1610
|
+
result,
|
|
1611
|
+
str(data["createdAt"]),
|
|
1612
|
+
str(data["finishedAt"])
|
|
1613
|
+
);
|
|
1614
|
+
}
|
|
1615
|
+
};
|
|
1616
|
+
|
|
1617
|
+
// src/dto/SmartEnrichmentHistoryPage.ts
|
|
1618
|
+
var SmartEnrichmentHistoryPage = class _SmartEnrichmentHistoryPage {
|
|
1619
|
+
constructor(rows, currentPage, perPage, total, lastPage, stats) {
|
|
1620
|
+
this.rows = rows;
|
|
1621
|
+
this.currentPage = currentPage;
|
|
1622
|
+
this.perPage = perPage;
|
|
1623
|
+
this.total = total;
|
|
1624
|
+
this.lastPage = lastPage;
|
|
1625
|
+
this.stats = stats;
|
|
1626
|
+
}
|
|
1627
|
+
rows;
|
|
1628
|
+
currentPage;
|
|
1629
|
+
perPage;
|
|
1630
|
+
total;
|
|
1631
|
+
lastPage;
|
|
1632
|
+
stats;
|
|
1633
|
+
static fromResponse(payload) {
|
|
1634
|
+
const obj = payload !== null && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
|
|
1635
|
+
const rows = Array.isArray(obj["data"]) ? obj["data"].filter((row) => typeof row === "object" && row !== null).map(SmartEnrichmentHistoryRow.fromArray) : [];
|
|
1636
|
+
const meta = obj["meta"] !== null && typeof obj["meta"] === "object" && !Array.isArray(obj["meta"]) ? obj["meta"] : {};
|
|
1637
|
+
const num = (value, fallback) => typeof value === "number" ? value : fallback;
|
|
1638
|
+
const statsRaw = obj["stats"] !== null && typeof obj["stats"] === "object" && !Array.isArray(obj["stats"]) ? obj["stats"] : void 0;
|
|
1639
|
+
const stats = statsRaw ? { total: num(statsRaw["total"], 0), found: num(statsRaw["found"], 0) } : void 0;
|
|
1640
|
+
return new _SmartEnrichmentHistoryPage(
|
|
1641
|
+
rows,
|
|
1642
|
+
num(meta["currentPage"], 1),
|
|
1643
|
+
num(meta["perPage"], rows.length),
|
|
1644
|
+
num(meta["total"], rows.length),
|
|
1645
|
+
num(meta["lastPage"], 1),
|
|
1646
|
+
stats
|
|
1647
|
+
);
|
|
1648
|
+
}
|
|
1649
|
+
[Symbol.iterator]() {
|
|
1650
|
+
return this.rows[Symbol.iterator]();
|
|
1651
|
+
}
|
|
1652
|
+
get length() {
|
|
1653
|
+
return this.rows.length;
|
|
1654
|
+
}
|
|
1655
|
+
};
|
|
1656
|
+
|
|
1657
|
+
// src/dto/SmartEnrichmentStatistics.ts
|
|
1658
|
+
function asString7(value, fallback = "") {
|
|
1659
|
+
return typeof value === "string" ? value : fallback;
|
|
1660
|
+
}
|
|
1661
|
+
function asNumber6(value) {
|
|
1662
|
+
return typeof value === "number" ? value : Number(value ?? 0) || 0;
|
|
1663
|
+
}
|
|
1664
|
+
function asRecord(value) {
|
|
1665
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
1666
|
+
}
|
|
1667
|
+
function asRecords2(value) {
|
|
1668
|
+
if (!Array.isArray(value)) return [];
|
|
1669
|
+
return value.filter((row) => typeof row === "object" && row !== null);
|
|
1670
|
+
}
|
|
1671
|
+
var SmartEnrichmentStatistics = class _SmartEnrichmentStatistics {
|
|
1672
|
+
constructor(range, totals, timeSeries, bySource, byOutcome, confidenceBuckets) {
|
|
1673
|
+
this.range = range;
|
|
1674
|
+
this.totals = totals;
|
|
1675
|
+
this.timeSeries = timeSeries;
|
|
1676
|
+
this.bySource = bySource;
|
|
1677
|
+
this.byOutcome = byOutcome;
|
|
1678
|
+
this.confidenceBuckets = confidenceBuckets;
|
|
1679
|
+
}
|
|
1680
|
+
range;
|
|
1681
|
+
totals;
|
|
1682
|
+
timeSeries;
|
|
1683
|
+
bySource;
|
|
1684
|
+
byOutcome;
|
|
1685
|
+
confidenceBuckets;
|
|
1686
|
+
static fromArray(data) {
|
|
1687
|
+
const range = asRecord(data["range"]);
|
|
1688
|
+
const totals = asRecord(data["totals"]);
|
|
1689
|
+
const timeSeries = asRecords2(data["time_series"]).map((row) => ({
|
|
1690
|
+
bucket: asString7(row["bucket"]),
|
|
1691
|
+
jobs: asNumber6(row["jobs"]),
|
|
1692
|
+
items: asNumber6(row["items"]),
|
|
1693
|
+
found: asNumber6(row["found"])
|
|
1694
|
+
}));
|
|
1695
|
+
const bySource = asRecords2(data["by_source"]).map((row) => ({
|
|
1696
|
+
source: asString7(row["source"]),
|
|
1697
|
+
jobs: asNumber6(row["jobs"]),
|
|
1698
|
+
found: asNumber6(row["found"])
|
|
1699
|
+
}));
|
|
1700
|
+
const byOutcome = asRecords2(data["by_outcome"]).map((row) => ({
|
|
1701
|
+
outcome: asString7(row["outcome"]),
|
|
1702
|
+
count: asNumber6(row["count"])
|
|
1703
|
+
}));
|
|
1704
|
+
const confidenceBuckets = asRecords2(data["confidence_buckets"]).map((row) => ({
|
|
1705
|
+
bucket: asString7(row["bucket"]),
|
|
1706
|
+
count: asNumber6(row["count"])
|
|
1707
|
+
}));
|
|
1708
|
+
return new _SmartEnrichmentStatistics(
|
|
1709
|
+
{
|
|
1710
|
+
dateFrom: asString7(range["date_from"]),
|
|
1711
|
+
dateTo: asString7(range["date_to"]),
|
|
1712
|
+
interval: asString7(range["interval"])
|
|
1713
|
+
},
|
|
1714
|
+
{
|
|
1715
|
+
jobs: asNumber6(totals["jobs"]),
|
|
1716
|
+
items: asNumber6(totals["items"]),
|
|
1717
|
+
found: asNumber6(totals["found"]),
|
|
1718
|
+
foundRate: asNumber6(totals["found_rate"]),
|
|
1719
|
+
avgConfidence: asNumber6(totals["avg_confidence"])
|
|
1720
|
+
},
|
|
1721
|
+
timeSeries,
|
|
1722
|
+
bySource,
|
|
1723
|
+
byOutcome,
|
|
1724
|
+
confidenceBuckets
|
|
1725
|
+
);
|
|
1726
|
+
}
|
|
1727
|
+
};
|
|
1728
|
+
|
|
1729
|
+
// src/endpoints/SmartEnrichmentEndpoint.ts
|
|
1730
|
+
var STATISTICS_INTERVALS = ["day", "week", "month"];
|
|
1731
|
+
var DEFAULT_POLL_INTERVAL_MS = 2e3;
|
|
1732
|
+
var DEFAULT_POLL_TIMEOUT_MS = 12e4;
|
|
1733
|
+
var SmartEnrichmentEndpoint = class {
|
|
1734
|
+
constructor(baseUrl, apiKey, tokenStorage, httpClient) {
|
|
1735
|
+
this.baseUrl = baseUrl;
|
|
1736
|
+
this.apiKey = apiKey;
|
|
1737
|
+
this.tokenStorage = tokenStorage;
|
|
1738
|
+
this.httpClient = httpClient;
|
|
1739
|
+
}
|
|
1740
|
+
baseUrl;
|
|
1741
|
+
apiKey;
|
|
1742
|
+
tokenStorage;
|
|
1743
|
+
httpClient;
|
|
1744
|
+
/**
|
|
1745
|
+
* Single reverse lookup. Returns a confident result synchronously, or a `processing`
|
|
1746
|
+
* job (poll with get(job.jobId) or waitForCompletion(job.jobId)) when deeper resolution
|
|
1747
|
+
* is needed.
|
|
1748
|
+
*/
|
|
1749
|
+
async lookup(input) {
|
|
1750
|
+
this.validateInput(input);
|
|
1751
|
+
const body = {
|
|
1752
|
+
companyName: input.companyName,
|
|
1753
|
+
country: input.country
|
|
1754
|
+
};
|
|
1755
|
+
if (input.street !== void 0) body["street"] = input.street;
|
|
1756
|
+
if (input.postalCode !== void 0) body["postalCode"] = input.postalCode;
|
|
1757
|
+
if (input.city !== void 0) body["city"] = input.city;
|
|
1758
|
+
const response = await this.sendRequest("POST", `${this.baseUrl}/smart-enrichment`, body);
|
|
1759
|
+
const data = await this.parseJsonResponse(response, [200, 202]);
|
|
1760
|
+
return SmartEnrichmentJob.fromArray(data);
|
|
1761
|
+
}
|
|
1762
|
+
/**
|
|
1763
|
+
* Bulk batch — always async. Returns a `processing` job; results arrive via the
|
|
1764
|
+
* `enrichment.completed` webhook and are retrievable via get(job.jobId).
|
|
1765
|
+
*/
|
|
1766
|
+
async bulkLookup(items) {
|
|
1767
|
+
if (items.length === 0) {
|
|
1768
|
+
throw new TaxoraException("bulkLookup requires at least one item.");
|
|
1769
|
+
}
|
|
1770
|
+
items.forEach((item, index) => this.validateInput(item, `items[${index}]`));
|
|
1771
|
+
const response = await this.sendRequest("POST", `${this.baseUrl}/smart-enrichment/bulk`, { items });
|
|
1772
|
+
const data = await this.parseJsonResponse(response, [200, 202]);
|
|
1773
|
+
return SmartEnrichmentJob.fromArray(data);
|
|
1774
|
+
}
|
|
1775
|
+
/** Poll a job (single or bulk) by its id. */
|
|
1776
|
+
async get(jobId) {
|
|
1777
|
+
this.validateJobId(jobId);
|
|
1778
|
+
const response = await this.sendRequest("GET", `${this.baseUrl}/smart-enrichment/${encodeURIComponent(jobId)}`);
|
|
1779
|
+
const data = await this.parseJsonResponse(response);
|
|
1780
|
+
return SmartEnrichmentJob.fromArray(data);
|
|
1781
|
+
}
|
|
1782
|
+
/**
|
|
1783
|
+
* Poll get(jobId) until the job is no longer processing (completed, failed or resolved).
|
|
1784
|
+
* Throws a TaxoraException when the job does not finish within `timeoutMs`.
|
|
1785
|
+
*/
|
|
1786
|
+
async waitForCompletion(jobId, options = {}) {
|
|
1787
|
+
this.validateJobId(jobId);
|
|
1788
|
+
const pollIntervalMs = options.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
|
|
1789
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_POLL_TIMEOUT_MS;
|
|
1790
|
+
if (!Number.isFinite(pollIntervalMs) || pollIntervalMs <= 0) {
|
|
1791
|
+
throw new TaxoraException("pollIntervalMs must be greater than 0.");
|
|
1792
|
+
}
|
|
1793
|
+
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
|
|
1794
|
+
throw new TaxoraException("timeoutMs must be greater than 0.");
|
|
1795
|
+
}
|
|
1796
|
+
const deadline = Date.now() + timeoutMs;
|
|
1797
|
+
for (; ; ) {
|
|
1798
|
+
const job = await this.get(jobId);
|
|
1799
|
+
if (!job.isProcessing()) {
|
|
1800
|
+
return job;
|
|
1801
|
+
}
|
|
1802
|
+
if (Date.now() + pollIntervalMs > deadline) {
|
|
1803
|
+
throw new TaxoraException(`Smart Enrichment job "${jobId}" did not complete within ${timeoutMs}ms.`, {
|
|
1804
|
+
jobId,
|
|
1805
|
+
timeoutMs
|
|
1806
|
+
});
|
|
1807
|
+
}
|
|
1808
|
+
await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
/**
|
|
1812
|
+
* Paginated lookup history (newest first). `perPage` is capped at 100 server-side.
|
|
1813
|
+
* `search` filters (free-text) over the queried company name and the resolved
|
|
1814
|
+
* VAT number / matched company name.
|
|
1815
|
+
*/
|
|
1816
|
+
async history(page = 1, perPage = 25, search) {
|
|
1817
|
+
const params = new URLSearchParams();
|
|
1818
|
+
params.set("page", String(page));
|
|
1819
|
+
params.set("perPage", String(perPage));
|
|
1820
|
+
if (search !== void 0) params.set("search", search);
|
|
1821
|
+
const response = await this.sendRequest("GET", `${this.baseUrl}/smart-enrichment/history?${params.toString()}`);
|
|
1822
|
+
return SmartEnrichmentHistoryPage.fromResponse(await this.parseRawJson(response));
|
|
1823
|
+
}
|
|
1824
|
+
/** Current billing-period quota usage, plus recent monthly billing entries. */
|
|
1825
|
+
async usage() {
|
|
1826
|
+
const response = await this.sendRequest("GET", `${this.baseUrl}/smart-enrichment/usage`);
|
|
1827
|
+
const data = await this.parseJsonResponse(response);
|
|
1828
|
+
return {
|
|
1829
|
+
period: typeof data["period"] === "string" ? data["period"] : "",
|
|
1830
|
+
used: typeof data["used"] === "number" ? data["used"] : 0,
|
|
1831
|
+
included: typeof data["included"] === "number" ? data["included"] : 0,
|
|
1832
|
+
remaining: typeof data["remaining"] === "number" ? data["remaining"] : 0,
|
|
1833
|
+
overageCount: typeof data["overageCount"] === "number" ? data["overageCount"] : 0,
|
|
1834
|
+
overagePrice: typeof data["overagePrice"] === "number" ? data["overagePrice"] : 0,
|
|
1835
|
+
overageAmount: typeof data["overageAmount"] === "number" ? data["overageAmount"] : 0,
|
|
1836
|
+
hardCap: typeof data["hardCap"] === "number" ? data["hardCap"] : null,
|
|
1837
|
+
history: this.parseUsageHistory(data["history"])
|
|
1838
|
+
};
|
|
1839
|
+
}
|
|
1840
|
+
/**
|
|
1841
|
+
* Export the company's lookups as CSV (bulk-input shape plus the resolved VAT columns;
|
|
1842
|
+
* bulk jobs are flattened to one line per input row). Returns the raw CSV text
|
|
1843
|
+
* (UTF-8, BOM included by the API so Excel opens umlauts correctly).
|
|
1844
|
+
*/
|
|
1845
|
+
async export(options = {}) {
|
|
1846
|
+
const params = new URLSearchParams();
|
|
1847
|
+
if (options.dateFrom !== void 0) params.set("date_from", options.dateFrom);
|
|
1848
|
+
if (options.dateTo !== void 0) params.set("date_to", options.dateTo);
|
|
1849
|
+
if (options.minConfidence !== void 0) params.set("min_confidence", String(options.minConfidence));
|
|
1850
|
+
for (const status of options.status ?? []) {
|
|
1851
|
+
params.append("status[]", status);
|
|
1852
|
+
}
|
|
1853
|
+
if (options.onlyFound !== void 0) params.set("only_found", options.onlyFound ? "1" : "0");
|
|
1854
|
+
const queryString = params.toString();
|
|
1855
|
+
const url = `${this.baseUrl}/smart-enrichment/export${queryString ? `?${queryString}` : ""}`;
|
|
1856
|
+
const response = await this.sendRequest("GET", url);
|
|
1857
|
+
return this.parseCsvResponse(response);
|
|
1858
|
+
}
|
|
1859
|
+
/**
|
|
1860
|
+
* Aggregated lookup statistics: headline totals, a time series and breakdowns by
|
|
1861
|
+
* source, outcome and confidence band. The API defaults to the last 12 months
|
|
1862
|
+
* and a monthly interval.
|
|
1863
|
+
*/
|
|
1864
|
+
async statistics(options = {}) {
|
|
1865
|
+
if (options.interval !== void 0 && !STATISTICS_INTERVALS.includes(options.interval)) {
|
|
1866
|
+
throw new TaxoraException(
|
|
1867
|
+
`Invalid statistics interval "${String(options.interval)}". Expected one of: ${STATISTICS_INTERVALS.join(", ")}.`
|
|
1868
|
+
);
|
|
1869
|
+
}
|
|
1870
|
+
const params = new URLSearchParams();
|
|
1871
|
+
if (options.dateFrom !== void 0) params.set("date_from", options.dateFrom);
|
|
1872
|
+
if (options.dateTo !== void 0) params.set("date_to", options.dateTo);
|
|
1873
|
+
if (options.interval !== void 0) params.set("interval", options.interval);
|
|
1874
|
+
const queryString = params.toString();
|
|
1875
|
+
const url = `${this.baseUrl}/smart-enrichment/statistics${queryString ? `?${queryString}` : ""}`;
|
|
1876
|
+
const response = await this.sendRequest("GET", url);
|
|
1877
|
+
return SmartEnrichmentStatistics.fromArray(await this.parseRawJson(response));
|
|
1878
|
+
}
|
|
1879
|
+
// ---------------------------------------------------------------------
|
|
1880
|
+
// Input validation (fail fast, before any request is sent)
|
|
1881
|
+
// ---------------------------------------------------------------------
|
|
1882
|
+
validateInput(input, context) {
|
|
1883
|
+
const where = context ? ` (${context})` : "";
|
|
1884
|
+
if (input.companyName.trim() === "") {
|
|
1885
|
+
throw new TaxoraException(`companyName must not be empty${where}.`);
|
|
1886
|
+
}
|
|
1887
|
+
if (input.country.length !== 2) {
|
|
1888
|
+
throw new TaxoraException(`country must be a 2-character ISO 3166-1 alpha-2 code${where}.`);
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1891
|
+
validateJobId(jobId) {
|
|
1892
|
+
if (jobId.trim() === "") {
|
|
1893
|
+
throw new TaxoraException("jobId must not be empty.");
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
// ---------------------------------------------------------------------
|
|
1897
|
+
// HTTP plumbing (kept in sync with VatEndpoint)
|
|
1898
|
+
// ---------------------------------------------------------------------
|
|
1899
|
+
buildHeaders() {
|
|
1900
|
+
const headers = {
|
|
1901
|
+
"Content-Type": "application/json",
|
|
1902
|
+
"x-api-key": this.apiKey
|
|
1903
|
+
};
|
|
1904
|
+
const token = this.tokenStorage.get();
|
|
1905
|
+
if (token) {
|
|
1906
|
+
headers["Authorization"] = `Bearer ${token.accessToken}`;
|
|
1907
|
+
}
|
|
1908
|
+
return headers;
|
|
1909
|
+
}
|
|
1910
|
+
async sendRequest(method, url, body) {
|
|
1911
|
+
const options = { headers: this.buildHeaders() };
|
|
1912
|
+
if (body) options.body = JSON.stringify(body);
|
|
1913
|
+
return this.httpClient.request(method, url, options);
|
|
1914
|
+
}
|
|
1915
|
+
async parseJsonResponse(response, acceptedStatuses = [200]) {
|
|
1916
|
+
const responseText = await response.text();
|
|
1917
|
+
if (response.status === 422) {
|
|
1918
|
+
throw new ValidationException("Validation failed", this.parseValidationErrors(responseText));
|
|
1919
|
+
}
|
|
1920
|
+
if (!response.ok && !acceptedStatuses.includes(response.status)) {
|
|
1921
|
+
throw new HttpException(`HTTP error ${response.status}`, response.status, responseText);
|
|
1922
|
+
}
|
|
1923
|
+
let parsed;
|
|
1924
|
+
try {
|
|
1925
|
+
parsed = JSON.parse(responseText);
|
|
1926
|
+
} catch {
|
|
1927
|
+
throw new HttpException("Invalid JSON response", 0, responseText);
|
|
1928
|
+
}
|
|
1929
|
+
if (typeof parsed !== "object" || parsed === null) {
|
|
1930
|
+
throw new HttpException("Unexpected response format", 0, responseText);
|
|
1931
|
+
}
|
|
1932
|
+
const obj = parsed;
|
|
1933
|
+
if (obj["data"] !== void 0 && (typeof obj["data"] === "object" || Array.isArray(obj["data"]))) {
|
|
1934
|
+
return obj["data"];
|
|
1935
|
+
}
|
|
1936
|
+
return obj;
|
|
1937
|
+
}
|
|
1938
|
+
/**
|
|
1939
|
+
* Like parseJsonResponse but returns the whole object WITHOUT unwrapping `data` — used for
|
|
1940
|
+
* the paginated history response (where `data` is the row array and `meta`/`stats` must be
|
|
1941
|
+
* preserved) and the statistics response.
|
|
1942
|
+
*/
|
|
1943
|
+
async parseRawJson(response) {
|
|
1944
|
+
const responseText = await response.text();
|
|
1945
|
+
if (response.status === 422) {
|
|
1946
|
+
throw new ValidationException("Validation failed", this.parseValidationErrors(responseText));
|
|
1947
|
+
}
|
|
1948
|
+
if (!response.ok) {
|
|
1949
|
+
throw new HttpException(`HTTP error ${response.status}`, response.status, responseText);
|
|
1950
|
+
}
|
|
1951
|
+
let parsed;
|
|
1952
|
+
try {
|
|
1953
|
+
parsed = JSON.parse(responseText);
|
|
1954
|
+
} catch {
|
|
1955
|
+
throw new HttpException("Invalid JSON response", 0, responseText);
|
|
1956
|
+
}
|
|
1957
|
+
if (typeof parsed !== "object" || parsed === null) {
|
|
1958
|
+
throw new HttpException("Unexpected response format", 0, responseText);
|
|
1959
|
+
}
|
|
1960
|
+
return parsed;
|
|
1961
|
+
}
|
|
1962
|
+
/**
|
|
1963
|
+
* For the CSV export: keeps the shared 422/HTTP error mapping but returns the body
|
|
1964
|
+
* verbatim (text/csv) instead of parsing JSON.
|
|
1965
|
+
*/
|
|
1966
|
+
async parseCsvResponse(response) {
|
|
1967
|
+
const responseText = await response.text();
|
|
1968
|
+
if (response.status === 422) {
|
|
1969
|
+
throw new ValidationException("Validation failed", this.parseValidationErrors(responseText));
|
|
1970
|
+
}
|
|
1971
|
+
if (!response.ok) {
|
|
1972
|
+
throw new HttpException(`HTTP error ${response.status}`, response.status, responseText);
|
|
1973
|
+
}
|
|
1974
|
+
return responseText;
|
|
1975
|
+
}
|
|
1976
|
+
parseValidationErrors(responseText) {
|
|
1977
|
+
try {
|
|
1978
|
+
const parsed = JSON.parse(responseText);
|
|
1979
|
+
if (parsed["errors"] !== null && typeof parsed["errors"] === "object" && !Array.isArray(parsed["errors"])) {
|
|
1980
|
+
return parsed["errors"];
|
|
1981
|
+
}
|
|
1982
|
+
} catch {
|
|
1983
|
+
}
|
|
1984
|
+
return {};
|
|
1985
|
+
}
|
|
1986
|
+
parseUsageHistory(value) {
|
|
1987
|
+
if (!Array.isArray(value)) return [];
|
|
1988
|
+
return value.filter((row) => typeof row === "object" && row !== null).map((row) => ({
|
|
1989
|
+
period: typeof row["period"] === "string" ? row["period"] : "",
|
|
1990
|
+
matches: typeof row["matches"] === "number" ? row["matches"] : 0,
|
|
1991
|
+
amount: typeof row["amount"] === "string" ? row["amount"] : "0.00",
|
|
1992
|
+
state: row["state"] === "billed" ? "billed" : "pending",
|
|
1993
|
+
billingType: typeof row["billingType"] === "string" ? row["billingType"] : null,
|
|
1994
|
+
manualReference: typeof row["manualReference"] === "string" ? row["manualReference"] : null
|
|
1995
|
+
}));
|
|
1996
|
+
}
|
|
1997
|
+
};
|
|
1998
|
+
|
|
226
1999
|
// src/enums/VatState.ts
|
|
227
2000
|
var VatState = {
|
|
228
2001
|
VALID: "valid",
|
|
@@ -233,14 +2006,14 @@ var VatState = {
|
|
|
233
2006
|
function getFailedVatStates() {
|
|
234
2007
|
return [VatState.INVALID, VatState.FRAUD];
|
|
235
2008
|
}
|
|
236
|
-
var
|
|
2009
|
+
var DESCRIPTIONS6 = {
|
|
237
2010
|
[VatState.VALID]: "The VAT number is valid and active.",
|
|
238
2011
|
[VatState.INVALID]: "The VAT number is invalid or not registered.",
|
|
239
2012
|
[VatState.FRAUD]: "The VAT number has been flagged as potentially fraudulent.",
|
|
240
2013
|
[VatState.UNKNOWN]: "The VAT number state could not be determined."
|
|
241
2014
|
};
|
|
242
2015
|
function describeVatState(state) {
|
|
243
|
-
return
|
|
2016
|
+
return DESCRIPTIONS6[state];
|
|
244
2017
|
}
|
|
245
2018
|
|
|
246
2019
|
// src/dto/CompanyAddress.ts
|
|
@@ -447,7 +2220,7 @@ var ProviderDocument = class _ProviderDocument {
|
|
|
447
2220
|
|
|
448
2221
|
// src/dto/VatResource.ts
|
|
449
2222
|
var VatResource = class _VatResource {
|
|
450
|
-
constructor(uuid, vatUid, state, countryCode, companyName, companyAddress, requestedCompanyName, requestedCompanyNameOriginal, requestedInputAddress, checkedAt, score, scoreSource, scoreAttempts, breakdown, environment, provider, usedProviders, providerVatState, providerNote, providerLastCheckedAt, hasApiError, errorMessage, nextApiRecheckAt, providerDocument) {
|
|
2223
|
+
constructor(uuid, vatUid, state, countryCode, companyName, companyAddress, requestedCompanyName, requestedCompanyNameOriginal, requestedInputAddress, checkedAt, score, scoreSource, scoreAttempts, breakdown, environment, provider, usedProviders, providerValid, providerVatState, providerNote, providerLastCheckedAt, hasApiError, errorMessage, nextApiRecheckAt, providerDocument) {
|
|
451
2224
|
this.uuid = uuid;
|
|
452
2225
|
this.vatUid = vatUid;
|
|
453
2226
|
this.state = state;
|
|
@@ -465,6 +2238,7 @@ var VatResource = class _VatResource {
|
|
|
465
2238
|
this.environment = environment;
|
|
466
2239
|
this.provider = provider;
|
|
467
2240
|
this.usedProviders = usedProviders;
|
|
2241
|
+
this.providerValid = providerValid;
|
|
468
2242
|
this.providerVatState = providerVatState;
|
|
469
2243
|
this.providerNote = providerNote;
|
|
470
2244
|
this.providerLastCheckedAt = providerLastCheckedAt;
|
|
@@ -490,6 +2264,7 @@ var VatResource = class _VatResource {
|
|
|
490
2264
|
environment;
|
|
491
2265
|
provider;
|
|
492
2266
|
usedProviders;
|
|
2267
|
+
providerValid;
|
|
493
2268
|
providerVatState;
|
|
494
2269
|
providerNote;
|
|
495
2270
|
providerLastCheckedAt;
|
|
@@ -509,6 +2284,7 @@ var VatResource = class _VatResource {
|
|
|
509
2284
|
const hasApiError = data["has_api_error"] === null ? null : typeof data["has_api_error"] === "boolean" ? data["has_api_error"] : void 0;
|
|
510
2285
|
const errorMessage = data["error_message"] === null ? null : typeof data["error_message"] === "string" ? data["error_message"] : void 0;
|
|
511
2286
|
const nextApiRecheckAt = data["next_api_recheck_at"] === null ? null : typeof data["next_api_recheck_at"] === "string" ? data["next_api_recheck_at"] : void 0;
|
|
2287
|
+
const providerValid = data["provider_valid"] === null ? null : typeof data["provider_valid"] === "boolean" ? data["provider_valid"] : void 0;
|
|
512
2288
|
const breakdown = Array.isArray(data["breakdown"]) ? data["breakdown"].map(ScoreBreakdown.fromArray) : void 0;
|
|
513
2289
|
const usedProviders = Array.isArray(data["used_providers"]) ? data["used_providers"].filter((v) => typeof v === "string") : void 0;
|
|
514
2290
|
const scoreAttempts = Array.isArray(data["score_attempts"]) ? data["score_attempts"] : void 0;
|
|
@@ -531,6 +2307,7 @@ var VatResource = class _VatResource {
|
|
|
531
2307
|
str("environment"),
|
|
532
2308
|
str("provider"),
|
|
533
2309
|
usedProviders,
|
|
2310
|
+
providerValid,
|
|
534
2311
|
str("provider_vat_state"),
|
|
535
2312
|
str("provider_note"),
|
|
536
2313
|
providerLastCheckedAt,
|
|
@@ -547,6 +2324,18 @@ var VatResource = class _VatResource {
|
|
|
547
2324
|
}
|
|
548
2325
|
return `https://app.sandbox.taxora.io/vat/history/${this.uuid}`;
|
|
549
2326
|
}
|
|
2327
|
+
isValid(useProviderState = false) {
|
|
2328
|
+
if (useProviderState) {
|
|
2329
|
+
return this.isProviderValid();
|
|
2330
|
+
}
|
|
2331
|
+
return this.state === VatState.VALID;
|
|
2332
|
+
}
|
|
2333
|
+
isProviderValid() {
|
|
2334
|
+
if (this.providerValid !== void 0 && this.providerValid !== null) {
|
|
2335
|
+
return this.providerValid;
|
|
2336
|
+
}
|
|
2337
|
+
return this.providerVatState === VatState.VALID;
|
|
2338
|
+
}
|
|
550
2339
|
toArray() {
|
|
551
2340
|
return {
|
|
552
2341
|
uuid: this.uuid,
|
|
@@ -566,6 +2355,7 @@ var VatResource = class _VatResource {
|
|
|
566
2355
|
environment: this.environment ?? null,
|
|
567
2356
|
provider: this.provider ?? null,
|
|
568
2357
|
used_providers: this.usedProviders ?? null,
|
|
2358
|
+
provider_valid: this.providerValid ?? null,
|
|
569
2359
|
provider_vat_state: this.providerVatState ?? null,
|
|
570
2360
|
provider_note: this.providerNote ?? null,
|
|
571
2361
|
provider_last_checked_at: this.providerLastCheckedAt?.toISOString() ?? null,
|
|
@@ -685,23 +2475,8 @@ var VatValidationAddressInput = class _VatValidationAddressInput {
|
|
|
685
2475
|
}
|
|
686
2476
|
};
|
|
687
2477
|
|
|
688
|
-
// src/exceptions/ValidationException.ts
|
|
689
|
-
var ValidationException = class extends TaxoraException {
|
|
690
|
-
statusCode = 422;
|
|
691
|
-
errors;
|
|
692
|
-
constructor(message, errors, context = {}) {
|
|
693
|
-
super(message, context);
|
|
694
|
-
this.name = "ValidationException";
|
|
695
|
-
this.errors = errors;
|
|
696
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
697
|
-
}
|
|
698
|
-
getErrors() {
|
|
699
|
-
return this.errors;
|
|
700
|
-
}
|
|
701
|
-
};
|
|
702
|
-
|
|
703
2478
|
// src/endpoints/VatEndpoint.ts
|
|
704
|
-
var
|
|
2479
|
+
var DATE_REGEX2 = /^\d{4}-\d{2}-\d{2}$/;
|
|
705
2480
|
var VatEndpoint = class {
|
|
706
2481
|
constructor(baseUrl, apiKey, tokenStorage, httpClient) {
|
|
707
2482
|
this.baseUrl = baseUrl;
|
|
@@ -866,7 +2641,7 @@ var VatEndpoint = class {
|
|
|
866
2641
|
const day = String(date.getDate()).padStart(2, "0");
|
|
867
2642
|
return `${year}-${month}-${day}`;
|
|
868
2643
|
}
|
|
869
|
-
if (!
|
|
2644
|
+
if (!DATE_REGEX2.test(date)) {
|
|
870
2645
|
throw new TaxoraException(`Invalid date format: "${date}". Expected YYYY-MM-DD.`);
|
|
871
2646
|
}
|
|
872
2647
|
return date;
|
|
@@ -949,21 +2724,47 @@ var AuthRetryHttpClient = class {
|
|
|
949
2724
|
}
|
|
950
2725
|
};
|
|
951
2726
|
|
|
2727
|
+
// src/version.ts
|
|
2728
|
+
var SDK_VERSION = "1.1.0";
|
|
2729
|
+
|
|
2730
|
+
// src/http/SdkVersionHttpClient.ts
|
|
2731
|
+
var SDK_VERSION_HEADER = "X-Taxora-SDK-Version";
|
|
2732
|
+
var SDK_VERSION_VALUE = `taxora-node/${SDK_VERSION}`;
|
|
2733
|
+
var SdkVersionHttpClient = class {
|
|
2734
|
+
constructor(inner) {
|
|
2735
|
+
this.inner = inner;
|
|
2736
|
+
}
|
|
2737
|
+
inner;
|
|
2738
|
+
async request(method, url, options) {
|
|
2739
|
+
const existing = options?.headers ?? {};
|
|
2740
|
+
const headers = {
|
|
2741
|
+
...existing,
|
|
2742
|
+
[SDK_VERSION_HEADER]: SDK_VERSION_VALUE
|
|
2743
|
+
};
|
|
2744
|
+
return this.inner.request(method, url, { ...options ?? {}, headers });
|
|
2745
|
+
}
|
|
2746
|
+
};
|
|
2747
|
+
|
|
952
2748
|
// src/client/TaxoraClient.ts
|
|
953
2749
|
var TaxoraClient = class {
|
|
954
2750
|
auth;
|
|
955
2751
|
vat;
|
|
956
2752
|
company;
|
|
2753
|
+
smartEnrichment;
|
|
2754
|
+
eReporting;
|
|
957
2755
|
baseUrl;
|
|
958
2756
|
constructor(options) {
|
|
959
2757
|
const environment = options.environment ?? Environment.SANDBOX;
|
|
960
2758
|
const tokenStorage = options.tokenStorage ?? new InMemoryTokenStorage();
|
|
961
2759
|
const httpClient = options.httpClient ?? new FetchHttpClient();
|
|
2760
|
+
const versionedClient = new SdkVersionHttpClient(httpClient);
|
|
962
2761
|
this.baseUrl = getBaseUrl(environment);
|
|
963
|
-
this.auth = new AuthEndpoint(this.baseUrl, options.apiKey, tokenStorage,
|
|
964
|
-
const retryClient = new AuthRetryHttpClient(
|
|
2762
|
+
this.auth = new AuthEndpoint(this.baseUrl, options.apiKey, tokenStorage, versionedClient);
|
|
2763
|
+
const retryClient = new AuthRetryHttpClient(versionedClient, tokenStorage, () => this.auth.refresh());
|
|
965
2764
|
this.vat = new VatEndpoint(this.baseUrl, options.apiKey, tokenStorage, retryClient);
|
|
966
2765
|
this.company = new CompanyEndpoint(this.baseUrl, options.apiKey, tokenStorage, retryClient);
|
|
2766
|
+
this.smartEnrichment = new SmartEnrichmentEndpoint(this.baseUrl, options.apiKey, tokenStorage, retryClient);
|
|
2767
|
+
this.eReporting = new EReportingEndpoint(this.baseUrl, options.apiKey, tokenStorage, retryClient);
|
|
967
2768
|
}
|
|
968
2769
|
};
|
|
969
2770
|
|
|
@@ -991,15 +2792,36 @@ export {
|
|
|
991
2792
|
AuthenticationException,
|
|
992
2793
|
CompanyAddress,
|
|
993
2794
|
CompanyEndpoint,
|
|
2795
|
+
ComplianceEnrollment,
|
|
2796
|
+
ComplianceEnrollmentPage,
|
|
2797
|
+
ComplianceEnrollmentStatus,
|
|
2798
|
+
ComplianceTaxReport,
|
|
2799
|
+
ComplianceTaxReportPage,
|
|
2800
|
+
ComplianceTaxReportState,
|
|
2801
|
+
ComplianceTransaction,
|
|
2802
|
+
ComplianceTransactionPage,
|
|
2803
|
+
ComplianceTransactionState,
|
|
2804
|
+
ComplianceTransactionType,
|
|
2805
|
+
EReportingEndpoint,
|
|
994
2806
|
Environment,
|
|
995
2807
|
FetchHttpClient,
|
|
996
2808
|
HttpException,
|
|
2809
|
+
ImportResult,
|
|
997
2810
|
InMemoryTokenStorage,
|
|
998
2811
|
Language,
|
|
999
2812
|
LoginIdentifier,
|
|
1000
2813
|
ProviderDocument,
|
|
1001
2814
|
ProviderDocumentLine,
|
|
2815
|
+
RevenueStatistics,
|
|
1002
2816
|
ScoreBreakdown,
|
|
2817
|
+
SireneLookupResult,
|
|
2818
|
+
SmartEnrichmentEndpoint,
|
|
2819
|
+
SmartEnrichmentHistoryPage,
|
|
2820
|
+
SmartEnrichmentHistoryRow,
|
|
2821
|
+
SmartEnrichmentJob,
|
|
2822
|
+
SmartEnrichmentResource,
|
|
2823
|
+
SmartEnrichmentStatistics,
|
|
2824
|
+
SmartEnrichmentStatus,
|
|
1003
2825
|
TaxoraClient,
|
|
1004
2826
|
TaxoraClientFactory,
|
|
1005
2827
|
TaxoraException,
|
|
@@ -1008,11 +2830,22 @@ export {
|
|
|
1008
2830
|
VatCertificateExport,
|
|
1009
2831
|
VatCollection,
|
|
1010
2832
|
VatEndpoint,
|
|
2833
|
+
VatRates,
|
|
1011
2834
|
VatResource,
|
|
1012
2835
|
VatState,
|
|
1013
2836
|
VatValidationAddressInput,
|
|
2837
|
+
describeComplianceEnrollmentStatus,
|
|
2838
|
+
describeComplianceTaxReportState,
|
|
2839
|
+
describeComplianceTransactionState,
|
|
2840
|
+
describeComplianceTransactionType,
|
|
2841
|
+
describeSmartEnrichmentStatus,
|
|
1014
2842
|
describeVatState,
|
|
1015
2843
|
getBaseUrl,
|
|
1016
|
-
getFailedVatStates
|
|
2844
|
+
getFailedVatStates,
|
|
2845
|
+
toComplianceEnrollmentStatus,
|
|
2846
|
+
toComplianceTaxReportState,
|
|
2847
|
+
toComplianceTransactionState,
|
|
2848
|
+
toComplianceTransactionType,
|
|
2849
|
+
toSmartEnrichmentStatus
|
|
1017
2850
|
};
|
|
1018
2851
|
//# sourceMappingURL=index.js.map
|