@facturino/node 1.2.0 → 2.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 +554 -22
- package/dist/cjs/client.d.ts +1 -1
- package/dist/cjs/client.js +2 -2
- package/dist/cjs/index.d.ts +6 -1
- package/dist/cjs/index.js +4 -0
- package/dist/cjs/resources/euThresholdLedgers.d.ts +98 -0
- package/dist/cjs/resources/euThresholdLedgers.js +129 -0
- package/dist/cjs/resources/invoices.d.ts +31 -1
- package/dist/cjs/resources/invoices.js +51 -0
- package/dist/cjs/resources/taxDecisions.d.ts +31 -0
- package/dist/cjs/resources/taxDecisions.js +63 -0
- package/dist/cjs/types.d.ts +985 -18
- package/dist/esm/client.d.ts +1 -1
- package/dist/esm/client.js +2 -2
- package/dist/esm/index.d.ts +6 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/resources/euThresholdLedgers.d.ts +99 -0
- package/dist/esm/resources/euThresholdLedgers.d.ts.map +1 -0
- package/dist/esm/resources/euThresholdLedgers.js +126 -0
- package/dist/esm/resources/euThresholdLedgers.js.map +1 -0
- package/dist/esm/resources/invoices.d.ts +31 -1
- package/dist/esm/resources/invoices.d.ts.map +1 -1
- package/dist/esm/resources/invoices.js +51 -0
- package/dist/esm/resources/invoices.js.map +1 -1
- package/dist/esm/resources/taxDecisions.d.ts +32 -0
- package/dist/esm/resources/taxDecisions.d.ts.map +1 -0
- package/dist/esm/resources/taxDecisions.js +60 -0
- package/dist/esm/resources/taxDecisions.js.map +1 -0
- package/dist/esm/types.d.ts +985 -18
- package/dist/esm/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/esm/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FacturinoConfig, RequestOptions } from './types.js';
|
|
2
|
-
export declare const VERSION = "1.
|
|
2
|
+
export declare const VERSION = "2.1.0";
|
|
3
3
|
/** HTTP client with retries, exponential backoff, and structured errors. */
|
|
4
4
|
export declare class HttpClient {
|
|
5
5
|
private readonly apiKey;
|
package/dist/esm/client.js
CHANGED
|
@@ -2,11 +2,11 @@ import { ApiError, ApiInternalError, AuthenticationError, ConflictError, Connect
|
|
|
2
2
|
const DEFAULT_BASE_URL = 'https://facturino.com/api';
|
|
3
3
|
const DEFAULT_MAX_RETRIES = 3;
|
|
4
4
|
const DEFAULT_TIMEOUT = 30000;
|
|
5
|
-
const DEFAULT_API_VERSION = '2026-
|
|
5
|
+
const DEFAULT_API_VERSION = '2026-09-01';
|
|
6
6
|
const RETRYABLE_STATUS_CODES = new Set([429, 500, 502, 503]);
|
|
7
7
|
const INITIAL_RETRY_DELAY_MS = 500;
|
|
8
8
|
const MAX_RETRY_DELAY_MS = 30000;
|
|
9
|
-
export const VERSION = '1.
|
|
9
|
+
export const VERSION = '2.1.0';
|
|
10
10
|
/** HTTP client with retries, exponential backoff, and structured errors. */
|
|
11
11
|
export class HttpClient {
|
|
12
12
|
constructor(apiKey, config = {}) {
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -17,6 +17,8 @@ import { ReceivedInvoices } from './resources/received-invoices.js';
|
|
|
17
17
|
import { Reporting } from './resources/reporting.js';
|
|
18
18
|
import { AccountResource } from './resources/account.js';
|
|
19
19
|
import { Billing } from './resources/billing.js';
|
|
20
|
+
import { TaxDecisions } from './resources/taxDecisions.js';
|
|
21
|
+
import { EuThresholdLedgers } from './resources/euThresholdLedgers.js';
|
|
20
22
|
import { Usage } from './resources/usage.js';
|
|
21
23
|
import { Validate } from './resources/validate.js';
|
|
22
24
|
import { Reference } from './resources/reference.js';
|
|
@@ -42,6 +44,9 @@ declare class Facturino {
|
|
|
42
44
|
readonly jobs: Jobs;
|
|
43
45
|
readonly reference: Reference;
|
|
44
46
|
readonly sandbox: Sandbox;
|
|
47
|
+
readonly taxDecisions: TaxDecisions;
|
|
48
|
+
/** Annual ledger of the common EUR 10,000 threshold. */
|
|
49
|
+
readonly euThresholdLedgers: EuThresholdLedgers;
|
|
45
50
|
readonly usage: Usage;
|
|
46
51
|
readonly validate: Validate;
|
|
47
52
|
readonly webhooks: Webhooks;
|
|
@@ -53,7 +58,7 @@ declare class Facturino {
|
|
|
53
58
|
}
|
|
54
59
|
export default Facturino;
|
|
55
60
|
export { Facturino };
|
|
56
|
-
export type { FacturinoConfig, RequestOptions, PaginationParams, PaginatedResponse, ApiErrorBody, Address, Contact, ContactRole, LineItem, VatBreakdown, Totals, CustomerRef, CustomerSnapshot, LifecycleEntry, Currency, Unit, VatCode, VatexCode, PaymentMethod, InvoiceType, InvoiceStatus, InvoiceDates, InvoicePaymentTerms, InvoiceEinvoicing, InvoicePortal, InvoiceArchive, InvoiceFiles, Invoice, InvoiceExpandField, InvoiceExpanded, InvoiceRetrieveParams, InvoiceBuyerParam, InvoiceCreateDates, InvoiceCreateParams, InvoiceLineItemParam, InvoiceUpdateParams, InvoiceListParams, IncomingInvoiceCreateParams, InvoiceStatusResponse, InvoiceVerifyResponse, DocumentUrlResponse, JobResponse, PaymentLinkResponse, PaymentLinkCreateParams, PaymentTokenResponse, Payment, PaymentCreateParams, Customer, CustomerCreateParams, CustomerUpdateParams, CustomerListParams, CustomerLookupParams, SireneLookupResponse, SireneCompany, Product, PriceHistoryEntry, ProductCreateParams, ProductUpdateParams, ProductListParams, QuoteStatus, QuoteDates, QuoteSignature, Quote, QuoteCreateParams, QuoteUpdateParams, QuoteListParams, CreditNoteType, CreditNoteStatus, CreditNoteReasonCode, CreditNote, CreditNoteCreateParams, CreditNoteUpdateParams, CreditNoteListParams, WebhookEventType, WebhookEvent, EventListParams, WebhookEndpoint, WebhookEndpointCreateParams, WebhookEndpointUpdateParams, RecurringFrequency, RecurringInvoice, RecurringInvoiceCreateParams, RecurringInvoiceUpdateParams, RecurringInvoiceListParams, BankDetails, InvoiceSettings, CreditNoteSettings, CreditNoteNumberingMode, Company, CompanyUpdateParams, CgvResponse, FecExportParams, EReportingType, EReportingStatus, EReportingLine, EReportingLineResponse, EReporting, EReportingCreateParams, EReportingListParams, JobType, JobStatus, Job, SandboxResetResponse, SimulateStatusParams, SimulateStatusResponse, ReceivedInvoiceStatus, ReceivedInvoice, ReceivedInvoiceListParams, ReceivedInvoiceRefuseParams, ReceivedInvoiceRecordPaymentParams, ReceivedInvoiceActionResponse, VatReportParams, VatReportBreakdown, VatReport, RevenueReportParams, RevenueReportBreakdownItem, RevenueReport, AccountPlan, Account, BillingCycle, BillingSubscription, PlatformInvoice, UsageMeter, UsageSummary, ValidateParams, ValidateResponse, LegalForm, NafCode, LegalFormInput, NafCodeInput, PaProvider, HealthStatus, } from './types.js';
|
|
61
|
+
export type { FacturinoConfig, RequestOptions, PaginationParams, PaginatedResponse, ApiErrorBody, Address, Contact, ContactRole, LineItem, VatBreakdown, Totals, CustomerRef, CustomerSnapshot, LifecycleEntry, Currency, Unit, VatCode, VatexCode, PaymentMethod, InvoiceType, InvoiceStatus, InvoiceDates, InvoicePaymentTerms, InvoiceEinvoicing, InvoicePortal, InvoiceArchive, InvoiceFiles, Invoice, InvoiceExpandField, InvoiceExpanded, InvoiceRetrieveParams, InvoiceBuyerParam, InvoiceCreateDates, InvoiceCreateParams, InvoiceBindTaxDecisionParams, CommercialDraft, CommercialDraftLine, InvoiceLineItemParam, InvoiceUpdateParams, InvoiceListParams, IncomingInvoiceCreateParams, InvoiceStatusResponse, InvoiceVerifyResponse, DocumentUrlResponse, JobResponse, PaymentLinkResponse, PaymentLinkCreateParams, PaymentTokenResponse, Payment, PaymentCreateParams, Customer, CustomerCreateParams, CustomerUpdateParams, CustomerListParams, CustomerLookupParams, SireneLookupResponse, SireneCompany, Product, PriceHistoryEntry, ProductCreateParams, ProductUpdateParams, ProductListParams, QuoteStatus, QuoteDates, QuoteSignature, Quote, QuoteCreateParams, QuoteUpdateParams, QuoteListParams, CreditNoteType, CreditNoteStatus, CreditNoteReasonCode, CreditNote, CreditNoteCreateParams, CreditNoteUpdateParams, CreditNoteListParams, WebhookEventType, WebhookEvent, EventListParams, WebhookEndpoint, WebhookEndpointCreateParams, WebhookEndpointUpdateParams, RecurringFrequency, RecurringInvoice, RecurringInvoiceCreateParams, RecurringInvoiceUpdateParams, RecurringInvoiceListParams, BankDetails, InvoiceSettings, CreditNoteSettings, CreditNoteNumberingMode, Company, CompanyUpdateParams, CgvResponse, FecExportParams, EReportingType, EReportingStatus, EReportingLine, EReportingLineResponse, EReporting, EReportingCreateParams, EReportingListParams, JobType, JobStatus, Job, SandboxResetResponse, SimulateStatusParams, SimulateStatusResponse, ReceivedInvoiceStatus, ReceivedInvoice, ReceivedInvoiceListParams, ReceivedInvoiceRefuseParams, ReceivedInvoiceRecordPaymentParams, ReceivedInvoiceActionResponse, VatReportParams, VatReportBreakdown, VatReport, RevenueReportParams, RevenueReportBreakdownItem, RevenueReport, AccountPlan, Account, BillingCycle, BillingSubscription, PlatformInvoice, UsageMeter, UsageSummary, ValidateParams, ValidateResponse, PriceMode, SupplyCategory, PrimarySupplyCategory, RateCategory, GoodsMovement, TaxDecisionStatus, TaxDecisionDiscount, TaxDecisionLineParam, TaxDecisionCreateParams, TaxDecision, TaxDecisionLine, TaxDecisionCustomer, TaxDecisionIssue, TaxDecisionObligationReason, TaxDecisionSettledObligations, TaxDecisionEuB2cDestination, EuThresholdLedger, EuThresholdLedgerEntry, EuThresholdLedgerEntryList, EuThresholdReservation, EuThresholdCoverageMode, EuThresholdCorrectionKind, EuThresholdReviewCode, OpenEuThresholdLedgerParams, EuThresholdAdjustmentParams, EuThresholdCorrectionParams, EuThresholdReviewParams, EuThresholdReviewResolutionParams, EuThresholdEntryListParams, TaxDecisionThresholdTrace, TaxDecisionDestinationRate, TaxDecisionDestinationMechanism, TaxDecisionEvidenceRelief, TaxDecisionVatBreakdownEntry, LocationEvidenceKind, LocationEvidenceParam, LocationEvidenceResult, NonEuBusinessEvidenceParam, NonEuBusinessEvidenceResult, EvidenceSource, ViesResult, InvoiceChannel, TransactionReporting, PaymentReporting, TaxSource, TaxSnapshot, DocumentStatus, TransmissionStatus, TransmissionDetail, PaymentStatus, DecisionBackedLineParam, InvoiceCreateBaseParams, CreditedLineParam, RecurringTaxLineParam, RecurringIntegrationTaxLineParam, RecurringTaxInputsParam, FacturinoTaxDecisionCreateParams, IntegrationTaxDecisionCreateParams, IntegrationTaxDecisionLineParam, LegalForm, NafCode, LegalFormInput, NafCodeInput, PaProvider, HealthStatus, } from './types.js';
|
|
57
62
|
export { FacturinoError, ApiError, InvalidRequestError, ValidationError, AuthenticationError, PermissionError, NotFoundError, ConflictError, RateLimitError, PlanLimitError, ApiInternalError, ConnectionError, } from './errors.js';
|
|
58
63
|
export { Webhooks } from './webhooks.js';
|
|
59
64
|
export { AutoPaginatingList } from './pagination.js';
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAA;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAChD,OAAO,EAA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,eAAe,GAChB,MAAM,aAAa,CAAA;AAEpB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA"}
|
package/dist/esm/index.js
CHANGED
|
@@ -18,6 +18,8 @@ import { ReceivedInvoices } from './resources/received-invoices.js';
|
|
|
18
18
|
import { Reporting } from './resources/reporting.js';
|
|
19
19
|
import { AccountResource } from './resources/account.js';
|
|
20
20
|
import { Billing } from './resources/billing.js';
|
|
21
|
+
import { TaxDecisions } from './resources/taxDecisions.js';
|
|
22
|
+
import { EuThresholdLedgers } from './resources/euThresholdLedgers.js';
|
|
21
23
|
import { Usage } from './resources/usage.js';
|
|
22
24
|
import { Validate } from './resources/validate.js';
|
|
23
25
|
import { Reference } from './resources/reference.js';
|
|
@@ -44,6 +46,8 @@ class Facturino {
|
|
|
44
46
|
this.jobs = new Jobs(client);
|
|
45
47
|
this.reference = new Reference(client);
|
|
46
48
|
this.sandbox = new Sandbox(client);
|
|
49
|
+
this.taxDecisions = new TaxDecisions(client);
|
|
50
|
+
this.euThresholdLedgers = new EuThresholdLedgers(client);
|
|
47
51
|
this.usage = new Usage(client);
|
|
48
52
|
this.validate = new Validate(client);
|
|
49
53
|
this.webhooks = new Webhooks();
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAClD,OAAO,EA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,OAAO,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,CAAA;QAClC,IAAI,CAAC,YAAY,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC,CAAA;QAC5C,IAAI,CAAC,kBAAkB,GAAG,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAA;QACxD,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,CAAA;QAC9B,IAAI,CAAC,QAAQ,GAAG,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAA;QACpC,IAAI,CAAC,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAA;QAC9B,IAAI,CAAC,gBAAgB,GAAG,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAA;QACpD,IAAI,CAAC,SAAS,GAAG,IAAI,SAAS,CAAC,MAAM,CAAC,CAAA;QACtC,IAAI,CAAC,QAAQ,GAAG,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAA;QACpC,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,CAAA;IAClC,CAAC;CACF;AAED,eAAe,SAAS,CAAA;AACxB,OAAO,EAAE,SAAS,EAAE,CAAA;AA6MpB,OAAO,EACL,cAAc,EACd,QAAQ,EACR,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,eAAe,GAChB,MAAM,aAAa,CAAA;AAEpB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { HttpClient } from '../client.js';
|
|
2
|
+
import type { EuThresholdAdjustmentParams, EuThresholdCorrectionParams, EuThresholdEntryListParams, EuThresholdLedger, EuThresholdLedgerEntryList, EuThresholdReviewParams, EuThresholdReviewResolutionParams, OpenEuThresholdLedgerParams, RequestOptions } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* The annual EU threshold ledger — the running total the common EUR 10,000
|
|
5
|
+
* threshold is assessed on.
|
|
6
|
+
*
|
|
7
|
+
* It is deliberately separate from the seller's fiscal profile: a profile
|
|
8
|
+
* revision is an immutable RULE that decisions freeze, while a turnover total
|
|
9
|
+
* moves with every sale and gets corrected. Keeping them apart is what lets a
|
|
10
|
+
* correction be recorded without rewriting the rule a frozen decision was taken
|
|
11
|
+
* under.
|
|
12
|
+
*
|
|
13
|
+
* It carries TWO counters, strictly apart and INDEPENDENT: the common
|
|
14
|
+
* EUR 10,000 threshold (art. 59c(1) — distance sales of goods AND cross-border
|
|
15
|
+
* services to consumers) and the EUR 100,000 location-evidence threshold
|
|
16
|
+
* (Reg. 282/2011 art. 24b — electronically supplied services, domestic ones
|
|
17
|
+
* included). Reading one off the other would open a single-evidence regime on
|
|
18
|
+
* turnover the regulation does not count towards it, and neither bounds the
|
|
19
|
+
* other: a seller whose electronic services are mostly domestic legitimately
|
|
20
|
+
* declares more on the second than on the first.
|
|
21
|
+
*
|
|
22
|
+
* Nothing is assumed. Opening a year declares four figures — the two totals and
|
|
23
|
+
* their services part — plus whether every covered sale goes through Facturino.
|
|
24
|
+
* Sales made elsewhere are never assumed absent: under `mixed_channels` they
|
|
25
|
+
* enter through adjustments, and the ledger serves a decision only up to the day
|
|
26
|
+
* those channels are declared complete through.
|
|
27
|
+
*
|
|
28
|
+
* The ledger is append-only: there is no update and no delete. Giving an amount
|
|
29
|
+
* back is a qualified CORRECTION, which names the movement it corrects; what
|
|
30
|
+
* cannot be qualified that way puts the ledger under review instead.
|
|
31
|
+
*/
|
|
32
|
+
export declare class EuThresholdLedgers {
|
|
33
|
+
private readonly client;
|
|
34
|
+
constructor(client: HttpClient);
|
|
35
|
+
/**
|
|
36
|
+
* Open a calendar year.
|
|
37
|
+
*
|
|
38
|
+
* A year already open is never rewritten (`eu_threshold_year_already_open`):
|
|
39
|
+
* decisions were frozen on its opening figures.
|
|
40
|
+
*/
|
|
41
|
+
open(params: OpenEuThresholdLedgerParams, options?: RequestOptions): Promise<EuThresholdLedger>;
|
|
42
|
+
/**
|
|
43
|
+
* Read the ledger of a year: acquired totals, held slices, what remains, and
|
|
44
|
+
* the first page of movements.
|
|
45
|
+
*/
|
|
46
|
+
retrieve(year: string, params?: EuThresholdEntryListParams): Promise<EuThresholdLedger>;
|
|
47
|
+
/** Alias of {@link retrieve}. */
|
|
48
|
+
get(year: string): Promise<EuThresholdLedger>;
|
|
49
|
+
/**
|
|
50
|
+
* Walk the movements page by page, newest first.
|
|
51
|
+
*
|
|
52
|
+
* The ledger keeps every movement; a page shows some. `next_cursor` names the
|
|
53
|
+
* last one returned.
|
|
54
|
+
*/
|
|
55
|
+
listEntries(year: string, params?: EuThresholdEntryListParams): Promise<EuThresholdLedgerEntryList>;
|
|
56
|
+
/**
|
|
57
|
+
* Record turnover made on another channel.
|
|
58
|
+
*
|
|
59
|
+
* Append-only and idempotent on your own `reference`, compared through a
|
|
60
|
+
* canonical fingerprint of the WHOLE body: replaying the same adjustment adds
|
|
61
|
+
* nothing, and reusing the reference for any different fact answers
|
|
62
|
+
* `eu_threshold_entry_conflict`. A negative amount is impossible here —
|
|
63
|
+
* giving an amount back is {@link correct}.
|
|
64
|
+
*/
|
|
65
|
+
adjust(year: string, params: EuThresholdAdjustmentParams, options?: RequestOptions): Promise<EuThresholdLedger>;
|
|
66
|
+
/**
|
|
67
|
+
* Take a qualified amount back out of the running total.
|
|
68
|
+
*
|
|
69
|
+
* Directive 2006/112/EC art. 90(1) reduces the taxable amount of a supply on
|
|
70
|
+
* cancellation, refusal or a price reduction after the supply, and the
|
|
71
|
+
* thresholds count the VALUE of the supplies — so the correction names the
|
|
72
|
+
* movement it corrects (`correctsEntryId`), its qualification, the resource it
|
|
73
|
+
* rests on and its evidence. The ledger keeps the BALANCE of each movement
|
|
74
|
+
* inside the transaction, so the corrections of one movement never add up to
|
|
75
|
+
* more than it brought in (`eu_threshold_correction_exceeds_counted`); an
|
|
76
|
+
* unknown movement answers `eu_threshold_correction_target_unknown`, and one
|
|
77
|
+
* that brought no turnover in `eu_threshold_correction_target_not_correctable`.
|
|
78
|
+
* Each entry publishes its `remainingMin`, so the balance is readable before
|
|
79
|
+
* the correction is attempted.
|
|
80
|
+
*
|
|
81
|
+
* Decisions already frozen are never rewritten: they were correct on the
|
|
82
|
+
* figures of their own day. Only the total the NEXT operations read changes.
|
|
83
|
+
*/
|
|
84
|
+
correct(year: string, params: EuThresholdCorrectionParams, options?: RequestOptions): Promise<EuThresholdLedger>;
|
|
85
|
+
/**
|
|
86
|
+
* Stop deciding on this ledger: its running total is known to be wrong.
|
|
87
|
+
*
|
|
88
|
+
* Every reservation then answers `eu_threshold_review_required`. This is the
|
|
89
|
+
* honest exit when an amount must come out and no qualified correction can
|
|
90
|
+
* name the movement it corrects.
|
|
91
|
+
*/
|
|
92
|
+
review(year: string, params: EuThresholdReviewParams, options?: RequestOptions): Promise<EuThresholdLedger>;
|
|
93
|
+
/**
|
|
94
|
+
* Serve decisions again — on a RECONCILIATION that matches, never on a
|
|
95
|
+
* comment. See {@link EuThresholdReviewResolutionParams}.
|
|
96
|
+
*/
|
|
97
|
+
resolveReview(year: string, params: EuThresholdReviewResolutionParams, options?: RequestOptions): Promise<EuThresholdLedger>;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=euThresholdLedgers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"euThresholdLedgers.d.ts","sourceRoot":"","sources":["../../../src/resources/euThresholdLedgers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,KAAK,EACV,2BAA2B,EAC3B,2BAA2B,EAC3B,0BAA0B,EAC1B,iBAAiB,EACjB,0BAA0B,EAC1B,uBAAuB,EACvB,iCAAiC,EACjC,2BAA2B,EAC3B,cAAc,EACf,MAAM,aAAa,CAAA;AAE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common EUR 10,000
|
|
3
|
+
* threshold is assessed on.
|
|
4
|
+
*
|
|
5
|
+
* It is deliberately separate from the seller's fiscal profile: a profile
|
|
6
|
+
* revision is an immutable RULE that decisions freeze, while a turnover total
|
|
7
|
+
* moves with every sale and gets corrected. Keeping them apart is what lets a
|
|
8
|
+
* correction be recorded without rewriting the rule a frozen decision was taken
|
|
9
|
+
* under.
|
|
10
|
+
*
|
|
11
|
+
* It carries TWO counters, strictly apart and INDEPENDENT: the common
|
|
12
|
+
* EUR 10,000 threshold (art. 59c(1) — distance sales of goods AND cross-border
|
|
13
|
+
* services to consumers) and the EUR 100,000 location-evidence threshold
|
|
14
|
+
* (Reg. 282/2011 art. 24b — electronically supplied services, domestic ones
|
|
15
|
+
* included). Reading one off the other would open a single-evidence regime on
|
|
16
|
+
* turnover the regulation does not count towards it, and neither bounds the
|
|
17
|
+
* other: a seller whose electronic services are mostly domestic legitimately
|
|
18
|
+
* declares more on the second than on the first.
|
|
19
|
+
*
|
|
20
|
+
* Nothing is assumed. Opening a year declares four figures — the two totals and
|
|
21
|
+
* their services part — plus whether every covered sale goes through Facturino.
|
|
22
|
+
* Sales made elsewhere are never assumed absent: under `mixed_channels` they
|
|
23
|
+
* enter through adjustments, and the ledger serves a decision only up to the day
|
|
24
|
+
* those channels are declared complete through.
|
|
25
|
+
*
|
|
26
|
+
* The ledger is append-only: there is no update and no delete. Giving an amount
|
|
27
|
+
* back is a qualified CORRECTION, which names the movement it corrects; what
|
|
28
|
+
* cannot be qualified that way puts the ledger under review instead.
|
|
29
|
+
*/
|
|
30
|
+
export class EuThresholdLedgers {
|
|
31
|
+
constructor(client) {
|
|
32
|
+
this.client = client;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Open a calendar year.
|
|
36
|
+
*
|
|
37
|
+
* A year already open is never rewritten (`eu_threshold_year_already_open`):
|
|
38
|
+
* decisions were frozen on its opening figures.
|
|
39
|
+
*/
|
|
40
|
+
async open(params, options) {
|
|
41
|
+
return this.client.post('/v1/eu-threshold-ledgers', params, options);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Read the ledger of a year: acquired totals, held slices, what remains, and
|
|
45
|
+
* the first page of movements.
|
|
46
|
+
*/
|
|
47
|
+
async retrieve(year, params) {
|
|
48
|
+
return this.client.get(`/v1/eu-threshold-ledgers/${year}${toQuery(params)}`);
|
|
49
|
+
}
|
|
50
|
+
/** Alias of {@link retrieve}. */
|
|
51
|
+
async get(year) {
|
|
52
|
+
return this.retrieve(year);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Walk the movements page by page, newest first.
|
|
56
|
+
*
|
|
57
|
+
* The ledger keeps every movement; a page shows some. `next_cursor` names the
|
|
58
|
+
* last one returned.
|
|
59
|
+
*/
|
|
60
|
+
async listEntries(year, params) {
|
|
61
|
+
return this.client.get(`/v1/eu-threshold-ledgers/${year}/entries${toQuery(params)}`);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Record turnover made on another channel.
|
|
65
|
+
*
|
|
66
|
+
* Append-only and idempotent on your own `reference`, compared through a
|
|
67
|
+
* canonical fingerprint of the WHOLE body: replaying the same adjustment adds
|
|
68
|
+
* nothing, and reusing the reference for any different fact answers
|
|
69
|
+
* `eu_threshold_entry_conflict`. A negative amount is impossible here —
|
|
70
|
+
* giving an amount back is {@link correct}.
|
|
71
|
+
*/
|
|
72
|
+
async adjust(year, params, options) {
|
|
73
|
+
return this.client.post(`/v1/eu-threshold-ledgers/${year}/adjustments`, params, options);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Take a qualified amount back out of the running total.
|
|
77
|
+
*
|
|
78
|
+
* Directive 2006/112/EC art. 90(1) reduces the taxable amount of a supply on
|
|
79
|
+
* cancellation, refusal or a price reduction after the supply, and the
|
|
80
|
+
* thresholds count the VALUE of the supplies — so the correction names the
|
|
81
|
+
* movement it corrects (`correctsEntryId`), its qualification, the resource it
|
|
82
|
+
* rests on and its evidence. The ledger keeps the BALANCE of each movement
|
|
83
|
+
* inside the transaction, so the corrections of one movement never add up to
|
|
84
|
+
* more than it brought in (`eu_threshold_correction_exceeds_counted`); an
|
|
85
|
+
* unknown movement answers `eu_threshold_correction_target_unknown`, and one
|
|
86
|
+
* that brought no turnover in `eu_threshold_correction_target_not_correctable`.
|
|
87
|
+
* Each entry publishes its `remainingMin`, so the balance is readable before
|
|
88
|
+
* the correction is attempted.
|
|
89
|
+
*
|
|
90
|
+
* Decisions already frozen are never rewritten: they were correct on the
|
|
91
|
+
* figures of their own day. Only the total the NEXT operations read changes.
|
|
92
|
+
*/
|
|
93
|
+
async correct(year, params, options) {
|
|
94
|
+
return this.client.post(`/v1/eu-threshold-ledgers/${year}/corrections`, params, options);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Stop deciding on this ledger: its running total is known to be wrong.
|
|
98
|
+
*
|
|
99
|
+
* Every reservation then answers `eu_threshold_review_required`. This is the
|
|
100
|
+
* honest exit when an amount must come out and no qualified correction can
|
|
101
|
+
* name the movement it corrects.
|
|
102
|
+
*/
|
|
103
|
+
async review(year, params, options) {
|
|
104
|
+
return this.client.post(`/v1/eu-threshold-ledgers/${year}/review`, params, options);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Serve decisions again — on a RECONCILIATION that matches, never on a
|
|
108
|
+
* comment. See {@link EuThresholdReviewResolutionParams}.
|
|
109
|
+
*/
|
|
110
|
+
async resolveReview(year, params, options) {
|
|
111
|
+
return this.client.post(`/v1/eu-threshold-ledgers/${year}/review/resolve`, params, options);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/** Query string for the cursor pagination, empty when nothing is asked. */
|
|
115
|
+
function toQuery(params) {
|
|
116
|
+
if (params === undefined)
|
|
117
|
+
return '';
|
|
118
|
+
const search = new URLSearchParams();
|
|
119
|
+
if (params.limit !== undefined)
|
|
120
|
+
search.set('limit', String(params.limit));
|
|
121
|
+
if (params.starting_after !== undefined)
|
|
122
|
+
search.set('starting_after', params.starting_after);
|
|
123
|
+
const query = search.toString();
|
|
124
|
+
return query === '' ? '' : `?${query}`;
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=euThresholdLedgers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"euThresholdLedgers.js","sourceRoot":"","sources":["../../../src/resources/euThresholdLedgers.ts"],"names":[],"mappings":"AAaA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,OAAO,kBAAkB;IAC7B,YAA6B,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;IAAG,CAAC;IAEnD;;;;;OAKG;IACH,KAAK,CAAC,IAAI,CACR,MAAmC,EACnC,OAAwB;QAExB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAoB,0BAA0B,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;IACzF,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,QAAQ,CAAC,IAAY,EAAE,MAAmC;QAC9D,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CACpB,4BAA4B,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE,CACrD,CAAA;IACH,CAAC;IAED,iCAAiC;IACjC,KAAK,CAAC,GAAG,CAAC,IAAY;QACpB,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IAC5B,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,WAAW,CACf,IAAY,EACZ,MAAmC;QAEnC,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CACpB,4BAA4B,IAAI,WAAW,OAAO,CAAC,MAAM,CAAC,EAAE,CAC7D,CAAA;IACH,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,MAAM,CACV,IAAY,EACZ,MAAmC,EACnC,OAAwB;QAExB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CACrB,4BAA4B,IAAI,cAAc,EAC9C,MAAM,EACN,OAAO,CACR,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
|
|
2
2
|
import { AutoPaginatingList } from '../pagination.js';
|
|
3
3
|
import { Payments } from './payments.js';
|
|
4
|
-
import type { Invoice, InvoiceCreateParams, InvoiceUpdateParams, InvoiceListParams, InvoiceRetrieveParams, InvoiceStatusResponse, InvoiceVerifyResponse, DocumentUrlResponse, JobResponse, PaymentLinkResponse, PaymentLinkCreateParams, PaymentTokenResponse, PaginatedResponse, LifecycleEntry, IncomingInvoiceCreateParams, ReceivedInvoice, RequestOptions } from '../types.js';
|
|
4
|
+
import type { Invoice, InvoiceCreateParams, InvoiceBindTaxDecisionParams, InvoiceUpdateParams, InvoiceListParams, InvoiceRetrieveParams, InvoiceStatusResponse, InvoiceVerifyResponse, DocumentUrlResponse, JobResponse, PaymentLinkResponse, PaymentLinkCreateParams, PaymentTokenResponse, PaginatedResponse, LifecycleEntry, IncomingInvoiceCreateParams, ReceivedInvoice, RequestOptions } from '../types.js';
|
|
5
5
|
/** Manages invoice lifecycle — creation, finalization, sending, and document retrieval. */
|
|
6
6
|
export declare class Invoices {
|
|
7
7
|
private readonly client;
|
|
8
8
|
readonly payments: Payments;
|
|
9
9
|
constructor(client: HttpClient);
|
|
10
|
+
/**
|
|
11
|
+
* Create an invoice — ALWAYS backed by a FINAL tax decision (`taxDecisionId`
|
|
12
|
+
* + `decisionLines`), whatever its fiscal source. The decided VAT, amounts
|
|
13
|
+
* and mentions are copied verbatim and frozen; `deposits` and `schedule` are
|
|
14
|
+
* settled server-side against the decided amount, inside the creation
|
|
15
|
+
* transaction. The types enforce this at compile time; the checks below turn
|
|
16
|
+
* the same misuse into an immediate local error instead of a round trip.
|
|
17
|
+
*/
|
|
10
18
|
create(params: InvoiceCreateParams, options?: RequestOptions): Promise<Invoice>;
|
|
11
19
|
list(params?: InvoiceListParams): AutoPaginatingList<Invoice>;
|
|
12
20
|
/**
|
|
@@ -19,6 +27,28 @@ export declare class Invoices {
|
|
|
19
27
|
update(id: string, params: InvoiceUpdateParams): Promise<Invoice>;
|
|
20
28
|
/** Soft-delete (draft only). */
|
|
21
29
|
del(id: string): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Bind a FINAL tax decision to a commercial draft that already exists —
|
|
32
|
+
* typically the one `quotes.convert()` produced.
|
|
33
|
+
*
|
|
34
|
+
* This closes the quote cycle on ONE document:
|
|
35
|
+
*
|
|
36
|
+
* ```ts
|
|
37
|
+
* const { invoiceId } = await facturino.quotes.convert(quoteId)
|
|
38
|
+
* const decision = await facturino.taxDecisions.create({ ... }, { idempotencyKey })
|
|
39
|
+
* await facturino.invoices.bindTaxDecision(invoiceId, {
|
|
40
|
+
* taxDecisionId: decision.id,
|
|
41
|
+
* decisionLines: [{ taxLineRef: 'l1', unit: 'unit' }],
|
|
42
|
+
* })
|
|
43
|
+
* await facturino.invoices.finalize(invoiceId)
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* The invoice stays a DRAFT: binding freezes the VAT, `finalize()` issues it.
|
|
47
|
+
* Idempotent on the decision — replaying the same call returns the same
|
|
48
|
+
* invoice. Binding a different decision to a bound invoice, or the same
|
|
49
|
+
* decision to a second invoice, is a conflict.
|
|
50
|
+
*/
|
|
51
|
+
bindTaxDecision(id: string, params: InvoiceBindTaxDecisionParams, options?: RequestOptions): Promise<Invoice>;
|
|
22
52
|
/** Assign number and lock. Irreversible. */
|
|
23
53
|
finalize(id: string, options?: RequestOptions): Promise<Invoice>;
|
|
24
54
|
/** Submit to PA. Returns 202 (async). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invoices.d.ts","sourceRoot":"","sources":["../../../src/resources/invoices.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,KAAK,EACV,OAAO,EACP,mBAAmB,EACnB,mBAAmB,EACnB,iB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EAAE,MAAM,EACV,MAAM,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,cAAc,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GACpE,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAUtD,wCAAwC;IAClC,qBAAqB,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC;IAIvF,sCAAsC;IAChC,iBAAiB,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,uBAAuB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAI7H,8CAA8C;IACxC,kBAAkB,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAI7F;;;;;;;;;OASG;IACG,gBAAgB,CACpB,EAAE,EAAE,MAAM,EACV,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;IAI9D,8EAA8E;IACxE,cAAc,CAClB,MAAM,EAAE,2BAA2B,EACnC,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,eAAe,CAAC;IAI3B,wFAAwF;IACxF,YAAY,CAAC,MAAM,CAAC,EAAE,iBAAiB,GAAG,kBAAkB,CAAC,eAAe,CAAC;CAG9E"}
|
|
@@ -6,7 +6,27 @@ export class Invoices {
|
|
|
6
6
|
this.client = client;
|
|
7
7
|
this.payments = new Payments(client);
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Create an invoice — ALWAYS backed by a FINAL tax decision (`taxDecisionId`
|
|
11
|
+
* + `decisionLines`), whatever its fiscal source. The decided VAT, amounts
|
|
12
|
+
* and mentions are copied verbatim and frozen; `deposits` and `schedule` are
|
|
13
|
+
* settled server-side against the decided amount, inside the creation
|
|
14
|
+
* transaction. The types enforce this at compile time; the checks below turn
|
|
15
|
+
* the same misuse into an immediate local error instead of a round trip.
|
|
16
|
+
*/
|
|
9
17
|
async create(params, options) {
|
|
18
|
+
const runtime = params;
|
|
19
|
+
if (typeof runtime.taxDecisionId !== 'string' || runtime.taxDecisionId.length === 0) {
|
|
20
|
+
throw new Error(`'taxDecisionId' is required: every invoice is backed by a FINAL tax decision `
|
|
21
|
+
+ `(facturino or integration source). Create one with taxDecisions.create() first.`);
|
|
22
|
+
}
|
|
23
|
+
if (!Array.isArray(runtime.decisionLines) || runtime.decisionLines.length === 0) {
|
|
24
|
+
throw new Error(`'decisionLines' is required: one presentation line per decision line, matched by 'taxLineRef'.`);
|
|
25
|
+
}
|
|
26
|
+
if ('lines' in runtime && runtime.lines !== undefined) {
|
|
27
|
+
throw new Error(`'lines' is not part of the invoice contract: the VAT of an invoice comes from its `
|
|
28
|
+
+ `tax decision. Send 'decisionLines' (presentation only).`);
|
|
29
|
+
}
|
|
10
30
|
return this.client.post('/v1/invoices', params, options);
|
|
11
31
|
}
|
|
12
32
|
list(params) {
|
|
@@ -30,6 +50,37 @@ export class Invoices {
|
|
|
30
50
|
async del(id) {
|
|
31
51
|
await this.client.del(`/v1/invoices/${id}`);
|
|
32
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Bind a FINAL tax decision to a commercial draft that already exists —
|
|
55
|
+
* typically the one `quotes.convert()` produced.
|
|
56
|
+
*
|
|
57
|
+
* This closes the quote cycle on ONE document:
|
|
58
|
+
*
|
|
59
|
+
* ```ts
|
|
60
|
+
* const { invoiceId } = await facturino.quotes.convert(quoteId)
|
|
61
|
+
* const decision = await facturino.taxDecisions.create({ ... }, { idempotencyKey })
|
|
62
|
+
* await facturino.invoices.bindTaxDecision(invoiceId, {
|
|
63
|
+
* taxDecisionId: decision.id,
|
|
64
|
+
* decisionLines: [{ taxLineRef: 'l1', unit: 'unit' }],
|
|
65
|
+
* })
|
|
66
|
+
* await facturino.invoices.finalize(invoiceId)
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* The invoice stays a DRAFT: binding freezes the VAT, `finalize()` issues it.
|
|
70
|
+
* Idempotent on the decision — replaying the same call returns the same
|
|
71
|
+
* invoice. Binding a different decision to a bound invoice, or the same
|
|
72
|
+
* decision to a second invoice, is a conflict.
|
|
73
|
+
*/
|
|
74
|
+
async bindTaxDecision(id, params, options) {
|
|
75
|
+
const runtime = params;
|
|
76
|
+
if (typeof runtime.taxDecisionId !== 'string' || runtime.taxDecisionId.length === 0) {
|
|
77
|
+
throw new Error(`'taxDecisionId' is required: a draft is fiscalised by binding a FINAL tax decision to it.`);
|
|
78
|
+
}
|
|
79
|
+
if (!Array.isArray(runtime.decisionLines) || runtime.decisionLines.length === 0) {
|
|
80
|
+
throw new Error(`'decisionLines' is required: one presentation line per decision line, matched by 'taxLineRef'.`);
|
|
81
|
+
}
|
|
82
|
+
return this.client.post(`/v1/invoices/${id}/bind-tax-decision`, params, options);
|
|
83
|
+
}
|
|
33
84
|
/** Assign number and lock. Irreversible. */
|
|
34
85
|
async finalize(id, options) {
|
|
35
86
|
return this.client.post(`/v1/invoices/${id}/finalize`, undefined, options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invoices.js","sourceRoot":"","sources":["../../../src/resources/invoices.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"invoices.js","sourceRoot":"","sources":["../../../src/resources/invoices.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AA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IAAI,CAAC,MAAM,CAAC,IAAI,CAAkB,uBAAuB,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;IACpF,CAAC;IAED,wFAAwF;IACxF,YAAY,CAAC,MAA0B;QACrC,OAAO,IAAI,kBAAkB,CAAkB,IAAI,CAAC,MAAM,EAAE,uBAAuB,EAAE,MAAM,CAAC,CAAA;IAC9F,CAAC;CACF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { HttpClient } from '../client.js';
|
|
2
|
+
import type { TaxDecision, TaxDecisionCreateParams, RequestOptions } from '../types.js';
|
|
3
|
+
export declare class TaxDecisions {
|
|
4
|
+
private readonly client;
|
|
5
|
+
constructor(client: HttpClient);
|
|
6
|
+
/**
|
|
7
|
+
* Take a decision on a commercial operation.
|
|
8
|
+
*
|
|
9
|
+
* Business idempotency is durable here, beyond the 24-hour transport window,
|
|
10
|
+
* and it is keyed on the KEY — not on the operation. The SAME
|
|
11
|
+
* `idempotencyKey` with the SAME canonical body always replays the SAME
|
|
12
|
+
* decision, so a retry after a lost response costs nothing and charges
|
|
13
|
+
* nothing twice. Two DIFFERENT keys describing the same operation produce TWO
|
|
14
|
+
* decisions: nothing matches them up, and reusing one key with a different
|
|
15
|
+
* body answers `409`.
|
|
16
|
+
*
|
|
17
|
+
* Only a `final` decision carries amounts. On `pending_verification` or
|
|
18
|
+
* `unsupported`, `totals` and `amountToCharge` are `null` — never `0` — and
|
|
19
|
+
* `issues` says what is missing.
|
|
20
|
+
*/
|
|
21
|
+
create(params: TaxDecisionCreateParams, options: RequestOptions & {
|
|
22
|
+
idempotencyKey: string;
|
|
23
|
+
}): Promise<TaxDecision>;
|
|
24
|
+
/**
|
|
25
|
+
* Read a decision back — typically after a payment capture, to check that the
|
|
26
|
+
* captured amount, currency and buyer match what was decided.
|
|
27
|
+
*/
|
|
28
|
+
retrieve(id: string): Promise<TaxDecision>;
|
|
29
|
+
/** Alias of {@link TaxDecisions.retrieve}, for consistency with the other resources. */
|
|
30
|
+
get(id: string): Promise<TaxDecision>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=taxDecisions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taxDecisions.d.ts","sourceRoot":"","sources":["../../../src/resources/taxDecisions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAgBvF,qBAAa,YAAY;IACX,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAE/C;;;;;;;;;;;;;;OAcG;IACG,MAAM,CACV,MAAM,EAAE,uBAAuB,EAC/B,OAAO,EAAE,cAAc,GAAG;QAAE,cAAc,EAAE,MAAM,CAAA;KAAE,GACnD,OAAO,CAAC,WAAW,CAAC;IAkBvB;;;OAGG;IACG,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAIhD,wFAAwF;IAClF,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;CAG5C"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tax decisions — the fiscal position of one commercial operation.
|
|
3
|
+
*
|
|
4
|
+
* A decision fixes the VAT, the exact amount to charge and the three reporting
|
|
5
|
+
* axes, then never changes. Ask for one BEFORE you charge anything: the amount
|
|
6
|
+
* to debit is `amountToCharge`, not a total computed locally.
|
|
7
|
+
*
|
|
8
|
+
* The resource is immutable by design — there is no update and no delete. To
|
|
9
|
+
* re-decide the same operation after supplying missing evidence, create a new
|
|
10
|
+
* decision with `retryOfTaxDecisionId`.
|
|
11
|
+
*/
|
|
12
|
+
/** Maximum length the API accepts for `Idempotency-Key`. */
|
|
13
|
+
const MAX_IDEMPOTENCY_KEY_LENGTH = 255;
|
|
14
|
+
export class TaxDecisions {
|
|
15
|
+
constructor(client) {
|
|
16
|
+
this.client = client;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Take a decision on a commercial operation.
|
|
20
|
+
*
|
|
21
|
+
* Business idempotency is durable here, beyond the 24-hour transport window,
|
|
22
|
+
* and it is keyed on the KEY — not on the operation. The SAME
|
|
23
|
+
* `idempotencyKey` with the SAME canonical body always replays the SAME
|
|
24
|
+
* decision, so a retry after a lost response costs nothing and charges
|
|
25
|
+
* nothing twice. Two DIFFERENT keys describing the same operation produce TWO
|
|
26
|
+
* decisions: nothing matches them up, and reusing one key with a different
|
|
27
|
+
* body answers `409`.
|
|
28
|
+
*
|
|
29
|
+
* Only a `final` decision carries amounts. On `pending_verification` or
|
|
30
|
+
* `unsupported`, `totals` and `amountToCharge` are `null` — never `0` — and
|
|
31
|
+
* `issues` says what is missing.
|
|
32
|
+
*/
|
|
33
|
+
async create(params, options) {
|
|
34
|
+
const key = typeof options?.idempotencyKey === 'string' ? options.idempotencyKey.trim() : '';
|
|
35
|
+
if (key.length === 0) {
|
|
36
|
+
throw new Error('Idempotency-Key is required to create a tax decision');
|
|
37
|
+
}
|
|
38
|
+
// The API caps the key at 255 characters. Checking it here turns a round
|
|
39
|
+
// trip and a 400 into an immediate, local error.
|
|
40
|
+
if (key.length > MAX_IDEMPOTENCY_KEY_LENGTH) {
|
|
41
|
+
throw new Error(`Idempotency-Key must be at most ${MAX_IDEMPOTENCY_KEY_LENGTH} characters (received ${key.length})`);
|
|
42
|
+
}
|
|
43
|
+
// 201 on creation, 200 when the same key already produced this decision.
|
|
44
|
+
// Both carry the decision itself, so the caller reads one shape either way;
|
|
45
|
+
// a different body under the same key answers 409 (ConflictError).
|
|
46
|
+
return this.client.post('/v1/tax-decisions', params, options);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Read a decision back — typically after a payment capture, to check that the
|
|
50
|
+
* captured amount, currency and buyer match what was decided.
|
|
51
|
+
*/
|
|
52
|
+
async retrieve(id) {
|
|
53
|
+
return this.client.get(`/v1/tax-decisions/${id}`);
|
|
54
|
+
}
|
|
55
|
+
/** Alias of {@link TaxDecisions.retrieve}, for consistency with the other resources. */
|
|
56
|
+
async get(id) {
|
|
57
|
+
return this.retrieve(id);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=taxDecisions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taxDecisions.js","sourceRoot":"","sources":["../../../src/resources/taxDecisions.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AACH,4DAA4D;AAC5D,MAAM,0BAA0B,GAAG,GAAG,CAAA;AAEtC,MAAM,OAAO,YAAY;IACvB,YAA6B,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;IAAG,CAAC;IAEnD;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,MAAM,CACV,MAA+B,EAC/B,OAAoD;QAEpD,MAAM,GAAG,GAAG,OAAO,OAAO,EAAE,cAAc,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;QAC5F,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAA;QACzE,CAAC;QACD,yEAAyE;QACzE,iDAAiD;QACjD,IAAI,GAAG,CAAC,MAAM,GAAG,0BAA0B,EAAE,CAAC;YAC5C,MAAM,IAAI,KAAK,CACb,mCAAmC,0BAA0B,yBAAyB,GAAG,CAAC,MAAM,GAAG,CACpG,CAAA;QACH,CAAC;QACD,yEAAyE;QACzE,4EAA4E;QAC5E,mEAAmE;QACnE,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAc,mBAAmB,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;IAC5E,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,QAAQ,CAAC,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