Skip to content

Commit 0970198

Browse files
committed
Agrega descarga masiva CFDI
1 parent 913f4fe commit 0970198

13 files changed

+709
-2
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System.Collections.Generic;
2+
using System.Threading.Tasks;
3+
using Fiscalapi.Common;
4+
5+
namespace Fiscalapi.Abstractions
6+
{
7+
/// <summary>
8+
/// Interface for the download catalog service
9+
/// </summary>
10+
public interface IDownloadCatalogService : IFiscalApiService<CatalogDto>
11+
{
12+
//GET /api/v4/download-catalogs
13+
Task<ApiResponse<List<string>>> GetListAsync();
14+
15+
16+
// /api/v4/download-catalogs/<catalogName>
17+
Task<ApiResponse<List<CatalogDto>>> GetRecordByNameAsync(string catalogName);
18+
}
19+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using System.Collections.Generic;
2+
using System.Threading.Tasks;
3+
using Fiscalapi.Common;
4+
using Fiscalapi.Models;
5+
6+
namespace Fiscalapi.Abstractions
7+
{
8+
/// <summary>
9+
/// Interface for the download request service.
10+
/// </summary>
11+
public interface IDownloadRequestService : IFiscalApiService<DownloadRequest>
12+
{
13+
/// <summary>
14+
/// Lista los xmls descargados para un requestId.
15+
/// </summary>
16+
/// <param name="requestId"></param>
17+
/// <returns>List of Xmls objects</returns>
18+
Task<ApiResponse<PagedList<Xml>>> GetXmlsAsync(string requestId);
19+
20+
/// <summary>
21+
/// Lista los meta-items descargados para un requestId.
22+
/// </summary>
23+
/// <param name="requestId"></param>
24+
/// <returns>List of meta-Items objects</returns>
25+
Task<ApiResponse<PagedList<MetadataItem>>> GetMetadataItemsAsync(string requestId);
26+
27+
/// <summary>
28+
/// Downloads la lista de paquetes (archivos .zip) de un requestId.
29+
/// </summary>
30+
/// <param name="requestId"></param>
31+
/// <returns>Lista of FileResponses</returns>
32+
Task<ApiResponse<List<FileResponse>>> DownloadPackageAsync(string requestId);
33+
34+
/// <summary>
35+
/// Descarga el archivo crudo de solicitud SAT para un requestId.
36+
/// </summary>
37+
/// <param name="requestId"></param>
38+
/// <returns>File response object</returns>
39+
Task<ApiResponse<FileResponse>> DownloadSatRequestAsync(string requestId);
40+
41+
/// <summary>
42+
/// Descarga la respuesta SAT para un requestId.
43+
/// </summary>
44+
/// <param name="requestId"></param>
45+
/// <returns>File response object</returns>
46+
Task<ApiResponse<FileResponse>> DownloadSatResponseAsync(string requestId);
47+
}
48+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System.Threading.Tasks;
2+
using Fiscalapi.Common;
3+
using Fiscalapi.Models;
4+
5+
namespace Fiscalapi.Abstractions
6+
{
7+
/// <summary>
8+
/// Interface for the Download Rule Service.
9+
/// </summary>
10+
public interface IDownloadRuleService : IFiscalApiService<DownloadRule>
11+
{
12+
// GET /api/v4/products/{id}/taxes
13+
Task<ApiResponse<DownloadRequest>> CreateTestRuleAsync();
14+
}
15+
}

Abstractions/IFiscalApiClient.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,8 @@ public interface IFiscalApiClient
1212

1313
ITaxFileService TaxFiles { get; }
1414
ICatalogService Catalogs { get; }
15+
IDownloadCatalogService DownloadCatalogs { get; }
16+
IDownloadRuleService DownloadRules { get; }
17+
IDownloadRequestService DownloadRequests { get; }
1518
}
1619
}

Models/DownlaodRequest.cs

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
using Fiscalapi.Common;
2+
using System;
3+
using System.Collections.Generic;
4+
5+
namespace Fiscalapi.Models
6+
{
7+
public class DownloadRequest : BaseDto
8+
{
9+
public int Consecutive { get; set; }
10+
11+
/// <summary>
12+
/// Sat Request ID used to track the request in the SAT system.
13+
/// </summary>
14+
public string SatRequestId { get; set; }
15+
16+
/// <summary>
17+
/// RuleId associated with the request.
18+
/// </summary>
19+
public string DownloadRuleId { get; set; }
20+
21+
public string DownloadTypeId { get; set; }
22+
public CatalogDto DownloadType { get; set; }
23+
24+
public string DownloadRequestTypeId { get; set; }
25+
public CatalogDto DownloadRequestType { get; set; }
26+
27+
28+
/// <summary>
29+
/// RfcReceptor
30+
/// Specific CFDIs or metadata of the given recipient TIN (RFC).
31+
/// </summary>
32+
public string RecipientTin { get; set; }
33+
34+
/// <summary>
35+
/// RfcEmisor
36+
/// Specific CFDIs or metadata of the given issuer TIN (RFC).
37+
/// </summary>
38+
public string IssuerTin { get; set; }
39+
40+
/// <summary>
41+
/// RfcSolicitante
42+
/// RFC who is requesting the query.
43+
/// </summary>
44+
public string RequesterTin { get; set; }
45+
46+
/// <summary>
47+
/// FechaInicial
48+
/// Start date for the associated request.
49+
/// </summary>
50+
public DateTime StartDate { get; set; }
51+
52+
/// <summary>
53+
/// FechaFinal
54+
/// End date for the associated request.
55+
/// </summary>
56+
public DateTime EndDate { get; set; }
57+
58+
59+
/// <summary>
60+
/// TipoSolicitud
61+
/// Request type for the request.
62+
/// CFDI or Metadata.
63+
/// </summary>
64+
public string SatQueryTypeId { get; set; }
65+
public CatalogDto SatQueryType { get; set; }
66+
67+
68+
/// <summary>
69+
/// TipoComprobante
70+
/// Specific invoice type to request.
71+
/// Ingreso
72+
/// Egreso
73+
/// Traslado
74+
/// Nómina
75+
/// Pago
76+
/// Todos
77+
/// </summary>
78+
79+
public string SatInvoiceTypeId { get; set; }
80+
public CatalogDto SatInvoiceType { get; set; }
81+
82+
83+
/// <summary>
84+
/// EstadoComprobante
85+
/// CFDIs status to request.
86+
/// </summary>
87+
88+
public string SatInvoiceStatusId { get; set; }
89+
public CatalogDto SatInvoiceStatus { get; set; }
90+
91+
92+
/// <summary>
93+
/// Complemento
94+
/// CFDIs complements for the request.
95+
/// </summary>
96+
97+
public string SatInvoiceComplementId { get; set; }
98+
public CatalogDto SatInvoiceComplement { get; set; }
99+
100+
101+
/// <summary>
102+
/// Estado actual de la solicitud.
103+
/// DESCONOCIDO
104+
/// ACEPTADA
105+
/// EN PROCESO
106+
/// TERMINADA
107+
/// ERROR
108+
/// RECHAZADA
109+
/// VENCIDA
110+
/// </summary>
111+
112+
public string SatRequestStatusId { get; set; }
113+
public CatalogDto SatRequestStatus { get; set; }
114+
115+
116+
/// <summary>
117+
/// Fiscalapi Request Status ID.
118+
/// </summary>
119+
public string DownloadRequestStatusId { get; set; }
120+
public CatalogDto DownloadRequestStatus { get; set; }
121+
122+
123+
/// <summary>
124+
/// FechaUltimoIntento
125+
/// Last attempt date for the associated request.
126+
/// </summary>
127+
public DateTime? LastAttemptDate { get; set; }
128+
129+
/// <summary>
130+
/// FechaSiguienteIntento
131+
/// Next attempt date for the associated request.
132+
/// </summary>
133+
public DateTime? NextAttemptDate { get; set; }
134+
135+
136+
/// <summary>
137+
/// Number of CFDIs found for the request when request is terminated.
138+
/// </summary>
139+
public int InvoiceCount { get; set; }
140+
141+
/// <summary>
142+
/// List of package IDs available for download when the request is terminated.
143+
/// </summary>
144+
public List<string> PackageIds { get; set; } = new List<string>();
145+
146+
/// <summary>
147+
/// Indicates if the request is ready for download, becomes true when the request is terminated and packages are available.
148+
/// </summary>
149+
public bool IsReadyToDownload { get; set; }
150+
151+
152+
/// <summary>
153+
/// Number of total retries attempted for this request across all re-submissions.
154+
/// </summary>
155+
public int RetriesCount { get; set; }
156+
}
157+
}

Models/DownloadRule.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using Fiscalapi.Common;
2+
3+
namespace Fiscalapi.Models
4+
{
5+
/// <summary>
6+
/// Representa una plantilla para crear solicitudes de descarga de CFDI o metadatos.
7+
/// </summary>
8+
public class DownloadRule : BaseDto
9+
{
10+
public string PersonId { get; set; }
11+
public Person Person { get; set; }
12+
public string Tin { get; set; }
13+
public string Description { get; set; }
14+
15+
// 1 Pendiente, 2 Aprobada, 3 Rechazada, 4 Abandonada
16+
public string DownloadRuleStatusId { get; set; }
17+
public CatalogDto DownloadRuleStatus { get; set; }
18+
19+
//CFDI, Metadata.
20+
public string SatQueryTypeId { get; set; }
21+
public CatalogDto SatQueryType { get; set; }
22+
23+
// Emitidos, Recibidos
24+
public string DownloadTypeId { get; set; }
25+
public CatalogDto DownloadType { get; set; }
26+
27+
//Vigente, Cancelado
28+
public string SatInvoiceStatusId { get; set; }
29+
public CatalogDto SatInvoiceStatus { get; set; }
30+
}
31+
}

Models/Invoice.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System;
33
using System.Collections.Generic;
44
using Fiscalapi.Common;
5-
using System.ComponentModel.DataAnnotations;
65

76
namespace Fiscalapi.Models
87
{

0 commit comments

Comments
 (0)