docparse-supplier-nge
Version:
process ngrid electric utility bill data for use in the docparse system
24 lines (23 loc) • 702 B
JavaScript
module.exports = function (data, cb) {
if (!cb) {
cb = data;
return cb('you must give a supplierCode as the first parameter');
}
var getDistinct = data.getDistinct;
if (!getDistinct) {
getDistinct = require('docparse-get-distinct-bill-field');
}
var distinctData = {
queryParams: { supplierCode: data.supplierCode},
field: 'account_number'
};
getDistinct(distinctData, function (err, reply) {
if (err) { return cb(err); }
if (!reply || reply.length === 0) {
return cb('no account numbers found to try and match to bill ocr text');
}
// transform from objects into an array
var accountNumbers = reply;
cb(null, accountNumbers);
});
};