consultame-sdk 1.2.1 → 1.2.3

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/index.mjs CHANGED
@@ -106,6 +106,30 @@ var NominationInvoiceUseCase = class {
106
106
  }
107
107
  };
108
108
 
109
+ // src/sifen/domain/useCases/generateBatch.useCase.ts
110
+ var GenerateBatchUseCase = class {
111
+ constructor(sifenRepository) {
112
+ this.sifenRepository = sifenRepository;
113
+ }
114
+ sifenRepository;
115
+ execute(generateBatchDto) {
116
+ const batch = this.sifenRepository.generateBatch(generateBatchDto);
117
+ return batch;
118
+ }
119
+ };
120
+
121
+ // src/sifen/domain/useCases/cancelDocument.useCase.ts
122
+ var CancelDocumentUseCase = class {
123
+ constructor(sifenRepository) {
124
+ this.sifenRepository = sifenRepository;
125
+ }
126
+ sifenRepository;
127
+ execute(cancelInvoiceDto) {
128
+ const xml = this.sifenRepository.cancelationInvoice(cancelInvoiceDto);
129
+ return xml;
130
+ }
131
+ };
132
+
109
133
  // src/shared/utils/dictionary.utils.ts
110
134
  var TIPOS_DOCUMENTOS = [
111
135
  {
@@ -8143,6 +8167,19 @@ var generateConsultBatchXml = (consultBatchDto) => {
8143
8167
  </env:Envelope>
8144
8168
  `;
8145
8169
  };
8170
+ var generateSendBatchXml = (generateBatchDto) => {
8171
+ return `<?xml version="1.0" encoding="UTF-8"?>
8172
+ <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
8173
+ <env:Header/>
8174
+ <env:Body>
8175
+ <rEnvioLote xmlns="http://ekuatia.set.gov.py/sifen/xsd">
8176
+ <dId>${generateBatchDto.id}</dId>
8177
+ <xDE>${generateBatchDto.xml}</xDE>
8178
+ </rEnvioLote>
8179
+ </env:Body>
8180
+ </env:Envelope>
8181
+ `;
8182
+ };
8146
8183
  var validateNominationInvoice = (dto) => {
8147
8184
  if (!/^\d{44}$/.test(dto.cdc)) {
8148
8185
  throw new Error("El CDC debe tener 44 d\xEDgitos");
@@ -8466,6 +8503,48 @@ var signXml = async (xml, tag, responseDigitalSign) => {
8466
8503
  throw error;
8467
8504
  }
8468
8505
  };
8506
+ var generateCancelInvoiceXml = (cancelInvocieDto) => {
8507
+ const json = {};
8508
+ json.gGroupGesEve = {};
8509
+ json.gGroupGesEve.rGesEve = {};
8510
+ json.gGroupGesEve.$ = {};
8511
+ json.gGroupGesEve.$["xmlns:xsi"] = "http://www.w3.org/2001/XMLSchema-instance";
8512
+ json.gGroupGesEve.$["xsi:schemaLocation"] = "http://ekuatia.set.gov.py/sifen/xsd siRecepEvento_v150.xsd";
8513
+ json.gGroupGesEve.rGesEve.rEve = {};
8514
+ json.gGroupGesEve.rGesEve.rEve.$ = {};
8515
+ json.gGroupGesEve.rGesEve.rEve.$.Id = 1;
8516
+ json.gGroupGesEve.rGesEve.rEve.dFecFirma = convertToFormatDateSET(/* @__PURE__ */ new Date());
8517
+ json.gGroupGesEve.rGesEve.rEve.dVerFor = 150;
8518
+ json.gGroupGesEve.rGesEve.rEve.gGroupTiEvt = {};
8519
+ json.gGroupGesEve.rGesEve.rEve.gGroupTiEvt.rGeVeCan = {
8520
+ Id: cancelInvocieDto.cdc,
8521
+ mOtEve: cancelInvocieDto.motivo
8522
+ };
8523
+ const builder = new xml2js.Builder({
8524
+ xmldec: {
8525
+ version: "1.0",
8526
+ encoding: "UTF-8",
8527
+ standalone: false
8528
+ }
8529
+ });
8530
+ let xml = builder.buildObject(json);
8531
+ xml = normalizeXML(xml);
8532
+ xml = xml.replace(
8533
+ '<?xml version="1.0" encoding="UTF-8" standalone="no"?>',
8534
+ ""
8535
+ );
8536
+ return `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
8537
+ <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
8538
+ <env:Header/>
8539
+ <env:Body>
8540
+ <rEnviEventoDe xmlns="http://ekuatia.set.gov.py/sifen/xsd">
8541
+ <dId>${cancelInvocieDto.id}</dId>
8542
+ <dEvReg>${xml}</dEvReg>
8543
+ </rEnviEventoDe>
8544
+ </env:Body>
8545
+ </env:Envelope>
8546
+ `;
8547
+ };
8469
8548
 
8470
8549
  // src/shared/clases/detalleDocumento.ts
8471
8550
  var DetalleDocumento = class {
@@ -10085,7 +10164,7 @@ var SifenPersistence = class {
10085
10164
  return xmlFormated;
10086
10165
  }
10087
10166
  cancelationInvoice(cancelInvoiceDto) {
10088
- throw new Error("Method not implemented.");
10167
+ return generateCancelInvoiceXml(cancelInvoiceDto);
10089
10168
  }
10090
10169
  invalidationInvoice(invalidationInvoiceDto) {
10091
10170
  try {
@@ -10142,6 +10221,13 @@ var SifenPersistence = class {
10142
10221
  throw error;
10143
10222
  }
10144
10223
  }
10224
+ generateBatch(generateBatchDto) {
10225
+ try {
10226
+ return generateSendBatchXml(generateBatchDto);
10227
+ } catch (error) {
10228
+ throw error;
10229
+ }
10230
+ }
10145
10231
  };
10146
10232
 
10147
10233
  // src/sifen/applications/services/sifen.service.ts
@@ -10154,6 +10240,8 @@ var SifenService = class {
10154
10240
  generateDocumentUseCase;
10155
10241
  signedXmlUseCase;
10156
10242
  nominationInvoiceUseCase;
10243
+ generateBatchUseCase;
10244
+ cancelDocumentUseCase;
10157
10245
  sifenRepository;
10158
10246
  constructor() {
10159
10247
  this.sifenRepository = new SifenPersistence();
@@ -10173,6 +10261,10 @@ var SifenService = class {
10173
10261
  this.nominationInvoiceUseCase = new NominationInvoiceUseCase(
10174
10262
  this.sifenRepository
10175
10263
  );
10264
+ this.generateBatchUseCase = new GenerateBatchUseCase(this.sifenRepository);
10265
+ this.cancelDocumentUseCase = new CancelDocumentUseCase(
10266
+ this.sifenRepository
10267
+ );
10176
10268
  }
10177
10269
  consultRuc(consultRucDto) {
10178
10270
  const ruc = this.consultRucUseCase.execute(consultRucDto);
@@ -10220,6 +10312,14 @@ var SifenService = class {
10220
10312
  throw error;
10221
10313
  }
10222
10314
  }
10315
+ generateBatch(generateBatchDto) {
10316
+ const xml = this.generateBatchUseCase.execute(generateBatchDto);
10317
+ return xml;
10318
+ }
10319
+ cancelInvoice(cancelInvocieDto) {
10320
+ const xml = this.cancelDocumentUseCase.execute(cancelInvocieDto);
10321
+ return xml;
10322
+ }
10223
10323
  };
10224
10324
 
10225
10325
  export { SifenService };