stripe: Fix invoice_plans_as_needed default value.

Python evaluates default values once when the function is defined, not
when it is called.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2023-04-27 13:25:38 -07:00 committed by Tim Abbott
parent 7ae7b753da
commit 13545ff885
1 changed files with 3 additions and 1 deletions

View File

@ -940,7 +940,9 @@ def invoice_plan(plan: CustomerPlan, event_time: datetime) -> None:
plan.save(update_fields=["next_invoice_date"])
def invoice_plans_as_needed(event_time: datetime = timezone_now()) -> None:
def invoice_plans_as_needed(event_time: Optional[datetime] = None) -> None:
if event_time is None: # nocoverage
event_time = timezone_now()
for plan in CustomerPlan.objects.filter(next_invoice_date__lte=event_time):
invoice_plan(plan, event_time)