UNPKG

docparse-supplier-nge

Version:

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

36 lines (32 loc) 881 B
/** * Find which supplier is suppling for this current bill on competitive supply * Note that bills on standard offer will not use this function */ var Supplier = require('docparse-supplier'); module.exports = function(text, callback) { var supplierCode; if (text.match(/Direct Energy Business LLC/i)) { supplierCode = 'DIR'; } else if (text.match(/Noble/i)) { supplierCode = 'NOB'; } else if (text.match(/NStar/i)) { supplierCode = 'NST'; } else if (text.match(/Hess/i)) { supplierCode = 'HES'; } else if (text.match(/Liberty Utilities/i)) { supplierCode = 'LIB'; } else if (text.match(/NextEra Energy/i)) { supplierCode = 'NEE'; } if (!supplierCode) { console.log(text); var err = 'unknown competitive supplier'; return callback(err, null); } Supplier.findOne({supplier_code: supplierCode}, callback); };