forked from HHS/TANF-app
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tribal Section 4 Parsing & Validation (#2762)
* Added formating for header and autofit columns * Formatted the headers * added year/month to the columns * Added contants - translation column * added friendly names to T1 and T2 * added friendly name to m1 and m2 * added friendly name to m3 * added friendly_name to t3 * added friendly_name to t4 and t5 * added friendly_name to t7 * correct missing friendly_name * correction on failing tests * addedfriendly name to excel report * linting * linting * linting * delete contants.py * added test for json field in error model * linting * linting * linting * - Added Tribal models, docs, admin refs - Added support for tribal parsing * - Update t1 field validators * - t2/t3 field validators * 2599-added friendly name to postparsing validators * - Updated cat3 validators * - Updated how we detect tribe code * - Added error handling for inconsistent header info wrt tribe code - Added new test * - Updated test * - Grammar fix - Removed unused function * refining the validator tests * - Format with Black - Add missing tests * - Fix lint * added returning fields names to validators * added friendly_name to error field * linting * corrections on views/tests * corrections for fields * failing test corrected * failing test corrected * correcting test failures * linting * corrected the excel fiel generator * removed excessive space in validator * linting * - Updated based on review feedback * - removing debug assert * - Fix lint * listing * - deconflicting migrations * - Fixing test * added m6 * lint * - Adding datafile * - Added support for parsing tribal t4/t5 - Added test for t4/t5 parsing * - ADded cat2/cat3 validators * corrected new line break * - Update doc strings * - Fixed failing test * - Fix lint * refactored validator logic * - resolving conflict * - Fix lint errors * - Resolve conflict * linting and correction on t1 * friendly_name correction from comments * friendly_name correction * corrected failing test for m5 * refactor the field_json creation DRY * - Renamed tribal files - Updated to allow case aggregates - Updated datafile to have a more convenient date range - Updated tests to capture case aggregates * - Reduced file size - Updated test * - Fix lint errors * - Added support for parsing and validating tribal t6 records * - Fix lint * - Added support for parsing/validating tribal t7 * - Fix lint * - Docstring fix * - Docstring fix * friendly_name corrections * - Adding friendly names to tribal * - Fixing typo * - Added friendly names * - Adding friendly names * - Adding friendly names * linting and cleaning errors * linting * correction on friendly_names * corrected friendly_name for test_util * correction child care - number of months * fixed a few more typos and some spacing. (#2767) * fixed a few more typos and some spacing. * fixed linting issues * missed a spot. --------- Co-authored-by: George Hudson <ghudson@teamraft.com> * - knowledge center * - Integrating Jans changes. Parametrizing values_is_empty * - Update based on review feedback * - Updated length checks * - removing fips code * Update tdrs-backend/tdpservice/parsers/schema_defs/tribal_tanf/t2.py Co-authored-by: Alex P. <63075587+ADPennington@users.noreply.github.com> * Update tdrs-backend/tdpservice/parsers/schema_defs/tribal_tanf/t3.py Co-authored-by: Alex P. <63075587+ADPennington@users.noreply.github.com> * Update tdrs-backend/tdpservice/parsers/schema_defs/tribal_tanf/t3.py Co-authored-by: Alex P. <63075587+ADPennington@users.noreply.github.com> * Update tdrs-backend/tdpservice/parsers/schema_defs/tribal_tanf/t3.py Co-authored-by: Alex P. <63075587+ADPennington@users.noreply.github.com> * - update based on review * - Fix migration * - Fixed name clash on PARENT_MINOR_CHILD * - Fixed name clash on PARENT_MINOR_CHILD * - Cherry pick commit and remove test file * Revert "- Fixed name clash on PARENT_MINOR_CHILD" This reverts commit 5850dc8. --------- Co-authored-by: Mo Sohani <msohani@goraft.tech> Co-authored-by: raftmsohani <97037188+raftmsohani@users.noreply.github.com> Co-authored-by: George Hudson <georgehudson78@gmail.com> Co-authored-by: George Hudson <ghudson@teamraft.com> Co-authored-by: Alex P. <63075587+ADPennington@users.noreply.github.com> Co-authored-by: Andrew <84722778+andrew-jameson@users.noreply.github.com>
- Loading branch information
1 parent
1b17e39
commit b35795f
Showing
19 changed files
with
315 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
tdrs-backend/tdpservice/parsers/schema_defs/tribal_tanf/t7.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
"""Schema for Tribal TANF T7 Row.""" | ||
|
||
from tdpservice.parsers.util import SchemaManager | ||
from tdpservice.parsers.fields import Field, TransformField | ||
from tdpservice.parsers.row_schema import RowSchema | ||
from tdpservice.parsers.transforms import calendar_quarter_to_rpt_month_year | ||
from tdpservice.parsers import validators | ||
from tdpservice.search_indexes.models.tribal import Tribal_TANF_T7 | ||
|
||
schemas = [] | ||
|
||
validator_index = 7 | ||
section_ind_index = 7 | ||
stratum_index = 8 | ||
families_index = 10 | ||
for i in range(1, 31): | ||
month_index = (i - 1) % 3 | ||
sub_item_labels = ["A", "B", "C"] | ||
families_value_item_number = f"6{sub_item_labels[month_index]}" | ||
|
||
schemas.append( | ||
RowSchema( | ||
model=Tribal_TANF_T7, | ||
quiet_preparser_errors=i > 1, | ||
preparsing_validators=[ | ||
validators.hasLength(247), | ||
validators.notEmpty(0, 7), | ||
validators.notEmpty(validator_index, validator_index + 24), | ||
], | ||
postparsing_validators=[], | ||
fields=[ | ||
Field( | ||
item="0", | ||
name="RecordType", | ||
friendly_name="record type", | ||
type="string", | ||
startIndex=0, | ||
endIndex=2, | ||
required=True, | ||
validators=[], | ||
), | ||
Field( | ||
item="3", | ||
name="CALENDAR_QUARTER", | ||
friendly_name="calendar quarter", | ||
type="number", | ||
startIndex=2, | ||
endIndex=7, | ||
required=True, | ||
validators=[ | ||
validators.dateYearIsLargerThan(1998), | ||
validators.quarterIsValid(), | ||
], | ||
), | ||
TransformField( | ||
transform_func=calendar_quarter_to_rpt_month_year(month_index), | ||
item="3A", | ||
name="RPT_MONTH_YEAR", | ||
friendly_name="reporting month year", | ||
type="number", | ||
startIndex=2, | ||
endIndex=7, | ||
required=True, | ||
validators=[ | ||
validators.dateYearIsLargerThan(1998), | ||
validators.dateMonthIsValid(), | ||
], | ||
), | ||
Field( | ||
item="4", | ||
name="TDRS_SECTION_IND", | ||
friendly_name="tdrs section indicator", | ||
type="string", | ||
startIndex=section_ind_index, | ||
endIndex=section_ind_index + 1, | ||
required=True, | ||
validators=[validators.oneOf(["1", "2"])], | ||
), | ||
Field( | ||
item="5", | ||
name="STRATUM", | ||
friendly_name="stratum", | ||
type="string", | ||
startIndex=stratum_index, | ||
endIndex=stratum_index + 2, | ||
required=True, | ||
validators=[validators.isInStringRange(0, 99)], | ||
), | ||
Field( | ||
item=families_value_item_number, | ||
name="FAMILIES_MONTH", | ||
friendly_name="families month", | ||
type="number", | ||
startIndex=families_index, | ||
endIndex=families_index + 7, | ||
required=True, | ||
validators=[validators.isInLimits(0, 9999999)], | ||
), | ||
], | ||
) | ||
) | ||
|
||
index_offset = 0 if i % 3 != 0 else 24 | ||
validator_index += index_offset | ||
section_ind_index += index_offset | ||
stratum_index += index_offset | ||
families_index += 7 if i % 3 != 0 else 10 | ||
|
||
t7 = SchemaManager(schemas=schemas) |
3 changes: 3 additions & 0 deletions
3
tdrs-backend/tdpservice/parsers/test/data/tribal_section_4_fake.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
HEADER20194S00142TAN1EU | ||
T720204101006853700680540068454103000312400037850003180104000347400036460003583106000044600004360000325299000506200036070003385202000039100002740000499 | ||
TRAILER0000001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
tdrs-backend/tdpservice/search_indexes/migrations/0025_tribal_tanf_t7.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Generated by Django 3.2.15 on 2023-11-29 19:49 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import uuid | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('data_files', '0012_datafile_s3_versioning_id'), | ||
('search_indexes', '0024_tribal_tanf_t6'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Tribal_TANF_T7', | ||
fields=[ | ||
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), | ||
('RecordType', models.CharField(max_length=156, null=True)), | ||
('CALENDAR_QUARTER', models.IntegerField(blank=True, null=True)), | ||
('RPT_MONTH_YEAR', models.IntegerField(null=True)), | ||
('TDRS_SECTION_IND', models.CharField(max_length=1, null=True)), | ||
('STRATUM', models.CharField(max_length=2, null=True)), | ||
('FAMILIES_MONTH', models.IntegerField(null=True)), | ||
('datafile', models.ForeignKey(blank=True, help_text='The parent file from which this record was created.', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='tribal_t7_parent', to='data_files.datafile')), | ||
], | ||
), | ||
] |
18 changes: 18 additions & 0 deletions
18
tdrs-backend/tdpservice/search_indexes/migrations/0026_parent_minor_child_rename.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 3.2.15 on 2023-09-14 17:20 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('search_indexes', '0025_tribal_tanf_t7'), | ||
] | ||
|
||
operations = [ | ||
migrations.RenameField( | ||
model_name='tanf_t2', | ||
old_name='PARENT_WITH_MINOR_CHILD', | ||
new_name='PARENT_MINOR_CHILD', | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.