UNPKG

docparse-supplier-nge

Version:

process ngrid electric utility bill data for use in the docparse system

24 lines (22 loc) 724 B
/** * Cost Supply text looks like "... Billing Period Jul 13, 2011 to Jul 21, 2011 Number of days in period 8 Basic Service Variable 0.0722 x 45600 kWh 3,292.32 Total Supply Services $ 11,414.00 ..." */ var extract = require('regex-extract'); var num = require('num'); module.exports = function(text, callback) { text = text.replace(/\$/g,''); if (!text.match(/Total Supply Services/)) { return callback(null, null); } var pattern = /Total Supply Services.*?(-?\s?[\d\.]+)\s*$/m; extract(text, pattern, function (err, reply) { if (err) { return callback(err, null); } var price = num(reply).toString(); return callback(null, price); }); };