feat: implement exchange rate filtering and validation enhancements in invoice processing

This commit is contained in:
AlexeerCT
2026-01-07 11:45:41 -06:00
parent 9fe07e78a6
commit 8cdcc369bb
12 changed files with 178 additions and 50 deletions

View File

@@ -165,6 +165,7 @@ class ErrorCollector:
self,
field: str,
message: str,
solution: Optional[List[str]],
code: Optional[str] = None,
value: Optional[Any] = None,
) -> "ErrorCollector":
@@ -184,6 +185,8 @@ class ErrorCollector:
"field": field,
"message": message,
}
if solution:
error["solution"] = solution
if code:
error["code"] = code
if value is not None:
@@ -199,11 +202,13 @@ class ErrorCollector:
code: str = "INVALID",
) -> "ErrorCollector":
"""Atajo para agregar error de campo"""
return self.add_error(field, message, code)
return self.add_error(field, message, solution=None, code=code)
def add_required_error(self, field: str) -> "ErrorCollector":
"""Atajo para agregar error de campo requerido"""
return self.add_error(field, f"El campo '{field}' es requerido", "REQUIRED")
return self.add_error(
field, f"El campo '{field}' es requerido", solution=None, code="REQUIRED"
)
def add_duplicate_error(
self,
@@ -215,7 +220,9 @@ class ErrorCollector:
final_message = (
message or f"El valor '{value}' ya existe para el campo '{field}'"
)
return self.add_error(field, final_message, "DUPLICATE", value)
return self.add_error(
field, final_message, solution=None, code="DUPLICATE", value=value
)
def add_invalid_format_error(
self,
@@ -224,7 +231,10 @@ class ErrorCollector:
) -> "ErrorCollector":
"""Atajo para agregar error de formato inválido"""
return self.add_error(
field, f"Formato inválido. Se esperaba: {expected_format}", "INVALID_FORMAT"
field,
f"Formato inválido. Se esperaba: {expected_format}",
solution=None,
code="INVALID_FORMAT",
)
def add_range_error(
@@ -243,7 +253,7 @@ class ErrorCollector:
else:
message = "Valor fuera de rango"
return self.add_error(field, message, "OUT_OF_RANGE")
return self.add_error(field, message, solution=None, code="OUT_OF_RANGE")
def has_errors(self) -> bool:
"""Verifica si hay errores acumulados"""