Skip to content

Commit

Permalink
Sk/3715 missing firm names (#3810)
Browse files Browse the repository at this point in the history
* Added test file for secondary auditor xforms

* Added append_secondary_auditors_changes

* Saving changes to secondary_auditor

* Added xform_cpafirmname

* Code improvement

* Code improvement

* Updated function name

* Updated function name

* Added required fields that contain GSA_MIGRATION

* Merged CPAFIRMNAME test cases

* Merged CPAFIRMNAME test cases

* Fixed merge issue

* Fixed linting error

* Update

* Tracking all data in change_records

* Fixed linting

* Code improvement

* Added more details to comment description
  • Loading branch information
gsa-suk authored May 9, 2024
1 parent 612020b commit e4c5b8e
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def check_for_gsa_migration_keyword(ir):
"contains_chart_or_table",
"is_minimis_rate_used",
"compliance_requirement",
"secondary_auditor_name",
"secondary_auditor_address_state",
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from .workbooklib.secondary_auditors import (
xform_address_state,
xform_cpafirmname,
)


Expand Down Expand Up @@ -30,3 +31,46 @@ def test_missing_address_state(self):
xform_address_state(secondary_auditors)

self.assertEqual(secondary_auditors[0].CPASTATE, settings.GSA_MIGRATION)


class TestXformCpaFirmName(SimpleTestCase):
class MockSecondaryAuditorHeader:
def __init__(
self,
DBKEY,
CPAFIRMNAME,
):
self.DBKEY = DBKEY
self.CPAFIRMNAME = CPAFIRMNAME

def _mock_secondaryauditor_header(self):
"""Returns a mock secondary_auditor with all necessary fields."""
return [
self.MockSecondaryAuditorHeader(
DBKEY="123456789",
CPAFIRMNAME="John Doe CPA Firm",
),
self.MockSecondaryAuditorHeader(
DBKEY="223456789",
CPAFIRMNAME="Jack C CPA Firm",
),
]

def test_valid_cpafirm(self):
"""Test that the function does not change the valid CPAFIRMNAME."""
secondary_auditors = self._mock_secondaryauditor_header()
cpas = secondary_auditors
xform_cpafirmname(secondary_auditors)
for index in range(len(secondary_auditors)):
self.assertEqual(
secondary_auditors[index].CPAFIRMNAME, cpas[index].CPAFIRMNAME
)

def test_blank_cpafirm(self):
"""Test that the function changes blank CPAFIRMNAME to GSA_MIGRATION."""
secondary_auditors = self._mock_secondaryauditor_header()
secondary_auditors[0].CPAFIRMNAME = ""
cpas = secondary_auditors
xform_cpafirmname(secondary_auditors)
self.assertEqual(secondary_auditors[0].CPAFIRMNAME, settings.GSA_MIGRATION)
self.assertEqual(secondary_auditors[1].CPAFIRMNAME, cpas[1].CPAFIRMNAME)
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from ..models import ELECCPAS as Caps
from ..change_record import InspectionRecord
from audit.fixtures.excel import FORM_SECTIONS

from django.conf import settings
import openpyxl as pyxl

Expand Down Expand Up @@ -94,6 +93,33 @@ def _get_secondary_auditors(dbkey, year):
return sort_by_field(results, "ID")


def xform_cpafirmname(secondary_auditors):
"""NOTE: We track all secondary_auditors data in change_records.
Save change_records in InspectionRecord only if at least one blank CPAFIRMNAME is found.
We do this so that we can match changedrecord to record in dissemination table in a one on one fashion.
"""

change_records = []
is_empty_cpafirmname_found = False
for secondary_auditor in secondary_auditors:
cpafirmname = string_to_string(secondary_auditor.CPAFIRMNAME)
if cpafirmname == "":
is_empty_cpafirmname_found = True
cpafirmname = settings.GSA_MIGRATION
track_transformations(
"CPAFIRMNAME",
secondary_auditor.CPAFIRMNAME,
"auditor_name",
cpafirmname,
["xform_cpafirmname"],
change_records,
)
secondary_auditor.CPAFIRMNAME = cpafirmname

if change_records and is_empty_cpafirmname_found:
InspectionRecord.append_secondary_auditor_changes(change_records)


def generate_secondary_auditors(audit_header, outfile):
"""
Generates secondary auditor workbook for a given audit header.
Expand All @@ -111,6 +137,7 @@ def generate_secondary_auditors(audit_header, outfile):
audit_header.DBKEY, audit_header.AUDITYEAR
)
xform_address_state(secondary_auditors)
xform_cpafirmname(secondary_auditors)
map_simple_columns(wb, mappings, secondary_auditors)
wb.save(outfile)

Expand Down

0 comments on commit e4c5b8e

Please sign in to comment.