#rock_unexpected

1 messages ¡ Page 1 of 1 (latest)

twin needleBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1371724473161744454

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

near monolith
#

The steps to create the invoice:

`upcoming_invoice = stripe.Invoice.upcoming(customer=cust_id)

        if not upcoming_invoice or not upcoming_invoice.get('lines'):
            raise ValueError("No upcoming invoice data available.")

        # Determine if automatic tax is enabled based on the upcoming invoice
        automatic_tax_enabled = upcoming_invoice.get('automatic_tax', {}).get('enabled', False)

        for item in upcoming_invoice['lines']['data']:
            stripe.InvoiceItem.create(
                customer=cust_id,
                amount=item['amount'],
                currency=item['currency'],
                description=item['description'],  
                tax_behavior='exclusive',
            )

        # Create a manual invoice
        invoice = stripe.Invoice.create(
            customer=cust_id,
            collection_method="charge_automatically",  
            auto_advance=False,  
            automatic_tax={"enabled": automatic_tax_enabled},  
            metadata={"annual_advance_payment": True}
        )

`

craggy dust
#

Hi! Looking into this!

#

Do you have an example invoice object ID and subscription ID for what you have attempted?

near monolith
#

Yes, just a min I'll share

#

Invoice Id: in_1RNtelCtiaajKx2EqiCb6Dcf
Subscription ID: sub_1RNsFBCtiaajKx2EvbDu81ma

This subscription is cancelled though right now,

#

I can create and share a different one if you want.

craggy dust
#

Looking into it.

near monolith
#

you can check this:

Invoice id: in_1ROBwiCtiaajKx2Evn89OLOS

Subscription ID: sub_1ROBwGCtiaajKx2EUsmz18EE

craggy dust
#

Can I confirm if your question is that if the tax rates change in the future will the invoice have an updated taxed amount?

near monolith
#

yes

craggy dust
#

Just a moment.

#

Once an invoice is paid, the tax amount will not change even if the tax rates change in the future.

near monolith
#

So at the time of finalizing and paying the invoice the current tax rates which are added at the time of creation will only reflect back? Is that what you meant?

craggy dust
#

Yes

near monolith
#

Any suggestions as to how I can avoid this from happening?

craggy dust
#

Like you want the tax rate and tax amount to be updated in a invoice that has been paid in the past?

near monolith
#

No instead I want the invoice to reflect the correct details at the time of payment.

I will be creating and storing the invoice id in db. So that no multiple calls and multiple manual invoices are created.

When user clicks on pay, the invoice will be paid. Now since we need to remit tax and stuff, we need the correct tax information at the time of invoice payment. Hence I want when the user pays the invoice the tax rates are current rates and not previous past rates.

craggy dust
#

Can I confirm if you are using Stripe automatic tax?

near monolith
#

yes

craggy dust
#

There will be no changes to the invoice once the invoice is finalized and there is no way to around that.