Skip to content

Commit

Permalink
fix aps street address
Browse files Browse the repository at this point in the history
  • Loading branch information
andobolocco committed Jun 19, 2020
1 parent c6148fe commit 3f5f3b9
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/documentTypes/apsBill.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module.exports = {

extractor: (keyValues, rawText) => {
const keys = Object.keys(keyValues);
const lineWithCityStateZipCodeIndex = rawText.findIndex((line) => line.match(/^[A-Z\s]+ [A-Z]{2} \d+-\d+$/g));
let fullName;
// first name & last name (WARNING splitting full name by space potential inconsistency)

Expand All @@ -48,8 +49,7 @@ module.exports = {
));
}
if (!fullName) {
const index = rawText.findIndex((line) => line.match(/^[A-Z\s]+ [A-Z]{2} \d+-\d+$/g)) - 2;
fullName = rawText[index];
fullName = rawText[lineWithCityStateZipCodeIndex - 2];
}

let first_name;
Expand All @@ -69,16 +69,18 @@ module.exports = {
if (indexOfFullNameInCapsLine >= 0) {
street_address_line_1 = rawText[indexOfFullNameInCapsLine + 1];
street_address_line_2 = rawText[indexOfFullNameInCapsLine + 2];
} else {
street_address_line_1 = rawText[lineWithCityStateZipCodeIndex - 1];
}

if (street_address_line_2.match(/Visit aps.com/g)) {
// case of no street_address_line_2
street_address_line_2 = '';
}
if (street_address_line_2.match(/Visit aps.com/g)) {
// case of no street_address_line_2
street_address_line_2 = '';
}
}

// city, state, zip code
const lineWithCityStateZip = rawText.find((line) => line.match(/^[A-Z\s]+ [A-Z]{2} \d+-\d+$/g));
const lineWithCityStateZip = rawText[lineWithCityStateZipCodeIndex];
if (lineWithCityStateZip === street_address_line_2) {
// case of no street_address_line_2
street_address_line_2 = '';
Expand Down

0 comments on commit 3f5f3b9

Please sign in to comment.