Skip to content
Merged
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
8 changes: 7 additions & 1 deletion src/cl_sii/dte/data_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,13 @@ def validate_referencias_numero_linea_ref_order(cls, v: object) -> object:
if isinstance(v, Sequence):
for idx, referencia in enumerate(v, start=1):
if referencia.numero_linea_ref != idx:
raise ValueError("items must be ordered according to their 'numero_linea_ref'")
raise ValueError(
"items must be ordered according to their 'numero_linea_ref'. "
f"Expected index value: {idx}, "
f"actual numero linea ref: {referencia.numero_linea_ref}. "
f"All numero_linea_refs: "
f"{', '.join(str(ref.numero_linea_ref) for ref in v)}"
)
return v

@pydantic.model_validator(mode='after')
Expand Down
6 changes: 5 additions & 1 deletion src/tests/test_dte_data_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1699,7 +1699,11 @@ def test_validate_referencias_numero_linea_ref_order(self) -> None:
expected_validation_errors = [
{
'loc': ('referencias',),
'msg': "Value error, items must be ordered according to their 'numero_linea_ref'",
'msg': (
"Value error, items must be ordered according to their 'numero_linea_ref'. "
"Expected index value: 1, actual numero linea ref: 2. "
"All numero_linea_refs: 2, 1"
),
'type': 'value_error',
},
]
Expand Down