Created
June 18, 2013 10:28
-
-
Save valachi/5804277 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def forfeited_amount | |
sum = 0 | |
all_grants.each do |grant| | |
sum += grant.forfeitures.between(from_date, to_date).sum(:amount) | |
end | |
sum | |
end | |
def second_forfeited_amount | |
all_grants.joins(:forfeitures) | |
.where("option_grant_actions.created_at > ? AND option_grant_actions.created_at < ?", from_date.beginning_of_day, to_date.end_of_day) | |
.select("option_grants.*, option_grant_actions.created_at AS forfeiture_created_at,"\ | |
"option_grant_actions.amount AS forfeited_amount") | |
.map{ |it| it.forfeited_amount.to_i }.sum | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment