#codex-invoice-decimal

1 messages · Page 1 of 1 (latest)

clear rainBOT
stoic cradle
#

I am using Avalara tax, with a subscription of 3 quantities

#

So each time I refund a subscription quantity 1, I have to refund 1/3rd of the Avalara tax

#

But in the end, when I refund all 3 sequentially, I am left with a "partial refund" of $0.02 remaining

#

Am I able to refund so that each partial refund will total to $0.00 remaining (i.e. FULL refund)

dull grove
#

👋 @stoic cradle all our amounts are in the smallest currency unit. So if you want $0.02 USD then you pass amount: 2, there's no decimal/float

#

codex-invoice-decimal

stoic cradle
#

In this case, how can I refund 1/3rd of the Avalara tax item exactly? So there is no leftover remaining amount on the invoice?

#

i.e. it will be a FULL refund, instead of a partial refund

dull grove
#

I'm sorry I don't understand what you could mean and we don't really control Avalara's integration

#

you have an Invoice for $X, and then you can refund how much you want up to $X

stoic cradle
#

For example, Avalara's tax is 335 cents on a subscription quantity of 3. If I refund a quantity of 1, I have to refund 1/3rd the tax. 1/3rd of that is 111 cents rounded down. If I refund two more times (fully cancelled), the invoice has 2 cents left

#

----------------------That is not what we want. If we refund 1/3rd of that three times, we want the invoice to be left with 0 cents

dull grove
#

Unfortunately you will have to handle that logic/rounding yourself in that case I think

stoic cradle
#

In that case is there any way to know how much is left remaining on a current invoice?

#

Per invoice line item?

dull grove
#

I don't think so

stoic cradle
#

Ahh so there's no API to check the remaining charge for a customer?

#

In that case, what kind of rounding does Stripe do for calculations? Banker's rounding, etc.?

dull grove
#

I mean there are some APIs, I just don't get what you are after at all unfortunately nor how you refund. If you do your own math and refund 111 then there's 224 left and then the next time if you refund 111 instead of 112 then there's 113 left

stoic cradle
#

Yes, and then the final refund, 113 minus 111 = 2 cents

#

As in, when I refund all 3 subscription items, and 3/3 of the avalara price, I am still off by 2 cents

#

It should instead be zero

dull grove
#

how do you refund all 3 subscriptions items. Like what exact API and code are you using?

stoic cradle
#

stripe.Refund.create

#

When we refund 1 subscription item, we refund the 1 subscription item cost + 1/3rd of the tax calculated

#

Refund second time, then refund third time (last time) should leave a total of ZERO remaining on the invoice

#

But we are left with 2 cents since we cannot refund by exact floats.

dull grove
#

okay so you do your own refund/math logic

#

in that case that's on you to keep track of how much was refunded and how much is left and to handle the rounding

stoic cradle
#

There is no API to check the remaining value on an invoice even after refunds?

dull grove
#

An Invoice has a Charge associated with it, that Charge can be refunded N times, so you can look at the original Charge's amount versus how much was refunded in amount_refunded and use that for example

#

does that make sense?

stoic cradle
#

Alright, I see. Thank you for the help

#

Yes