Skip to content

Commit

Permalink
fix srp bill date
Browse files Browse the repository at this point in the history
  • Loading branch information
andobolocco committed Jun 23, 2020
1 parent 2815850 commit e4a55b4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/documentTypes/srpBill.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable camelcase */
const moment = require('moment');
const stringSimilarity = require('string-similarity');

module.exports = {

Expand Down Expand Up @@ -28,6 +29,7 @@ module.exports = {
},

extractor: (keyValues, rawText) => {
const keys = Object.keys(keyValues);
const serviceFromLineIndex = rawText.findIndex((line) => line.match(/^SERVICE FROM (.*)$/g));
let fullNameLine;
let first_name;
Expand Down Expand Up @@ -68,7 +70,14 @@ module.exports = {
}

// bill date
const bill_date = rawText.slice(-15).find((line) => line.match(/^\w+ \d+, \d+$/g));
let bill_date = keyValues[keys[stringSimilarity.findBestMatch(
'Please Pay by',
keys,
).bestMatchIndex]];

if (!bill_date || !bill_date.length || !bill_date.match(/^\w+ \d+, \d+$/g)) {
bill_date = rawText.slice(-20).find((line) => line.match(/^\w+ \d+, \d+$/g));
}

// account number
const accountNumberLine = rawText.find((line) => line.match(/^Account# (.*)$/g));
Expand Down

0 comments on commit e4a55b4

Please sign in to comment.