Skip to content

Instantly share code, notes, and snippets.

@felipecabargas
Created July 18, 2018 10:09
Show Gist options
  • Save felipecabargas/6d17b37f3ed591f505d3b6d437db3078 to your computer and use it in GitHub Desktop.
Save felipecabargas/6d17b37f3ed591f505d3b6d437db3078 to your computer and use it in GitHub Desktop.
Test
require 'date'
def compensation(salary, months)
#salary.class == Integer
#months.class == Integer
if months < 12
return 0
else
return salary*((months/12)+(((months%12 > 6) ? 1 : 0)))
end
end
def progressive_holidays(seniority, start_date, current_date)
# seniority.class == Integer
# start_date.class == Date
# current_date.class == Date
years = ((current_date-start_date).to_i/365)+(seniority)
years_at_current = (current_date-start_date).to_i/365
if years > 13
if years_at_current < 3
return 0
else
return (years - 10)/3
end
else
return 0
end
end
#Execution Examples
#puts compensation(300000, 31)
#puts progressive_holidays(10, Date.parse("1/1/2010"), Date.today)
#puts progressive_holidays(0, Date.parse("1/1/2000"), Date.today)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment