components/financial_assistance/app/models/financial_assistance/application.rb
def compute_actual_days_worked(year, start_date, end_date)
      working_days_in_year = Float(52 * 5)

      start_date_to_consider = if Date.new(year, 1, 1) < start_date
                                 start_date
                               else
                                 Date.new(year, 1, 1)
                               end

      end_date_to_consider = if Date.new(year, 1, 1).end_of_year < end_date
                               Date.new(year, 1, 1).end_of_year
                             else
                               end_date
                             end

      # we have to add one to include last day of work. We multiply by working_days_in_year/365 to remove weekends.
      ((end_date_to_consider - start_date_to_consider + 1).to_i * (working_days_in_year / 365)).to_i #actual days worked in 'year'
    end
# Compute the actual days a applicant worked during one year
Compute the actual days a applicant worked during one year
Compute the actual days a applicant worked during one year
def compute_actual_days_worked(year, start_date, end_date)
      working_days_in_year = Float(52 * 5)
      start_date_to_consider = if Date.new(year, 1, 1) < start_date
                                 start_date
                               else
                                 Date.new(year, 1, 1)
                               end
      end_date_to_consider = if Date.new(year, 1, 1).end_of_year < end_date
                               Date.new(year, 1, 1).end_of_year
                             else
                               end_date
                             end
      ((end_date_to_consider - start_date_to_consider + 1).to_i * (working_days_in_year / 365)).to_i 
    end
def compute_actual_days_worked ( year , start_date , end_date ) working_days_in_year = Float ( 52 * 5 ) start_date_to_consider = if Date . new ( year , 1 , 1 ) < start_date start_date else Date . new ( year , 1 , 1 ) end end_date_to_consider = if Date . new ( year , 1 , 1 ) . end_of_year < end_date Date . new ( year , 1 , 1 ) . end_of_year else end_date end ( ( end_date_to_consider - start_date_to_consider + 1 ) . to_i * ( working_days_in_year / 365 ) ) . to_i end
Compute the actual days a applicant worked during one year
Compute the actual days a applicant worked during one year
# we have to add one to include last day of work. We multiply by working_days_in_year/365 to remove weekends. #actual days worked in 'year'
year
start_date
end_date