Skip to content

Commit

Permalink
Add method to generate report that contains projects that are not being
Browse files Browse the repository at this point in the history
billed for.
  • Loading branch information
naved001 committed Nov 1, 2023
1 parent deb0d45 commit b984134
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
10 changes: 10 additions & 0 deletions process_report/process_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def main():
projects = list(set(projects + timed_projects_list))

remove_non_billables(merged_dataframe, pi, projects, args.output_file)
remove_billables(merged_dataframe, pi, projects, "non_billable.csv")


def merge_csv(files):
Expand Down Expand Up @@ -96,5 +97,14 @@ def remove_non_billables(dataframe, pi, projects, output_file):
filtered_dataframe = dataframe[~dataframe['Manager (PI)'].isin(pi) & ~dataframe['Project - Allocation'].isin(projects)]
filtered_dataframe.to_csv(output_file, index=False)


def remove_billables(dataframe, pi, projects, output_file):
"""Removes projects and PIs that should be billed from the dataframe
So this *keeps* the projects/pis that should not be billed.
"""
filtered_dataframe = dataframe[dataframe['Manager (PI)'].isin(pi) | dataframe['Project - Allocation'].isin(projects)]
filtered_dataframe.to_csv(output_file, index=False)

if __name__ == "__main__":
main()
17 changes: 17 additions & 0 deletions process_report/tests/unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ def setUp(self):
self.projects_to_exclude = ['ProjectB', 'ProjectC']

self.output_file = tempfile.NamedTemporaryFile(delete=False)
self.output_file2 = tempfile.NamedTemporaryFile(delete=False)

def tearDown(self):
os.remove(self.output_file.name)
os.remove(self.output_file2.name)

def test_remove_non_billables(self):
process_report.remove_non_billables(self.dataframe, self.pi_to_exclude, self.projects_to_exclude, self.output_file.name)
Expand All @@ -77,6 +79,21 @@ def test_remove_non_billables(self):
self.assertNotIn('ProjectB', result_df['Project - Allocation'].tolist())
self.assertNotIn('ProjectC', result_df['Project - Allocation'].tolist())

def test_remove_billables(self):
process_report.remove_billables(self.dataframe, self.pi_to_exclude, self.projects_to_exclude, self.output_file2.name)

result_df = pandas.read_csv(self.output_file2.name)

self.assertIn('PI2', result_df['Manager (PI)'].tolist())
self.assertIn('PI3', result_df['Manager (PI)'].tolist())
self.assertIn('ProjectB', result_df['Project - Allocation'].tolist())
self.assertIn('ProjectC', result_df['Project - Allocation'].tolist())

self.assertNotIn('PI1', result_df['Manager (PI)'].tolist())
self.assertNotIn('PI4', result_df['Manager (PI)'].tolist())
self.assertNotIn('ProjectA', result_df['Project - Allocation'].tolist())
self.assertNotIn('ProjectD', result_df['Project - Allocation'].tolist())


class TestMergeCSV(TestCase):
def setUp(self):
Expand Down

0 comments on commit b984134

Please sign in to comment.