Fix inefficient loop in compute_validity (Z#23245937 / PRT-013)

This commit is contained in:
Mira Weller
2026-09-29 14:30:53 +02:00
committed by Raphael Michel
parent 4edd3c4654
commit c7d6630979
+2 -4
View File
@@ -1050,10 +1050,8 @@ class Item(LoggedModel):
replace_year = valid_until.year
replace_month = valid_until.month + self.validity_dynamic_duration_months
while replace_month > 12:
replace_month -= 12
replace_year += 1
replace_year += (replace_month - 1) // 12
replace_month = ((replace_month - 1) % 12) + 1
max_day = calendar.monthrange(replace_year, replace_month)[1]
replace_date = date(
year=replace_year,