I have this block of code here:
if contract.amendments.empty?
if Date.today - contract.due_date >= 30 || Date.today + contract.due_date <= 30
@start_date = contract.due_date + 1
@end_date = contract.due_date + 365
elsif Date.today - contract.due_date < 30
@start_date = Date.today
@end_date = contract.end_date
end
else
last_amendment = contract.amendments.last
if Date.today - last_amendment.due_date >= 30 || Date.today + last_amendment.due_date <= 30
@start_date = last_amendment.end_date + 1
@end_date = last_amendment.end_date + 365
elsif Date.today - last_amendment.end_date < 30
@start_date = Date.today
@end_date = last_amendment.end_date
end
end
And I'd like to leave you DRY, but I can not. I'm new to Ruby