Skip to content

Commit

Permalink
Merge pull request #8 from AndresRamos/develop
Browse files Browse the repository at this point in the history
Descargar CFDI por UUID
  • Loading branch information
AndresRamos authored Apr 6, 2023
2 parents 190dcaa + aee0317 commit 9ffad18
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ public sealed record CrearSolicitudCommand(int EmpresaId,
string RfcEmisor,
string RfcReceptor,
string RfcSolicitante,
string TipoSolicitud) : IRequest<int>;
string TipoSolicitud,
string Uuid) : IRequest<int>;
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public async Task<int> Handle(CrearSolicitudCommand request, CancellationToken c
request.RfcEmisor,
request.RfcReceptor,
request.RfcSolicitante,
request.TipoSolicitud);
request.TipoSolicitud,
request.Uuid);

_context.Entry(nuevaSolicitud).State = EntityState.Added;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,23 @@ public async Task Handle(GenerarSolicitudCommand request, CancellationToken canc

Logger.WithProperty(LogPropertyConstants.SolicitudId, solicitud.Id).Info("Generando XML SOAP de solicitud.");

var solicitudRequest = SolicitudRequest.CreateInstance(solicitud.FechaInicio,
solicitud.FechaFin,
solicitud.TipoSolicitud == TipoSolicitud.Cfdi.Name ? TipoSolicitud.Cfdi :
solicitud.TipoSolicitud == TipoSolicitud.Metadata.Name ? TipoSolicitud.Metadata :
throw new ArgumentException("El tipo de solicitud no es un tipo valido."),
solicitud.RfcEmisor ?? "",
solicitud.Receptores,
solicitud.RfcSolicitante,
AccessToken.CreateInstance(solicitud.SolicitudAutenticacion.Token));
SolicitudRequest solicitudRequest;

if (!string.IsNullOrWhiteSpace(solicitud.Uuid))
// Buscar solicitud por UUID
solicitudRequest = SolicitudRequest.CreateInstance(solicitud.Uuid,
solicitud.RfcSolicitante,
AccessToken.CreateInstance(solicitud.SolicitudAutenticacion.Token));
else
solicitudRequest = SolicitudRequest.CreateInstance(solicitud.FechaInicio,
solicitud.FechaFin,
solicitud.TipoSolicitud == TipoSolicitud.Cfdi.Name ? TipoSolicitud.Cfdi :
solicitud.TipoSolicitud == TipoSolicitud.Metadata.Name ? TipoSolicitud.Metadata :
throw new ArgumentException("El tipo de solicitud no es un tipo valido."),
solicitud.RfcEmisor ?? "",
solicitud.Receptores,
solicitud.RfcSolicitante,
AccessToken.CreateInstance(solicitud.SolicitudAutenticacion.Token));

string soapRequestEnvelopeXml = _solicitudService.GenerateSoapRequestEnvelopeXmlContent(solicitudRequest, certificadoSat);
Logger.WithProperty(LogPropertyConstants.SolicitudId, solicitud.Id).Info("SoapRequestEnvelopeXml: {0}", soapRequestEnvelopeXml);
Expand Down
3 changes: 3 additions & 0 deletions Core.Application/Solicitudes/Models/SolicitudDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public SolicitudDto(int id,
string rfcReceptor,
string rfcSolicitante,
string tipoSolicitud,
string uuid,
SolicitudAutenticacionDto solicitudAutenticacion,
SolicitudSolicitudDto solicitudSolicitud,
SolicitudVerificacionDto solicitudVerificacion,
Expand All @@ -31,6 +32,7 @@ public SolicitudDto(int id,
RfcReceptor = rfcReceptor;
RfcSolicitante = rfcSolicitante;
TipoSolicitud = tipoSolicitud;
Uuid = uuid;
SolicitudAutenticacion = solicitudAutenticacion;
SolicitudSolicitud = solicitudSolicitud;
SolicitudVerificacion = solicitudVerificacion;
Expand All @@ -51,6 +53,7 @@ public SolicitudDto(int id,
public string RfcReceptor { get; set; }
public string RfcSolicitante { get; set; }
public string TipoSolicitud { get; set; }
public string Uuid { get; set; }
public SolicitudAutenticacionDto SolicitudAutenticacion { get; set; }
public SolicitudSolicitudDto SolicitudSolicitud { get; set; }
public SolicitudVerificacionDto SolicitudVerificacion { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public async Task<SolicitudDto> Handle(BuscarSolicitudPorIdQuery request, Cancel
solicitud.RfcReceptor,
solicitud.RfcSolicitante,
solicitud.TipoSolicitud,
solicitud.Uuid,
solicitud.SolicitudAutenticacion != null
? new SolicitudAutenticacionDto(solicitud.SolicitudAutenticacion.Id,
solicitud.SolicitudAutenticacion.FechaCreacionUtc,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public async Task<IEnumerable<SolicitudDto>> Handle(BuscarSolicitudesPorRangoFec
solicitud.RfcReceptor,
solicitud.RfcSolicitante,
solicitud.TipoSolicitud,
solicitud.Uuid,
solicitud.SolicitudAutenticacion != null
? new SolicitudAutenticacionDto(solicitud.SolicitudAutenticacion.Id,
solicitud.SolicitudAutenticacion.FechaCreacionUtc,
Expand Down
8 changes: 6 additions & 2 deletions Core.Domain/Entities/Solicitud.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public Solicitud()
public string RfcReceptor { get; set; }
public string RfcSolicitante { get; set; }
public string TipoSolicitud { get; set; }
public string Uuid { get; set; }

public IEnumerable<string> Receptores => RfcReceptor.Split('|');

Expand Down Expand Up @@ -53,7 +54,8 @@ public static Solicitud CreateNew(int empresaId,
string rfcEmisor,
string rfcReceptor,
string rfcSolicitante,
string tipoSolicitud)
string tipoSolicitud,
string uuid)
{
var solicitud = new Solicitud
{
Expand All @@ -65,8 +67,10 @@ public static Solicitud CreateNew(int empresaId,
RfcEmisor = rfcEmisor,
RfcReceptor = rfcReceptor,
RfcSolicitante = rfcSolicitante,
TipoSolicitud = tipoSolicitud
TipoSolicitud = tipoSolicitud,
Uuid = uuid
};

return solicitud;
}
}
1 change: 1 addition & 0 deletions Presentation.ConsoleApp/Models/CrearCommandOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ public class CrearCommandOptions
public DateTime FechaInicio { get; set; }
public DateTime FechaFin { get; set; }
public TipoSolicitudEnum TipoSolicitud { get; set; }
public string Uuid { get; set; }
public bool Procesar { get; set; }
}
3 changes: 2 additions & 1 deletion Presentation.ConsoleApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ await mediator.Send(new ValidarCredencialesUsuarioQuery(crearCommandOptions.Usua
rfcEmisor,
rfcReceptor,
configuracionEmpresa.CertificadoSat.Rfc,
"CFDI"));
"CFDI",
crearCommandOptions.Uuid));

if (solicitudId != 0 && crearCommandOptions.Procesar)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public sealed class NuevaSolicitudViewModel : Screen
private string _rfcSolicitante = string.Empty;
private TipoRangoFechaEnum _tipoRangoFechaSeleccionado;
private TipoSolicitudDto _tipoSolicitudSeleccionado;
private string _uuid;

public NuevaSolicitudViewModel(ConfiguracionAplicacion configuracionAplicacion,
IMediator mediator,
Expand Down Expand Up @@ -183,6 +184,12 @@ public TipoSolicitudDto TipoSolicitudSeleccionado
}
}

public string Uuid
{
get => _uuid;
set => Set(ref _uuid, value);
}

public async Task InicializarAsync()
{
RfcReceptor = _configuracionAplicacion.ConfiguracionGeneral.CertificadoSat.Rfc;
Expand All @@ -208,7 +215,8 @@ await _mediator.Send(new CrearSolicitudCommand(_configuracionAplicacion.Empresa.
RfcEmisor,
RfcReceptor,
RfcSolicitante,
TipoSolicitudSeleccionado.Name));
TipoSolicitudSeleccionado.Name,
Uuid));
await TryCloseAsync();
}
catch (Exception e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@
Binding="{Binding RfcSolicitante}" />
<DataGridTextColumn Header="Tipo Solicitud"
Binding="{Binding TipoSolicitud}" />
<DataGridTextColumn Header="UUID"
Binding="{Binding Uuid}" />
<DataGridTextColumn Header="Solicitud Coigo"
Binding="{Binding SolicitudSolicitud.CodEstatus}" />
<DataGridTextColumn Header="Solicitud Mensaje"
Expand Down
13 changes: 13 additions & 0 deletions Presentation.WpfApp/Views/Solicitudes/NuevaSolicitudView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
Expand Down Expand Up @@ -171,6 +172,18 @@
DisplayMemberPath="Name"
VerticalAlignment="Center"
Margin="5" />
<Label Grid.Row="7"
Grid.Column="0"
Content="UUID:"
FontWeight="Bold"
VerticalAlignment="Center"
HorizontalAlignment="Right"
Margin="5" />
<TextBox Grid.Row="7"
Grid.Column="1"
Text="{Binding Uuid, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
VerticalAlignment="Center"
Margin="5" />
</Grid>
</Grid>
</controls:MetroWindow>
13 changes: 13 additions & 0 deletions Presentation.WpfApp/Views/Solicitudes/SolicitudView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
Expand Down Expand Up @@ -150,6 +151,18 @@
Text="{Binding Solicitud.TipoSolicitud}"
VerticalAlignment="Center"
Margin="5" />
<Label Grid.Row="8"
Grid.Column="0"
Content="UUID:"
FontWeight="Bold"
VerticalAlignment="Center"
HorizontalAlignment="Right"
Margin="5" />
<TextBlock Grid.Row="8"
Grid.Column="1"
Text="{Binding Solicitud.Uuid}"
VerticalAlignment="Center"
Margin="5" />
</Grid>
</Grid>
</UserControl>

0 comments on commit 9ffad18

Please sign in to comment.