mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 05:53:43 +00:00
stripe: Use more specific type annotations.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
c5027e6bca
commit
e7a3d743d1
@@ -864,7 +864,7 @@ class BillingSession(ABC):
|
|||||||
plan_tier: int,
|
plan_tier: int,
|
||||||
billing_schedule: int,
|
billing_schedule: int,
|
||||||
charge_automatically: bool,
|
charge_automatically: bool,
|
||||||
invoice_period: Dict[str, int],
|
invoice_period: stripe.InvoiceItem.CreateParamsPeriod,
|
||||||
license_management: Optional[str] = None,
|
license_management: Optional[str] = None,
|
||||||
days_until_due: Optional[int] = None,
|
days_until_due: Optional[int] = None,
|
||||||
on_free_trial: bool = False,
|
on_free_trial: bool = False,
|
||||||
@@ -910,7 +910,9 @@ class BillingSession(ABC):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if charge_automatically:
|
if charge_automatically:
|
||||||
collection_method = "charge_automatically"
|
collection_method: Literal["charge_automatically" | "send_invoice"] = (
|
||||||
|
"charge_automatically"
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
collection_method = "send_invoice"
|
collection_method = "send_invoice"
|
||||||
# days_until_due is required for `send_invoice` collection method. Since this is an invoice
|
# days_until_due is required for `send_invoice` collection method. Since this is an invoice
|
||||||
@@ -3006,7 +3008,7 @@ class BillingSession(ABC):
|
|||||||
invoiced_through_id = plan.invoiced_through.id
|
invoiced_through_id = plan.invoiced_through.id
|
||||||
|
|
||||||
invoice_item_created = False
|
invoice_item_created = False
|
||||||
invoice_period = None
|
invoice_period: stripe.InvoiceItem.CreateParamsPeriod | None = None
|
||||||
for ledger_entry in LicenseLedger.objects.filter(
|
for ledger_entry in LicenseLedger.objects.filter(
|
||||||
plan=plan, id__gt=invoiced_through_id, event_time__lte=event_time
|
plan=plan, id__gt=invoiced_through_id, event_time__lte=event_time
|
||||||
).order_by("id"):
|
).order_by("id"):
|
||||||
@@ -3104,7 +3106,9 @@ class BillingSession(ABC):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if plan.charge_automatically:
|
if plan.charge_automatically:
|
||||||
collection_method = "charge_automatically"
|
collection_method: Literal["charge_automatically" | "send_invoice"] = (
|
||||||
|
"charge_automatically"
|
||||||
|
)
|
||||||
days_until_due = None
|
days_until_due = None
|
||||||
else:
|
else:
|
||||||
collection_method = "send_invoice"
|
collection_method = "send_invoice"
|
||||||
@@ -3435,7 +3439,7 @@ class BillingSession(ABC):
|
|||||||
# Stripe does something weird and puts the discount item first, so we need to reverse the order here.
|
# Stripe does something weird and puts the discount item first, so we need to reverse the order here.
|
||||||
invoice_items.reverse()
|
invoice_items.reverse()
|
||||||
for invoice_item in invoice_items:
|
for invoice_item in invoice_items:
|
||||||
price_args = {}
|
price_args: PriceArgs = {}
|
||||||
# If amount is positive, this must be non-discount item we need to update.
|
# If amount is positive, this must be non-discount item we need to update.
|
||||||
if invoice_item.amount > 0:
|
if invoice_item.amount > 0:
|
||||||
assert invoice_item.price is not None
|
assert invoice_item.price is not None
|
||||||
|
|||||||
Reference in New Issue
Block a user