Answers.Body: <p>For every contribution, a line_item is being created. The <code>contribution_id</code> field is the FK reference to the <code>civicrm_contribution</code> table. </p>
  
  <p>If I manually delete the Contribution record related to the Contact, the contribution gets deleted from <code>civicrm_contribution</code> table, which results in <code>contribution_id</code> to be NULL in <code>civicrm_line_item</code>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-30T13:54:57.630Z
Answers.Text: I would have thought that if a contribution is deleted the line items linked to it should also been deleted.
Answers.UserDisplayName: JoAnne
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-29T17:13:46.037Z
Answers.Text: @JoAnne - I believe the line items aren't deleted for auditing/bookkeeping reasons.  I could be wrong!
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-30T13:28:03.707Z
Answers.LastActivityDate: 2015-07-30T13:28:03.707Z
Answers.UserDisplayName: jitendra - fuzion
Answers.Body: <p>Here's one context where a <code>civicrm_line_item</code> record is created with <code>contribution_id</code> NULL:<br>
  <a href="https://issues.civicrm.org/jira/browse/CRM-14918" rel="nofollow">Line Items should be created for all Membership Signup/Renewal and Participant Registration transactions</a></p>
  
  <p>See also:<br>
  <a href="https://issues.civicrm.org/jira/browse/CRM-15055" rel="nofollow">Line item for membership entity should be created even when Record Payment is not checked</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-05T16:34:40.717Z
Answers.LastActivityDate: 2016-05-05T16:34:40.717Z
Answers.UserDisplayName: davejenx
Body: <p>The table "civicrm_line_item" has a field called "contribution_id". For the most part, this field is filled in. But there are many records where the "contribution_id" field is NULL.  I have seen this with happen no matter what the "entity_table" value is. </p>
  
  <p>Why is "contribution_id sometimes NULL? What would cause this? (I have seen this in version 4.5.x and version 4.6.5)</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-07-29T13:29:15.027Z
Comments.Text: I've noticed this when importing participants/memberships. Could it be the same thing that you're seeing?
Comments.UserDisplayName: Nicholai
Tags: <civicontribute>
Title: Why is the field "contribution_id" in "civicrm_line_item" sometimes NULL
ThreadText: # Why is the field "contribution_id" in "civicrm_line_item" sometimes NULL
  
  (Asked by: username_0 on 2015-07-28)
  
  The table "civicrm\_line\_item" has a field called "contribution\_id". For the most part, this field is filled in. But there are many records where the "contribution\_id" field is NULL. I have seen this with happen no matter what the "entity\_table" value is.
  
  Why is "contribution\_id sometimes NULL? What would cause this? (I have seen this in version 4.5.x and version 4.6.5)
  
  **Tags:** civicontribute
  
  > **Comments:**
  > **username_1**: I've noticed this when importing participants/memberships. Could it be the same thing that you're seeing?  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2015-07-30. Score: 1
  
  For every contribution, a line\_item is being created. The `contribution_id` field is the FK reference to the `civicrm_contribution` table.
  
  If I manually delete the Contribution record related to the Contact, the contribution gets deleted from `civicrm_contribution` table, which results in `contribution_id` to be NULL in `civicrm_line_item`.
  
  > **Comments:**
  > **username_3**: I would have thought that if a contribution is deleted the line items linked to it should also been deleted.  
  > **username_4**: @username_3 - I believe the line items aren't deleted for auditing/bookkeeping reasons.  I could be wrong!  
  
  ---
  
  ### Answer by username_5 on 2016-05-05. Score: 0
  
  Here's one context where a `civicrm_line_item` record is created with `contribution_id` NULL:  
  [Line Items should be created for all Membership Signup/Renewal and Participant Registration transactions](https://issues.civicrm.org/jira/browse/CRM-14918)
  
  See also:  
  [Line item for membership entity should be created even when Record Payment is not checked](https://issues.civicrm.org/jira/browse/CRM-15055)
  
  
  ---
  
  