Skip to content

Commit

Permalink
changed syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
rnickles committed Apr 29, 2024
1 parent 4a7d67b commit baa275d
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions app/models/items/recurring_donation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,24 @@ class RecurringDonation < Item

def one_line_description ; end
def description_for_audit_txn ; end
def first_donation
# Retrieves the earliest donation based on sold_on
Donation.where(recurring_donation_id: id).order(sold_on: :asc).first
end
def monthly_amount
# Finds the first donation with the recurring_donation_id matching this instance's id
donation = Donation.find_by(recurring_donation_id: id)
donation = first_donation
donation ? donation.amount : nil # Returns the donation amount if found, otherwise returns nil
end
def total_to_date
RecurringDonation.find(id).donations.sum(:amount)
end
def item_description
# Finds the first donation with the recurring_donation_id matching this instance's id
donation = Donation.find_by(recurring_donation_id: id)
donation = first_donation
donation ? donation.item_description : nil # Returns the donation item description if found, otherwise returns nil
end
def first_donation
# Retrieves the earliest donation based on the created_at timestamp
Donation.where(recurring_donation_id: id).order(sold_on: :asc).first
def total_to_date
# Calculate the sum of all donations belonging to this recurring donation
Donation.where(recurring_donation_id: id).sum(:amount)

end
def start_date
first_donation.sold_on
Expand Down

0 comments on commit baa275d

Please sign in to comment.