(
        cls,
        api_key=djstripe_settings.STRIPE_SECRET_KEY,
        customer=None,
        coupon=None,
        subscription=None,
        subscription_plan=None,
        subscription_prorate=None,
        subscription_proration_date=None,
        subscription_quantity=None,
        subscription_trial_end=None,
        **kwargs,
    )
return UpcomingInvoice._create_from_stripe_object(
            upcoming_stripe_invoice, save=False
        )
Gets the upcoming preview invoice (singular) for a customer.

        At any time, you can preview the upcoming
        invoice for a customer. This will show you all the charges that are
        pending, including subscription renewal charges, invoice item charges,
        etc. It will also show you any discount that is applicable to the
        customer. (Source: https://stripe.com/docs/api#upcoming_invoice)

        .. important:: Note that when you are viewing an upcoming invoice,
            you are simply viewing a preview.

        :param customer: The identifier of the customer whose upcoming invoice \
        you'd like to retrieve.
        :type customer: Customer or string (customer ID)
        :param coupon: The code of the coupon to apply.
        :type coupon: str
        :param subscription: The identifier of the subscription to retrieve an \
        invoice for.
        :type subscription: Subscription or string (subscription ID)
        :param subscription_plan: If set, the invoice returned will preview \
        updating the subscription given to this plan, or creating a new \
        subscription to this plan if no subscription is given.
        :type subscription_plan: Plan or string (plan ID)
        :param subscription_prorate: If previewing an update to a subscription, \
        this decides whether the preview will show the result of applying \
        prorations or not.
        :type subscription_prorate: bool
        :param subscription_proration_date: If previewing an update to a \
        subscription, and doing proration, subscription_proration_date forces \
        the proration to be calculated as though the update was done at the \
        specified time.
        :type subscription_proration_date: datetime
        :param subscription_quantity: If provided, the invoice returned will \
        preview updating or creating a subscription with that quantity.
        :type subscription_quantity: int
        :param subscription_trial_end: If provided, the invoice returned will \
        preview updating or creating a subscription with that trial end.
        :type subscription_trial_end: datetime
        :returns: The upcoming preview invoice.
Gets the upcoming preview invoice (singular) for a customer.
Gets the upcoming preview invoice ( singular ) for a customer .
def upcoming(
        cls,
        api_key=djstripe_settings.STRIPE_SECRET_KEY,
        customer=None,
        coupon=None,
        subscription=None,
        subscription_plan=None,
        subscription_prorate=None,
        subscription_proration_date=None,
        subscription_quantity=None,
        subscription_trial_end=None,
        **kwargs,
    ) -> Optional["UpcomingInvoice"]:
        """
        Gets the upcoming preview invoice (singular) for a customer.

        At any time, you can preview the upcoming
        invoice for a customer. This will show you all the charges that are
        pending, including subscription renewal charges, invoice item charges,
        etc. It will also show you any discount that is applicable to the
        customer. (Source: https://stripe.com/docs/api#upcoming_invoice)

        .. important:: Note that when you are viewing an upcoming invoice,
            you are simply viewing a preview.

        :param customer: The identifier of the customer whose upcoming invoice \
        you'd like to retrieve.
        :type customer: Customer or string (customer ID)
        :param coupon: The code of the coupon to apply.
        :type coupon: str
        :param subscription: The identifier of the subscription to retrieve an \
        invoice for.
        :type subscription: Subscription or string (subscription ID)
        :param subscription_plan: If set, the invoice returned will preview \
        updating the subscription given to this plan, or creating a new \
        subscription to this plan if no subscription is given.
        :type subscription_plan: Plan or string (plan ID)
        :param subscription_prorate: If previewing an update to a subscription, \
        this decides whether the preview will show the result of applying \
        prorations or not.
        :type subscription_prorate: bool
        :param subscription_proration_date: If previewing an update to a \
        subscription, and doing proration, subscription_proration_date forces \
        the proration to be calculated as though the update was done at the \
        specified time.
        :type subscription_proration_date: datetime
        :param subscription_quantity: If provided, the invoice returned will \
        preview updating or creating a subscription with that quantity.
        :type subscription_quantity: int
        :param subscription_trial_end: If provided, the invoice returned will \
        preview updating or creating a subscription with that trial end.
        :type subscription_trial_end: datetime
        :returns: The upcoming preview invoice.
        """

        # Convert Customer to id
        if customer is not None and isinstance(customer, StripeModel):
            customer = customer.id

        # Convert Subscription to id
        if subscription is not None and isinstance(subscription, StripeModel):
            subscription = subscription.id

        # Convert Plan to id
        if subscription_plan is not None and isinstance(subscription_plan, StripeModel):
            subscription_plan = subscription_plan.id

        try:
            upcoming_stripe_invoice = cls.stripe_class.upcoming(
                api_key=api_key,
                customer=customer,
                coupon=coupon,
                subscription=subscription,
                subscription_plan=subscription_plan,
                subscription_prorate=subscription_prorate,
                subscription_proration_date=subscription_proration_date,
                subscription_quantity=subscription_quantity,
                subscription_trial_end=subscription_trial_end,
                **kwargs,
            )
        except InvalidRequestError as exc:
            if str(exc) != "Nothing to invoice for customer":
                raise
            return None

        # Workaround for "id" being missing (upcoming invoices don't persist).
        upcoming_stripe_invoice["id"] = "upcoming"

        return UpcomingInvoice._create_from_stripe_object(
            upcoming_stripe_invoice, save=False
        )
def upcoming ( cls , api_key = djstripe_settings . STRIPE_SECRET_KEY , customer = None , coupon = None , subscription = None , subscription_plan = None , subscription_prorate = None , subscription_proration_date = None , subscription_quantity = None , subscription_trial_end = None , * * kwargs , ) -> Optional [ "UpcomingInvoice" ] : # Convert Customer to id if customer is not None and isinstance ( customer , StripeModel ) : customer = customer . id # Convert Subscription to id if subscription is not None and isinstance ( subscription , StripeModel ) : subscription = subscription . id # Convert Plan to id if subscription_plan is not None and isinstance ( subscription_plan , StripeModel ) : subscription_plan = subscription_plan . id try : upcoming_stripe_invoice = cls . stripe_class . upcoming ( api_key = api_key , customer = customer , coupon = coupon , subscription = subscription , subscription_plan = subscription_plan , subscription_prorate = subscription_prorate , subscription_proration_date = subscription_proration_date , subscription_quantity = subscription_quantity , subscription_trial_end = subscription_trial_end , * * kwargs , ) except InvalidRequestError as exc : if str ( exc ) != "Nothing to invoice for customer" : raise return None # Workaround for "id" being missing (upcoming invoices don't persist). upcoming_stripe_invoice [ "id" ] = "upcoming" return UpcomingInvoice . _create_from_stripe_object ( upcoming_stripe_invoice , save = False )