Skip to content

Commit

Permalink
Add scope for projects and round financial calculations in Fund model
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew committed Mar 5, 2025
1 parent ac0df32 commit e4cc293
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/models/fund.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class Fund < ApplicationRecord

scope :project_legacy_id, ->(id) { where("opencollective_project->>'legacyId' = ?", id) }

scope :with_project, -> { where.not(opencollective_project_id: nil) }

scope :featured, -> { where(featured: true) }
scope :not_featured, -> { where(featured: false) }
scope :short_names, -> { where("LENGTH(name) < ?", 20) }
Expand Down Expand Up @@ -489,11 +491,11 @@ def total_donations
end

def total_expenses
transactions.expenses.sum(:net_amount)
transactions.expenses.sum(:net_amount).round(2)
end

def current_balance
transactions.sum(:net_amount)
transactions.sum(:net_amount).round(2)
end

def total_donors
Expand Down

0 comments on commit e4cc293

Please sign in to comment.