-
Notifications
You must be signed in to change notification settings - Fork 22
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 #222 from momibun926/redmine5.0
Redmine5.0
- Loading branch information
Showing
17 changed files
with
399 additions
and
409 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
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,54 @@ | ||
# Calculation EVM base class. | ||
# This class is base class of calculate AC, EV, PV(issues, baseline) | ||
# | ||
class BaseCalculateEvm | ||
# Basis date | ||
attr_reader :basis_date | ||
# daily element | ||
attr_reader :daily | ||
# cumulative by date | ||
attr_reader :cumulative | ||
|
||
# Constractor | ||
# | ||
# @param [Date] basis_date basis date. | ||
def initialize(basis_date) | ||
# basis date | ||
@basis_date = basis_date | ||
end | ||
|
||
# Cumulative ac at target date | ||
# | ||
# @param [Date] target_date pv at target date | ||
# @return [Hash] cumulative at ac target date | ||
def cumulative_at(target_date) | ||
@cumulative.select { |k, _v| k <= target_date } | ||
end | ||
|
||
private | ||
|
||
# Sort evm hash, Assending date. | ||
# | ||
# @param [Hash] evm_hash target issues of EVM | ||
# @return [Hash] Sorted EVM hash. Key:date, Value:EVM value | ||
def create_cumulative_evm(evm_hash) | ||
temp_hash = {} | ||
sum_value = 0.0 | ||
evm_hash.sort_by { |key, _val| key }.each do |date, value| | ||
sum_value += value | ||
temp_hash[date] = sum_value | ||
end | ||
temp_hash | ||
end | ||
|
||
# Add daily EVM value | ||
# | ||
# @param [Numeric] evm_value EVM value | ||
# @param [Numeric] value EVM value | ||
# @param [Numeric] done_ratio done ratio | ||
# @return [Numeric] after add value | ||
def add_daily_evm_value(evm_value, value, done_ratio = 100) | ||
add_value = value.to_f * done_ratio.fdiv(100) | ||
evm_value.nil? ? add_value : evm_value.to_f + add_value | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,37 @@ | ||
require "base_calculate" | ||
# Calculation AC class. | ||
# AC calculate Spent time of pv issues. | ||
# | ||
class CalculateAc < BaseCalculateEvm | ||
# min date of spent time (exclude basis date) | ||
attr_reader :min_date | ||
# max date of spent time (exclude basis date) | ||
attr_reader :max_date | ||
|
||
# Calculation EVM module | ||
module CalculateEvmLogic | ||
# Calculation AC class. | ||
# AC calculate Spent time of pv issues. | ||
# Constractor | ||
# | ||
class CalculateAc < BaseCalculateEvm | ||
# min date of spent time (exclude basis date) | ||
attr_reader :min_date | ||
# max date of spent time (exclude basis date) | ||
attr_reader :max_date | ||
|
||
# Constractor | ||
# | ||
# @param [Date] basis_date basis date. | ||
# @param [costs] costs culculation of AC. | ||
def initialize(basis_date, costs) | ||
super(basis_date) | ||
# daily AC | ||
@daily = costs.to_h | ||
# minimum first date | ||
# if no data, set basis date | ||
@min_date = @daily.keys.min || @basis_date | ||
# maximum last date | ||
# if no data, set basis date | ||
@max_date = @daily.keys.max || @basis_date | ||
# basis date | ||
@daily[@basis_date] ||= 0.0 | ||
# cumulative AC | ||
@cumulative = create_cumulative_evm(@daily) | ||
@cumulative.reject! { |k, _v| @basis_date < k } | ||
end | ||
# @param [Date] basis_date basis date. | ||
# @param [costs] costs culculation of AC. | ||
def initialize(basis_date, costs) | ||
super(basis_date) | ||
# daily AC | ||
@daily = costs.to_h | ||
# minimum first date | ||
# if no data, set basis date | ||
@min_date = @daily.keys.min || @basis_date | ||
# maximum last date | ||
# if no data, set basis date | ||
@max_date = @daily.keys.max || @basis_date | ||
# basis date | ||
@daily[@basis_date] ||= 0.0 | ||
# cumulative AC | ||
@cumulative = create_cumulative_evm(@daily) | ||
@cumulative.reject! { |k, _v| @basis_date < k } | ||
end | ||
|
||
# Today's Actual cost | ||
# | ||
# @return [Numeric] AC on basis date | ||
def today_value | ||
@cumulative[@basis_date] | ||
end | ||
# Today's Actual cost | ||
# | ||
# @return [Numeric] AC on basis date | ||
def today_value | ||
@cumulative[@basis_date] | ||
end | ||
end |
Oops, something went wrong.