@@ -97,6 +97,19 @@ def validate_cesion_and_dte_montos(cesion_value: int, dte_value: int) -> None:
97
97
raise ValueError ('Value of "cesión" must be <= value of DTE.' , cesion_value , dte_value )
98
98
99
99
100
+ def validate_cesion_fecha_ultimo_vencimiento_is_consistent_with_dte (
101
+ cesion_value : date , dte_value : date
102
+ ) -> None :
103
+ """
104
+ Validate 'fecha_ultimo_vencimiento' of the "cesión" is after or equal
105
+ to 'fecha_emision' of the DTE.
106
+
107
+ :raises ValueError:
108
+ """
109
+ if not (cesion_value >= dte_value ):
110
+ raise ValueError ('Value of "cesión" must be >= value of DTE.' , cesion_value , dte_value )
111
+
112
+
100
113
@pydantic .dataclasses .dataclass (
101
114
frozen = True ,
102
115
config = type ('Config' , (), dict (
@@ -531,6 +544,20 @@ def validate_monto_cedido_does_not_exceed_dte_monto_total(
531
544
532
545
return values
533
546
547
+ @pydantic .root_validator (skip_on_failure = True )
548
+ def validate_fecha_ultimo_vencimiento_is_consistent_with_dte (
549
+ cls , values : Mapping [str , object ],
550
+ ) -> Mapping [str , object ]:
551
+ fecha_ultimo_vencimiento = values ['fecha_ultimo_vencimiento' ]
552
+ dte_fecha_emision = values ['dte_fecha_emision' ]
553
+
554
+ if isinstance (fecha_ultimo_vencimiento , date ) and isinstance (dte_fecha_emision , date ):
555
+ validate_cesion_fecha_ultimo_vencimiento_is_consistent_with_dte (
556
+ cesion_value = fecha_ultimo_vencimiento , dte_value = dte_fecha_emision
557
+ )
558
+
559
+ return values
560
+
534
561
535
562
@pydantic .dataclasses .dataclass (
536
563
frozen = True ,
@@ -694,8 +721,6 @@ def as_dte_data_l2(self) -> dte_data_models.DteDataL2:
694
721
695
722
# TODO: Validate value of 'fecha_firma_dt' in relation to the DTE data.
696
723
697
- # TODO: Validate value of 'fecha_ultimo_vencimiento' in relation to the DTE data.
698
-
699
724
@pydantic .validator ('fecha_cesion_dt' )
700
725
def validate_fecha_cesion_dt (cls , v : object ) -> object :
701
726
if isinstance (v , datetime ):
@@ -739,3 +764,17 @@ def validate_dte_data_l2(cls, values: Mapping[str, Any]) -> Mapping[str, object]
739
764
raise
740
765
741
766
return values
767
+
768
+ @pydantic .root_validator (skip_on_failure = True )
769
+ def validate_fecha_ultimo_vencimiento_is_consistent_with_dte (
770
+ cls , values : Mapping [str , object ],
771
+ ) -> Mapping [str , object ]:
772
+ fecha_ultimo_vencimiento = values ['fecha_ultimo_vencimiento' ]
773
+ dte_fecha_emision = values ['dte_fecha_emision' ]
774
+
775
+ if isinstance (fecha_ultimo_vencimiento , date ) and isinstance (dte_fecha_emision , date ):
776
+ validate_cesion_fecha_ultimo_vencimiento_is_consistent_with_dte (
777
+ cesion_value = fecha_ultimo_vencimiento , dte_value = dte_fecha_emision
778
+ )
779
+
780
+ return values
0 commit comments