Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve total_fed_expenditures, type_report_major_program, type_requirement #1786

Merged
merged 4 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions backend/audit/etl.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,19 @@ def load_findings(self):

def load_federal_award(self):
federal_awards = self.single_audit_checklist.federal_awards
report_id = self.single_audit_checklist.report_id
try:
general = General.objects.get(report_id=report_id)
except General.DoesNotExist:
logger.error(
f"General must be loaded before FederalAward. report_id = {report_id}"
)
return
general.total_amount_expended = federal_awards["FederalAwards"].get(
"total_amount_expended"
)
general.save()

for entry in federal_awards["FederalAwards"]["federal_awards"]:
program = entry["program"]
loan = entry["loan_or_loan_guarantee"]
Expand Down Expand Up @@ -113,12 +126,10 @@ def load_federal_award(self):
is_loan=loan["is_guaranteed"] == "Y",
loan_balance=loan["loan_balance_at_audit_period_end"],
is_direct=is_direct,
is_major=program["is_major"] == "Y",
mp_audit_report_type=program["audit_report_type"],
findings_count=program["number_of_audit_findings"],
is_passthrough_award=is_passthrough,
passthrough_amount=subrecipient_amount,
type_requirement=None, # TODO: What is this?
)
federal_award.save()

Expand Down Expand Up @@ -274,9 +285,7 @@ def load_general(self):
entity_type=general_information["user_provided_organization_type"],
number_months=general_information["audit_period_other_months"],
audit_period_covered=general_information["audit_period_covered"],
is_report_required=None, # TODO: Notes say this hasn't been used since 2008.
total_fed_expenditures=None, # TODO: Where does this come from?
type_report_major_program=None, # TODO: Where does this come from?
total_amount_expended=None, # loaded from FederalAward
type_audit_code="UG",
is_public=self.single_audit_checklist.is_public,
data_source="G-FAC",
Expand Down
12 changes: 11 additions & 1 deletion backend/audit/test_etl.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ def _fake_federal_awards():
"award_reference": "ABC123",
"cluster": {"cluster_name": "N/A", "cluster_total": 0},
"program": {
"is_major": "Y",
"program_name": "RETIRED AND SENIOR VOLUNTEER PROGRAM",
"amount_expended": 9000,
"audit_report_type": "U",
Expand Down Expand Up @@ -271,12 +270,23 @@ def test_load_general(self):
general = generals.first()
self.assertEqual(self.report_id, general.report_id)

def test_load_award_before_general_should_fail(self):
self.etl.load_federal_award()
federal_awards = FederalAward.objects.all()
self.assertEqual(len(federal_awards), 0)

def test_load_federal_award(self):
self.etl.load_general()
self.etl.load_federal_award()
federal_awards = FederalAward.objects.all()
self.assertEqual(len(federal_awards), 1)
federal_award = federal_awards.first()
self.assertEqual(self.report_id, federal_award.report_id)
general = General.objects.first()
self.assertEqual(
general.total_amount_expended,
self.sac.federal_awards["FederalAwards"].get("total_amount_expended"),
)

def test_load_findings(self):
self.etl.load_findings()
Expand Down
3 changes: 3 additions & 0 deletions backend/audit/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
from audit.validators import validate_audit_information_json
from audit.utils import ExcelExtractionError

logging.basicConfig(
format="%(asctime)s %(levelname)-8s %(module)s:%(lineno)d %(message)s"
)
logger = logging.getLogger(__name__)


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated by Django 4.2.3 on 2023-08-10 17:37

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
(
"dissemination",
"0023_rename_report_required_general_is_report_required_and_more",
),
]

operations = [
migrations.RenameField(
model_name="general",
old_name="total_fed_expenditures",
new_name="total_amount_expended",
),
migrations.RemoveField(
model_name="federalaward",
name="is_major",
),
migrations.RemoveField(
model_name="federalaward",
name="type_requirement",
),
migrations.RemoveField(
model_name="general",
name="type_report_major_program",
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 4.2.3 on 2023-08-10 17:43

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
(
"dissemination",
"0024_rename_total_fed_expenditures_general_total_amount_expended_and_more",
),
]

operations = [
migrations.RemoveField(
model_name="general",
name="is_report_required",
),
]
25 changes: 1 addition & 24 deletions backend/dissemination/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,6 @@ class FederalAward(models.Model):
help_text=docs.direct,
)

is_major = models.BooleanField(
"Indicate whether or not the Federal program is a major program",
null=True,
help_text=docs.major_program,
)
mp_audit_report_type = models.CharField(
"Type of Report Issued on the Major Program Compliance",
max_length=40,
Expand Down Expand Up @@ -232,12 +227,6 @@ class FederalAward(models.Model):
decimal_places=2,
help_text=docs.passthrough_amount,
)
type_requirement = models.CharField(
"Type Requirement Failure",
max_length=40,
null=True,
help_text=docs.type_requirement_cfdainfo,
)

class Meta:
unique_together = (
Expand Down Expand Up @@ -732,25 +721,13 @@ class General(models.Model):
audit_period_covered = models.CharField(
"Audit Period Covered by Audit", max_length=40, help_text=docs.period_covered
)
is_report_required = models.BooleanField(
"Distribution to Federal Agency required?",
null=True,
help_text=docs.report_required,
)

total_fed_expenditures = models.DecimalField(
total_amount_expended = models.DecimalField(
"Total Federal Expenditures",
null=True,
max_digits=10,
decimal_places=2,
help_text=docs.total_fed_expenditures,
)
type_report_major_program = models.CharField(
"Type of Report Issued on the Major Program Compliance",
max_length=40,
null=True,
help_text=docs.type_report_major_program_general,
)
type_audit_code = models.CharField("Determines if audit is A133 or UG", default="")

# Metadata
Expand Down