Skip to content

Commit

Permalink
fix an error that cause that an renewed financing was showed as error
Browse files Browse the repository at this point in the history
  • Loading branch information
jefer94 committed Sep 19, 2024
1 parent b153ee8 commit 6aea26d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion breathecode/payments/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,9 @@ def alert_payment_issue(message: str, button: str) -> None:
subscription.valid_until += delta

subscription.invoices.add(invoice)

subscription.status = "ACTIVE"
subscription.save()

value = invoice.currency.format_price(invoice.amount)

subject = translation(
Expand Down Expand Up @@ -572,6 +573,9 @@ def alert_payment_issue(message: str, button: str) -> None:
remaining_installments -= 1
plan_financing.valid_until = utc_now + relativedelta(months=remaining_installments)

elif remaining_installments > 0:
remaining_installments -= 1

plan_financing.invoices.add(invoice)

value = invoice.currency.format_price(invoice.amount)
Expand Down Expand Up @@ -604,6 +608,7 @@ def alert_payment_issue(message: str, button: str) -> None:
delta += relativedelta(months=1)

plan_financing.next_payment_at += delta
plan_financing.status = "ACTIVE" if remaining_installments > 0 else "FULLY_PAID"
plan_financing.save()

# if this charge but the client paid all its installments, there hasn't been a new bag created
Expand Down

0 comments on commit 6aea26d

Please sign in to comment.