Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link LineItem to an Invoice via some foreign key or related manager #1958

Open
gmulz opened this issue Aug 3, 2023 · 1 comment
Open

Link LineItem to an Invoice via some foreign key or related manager #1958

gmulz opened this issue Aug 3, 2023 · 1 comment
Labels
discussion The premise or details of this issue is open for discussion
Milestone

Comments

@gmulz
Copy link

gmulz commented Aug 3, 2023

Is your request related to a problem? Please describe.

Recently I've been trying to access the LineItem objects that are tied to a particular Invoice. I would like to do this offline (i.e. through the database/Django models, instead of calling the Stripe API directly or using api_list). However, there does not seem to be any invoice_id property or some join table between Invoice and LineItem.

In Stripe's own JSON response from their invoice API, the lines property encapsulates this relationship. On an Invoice response from Stripe, there is an array of LineItem objects that clearly tie to the given Invoice. But in the djstripe models, nothing directly conveys "given this Invoice, these are the LineItems"

To make matters more complicated, LineItem can have either an associated InvoiceItem (the invoice_item_id column) or a Subscription (subscription_id column), and doesn't always have both available. InvoiceItem clearly links back to an Invoice through the invoice_id, but Subscription does not directly link to a given Invoice. So the subscription-type LineItem isn't covered well for this problem.

Describe the solution you'd like

Either a lines Field/ many-to-one manager/join table on the Invoice item relating it directly to LineItem, or an invoice ForeignKey field on LineItem itself. Just generally some direct relation in the database between a Invoice and a LineItem

Additional context

@gmulz gmulz added the discussion The premise or details of this issue is open for discussion label Aug 3, 2023
@arnav13081994 arnav13081994 added this to the 3.0.0 milestone Oct 2, 2023
@arnav13081994
Copy link
Collaborator

@gmulz There is already a todo to add the lines column to the Invoice table.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion The premise or details of this issue is open for discussion
Projects
None yet
Development

No branches or pull requests

2 participants