Skip to content

fix(cli): drop non-gift rows from the raw gift log used by check and leadership - #353

Merged
shivamlalakiya merged 1 commit into
mainfrom
fix/cli-raw-gift-filters
Nov 3, 2026
Merged

shivamlalakiya merged 1 commit into
mainfrom
fix/cli-raw-gift-filters

Conversation

@shivamlalakiya

Copy link
Copy Markdown
Contributor

What & why

philanthropy check and philanthropy train --task leadership built their gift log with _read_raw_gifts, which only renamed headers. None of the row filters the ingest bridges apply ran on that path, so a Raiser's Edge pledge was summed next to its payment, and cancelled or test-mode CiviCRM contributions, NPSP open stages and unpaid Nonprofit Cloud schedules all counted as gifts. philanthropy features on the same file dropped them.

On main:

raisers_edge  raw gift log 2000.0   read_gifts 1000.0
civicrm       raw gift log 9500.0   read_gifts  500.0

On this branch both read 1000.0 and 500.0.

How

  • Each bridge's normalise + required-column check + row filter moves into a private helper (_raisers_edge_received_rows, _npsp_received_rows, _nonprofit_cloud_received_rows). The public *_to_features functions call it and behave exactly as before.
  • The CiviCRM id dedup, test-mode drop and status filter move into _civicrm_received_rows, which the aggregator calls.
  • _read_raw_gifts calls the same helpers, so there is one definition of "a received gift" per CRM instead of two. It also turns a bridge's missing-field KeyError into the SystemExit message features already prints.
  • Side effect, intended: an NPSP export carrying both Account ID and Primary Contact is now keyed by Account on this path too, matching features.
  • The filter warnings use stacklevel=3 so they still point at the caller after moving one frame deeper.

Closes #337

Testing

  • New test_raw_gift_log_drops_the_rows_features_drops, parametrised over the four CLI sources: one counted row and one excluded row each, compared against read_gifts.
  • New test that a missing field exits with the bridge's message instead of a traceback.
  • The existing check and train --task leadership fixtures now carry a Gift Type column, since the CLI now (correctly) warns when it is missing.
  • make ci: 2958 passed, coverage 98.64%. make riskcov: passed. flake8 clean.

Follow-up: #341 extends the same treatment to the Bloomerang, DonorPerfect and Blackbaud CRM sources.

Checklist

  • make ci passes locally
  • Tests added
  • CHANGELOG.md updated under [Unreleased]

…leadership

`philanthropy check` and `philanthropy train --task leadership` read the
export through `_read_raw_gifts`, which only renamed headers. Raiser's Edge
pledges were summed next to the payments against them, and cancelled,
pending or test-mode CiviCRM contributions, NPSP open stages and unpaid
Nonprofit Cloud schedules all counted as gifts, while `features` on the same
file dropped them.

Each bridge's row filter now lives in a private `_<crm>_received_rows`
helper that both its `*_to_features` aggregator and the CLI call, and the
CiviCRM id dedup, test-mode and status filter moved into
`_civicrm_received_rows` the same way. The CLI turns a bridge's missing-field
KeyError into a SystemExit message, as `features` already did.

Closes #337
@shivamlalakiya
shivamlalakiya enabled auto-merge (squash) November 3, 2026 16:33
@shivamlalakiya
shivamlalakiya merged commit 03c3c43 into main Nov 3, 2026
14 checks passed
@shivamlalakiya
shivamlalakiya deleted the fix/cli-raw-gift-filters branch November 6, 2026 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: philanthropy check and train --task leadership count pledges and cancelled gifts that features drops

1 participant