progressivetech / net.ourpowerbase.sumfields

The Summary Fields extension creates read-only custom data fields that extend Contact and are automatically populated with up-to-date totals such as total lifetime contributions, last contribution amount, last attended event, etc.
Other
8 stars 29 forks source link

incorrect contribution values for legacy contributions lacking line_item entries #79

Closed twomice closed 3 years ago

twomice commented 4 years ago

In modern CiviCRM versions, every contribution has at least one line item, as well as entries in other tables, e.g., as Jamie notes in https://github.com/progressivetech/net.ourpowerbase.sumfields/issues/66#issue-504758267:

If you create a contribution for $1000.00, then a record is entered in:

civicrm_contribution: the main contribution record civicrm_line_item: one contribution can be split into different line items - for example - a portion of an event fee could go to the event fee, and a portion could go as a donation (different financial_type_ids). civicrm_financial_item: every civicrm_line_item record might have one more more civicrm_financial_items which seem to adjustments made to the line items civicrm_entity_financial_trxn: this seems to simply link contributions and line items to civicrm_financial_trxn civicrm_financial_trxn: this table seems to serve as a double entry accounting system - recording which financial account each transaction goes in and out of

But in older versions of CiviCRM (in my case, version 4.2.17), simple single-value contributions were recorded in civicrm_contribution with no corresponding record in civicrm_line_item (and probably not in most of the other tables mentioned above, either).

Of course the past is passed, and we can't expect to keep supporting old CiviCRM version. But, when we upgraded civicrm 4.2.17 to modern 5.x, the old data still has the old data structures: contributions recorded before that upgrade still have no entries in civicrm_line_item. Therefore, because it expects a line_item for every contribution, Summary Fields fails to count these contributions correctly, in various fields including but not limited to:

It seems there are two options:

  1. Modify Summary Fields to account for contributions without line_items (and potentially without other related table rows); OR
  2. Come up with a solid plan for upgrading this legacy data by creating the rows that modern CiviCRM would have created.

@jmcclelland or others: any thoughts on this?

jmcclelland commented 4 years ago

Hi @twomice - when we switched from tracking contributions via the contributions table to tracking it via line items, we left a backwards compatible option. Under field settings, you should see a checkbox called "Show simplified fields". If you check this option, then every contribution summary field as a version with "simplified" in parentheses. The simplified version should only consult the contribution table, not the line items table.

Does that work for you?

twomice commented 4 years ago

@jmcclelland That sounds like it would be the right thing, but the string "simpl" doesn't appear anywhere on the "Summary Fields Administration" page at /civicrm/admin/setting/sumfields I'm running Summary Fields version 4.0.2 under CiviCRM 5.24.3 / Drupal 8. Is that "simplified" option only available under master?

jmcclelland commented 4 years ago

Yes - try master if you don't mind. The last release broke a lot of things so I've been a bit shy. I really should do a new official release.

jmcclelland commented 3 years ago

The release is out.