Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/1119 ssp section 3 #2733

Merged
merged 9 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tdrs-backend/tdpservice/parsers/schema_defs/ssp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from .m1 import m1
from .m2 import m2
from .m3 import m3
from .m6 import m6

m1 = m1
m2 = m2
m3 = m3
m6 = m6
147 changes: 147 additions & 0 deletions tdrs-backend/tdpservice/parsers/schema_defs/ssp/m6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
"""Schema for HEADER row of all submission types."""


from ...util import SchemaManager
from ...transforms import calendar_quarter_to_rpt_month_year
from ...fields import Field, TransformField
from ...row_schema import RowSchema
from ... import validators
from tdpservice.search_indexes.models.ssp import SSP_M6

s1 = RowSchema(
model=SSP_M6,
preparsing_validators=[
validators.hasLength(259),
],
postparsing_validators=[
validators.sumIsEqual(
"SSPMOE_FAMILIES", ["NUM_2_PARENTS", "NUM_1_PARENTS", "NUM_NO_PARENTS"]),
validators.sumIsEqual(
"NUM_RECIPIENTS", ["ADULT_RECIPIENTS", "CHILD_RECIPIENTS"]),
],
fields=[
Field(item="0", name='RecordType', type='string', startIndex=0, endIndex=2,
required=True, validators=[]),
Field(item="2", name='CALENDAR_QUARTER', type='number', startIndex=2, endIndex=7,
required=True, validators=[validators.dateYearIsLargerThan(1998),
validators.quarterIsValid()]),
TransformField(calendar_quarter_to_rpt_month_year(0), item="2B", name='RPT_MONTH_YEAR', type='number',
startIndex=2, endIndex=7, required=True, validators=[validators.dateYearIsLargerThan(1998),
validators.dateMonthIsValid()]),
Field(item="3A", name='SSPMOE_FAMILIES', type='number', startIndex=7, endIndex=15,
required=True, validators=[validators.isInLimits(0, 99999999)]),
Field(item="4A", name='NUM_2_PARENTS', type='number', startIndex=31, endIndex=39,
required=True, validators=[validators.isInLimits(0, 99999999)]),
Field(item="5A", name='NUM_1_PARENTS', type='number', startIndex=55, endIndex=63,
required=True, validators=[validators.isInLimits(0, 99999999)]),
Field(item="6A", name='NUM_NO_PARENTS', type='number', startIndex=79, endIndex=87,
required=True, validators=[validators.isInLimits(0, 99999999)]),
Field(item="7A", name='NUM_RECIPIENTS', type='number', startIndex=103, endIndex=111,
required=True, validators=[validators.isInLimits(0, 99999999)]),
Field(item="8A", name='ADULT_RECIPIENTS', type='number', startIndex=127, endIndex=135,
required=True, validators=[validators.isInLimits(0, 99999999)]),
Field(item="9A", name='CHILD_RECIPIENTS', type='number', startIndex=151, endIndex=159,
required=True, validators=[validators.isInLimits(0, 99999999)]),
Field(item="10A", name='NONCUSTODIALS', type='number', startIndex=175, endIndex=183,
required=True, validators=[validators.isInLimits(0, 99999999)]),
Field(item="11A", name='AMT_ASSISTANCE', type='number', startIndex=199, endIndex=211,
required=True, validators=[validators.isInLimits(0, 999999999999)]),
Field(item="12A", name='CLOSED_CASES', type='number', startIndex=235, endIndex=243,
required=True, validators=[validators.isInLimits(0, 99999999)]),
],
)

s2 = RowSchema(
model=SSP_M6,
preparsing_validators=[
validators.hasLength(259),
],
postparsing_validators=[
validators.sumIsEqual(
"SSPMOE_FAMILIES", ["NUM_2_PARENTS", "NUM_1_PARENTS", "NUM_NO_PARENTS"]),
validators.sumIsEqual(
"NUM_RECIPIENTS", ["ADULT_RECIPIENTS", "CHILD_RECIPIENTS"]),
],
fields=[
Field(item="0", name='RecordType', type='string', startIndex=0, endIndex=2,
required=True, validators=[]),
Field(item="2", name='CALENDAR_QUARTER', type='number', startIndex=2, endIndex=7,
required=True, validators=[validators.dateYearIsLargerThan(1998),
validators.quarterIsValid()]),
TransformField(calendar_quarter_to_rpt_month_year(1), item="2B", name='RPT_MONTH_YEAR', type='number',
startIndex=2, endIndex=7, required=True, validators=[validators.dateYearIsLargerThan(1998),
validators.dateMonthIsValid()]),
Field(item="3B", name='SSPMOE_FAMILIES', type='number', startIndex=15, endIndex=23,
required=True, validators=[validators.isInLimits(0, 99999999)]),
Field(item="4B", name='NUM_2_PARENTS', type='number', startIndex=39, endIndex=47,
required=True, validators=[validators.isInLimits(0, 99999999)]),
Field(item="5B", name='NUM_1_PARENTS', type='number', startIndex=63, endIndex=71,
required=True, validators=[validators.isInLimits(0, 99999999)]),
Field(item="6B", name='NUM_NO_PARENTS', type='number', startIndex=87, endIndex=95,
required=True, validators=[validators.isInLimits(0, 99999999)]),
Field(item="7B", name='NUM_RECIPIENTS', type='number', startIndex=111, endIndex=119,
required=True, validators=[validators.isInLimits(0, 99999999)]),
Field(item="8B", name='ADULT_RECIPIENTS', type='number', startIndex=135, endIndex=143,
required=True, validators=[validators.isInLimits(0, 99999999)]),
Field(item="9B", name='CHILD_RECIPIENTS', type='number', startIndex=159, endIndex=167,
required=True, validators=[validators.isInLimits(0, 99999999)]),
Field(item="10B", name='NONCUSTODIALS', type='number', startIndex=183, endIndex=191,
required=True, validators=[validators.isInLimits(0, 99999999)]),
Field(item="11B", name='AMT_ASSISTANCE', type='number', startIndex=211, endIndex=223,
required=True, validators=[validators.isInLimits(0, 999999999999)]),
Field(item="12B", name='CLOSED_CASES', type='number', startIndex=243, endIndex=251,
required=True, validators=[validators.isInLimits(0, 99999999)]),
],
)

s3 = RowSchema(
model=SSP_M6,
preparsing_validators=[
validators.hasLength(259),
],
postparsing_validators=[
validators.sumIsEqual(
"SSPMOE_FAMILIES", ["NUM_2_PARENTS", "NUM_1_PARENTS", "NUM_NO_PARENTS"]),
validators.sumIsEqual(
"NUM_RECIPIENTS", ["ADULT_RECIPIENTS", "CHILD_RECIPIENTS"]),
],
fields=[
Field(item="0", name='RecordType', type='string', startIndex=0, endIndex=2,
required=True, validators=[]),
Field(item="2", name='CALENDAR_QUARTER', type='number', startIndex=2, endIndex=7,
required=True, validators=[validators.dateYearIsLargerThan(1998),
validators.quarterIsValid()]),
TransformField(calendar_quarter_to_rpt_month_year(2), item="2B", name='RPT_MONTH_YEAR', type='number',
startIndex=2, endIndex=7, required=True, validators=[validators.dateYearIsLargerThan(1998),
validators.dateMonthIsValid()]),
Field(item="3C", name='SSPMOE_FAMILIES', type='number', startIndex=23, endIndex=31,
required=True, validators=[validators.isInLimits(0, 99999999)]),
Field(item="4C", name='NUM_2_PARENTS', type='number', startIndex=47, endIndex=55,
required=True, validators=[validators.isInLimits(0, 99999999)]),
Field(item="5C", name='NUM_1_PARENTS', type='number', startIndex=71, endIndex=79,
required=True, validators=[validators.isInLimits(0, 99999999)]),
Field(item="6C", name='NUM_NO_PARENTS', type='number', startIndex=95, endIndex=103,
required=True, validators=[validators.isInLimits(0, 99999999)]),
Field(item="7C", name='NUM_RECIPIENTS', type='number', startIndex=119, endIndex=127,
required=True, validators=[validators.isInLimits(0, 99999999)]),
Field(item="8C", name='ADULT_RECIPIENTS', type='number', startIndex=143, endIndex=151,
required=True, validators=[validators.isInLimits(0, 99999999)]),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this supposed to have a validator or did Alex make a mistake in the spreadsheet?

Field(item="9C", name='CHILD_RECIPIENTS', type='number', startIndex=167, endIndex=175,
required=True, validators=[validators.isInLimits(0, 99999999)]),
Field(item="10C", name='NONCUSTODIALS', type='number', startIndex=191, endIndex=199,
required=True, validators=[validators.isInLimits(0, 99999999)]),
Field(item="11C", name='AMT_ASSISTANCE', type='number', startIndex=223, endIndex=235,
required=True, validators=[validators.isInLimits(0, 999999999999)]),
Field(item="12C", name='CLOSED_CASES', type='number', startIndex=251, endIndex=259,
required=True, validators=[validators.isInLimits(0, 99999999)]),
],
)


m6 = SchemaManager(
schemas=[
s1,
s2,
s3
]
)
3 changes: 3 additions & 0 deletions tdrs-backend/tdpservice/parsers/test/data/ADS.E2J.NDM3.MS24
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
HEADER20184G24 SSP1 N
M620184000158690001600800015956000008610000085100000845000149050001505500015013000001030000010200000098000513550005169600051348000157070001581400015766000356480003588200035582000000000000000000000000000000000000000000000000000000000000000012020000118900001229
TRAILER0000001
Loading
Loading