Skip to content

Commit

Permalink
Allowed filtering for non-billable projects to be case-insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
QuanMPhm committed Jan 17, 2025
1 parent e0d3bf7 commit 4b6c425
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 7 additions & 1 deletion process_report/processors/validate_billable_pi_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,15 @@ def _get_billables(
nonbillable_pis: list[str],
nonbillable_projects: list[str],
):
def _str_to_lowercase(data):
return data.lower()

nonbillable_projects_lowercase = [
project.lower() for project in nonbillable_projects
]
return ~data[invoice.PI_FIELD].isin(nonbillable_pis) & ~data[
invoice.PROJECT_FIELD
].isin(nonbillable_projects)
].apply(_str_to_lowercase).isin(nonbillable_projects_lowercase)

def _process(self):
self.data[invoice.IS_BILLABLE_FIELD] = self._get_billables(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ def test_remove_nonbillables(self):
pis = [uuid.uuid4().hex for x in range(10)]
projects = [uuid.uuid4().hex for x in range(10)]
nonbillable_pis = pis[:3]
nonbillable_projects = projects[7:]
nonbillable_projects = [
project.upper() for project in projects[7:]
] # Test for case-insentivity
billable_pis = pis[3:7]
data = pandas.DataFrame({"Manager (PI)": pis, "Project - Allocation": projects})

Expand Down

0 comments on commit 4b6c425

Please sign in to comment.