Open as1729 opened 3 months ago
@ClaireValdivia are you able to provide here what should go in each of the cells of this table when we identify a project that does not have a valid subrecipient? Since this is a cross-sheet validation I wasn't sure what row/col/sheet-name to use. If you're able to add-in the exact error verbiage then this ticket should be ready for work.
@as1729 just updated the definition of done section, lmk if you have any questions! referencing two columns is not our typical behavior but wondering if this feels feasible as I'm not sure of a better way to reference the error.
That looks good to me 👍 thank you!
Is there a difference between EIN and TIN? Is EIN just legacy (and if so, should we change it to TIN)?
@vshia EIN and TIN are referring to the same field, but unfortunately Treasury has named the field "EIN" in some places, so we need to be consistent with their naming conventions.
For context, we don't want to get out of sync with naming of fields that are provided by Treasury and are included in the report we send to Treasury. The reason we were able to change a field name recently (Project Use Code > EC Code in the input template Cover sheet) is because that is a field name in our input template only and not provided by Treasury.
@vshia seeing a couple issues here for this test upload. For this file, there are three project records
https://github.com/usdigitalresponse/cpf-reporter/pull/314 will address this
This is looking good to me in staging!
Current State
Users are able to submit workbooks with projects that do not map to a subrecipient.
Expected State
When user adds a project, there must always be a valid subrecipient that has the same UEI/TIN information. They must receive an error if no subrecipient is found with the UEI/TIN data found in the projects tab.
Definition of Done
If the subrecipient is entered in the project sheet, it must be entered in the subrecipient sheet (i.e. UEI & TIN on project record must be an exact match to UEI & TIN entered for a subrecipient record on the Subrecipient sheet)
Succesful validation:
Unsuccessful validation:
TEST FILES Pass & Fail test files can be found here CPF Input Template v20240524_UEITIN_PASS.xlsm has one project that has a matching UEI & TIN in the subrecipient tab CPF Input Template v20240524_UEITIN_FAIL.xlsm has three projects that fail for different reasons
Implementation Plan
projects
andsubrecipients
like so:This function now returns the "valid" subrecipients
def validate_subrecipient_sheet(subrecipient_sheet: Worksheet) -> Tuple(Errors, Subrecipients): errors = [] subrecipients = [] subrecipient_headers = get_headers(subrecipient_sheet, "C3:O3") current_row = INITIAL_STARTING_ROW for subrecipient_row in subrecipient_sheet.iter_rows( min_row=13, min_col=3, max_col=16, values_only=True ): current_row += 1 if is_empty_row(subrecipient_row): continue row_dict = map_values_to_headers(subrecipient_headers, subrecipient_row) try: subrecipients.append(SubrecipientRow(**row_dict)) except ValidationError as e: errors += get_workbook_errors_for_row( SubrecipientRow, e, current_row, SUBRECIPIENTS_SHEET ) return (errors, subrecipients)
Add a new function to validate projects and subrecipients together:
Use the returned information to do the additional validation here: https://github.com/usdigitalresponse/cpf-reporter/blob/main/python/src/lib/workbook_validator.py#L218: