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

Jmm/1729 sp_framework fields #1798

Merged
merged 10 commits into from
Aug 14, 2023
56 changes: 46 additions & 10 deletions backend/audit/etl.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def load_all(self):
self.load_passthrough,
self.load_finding_texts,
self.load_captext,
# self.load_audit_info() # TODO: Uncomment when SingleAuditChecklist adds audit_information
self.load_audit_info,
)
for load_method in load_methods:
try:
Expand All @@ -47,6 +47,11 @@ def load_all(self):

def load_finding_texts(self):
findings_text = self.single_audit_checklist.findings_text

if not findings_text:
logger.warning("No finding texts found to load")
return

findings_text_entries = findings_text["FindingsText"]["findings_text_entries"]
for entry in findings_text_entries:
finding_text_ = FindingText(
Expand All @@ -61,6 +66,10 @@ def load_findings(self):
findings_uniform_guidance = (
self.single_audit_checklist.findings_uniform_guidance
)
if not findings_uniform_guidance:
logger.warning("No findings found to load")
return

findings_uniform_guidance_entries = findings_uniform_guidance[
"FindingsUniformGuidance"
]["findings_uniform_guidance_entries"]
Expand Down Expand Up @@ -135,6 +144,10 @@ def load_federal_award(self):

def load_captext(self):
corrective_action_plan = self.single_audit_checklist.corrective_action_plan
if not corrective_action_plan:
logger.warning("No corrective action plans found to load")
return

corrective_action_plan_entries = corrective_action_plan["CorrectiveActionPlan"][
"corrective_action_plan_entries"
]
Expand All @@ -149,6 +162,10 @@ def load_captext(self):

def load_note(self):
notes_to_sefa = self.single_audit_checklist.notes_to_sefa["NotesToSefa"]
if not notes_to_sefa:
logger.warning("No notes to sefa found to load")
return

accounting_policies = notes_to_sefa["accounting_policies"]
is_minimis_rate_used = notes_to_sefa["is_minimis_rate_used"] == "Y"
rate_explained = notes_to_sefa["rate_explained"]
Expand Down Expand Up @@ -201,6 +218,13 @@ def load_revision(self):
def load_passthrough(self):
federal_awards = self.single_audit_checklist.federal_awards
for entry in federal_awards["FederalAwards"]["federal_awards"]:
entities = (
entry["direct_or_indirect_award"]
and entry["direct_or_indirect_award"]["entities"]
)
if not entities:
logger.warning("No passthrough to load")
return
for entity in entry["direct_or_indirect_award"]["entities"]:
passthrough = Passthrough(
award_reference=entry["award_reference"],
Expand Down Expand Up @@ -294,6 +318,9 @@ def load_general(self):

def load_secondary_auditor(self):
secondary_auditors = self.single_audit_checklist.secondary_auditors
if not secondary_auditors:
logger.warning("No secondary_auditors found to load")
return

for secondary_auditor in secondary_auditors["SecondaryAuditors"][
"secondary_auditors_entries"
Expand All @@ -315,17 +342,26 @@ def load_secondary_auditor(self):
sec_auditor.save()

def load_audit_info(self):
general = General.objects.get(report_id=self.single_audit_checklist.report_id)
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 AuditInfo. report_id = {report_id}"
)
return
audit_information = self.single_audit_checklist.audit_information

if not audit_information:
logger.warning("No audit info found to load")
return
general.gaap_results = audit_information["gaap_results"]
"""
TODO:
Missing in schema
general.sp_framework = audit_information[]
general.is_sp_framework_required = audit_information[]
general.sp_framework_auditor_opinion = audit_information[]
"""
general.sp_framework = audit_information["sp_framework_basis"]
general.is_sp_framework_required = (
audit_information["is_sp_framework_required"] == "Y"
)
general.sp_framework_auditor_opinion = audit_information[
"sp_framework_opinions"
]
general.is_going_concern = audit_information["is_going_concern_included"] == "Y"
general.is_significant_deficiency = (
audit_information["is_internal_control_deficiency_disclosed"] == "Y"
Expand Down
48 changes: 48 additions & 0 deletions backend/audit/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,57 @@ def clean_booleans(self):
"Financial statements were not prepared in accordance with GAAP but were prepared in accordance with a special purpose framework.",
),
)
choices_SP_FRAMEWORK_BASIS = (
(
"cash_basis",
"Cash basis",
),
(
"tax_basis",
"Tax basis",
),
(
"contractual_basis",
"Contractual basis",
),
(
"other_basis",
"Other basis",
),
)
choices_SP_FRAMEWORK_OPINIONS = (
(
"unmodified_opinion",
"Unmodified opinion",
),
(
"qualified_opinion",
"Qualified opinion",
),
(
"adverse_opinion",
"Adverse opinion",
),
(
"disclaimer_of_opinion",
"Disclaimer of opinion",
),
)

choices_agencies = list((i, i) for i in AGENCY_NAMES)

gaap_results = forms.MultipleChoiceField(choices=choices_GAAP)
sp_framework_basis = forms.MultipleChoiceField(
choices=choices_SP_FRAMEWORK_BASIS,
required=False,
)
is_sp_framework_required = forms.MultipleChoiceField(
choices=choices_YoN,
)
sp_framework_opinions = forms.MultipleChoiceField(
choices=choices_SP_FRAMEWORK_OPINIONS,
required=False,
)
is_going_concern_included = forms.MultipleChoiceField(choices=choices_YoN)
is_internal_control_deficiency_disclosed = forms.MultipleChoiceField(
choices=choices_YoN
Expand Down
4 changes: 2 additions & 2 deletions backend/audit/get_agency_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ def get_agency_names():
return agency_names


def get_gaap_results():
def get_audit_info_lists(name):
sonnet = "./schemas/source/base/GAAP.libsonnet"
json_str = _jsonnet.evaluate_file(sonnet)
jobj = json.loads(json_str)
# Returns a list of dictionaries with the keys 'tag' and 'readable'
return jobj["gaap_results"]
return jobj[name]
75 changes: 70 additions & 5 deletions backend/audit/templates/audit/audit-info-form.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h1>Audit information</h1>
<h1>Financial statements</h1>
<fieldset class="usa-fieldset">
<legend>
What were the results of the auditor’s determination of whether the financial statements of the auditee were prepared in accordance with generally accepted accounting principles (GAAP)? <abbr title="required" class="usa-hint usa-hint--required">*</abbr>
a. What were the results of the auditor’s determination of whether the financial statements of the auditee were prepared in accordance with generally accepted accounting principles (GAAP)? <abbr title="required" class="usa-hint usa-hint--required">*</abbr>
</legend>
<p class="text-base">Select any of the following that apply.</p>
{% for pair in gaap_results %}
Expand All @@ -53,9 +53,74 @@ <h1>Financial statements</h1>
{% endfor %}
<span class="usa-error-message margin-top-2">{{ form.errors.gaap_results|striptags }}</span>
</fieldset>
<div id="sp_framework_section">
<fieldset class="usa-fieldset margin-top-2">
<legend>
If the financial statements of the auditee were prepared in accordance with GAAP, proceed to question b.
</legend>
<p class="text-base">i. What was the special purpose framework? Select only one.</p>
{% for pair in sp_framework_basis %}
<div class="usa-checkbox">
<input id="sp_framework_basis--{{ pair.tag }}"
name="sp_framework_basis"
class="usa-radio__input"
required
type="radio"
value="{{ pair.tag }}"
{% if pair.tag in form.cleaned_data.sp_framework_basis %}checked{% endif %} />
<label class="usa-radio__label" for="sp_framework_basis--{{ pair.tag }}">{{ pair.readable }}</label>
</div>
{% endfor %}
<span class="usa-error-message margin-top-2">{{ form.errors.gaap_results|striptags }}</span>
</fieldset>
<fieldset class="usa-fieldset margin-top-2">
<legend>
ii. Was the special purpose framework used as a basis of accounting required by state law?
</legend>
<div class="usa-radio">
<input id="is_sp_framework_required--true"
name="is_sp_framework_required"
class="usa-radio__input"
required
type="radio"
value="True"
{% if form.cleaned_data.is_sp_framework_required is True %}checked{% endif %} />
<label class="usa-radio__label" for="is_sp_framework_required--true">Yes</label>
</div>
<div class="usa-radio">
<input id="is_sp_framework_required--false"
name="is_sp_framework_required"
class="usa-radio__input"
type="radio"
value="False"
{% if form.cleaned_data.is_sp_framework_required is False %}checked{% endif %} />
<label class="usa-radio__label" for="is_sp_framework_required--false">No</label>
</div>
<span class="usa-error-message margin-top-2">{{ form.errors.is_going_concern_included|striptags }}</span>
</fieldset>
<fieldset class="usa-fieldset">
<legend>
iii. What was the auditor’s opinion on the special purpose framework? <abbr title="required" class="usa-hint usa-hint--required">*</abbr>
</legend>
<p class="text-base">Select any of the following that apply.</p>
{% for pair in sp_framework_opinions %}
<div class="usa-checkbox">
<input id="sp_framework_opinions--{{ pair.tag }}"
name="sp_framework_opinions"
class="usa-checkbox__input"
required
type="checkbox"
value="{{ pair.tag }}"
{% if pair.tag in form.cleaned_data.sp_framework_opinions %}checked{% endif %} />
<label class="usa-checkbox__label" for="sp_framework_opinions--{{ pair.tag }}">{{ pair.readable }}</label>
</div>
{% endfor %}
<span class="usa-error-message margin-top-2">{{ form.errors.gaap_results|striptags }}</span>
</fieldset>
</div>
<fieldset class="usa-fieldset margin-top-2">
<legend>
Is a "going concern" emphasis-of-matter paragraph included in the audit report? <abbr title="required" class="usa-hint usa-hint--required">*</abbr>
b. Is a "going concern" emphasis-of-matter paragraph included in the audit report? <abbr title="required" class="usa-hint usa-hint--required">*</abbr>
</legend>
<div class="usa-radio">
<input id="is_going_concern_included--true"
Expand All @@ -80,7 +145,7 @@ <h1>Financial statements</h1>
</fieldset>
<fieldset class="usa-fieldset margin-top-2">
<legend>
Is a significant deficiency in internal control disclosed? <abbr title="required" class="usa-hint usa-hint--required">*</abbr>
c. Is a significant deficiency in internal control disclosed? <abbr title="required" class="usa-hint usa-hint--required">*</abbr>
</legend>
<div class="usa-radio">
<input id="is_internal_control_deficiency_disclosed--true"
Expand All @@ -107,7 +172,7 @@ <h1>Financial statements</h1>
</fieldset>
<fieldset class="usa-fieldset margin-top-2">
<legend>
Is a material weakness in internal control disclosed? <abbr title="required" class="usa-hint usa-hint--required">*</abbr>
d. Is a material weakness in internal control disclosed? <abbr title="required" class="usa-hint usa-hint--required">*</abbr>
</legend>
<div class="usa-radio">
<input id="is_internal_control_material_weakness_disclosed--true"
Expand All @@ -134,7 +199,7 @@ <h1>Financial statements</h1>
</fieldset>
<fieldset class="usa-fieldset margin-top-2">
<legend>
Is a material noncompliance disclosed? <abbr title="required" class="usa-hint usa-hint--required">*</abbr>
e. Is a material noncompliance disclosed? <abbr title="required" class="usa-hint usa-hint--required">*</abbr>
</legend>
<div class="usa-radio">
<input id="is_material_noncompliance_disclosed--true"
Expand Down
Loading