#mentijm - credit-note

1 messages ยท Page 1 of 1 (latest)

real flare
bronze skiff
#

Hey! Yeah I see that but I need to send line items

#

and they need to have quantity for normal line items and amount for proration it seems. Got that far but I dont understand this error message

#

Should refunds/cns include tax to be full?

real flare
ashen temple
#

That'll give you any details re: proration (it's a pretty new field, let me know if it's useful)

bronze skiff
#

Ok, and how would one create a credit note on an original invoice containing proration?

#

Tried with sending the proration line to creditnote creation and just issuing the credit note based on the normal purchase line

#

screenshot without the proration

ashen temple
#

Hmm, what are you actually trying to achieve here?

bronze skiff
#

when we refund a invoice/payment it triggers a charge.refunded but we wanna have a credit note for that one as well

#

so we doing refund: re_1234 (example refund id from charge.refunded webhook payload) instead of the amount in the picture above

ashen temple
#

Can you share the Invoice ID?

bronze skiff
#

in_1KbiPSLLAsLlRiDemp3kEAXD

#

Maybe this makes the goal/purpose clearer for you

#

This was what we had earlier (before realising that it didn't work for refunds of invoices with proration items)

#

And the goal is to always have a credit note for each refund (but we still wanna let support into Stripe dashboard but it's very easy to find the refund button everywhere and go that route instead of issuing a credit note with a refund)

ashen temple
#

Taking a look

bronze skiff
#

Thank you

ashen temple
#
{
  error: {
    message: "The total amount of all credit notes associated with invoice line item il_1KbiPSLLAsLlRiDeS0WT6aXq cannot exceed the invoiced amount (including discounts and taxes) for the line item.",
    type: "invalid_request_error"
  }
}
bronze skiff
#

Ok, that was one were I changed the -29988 to absolute number tho (to get it through the 1 or greater error message)

ashen temple
#

The issue is that that Invoice Item already has a proration/credit applied

bronze skiff
#

Yes, I understand that, but how does one create a credit note for such a case then?

#

say I buy 1 license x 375usd

#

instantly add a license (which makes a new invoice of 375*2 total - the proration of 375 for the unused time)

ashen temple
#

Yes, but creating a Credit Note applies the adjustments to the applicable invoice. In the case of in_1KbiPSLLAsLlRiDemp3kEAXD, there's already prorations applied to account for those adjustments

#

Do you need a credit note purely for accounting purposes or something?

bronze skiff
#

Yes that was our plan

#

So what does this mean basically?

#

We can't issue a credit note to an invoice that contains an proration item?

ashen temple
#

I think you can, I'm just not sure what parameters/values you need to pass in this instance. Checking

bronze skiff
#

Ok thanks ๐Ÿ™

upbeat turret
#

I guess I'm missing something but can't you just do this?

const creditNote = await stripe.creditNotes.create({
  invoice:subscription.latest_invoice.id,
  refund_amount: subscription.latest_invoice.amount_due,
  lines: [{type:"custom_line_item", description:"Refund", unit_amount:subscription.latest_invoice.amount_due, quantity:1}]
});
#

it's not perfect really since it's just "hacking" a custom line item but I don't see how else we expect this to work โ€” each line has to be positive, and the amount from all the CreditNote lines has to add up to the total amount being refunded, so you can't really transpose the Invoice line items directly into it. This I suppose works, but admittedly I rarely use this API at all.

bronze skiff
#

Hey karllekko ok thanks for this suggestion

#

I'll test and see if it works for us

bronze skiff
#

Hi again

#

Stripe::InvalidRequestError: Custom line items are not supported for invoices with automatic_tax.enabled = true.

#

It says this hmm

upbeat turret
#

oh, that's annoying

#

yeah I don't know you can do this, sorry

#

my best effort is

lines = lines.data.filter(x => x.amount > 0).map(x => {return {type:"invoice_line_item", amount:x.amount, invoice_line_item:x.id}})


const creditNote = await stripe.creditNotes.create({
  invoice:subscription.latest_invoice.id,
  refund_amount: subscription.latest_invoice.amount_due,
  lines: lines
});

i.e. create the lines for the credit note only using the positive items on the invoice, but then the lines won't add up to refund amount (because they don't include the negative proration) so you get
The credit note amount ($300.00) must be less than the invoice amount ($200.00).

#

I'll try seeing what the dashboard does is if I use that to issue a credit note for this invoice...

#

ah right, I see.

#

you are meant to credit the invoice line item but not use its amount, instead change it so that it's smaller and inclusive of the proration or so on, so that it adds up to less than the total amount. Which requires custom business logic(or manually typing a number as the dashboard does it). It's making more sense to me now.

bronze skiff
#

Hmm

#

Which of the invoice line items?

#

the non-proration one?

upbeat turret
#

well, any of the positive ones.

#

you have to credit the positive ones but only for amounts that ultimately add up to being less-than-equal-to the actual invoice total

bronze skiff
#

Hmm ok, and one can set amount instead of quantity on those line items?

#

ie: one line item with -375 and one line item with 2x 375 (totalling to 375)

#

I need to credit the 2x 375 with amount of 375 instead of quantity of 2?

upbeat turret
#

either way works as far as I know

#

but I suppose lines: [{type:"invoice_line_item", amount:375, invoice_line_item:<ID of the item that is 2x375> } ] maybe makes most sense

#

but writing code to do this programmatically is non trivial unfortunately