Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

refactor: merge contribution data into same table #428

Closed
wants to merge 9 commits into from

Conversation

wpf500
Copy link
Member

@wpf500 wpf500 commented May 15, 2024

This is a fairly major refactor (rewrite?) of the contribution code.

There are lots of problems with the contribution logic at the moment:

  • The data is split between the Contact model (contribution* fields) and ContactContribution. This indicates poor logical separation and means some contribution code ends up being in ContactsService when it shouldn't be.
  • Contact.contributionType and ContactContribution.method largely overlap (e.g. a Stripe payment method is always an automatic contribution, etc.)
  • Each Contact only has one ContactContribution, so changes are overwritten and there's no history of a contact's payment IDs. This is especially problematic for contributions that have pending changes (e.g. a non-prorated annual change), as we can loose the ID for a current subscription or mandate
    • ContactContribution.nextAmount attempts to solve this in a very ugly way
  • The various PaymentProvider implementations have to manage a lot of the logic of how things are stored in ContactContribution and there's a lot of duplication
  • Manual contributions are handled differently to Stripe or GoCardless ones, we currently have a very ugly ContactsService.forceUpdateContactContribution method to allow updating them

This PR introduces a many-to-one relationship between ContactContribution and Contact, and a ContactContribution.status field to differentiate between versions. The status can be pending, current or NULL, there can only ever be one current or pending ContactContribution.

@wpf500 wpf500 force-pushed the refactor/merge-contribution-data branch from 9d08ddd to 4f24a91 Compare May 16, 2024 13:23
Base automatically changed from chore/remove-old-app to master May 16, 2024 15:20
@wpf500 wpf500 force-pushed the refactor/merge-contribution-data branch from 4f24a91 to a1fd867 Compare May 16, 2024 16:22
@wpf500
Copy link
Member Author

wpf500 commented Aug 9, 2024

Closing as moved to beabee-communityrm/monorepo#42

@wpf500 wpf500 closed this Aug 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant