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

Link to this function create(attributes) View Source
create(map()) :: tuple()

Creates the CodeCorps.DonationGoal by wrapping the following in a transaction:

Link to this function update(donation_goal, attributes) View Source

Updates the CodeCorps.DonationGoal by wrapping the following in a transaction:

Link to this function update_project_goals(project) View Source

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 current for each of its siblings to false
  • setting current for the current goal to true