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

Draft: Supporting multiple expenditure thresholds on eligibility page #4405

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
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
16 changes: 15 additions & 1 deletion backend/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from audit.get_agency_names import get_agency_names, get_audit_info_lists
import dj_database_url
import newrelic.agent
import datetime

newrelic.agent.initialize()

Expand Down Expand Up @@ -553,7 +554,6 @@

# APP-level constants
CENSUS_DATA_SOURCE = "CENSUS"
DOLLAR_THRESHOLD = 750000
SUMMARY_REPORT_DOWNLOAD_LIMIT = 1000
DEFAULT_MAX_ROWS = (
10000 # A version of this constant also exists in schemas.scrpits.render.py
Expand Down Expand Up @@ -581,3 +581,17 @@
# Keep sessions alive if the user is active
# https://docs.djangoproject.com/en/dev/ref/settings/#session-save-every-request
SESSION_SAVE_EVERY_REQUEST = True

# Minimum expenditure thresholds
DOLLAR_THRESHOLDS = [
{
"start": None,
"end": datetime.date(2024, 10, 1),
"minimum": 750000,
},
{
"start": datetime.date(2024, 10, 1),
"end": None,
"minimum": 1000000,
},
]
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,13 @@
</fieldset>
<fieldset class="usa-fieldset question">
<legend class="usa-legend">
Did this entity spend $750,000 or more in federal awards during its audit period in accordance with
Uniform
Guidance?
Did this entity spend an amount of federal awards meeting one of the following criteria during its audit period, in accordance with Uniform Guidance?
<abbr title="required" class="usa-hint usa-hint--required">*</abbr>
<ul>
{% for dollar_threshold in dollar_thresholds %}
<li>{{ dollar_threshold }}</li>
{% endfor %}
</ul>
</legend>
<div class="usa-radio">
<input class="usa-radio__input"
Expand All @@ -118,9 +121,7 @@
aria-required="true"
required/>
<label class="usa-radio__label" for="spend-no">No</label>
<span class="usa-error-message">You only need to submit a report for an entity that spent $750,000
or more in federal awards during its audit period (fiscal period beginning dates on or after
12/26/2014).</span>
<span class="usa-error-message">You do not meet the requirements for submitting a single audit report.</span>
</div>
</fieldset>
<fieldset class="usa-fieldset question">
Expand Down
39 changes: 38 additions & 1 deletion backend/report_submission/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.urls import reverse
from django.conf import settings
from unittest.mock import MagicMock, patch
from report_submission.views import DeleteFileView
from report_submission.views import DeleteFileView, EligibilityFormView
from model_bakery import baker

from audit.models import Access, SingleAuditChecklist, SubmissionEvent
Expand Down Expand Up @@ -164,6 +164,43 @@ def test_step_one_eligibility_submission_fail(self):
self.assertEqual(response.status_code, 302)
self.assertEqual(response.url, "/report_submission/eligibility/")

def test_step_one_generate_dollar_thresholds(self):
"""
/report_submissions/eligibility
Check that the correct threshold conditions are generated
"""
view = EligibilityFormView()

# Empty case
dollar_thresholds = []
result = []
self.assertEqual(view._generate_dollar_thresholds(dollar_thresholds), result)

# Normal case
dollar_thresholds = [
{
"start": None,
"end": date(2024, 1, 1),
"minimum": 750000,
},
{
"start": date(2024, 6, 1),
"end": date(2024, 12, 1),
"minimum": 900000,
},
{
"start": date(2024, 12, 1),
"end": None,
"minimum": 1000000,
},
]
result = [
"$750,000 or more with a Fiscal Year starting BEFORE January 01, 2024",
"$900,000 or more with a Fiscal Year starting ON or AFTER June 01, 2024 and BEFORE December 01, 2024",
"$1,000,000 or more with a Fiscal Year starting ON or AFTER December 01, 2024",
]
self.assertEqual(view._generate_dollar_thresholds(dollar_thresholds), result)

@patch("report_submission.forms.get_uei_info_from_sam_gov")
def test_end_to_end_submission_pass(self, mock_get_uei_info):
"""
Expand Down
32 changes: 28 additions & 4 deletions backend/report_submission/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from audit.utils import Util
from audit.models.models import ExcelFile
from audit.fixtures.excel import FORM_SECTIONS
from config.settings import STATIC_SITE_URL, STATE_ABBREVS
from config.settings import STATIC_SITE_URL, STATE_ABBREVS, DOLLAR_THRESHOLDS

from report_submission.forms import AuditeeInfoForm, GeneralInformationForm

Expand All @@ -35,11 +35,35 @@ def get(self, request):
# Step 1
class EligibilityFormView(LoginRequiredMixin, View):
def get(self, request):
args = {}
args["step"] = 1
args = {
"step": 1,
"dollar_thresholds": self._generate_dollar_thresholds(DOLLAR_THRESHOLDS),
}

return render(request, "report_submission/step-1.html", args)

# render eligibility form
# Used for populating the expenditure criteria bulletpoints
def _generate_dollar_thresholds(self, dollar_thresholds):
result = []
for dollar_threshold in dollar_thresholds:
start = dollar_threshold["start"]
end = dollar_threshold["end"]
minimum = format(dollar_threshold["minimum"], ",d")

if not start and end:
result.append(
f"${minimum} or more with a Fiscal Year starting BEFORE {end.strftime('%B %d, %Y')}"
)
elif start and end:
result.append(
f"${minimum} or more with a Fiscal Year starting ON or AFTER {start.strftime('%B %d, %Y')} and BEFORE {end.strftime('%B %d, %Y')}"
)
elif start and not end:
result.append(
f"${minimum} or more with a Fiscal Year starting ON or AFTER {start.strftime('%B %d, %Y')}"
)

return result

# gather/save step 1 info, redirect to step 2
def post(self, post_request):
Expand Down