Skip to content

Commit

Permalink
Fixed validation of dates of fatture collegate
Browse files Browse the repository at this point in the history
  • Loading branch information
spanezz committed Jan 3, 2024
1 parent 8ed00df commit ce8bee6
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions a38/fattura.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,16 +672,19 @@ class DatiGenerali(models.Model):

def validate_model(self, validation):
super().validate_model(validation)
dfc_dates = [x.data for x in self.dati_fatture_collegate if x.data is not None]
if dfc_dates and self.dati_generali_documento.data < min(dfc_dates):
validation.add_error(
(
self.dati_fatture_collegate._meta["data"],
self.dati_generali_documento._meta["data"],
),
"dati_generali_documento.data is earlier than dati_fatture_collegate.data",
code="00418",
)
for idx, dfc in enumerate(self.dati_fatture_collegate):
if dfc.data is None:
continue
if self.dati_generali_documento.data < dfc.data:
validation.add_error(
(
dfc._meta["data"],
self.dati_generali_documento._meta["data"],
),
f"dati_generali_documento[{idx}].data"
" is earlier than dati_fatture_collegate.data",
code="00418",
)


@export
Expand Down

0 comments on commit ce8bee6

Please sign in to comment.