anteo / redmine_custom_workflows

Allows to create custom workflows for Redmine
http://www.redmine.org/plugins/custom-workflows
GNU General Public License v2.0
182 stars 72 forks source link

prevent changes to time entries in previous month #229

Closed znyak closed 3 years ago

znyak commented 3 years ago

I am trying to prevent changes to time entries, if the spent_on time is from previous months:

spent_on = read_attribute(:spent_on)
today = Date.today
if (spent_on.year <= today.year) && (spent_on.month < today.month) && (today.day > 5)
  errors.add '', 'You are not allowed to change time entries from the previous month.'
end

which always results in the error undefined method 'year' for nil:NilClass

znyak commented 3 years ago

answered: i was missing the null check on spent_on.