code_corps v0.0.1 CodeCorps.Services.DonationGoalsService View Source
Handles CRUD operations for donation goals.
When operations happen on CodeCorps.DonationGoal, we need to set
the current donation goal on CodeCorps.Project.
The current donation goal should be the smallest value that is greater than the project’s current total donations, or falls back to the largest donation goal.
Link to this section Summary
Functions
Creates the CodeCorps.DonationGoal by wrapping the following in a
transaction
Updates the CodeCorps.DonationGoal by wrapping the following in a
transaction
Updates all CodeCorpes.DonationGoal records for a project
Updates sibling goals for a CodeCorps.DonationGoal by
Link to this section Functions
Creates the CodeCorps.DonationGoal by wrapping the following in a
transaction:
- Inserting the donation goal
- Updating the sibling goals with
update_related_goals/1
Updates the CodeCorps.DonationGoal by wrapping the following in a
transaction:
- Updating the donation goal
- Updating the sibling goals with
update_related_goals/1
Updates all CodeCorpes.DonationGoal records for a project.
To be used when something related to the project’s donation goals changes, but not any of the donation goals directly.
For example, a customer could update their subscription, which would change the total amount in monthly donations to a project, so the current goal might need updating.
It updates all goals for a project by
- finding the current goal for a project
- setting
currentfor each of its siblings to false - setting
currentfor the current goal to true