@facturacr/atv-sdk 1.1.0 → 1.2.1
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/dist/src/ATV/useCases/createReceptorMessage/index.d.ts +10 -1
- package/dist/src/ATV/useCases/createReceptorMessage/index.js +11 -12
- package/dist/src/ATV/useCases/createReceptorMessage/index.js.map +1 -1
- package/examples/atvAccept.ts +13 -2
- package/package.json +1 -1
- package/src/ATV/useCases/createReceptorMessage/index.ts +21 -13
|
@@ -2,7 +2,16 @@ import { AceptationStates } from "@src/ATV/core/types";
|
|
|
2
2
|
import { Command } from "../createDocument/types";
|
|
3
3
|
import { ATV } from "@src/ATV";
|
|
4
4
|
export type CreateReceptorMessageCommandInput = {
|
|
5
|
-
|
|
5
|
+
clave: string;
|
|
6
|
+
emitterIdentifier: string;
|
|
7
|
+
emitterIdentifierType: string;
|
|
8
|
+
receptorIdentifier: string;
|
|
9
|
+
receptorIdentifierType: string;
|
|
10
|
+
documentIssueDate: Date;
|
|
11
|
+
activityCode: string;
|
|
12
|
+
taxCondition: string;
|
|
13
|
+
totalTaxes: number;
|
|
14
|
+
totalSale: number;
|
|
6
15
|
aceptationState: AceptationStates;
|
|
7
16
|
aceptationDetailMessage: string;
|
|
8
17
|
branch: string;
|
|
@@ -83,7 +83,6 @@ class CreateReceptorMessageCommand {
|
|
|
83
83
|
}
|
|
84
84
|
processDocument(input) {
|
|
85
85
|
try {
|
|
86
|
-
const electronillBillRaw = (0, genXML_1.parseElectronicBillXML)(input.receivedDocument);
|
|
87
86
|
const receptorConsecutive = ReceptorConsecutive_1.ReceptorConsecutive.create({
|
|
88
87
|
branch: input.branch,
|
|
89
88
|
terminal: input.terminal,
|
|
@@ -91,23 +90,23 @@ class CreateReceptorMessageCommand {
|
|
|
91
90
|
consecutive: input.consecutive,
|
|
92
91
|
});
|
|
93
92
|
return {
|
|
94
|
-
clave:
|
|
95
|
-
emitterIdentifier:
|
|
96
|
-
emitterIdentifierType:
|
|
97
|
-
receptorIdentifier:
|
|
98
|
-
receptorIdentifierType:
|
|
99
|
-
documentIssueDate:
|
|
100
|
-
activityCode:
|
|
101
|
-
taxCondition:
|
|
102
|
-
totalTaxes:
|
|
103
|
-
totalSale:
|
|
93
|
+
clave: input.clave,
|
|
94
|
+
emitterIdentifier: input.emitterIdentifier,
|
|
95
|
+
emitterIdentifierType: input.emitterIdentifier,
|
|
96
|
+
receptorIdentifier: input.receptorIdentifier,
|
|
97
|
+
receptorIdentifierType: input.receptorIdentifierType,
|
|
98
|
+
documentIssueDate: input.documentIssueDate,
|
|
99
|
+
activityCode: input.activityCode,
|
|
100
|
+
taxCondition: input.taxCondition,
|
|
101
|
+
totalTaxes: input.totalTaxes,
|
|
102
|
+
totalSale: input.totalSale,
|
|
104
103
|
aceptationState: input.aceptationState,
|
|
105
104
|
aceptationDetailMessage: input.aceptationDetailMessage,
|
|
106
105
|
receptorConcecutive: receptorConsecutive.value
|
|
107
106
|
};
|
|
108
107
|
}
|
|
109
108
|
catch (err) {
|
|
110
|
-
throw new Error('Error parsing the document');
|
|
109
|
+
throw new Error('Error parsing the document', err);
|
|
111
110
|
}
|
|
112
111
|
}
|
|
113
112
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/ATV/useCases/createReceptorMessage/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAA6E;AAC7E,6DAA8E;AAC9E,gDAAiE;AAGjE,wEAAwE;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/ATV/useCases/createReceptorMessage/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAA6E;AAC7E,6DAA8E;AAC9E,gDAAiE;AAGjE,wEAAwE;AAyBxE,MAAM,OAAO,GAA4C;IACrD,IAAI,EAAE;QACJ,UAAU,EAAE,yDAAyD;KACtE;IACD,GAAG,EAAE;QACH,UAAU,EAAE,2EAA2E;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Ae,EAAE,KAAK,CAAC,eAAe;gBACtC,uBAAuB,EAAE,KAAK,CAAC,uBAAuB;gBACtD,mBAAmB,EAAE,mBAAmB,CAAC,KAAK;aACjD,CAAA;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAA;QACtD,CAAC;IACL,CAAC;CACJ;AAzFD,oEAyFC"}
|
package/examples/atvAccept.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import fs from 'fs'
|
|
2
2
|
import { createDocumentInputExample } from '@test/stubs/createDocument.data'
|
|
3
|
-
import { ATV
|
|
3
|
+
import { ATV } from '../dist/src'
|
|
4
4
|
import { PersonProps } from 'dist/src/ATV/core/Person'
|
|
5
5
|
import { AceptationStates } from 'dist/src/ATV/core/types'
|
|
6
|
+
import { parseElectronicBillXML } from '@src/lib/genXML'
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
const IS_STG = process.env.IS_STG
|
|
@@ -50,10 +51,20 @@ async function main(): Promise<void> {
|
|
|
50
51
|
username: USERNAME_TEST,
|
|
51
52
|
password: PASSWORD_TEST
|
|
52
53
|
})
|
|
54
|
+
const electronillBillRaw = parseElectronicBillXML(receivedDocumentXML)
|
|
53
55
|
const { command, extraData } = await atv.createReceptorMessage({
|
|
54
56
|
aceptationState: AceptationStates.ACCEPTED,
|
|
55
57
|
aceptationDetailMessage: 'Accepted',
|
|
56
|
-
|
|
58
|
+
clave: electronillBillRaw.Clave,
|
|
59
|
+
emitterIdentifier: electronillBillRaw.Emisor.Identificacion.Numero,
|
|
60
|
+
emitterIdentifierType: electronillBillRaw.Emisor.Identificacion.Tipo,
|
|
61
|
+
receptorIdentifier: electronillBillRaw.Receptor.Identificacion.Numero,
|
|
62
|
+
receptorIdentifierType: electronillBillRaw.Receptor.Identificacion.Tipo,
|
|
63
|
+
documentIssueDate: new Date(electronillBillRaw.FechaEmision),
|
|
64
|
+
activityCode: electronillBillRaw.CodigoActividad,
|
|
65
|
+
taxCondition: electronillBillRaw.CondicionVenta,
|
|
66
|
+
totalTaxes: electronillBillRaw.ResumenFactura.TotalImpuesto,
|
|
67
|
+
totalSale: electronillBillRaw.ResumenFactura.TotalVenta,
|
|
57
68
|
branch: '01',
|
|
58
69
|
terminal: '01',
|
|
59
70
|
consecutive: '01',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@facturacr/atv-sdk",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Librería (SDK) de Javascript/NodeJS para acceder al API de Administración Tributaria Virtual (ATV) del Ministerio de Hacienda.",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -6,7 +6,16 @@ import { ATV } from "@src/ATV";
|
|
|
6
6
|
import { ReceptorConsecutive } from "@src/ATV/core/ReceptorConsecutive";
|
|
7
7
|
|
|
8
8
|
export type CreateReceptorMessageCommandInput = {
|
|
9
|
-
|
|
9
|
+
clave: string;
|
|
10
|
+
emitterIdentifier: string;
|
|
11
|
+
emitterIdentifierType: string;
|
|
12
|
+
receptorIdentifier: string;
|
|
13
|
+
receptorIdentifierType: string;
|
|
14
|
+
documentIssueDate: Date;
|
|
15
|
+
activityCode: string;
|
|
16
|
+
taxCondition: string;
|
|
17
|
+
totalTaxes: number;
|
|
18
|
+
totalSale: number;
|
|
10
19
|
aceptationState: AceptationStates;
|
|
11
20
|
aceptationDetailMessage: string;
|
|
12
21
|
branch: string;
|
|
@@ -92,7 +101,6 @@ export class CreateReceptorMessageCommand {
|
|
|
92
101
|
|
|
93
102
|
private processDocument(input: CreateReceptorMessageCommandInput): ReceptorMessageProps {
|
|
94
103
|
try {
|
|
95
|
-
const electronillBillRaw = parseElectronicBillXML(input.receivedDocument)
|
|
96
104
|
const receptorConsecutive = ReceptorConsecutive.create({
|
|
97
105
|
branch: input.branch,
|
|
98
106
|
terminal: input.terminal,
|
|
@@ -100,22 +108,22 @@ export class CreateReceptorMessageCommand {
|
|
|
100
108
|
consecutive: input.consecutive,
|
|
101
109
|
})
|
|
102
110
|
return {
|
|
103
|
-
clave:
|
|
104
|
-
emitterIdentifier:
|
|
105
|
-
emitterIdentifierType:
|
|
106
|
-
receptorIdentifier:
|
|
107
|
-
receptorIdentifierType:
|
|
108
|
-
documentIssueDate:
|
|
109
|
-
activityCode:
|
|
110
|
-
taxCondition:
|
|
111
|
-
totalTaxes:
|
|
112
|
-
totalSale:
|
|
111
|
+
clave: input.clave,
|
|
112
|
+
emitterIdentifier: input.emitterIdentifier,
|
|
113
|
+
emitterIdentifierType: input.emitterIdentifier,
|
|
114
|
+
receptorIdentifier: input.receptorIdentifier,
|
|
115
|
+
receptorIdentifierType: input.receptorIdentifierType,
|
|
116
|
+
documentIssueDate: input.documentIssueDate,
|
|
117
|
+
activityCode: input.activityCode,
|
|
118
|
+
taxCondition: input.taxCondition,
|
|
119
|
+
totalTaxes: input.totalTaxes,
|
|
120
|
+
totalSale: input.totalSale,
|
|
113
121
|
aceptationState: input.aceptationState,
|
|
114
122
|
aceptationDetailMessage: input.aceptationDetailMessage,
|
|
115
123
|
receptorConcecutive: receptorConsecutive.value
|
|
116
124
|
}
|
|
117
125
|
} catch (err) {
|
|
118
|
-
throw new Error('Error parsing the document')
|
|
126
|
+
throw new Error('Error parsing the document', err)
|
|
119
127
|
}
|
|
120
128
|
}
|
|
121
129
|
}
|