rate=HourlyRate.find(:first,:conditions=>["user_id = ? and project_id = ? and valid_from <= ?",id,project,date],:order=>"valid_from DESC")
# TODO: this is Redmine 0.8 specific. Sort by project.lft first if using redmine 0.9!
rate||=HourlyRate.find(:first,:conditions=>["user_id = ? and project_id in (?) and valid_from <= ?",id,project.ancestors,date],:order=>"valid_from DESC")