update the "issue done_ratio" in time tracker plugin

Added by Hossein Ansari about 9 years ago

Hi,
I use Time Tracker Plugin (https://github.com/hicknhack-software/redmine_time_tracker).
I want to set the done_ratio of issue when i book a time.
How I can access to done_ratio of issue in a plugin?

TimeTrackerPlugin changes the timeEntry by this:

time_entry = TimeEntry.create({:project => args[:project], :issue => args[:issue], :hours => args[:hours], :comments => args[:comments], :spent_on => args[:started_on], :activity_id => args[:activity_id]})

self.time_entry.update_attributes!(:spent_on => start, :hours => self.hours_spent) #also update TimeEntry

thanks

Replies (1)

RE: update the "issue done_ratio" in time tracker plugin - Added by Razi Baluchi almost 9 years ago

if all you want to do is increment the done ratio by 10% to a specified limit - say 90% - then:


time_entry.issue.done_ratio = time_entry.issue.done_ratio + 10 if time_entry.issue.done_ratio < 90

If the issue has estimated hours - then you can calculate the done ratio before incrementing:

if !time_entry.issue.estimated_hours.blank?
    done_ratio = time_entry.hours/time_entry.issue.estimated_hours * 100
    time_entry.issue.done_ratio = time_entry.issue.done_ratio + done_ratio
else
    time_entry.issue.done_ratio = time_entry.issue.done_ratio + 10 if time_entry.issue.done_ratio < 90
end

(1-1/1)