Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit 5d163cf

Browse files
refactor: Change variable definition
1 parent ad4d771 commit 5d163cf

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

services/billing.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,13 @@ def cancel_and_refund(
158158
):
159159
stripe.Subscription.cancel(owner.stripe_subscription_id)
160160

161-
start_of_last_period = (
162-
current_subscription_datetime - relativedelta(months=1)
163-
if subscription_plan_interval == "month"
164-
else current_subscription_datetime - relativedelta(years=1)
165-
)
161+
start_of_last_period = current_subscription_datetime - relativedelta(months=1)
162+
invoice_grace_period_start = current_subscription_datetime - relativedelta(days=1)
163+
164+
if subscription_plan_interval == "year":
165+
start_of_last_period = current_subscription_datetime - relativedelta(years=1)
166+
invoice_grace_period_start = current_subscription_datetime - relativedelta(days=3)
167+
166168
invoices_list = stripe.Invoice.list(
167169
subscription=owner.stripe_subscription_id,
168170
status="paid",
@@ -171,11 +173,7 @@ def cancel_and_refund(
171173
"created.lt": int(current_subscription_datetime.timestamp()),
172174
},
173175
)
174-
invoice_grace_period_start = (
175-
current_subscription_datetime - relativedelta(days=1)
176-
if subscription_plan_interval == "month"
177-
else current_subscription_datetime - relativedelta(days=3)
178-
)
176+
179177
# we only want to refund the invoices for the latest, current period
180178
recently_paid_invoices_list = [
181179
invoice

0 commit comments

Comments
 (0)