Changes this file in your project. You can undo it afterwards.
Proposed source edit · original stays intact until approval
View diff
@@ -1,14 +1,17 @@ """Date helpers for invoice terms."""+import calendar from datetime import date, timedelta def add_months(start: date, months: int) -> date:- """Return the same day `months` later."""+ """Return the same day `months` later, clamped to that month's last day.""" index = start.month - 1 + months year, month = start.year + index // 12, index % 12 + 1- return date(year, month, start.day)+ last_day = calendar.monthrange(year, month)[1]+ return date(year, month, min(start.day, last_day)) def due_date(issued: date, terms_days: int = 30) -> date:




























