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

This commit is contained in:
Mira Weller
2026-09-29 13:40:18 +02:00
committed by Raphael Michel
parent 912851aa87
commit b7117bb3a3
+2 -4
View File
@@ -1070,10 +1070,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,