Skip to content

Commit

Permalink
fixes srp bad city
Browse files Browse the repository at this point in the history
  • Loading branch information
andobolocco committed Jun 22, 2020
1 parent 2e04304 commit 08a1454
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions lib/documentTypes/srpBill.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,31 @@ module.exports = {
last_name = fullNameLine.split(' ').slice(-1).join(' ');
}

let last10Lines = rawText.slice(-10);
if (last10Lines.filter((line) => line === 'PRESCOTT AZ 86304-8062').length === 1) {
// remove SRP address
last10Lines = last10Lines.filter((line) => (
line !== 'PO BOX 80062'
&& line !== 'PRESCOTT AZ 86304-8062'
));
}
// street address line 1 & 2
const last5Lines = rawText.slice(-5);

let street_address_line_1;
let street_address_line_2;

let cityStateZipCodeLine = [];
// city, state, zip code
const lineWithCityStateZipCodeIndex = last5Lines.findIndex((line) => line.match(/^([A-Za-z\s]+) ([A-Z]{2}) (\d+-\d+)$/g));
const lineWithCityStateZipCodeIndex = last10Lines.findIndex((line) => line.match(/^([A-Za-z\s]+) ([A-Z]{2}) (\d+-\d+)$/g));
if (lineWithCityStateZipCodeIndex) {
street_address_line_1 = last5Lines[lineWithCityStateZipCodeIndex - 1];
street_address_line_1 = last10Lines[lineWithCityStateZipCodeIndex - 1];
street_address_line_2 = '';
cityStateZipCodeLine = last5Lines[lineWithCityStateZipCodeIndex].split(' ');
cityStateZipCodeLine = last10Lines[lineWithCityStateZipCodeIndex].split(' ');
}
const [city, state, zip_code] = cityStateZipCodeLine;

// bill amount
let bill_amount = keyValues['PLEASE PAY'];
if(!bill_amount || !bill_amount.length) {
if (!bill_amount || !bill_amount.length) {
bill_amount = keyValues['This Month\'s Charges'];
}

Expand Down

0 comments on commit 08a1454

Please sign in to comment.