facturas 0.7.0 → 0.8.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 +16 -4
- package/dist/chunk-76WU5BVI.mjs +109 -0
- package/dist/chunk-76WU5BVI.mjs.map +1 -0
- package/dist/{chunk-MBWOFO67.mjs → chunk-HUT3PFKF.mjs} +14 -2
- package/dist/{chunk-MBWOFO67.mjs.map → chunk-HUT3PFKF.mjs.map} +1 -1
- package/dist/{chunk-EDY3PNKJ.mjs → chunk-NUV5RZPZ.mjs} +2 -2
- package/dist/{chunk-IOKZX6CA.mjs → chunk-PPYGVNFA.mjs} +2 -2
- package/dist/{chunk-C55KOV5N.mjs → chunk-TOVSOJ3G.mjs} +239 -46
- package/dist/chunk-TOVSOJ3G.mjs.map +1 -0
- package/dist/{chunk-PKE4Z4GE.mjs → chunk-ZX4OOCML.mjs} +6 -5
- package/dist/chunk-ZX4OOCML.mjs.map +1 -0
- package/dist/constants.d.ts +49 -1
- package/dist/constants.mjs +9 -1
- package/dist/{fiscal-evidence-BQuBbJ3h.d.ts → errors-B0uouRzR.d.ts} +82 -74
- package/dist/errors.d.ts +1 -1
- package/dist/errors.mjs +5 -3
- package/dist/index.d.ts +199 -5
- package/dist/index.mjs +712 -10
- package/dist/index.mjs.map +1 -1
- package/dist/padron.mjs +2 -2
- package/dist/wsfe-CG_erq7V.d.ts +314 -0
- package/dist/wsfe.d.ts +4 -309
- package/dist/wsfe.mjs +4 -4
- package/dist/wsmtxca.d.ts +1 -1
- package/dist/wsmtxca.mjs +3 -3
- package/package.json +1 -1
- package/dist/chunk-C55KOV5N.mjs.map +0 -1
- package/dist/chunk-PKE4Z4GE.mjs.map +0 -1
- package/dist/chunk-VVY2LZIZ.mjs +0 -61
- package/dist/chunk-VVY2LZIZ.mjs.map +0 -1
- /package/dist/{chunk-EDY3PNKJ.mjs.map → chunk-NUV5RZPZ.mjs.map} +0 -0
- /package/dist/{chunk-IOKZX6CA.mjs.map → chunk-PPYGVNFA.mjs.map} +0 -0
|
@@ -1,5 +1,80 @@
|
|
|
1
1
|
import { A as ArcaServiceName } from './types-BXq0da71.js';
|
|
2
2
|
|
|
3
|
+
/** ARCA services that authorize fiscal vouchers. */
|
|
4
|
+
type ArcaFiscalService = "wsfe" | "wsmtxca";
|
|
5
|
+
/** Location of a structured authorization result in the service response. */
|
|
6
|
+
type ArcaFiscalResultLevel = "header" | "detail" | "operation";
|
|
7
|
+
/** Every structured result field exposed by one provider response. */
|
|
8
|
+
type ArcaFiscalResults = {
|
|
9
|
+
header?: string;
|
|
10
|
+
detail?: string;
|
|
11
|
+
operation?: string;
|
|
12
|
+
};
|
|
13
|
+
/** Source and meaning of one provider issue. */
|
|
14
|
+
type ArcaFiscalIssue = {
|
|
15
|
+
service: ArcaFiscalService;
|
|
16
|
+
operation: string;
|
|
17
|
+
source: "error" | "observation";
|
|
18
|
+
category: "business" | "infrastructure" | "observation" | "unknown";
|
|
19
|
+
code?: string;
|
|
20
|
+
message: string;
|
|
21
|
+
resultLevel?: ArcaFiscalResultLevel;
|
|
22
|
+
};
|
|
23
|
+
/** Why an authorization response cannot prove approval or rejection. */
|
|
24
|
+
type ArcaAuthorizationIndeterminateReason = "authentication_rejected" | "transport_error" | "soap_fault" | "invalid_response" | "incomplete_response" | "contradictory_response" | "unexpected_error";
|
|
25
|
+
/** Safe authentication evidence attached to an exact authorization outcome. */
|
|
26
|
+
type ArcaAuthenticationEvidence = {
|
|
27
|
+
code: "ARCA_AUTHENTICATION_ERROR";
|
|
28
|
+
reason: ArcaAuthenticationReason;
|
|
29
|
+
providerCode?: string | number;
|
|
30
|
+
};
|
|
31
|
+
type ArcaAuthorizationEvidenceBase<TService extends ArcaFiscalService = ArcaFiscalService> = {
|
|
32
|
+
service: TService;
|
|
33
|
+
operation: string;
|
|
34
|
+
results: ArcaFiscalResults;
|
|
35
|
+
errors: ArcaFiscalIssue[];
|
|
36
|
+
observations: ArcaFiscalIssue[];
|
|
37
|
+
raw?: Record<string, unknown>;
|
|
38
|
+
};
|
|
39
|
+
/** Structured evidence returned by one exact voucher authorization attempt. */
|
|
40
|
+
type ArcaAuthorizationOutcome<TService extends ArcaFiscalService = ArcaFiscalService> = (ArcaAuthorizationEvidenceBase<TService> & {
|
|
41
|
+
kind: "authorized";
|
|
42
|
+
result: "A" | "O";
|
|
43
|
+
resultLevel: ArcaFiscalResultLevel;
|
|
44
|
+
cae: string;
|
|
45
|
+
caeExpiry?: string;
|
|
46
|
+
voucherNumber: number;
|
|
47
|
+
}) | (ArcaAuthorizationEvidenceBase<TService> & {
|
|
48
|
+
kind: "rejected";
|
|
49
|
+
result: "R";
|
|
50
|
+
resultLevel: ArcaFiscalResultLevel;
|
|
51
|
+
}) | (ArcaAuthorizationEvidenceBase<TService> & {
|
|
52
|
+
kind: "indeterminate";
|
|
53
|
+
reason: ArcaAuthorizationIndeterminateReason;
|
|
54
|
+
authentication?: ArcaAuthenticationEvidence;
|
|
55
|
+
result?: string;
|
|
56
|
+
resultLevel?: ArcaFiscalResultLevel;
|
|
57
|
+
cae?: string;
|
|
58
|
+
caeExpiry?: string;
|
|
59
|
+
voucherNumber?: number;
|
|
60
|
+
});
|
|
61
|
+
/** Structured result of consulting one exact voucher number. */
|
|
62
|
+
type ArcaVoucherLookupResult<TVoucher, TService extends ArcaFiscalService = ArcaFiscalService> = {
|
|
63
|
+
kind: "found";
|
|
64
|
+
service: TService;
|
|
65
|
+
operation: string;
|
|
66
|
+
voucher: TVoucher;
|
|
67
|
+
observations: ArcaFiscalIssue[];
|
|
68
|
+
raw: Record<string, unknown>;
|
|
69
|
+
} | {
|
|
70
|
+
kind: "not_found";
|
|
71
|
+
service: TService;
|
|
72
|
+
operation: string;
|
|
73
|
+
errors: ArcaFiscalIssue[];
|
|
74
|
+
observations: ArcaFiscalIssue[];
|
|
75
|
+
raw: Record<string, unknown>;
|
|
76
|
+
};
|
|
77
|
+
|
|
3
78
|
/** Base error class for all ARCA-related errors. */
|
|
4
79
|
declare class ArcaError extends Error {
|
|
5
80
|
readonly code: string;
|
|
@@ -110,80 +185,13 @@ declare class ArcaServiceError extends ArcaError {
|
|
|
110
185
|
issues?: readonly ArcaFiscalIssue[];
|
|
111
186
|
});
|
|
112
187
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
/** Location of a structured authorization result in the service response. */
|
|
117
|
-
type ArcaFiscalResultLevel = "header" | "detail" | "operation";
|
|
118
|
-
/** Every structured result field exposed by one provider response. */
|
|
119
|
-
type ArcaFiscalResults = {
|
|
120
|
-
header?: string;
|
|
121
|
-
detail?: string;
|
|
122
|
-
operation?: string;
|
|
123
|
-
};
|
|
124
|
-
/** Source and meaning of one provider issue. */
|
|
125
|
-
type ArcaFiscalIssue = {
|
|
126
|
-
service: ArcaFiscalService;
|
|
127
|
-
operation: string;
|
|
128
|
-
source: "error" | "observation";
|
|
129
|
-
category: "business" | "infrastructure" | "observation" | "unknown";
|
|
130
|
-
code?: string;
|
|
188
|
+
/** Narrow error evidence: never includes a cause, raw response or stack. */
|
|
189
|
+
type ArcaSafeErrorMetadata = {
|
|
190
|
+
name: string;
|
|
131
191
|
message: string;
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
/** Why an authorization response cannot prove approval or rejection. */
|
|
135
|
-
type ArcaAuthorizationIndeterminateReason = "authentication_rejected" | "transport_error" | "soap_fault" | "invalid_response" | "incomplete_response" | "contradictory_response" | "unexpected_error";
|
|
136
|
-
/** Safe authentication evidence attached to an exact authorization outcome. */
|
|
137
|
-
type ArcaAuthenticationEvidence = {
|
|
138
|
-
code: "ARCA_AUTHENTICATION_ERROR";
|
|
139
|
-
reason: ArcaAuthenticationReason;
|
|
140
|
-
providerCode?: string | number;
|
|
141
|
-
};
|
|
142
|
-
type ArcaAuthorizationEvidenceBase<TService extends ArcaFiscalService = ArcaFiscalService> = {
|
|
143
|
-
service: TService;
|
|
144
|
-
operation: string;
|
|
145
|
-
results: ArcaFiscalResults;
|
|
146
|
-
errors: ArcaFiscalIssue[];
|
|
147
|
-
observations: ArcaFiscalIssue[];
|
|
148
|
-
raw?: Record<string, unknown>;
|
|
149
|
-
};
|
|
150
|
-
/** Structured evidence returned by one exact voucher authorization attempt. */
|
|
151
|
-
type ArcaAuthorizationOutcome<TService extends ArcaFiscalService = ArcaFiscalService> = (ArcaAuthorizationEvidenceBase<TService> & {
|
|
152
|
-
kind: "authorized";
|
|
153
|
-
result: "A" | "O";
|
|
154
|
-
resultLevel: ArcaFiscalResultLevel;
|
|
155
|
-
cae: string;
|
|
156
|
-
caeExpiry?: string;
|
|
157
|
-
voucherNumber: number;
|
|
158
|
-
}) | (ArcaAuthorizationEvidenceBase<TService> & {
|
|
159
|
-
kind: "rejected";
|
|
160
|
-
result: "R";
|
|
161
|
-
resultLevel: ArcaFiscalResultLevel;
|
|
162
|
-
}) | (ArcaAuthorizationEvidenceBase<TService> & {
|
|
163
|
-
kind: "indeterminate";
|
|
164
|
-
reason: ArcaAuthorizationIndeterminateReason;
|
|
165
|
-
authentication?: ArcaAuthenticationEvidence;
|
|
166
|
-
result?: string;
|
|
167
|
-
resultLevel?: ArcaFiscalResultLevel;
|
|
168
|
-
cae?: string;
|
|
169
|
-
caeExpiry?: string;
|
|
170
|
-
voucherNumber?: number;
|
|
171
|
-
});
|
|
172
|
-
/** Structured result of consulting one exact voucher number. */
|
|
173
|
-
type ArcaVoucherLookupResult<TVoucher, TService extends ArcaFiscalService = ArcaFiscalService> = {
|
|
174
|
-
kind: "found";
|
|
175
|
-
service: TService;
|
|
176
|
-
operation: string;
|
|
177
|
-
voucher: TVoucher;
|
|
178
|
-
observations: ArcaFiscalIssue[];
|
|
179
|
-
raw: Record<string, unknown>;
|
|
180
|
-
} | {
|
|
181
|
-
kind: "not_found";
|
|
182
|
-
service: TService;
|
|
183
|
-
operation: string;
|
|
184
|
-
errors: ArcaFiscalIssue[];
|
|
185
|
-
observations: ArcaFiscalIssue[];
|
|
186
|
-
raw: Record<string, unknown>;
|
|
192
|
+
code?: string;
|
|
193
|
+
statusCode?: number;
|
|
187
194
|
};
|
|
195
|
+
declare function toArcaSafeErrorMetadata(error: unknown): ArcaSafeErrorMetadata;
|
|
188
196
|
|
|
189
|
-
export {
|
|
197
|
+
export { type ArcaAuthorizationOutcome as A, type ArcaFiscalIssue as a, type ArcaSafeErrorMetadata as b, ArcaAuthenticationError as c, type ArcaAuthenticationErrorOptions as d, type ArcaAuthenticationEvidence as e, type ArcaAuthenticationReason as f, type ArcaAuthorizationIndeterminateReason as g, ArcaConfigurationError as h, ArcaError as i, type ArcaFiscalResultLevel as j, type ArcaFiscalResults as k, type ArcaFiscalService as l, ArcaInputError as m, type ArcaInputErrorCode as n, type ArcaInputErrorOptions as o, ArcaInvalidSoapResponseError as p, ArcaServiceError as q, ArcaSoapFaultError as r, ArcaTransportError as s, type ArcaVoucherLookupResult as t, isArcaAuthenticationError as u, toArcaSafeErrorMetadata as v };
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import './types-BXq0da71.js';
|
|
2
|
-
export {
|
|
2
|
+
export { c as ArcaAuthenticationError, d as ArcaAuthenticationErrorOptions, f as ArcaAuthenticationReason, h as ArcaConfigurationError, i as ArcaError, m as ArcaInputError, n as ArcaInputErrorCode, o as ArcaInputErrorOptions, p as ArcaInvalidSoapResponseError, b as ArcaSafeErrorMetadata, q as ArcaServiceError, r as ArcaSoapFaultError, s as ArcaTransportError, u as isArcaAuthenticationError, v as toArcaSafeErrorMetadata } from './errors-B0uouRzR.js';
|
package/dist/errors.mjs
CHANGED
|
@@ -7,8 +7,9 @@ import {
|
|
|
7
7
|
ArcaServiceError,
|
|
8
8
|
ArcaSoapFaultError,
|
|
9
9
|
ArcaTransportError,
|
|
10
|
-
isArcaAuthenticationError
|
|
11
|
-
|
|
10
|
+
isArcaAuthenticationError,
|
|
11
|
+
toArcaSafeErrorMetadata
|
|
12
|
+
} from "./chunk-HUT3PFKF.mjs";
|
|
12
13
|
export {
|
|
13
14
|
ArcaAuthenticationError,
|
|
14
15
|
ArcaConfigurationError,
|
|
@@ -18,6 +19,7 @@ export {
|
|
|
18
19
|
ArcaServiceError,
|
|
19
20
|
ArcaSoapFaultError,
|
|
20
21
|
ArcaTransportError,
|
|
21
|
-
isArcaAuthenticationError
|
|
22
|
+
isArcaAuthenticationError,
|
|
23
|
+
toArcaSafeErrorMetadata
|
|
22
24
|
};
|
|
23
25
|
//# sourceMappingURL=errors.mjs.map
|
package/dist/index.d.ts
CHANGED
|
@@ -2,13 +2,206 @@ import { f as ArcaEnvironment, g as ArcaClientConfig, h as ArcaWsaaSessionStore
|
|
|
2
2
|
export { e as ArcaAuthCredentials, d as ArcaAuthOptions, i as ArcaLogLevel, j as ArcaLoggerConfig, k as ArcaPadronServiceName, l as ArcaRepresentedTaxId, A as ArcaServiceName, m as ArcaServiceTarget, c as ArcaWsaaServiceId, n as ArcaWsaaSessionKey } from './types-BXq0da71.js';
|
|
3
3
|
import { PadronService } from './padron.js';
|
|
4
4
|
export { CreatePadronServiceOptions, PadronTaxIdLookupResult, PadronTaxpayerResult, createPadronService } from './padron.js';
|
|
5
|
-
import {
|
|
6
|
-
export {
|
|
5
|
+
import { VoucherClass, ReceiverCondition } from './constants.js';
|
|
6
|
+
export { ARCA_FINAL_CONSUMER_IDENTIFICATION_THRESHOLD_MINOR_UNITS, ARCA_INVOICE_CLASS_BY_ISSUER, ARCA_ISSUER_CONDITION_IDS, ARCA_RECEIVER_CONDITION_IDS, IssuerCondition } from './constants.js';
|
|
7
|
+
import { A as ArcaAuthorizationOutcome, a as ArcaFiscalIssue, b as ArcaSafeErrorMetadata } from './errors-B0uouRzR.js';
|
|
8
|
+
export { c as ArcaAuthenticationError, d as ArcaAuthenticationErrorOptions, e as ArcaAuthenticationEvidence, f as ArcaAuthenticationReason, g as ArcaAuthorizationIndeterminateReason, h as ArcaConfigurationError, i as ArcaError, j as ArcaFiscalResultLevel, k as ArcaFiscalResults, l as ArcaFiscalService, m as ArcaInputError, n as ArcaInputErrorCode, o as ArcaInputErrorOptions, p as ArcaInvalidSoapResponseError, q as ArcaServiceError, r as ArcaSoapFaultError, s as ArcaTransportError, t as ArcaVoucherLookupResult, u as isArcaAuthenticationError, v as toArcaSafeErrorMetadata } from './errors-B0uouRzR.js';
|
|
9
|
+
import { S as SupportedVatRate, W as WsfeVoucherInput, a as WsfeVoucherInfo, b as WsfeDateInput, c as WsfeService } from './wsfe-CG_erq7V.js';
|
|
10
|
+
export { B as BuildFacturaBInput, d as BuildFacturaCInput, C as CreateWsfeServiceOptions, e as WsfeActivity, f as WsfeActivityType, g as WsfeAssociatedPeriod, h as WsfeAssociatedVoucher, i as WsfeAuthorizationOutcome, j as WsfeAuthorizationResult, k as WsfeAuthorizeVoucherInput, l as WsfeBuilderCurrencyInput, m as WsfeBuilderVatRate, n as WsfeBuyer, o as WsfeCatalogEntry, p as WsfeCurrencyType, q as WsfeOptionalField, r as WsfeQuotation, s as WsfeReceiverVatCondition, t as WsfeSalesPoint, u as WsfeServerStatus, v as WsfeTax, w as WsfeVatRate, x as WsfeVoucherLookupResult, y as buildFacturaB, z as buildFacturaC, A as createWsfeService } from './wsfe-CG_erq7V.js';
|
|
7
11
|
import { WsmtxcaService } from './wsmtxca.js';
|
|
8
12
|
export { CreateWsmtxcaServiceOptions, WsmtxcaAuthorizationOutcome, WsmtxcaAuthorizationResult, WsmtxcaAuthorizeVoucherInput, WsmtxcaLastAuthorizedVoucherResult, WsmtxcaSalesPoint, WsmtxcaSalesPointsResult, WsmtxcaVoucherInfo, WsmtxcaVoucherLookupOutcome, WsmtxcaVoucherLookupResult, createWsmtxcaService } from './wsmtxca.js';
|
|
9
|
-
export { A as ArcaAuthenticationError, a as ArcaAuthenticationErrorOptions, b as ArcaAuthenticationEvidence, c as ArcaAuthenticationReason, d as ArcaAuthorizationIndeterminateReason, e as ArcaAuthorizationOutcome, f as ArcaConfigurationError, g as ArcaError, h as ArcaFiscalIssue, i as ArcaFiscalResultLevel, j as ArcaFiscalResults, k as ArcaFiscalService, l as ArcaInputError, m as ArcaInputErrorCode, n as ArcaInputErrorOptions, o as ArcaInvalidSoapResponseError, p as ArcaServiceError, q as ArcaSoapFaultError, r as ArcaTransportError, s as ArcaVoucherLookupResult, t as isArcaAuthenticationError } from './fiscal-evidence-BQuBbJ3h.js';
|
|
10
13
|
import './index-CVpygFb0.js';
|
|
11
14
|
|
|
15
|
+
type VatRate = SupportedVatRate | "exempt" | "untaxed";
|
|
16
|
+
type VatItem = {
|
|
17
|
+
net: number;
|
|
18
|
+
gross?: never;
|
|
19
|
+
amount?: never;
|
|
20
|
+
vat: VatRate;
|
|
21
|
+
} | {
|
|
22
|
+
gross: number;
|
|
23
|
+
net?: never;
|
|
24
|
+
amount?: never;
|
|
25
|
+
vat: VatRate;
|
|
26
|
+
};
|
|
27
|
+
type AmountItem = {
|
|
28
|
+
amount: number;
|
|
29
|
+
vat?: never;
|
|
30
|
+
net?: never;
|
|
31
|
+
gross?: never;
|
|
32
|
+
};
|
|
33
|
+
type IssueAmounts = {
|
|
34
|
+
computedTotal: number;
|
|
35
|
+
sentTotal: number;
|
|
36
|
+
vatAdjustment: number;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
type VoucherCoordinates = {
|
|
40
|
+
salesPoint: number;
|
|
41
|
+
voucherType: number;
|
|
42
|
+
number: number;
|
|
43
|
+
};
|
|
44
|
+
/** Raw-free consultation evidence. Missing provider fields remain absent. */
|
|
45
|
+
type VoucherSummary = {
|
|
46
|
+
number: number;
|
|
47
|
+
salesPoint?: number;
|
|
48
|
+
voucherType?: number;
|
|
49
|
+
date?: string;
|
|
50
|
+
concept?: number;
|
|
51
|
+
documentType?: number;
|
|
52
|
+
documentNumber?: string;
|
|
53
|
+
receiverVatConditionId?: number;
|
|
54
|
+
currencyId?: string;
|
|
55
|
+
exchangeRate?: number;
|
|
56
|
+
totalAmount?: number;
|
|
57
|
+
netAmount?: number;
|
|
58
|
+
vatAmount?: number;
|
|
59
|
+
exemptAmount?: number;
|
|
60
|
+
nonTaxableAmount?: number;
|
|
61
|
+
taxAmount?: number;
|
|
62
|
+
vatRates?: {
|
|
63
|
+
id: number;
|
|
64
|
+
baseAmount: number;
|
|
65
|
+
amount: number;
|
|
66
|
+
}[];
|
|
67
|
+
serviceStartDate?: string;
|
|
68
|
+
serviceEndDate?: string;
|
|
69
|
+
paymentDueDate?: string;
|
|
70
|
+
result?: string;
|
|
71
|
+
cae?: string;
|
|
72
|
+
caeExpiry?: string;
|
|
73
|
+
};
|
|
74
|
+
type WsfeIdentityMatch = {
|
|
75
|
+
matches: true;
|
|
76
|
+
} | {
|
|
77
|
+
matches: false;
|
|
78
|
+
evidence: "conflict" | "incomplete";
|
|
79
|
+
reason: string;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Compares the invoice subset supported by vouchers.issue(). This proves
|
|
83
|
+
* consistency, not authorship; callers must serialize writers per taxpayer,
|
|
84
|
+
* sales point and voucher type. Unsupported exact-API extensions are incomplete.
|
|
85
|
+
*/
|
|
86
|
+
declare function matchWsfeVoucherIdentity(sent: WsfeVoucherInput, number: number, found: WsfeVoucherInfo): WsfeIdentityMatch;
|
|
87
|
+
|
|
88
|
+
type IssueOptions = {
|
|
89
|
+
representedTaxId?: number | string;
|
|
90
|
+
forceRefresh?: boolean;
|
|
91
|
+
include?: {
|
|
92
|
+
raw?: boolean;
|
|
93
|
+
exactInput?: boolean;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
type IssuedVoucher = VoucherCoordinates & {
|
|
97
|
+
voucherClass: VoucherClass;
|
|
98
|
+
date: string;
|
|
99
|
+
cae: string;
|
|
100
|
+
caeExpiry: string;
|
|
101
|
+
amounts: IssueAmounts;
|
|
102
|
+
};
|
|
103
|
+
type WithRaw<T, O extends IssueOptions> = T & (true extends NonNullable<O["include"]>["raw"] ? {
|
|
104
|
+
raw?: Record<string, unknown>;
|
|
105
|
+
} : unknown);
|
|
106
|
+
type WithSent<O extends IssueOptions> = O extends {
|
|
107
|
+
include: {
|
|
108
|
+
exactInput: true;
|
|
109
|
+
};
|
|
110
|
+
} ? {
|
|
111
|
+
sent: WsfeVoucherInput;
|
|
112
|
+
} : true extends NonNullable<O["include"]>["exactInput"] ? {
|
|
113
|
+
sent?: WsfeVoucherInput;
|
|
114
|
+
} : unknown;
|
|
115
|
+
type Evidence<K extends ArcaAuthorizationOutcome<"wsfe">["kind"], O extends IssueOptions> = WithRaw<Omit<Extract<ArcaAuthorizationOutcome<"wsfe">, {
|
|
116
|
+
kind: K;
|
|
117
|
+
}>, "raw">, O>;
|
|
118
|
+
/** Fiscal outcomes are returned, never thrown or automatically resubmitted. */
|
|
119
|
+
type IssueOutcome<O extends IssueOptions = {
|
|
120
|
+
include?: never;
|
|
121
|
+
}> = ({
|
|
122
|
+
kind: "authorized";
|
|
123
|
+
recoveredByMatch: false;
|
|
124
|
+
voucher: IssuedVoucher;
|
|
125
|
+
authorization: Evidence<"authorized", O>;
|
|
126
|
+
} & WithSent<O>) | ({
|
|
127
|
+
kind: "authorized";
|
|
128
|
+
recoveredByMatch: true;
|
|
129
|
+
voucher: IssuedVoucher;
|
|
130
|
+
attempt: Evidence<"indeterminate", O>;
|
|
131
|
+
lookup: WithRaw<VoucherSummary, O>;
|
|
132
|
+
} & WithSent<O>) | {
|
|
133
|
+
kind: "rejected";
|
|
134
|
+
attempted: VoucherCoordinates;
|
|
135
|
+
issues: ArcaFiscalIssue[];
|
|
136
|
+
authorization: Evidence<"rejected", O>;
|
|
137
|
+
} | {
|
|
138
|
+
kind: "indeterminate";
|
|
139
|
+
attempted: VoucherCoordinates;
|
|
140
|
+
attempt: Evidence<"indeterminate", O>;
|
|
141
|
+
lookup: WithRaw<{
|
|
142
|
+
kind: "not_found";
|
|
143
|
+
}, O> | WithRaw<{
|
|
144
|
+
kind: "incomplete";
|
|
145
|
+
reason: string;
|
|
146
|
+
}, O> | {
|
|
147
|
+
kind: "failed";
|
|
148
|
+
error: ArcaSafeErrorMetadata;
|
|
149
|
+
};
|
|
150
|
+
} | {
|
|
151
|
+
kind: "conflict";
|
|
152
|
+
attempted: VoucherCoordinates;
|
|
153
|
+
attempt: Evidence<"indeterminate", O>;
|
|
154
|
+
found: WithRaw<VoucherSummary, O>;
|
|
155
|
+
reason: string;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
type Receiver = {
|
|
159
|
+
condition: "consumidor_final";
|
|
160
|
+
cuit?: number | string;
|
|
161
|
+
dni?: number | string;
|
|
162
|
+
} | {
|
|
163
|
+
condition: Exclude<ReceiverCondition, "consumidor_final">;
|
|
164
|
+
cuit: number | string;
|
|
165
|
+
dni?: never;
|
|
166
|
+
};
|
|
167
|
+
type IssueCommon = {
|
|
168
|
+
salesPoint: number;
|
|
169
|
+
to: Receiver;
|
|
170
|
+
total?: number;
|
|
171
|
+
date?: WsfeDateInput;
|
|
172
|
+
currency?: "ARS" | "USD";
|
|
173
|
+
exchangeRate?: string;
|
|
174
|
+
service?: {
|
|
175
|
+
from: WsfeDateInput;
|
|
176
|
+
to: WsfeDateInput;
|
|
177
|
+
dueDate: WsfeDateInput;
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
type IssueInput = IssueCommon & ({
|
|
181
|
+
issuer: "responsable_inscripto";
|
|
182
|
+
items: readonly VatItem[];
|
|
183
|
+
} | {
|
|
184
|
+
issuer: "monotributo" | "exento" | "no_alcanzado";
|
|
185
|
+
items: readonly AmountItem[];
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
type VouchersService = {
|
|
189
|
+
/**
|
|
190
|
+
* Single-writer contract: serialize calls per (representedTaxId, salesPoint,
|
|
191
|
+
* voucherType), including concurrent promises in one process. The SDK does not
|
|
192
|
+
* coordinate writers; uncoordinated calls collide on ARCA 10016. Servers and
|
|
193
|
+
* queues must persist attempts and use wsfe.authorizeVoucherOutcome() directly.
|
|
194
|
+
* See the "does not serialize concurrent calls" test in services/vouchers.test.ts.
|
|
195
|
+
*
|
|
196
|
+
* One next-number read, one authorization attempt (zero transport retries), and
|
|
197
|
+
* at most one identity-matched lookup after indeterminate. Never resubmits.
|
|
198
|
+
* Local validation and next-number read failures throw before authorization.
|
|
199
|
+
*/
|
|
200
|
+
issue<O extends IssueOptions = {
|
|
201
|
+
include?: never;
|
|
202
|
+
}>(input: IssueInput, options?: O): Promise<IssueOutcome<O>>;
|
|
203
|
+
};
|
|
204
|
+
|
|
12
205
|
/** Immutable, credential-free operational view of an ARCA client configuration. */
|
|
13
206
|
type ArcaClientConfigView = Readonly<{
|
|
14
207
|
taxId: string;
|
|
@@ -21,13 +214,14 @@ type ArcaClientConfigView = Readonly<{
|
|
|
21
214
|
type ArcaClient = {
|
|
22
215
|
readonly config: ArcaClientConfigView;
|
|
23
216
|
wsfe: WsfeService;
|
|
217
|
+
vouchers: VouchersService;
|
|
24
218
|
wsmtxca: WsmtxcaService;
|
|
25
219
|
padron: PadronService;
|
|
26
220
|
};
|
|
27
221
|
/**
|
|
28
222
|
* Creates an ARCA client from the given configuration.
|
|
29
223
|
* Validates the config, wires WSAA authentication and SOAP transport,
|
|
30
|
-
* and returns an object with `.wsfe`, `.wsmtxca`, and `.padron` service modules.
|
|
224
|
+
* and returns an object with `.vouchers`, `.wsfe`, `.wsmtxca`, and `.padron` service modules.
|
|
31
225
|
*
|
|
32
226
|
* @throws {ArcaConfigurationError} When the config is missing or invalid.
|
|
33
227
|
*/
|
|
@@ -67,4 +261,4 @@ declare function assertArcaClientConfig(config: ArcaClientConfig): void;
|
|
|
67
261
|
|
|
68
262
|
declare function createMemoryWsaaSessionStore(): ArcaWsaaSessionStore;
|
|
69
263
|
|
|
70
|
-
export { ARCA_ENVIRONMENTS, ARCA_ENV_VARIABLES, type ArcaClient, ArcaClientConfig, type ArcaClientConfigView, ArcaEnvironment, ArcaWsaaSessionStore, type CreateArcaClientConfigFromEnvOptions, PadronService, WsfeService, WsmtxcaService, assertArcaClientConfig, createArcaClient, createArcaClientConfigFromEnv, createMemoryWsaaSessionStore, resolveArcaEnvironment };
|
|
264
|
+
export { ARCA_ENVIRONMENTS, ARCA_ENV_VARIABLES, type AmountItem, ArcaAuthorizationOutcome, type ArcaClient, ArcaClientConfig, type ArcaClientConfigView, ArcaEnvironment, ArcaFiscalIssue, ArcaSafeErrorMetadata, ArcaWsaaSessionStore, type CreateArcaClientConfigFromEnvOptions, type IssueAmounts, type IssueCommon, type IssueInput, type IssueOptions, type IssueOutcome, type IssuedVoucher, PadronService, type Receiver, ReceiverCondition, type VatItem, type VatRate, VoucherClass, type VoucherCoordinates, type VoucherSummary, type VouchersService, WsfeDateInput, type WsfeIdentityMatch, WsfeService, WsfeVoucherInfo, WsfeVoucherInput, WsmtxcaService, assertArcaClientConfig, createArcaClient, createArcaClientConfigFromEnv, createMemoryWsaaSessionStore, matchWsfeVoucherIdentity, resolveArcaEnvironment };
|