Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aggregate transactions per command line parameter #253

Merged
merged 17 commits into from
Nov 21, 2020

Conversation

ChrisRBe
Copy link
Owner

This PR should cover the idea proposed in #252 by adding a command line parameter that can be used to aggregate account statements by month.

@@ -51,6 +51,28 @@ def config_file(self, value):
"""config file property setter"""
self._config_file = value

def __format_statement(self, statement):
"""
Formats a given statement into a dictionary containing the relevant data for Portfolio Performance.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line too long (107 > 79 characters)

PP_FIELDNAMES[4]: sttmnt.get_note(),
}
self.output_list.append(formatted_account_entry)
formatted_account_entry = self.__format_statement(statement)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line too long (80 > 79 characters)

@codeclimate
Copy link

codeclimate bot commented Nov 20, 2020

Code Climate has analyzed commit 12b5172 and detected 2 issues on this pull request.

Here's the issue category breakdown:

Category Count
Duplication 2

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 98.8% (-0.7% change).

View more on Code Climate.

"""
with open(self.config_file, "r", encoding="utf-8") as ymlconfig:
yaml = YAML(typ="safe")
config = yaml.load(ymlconfig)
self.config = Config(config)

def parse_account_statement(self):
def parse_account_statement(self, aggregate="daily"):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cyclomatic complexity is too high in method parse_account_statement. (6)

"""
with open(self.config_file, "r", encoding="utf-8") as ymlconfig:
yaml = YAML(typ="safe")
config = yaml.load(ymlconfig)
self.config = Config(config)

def parse_account_statement(self):
def parse_account_statement(self, aggregate="daily"):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactor this function to reduce its Cognitive Complexity from 21 to the 15 allowed.

self.output_list.append(formatted_account_entry)
formatted_account_entry = self.__format_statement(statement)
if formatted_account_entry:
if aggregate == "daily":
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid deeply nested control flow statements.

PP_FIELDNAMES[1]
]
else:
self.aggregation_data[entry_date][entry_type] = {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Identical blocks of code found in 2 locations. Consider refactoring.

"""
with open(self.config_file, "r", encoding="utf-8") as ymlconfig:
yaml = YAML(typ="safe")
config = yaml.load(ymlconfig)
self.config = Config(config)

def parse_account_statement(self):
def parse_account_statement(self, aggregate="daily"):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cyclomatic complexity is too high in method parse_account_statement. (12)

if not category:
return

formatted_account_entry = {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Identical blocks of code found in 2 locations. Consider refactoring.

@@ -43,13 +51,15 @@ def platform_factory(operator_name="mintos"):
return None


def main(infile, p2p_operator_name="mintos"):
def main(infile, p2p_operator_name="mintos", aggregate="daily"):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function main has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.

self.config = Config(config)

def parse_account_statement(self):
def parse_account_statement(self, aggregate="daily"):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactor this function to reduce its Cognitive Complexity from 17 to the 15 allowed.

self.config = Config(config)

def parse_account_statement(self):
def parse_account_statement(self, aggregate="daily"):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cyclomatic complexity is too high in method parse_account_statement. (9)

@ChrisRBe ChrisRBe merged commit 08ab796 into master Nov 21, 2020
@ChrisRBe ChrisRBe deleted the feature/monthly-summary branch November 21, 2020 21:53
@ChrisRBe ChrisRBe linked an issue Nov 28, 2020 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Idea: Feature to aggregate transactions per month
2 participants