Skip to content

Commit 5f9ac69

Browse files
committed
fix srp first and last names
1 parent ed5da60 commit 5f9ac69

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lib/documentTypes/srpBill.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ module.exports = {
3636
let last_name;
3737
if (serviceFromLineIndex >= 0) {
3838
fullNameLine = rawText[serviceFromLineIndex + 1];
39-
// first name & last name (dropping anything between first and last words)
40-
first_name = fullNameLine.split(' ').slice(0, 1).join(' ');
41-
last_name = fullNameLine.split(' ').slice(-1).join(' ');
39+
if (!fullNameLine.match(/^YOUR ACCOUNT SUMMARY(.*)$/g)) {
40+
// first name & last name (dropping anything between first and last words)
41+
first_name = fullNameLine.split(' ').slice(0, 1).join(' ');
42+
last_name = fullNameLine.split(' ').slice(-1).join(' ');
43+
}
4244
}
4345

4446
let last10Lines = rawText.slice(-10);
@@ -57,6 +59,13 @@ module.exports = {
5759
// city, state, zip code
5860
const lineWithCityStateZipCodeIndex = last10Lines.findIndex((line) => line.match(/^([A-Za-z\s]+) ([A-Z]{2}) (\d+-\d+)$/g));
5961
if (lineWithCityStateZipCodeIndex) {
62+
if (!first_name || !last_name
63+
|| !first_name.length || !last_name.length
64+
|| first_name.match(/\d+/g) || last_name.match(/\d+/g)) {
65+
fullNameLine = last10Lines[lineWithCityStateZipCodeIndex - 2];
66+
first_name = fullNameLine.split(' ').slice(0, 1).join(' ');
67+
last_name = fullNameLine.split(' ').slice(-1).join(' ');
68+
}
6069
street_address_line_1 = last10Lines[lineWithCityStateZipCodeIndex - 1];
6170
street_address_line_2 = '';
6271
cityStateZipCodeLine = last10Lines[lineWithCityStateZipCodeIndex].split(' ');

0 commit comments

Comments
 (0)