@facturino/node 1.1.0 → 2.0.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.
@@ -5,7 +5,7 @@ export interface FacturinoConfig {
5
5
  maxRetries?: number;
6
6
  /** Timeout in ms (default: 30000). */
7
7
  timeout?: number;
8
- /** API version header (default: "2026-03-01"). */
8
+ /** API version header (default: "2026-09-01"). */
9
9
  apiVersion?: string;
10
10
  }
11
11
  export interface RequestOptions {
@@ -162,7 +162,35 @@ export interface Invoice {
162
162
  id: string;
163
163
  object: 'invoice';
164
164
  type: InvoiceType;
165
+ /**
166
+ * One-word SUMMARY derived from the three axes below — never an authority of
167
+ * its own. Prefer the axes when you need to tell transmission from collection.
168
+ */
165
169
  status: InvoiceStatus;
170
+ /** Documentary axis: is the invoice a draft, finalized, or cancelled? */
171
+ documentStatus?: DocumentStatus;
172
+ /** Transmission axis: where the invoice stands with the platform. */
173
+ transmissionStatus?: TransmissionStatus;
174
+ /** DGFiP detail inside `transmitted` / `rejected`. */
175
+ transmissionDetail?: TransmissionDetail;
176
+ /** Collection axis: what has actually been paid. */
177
+ paymentStatus?: PaymentStatus;
178
+ /** Fiscal source of the backing decision; `null` while a commercial draft has none. */
179
+ taxSource?: TaxSource | null;
180
+ /** The decision this invoice is backed by, when it has one. */
181
+ taxDecisionId?: string;
182
+ /** The frozen fiscal position, copied from the decision. */
183
+ taxSnapshot?: TaxSnapshot;
184
+ /**
185
+ * The operation a COMMERCIAL draft states, before any decision — typically a
186
+ * draft produced by `quotes.convert()`. Present only while `taxSource` is
187
+ * `null`; it disappears the moment the invoice is bound to a decision.
188
+ *
189
+ * Read its lines to build the decision that fiscalises this draft: the line
190
+ * references are assigned server-side at conversion, and the decision must
191
+ * state exactly the operation the draft carries.
192
+ */
193
+ commercialDraft?: CommercialDraft | null;
166
194
  number: string | null;
167
195
  currency: Currency;
168
196
  customer: CustomerRef;
@@ -222,18 +250,26 @@ export interface InvoiceScheduleParam {
222
250
  dueDate: string;
223
251
  label?: string;
224
252
  }
225
- export interface InvoiceCreateParams {
253
+ /** Fields every invoice creation carries alongside its decision. */
254
+ export interface InvoiceCreateBaseParams {
226
255
  customerId: string;
227
256
  type?: InvoiceType;
228
- lines: InvoiceLineItemParam[];
229
257
  buyer: InvoiceBuyerParam;
230
258
  dates: InvoiceCreateDates;
231
259
  payment: InvoicePaymentTerms;
232
260
  notes?: string;
233
261
  purchaseOrderNumber?: string;
234
- /** Deposit invoices to deduct from the amount due (CGI art. 289). Max 20. */
262
+ /**
263
+ * Fully paid deposit invoices to deduct (CGI art. 289). The decided
264
+ * `amountToCharge` is untouched: deposits seed `amountPaid` (BT-113) and
265
+ * lower `amountDue` (BT-115), settled server-side in the creation
266
+ * transaction. Max 20.
267
+ */
235
268
  deposits?: InvoiceDepositParam[];
236
- /** Payment schedule (2 to 12 instalments) summing to the total. */
269
+ /**
270
+ * Payment schedule (2 to 12 instalments). It must distribute EXACTLY the
271
+ * decided amount due — it never modifies the total.
272
+ */
237
273
  schedule?: InvoiceScheduleParam[];
238
274
  metadata?: Record<string, unknown>;
239
275
  /** Finalize the invoice in the same call (assigns its number). */
@@ -247,6 +283,34 @@ export interface InvoiceCreateParams {
247
283
  pa?: boolean;
248
284
  };
249
285
  }
286
+ /**
287
+ * Creating an invoice — ALWAYS backed by a FINAL tax decision, whatever its
288
+ * fiscal source (`facturino` or `integration`). The decided VAT, amounts and
289
+ * legal mentions are copied verbatim and frozen; `decisionLines` carries
290
+ * presentation only (unit, catalogue product), matched by `taxLineRef`. A
291
+ * final decision backs exactly ONE invoice.
292
+ */
293
+ export interface InvoiceCreateParams extends InvoiceCreateBaseParams {
294
+ taxDecisionId: string;
295
+ decisionLines: DecisionBackedLineParam[];
296
+ }
297
+ /**
298
+ * Binding a FINAL decision to a commercial draft that already exists — the
299
+ * draft produced by converting a quote.
300
+ *
301
+ * The same two fields the direct creation carries, and only those: the decision
302
+ * states the whole fiscal content, and the draft already states the buyer, the
303
+ * dates and the payment terms.
304
+ */
305
+ export interface InvoiceBindTaxDecisionParams {
306
+ taxDecisionId: string;
307
+ decisionLines: DecisionBackedLineParam[];
308
+ }
309
+ /**
310
+ * A COMMERCIAL line with an indicative VAT — used by quotes only. A quote is a
311
+ * commercial document; converting it to an invoice goes through a tax decision,
312
+ * which re-decides (or re-validates) the VAT.
313
+ */
250
314
  export interface InvoiceLineItemParam {
251
315
  description: string;
252
316
  quantity: string;
@@ -260,17 +324,16 @@ export interface InvoiceLineItemParam {
260
324
  discountPercent?: number;
261
325
  product?: string | null;
262
326
  }
327
+ /**
328
+ * Patching a draft. The fiscal content (lines, buyer, deposits, schedule) is
329
+ * frozen by the decision: only non-fiscal fields are patchable, and `dates` is
330
+ * restricted to the due date server-side.
331
+ */
263
332
  export interface InvoiceUpdateParams {
264
- buyer?: InvoiceBuyerParam;
265
- lines?: InvoiceLineItemParam[];
266
333
  dates?: Partial<InvoiceCreateDates>;
267
334
  payment?: Partial<InvoicePaymentTerms>;
268
335
  notes?: string;
269
336
  purchaseOrderNumber?: string;
270
- /** Replace the linked deposit invoices; an empty array unlinks them. */
271
- deposits?: InvoiceDepositParam[];
272
- /** Replace the payment schedule. */
273
- schedule?: InvoiceScheduleParam[];
274
337
  metadata?: Record<string, unknown>;
275
338
  }
276
339
  export interface InvoiceListParams extends PaginationParams {
@@ -586,7 +649,26 @@ export interface CreditNote {
586
649
  object: 'credit_note';
587
650
  customer: CustomerRef;
588
651
  relatedInvoiceId: string;
652
+ /**
653
+ * One-word SUMMARY derived from the three axes below — never an authority of
654
+ * its own. Prefer the axes when you need to tell transmission from collection.
655
+ */
589
656
  status: CreditNoteStatus;
657
+ /** Documentary axis. */
658
+ documentStatus?: DocumentStatus;
659
+ /** Transmission axis. */
660
+ transmissionStatus?: TransmissionStatus;
661
+ transmissionDetail?: TransmissionDetail;
662
+ /** Collection axis — a credit note follows the refund, not the invoice. */
663
+ paymentStatus?: PaymentStatus;
664
+ /** Where this credit note's VAT comes from. */
665
+ taxSource?: TaxSource;
666
+ /** The invoice this credit note credits. */
667
+ originalInvoiceId?: string;
668
+ /** The decision the credited invoice was backed by; the credit note inherits it. */
669
+ originalTaxDecisionId?: string;
670
+ /** The frozen fiscal position, inherited from the credited invoice. */
671
+ taxSnapshot?: TaxSnapshot;
590
672
  creditNoteType: CreditNoteType;
591
673
  number: string | null;
592
674
  currency: Currency;
@@ -618,21 +700,48 @@ export interface CreditNote {
618
700
  created: string;
619
701
  updated: string;
620
702
  }
621
- export interface CreditNoteCreateParams {
622
- customerId: string;
703
+ /**
704
+ * One credited line of a decision-backed invoice.
705
+ *
706
+ * State EITHER a `quantity` or an `amountTTC`, never both: they are two ways of
707
+ * saying how much of the line is credited, and stating both would state two
708
+ * different amounts. Omit both to credit the whole remaining balance of the line.
709
+ */
710
+ export interface CreditedLineParam {
711
+ /** Reference of the decided line being credited. */
712
+ taxLineRef: string;
713
+ /** Credited quantity, as a decimal string. Mutually exclusive with `amountTTC`. */
714
+ quantity?: string;
715
+ /** Credited amount in integer cents. Mutually exclusive with `quantity`. */
716
+ amountTTC?: number;
717
+ }
718
+ /** Fields every credit-note creation carries. */
719
+ export interface CreditNoteCreateBaseParams {
720
+ customerId?: string;
623
721
  relatedInvoiceId: string;
624
722
  creditNoteType: CreditNoteType;
625
723
  reasonCode: CreditNoteReasonCode;
626
724
  reason?: string;
627
- items: InvoiceLineItemParam[];
628
725
  dates?: {
629
726
  issued: string;
630
727
  };
631
728
  notes?: string;
632
729
  metadata?: Record<string, unknown>;
633
730
  }
731
+ /**
732
+ * Crediting an invoice.
733
+ *
734
+ * A credit note inherits the fiscal position of the invoice it corrects —
735
+ * source, snapshot and lines. The rate, the category, the VATEX code and the
736
+ * legal mention come from the frozen snapshot; `creditedLines` states WHICH
737
+ * original lines are credited and how much of each, nothing more.
738
+ */
739
+ export interface CreditNoteCreateParams extends CreditNoteCreateBaseParams {
740
+ creditedLines: CreditedLineParam[];
741
+ }
742
+ /** Updating a draft credit note. */
634
743
  export interface CreditNoteUpdateParams {
635
- items?: InvoiceLineItemParam[];
744
+ creditedLines?: CreditedLineParam[];
636
745
  reason?: string;
637
746
  notes?: string;
638
747
  metadata?: Record<string, unknown>;
@@ -715,6 +824,36 @@ export interface RecurringInvoice {
715
824
  created: string;
716
825
  updated: string;
717
826
  }
827
+ /**
828
+ * A commercial line of a decision-backed recurrence.
829
+ *
830
+ * It carries its own presentation because a recurrence stores no decision: each
831
+ * occurrence is decided on ITS OWN effective date, so a stored decision would
832
+ * apply last quarter's rules to this quarter's invoice.
833
+ */
834
+ export interface RecurringTaxLineParam extends TaxDecisionLineParam {
835
+ unit: Unit;
836
+ product?: string | null;
837
+ }
838
+ /** Integration line of a recurrence: supplied VAT, re-validated at EVERY occurrence. */
839
+ export interface RecurringIntegrationTaxLineParam extends IntegrationTaxDecisionLineParam {
840
+ unit: Unit;
841
+ product?: string | null;
842
+ }
843
+ /**
844
+ * Fiscal inputs of the per-occurrence decisions. The recurrence keeps ONE
845
+ * fiscal source for its whole life; each occurrence takes a NEW decision under
846
+ * it, on its own effective date.
847
+ */
848
+ export type RecurringTaxInputsParam = {
849
+ taxSource: 'facturino';
850
+ priceMode: PriceMode;
851
+ lines: RecurringTaxLineParam[];
852
+ } | {
853
+ taxSource: 'integration';
854
+ priceMode: PriceMode;
855
+ lines: RecurringIntegrationTaxLineParam[];
856
+ };
718
857
  export interface RecurringInvoiceCreateParams {
719
858
  customerId: string;
720
859
  frequency: RecurringFrequency;
@@ -722,8 +861,13 @@ export interface RecurringInvoiceCreateParams {
722
861
  nextGenerationDate: string;
723
862
  endDate?: string;
724
863
  customIntervalDays?: number;
864
+ /**
865
+ * Commercial inputs of the per-occurrence decisions. Required: an
866
+ * occurrence that cannot be decided generates no invoice.
867
+ */
868
+ taxInputs: RecurringTaxInputsParam;
869
+ /** Presentation and terms of the generated invoices — never a line. */
725
870
  templateInvoice: {
726
- items: InvoiceLineItemParam[];
727
871
  notes?: string;
728
872
  paymentMethod?: PaymentMethod;
729
873
  paymentTermsDays?: number;
@@ -732,12 +876,13 @@ export interface RecurringInvoiceCreateParams {
732
876
  autoSend?: boolean;
733
877
  }
734
878
  export interface RecurringInvoiceUpdateParams {
879
+ /** Replaces the fiscal inputs (same fiscal source for the recurrence's life). */
880
+ taxInputs?: RecurringTaxInputsParam;
735
881
  frequency?: RecurringFrequency;
736
882
  nextGenerationDate?: string;
737
883
  endDate?: string;
738
884
  customIntervalDays?: number;
739
885
  templateInvoice?: {
740
- items?: InvoiceLineItemParam[];
741
886
  notes?: string;
742
887
  paymentMethod?: PaymentMethod;
743
888
  paymentTermsDays?: number;
@@ -786,7 +931,7 @@ export interface Company {
786
931
  phone?: string;
787
932
  website?: string;
788
933
  logoPath?: string;
789
- vatRegime: 'normal' | 'franchise' | 'simplified' | 'debit';
934
+ vatRegime: 'normal' | 'normal_quarterly' | 'franchise' | 'simplified' | 'debit';
790
935
  billingEmail?: string;
791
936
  bankDetails: BankDetails;
792
937
  defaultPaymentTerms: number;
@@ -804,7 +949,7 @@ export interface CompanyUpdateParams {
804
949
  email?: string;
805
950
  phone?: string;
806
951
  website?: string;
807
- vatRegime?: 'normal' | 'franchise' | 'simplified' | 'debit';
952
+ vatRegime?: 'normal' | 'normal_quarterly' | 'franchise' | 'simplified' | 'debit';
808
953
  billingEmail?: string;
809
954
  bankDetails?: BankDetails;
810
955
  defaultPaymentTerms?: number;
@@ -1061,7 +1206,7 @@ export interface BillingSubscription {
1061
1206
  currentPeriodEnd: string;
1062
1207
  cancelAtPeriodEnd: boolean;
1063
1208
  }
1064
- /** Subscription (platform) invoice issued by INTEK CENTER to the Facturino account. */
1209
+ /** Subscription (platform) invoice issued to this account. */
1065
1210
  export interface PlatformInvoice {
1066
1211
  object: 'platform_invoice';
1067
1212
  id: string;
@@ -1176,3 +1321,385 @@ export interface HealthStatus {
1176
1321
  region: string;
1177
1322
  timestamp: string;
1178
1323
  }
1324
+ /**
1325
+ * Whether the amounts you send include VAT.
1326
+ *
1327
+ * `tax_exclusive`: VAT is added to your unit amounts.
1328
+ * `tax_inclusive`: VAT is extracted from them.
1329
+ */
1330
+ export type PriceMode = 'tax_exclusive' | 'tax_inclusive';
1331
+ /**
1332
+ * Fiscal nature of a line.
1333
+ *
1334
+ * `electronically_supplied_services` carries its own place-of-supply rules and
1335
+ * is not the same as an ordinary service. `deposit` and `ancillary_costs`
1336
+ * follow the principal supply, which they must name via `relatedCategory`.
1337
+ */
1338
+ /**
1339
+ * One line of a commercial draft: the operation as stated, with NO VAT.
1340
+ *
1341
+ * `unitPrice` is in integer cents, in the draft's `priceMode`; `quantity` is a
1342
+ * decimal string. `rateCategory` is the band the seller asks for — the decision
1343
+ * concludes the actual rate.
1344
+ */
1345
+ export interface CommercialDraftLine {
1346
+ /** Stable reference, assigned server-side; the decision reuses it. */
1347
+ reference: string;
1348
+ description: string;
1349
+ quantity: string;
1350
+ unit: Unit;
1351
+ unitPrice: number;
1352
+ supplyCategory: SupplyCategory;
1353
+ rateCategory: RateCategory;
1354
+ discount?: TaxDecisionDiscount;
1355
+ product?: string | null;
1356
+ }
1357
+ /**
1358
+ * The operation an undecided draft states. Its total is COMMERCIAL: neither a
1359
+ * decided net nor a decided gross amount, because nothing has been decided yet.
1360
+ */
1361
+ export interface CommercialDraft {
1362
+ priceMode: PriceMode;
1363
+ lines: CommercialDraftLine[];
1364
+ totalCents: number;
1365
+ }
1366
+ export type SupplyCategory = 'goods' | 'services' | 'electronically_supplied_services' | 'deposit' | 'ancillary_costs';
1367
+ /** Principal supply a deposit or an ancillary cost follows. */
1368
+ export type PrimarySupplyCategory = 'goods' | 'services' | 'electronically_supplied_services';
1369
+ /** Rate band requested. The engine decides whether it actually applies. */
1370
+ export type RateCategory = 'standard' | 'intermediate' | 'reduced' | 'super_reduced' | 'specific';
1371
+ /** Where the goods physically go. Relevant to cross-border supplies of goods. */
1372
+ export type GoodsMovement = 'stays_in_seller_territory' | 'dispatched_to_buyer_territory' | 'unknown';
1373
+ /**
1374
+ * Only `final` carries amounts.
1375
+ *
1376
+ * On any other status `totals` and `amountToCharge` are `null`, never `0`:
1377
+ * absent is not "nothing to charge".
1378
+ */
1379
+ export type TaxDecisionStatus = 'final' | 'pending_verification' | 'unsupported';
1380
+ /** Explicit discount. `percent` in centi-percent (2500 = 25.00 %), `amount` in integer cents. */
1381
+ export interface TaxDecisionDiscount {
1382
+ type: 'percent' | 'amount';
1383
+ value: number;
1384
+ }
1385
+ export interface TaxDecisionLineParam {
1386
+ /** Stable caller-side reference, echoed on the decided line. */
1387
+ reference: string;
1388
+ description: string;
1389
+ category: SupplyCategory;
1390
+ /** Required when `category` is `deposit` or `ancillary_costs`. */
1391
+ relatedCategory?: PrimarySupplyCategory;
1392
+ rateCategory: RateCategory;
1393
+ /** Only `general` is implemented; anything else is reported as unsupported. */
1394
+ placeOfSupplyRule?: string;
1395
+ goodsMovement?: GoodsMovement;
1396
+ /** Unit amount in integer cents, in the request's `priceMode`. */
1397
+ unitAmount: number;
1398
+ /** Decimal quantity sent as a STRING, never a float. Up to 6 decimals. */
1399
+ quantity: string;
1400
+ discount?: TaxDecisionDiscount;
1401
+ }
1402
+ /** Kind of location signal (Implementing Regulation (EU) 282/2011). */
1403
+ export type LocationEvidenceKind = 'billing_address' | 'ip_geolocation' | 'bank_details' | 'sim_mobile_country' | 'fixed_line' | 'other_commercial';
1404
+ /** Who supplied the signal. */
1405
+ export type EvidenceSource = 'psp' | 'network' | 'bank' | 'declared' | 'other';
1406
+ /**
1407
+ * One piece of location evidence.
1408
+ *
1409
+ * Send the territorial SIGNAL, never the raw one: a country — and a postal code
1410
+ * where the territory needs one — not an IP address, a PSP payload or bank
1411
+ * account details. `reference` is a bounded opaque identifier (a PSP charge id,
1412
+ * a geolocation batch id), not the signal itself.
1413
+ */
1414
+ export interface LocationEvidenceParam {
1415
+ kind: LocationEvidenceKind;
1416
+ /** ISO 3166-1 alpha-2. */
1417
+ country: string;
1418
+ postalCode?: string;
1419
+ /** Is the evidence from a party independent of both seller and buyer? */
1420
+ thirdParty: boolean;
1421
+ source: EvidenceSource;
1422
+ /** Civil date `YYYY-MM-DD`. */
1423
+ collectedAt: string;
1424
+ reference?: string;
1425
+ }
1426
+ /** Non-EU business-status evidence (282/2011 art. 18-3). */
1427
+ export interface NonEuBusinessEvidenceParam {
1428
+ kind: 'tax_authority_certificate' | 'vat_or_similar_number' | 'other_commercial_evidence';
1429
+ reference: string;
1430
+ /** ISO 3166-1 alpha-2. */
1431
+ issuedByCountry: string;
1432
+ issuedByPostalCode?: string;
1433
+ reasonableVerificationPerformed: boolean;
1434
+ collectedAt: string;
1435
+ }
1436
+ interface TaxDecisionCreateBaseParams {
1437
+ customerId: string;
1438
+ /** Civil date `YYYY-MM-DD`. A timestamp is refused: the timezone call is yours. */
1439
+ effectiveAt: string;
1440
+ /** `eur` only in this ruleset. Any other currency is refused, never converted. */
1441
+ currency: string;
1442
+ priceMode: PriceMode;
1443
+ locationEvidence?: LocationEvidenceParam[];
1444
+ nonEuBusinessEvidence?: NonEuBusinessEvidenceParam;
1445
+ /**
1446
+ * Previous decision this one retries after supplying the missing facts. The
1447
+ * commercial operation must be identical; only the evidence may change.
1448
+ */
1449
+ retryOfTaxDecisionId?: string;
1450
+ }
1451
+ /**
1452
+ * `taxSource: 'facturino'` — the VAT is DETERMINED by Facturino. You describe
1453
+ * the operation; the rate, the category, the VATEX code, the legal mentions,
1454
+ * the amounts and the three reporting axes are decided server-side.
1455
+ */
1456
+ export interface FacturinoTaxDecisionCreateParams extends TaxDecisionCreateBaseParams {
1457
+ taxSource: 'facturino';
1458
+ lines: TaxDecisionLineParam[];
1459
+ }
1460
+ /**
1461
+ * Line of an INTEGRATION decision: the same commercial data plus the VAT your
1462
+ * own engine concluded. Facturino validates the coherence of rate/category/
1463
+ * VATEX and refuses any detectable contradiction (`integration_vat_incoherent`)
1464
+ * — it never silently corrects a supplied rate.
1465
+ */
1466
+ export interface IntegrationTaxDecisionLineParam {
1467
+ /** Stable caller-side reference, echoed on the decided line. */
1468
+ reference: string;
1469
+ description: string;
1470
+ category: SupplyCategory;
1471
+ /** Required when `category` is `deposit` or `ancillary_costs`. */
1472
+ relatedCategory?: PrimarySupplyCategory;
1473
+ /** Unit amount in integer cents, in the request's `priceMode`. */
1474
+ unitAmount: number;
1475
+ /** Decimal quantity sent as a STRING, never a float. Up to 6 decimals. */
1476
+ quantity: string;
1477
+ discount?: TaxDecisionDiscount;
1478
+ /** Supplied VAT rate in centipercent (2000 = 20.00 %). Never corrected. */
1479
+ vatRate: number;
1480
+ /** Supplied EN 16931 category code (BT-151). */
1481
+ vatCode: VatCode;
1482
+ /** VATEX code (BT-121). Required for E/AE/K/G/O; refused for S/Z. */
1483
+ vatexCode?: string;
1484
+ /** Declared place of supply (canonical territory id, e.g. `FR-MET`, `DE`). */
1485
+ placeOfSupply?: string;
1486
+ }
1487
+ /**
1488
+ * `taxSource: 'integration'` — the VAT is SUPPLIED by the integration and
1489
+ * validated for coherence. The amounts, the legal mentions and the three
1490
+ * reporting axes are still decided server-side, by the same engines.
1491
+ */
1492
+ export interface IntegrationTaxDecisionCreateParams extends TaxDecisionCreateBaseParams {
1493
+ taxSource: 'integration';
1494
+ lines: IntegrationTaxDecisionLineParam[];
1495
+ }
1496
+ /** The two fiscal journeys of the stable contract — `taxSource` is required. */
1497
+ export type TaxDecisionCreateParams = FacturinoTaxDecisionCreateParams | IntegrationTaxDecisionCreateParams;
1498
+ /** VIES consultation outcome. The status is kept, never the raw response. */
1499
+ export interface ViesResult {
1500
+ status: 'valid' | 'invalid' | 'unavailable' | 'invalid_format';
1501
+ checkedAt: string | null;
1502
+ normalizedVatNumber: string | null;
1503
+ source: 'vies';
1504
+ returnedName: string | null;
1505
+ consultationNumber: string | null;
1506
+ }
1507
+ /** Normalized territorial evidence kept with the decision. No raw signal is exposed. */
1508
+ export interface LocationEvidenceResult {
1509
+ kind: LocationEvidenceKind;
1510
+ territoryId: string;
1511
+ declaredCountry: string;
1512
+ declaredPostalCode: string | null;
1513
+ thirdParty: boolean;
1514
+ source: EvidenceSource;
1515
+ collectedAt: string;
1516
+ reference: string | null;
1517
+ }
1518
+ export interface NonEuBusinessEvidenceResult {
1519
+ kind: 'tax_authority_certificate' | 'vat_or_similar_number' | 'other_commercial_evidence';
1520
+ reference: string;
1521
+ issuedByTerritoryId: string;
1522
+ reasonableVerificationPerformed: boolean;
1523
+ collectedAt: string;
1524
+ }
1525
+ /** One decided line. Amounts in integer cents. */
1526
+ export interface TaxDecisionLine {
1527
+ reference: string;
1528
+ description: string;
1529
+ category: SupplyCategory;
1530
+ relatedCategory: PrimarySupplyCategory | null;
1531
+ effectiveCategory: string | null;
1532
+ quantity: string;
1533
+ unitAmount: number;
1534
+ discount: TaxDecisionDiscount | null;
1535
+ /** Requested rate band. `null` on an integration line: the exact rate was supplied. */
1536
+ rateCategory: RateCategory | null;
1537
+ placeOfSupplyRule: string | null;
1538
+ goodsMovement: GoodsMovement | null;
1539
+ treatment: string | null;
1540
+ vatCategoryCode: string | null;
1541
+ vatexCode: string | null;
1542
+ legalMention: string | null;
1543
+ rateCentipercent: number | null;
1544
+ rateBasis: string | null;
1545
+ placeOfSupply: string | null;
1546
+ placeOfSupplyReference: string | null;
1547
+ treatmentReference: string | null;
1548
+ amountHT: number | null;
1549
+ amountVAT: number | null;
1550
+ amountTTC: number | null;
1551
+ invoiceChannel: InvoiceChannel | null;
1552
+ transactionReporting: TransactionReporting | null;
1553
+ paymentReporting: PaymentReporting | null;
1554
+ }
1555
+ /** Whether the invoice travels the e-invoicing network. */
1556
+ export type InvoiceChannel = 'einvoicing' | 'none';
1557
+ /** Whether the transaction itself must be reported. */
1558
+ export type TransactionReporting = 'ereporting' | 'none' | 'outside_scope';
1559
+ /** Whether and how the collection must be reported. */
1560
+ export type PaymentReporting = 'fr212' | 'ereporting' | 'none';
1561
+ /** Buyer identity and qualification, frozen when the decision was taken. */
1562
+ export interface TaxDecisionCustomer {
1563
+ customerId: string;
1564
+ name: string;
1565
+ nature: 'business' | 'consumer';
1566
+ natureBasis: string;
1567
+ territoryId: string;
1568
+ territoryKind: string;
1569
+ declaredCountry: string;
1570
+ declaredPostalCode: string | null;
1571
+ legalRegistrationId: string | null;
1572
+ vatNumber: string | null;
1573
+ crossBorderTaxableStatus: string;
1574
+ businessStatusBasis: string;
1575
+ }
1576
+ /** Why an axis carries the obligation it does. */
1577
+ export interface TaxDecisionObligationReason {
1578
+ axis: 'invoiceChannel' | 'transactionReporting' | 'paymentReporting';
1579
+ code: string;
1580
+ reference: string;
1581
+ message: string;
1582
+ }
1583
+ /** What is missing, on a decision that is not final. */
1584
+ export interface TaxDecisionIssue {
1585
+ code: string;
1586
+ message: string;
1587
+ }
1588
+ export interface TaxDecisionVatBreakdownEntry {
1589
+ rateCentipercent: number;
1590
+ categoryCode: string;
1591
+ vatexCode: string | null;
1592
+ base: number;
1593
+ amount: number;
1594
+ }
1595
+ /**
1596
+ * An immutable fiscal position.
1597
+ *
1598
+ * It fixes the VAT, the exact amount to charge and the three reporting axes for
1599
+ * ONE commercial operation, then never changes. A decision is never modified or
1600
+ * deleted — request a new one, optionally with `retryOfTaxDecisionId`.
1601
+ */
1602
+ export interface TaxDecision {
1603
+ id: string;
1604
+ object: 'tax_decision';
1605
+ companyId: string;
1606
+ /** Fiscal source of the decision — `facturino` or `integration`. */
1607
+ taxSource: TaxSource;
1608
+ status: TaxDecisionStatus;
1609
+ customerId: string;
1610
+ customer: TaxDecisionCustomer;
1611
+ sellerProfileId: string;
1612
+ sellerProfileRevision: number;
1613
+ sellerProfile: Record<string, unknown>;
1614
+ currency: string;
1615
+ priceMode: PriceMode;
1616
+ effectiveAt: string;
1617
+ decidedAt: string;
1618
+ /** Past this instant the decision may no longer open a payment. It stays readable. */
1619
+ expiresAt: string;
1620
+ checkoutValidityPolicy: 'checkout-validity-v1';
1621
+ /** Derived from the server clock at read time, never stored. */
1622
+ expired: boolean;
1623
+ rulesVersion: string;
1624
+ reportingCalendar: string;
1625
+ roundingPolicy: string;
1626
+ /** SHA-256 of the canonical request. Never the raw idempotency key. */
1627
+ requestFingerprint: string;
1628
+ /** SHA-256 of the commercial operation, used to control retries. */
1629
+ operationFingerprint: string;
1630
+ lines: TaxDecisionLine[];
1631
+ /** `null` on any status other than `final`. */
1632
+ totals: {
1633
+ totalHT: number;
1634
+ totalVAT: number;
1635
+ totalTTC: number;
1636
+ } | null;
1637
+ vatBreakdown: TaxDecisionVatBreakdownEntry[];
1638
+ /** Exact amount to charge, in integer cents. `null` unless the decision is final. */
1639
+ amountToCharge: number | null;
1640
+ invoiceChannel: InvoiceChannel | null;
1641
+ transactionReporting: TransactionReporting | null;
1642
+ paymentReporting: PaymentReporting | null;
1643
+ /**
1644
+ * A foreign tax may apply. Facturino decides French VAT and the matching
1645
+ * French obligations; this case must be reviewed outside Facturino.
1646
+ */
1647
+ foreignTaxReviewRequired: boolean;
1648
+ vies: ViesResult | null;
1649
+ locationEvidence: LocationEvidenceResult[];
1650
+ nonEuBusinessEvidence: NonEuBusinessEvidenceResult | null;
1651
+ issues: TaxDecisionIssue[];
1652
+ obligationReasons: TaxDecisionObligationReason[];
1653
+ retryOfTaxDecisionId: string | null;
1654
+ livemode: boolean;
1655
+ created: string;
1656
+ updated: string;
1657
+ }
1658
+ /**
1659
+ * Where a document's VAT comes from — the two equal journeys of the stable
1660
+ * contract. `facturino`: the VAT was determined by the Facturino engines.
1661
+ * `integration`: the VAT was supplied by the integration and validated for
1662
+ * coherence — never silently corrected. A commercial draft created from the
1663
+ * app reads `taxSource: null` until its decision is taken.
1664
+ */
1665
+ export type TaxSource = 'facturino' | 'integration';
1666
+ /** Documentary axis. */
1667
+ export type DocumentStatus = 'draft' | 'finalized' | 'cancelled';
1668
+ /** Transmission axis. A collection never moves it. */
1669
+ export type TransmissionStatus = 'not_applicable' | 'pending' | 'sending' | 'deposited' | 'transmitted' | 'approved' | 'rejected';
1670
+ /** DGFiP detail inside `transmitted` / `rejected`. */
1671
+ export type TransmissionDetail = 'available' | 'received' | 'suspended' | 'refused' | null;
1672
+ /** Collection axis. A refund does not erase the collection that happened. */
1673
+ export type PaymentStatus = 'unpaid' | 'partially_paid' | 'paid' | 'partially_refunded' | 'refunded';
1674
+ /**
1675
+ * A presentation-only line of a decision-backed document.
1676
+ *
1677
+ * It carries no VAT: the rate, the category, the VATEX code and the legal
1678
+ * mention all come from the decision line it references.
1679
+ */
1680
+ export interface DecisionBackedLineParam {
1681
+ /** Reference of the decided line this document line renders. */
1682
+ taxLineRef: string;
1683
+ unit: Unit;
1684
+ product?: string | null;
1685
+ }
1686
+ /** The frozen fiscal position copied onto a document. */
1687
+ export interface TaxSnapshot {
1688
+ taxDecisionId: string;
1689
+ /** Fiscal source of the decision, frozen with it. */
1690
+ taxSource?: TaxSource;
1691
+ priceMode: PriceMode;
1692
+ currency: string;
1693
+ rulesVersion?: string;
1694
+ reportingCalendar?: string;
1695
+ effectiveAt?: string;
1696
+ invoiceChannel?: InvoiceChannel | null;
1697
+ transactionReporting?: TransactionReporting | null;
1698
+ paymentReporting?: PaymentReporting | null;
1699
+ amountToChargeCents?: number;
1700
+ legalMentions?: string[];
1701
+ lines?: Array<Record<string, unknown>>;
1702
+ totals?: Record<string, number>;
1703
+ vatBreakdown?: Array<Record<string, unknown>>;
1704
+ }
1705
+ export {};
@@ -1,5 +1,5 @@
1
1
  import type { FacturinoConfig, RequestOptions } from './types.js';
2
- export declare const VERSION = "1.1.0";
2
+ export declare const VERSION = "2.0.0";
3
3
  /** HTTP client with retries, exponential backoff, and structured errors. */
4
4
  export declare class HttpClient {
5
5
  private readonly apiKey;