Skip to content

Commit

Permalink
Merge pull request #3129 from raft-tech/3073-closed-case-errors
Browse files Browse the repository at this point in the history
Bug: Fix REC_SSI Cat4 Validator
  • Loading branch information
elipe17 authored Aug 12, 2024
2 parents bfb55bf + cb10046 commit c632f19
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions tdrs-backend/tdpservice/parsers/case_consistency_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def __validate_section1(self, num_errors):
def __validate_section2(self, num_errors):
"""Perform TANF Section 2 category four validation on all cached records."""
num_errors += self.__validate_s2_records_are_related()
num_errors += self.__validate_t5_aabd_and_ssi()
num_errors += self.__validate_t5_atd_and_ssi()
return num_errors

def __validate_family_affiliation(self, num_errors, t1s, t2s, t3s, error_msg):
Expand Down Expand Up @@ -390,7 +390,7 @@ def __validate_s2_records_are_related(self):
num_errors += 1
return num_errors

def __validate_t5_aabd_and_ssi(self):
def __validate_t5_atd_and_ssi(self):
num_errors = 0
is_ssp = self.program_type == 'SSP'

Expand All @@ -403,7 +403,7 @@ def __validate_t5_aabd_and_ssi(self):
t5s = self.sorted_cases.get(t5_model, [])

for record, schema in t5s:
rec_aabd = getattr(record, 'REC_AID_TOTALLY_DISABLED')
rec_atd = getattr(record, 'REC_AID_TOTALLY_DISABLED')
rec_ssi = getattr(record, 'REC_SSI')
family_affiliation = getattr(record, 'FAMILY_AFFILIATION')
dob = getattr(record, 'DATE_OF_BIRTH')
Expand All @@ -413,7 +413,7 @@ def __validate_t5_aabd_and_ssi(self):
dob_date = datetime.strptime(dob, '%Y%m%d')
is_adult = get_years_apart(rpt_date, dob_date) >= 19

if is_territory and is_adult and (rec_aabd != 1 and rec_aabd != 2):
if is_territory and is_adult and rec_atd not in {1, 2}:
self.__generate_and_add_error(
schema,
record,
Expand All @@ -424,7 +424,7 @@ def __validate_t5_aabd_and_ssi(self):
)
)
num_errors += 1
elif is_state and rec_aabd != 2:
elif is_state and rec_atd == 1:
self.__generate_and_add_error(
schema,
record,
Expand All @@ -446,7 +446,7 @@ def __validate_t5_aabd_and_ssi(self):
)
)
num_errors += 1
elif is_state and family_affiliation == 1:
elif is_state and family_affiliation == 1 and rec_ssi not in {1, 2}:
self.__generate_and_add_error(
schema,
record,
Expand Down
8 changes: 4 additions & 4 deletions tdrs-backend/tdpservice/parsers/test/test_case_consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,7 @@ def test_section2_aabd_ssi_validator_pass_territory_child_aabd(self, small_corre
),
])
@pytest.mark.django_db
def test_section2_aabd_ssi_validator_fail_state_aabd(self, small_correct_file, header, T4Stuff, T5Stuff):
def test_section2_atd_ssi_validator_fail_state_atdd(self, small_correct_file, header, T4Stuff, T5Stuff):
"""Test records are related validator section 2 success case."""
(T4Factory, t4_schema, t4_model_name) = T4Stuff
(T5Factory, t5_schema, t5_model_name) = T5Stuff
Expand Down Expand Up @@ -1198,7 +1198,7 @@ def test_section2_aabd_ssi_validator_fail_territory_ssi(self, small_correct_file
),
])
@pytest.mark.django_db
def test_section2_aabd_ssi_validator_fail_state_ssi(self, small_correct_file, header, T4Stuff, T5Stuff):
def test_section2_atd_ssi_validator_fail_state_ssi(self, small_correct_file, header, T4Stuff, T5Stuff):
"""Test records are related validator section 2 success case."""
(T4Factory, t4_schema, t4_model_name) = T4Stuff
(T5Factory, t5_schema, t5_model_name) = T5Stuff
Expand Down Expand Up @@ -1228,15 +1228,15 @@ def test_section2_aabd_ssi_validator_fail_state_ssi(self, small_correct_file, he
DATE_OF_BIRTH="19970209",
FAMILY_AFFILIATION=1,
REC_AID_TOTALLY_DISABLED=2,
REC_SSI=2
REC_SSI=0
),
T5Factory.create(
RPT_MONTH_YEAR=202010,
CASE_NUMBER='123',
DATE_OF_BIRTH="19970209",
FAMILY_AFFILIATION=2, # validator only applies to fam_affil = 1; won't generate error
REC_AID_TOTALLY_DISABLED=2,
REC_SSI=2
REC_SSI=0
),
]
for t5 in t5s:
Expand Down

0 comments on commit c632f19

Please sign in to comment.