Skip to content

Commit

Permalink
replaced logic for determining internal vs sponsored by checking the …
Browse files Browse the repository at this point in the history
…Project Type column instead of looking for "PPM Only" in the project name
  • Loading branch information
dave-doty committed Aug 23, 2024
1 parent 4e12cda commit c1ade47
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions aggie_unterprise/aggie_unterprise.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ def from_file(
balance_header = 'Budget Balance (Budget – (Comm & Exp))'
col_names = [project_name_header, budget_header, expenses_header, balance_header]

project_type_header = 'Project Type'

# used to distinguish CS-specific accounts that all have the same project name of
# "David Doty ENGR COMPUTER SCIENCE PPM Only"
# In these cases we grab the Task name and used that as the project name instead
Expand All @@ -177,7 +179,7 @@ def from_file(
summary_col_idxs = {}
for i, cell in enumerate(header_row):
header = cell.value
if header in col_names + [task_header]:
if header in col_names + [task_header] + [project_type_header]:
summary_col_idxs[header] = i

project_names = []
Expand Down Expand Up @@ -209,21 +211,31 @@ def from_file(
)
find_expenses_by_category(summary, ws_detail, project_name_header, project_name)

clean_project_name = project_name
# TODO: replace this with a check for Project Type = Internal (vs. Sponsored)
if 'PPM Only' in project_name:
if project_name in project_names:
raise ValueError(f'There are duplicates in the project names: "{project_name}" appears in two '
f'different rows of the Summary worksheet of the Excel file "{fn}". '
f'I do not know how to process such a file.')


# Internal project names are typically of the form "David Doty ENGR COMPUTER SCIENCE PPM Only"
# so we replace those with the more specific task name such as
# "CS INDIRECT COST RETURN DOTY DEFAULT PROJECT 13U00" or
# "CS DISCRETIONARY FUNDS DOTY DEFAULT PROJECT 13U00"
project_type = row[summary_col_idxs[project_type_header]].value
assert project_type in ['Internal', 'Sponsored']
internal = project_type == 'Internal'
if internal:
if 'PPM Only' not in project_name:
print("WARNING: Internal project name typically contain the phrase 'PPM Only'; "
f'double-check that project "{project_name}" is internal and is the correct project name.')
# replace with more specific task name
clean_project_name = row[summary_col_idxs[task_header]].value
project_name = row[summary_col_idxs[task_header]].value

clean_project_name = project_name
clean_project_name = remove_suffix_starting_with(clean_project_name, suffixes_to_clean)
clean_project_name = remove_substrings(clean_project_name, substrings_to_clean)
clean_project_name = clean_whitespace(clean_project_name)

if project_name in project_names:
raise ValueError(f'There are duplicates in the project names: "{project_name}" appears in two '
f'different rows of the Summary worksheet of the Excel file "{fn}". '
f'I do not know how to process such a file.')

if clean_project_name in clean_name_to_orig.keys():
# check if iterable suffixes_to_clean is empty
first_orig_project_name = clean_name_to_orig[clean_project_name]
Expand Down

0 comments on commit c1ade47

Please sign in to comment.