Skip to content

Commit

Permalink
fix: support validation of projects with ec code 7.3 (#3398)
Browse files Browse the repository at this point in the history
* Add new ec code declaration (7.3)

* Add unit test assertion for new IAA_Basic_Conditions__c column

* Apply normalization to multiselect values before comparing during validation

* Map projects with ec 7.3 code to project baseline template

---------

Co-authored-by: Andrew Hyndman <[email protected]>
  • Loading branch information
ajhyndman and Andrew Hyndman authored Aug 20, 2024
1 parent 53f72f3 commit 63187f4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ describe('validate record', () => {
Place_of_Performance_Zip__c: '02920',
Description__c: 'Sample description',
Subaward_Changed__c: 'No',
IAA_Basic_Conditions__c: '1. It imposes conditions on the use of funds by the agency, department, or part of government receiving funds to carry out the program',
};

it('validates a valid project succesfully', () => validateRecord({
Expand Down
1 change: 1 addition & 0 deletions packages/server/src/arpa_reporter/lib/arpa-ec-codes.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const ecCodes = {
5.21: 'Broadband: Other projects',
7.1: 'Administrative Expenses',
7.2: 'Transfers to Other Units of Government',
7.3: 'Costs Associated with Satisfying Certain Legal and Administrative Requirements of the SLFRF Program After December 31, 2024',
};

module.exports = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,8 @@ async function generateProjectBaseline(records) {
case '3.4':
case '3.5':
case '7.1':
case '7.2': {
case '7.2':
case '7.3': {
return [
null, // first col is blank
ec(record.type),
Expand Down
5 changes: 3 additions & 2 deletions packages/server/src/arpa_reporter/services/validate-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const { createRecipient, findRecipient, updateRecipient } = require('../db/arpa-
const { recordsForUpload, TYPE_TO_SHEET_NAME } = require('./records');
const { getRules } = require('./validation-rules');
const { ecCodes } = require('../lib/arpa-ec-codes');
const { multiselect } = require('../lib/format');

const ValidationError = require('../lib/validation-error');

Expand Down Expand Up @@ -291,7 +292,7 @@ async function validateRecord({ upload, record, typeRules: rules }) {
// make sure pick value is one of pick list values
if (rule.listVals.length > 0) {
// enforce validation in lower case
const lcItems = rule.listVals.map((val) => val.toLowerCase());
const lcItems = rule.listVals.map((val) => multiselect(val.toLowerCase()));

// for pick lists, the value must be one of possible values
if (rule.dataType === 'Pick List' && !lcItems.includes(value)) {
Expand All @@ -307,7 +308,7 @@ async function validateRecord({ upload, record, typeRules: rules }) {
for (const entry of entries) {
if (!lcItems.includes(entry)) {
errors.push(new ValidationError(
`Entry '${entry}' of ${key} is not one of ${lcItems.length} valid options`,
`Entry '${entry}' of ${key} is not one of ${lcItems.length} valid options (${JSON.stringify(lcItems)})`,
{ col: rule.columnName, severity: 'err' },
));
}
Expand Down

0 comments on commit 63187f4

Please sign in to comment.