#Jeremy-subscriptions
1 messages ยท Page 1 of 1 (latest)
you do have to use invoices and look at each line item to calculate revenue I would say
each line item points to the information about what is prorated/charged
I did but that didn't work
It should, it's just a lot of work and dozens of edge-cases
we also have https://stripe.com/docs/revenue-recognition
this is wrong, they only paid $130.09 for this subscription
I don't want to use Rev recognition, it's for the client, not me
They need to understand their cost
Yeah I'm sorry I don't really understand. This is definitely what they paid
the reason why they paid less is because they change the subscription. E.g. They purchase a sub for 147 (for the month), a few days later, they reduce the quantity (generating credits), then a few weeks later they increase the quantity (this use some of that credit, hence no invoice generated), at renewal they pay 225 and reduce amount...
You need to understand that clients have multiple subscriptions
I know but if they had credits the invoice amount would be lower
it won't, because credit will be used for another subscription
they have plenty of subscriptions, all with different billing cycles and quantities
1 client, multiple subscriptions
I'm sorry, you seem really deep in something and convined something doesn't work but there's no real actionable info. You shared a screenshot of 5 invoices amounts and that's it
nothing is wrong
I need to calculate how much each subscription cost the client
The client has multiple subscriptions (1 per product) and he needs to know how much each product cost him in services.
I don't know how to calculate this, looking at invoice line won't help as negative amount is not created in invoices unfortunately
otherwise this would have been easy, look at each line item
but credits back to the stripe client is not tracked as invoice line
I'm looking for help as to the best work around/approach
Can you take a concrete examples? You keep saying "doesn't work" and I don't get why
how do I calculate how much subscription A generated? (the invoice line will only show $100, but it only generated $75)
hehe was doing it ๐
So why would the invoice line only show $100? The +$25 would directly be reflected on an invoice and reference that subscription
why aren't you finding this?
there is no invoice created with the $25 credits, but you say that when B is created and used the credit the $25 mentioned that it came from A? That's not what I see but I can double check
yeah you must be misunderstanding something, the credit is absolutely reflected as a credit invoice line item and visible on one of the invoices
That's what I expected to happen indeed but did not see that, let me double check, could be that we don't capture everything we should somehow.
the weird thing is that I checked all the invoices in the screenshot I pasted, they are all full amount, no credit is mentioned
and I can see the events that they changed subscriptions
do you have an example event?
sure, you want an event of what? change subscription quantity?
yeah event id evt_123
sure
here is the list of event, let me get you the event id for the prorated
this is the pro rated event evt_1JbPhQAkNDVprSsPKs8A6xZW
invoice is null
it could be the code on our end not generating invoices for negative invoices? but yeah no invoice line ๐ฆ
so clearly that event shows an invoice item was created
ah true
but I don't see the credit (probably because it's used but another sub?)
seems to lead to a Upcoming invoice
yeah sorry that's a pretty active subscription so not easy to debug and I'm not sure how much you understand about proration and subscription changes and when invoices are cut
agree, but that was very helpful, querying the invoice item by code, I can see the invoice and I can see it has a negative value. This is very helpful already!
that request is your own code explicitly creating an invoice after the subscription is cut
my customers have tons of sub and they keep changing subscription plan and quantity, hence why they need that info ๐
I think our code keep asking creation of invoice for any change
Ah! it could be that we don't capture invoices that don't generate charges!
hence why I would not see the invoices that are negative
I'll keep digging, thanks!
my advice is to take one customer and list all invoices and dump all line items one by one
it should help you debug, that customer is a great example
that's what I did, but I used our database for the record of invoices, and I beleive we only capture invoice with a charge, this would explain my problem
ah yeah that makes sense
thanks again! I'm happy I may be able to do it with just invoices (which makes sense)
also you should look at proration_behavior
you could pass always_invoice to immediately charge/invoice and have it tied to the subscription
instead of explicitly ask for an invoice creation? cool!
yes it seems to match a lot more with what you want
ok here is my problem:
Looking at that refund event, the invoice created is : in_1JbPhQAkNDVprSsP4RIM6eyr
Listing all the invoices for sub_Jb2G3XacVBSgza however only gives me:
in_1Jg4LLAkNDVprSsPb8abSOvX
in_1JVC2pAkNDVprSsPv9Kn9bG7
in_1JJxHhAkNDVprSsPyIsIKJdI
in_1J8iUrAkNDVprSsP6bqe7VN5
in_1IxqCKAkNDVprSsPtMy8hHrr
Could have been caused by not using the flag you mentioned? I don't get why in_1JbPhQAkNDVprSsP4RIM6eyr will not show when querying sub_Jb2G3XacVBSgza
Because when looking at the invoice, this sub is mentioned.
What am I missing ?
that's because your code explicitly creates a one off invoice not tied to the subscription
ARRRRG
you call https://stripe.com/docs/api/invoices/create and that pulls all pending invoice items and so it's not subscription specific
there's an extra subscription parameter if you want to only pull that subscription's pending invoice items and that invoice would have the sub_123 associated
but really moving to proration_behavior is a lot cleaner/better
yeah for sure, we'll move to that.
thanks for the tip
Is there a way to get all the invoices referencing this sub you can think of given the current implementation :/ ?
list every invoice per customer and then look at each line item
the line item of that invoice would point to the sub
Yeah make sense. I think I got a pretty good understanding of what to do next (short and long term). Thanks a ton for all the help.
Oh, I found that the invoice was created explicitly in our code to immediately charge the customer when they increase the amount of their subscription instead of waiting for the next billing cycle.
(subscription was not mentioned in the invoice creation indeed).
proration_behavior probably won't address this case
Nice, will do of course. It's 3am here, I should go to bed ๐
๐ have a great night adn come back if you have follow up questions!