-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
570c9a8
commit a7a6308
Showing
14 changed files
with
272 additions
and
250 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,17 @@ | ||
# This configuration was generated by | ||
# `rubocop --auto-gen-config` | ||
# on 2023-11-21 13:11:04 UTC using RuboCop version 1.56.2. | ||
# on 2023-12-12 20:30:29 UTC using RuboCop version 1.56.2. | ||
# The point is for the user to remove these configuration records | ||
# one by one as the offenses are removed from the code base. | ||
# Note that changes in the inspected code, or installation of new | ||
# versions of RuboCop, may require this file to be generated again. | ||
|
||
# Offense count: 6 | ||
# Offense count: 4 | ||
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. | ||
Metrics/AbcSize: | ||
Max: 37 | ||
Max: 22 | ||
|
||
# Offense count: 12 | ||
# Offense count: 3 | ||
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. | ||
Metrics/MethodLength: | ||
Max: 32 | ||
|
||
# Offense count: 6 | ||
# Configuration parameters: EnforcedStyle, AllowedIdentifiers, AllowedPatterns. | ||
# SupportedStyles: snake_case, camelCase | ||
Naming/VariableName: | ||
Exclude: | ||
- 'app/utils/analytics/finances/project_calculator.rb' | ||
Max: 16 |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# frozen_string_literal: true | ||
|
||
module Analytics | ||
module Finances | ||
module Models | ||
class FinancialItem | ||
attr_accessor :name, | ||
:slug, | ||
:expected_hours, | ||
:executed_hours, | ||
:expected_income, | ||
:executed_income, | ||
:paid_time_off_hours, | ||
:executed_cost, | ||
:expected_cost | ||
|
||
def initialize(name, slug) | ||
@name = name | ||
@slug = slug | ||
@expected_hours = 0 | ||
@executed_hours = 0 | ||
@expected_income = 0 | ||
@executed_income = 0 | ||
@paid_time_off_hours = 0 | ||
@executed_cost = 0 | ||
@expected_cost = 0 | ||
end | ||
|
||
def add_executed_income(amount) | ||
@executed_income += amount | ||
end | ||
|
||
def add_expected_income(amount) | ||
@expected_income += amount | ||
end | ||
|
||
def add_executed_cost(amount) | ||
@executed_cost += amount | ||
end | ||
|
||
def add_expected_cost(amount) | ||
@expected_cost += amount | ||
end | ||
|
||
def add_executed_hours(amount) | ||
@executed_hours += amount | ||
end | ||
|
||
def add_expected_hours(amount) | ||
@expected_hours += amount | ||
end | ||
|
||
def add_paid_time_off_hours(amount) | ||
@paid_time_off_hours += amount | ||
end | ||
|
||
def merge(financial_item) | ||
add_executed_income(financial_item.executed_income) | ||
add_expected_income(financial_item.expected_income) | ||
add_executed_cost(financial_item.executed_cost) | ||
add_expected_cost(financial_item.expected_cost) | ||
add_executed_hours(financial_item.executed_hours) | ||
add_expected_hours(financial_item.expected_hours) | ||
add_paid_time_off_hours(financial_item.paid_time_off_hours) | ||
end | ||
end | ||
end | ||
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# frozen_string_literal: true | ||
|
||
module Analytics | ||
module Finances | ||
module Models | ||
class FinancialProjects < FinancialReport | ||
def calculate! | ||
projects.each do |project| | ||
finances = Analytics::Finances::Models::FinancialStatementsOfWork.new(project, @start_date, @end_date) | ||
add_executed_income(finances.total_executed_income) | ||
add_expected_income(finances.total_expected_income) | ||
add_executed_cost(finances.total_executed_cost) | ||
add_expected_cost(finances.total_expected_cost) | ||
|
||
finances.financial_items.each do |financial_item| | ||
existing_item = financial_item_by_name(project.name, project.slug) | ||
existing_item.merge(financial_item) | ||
end | ||
end | ||
end | ||
|
||
private | ||
|
||
def projects | ||
Project.active_in_period(@start_date, @end_date) | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.