Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-12155

Financial items are not deleted when associated contributions are deleted

    Details

      Description

      Financial item(s) associated with a contribution need to be deleted when contribution is deleted. We are already deleting all other associated records (line_item, financial_trxn, entity_financial_trxn).

      In review the CiviAccount Data Flow (), looks like financial_item rows may be linked (via entity_table / entity_id) to EITHER a line_item or financial_trxn. Given that, one reasonable approach would be to add the DELETE financial_item query to these two existing functions:

      CRM_Core_BAO_FinancialTrxn::deleteFinancialTrxn

      • delete FROM civicrm_financial_item where entity_table = 'civicrm_financial_trxn' and entity_id = $thisFinancialTrxn

      CRM_Price_BAO_LineItem::deleteLineItems

      • delete FROM civicrm_financial_item where entity_table = 'civicrm_line_item' and entity_id = $thisLineItem

      Also added check for orphaned financial rows to 4.3 upgrade (beta5) in postUpgradeMessage function. Gives user heads-up if there are orphaned records and points to wiki page w/ details and cleanup queries.

      — original post —
      When a contribution is deleted, the records in civicrm_contribution and civicrm_line_item are deleted. However, the associated record in civicrm_financial_item is not deleted and remains orphaned.

      This is at odds with the warning message displayed when you are about to delete a contribution, which says: "Deleting this contribution will result in the loss of the associated financial transactions (if any)."

      Applies to CiviCRM 4.3 beta 3.

        Attachments

        1. AfterDelete-entity_fin_trxn.PNG
          37 kB
          David Greenberg
        2. AfterDelete-Fin_item.PNG
          22 kB
          David Greenberg
        3. AfterDelete-Fin_trxn.PNG
          27 kB
          David Greenberg
        4. BeforeDelete-entity_fin_trxn.PNG
          47 kB
          David Greenberg
        5. BeforeDelete-fin_item.PNG
          48 kB
          David Greenberg
        6. BeforeDelete-Fin_trxn.PNG
          32 kB
          David Greenberg

          Issue Links

            Activity

              People

              • Assignee:
                dgg David Greenberg
                Reporter:
                kirk Kirk Jackson
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: