-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2509 add a validation check for the sum calculations in federal award…
…s workbook (#2531) * #2509 Added logic to check cluster total * #2509 Added logic to check federal program total * #2509 Added logic to check total amount expended * #2509 Updated error messages and federal awards check queue * #2509 Updated federal awards checks * #2509 Bug fix * #2509 Regenerated output files * #2509 Updated test workbooks to include missing cfda_key. The key was absent because these workbooks were auto-generated, not manually created. --------- Co-authored-by: Dan Swick <[email protected]>
- Loading branch information
Showing
28 changed files
with
159 additions
and
2 deletions.
There are no files selected for viewing
Binary file added
BIN
+923 KB
backend/audit/fixtures/workbooks/should_fail/federal-awards/federal-awards-171944.xlsx
Binary file not shown.
Binary file added
BIN
+678 KB
backend/audit/fixtures/workbooks/should_fail/federal-awards/incorrect-cluster-total.xlsx
Binary file not shown.
Binary file added
BIN
+677 KB
.../audit/fixtures/workbooks/should_fail/federal-awards/incorrect-federal-program-total.xlsx
Binary file not shown.
Binary file added
BIN
+677 KB
.../audit/fixtures/workbooks/should_fail/federal-awards/incorrect-total-amount-expended.xlsx
Binary file not shown.
Binary file modified
BIN
+21.1 KB
(100%)
backend/audit/fixtures/workbooks/should_pass/100010-22/federal-awards-100010.xlsx
Binary file not shown.
Binary file modified
BIN
+21.7 KB
(100%)
backend/audit/fixtures/workbooks/should_pass/134732-21/federal-awards-134732.xlsx
Binary file not shown.
Binary file modified
BIN
+29.1 KB
(100%)
backend/audit/fixtures/workbooks/should_pass/147110-22/federal-awards-147110.xlsx
Binary file not shown.
Binary file removed
BIN
-921 KB
backend/audit/fixtures/workbooks/should_pass/171944-22/federal-awards-171944.xlsx
Binary file not shown.
Binary file modified
BIN
+23.7 KB
(100%)
backend/audit/fixtures/workbooks/should_pass/181744-22/federal-awards-181744.xlsx
Binary file not shown.
Binary file modified
BIN
+35.2 KB
(100%)
backend/audit/fixtures/workbooks/should_pass/182926-22/federal-awards-182926.xlsx
Binary file not shown.
Binary file modified
BIN
+23.4 KB
(100%)
backend/audit/fixtures/workbooks/should_pass/191734-21/federal-awards-191734.xlsx
Binary file not shown.
Binary file modified
BIN
+23.6 KB
(100%)
backend/audit/fixtures/workbooks/should_pass/191734-22/federal-awards-191734.xlsx
Binary file not shown.
Binary file modified
BIN
+24 KB
(100%)
backend/audit/fixtures/workbooks/should_pass/219107-21/federal-awards-219107.xlsx
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import logging | ||
from audit.intakelib.intermediate_representation import ( | ||
get_range_values_by_name, | ||
get_range_by_name, | ||
) | ||
from .util import get_message, build_cell_error_tuple | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
STATE_CLUSTER = "STATE CLUSTER" | ||
OTHER_CLUSTER = "OTHER CLUSTER NOT LISTED ABOVE" | ||
NOT_APPLICABLE = "N/A" | ||
|
||
|
||
# DESCRIPTION | ||
# The sum of the amount_expended for a given cluster should equal the corresponding cluster_total | ||
# K{0}=IF(G{0}="OTHER CLUSTER NOT LISTED ABOVE",SUMIFS(amount_expended,uniform_other_cluster_name,X{0}),IF(AND(OR(G{0}="N/A",G{0}=""),H{0}=""),0,IF(G{0}="STATE CLUSTER",SUMIFS(amount_expended,uniform_state_cluster_name,W{0}),SUMIFS(amount_expended,cluster_name,G{0})))) | ||
def cluster_total_is_correct(ir): | ||
uniform_other_cluster_name = get_range_values_by_name( | ||
ir, "uniform_other_cluster_name" | ||
) | ||
uniform_state_cluster_name = get_range_values_by_name( | ||
ir, "uniform_state_cluster_name" | ||
) | ||
state_cluster_name = get_range_values_by_name(ir, "state_cluster_name") | ||
cluster_name = get_range_values_by_name(ir, "cluster_name") | ||
cluster_total = get_range_values_by_name(ir, "cluster_total") | ||
amount_expended = get_range_values_by_name(ir, "amount_expended") | ||
|
||
errors = [] | ||
|
||
# Validating each cluster_total | ||
for idx, name in enumerate(cluster_name): | ||
# Based on the formula's conditions | ||
if name == OTHER_CLUSTER: | ||
expected_value = sum( | ||
[ | ||
amount | ||
for k, amount in zip(uniform_other_cluster_name, amount_expended) | ||
if k == uniform_other_cluster_name[idx] | ||
] | ||
) | ||
elif (name == NOT_APPLICABLE or not name) and not state_cluster_name[idx]: | ||
expected_value = 0 | ||
elif name == STATE_CLUSTER: | ||
expected_value = sum( | ||
[ | ||
amount | ||
for k, amount in zip(uniform_state_cluster_name, amount_expended) | ||
if k == uniform_state_cluster_name[idx] | ||
] | ||
) | ||
elif name: | ||
expected_value = sum( | ||
[ | ||
amount | ||
for k, amount in zip(cluster_name, amount_expended) | ||
if k == name | ||
] | ||
) | ||
|
||
# Check if the calculated value matches the provided one | ||
if expected_value != cluster_total[idx]: | ||
errors.append( | ||
build_cell_error_tuple( | ||
ir, | ||
get_range_by_name(ir, "cluster_total"), | ||
idx, | ||
get_message("check_cluster_total").format( | ||
cluster_total[idx], expected_value | ||
), | ||
) | ||
) | ||
|
||
return errors |
39 changes: 39 additions & 0 deletions
39
backend/audit/intakelib/checks/check_federal_program_total.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import logging | ||
from audit.intakelib.intermediate_representation import ( | ||
get_range_values_by_name, | ||
get_range_by_name, | ||
) | ||
from .util import get_message, build_cell_error_tuple | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
# DESCRIPTION | ||
# The sum of the amount_expended for a given cfda_key should equal the corresponding federal_program_total | ||
# J{0}=SUMIFS(amount_expended,cfda_key,V{0})) | ||
def federal_program_total_is_correct(ir): | ||
federal_program_total = get_range_values_by_name(ir, "federal_program_total") | ||
cfda_key = get_range_values_by_name(ir, "cfda_key") | ||
amount_expended = get_range_values_by_name(ir, "amount_expended") | ||
|
||
errors = [] | ||
|
||
# Validating each federal_program_total | ||
for idx, key in enumerate(cfda_key): | ||
# Compute the sum for current cfda_key | ||
computed_sum = sum( | ||
[amount for k, amount in zip(cfda_key, amount_expended) if k == key] | ||
) | ||
if computed_sum != federal_program_total[idx]: | ||
errors.append( | ||
build_cell_error_tuple( | ||
ir, | ||
get_range_by_name(ir, "federal_program_total"), | ||
idx, | ||
get_message("check_federal_program_total").format( | ||
federal_program_total[idx], computed_sum | ||
), | ||
) | ||
) | ||
|
||
return errors |
34 changes: 34 additions & 0 deletions
34
backend/audit/intakelib/checks/check_total_amount_expended.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import logging | ||
from audit.intakelib.intermediate_representation import ( | ||
get_range_values_by_name, | ||
get_range_by_name, | ||
) | ||
from .util import get_message, build_cell_error_tuple | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
# DESCRIPTION | ||
# The sum of the amount_expended should equal the total_amount_expended | ||
# B5=SUM(Form!F$2:F$5000) | ||
def total_amount_expended_is_correct(ir): | ||
total_amount_expended_value = get_range_values_by_name(ir, "total_amount_expended") | ||
amount_expended_values = get_range_values_by_name(ir, "amount_expended") | ||
|
||
errors = [] | ||
|
||
# Validating total_amount_expended | ||
computed_sum = sum(amount_expended_values) | ||
if computed_sum != total_amount_expended_value[0]: | ||
errors.append( | ||
build_cell_error_tuple( | ||
ir, | ||
get_range_by_name(ir, "total_amount_expended"), | ||
0, | ||
get_message("check_total_amount_expended").format( | ||
total_amount_expended_value[0], computed_sum | ||
), | ||
) | ||
) | ||
|
||
return errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+2 Bytes
(100%)
backend/schemas/output/excel/xlsx/additional-eins-workbook.xlsx
Binary file not shown.
Binary file modified
BIN
-2 Bytes
(100%)
backend/schemas/output/excel/xlsx/additional-ueis-workbook.xlsx
Binary file not shown.
Binary file modified
BIN
+1 Byte
(100%)
backend/schemas/output/excel/xlsx/audit-findings-text-workbook.xlsx
Binary file not shown.
Binary file modified
BIN
+9 Bytes
(100%)
backend/schemas/output/excel/xlsx/corrective-action-plan-workbook.xlsx
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
backend/schemas/output/excel/xlsx/federal-awards-audit-findings-workbook.xlsx
Binary file not shown.
Binary file modified
BIN
-3.17 KB
(100%)
backend/schemas/output/excel/xlsx/federal-awards-workbook.xlsx
Binary file not shown.
Binary file modified
BIN
+5 Bytes
(100%)
backend/schemas/output/excel/xlsx/notes-to-sefa-workbook.xlsx
Binary file not shown.
Binary file modified
BIN
+2 Bytes
(100%)
backend/schemas/output/excel/xlsx/secondary-auditors-workbook.xlsx
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters