@facturino/node 2.0.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 +263 -0
- package/dist/cjs/client.d.ts +1 -1
- package/dist/cjs/client.js +1 -1
- package/dist/cjs/index.d.ts +4 -1
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/resources/euThresholdLedgers.d.ts +98 -0
- package/dist/cjs/resources/euThresholdLedgers.js +129 -0
- package/dist/cjs/types.d.ts +441 -1
- package/dist/esm/client.d.ts +1 -1
- package/dist/esm/client.js +1 -1
- package/dist/esm/index.d.ts +4 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -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/types.d.ts +441 -1
- package/dist/esm/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -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;AAEpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,kBAAkB;IACjB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAE/C;;;;;OAKG;IACG,IAAI,CACR,MAAM,EAAE,2BAA2B,EACnC,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,iBAAiB,CAAC;IAI7B;;;OAGG;IACG,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,0BAA0B,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAM7F,iCAAiC;IAC3B,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAInD;;;;;OAKG;IACG,WAAW,CACf,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,0BAA0B,GAClC,OAAO,CAAC,0BAA0B,CAAC;IAMtC;;;;;;;;OAQG;IACG,MAAM,CACV,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,2BAA2B,EACnC,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,iBAAiB,CAAC;IAQ7B;;;;;;;;;;;;;;;;;OAiBG;IACG,OAAO,CACX,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,2BAA2B,EACnC,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,iBAAiB,CAAC;IAQ7B;;;;;;OAMG;IACG,MAAM,CACV,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,uBAAuB,EAC/B,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,iBAAiB,CAAC;IAQ7B;;;OAGG;IACG,aAAa,CACjB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,iCAAiC,EACzC,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,iBAAiB,CAAC;CAO9B"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The annual EU threshold ledger — the running total the 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;I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