Skip to content

Commit

Permalink
Persist the fields in the DB
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanMarie-PM committed Aug 11, 2023
1 parent 114c851 commit 3ab9f33
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 24 deletions.
42 changes: 42 additions & 0 deletions backend/audit/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,51 @@ 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)
is_sp_framework_required = forms.MultipleChoiceField(choices=choices_YoN)
sp_framework_opinions = forms.MultipleChoiceField(
choices=choices_SP_FRAMEWORK_OPINIONS
)
is_going_concern_included = forms.MultipleChoiceField(choices=choices_YoN)
is_internal_control_deficiency_disclosed = forms.MultipleChoiceField(
choices=choices_YoN
Expand Down
59 changes: 35 additions & 24 deletions backend/audit/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,15 @@ def get(self, request, *args, **kwargs):
current_info = {
"cleaned_data": {
"gaap_results": sac.audit_information.get("gaap_results"),
"sp_framework_basis": sac.audit_information.get(
"sp_framework_basis"
),
"is_sp_framework_required": sac.audit_information.get(
"is_sp_framework_required"
),
"sp_framework_opinions": sac.audit_information.get(
"sp_framework_opinions"
),
"is_going_concern_included": sac.audit_information.get(
"is_going_concern_included"
),
Expand All @@ -602,17 +611,7 @@ def get(self, request, *args, **kwargs):
}
}

context = {
"auditee_name": sac.auditee_name,
"report_id": report_id,
"auditee_uei": sac.auditee_uei,
"user_provided_organization_type": sac.user_provided_organization_type,
"agency_names": AGENCY_NAMES,
"gaap_results": GAAP_RESULTS,
"sp_framework_basis": SP_FRAMEWORK_BASIS,
"sp_framework_opinions": SP_FRAMEWORK_OPINIONS,
"form": current_info,
}
context = self._get_context(sac, current_info)

return render(request, "audit/audit-info-form.html", context)
except SingleAuditChecklist.DoesNotExist:
Expand All @@ -636,22 +635,14 @@ def post(self, request, *args, **kwargs):
validated = validate_audit_information_json(audit_information)
sac.audit_information = validated
sac.save()

logger.info("Audit info form saved.", form.cleaned_data)

return redirect(reverse("audit:SubmissionProgress", args=[report_id]))
else:
logger.warn(form.errors)
for field, errors in form.errors.items():
for error in errors:
logger.warn(f"ERROR in field {field} : {error}")

form.clean_booleans()
context = {
"auditee_name": sac.auditee_name,
"report_id": report_id,
"auditee_uei": sac.auditee_uei,
"user_provided_organization_type": sac.user_provided_organization_type,
"agency_names": AGENCY_NAMES,
"gaap_results": GAAP_RESULTS,
"form": form,
}
context = self._get_context(sac, form)
return render(request, "audit/audit-info-form.html", context)

except SingleAuditChecklist.DoesNotExist:
Expand All @@ -660,6 +651,26 @@ def post(self, request, *args, **kwargs):
logger.info("Enexpected error in AuditInfoFormView post.\n", e)
raise BadRequest()

def _get_context(self, sac, form):
context = {
"auditee_name": sac.auditee_name,
"report_id": sac.report_id,
"auditee_uei": sac.auditee_uei,
"user_provided_organization_type": sac.user_provided_organization_type,
"agency_names": AGENCY_NAMES,
"gaap_results": GAAP_RESULTS,
"sp_framework_basis": SP_FRAMEWORK_BASIS,
"sp_framework_opinions": SP_FRAMEWORK_OPINIONS,
}
for field, value in context.items():
logger.warn(f"{field}:{value}")
context.update(
{
"form": form,
}
)
return context


class PageInput:
def __init__(self, text="", id="", required=True, hint=None):
Expand Down
29 changes: 29 additions & 0 deletions backend/schemas/output/sections/AuditInformation.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,35 @@
},
"is_material_noncompliance_disclosed": {
"type": "boolean"
},
"is_sp_framework_required": {
"type": "boolean"
},
"sp_framework_basis": {
"items": {
"description": "GAAP Results (Audit Information)",
"enum": [
"cash_basis",
"tax_basis",
"contractual_basis",
"other_basis"
],
"type": "string"
},
"type": "array"
},
"sp_framework_opinions": {
"items": {
"description": "GAAP Results (Audit Information)",
"enum": [
"unmodified_opinion",
"qualified_opinion",
"adverse_opinion",
"disclaimer_of_opinion"
],
"type": "string"
},
"type": "array"
}
},
"required": [
Expand Down
9 changes: 9 additions & 0 deletions backend/schemas/source/base/Base.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,15 @@ local Enum = {
description: 'GAAP Results (Audit Information)',
enum: std.map(function(pair) pair.tag, GAAP.gaap_results),
},
SP_Framework_Basis: Types.string {
description: 'SP Framework Basis (Audit Information)',
enum: std.map(function(pair) pair.tag, GAAP.sp_framework_basis),
},
SP_Framework_Opinions: Types.string {
description: 'SP Framework Opinions (Audit Information)',
enum: std.map(function(pair) pair.tag, GAAP.sp_framework_opinions),
},

};

local simple_phone_regex = '[1-9]{1}[0-9]{9}+';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ local AuditInformation = Types.object {
gaap_results: Types.array {
items: Base.Enum.GAAPResults,
},
sp_framework_basis: Types.array {
items: Base.Enum.SP_Framework_Basis,
},
is_sp_framework_required: Types.boolean,
sp_framework_opinions: Types.array {
items: Base.Enum.SP_Framework_Opinions,
},
dollar_threshold: Types.integer,
is_going_concern_included: Types.boolean,
is_internal_control_deficiency_disclosed: Types.boolean,
Expand Down
3 changes: 3 additions & 0 deletions backend/static/js/audit-info-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ function setCheckboxRequired(name) {

function init() {
setCheckboxRequired('gaap_results');
setCheckboxRequired('sp_framework_basis');
setCheckboxRequired('is_sp_framework_required');
setCheckboxRequired('sp_framework_opinions');
setCheckboxRequired('is_going_concern_included');
setCheckboxRequired('is_internal_control_deficiency_disclosed');
setCheckboxRequired('is_internal_control_material_weakness_disclosed');
Expand Down

0 comments on commit 3ab9f33

Please sign in to comment.