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

% Done is not included in the list #283

Closed ashrafalzyoud closed 2 years ago

ashrafalzyoud commented 2 years ago

in my case i have Four level sub task Tracker(1) --> tracker(2)-->Tracker(3)-->Tracker(4) subtasks im config setting

**Calculate the issue done ratio with : issue filed
% Done : calculated from subtask**

im do this configuration

if tracker_id == 4     
@updated_done_ratio = Issue.where(:id => self.id).pluck(:done_ratio).first
@issue.update_columns(done_ratio: custom_field_value(1).to_f.round ) unless new_record?
elsif tracker_id == 3
@updated_done_ratio = Issue.where(:id => self.id).pluck(:done_ratio).first
@issue.update_columns(done_ratio: @updated_done_ratio * (0.5)) unless new_record?
elsif tracker_id == 2
@updated_done_ratio = Issue.where(:id => self.id).pluck(:done_ratio).first
@issue.update_columns(done_ratio: @updated_done_ratio * (0.3)) unless new_record?
else tracker_id == 1
@updated_done_ratio = Issue.where(:id => self.id).pluck(:done_ratio).first
@issue.update_columns(done_ratio: @updated_done_ratio * (0.1)) unless new_record?
end

the msg error give to me % Done is not included in the list i need in tracker (2 +3+4) after system calauted the DONE * (i)

picman commented 2 years ago

I'd suspect this line. Very probably custom_field_value(1).to_f.round is not a number 1..100. There is a validation that % Done must be in range 1..100. Your code must respect it.

@issue.update_columns(done_ratio: custom_field_value(1).to_f.round ) unless new_record?
picman commented 2 years ago

maybe, you can stash them in _beforedestroy for a later usage in _afterdestroy.