Repository navigation
feat: add Salesforce Nonprofit Cloud GiftTransaction ingest bridge - #315
Conversation
|
Thanks, this is careful work. Reading Blocking
Should fix
|
|
Thanks for the feedback. On 2, I agree after looking at it again that the exclusion set was wrong. |
|
Sounds good, an allowlist defaulting to
Thanks for turning this around quickly. |
b5e6d02 to
53c7245
Compare
- Add _nonprofit_cloud.py with header aliases and status allowlist, mirroring the NPSP and Raiser's Edge commitment versus payment guards - Export DEFAULT_INCLUDED_GIFT_TRANSACTION_STATUSES, nonprofit_cloud_gifts_to_features, and read_nonprofit_cloud_gifts - Add tests/test_nonprofit_cloud.py at the depth of test_npsp.py - Add tests to tests/test_read_gifts.py - Register the source in cli.py, read_gifts.py, docs/reference/index.md, and docs/index.md - Add CHANGELOG and CONTRIBUTORS entry
53c7245 to
3ecabd0
Compare
|
For the partial refunds, I checked the Gift Transactions Overview. The documented status values are For the blank status, I've implemented it as |
Closes #234
Summary
Adds a Salesforce Nonprofit Cloud
GiftTransactionexport reader alongside the existing CiviCRM, Raiser's Edge, and NPSP bridges, and wires it into the CLI asphilanthropy features --source nonprofit_cloud.philanthropy.ingest.read_nonprofit_cloud_gifts(path): reads a GiftTransaction export CSV (or a directory of them) and delegates it to the shared CiviCRM reader.philanthropy.ingest.nonprofit_cloud_gifts_to_features(gifts, *, reference_date=None, include_statuses=DEFAULT_INCLUDED_GIFT_TRANSACTION_STATUSES): rolls the export up into the donor-level feature table, keeping onlyPaidrows by default before handing the rest tocivicrm_contributions_to_features.philanthropy.ingest.DEFAULT_INCLUDED_GIFT_TRANSACTION_STATUSES = ("Paid",).Why the
Paidallowlist exists: NPC'sGiftCommitmentobject represents a pledge or recurring donation agreement and, on save, automatically and immediately generates theGiftTransactionrecords its schedule implies. Each carries aStatusfield that starts atUnpaidand only moves toPaidonce the money actually arrives. A $1,200 pledge paid monthly becomes twelveGiftTransactionrows the moment the commitment is saved. As a result, untilStatusis read, the two that have been received look identical to the ten that have not. The same overcount applies toFailed,Canceled,Pending,Fully Refunded, andWritten Offrows and to any custom status an org adds. An allowlist is a safer default: onlyPaidis counted, and an unrecognized status is dropped rather than summed. This mirrors the same commitment versus payment trap the NPSP bridge guards against by excludingPledgedOpportunity stages and the Raiser's Edge bridge guards against by excludingPledgegift types.Partial refunds: there is no
Partially Refundedstatus in the NPC status list. For a partial refund, the row remains at the state ofStatus = 'Paid'and reducesCurrentAmountto the net. TheIsPartiallyRefundedboolean is set independently. Since the allowlist keepsPaidrows, and the aggregation usesCurrentAmount(already net of the refund), a partially refunded gift contributes what was actually kept. Only a full refund moves the status toFully Refunded, which the default drops.Header aliases accept a Salesforce report export's column labels (
Donor ID,Transaction Date,Current Amount,Status), the rawGiftTransactionAPI field names (DonorId,TransactionDate,CurrentAmount,Status), andContact IDas a fallback donor key.DonorIdis preferred when both are present. It maps to theAccountDMO (the person, household, or organization account associated with the gift), whereasContactIdmaps to theIndividualDMO (the contact associated with the transaction). This mirrors the NPSP bridge's Account-over-Primary-Contact precedence.NPC vocabulary was verified against Salesforce's own public documentation instead of assumed:
Unpaid->Paid/Canceled/Failed/Fully Refunded/Written Off):https://help.salesforce.com/s/articleView?id=sfdo.fundraising_gift_transactions_overview.htm
https://trailhead.salesforce.com/content/learn/modules/nonprofit-cloud-fundraising-operations/track-gift-transactions
https://developer.salesforce.com/docs/atlas.en-us.nonprofit_cloud.meta/nonprofit_cloud/npc_fundraising_api_objects_gifttransaction.htm
https://developer.salesforce.com/docs/data/data-cloud-dmo-mapping/guide/c360dm-gifttransaction_dmo_mappings.html
ContactId->IndividualDMO,DonorId->AccountDMO):https://developer.salesforce.com/docs/data/data-cloud-dmo-mapping/guide/c360dm-si-gifttransactiondmo-dmo.html
https://help.salesforce.com/s/articleView?id=sfdo.fundraising_fundraising_performance_insights_dashboard.htm
https://developer.salesforce.com/docs/atlas.en-us.nonprofit_cloud.meta/nonprofit_cloud/connect_resources_gift_transaction_post.htm
I deliberately did not model the
GiftCommitmentobject. This bridge readsGiftTransactionexports, and I did not want to assert commitment field names I could not verify against a primary source. I also did not populatedistinct_financial_typesas NPC's designation data lives on the relatedGiftTransactionDesignationandGiftDesignationobjects (not as a direct field onGiftTransaction), and a simple CSV export does not carry those columns. Both are documented in the module docstring as out of scope.Files Changed
philanthropy/ingest/_nonprofit_cloud.py(new)philanthropy/ingest/__init__.py(export the three new names)--
philanthropy/ingest/_read_gifts.py(registernonprofit_cloud)philanthropy/cli.py(--source nonprofit_cloud)tests/test_nonprofit_cloud.py(new, same depth astests/test_npsp.py)tests/test_read_gifts.py(new case for the new source)docs/reference/index.md(Tier 2/Beta row),docs/index.mdCHANGELOG.mdCONTRIBUTORS.mdChecklist
make cipasses locally (lint → collection → tests → coverage ≥ 92%)__init__.pyCHANGELOG.mdupdated under[Unreleased]