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

This commit is contained in:
Mira Weller
2026-09-29 13:43:52 +02:00
committed by Raphael Michel
parent d5fe5b49df
commit 9eaa6b0e1d
+2 -4
View File
@@ -1060,10 +1060,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,