-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16649 from opf/implementation/57529-options-for-t…
…otal-calculation-sum-mode [#57529] Add options for sum totals calculation mode in hierarchies
- Loading branch information
Showing
19 changed files
with
1,351 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
app/models/journal/caused_by_total_percent_complete_mode_changed_to_simple_average.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#-- copyright | ||
# OpenProject is an open source project management software. | ||
# Copyright (C) the OpenProject GmbH | ||
# | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU General Public License version 3. | ||
# | ||
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: | ||
# Copyright (C) 2006-2013 Jean-Philippe Lang | ||
# Copyright (C) 2010-2013 the ChiliProject Team | ||
# | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU General Public License | ||
# as published by the Free Software Foundation; either version 2 | ||
# of the License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
# | ||
# See COPYRIGHT and LICENSE files for more details. | ||
#++ | ||
|
||
class Journal::CausedByTotalPercentCompleteModeChangedToSimpleAverage < CauseOfChange::Base | ||
def initialize | ||
super("total_percent_complete_mode_changed_to_simple_average") | ||
end | ||
end |
33 changes: 33 additions & 0 deletions
33
app/models/journal/caused_by_total_percent_complete_mode_changed_to_work_weighted_average.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#-- copyright | ||
# OpenProject is an open source project management software. | ||
# Copyright (C) the OpenProject GmbH | ||
# | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU General Public License version 3. | ||
# | ||
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: | ||
# Copyright (C) 2006-2013 Jean-Philippe Lang | ||
# Copyright (C) 2010-2013 the ChiliProject Team | ||
# | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU General Public License | ||
# as published by the Free Software Foundation; either version 2 | ||
# of the License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
# | ||
# See COPYRIGHT and LICENSE files for more details. | ||
#++ | ||
|
||
class Journal::CausedByTotalPercentCompleteModeChangedToWorkWeightedAverage < CauseOfChange::Base | ||
def initialize | ||
super("total_percent_complete_mode_changed_to_work_weighted_average") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
app/workers/work_packages/progress/apply_total_percent_complete_mode_change_job.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
#-- copyright | ||
# OpenProject is an open source project management software. | ||
# Copyright (C) the OpenProject GmbH | ||
# | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU General Public License version 3. | ||
# | ||
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: | ||
# Copyright (C) 2006-2013 Jean-Philippe Lang | ||
# Copyright (C) 2010-2013 the ChiliProject Team | ||
# | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU General Public License | ||
# as published by the Free Software Foundation; either version 2 | ||
# of the License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
# | ||
# See COPYRIGHT and LICENSE files for more details. | ||
#++ | ||
|
||
class WorkPackages::Progress::ApplyTotalPercentCompleteModeChangeJob < WorkPackages::Progress::Job | ||
VALID_CAUSE_TYPES = %w[ | ||
total_percent_complete_mode_changed_to_work_weighted_average | ||
total_percent_complete_mode_changed_to_simple_average | ||
].freeze | ||
|
||
attr_reader :cause_type, :mode | ||
|
||
# Updates the total % complete of all work packages after the total | ||
# percent complete mode has been changed. | ||
# | ||
# It creates a journal entry with the System user describing the changes. | ||
# | ||
# | ||
# Updates the total % complete of all work packages after the total | ||
# percent complete mode has been changed. | ||
# | ||
# It creates a journal entry with the System user describing the changes. | ||
# | ||
# @param [String] cause_type The cause type of the change | ||
# @param [String] mode The new total percent complete mode | ||
# @return [void] | ||
def perform(cause_type:, mode:) | ||
@cause_type = cause_type | ||
@mode = mode | ||
|
||
with_temporary_total_percent_complete_table do | ||
update_total_percent_complete | ||
copy_total_percent_complete_values_to_work_packages_and_update_journals(journal_cause) | ||
end | ||
end | ||
|
||
private | ||
|
||
def update_total_percent_complete | ||
case mode | ||
when "work_weighted_average" | ||
update_total_percent_complete_in_work_weighted_average_mode | ||
when "simple_average" | ||
update_total_percent_complete_in_simple_average_mode | ||
else | ||
raise ArgumentError, "Invalid total percent complete mode: #{mode}" | ||
end | ||
end | ||
|
||
def journal_cause | ||
assert_valid_cause_type! | ||
|
||
@journal_cause ||= | ||
case cause_type | ||
when "total_percent_complete_mode_changed_to_work_weighted_average" | ||
Journal::CausedByTotalPercentCompleteModeChangedToWorkWeightedAverage.new | ||
when "total_percent_complete_mode_changed_to_simple_average" | ||
Journal::CausedByTotalPercentCompleteModeChangedToSimpleAverage.new | ||
else | ||
raise "Unable to handle cause type #{cause_type.inspect}" | ||
end | ||
end | ||
|
||
def assert_valid_cause_type! | ||
unless VALID_CAUSE_TYPES.include?(cause_type) | ||
raise ArgumentError, "Invalid cause type #{cause_type.inspect}. " \ | ||
"Valid values are #{VALID_CAUSE_TYPES.inspect}" | ||
end | ||
end | ||
end |
Oops, something went wrong.