@facturacr/atv-sdk 1.0.1 → 1.2.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.
Files changed (58) hide show
  1. package/.github/workflows/publish.yml +10 -12
  2. package/.github/workflows/release-please.yml +17 -0
  3. package/CHANGELOG.md +8 -0
  4. package/dist/src/ATV/core/CreateDocFactory.d.ts +2 -0
  5. package/dist/src/ATV/core/CreateDocFactory.js.map +1 -1
  6. package/dist/src/ATV/core/Person.d.ts +1 -1
  7. package/dist/src/ATV/core/ReceptorConsecutive.d.ts +13 -0
  8. package/dist/src/ATV/core/ReceptorConsecutive.js +21 -0
  9. package/dist/src/ATV/core/ReceptorConsecutive.js.map +1 -0
  10. package/dist/src/ATV/core/documentNames.types.d.ts +1 -1
  11. package/dist/src/ATV/core/types.d.ts +20 -0
  12. package/dist/src/ATV/core/types.js +10 -0
  13. package/dist/src/ATV/core/types.js.map +1 -0
  14. package/dist/src/ATV/index.d.ts +8 -0
  15. package/dist/src/ATV/index.js +5 -0
  16. package/dist/src/ATV/index.js.map +1 -1
  17. package/dist/src/ATV/mappers/billDocToAtv.d.ts +2 -0
  18. package/dist/src/ATV/mappers/billDocToAtv.js +20 -1
  19. package/dist/src/ATV/mappers/billDocToAtv.js.map +1 -1
  20. package/dist/src/ATV/useCases/createDocument/types.d.ts +16 -13
  21. package/dist/src/ATV/useCases/createReceptorMessage/index.d.ts +40 -0
  22. package/dist/src/ATV/useCases/createReceptorMessage/index.js +114 -0
  23. package/dist/src/ATV/useCases/createReceptorMessage/index.js.map +1 -0
  24. package/dist/src/confirmXML.js +1 -1
  25. package/dist/src/confirmXML.js.map +1 -1
  26. package/dist/src/electronicBill.js.map +1 -1
  27. package/dist/src/helpers/comprobantes.js.map +1 -1
  28. package/dist/src/index.d.ts +1 -0
  29. package/dist/src/index.js +3 -1
  30. package/dist/src/index.js.map +1 -1
  31. package/dist/src/lib/genJSON/confirmXML.js +3 -3
  32. package/dist/src/lib/genJSON/confirmXML.js.map +1 -1
  33. package/dist/src/lib/genJSON/index.js.map +1 -1
  34. package/dist/src/lib/genXML/index.d.ts +2 -1
  35. package/dist/src/lib/genXML/index.js +3 -3
  36. package/dist/src/lib/genXML/index.js.map +1 -1
  37. package/dist/src/types/facturaInterfaces.d.ts +19 -2
  38. package/examples/README.md +10 -5
  39. package/examples/atvAccept.ts +87 -0
  40. package/package.json +1 -1
  41. package/src/ATV/core/CreateDocFactory.ts +2 -0
  42. package/src/ATV/core/Person.ts +1 -1
  43. package/src/ATV/core/ReceptorConsecutive.ts +27 -0
  44. package/src/ATV/core/documentNames.types.ts +2 -1
  45. package/src/ATV/core/types.ts +22 -0
  46. package/src/ATV/index.ts +6 -0
  47. package/src/ATV/mappers/billDocToAtv.ts +20 -0
  48. package/src/ATV/useCases/createDocument/types.ts +16 -13
  49. package/src/ATV/useCases/createReceptorMessage/index.ts +129 -0
  50. package/src/confirmXML.ts +2 -2
  51. package/src/electronicBill.ts +2 -1
  52. package/src/helpers/comprobantes.ts +1 -1
  53. package/src/index.ts +1 -1
  54. package/src/lib/genJSON/confirmXML.ts +5 -5
  55. package/src/lib/genJSON/index.ts +1 -1
  56. package/src/lib/genXML/index.ts +2 -1
  57. package/src/types/facturaInterfaces.ts +21 -2
  58. package/examples/confirmXML.ts +0 -76
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/genJSON/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,sCAAwC;AAExC,qBAAqB;AACrB,MAAM,cAAc,GAAG;IACrB,GAAG,EAAE,CAAC;IACN,OAAO,EAAE,aAAa;IACtB,cAAc,EAAE,qBAAqB;IACrC,kBAAkB,EAAE,IAAI;CACzB,CAAA;AAED,SAAS,QAAQ,CAAC,KAAqB;IACrC,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,WAAgB,EAAE,YAAiB,EAAE,EAAE;QAC1D,MAAM,SAAS,GAAG,WAAW,CAAC,UAA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C,aAAa,CAAC,CAAA;IAC7D,MAAM,GAAG,GAAG,eAAe,CAAC,sBAAsB,IAAI,oBAAoB,CAAA;IAC1E,MAAM,IAAI,GAAG;QACX,KAAK,EAAE,KAAK;QACZ,eAAe,EAAE,eAAe,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;QAC3D,iBAAiB,EAAE,WAAW;QAC9B,YAAY,EAAE,IAAI;QAClB,MAAM,EAAE,MAAM;QACd,QAAQ,EAAE,QAAQ;QAClB,cAAc,EAAE,IAAI;QACpB,SAAS,EAAE,IAAI;QACf,eAAe,EAAE;YACf,YAAY,EAAE,KAAK;SACpB;QACD,cAAc,EAAE,YAAY,CAAC,KAAK,CAAC;KACpC,CAAA;IACD,MAAM,OAAO,GAA6B;QACxC,CAAC,GAAG,CAAC,EAAE,IAAI;KACZ,CAAA;IACD,MAAM,GAAG,GAAG,MAAM,IAAA,eAAM,EAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;IAC/C,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA,CAAA"}
@@ -1,7 +1,8 @@
1
+ import { XMLRawDocument } from '@src/types/facturaInterfaces';
1
2
  export declare const objToXML: (xmlStructure: string, obj: object) => string;
2
3
  export declare function genXML(xmlStructure: string, obj: object, options?: {
3
4
  buffer?: string;
4
5
  password?: string;
5
6
  base64?: boolean;
6
7
  }): Promise<string>;
7
- export declare const xmlToJson: (xml: string) => any;
8
+ export declare const parseElectronicBillXML: (xml: string) => XMLRawDocument;
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.xmlToJson = exports.genXML = exports.objToXML = void 0;
15
+ exports.parseElectronicBillXML = exports.genXML = exports.objToXML = void 0;
16
16
  const fast_xml_parser_1 = require("fast-xml-parser");
17
17
  const xmlConfig_1 = require("./xmlConfig");
18
18
  const index_1 = __importDefault(require("./sigXML/index"));
@@ -34,7 +34,7 @@ function genXML(xmlStructure, obj, options) {
34
34
  });
35
35
  }
36
36
  exports.genXML = genXML;
37
- const xmlToJson = (xml) => {
37
+ const parseElectronicBillXML = (xml) => {
38
38
  try {
39
39
  const json = (0, fast_xml_parser_1.parse)(xml, {
40
40
  ignoreAttributes: false,
@@ -47,5 +47,5 @@ const xmlToJson = (xml) => {
47
47
  return null;
48
48
  }
49
49
  };
50
- exports.xmlToJson = xmlToJson;
50
+ exports.parseElectronicBillXML = parseElectronicBillXML;
51
51
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/genXML/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,qDAAkD;AAClD,2CAAuF;AACvF,2DAAiD;AAE1C,MAAM,QAAQ,GAAG,CAAC,YAAoB,EAAE,GAAW,EAAU,EAAE;IACpE,MAAM,MAAM,GAAG,IAAI,2BAAS,CAAC,0BAAc,CAAC,CAAA,CAAC,8BAA8B;IAC3E,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IACnC,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,GAAG,0BAAc,CAAC,YAAY,CAAC,CAAA;IAChD,OAAO,uBAAW,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;AACxC,CAAC,CAAA;AALY,QAAA,QAAQ,YAKpB;AAED,4BAA4B;AAC5B,SAAsB,MAAM,CAAC,YAAoB,EAAE,GAAW,EAAE,OAI7D;;QACD,MAAM,GAAG,GAAG,IAAA,gBAAQ,EAAC,YAAY,EAAE,GAAG,CAAC,CAAA;QACvC,IAAI,CAAC,OAAO;YAAE,OAAO,GAAG,CAAA;QACxB,MAAM,SAAS,GAAG,MAAM,IAAA,eAAM,EAAC,GAAG,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO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eAAM,EAAC,GAAG,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAA;QACrE,OAAO,SAAS,CAAA;IAClB,CAAC;CAAA;AATD,wBASC;AAEM,MAAM,sBAAsB,GAAG,CAAC,GAAW,EAAkB,EAAE;IACpE,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,IAAA,uBAAK,EAAC,GAAG,EAAE;YACtB,gBAAgB,EAAE,KAAK;YACvB,eAAe,EAAE,KAAK;YACtB,cAAc,EAAE,KAAK;SACtB,CAAC,CAAA;QACF,OAAO,IAAI,CAAC,kBAAkB,CAAA;IAChC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC,CAAA;AAXY,QAAA,sBAAsB,0BAWlC"}
@@ -41,7 +41,7 @@ export interface Resumen {
41
41
  export interface Persona {
42
42
  Nombre: string;
43
43
  Identificacion: {
44
- Tipo?: string;
44
+ Tipo?: '01' | '02';
45
45
  Numero: string;
46
46
  };
47
47
  NombreComercial?: string;
@@ -90,8 +90,24 @@ export interface Document {
90
90
  };
91
91
  InformacionReferencia?: InformacionReferencia;
92
92
  }
93
+ export interface XMLRawDocument extends Document {
94
+ }
95
+ interface MensajeReceptor {
96
+ Clave: string;
97
+ NumeroCedulaEmisor: string;
98
+ FechaEmisionDoc: string;
99
+ Mensaje: string;
100
+ DetalleMensaje: string;
101
+ MontoTotalImpuesto: number;
102
+ CodigoActividad: string;
103
+ CondicionImpuesto: string;
104
+ MontoTotalDeGastoAplicable: number;
105
+ TotalFactura: number;
106
+ NumeroCedulaReceptor: string;
107
+ NumeroConsecutivoReceptor: string;
108
+ }
93
109
  export interface InvoiceDocumentContainer {
94
- [key: string]: Document;
110
+ [key: string]: Document | MensajeReceptor;
95
111
  }
96
112
  export type ConfirmationMessageRaw = {
97
113
  MensajeHacienda: {
@@ -116,3 +132,4 @@ export type ConfirmationMessageRaw = {
116
132
  };
117
133
  };
118
134
  };
135
+ export {};
@@ -9,6 +9,16 @@ Para probar crear y enviar factura
9
9
  yarn ts-node -r tsconfig-paths/register --require dotenv/config examples/createAndSend.ts
10
10
  ```
11
11
 
12
+ Para aceptar una factura
13
+ ```
14
+ yarn ts-node -r tsconfig-paths/register --require dotenv/config examples/atvAccept.ts
15
+ ```
16
+
17
+ Para crear y enviar una nota de credito
18
+ ```
19
+ yarn ts-node -r tsconfig-paths/register --require dotenv/config examples/createCreditNote.ts
20
+ ```
21
+
12
22
  Para probar genJson HeaderXML
13
23
  ```
14
24
  yarn ts-node -r tsconfig-paths/register --require dotenv/config examples/genBasicXML.ts
@@ -19,11 +29,6 @@ Generar la clave
19
29
  yarn ts-node -r tsconfig-paths/register--require dotenv/config examples/getClave.ts
20
30
  ```
21
31
 
22
- Para crear una nota de credito
23
- ```
24
- yarn ts-node -r tsconfig-paths/register --require dotenv/config examples/createCreditNote.ts
25
- ```
26
-
27
32
  Para obtener un token
28
33
  ```
29
34
  yarn ts-node -r tsconfig-paths/register --require dotenv/config examples/getToken.ts
@@ -0,0 +1,87 @@
1
+ import fs from 'fs'
2
+ import { createDocumentInputExample } from '@test/stubs/createDocument.data'
3
+ import { ATV } from '../dist/src'
4
+ import { PersonProps } from 'dist/src/ATV/core/Person'
5
+ import { AceptationStates } from 'dist/src/ATV/core/types'
6
+ import { parseElectronicBillXML } from '@src/lib/genXML'
7
+
8
+
9
+ const IS_STG = process.env.IS_STG
10
+ const USERNAME_TEST = process.env.USERNAME_TEST
11
+ const PASSWORD_TEST = process.env.PASSWORD_TEST
12
+ const XML_TO_CONFIRM = process.env.XML_TO_CONFIRM
13
+ console.log('process.env.IS_STG', IS_STG)
14
+
15
+ const SOURCE_P12_URI = process.env.SOURCE_P12_URI
16
+ const SOURCE_P12_PASSPORT = process.env.SOURCE_P12_PASSPORT
17
+
18
+ if (!SOURCE_P12_PASSPORT || !SOURCE_P12_URI) {
19
+ throw new Error('No environment. For running examples set .env before.')
20
+ }
21
+
22
+ const pem = fs.readFileSync(SOURCE_P12_URI, 'binary')
23
+ const receivedDocumentXML = fs.readFileSync(XML_TO_CONFIRM, 'utf-8')
24
+
25
+ // TODO: dynamic param --identifier 1 args[x]
26
+ createDocumentInputExample.consecutiveIdentifier = process.env.TEST_CONSECUTIVE
27
+ createDocumentInputExample.emitter.identifier.id = process.env.EMITTER_IDENTIFIER_ID as string;
28
+ createDocumentInputExample.emitter.identifier.type = process.env.EMITTER_IDENTIFIER_TYPE as PersonProps['identifier']['type'];
29
+
30
+ console.log('requestStub consecutivo', createDocumentInputExample.consecutiveIdentifier)
31
+
32
+ function getConfimation(atv: ATV, token: string, location: string, ms: number): Promise<any> {
33
+ return new Promise((resolve, reject): any => {
34
+ setTimeout(() => {
35
+ console.log('location', location)
36
+ atv.sendConfirmation({
37
+ url: location,
38
+ headers: {
39
+ 'Content-Type': 'application/json',
40
+ Authorization: 'bearer ' + token
41
+ }
42
+ }).then(data => resolve(data))
43
+ .catch(err => reject(err))
44
+ }, ms)
45
+ })
46
+ }
47
+
48
+ async function main(): Promise<void> {
49
+ const atv = new ATV({}, 'stg')
50
+ const tokenData = await atv.getToken({
51
+ username: USERNAME_TEST,
52
+ password: PASSWORD_TEST
53
+ })
54
+ const electronillBillRaw = parseElectronicBillXML(receivedDocumentXML)
55
+ const { command, extraData } = await atv.createReceptorMessage({
56
+ aceptationState: AceptationStates.ACCEPTED,
57
+ aceptationDetailMessage: 'Accepted',
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,
68
+ branch: '01',
69
+ terminal: '01',
70
+ consecutive: '01',
71
+ token: tokenData.accessToken,
72
+ signatureOptions: {
73
+ buffer: pem,
74
+ password: SOURCE_P12_PASSPORT
75
+ }
76
+ })
77
+ console.log('extraData', extraData);
78
+ const response = await atv.sendDocument(command)
79
+ if (response.errorCause) {
80
+ console.log('error response', response)
81
+ return
82
+ }
83
+ const confirmationResponse = await getConfimation(atv, tokenData.accessToken, response.location, 2000)
84
+ console.log({ MensajeHacienda: confirmationResponse.confirmation })
85
+ }
86
+
87
+ main()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@facturacr/atv-sdk",
3
- "version": "1.0.1",
3
+ "version": "1.2.0",
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",
@@ -7,6 +7,7 @@ import { Document } from '@src/ATV/core/Document'
7
7
  import { Clave } from '@src/ATV/core/Clave'
8
8
  import { DocumentType } from '@src/ATV/core/DocumentType'
9
9
  import { ReferenceInformation, ReferenceInformationProps } from './ReferenceInformation'
10
+ import { ReceptorMessageProps } from './types'
10
11
 
11
12
  type PersonInput = PersonProps;
12
13
 
@@ -51,6 +52,7 @@ type DocumentInput = {
51
52
  export type CreateDocumentInput = {
52
53
  document: DocumentInput;
53
54
  token: string;
55
+ receptorMessageProps?: ReceptorMessageProps;
54
56
  signatureOptions: {
55
57
  buffer: string;
56
58
  password: string;
@@ -34,7 +34,7 @@ export class Person {
34
34
  return this.props.fullName
35
35
  }
36
36
 
37
- get identifierType(): string | undefined {
37
+ get identifierType(): '01' | '02' | undefined {
38
38
  return this.props.identifier.type
39
39
  }
40
40
 
@@ -0,0 +1,27 @@
1
+ type ReceptorConsecutiveProps = {
2
+ branch: string; // sucursal
3
+ terminal: string; // terminal
4
+ documentType: '05' | '06' | '07'; // 05=aceptación, 06=aceptación parcial, 07=rechazo
5
+ consecutive: string;
6
+ }
7
+
8
+ export class ReceptorConsecutive {
9
+ private props: ReceptorConsecutiveProps
10
+
11
+ constructor(props: ReceptorConsecutiveProps) {
12
+ this.props = props
13
+ }
14
+
15
+ get value(): string {
16
+ return Object.values(this.props).join('')
17
+ }
18
+
19
+ public static create(props: ReceptorConsecutiveProps): ReceptorConsecutive {
20
+ return new ReceptorConsecutive({
21
+ branch: props.branch.padStart(3, '0'),
22
+ terminal: props.terminal.padStart(5, '0'),
23
+ documentType: props.documentType,
24
+ consecutive: props.consecutive.padStart(10, '0')
25
+ })
26
+ }
27
+ }
@@ -2,4 +2,5 @@ export type DocumentNames =
2
2
  'FacturaElectronica' |
3
3
  'FacturaElectronicaExportacion' |
4
4
  'NotaCreditoElectronica' |
5
- 'NotaDebitoElectronica'
5
+ 'NotaDebitoElectronica' |
6
+ 'MensajeReceptor'
@@ -0,0 +1,22 @@
1
+ export enum AceptationStates {
2
+ ACCEPTED = 1,
3
+ PARTIALLY_ACCEPTED = 2,
4
+ DECLINED = 3
5
+ }
6
+
7
+ export type ReceptorMessageProps = {
8
+ clave: string;
9
+ emitterIdentifier: string;
10
+ emitterIdentifierType: string;
11
+ receptorIdentifier: string;
12
+ receptorIdentifierType: string;
13
+ documentIssueDate: Date;
14
+ activityCode: string;
15
+ aceptationState: AceptationStates
16
+ aceptationDetailMessage: string;
17
+ receptorConcecutive: string;
18
+ taxCondition: string;
19
+ totalTaxes: number;
20
+ totalSale: number;
21
+ }
22
+
package/src/ATV/index.ts CHANGED
@@ -8,6 +8,7 @@ import { ATVOptions, ConfirmationMessage, Mode, SendConfirmationInput, SendRespo
8
8
  import { Command, CreateAndSendDocumentResponse } from './useCases/createDocument/types'
9
9
  import { CreateDocumentCommand } from './useCases/createDocument'
10
10
  import { CreateDocumentInput } from './core/CreateDocFactory'
11
+ import { CreateReceptorMessageCommand, CreateReceptorMessageCommandInput } from './useCases/createReceptorMessage'
11
12
 
12
13
  export class ATV {
13
14
  public readonly options: ATVOptions
@@ -25,6 +26,11 @@ export class ATV {
25
26
  return createDocument.execute(input)
26
27
  }
27
28
 
29
+ public createReceptorMessage(input: CreateReceptorMessageCommandInput) {
30
+ const useCase = new CreateReceptorMessageCommand(this)
31
+ return useCase.execute(input)
32
+ }
33
+
28
34
  public async sendDocument(input: Command): Promise<SendResponse> {
29
35
  try {
30
36
  const response = await axios(input)
@@ -3,6 +3,7 @@ import { Document as DomainDocument } from '../core/Document'
3
3
  import { OrderLine } from '../core/OrderLine'
4
4
  import { Person } from '../core/Person'
5
5
  import { ReferenceInformation } from '../core/ReferenceInformation'
6
+ import { ReceptorMessageProps } from '../core/types'
6
7
 
7
8
  type AtvFormat = InvoiceDocumentContainer
8
9
 
@@ -120,3 +121,22 @@ export const mapDocumentToAtvFormat = (docName: string, document: DomainDocument
120
121
  [key]: doc
121
122
  }
122
123
  }
124
+
125
+ export const mapReceptorMessageToAtvFormat = (props: ReceptorMessageProps): AtvFormat => {
126
+ return {
127
+ MensajeReceptor: {
128
+ Clave: props.clave,
129
+ NumeroCedulaEmisor: props.emitterIdentifier,
130
+ FechaEmisionDoc: props.documentIssueDate.toISOString(),
131
+ Mensaje: props.aceptationState.toString(), // 1 Aceptado | 2 Aceptado Parcialmente | 3 Rechazado
132
+ DetalleMensaje: props.aceptationDetailMessage,
133
+ MontoTotalImpuesto: props.totalTaxes,
134
+ CodigoActividad: props.activityCode,
135
+ CondicionImpuesto: props.taxCondition,
136
+ MontoTotalDeGastoAplicable: props.totalSale, // fullInvoice.ResumenFactura.TotalVenta, // TODO investigar casos de uso
137
+ TotalFactura: props.totalSale, // fullInvoice.ResumenFactura.TotalVenta,
138
+ NumeroCedulaReceptor: props.receptorIdentifier,
139
+ NumeroConsecutivoReceptor: props.receptorConcecutive
140
+ }
141
+ }
142
+ }
@@ -5,22 +5,25 @@ import { Method } from 'axios'
5
5
 
6
6
  export type DocumentTypes = 'FE'
7
7
 
8
+ type CommandData = {
9
+ clave: string;
10
+ fecha: string;
11
+ emisor: {
12
+ tipoIdentificacion: string;
13
+ numeroIdentificacion: string;
14
+ };
15
+ receptor: {
16
+ tipoIdentificacion: string;
17
+ numeroIdentificacion: string;
18
+ };
19
+ comprobanteXml: string;
20
+ consecutivoReceptor?: string;
21
+ };
22
+
8
23
  export type Command = {
9
24
  url: string;
10
25
  method: Method;
11
- data: {
12
- clave: string;
13
- fecha: string;
14
- emisor: {
15
- tipoIdentificacion: string;
16
- numeroIdentificacion: string;
17
- };
18
- receptor: {
19
- tipoIdentificacion: string;
20
- numeroIdentificacion: string;
21
- };
22
- comprobanteXml: string;
23
- };
26
+ data: CommandData;
24
27
  headers: {
25
28
  Authorization: string;
26
29
  'Content-Type': string;
@@ -0,0 +1,129 @@
1
+ import { AceptationStates, ReceptorMessageProps } from "@src/ATV/core/types";
2
+ import { mapReceptorMessageToAtvFormat } from "@src/ATV/mappers/billDocToAtv";
3
+ import { genXML, parseElectronicBillXML } from "@src/lib/genXML";
4
+ import { Command } from "../createDocument/types";
5
+ import { ATV } from "@src/ATV";
6
+ import { ReceptorConsecutive } from "@src/ATV/core/ReceptorConsecutive";
7
+
8
+ export type CreateReceptorMessageCommandInput = {
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;
19
+ aceptationState: AceptationStates;
20
+ aceptationDetailMessage: string;
21
+ branch: string;
22
+ terminal: string;
23
+ token: string;
24
+ consecutive: string;
25
+ signatureOptions: {
26
+ buffer: string;
27
+ password: string;
28
+ };
29
+ }
30
+
31
+ const options: { [key: string]: { serviceUrl: string}} = {
32
+ prod: {
33
+ serviceUrl: 'https://api.comprobanteselectronicos.go.cr/v1/recepcion'
34
+ },
35
+ stg: {
36
+ serviceUrl: 'https://api-sandbox.comprobanteselectronicos.go.cr/recepcion/v1/recepcion'
37
+ }
38
+ }
39
+
40
+ export class CreateReceptorMessageCommand {
41
+ private readonly serviceUrl: string
42
+
43
+ constructor(scope: ATV) {
44
+ this.serviceUrl = options[scope.mode].serviceUrl
45
+ }
46
+
47
+ public async execute(input: CreateReceptorMessageCommandInput) {
48
+ const receptorMessageProps = this.processDocument(input)
49
+ const atvDocument = mapReceptorMessageToAtvFormat(receptorMessageProps)
50
+ const xml = await genXML('MensajeReceptor', atvDocument, input.signatureOptions)
51
+ const command = await this.createDocumentCommand(receptorMessageProps, xml, input.token)
52
+ return {
53
+ command,
54
+ extraData: {
55
+ xml,
56
+ document: atvDocument
57
+ }
58
+ }
59
+ }
60
+
61
+ private async createDocumentCommand(receptorMessageProps: ReceptorMessageProps, xml: string, token: string): Promise<Command> {
62
+ return {
63
+ url: this.serviceUrl,
64
+ method: 'post',
65
+ data: {
66
+ clave: receptorMessageProps.clave,
67
+ fecha: receptorMessageProps.documentIssueDate.toISOString(),
68
+ emisor: {
69
+ tipoIdentificacion: receptorMessageProps.emitterIdentifierType,
70
+ numeroIdentificacion: receptorMessageProps.emitterIdentifier,
71
+ },
72
+ receptor: {
73
+ tipoIdentificacion: receptorMessageProps.receptorIdentifierType,
74
+ numeroIdentificacion: receptorMessageProps.receptorIdentifier,
75
+ },
76
+ comprobanteXml: this.encodeXML(xml),
77
+ consecutivoReceptor: receptorMessageProps.receptorConcecutive
78
+ },
79
+ headers: {
80
+ Authorization: 'bearer ' + token,
81
+ 'Content-Type': 'application/json'
82
+ }
83
+ }
84
+ }
85
+
86
+ private encodeXML(xmlStr: string): string {
87
+ const buffer = Buffer.from(xmlStr)
88
+ return buffer.toString('base64')
89
+ }
90
+
91
+ private acceptationStateToDocumentType(aceptationState: AceptationStates) {
92
+ switch (aceptationState) {
93
+ case AceptationStates.ACCEPTED:
94
+ return '05'
95
+ case AceptationStates.PARTIALLY_ACCEPTED:
96
+ return '06'
97
+ default:
98
+ return '07'
99
+ }
100
+ }
101
+
102
+ private processDocument(input: CreateReceptorMessageCommandInput): ReceptorMessageProps {
103
+ try {
104
+ const receptorConsecutive = ReceptorConsecutive.create({
105
+ branch: input.branch,
106
+ terminal: input.terminal,
107
+ documentType: this.acceptationStateToDocumentType(input.aceptationState),
108
+ consecutive: input.consecutive,
109
+ })
110
+ return {
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,
121
+ aceptationState: input.aceptationState,
122
+ aceptationDetailMessage: input.aceptationDetailMessage,
123
+ receptorConcecutive: receptorConsecutive.value
124
+ }
125
+ } catch (err) {
126
+ throw new Error('Error parsing the document')
127
+ }
128
+ }
129
+ }
package/src/confirmXML.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { consecutivoStr } from '@src/lib/genClave'
2
- import { xmlToJson, genXML } from '@src/lib/genXML/index'
2
+ import { parseElectronicBillXML, genXML } from '@src/lib/genXML/index'
3
3
  import { send } from '@src/services/send/index'
4
4
  import { getFinalMessage, getMsjObj } from '@src/lib/genJSON/confirmXML'
5
5
 
@@ -21,7 +21,7 @@ export default async (opts: {
21
21
  }): Promise<any> => {
22
22
  const { token, pemOpt, tipoDocKey } = opts
23
23
  const consecutivo = getConsecutivoStr(opts)
24
- const fullInvoice = xmlToJson(opts.xmlStr)
24
+ const fullInvoice = parseElectronicBillXML(opts.xmlStr)
25
25
  const msjObj = getMsjObj({ fullInvoice, consecutivo, tipoDocKey })
26
26
  const xmlBase64 = await genXML(tipoDocKey, msjObj, {
27
27
  buffer: pemOpt.buffer,
@@ -2,9 +2,10 @@ import { ClientPayload, FinalMessagePerson } from '@src/types/globalInterfaces'
2
2
  import { genClaveObj, genString, parseOptions } from '@src/lib/genClave/index'
3
3
  import genJSON from '@src/lib/genJSON/index'
4
4
  import { send } from '@src/services/send/index'
5
+ import { Persona } from './types/facturaInterfaces'
5
6
 
6
7
  const DEFAULT_VALUES = {
7
- tipoIdentificacion: '01'
8
+ tipoIdentificacion: '01' as Persona['Identificacion']['Tipo']
8
9
  }
9
10
 
10
11
  const encodeXML = (xmlStr: string): string => {
@@ -6,7 +6,7 @@ const DEFAULT_VALUES = {
6
6
  message: 'Default msj',
7
7
  detailsMessage: 'Default details msj',
8
8
  taxes: 100,
9
- tipoIdentificacion: '01'
9
+ tipoIdentificacion: '01' as Persona['Identificacion']['Tipo']
10
10
  }
11
11
 
12
12
  export function getSimpleSender(frontEndRequest: ClientPayload): FinalMessagePerson {
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
-
1
+ export { parseElectronicBillXML as xmlToJson } from './lib/genXML'
2
2
  export { Document, InvoiceDocumentContainer, DetalleServicio, Resumen, Persona } from './types/facturaInterfaces'
3
3
  export { CreateDocumentInput } from './ATV/core/CreateDocFactory'
4
4
  export { ATV } from './ATV'
@@ -31,17 +31,17 @@ export function getMsjObj(opts: {
31
31
  export function getFinalMessage(fullInvoice: any, consecutivoReceptor: string, xmlBase64: any): any {
32
32
  const date = new Date()
33
33
  return {
34
- clave: fullInvoice.Clave,
35
- fecha: date.toISOString(),
36
- emisor: {
34
+ clave: fullInvoice.Clave, // in command
35
+ fecha: date.toISOString(), // in command
36
+ emisor: { // in command
37
37
  tipoIdentificacion: fullInvoice.Receptor.Identificacion.Tipo,
38
38
  numeroIdentificacion: fullInvoice.Receptor.Identificacion.Numero
39
39
  },
40
- receptor: {
40
+ receptor: { // in command
41
41
  tipoIdentificacion: fullInvoice.Emisor.Identificacion.Tipo,
42
42
  numeroIdentificacion: fullInvoice.Emisor.Identificacion.Numero
43
43
  },
44
44
  consecutivoReceptor,
45
- comprobanteXml: xmlBase64
45
+ comprobanteXml: xmlBase64 // in command
46
46
  }
47
47
  }
@@ -7,7 +7,7 @@ const DEFAULT_VALUES = {
7
7
  key: 0,
8
8
  message: 'Default msj',
9
9
  detailsMessage: 'Default details msj',
10
- tipoIdentificacion: '01'
10
+ tipoIdentificacion: '01' as Persona['Identificacion']['Tipo']
11
11
  }
12
12
 
13
13
  function sumLines(lines: LineaDetalle[]): any {
@@ -1,6 +1,7 @@
1
1
  import { j2xParser, parse } from 'fast-xml-parser'
2
2
  import { declaration, defaultOptions, xmlExtructures } from '@src/lib/genXML/xmlConfig'
3
3
  import sigXML from '@src/lib/genXML/sigXML/index'
4
+ import { XMLRawDocument } from '@src/types/facturaInterfaces'
4
5
 
5
6
  export const objToXML = (xmlStructure: string, obj: object): string => {
6
7
  const parser = new j2xParser(defaultOptions) // eslint-disable-line new-cap
@@ -21,7 +22,7 @@ export async function genXML(xmlStructure: string, obj: object, options?: {
21
22
  return signedXML
22
23
  }
23
24
 
24
- export const xmlToJson = (xml: string): any => {
25
+ export const parseElectronicBillXML = (xml: string): XMLRawDocument => {
25
26
  try {
26
27
  const json = parse(xml, {
27
28
  ignoreAttributes: false,