Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Verify/Models/VerifyResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* ============================================================================
*/

using Fiscalapi.XmlDownloader.Common.Enums;
using Fiscalapi.XmlDownloader.Common.Http;

namespace Fiscalapi.XmlDownloader.Verify.Models;
Expand Down Expand Up @@ -42,4 +43,14 @@ public class VerifyResponse : BaseResponse
/// Indicates if the request is ready for download
/// </summary>
public bool IsReadyToDownload => RequestStatus == RequestStatus.Terminada && InvoiceCount > 0;

/// <summary>
/// Operation status code from the SAT verification service
/// </summary>
public SatStatus SatStatusDownload { get; set; }

/// <summary>
/// Sat 'CodigoEstadoSolicitud' received from the service
/// </summary>
public string? SatStatusCodeDownload { get; set; }
}
11 changes: 11 additions & 0 deletions Verify/VerifyResponseService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,22 @@ public static VerifyResponse Build(SatResponse satResponse, ILogger logger)
*/

//CodEstatus="5000"
// <Obsolete> No refleja correctamente el estatus de la ejecución de la acción Verify
var codEstatus = envelope?.Body.VerifyDownloadRequestResponse
.VerifyDownloadRequestResult.CodEstatus;

// <Obsolete> No refleja correctamente el estatus de la ejecución de la acción Verify
var status = !string.IsNullOrWhiteSpace(codEstatus)
? codEstatus.ToEnumElement<SatStatus>()
: SatStatus.Unknown;

var codSatStatus = envelope?.Body.VerifyDownloadRequestResponse
.VerifyDownloadRequestResult.CodigoEstadoSolicitud;

var satStatus = !string.IsNullOrWhiteSpace(codSatStatus)
? codSatStatus.ToEnumElement<SatStatus>()
: SatStatus.Unknown;

// EstadoSolicitud="3"
var estadoSolicitud = envelope?.Body.VerifyDownloadRequestResponse
.VerifyDownloadRequestResult.EstadoSolicitud;
Expand Down Expand Up @@ -96,6 +105,8 @@ public static VerifyResponse Build(SatResponse satResponse, ILogger logger)
Succeeded = true,
SatStatus = status,
SatStatusCode = status.ToEnumCode(),
SatStatusDownload = satStatus,
SatStatusCodeDownload = satStatus.ToEnumCode(),
Comment on lines +108 to +109
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Preserve raw CodigoEstadoSolicitud in SatStatusCodeDownload.
Using satStatus.ToEnumCode() can drop unmapped/unknown codes and doesn’t reflect the raw SAT attribute. Consider storing codSatStatus (with a fallback) to match the property’s intent.

🔧 Suggested fix
-                SatStatusCodeDownload = satStatus.ToEnumCode(),
+                SatStatusCodeDownload = string.IsNullOrWhiteSpace(codSatStatus)
+                    ? satStatus.ToEnumCode()
+                    : codSatStatus,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
SatStatusDownload = satStatus,
SatStatusCodeDownload = satStatus.ToEnumCode(),
SatStatusCodeDownload = string.IsNullOrWhiteSpace(codSatStatus)
? satStatus.ToEnumCode()
: codSatStatus,
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Verify/VerifyResponseService.cs` around lines 108 - 109, The
SatStatusCodeDownload assignment currently uses satStatus.ToEnumCode(), which
can lose unmapped/unknown SAT codes; instead set SatStatusCodeDownload to the
raw codSatStatus (with a fallback to ToEnumCode() only if codSatStatus is
null/empty) so the property preserves the original CodigoEstadoSolicitud; update
the object initializer where SatStatusDownload and SatStatusCodeDownload are set
to use codSatStatus ?? satStatus.ToEnumCode() (or equivalent null/empty check)
and keep SatStatusDownload = satStatus as-is.

SatMessage = mensaje,
RequestStatus = requestStatus,
InvoiceCount = invoiceCount,
Expand Down