I am trying to preview an upcoming invoice with prorated charges.

The client is changing from a 30 euros / Year plan to a 65 euros / Year plan on day 1 (important for proration date calculations).

According to the documentation [here](https://stripe.com/docs/billing/subscriptions/prorations) the client should be charged:

* -30 euros for the remaining time on the old plan
* 65 euros for the remaining time on the new plan

Which comes out to 35 euros in total. The next invoice issued should be for 35 euros.
The following call is made using the Java library to fetch the upcoming invoice:

```
InvoiceUpcomingParams params = InvoiceUpcomingParams.builder()
        .setCustomer(userId)
        .setSubscription(subscriptionId)
        .addSubscriptionItem(
                InvoiceUpcomingParams.SubscriptionItem.builder()
                .setId(subscription.getItems().getData().get(0).getId())
                .setPrice(priceId)
                .build()
        ).setSubscriptionProrationDate(prorationDate)
        .build();

```

The resulting invoice has the following properties:

* amountPaid: 0
* amountDue: 9999
* amountRemaining: 9999
* subTotal: 9999

...and the following invoice lines (ids have been obfuscated):

```
{
    "data": [
        {
            "amount": -3000,
            "currency": "eur",
            "description": "Unused time on xxxxx after 09 Jan 2021",
            "discount_amounts": [],
            "discountable": false,
            "discounts": [],
            "id": "---",
            "invoice_item": "---",
            "livemode": false,
            "metadata": {},
            "object": "line_item",
            "period": {
                "end": 1641756061,
                "start": 1610222989
            },
            "plan": {
                "active": true,
                "aggregate_usage": null,
                "amount": 3000,
                "amount_decimal": 3000,
                "billing_scheme": "per_unit",
                "created": 1598220277,
                "currency": "eur",
                "deleted": null,
                "id": "---",
                "interval": "year",
                "interval_count": 1,
                "livemode": false,
                "metadata": {},
                "nickname": null,
                "object": "plan",
                "product": "---",
                "tiers": null,
                "tiers_mode": null,
                "transform_usage": null,
                "trial_period_days": null,
                "usage_type": "licensed"
            },
            "price": {
                "active": true,
                "billing_scheme": "per_unit",
                "created": 1598220277,
                "currency": "eur",
                "deleted": null,
                "id": "---",
                "livemode": false,
                "lookup_key": null,
                "metadata": {},
                "nickname": null,
                "object": "price",
                "product": "---",
                "recurring": {
                    "aggregate_usage": null,
                    "interval": "year",
                    "interval_count": 1,
                    "trial_period_days": null,
                    "usage_type": "licensed"
                },
                "tiers": null,
                "tiers_mode": null,
                "transform_quantity": null,
                "type": "recurring",
                "unit_amount": 3000,
                "unit_amount_decimal": 3000
            },
            "proration": true,
            "quantity": 1,
            "subscription": "---",
            "subscription_item": "---",
            "tax_amounts": [],
            "tax_rates": [],
            "type": "invoiceitem",
            "unified_proration": null
        },
        {
            "amount": 6499,
            "currency": "eur",
            "description": "Remaining time on xxxx after 09 Jan 2021",
            "discount_amounts": [],
            "discountable": false,
            "discounts": [],
            "id": "---",
            "invoice_item": "---",
            "livemode": false,
            "metadata": {},
            "object": "line_item",
            "period": {
                "end": 1641756061,
                "start": 1610222989
            },
            "plan": {
                "active": true,
                "aggregate_usage": null,
                "amount": 6500,
                "amount_decimal": 6500,
                "billing_scheme": "per_unit",
                "created": 1598220248,
                "currency": "eur",
                "deleted": null,
                "id": "---",
                "interval": "year",
                "interval_count": 1,
                "livemode": false,
                "metadata": {},
                "nickname": null,
                "object": "plan",
                "product": "---",
                "tiers": null,
                "tiers_mode": null,
                "transform_usage": null,
                "trial_period_days": null,
                "usage_type": "licensed"
            },
            "price": {
                "active": true,
                "billing_scheme": "per_unit",
                "created": 1598220248,
                "currency": "eur",
                "deleted": null,
                "id": "---",
                "livemode": false,
                "lookup_key": null,
                "metadata": {},
                "nickname": null,
                "object": "price",
                "product": "---",
                "recurring": {
                    "aggregate_usage": null,
                    "interval": "year",
                    "interval_count": 1,
                    "trial_period_days": null,
                    "usage_type": "licensed"
                },
                "tiers": null,
                "tiers_mode": null,
                "transform_quantity": null,
                "type": "recurring",
                "unit_amount": 6500,
                "unit_amount_decimal": 6500
            },
            "proration": true,
            "quantity": 1,
            "subscription": "---",
            "subscription_item": "---",
            "tax_amounts": [],
            "tax_rates": [],
            "type": "invoiceitem",
            "unified_proration": null
        },
        {
            "amount": 6500,
            "currency": "eur",
            "description": "1 × xxxx (at €65.00 / year)",
            "discount_amounts": [],
            "discountable": true,
            "discounts": [],
            "id": "---",
            "invoice_item": null,
            "livemode": false,
            "metadata": {},
            "object": "line_item",
            "period": {
                "end": 1673292061,
                "start": 1641756061
            },
            "plan": {
                "active": true,
                "aggregate_usage": null,
                "amount": 6500,
                "amount_decimal": 6500,
                "billing_scheme": "per_unit",
                "created": 1598220248,
                "currency": "eur",
                "deleted": null,
                "id": "---",
                "interval": "year",
                "interval_count": 1,
                "livemode": false,
                "metadata": {},
                "nickname": null,
                "object": "plan",
                "product": "---",
                "tiers": null,
                "tiers_mode": null,
                "transform_usage": null,
                "trial_period_days": null,
                "usage_type": "licensed"
            },
            "price": {
                "active": true,
                "billing_scheme": "per_unit",
                "created": 1598220248,
                "currency": "eur",
                "deleted": null,
                "id": "---",
                "livemode": false,
                "lookup_key": null,
                "metadata": {},
                "nickname": null,
                "object": "price",
                "product": "---",
                "recurring": {
                    "aggregate_usage": null,
                    "interval": "year",
                    "interval_count": 1,
                    "trial_period_days": null,
                    "usage_type": "licensed"
                },
                "tiers": null,
                "tiers_mode": null,
                "transform_quantity": null,
                "type": "recurring",
                "unit_amount": 6500,
                "unit_amount_decimal": 6500
            },
            "proration": false,
            "quantity": 1,
            "subscription": "---",
            "subscription_item": "---",
            "tax_amounts": [],
            "tax_rates": [],
            "type": "subscription",
            "unified_proration": null
        }
    ],
    "has_more": false,
    "object": "list",
    "request_options": null,
    "request_params": null,
    "url": "---"
}

```

In short the invoice lines contain the following:

* Unused time on xxxxx after 09 Jan 2021: -3000
* Remaining time on xxxxx after 09 Jan 2021: 6499
* 1 × xxxxx (at €65.00 / year): 6500

Issue 1
-------

**I believe this to be wrong**. According to the documentation [here](https://stripe.com/docs/billing/subscriptions/prorations) the charge should be: *64.99 - 30 = 34.99 euros*

Now if I **go through** with the actual subscription update the invoice that Stripe generates is indeed for 34.99 euros. So there seems to be something wrong with either how I call the upcoming invoice API or what it returns.

What am I missing? Am I supposed to deduct the price of the subscription from the *amountDue* myself?