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.
Merge branch 'develop' into 2722/circleci
- Loading branch information
Showing
29 changed files
with
393 additions
and
28 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
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')), | ||
], | ||
), | ||
] |
Oops, something went wrong.