const {
get_date_header_parser,
parsers_html_wrapper
} = require('./helpers');
const time = require('../../../utils/time');
module.exports = {
q: `from:no-reply@authoritypay.com subject:"Your Gahanna Utility Bill is ready"`,
headers: get_date_header_parser('created_date'),
html: parsers_html_wrapper(function (root) {
const transaction = {};
let values_to_match_remaining = 2;
const trs = root.querySelectorAll('tr');
for (const tr of trs) {
if (tr.childElementCount === 2) {
const [td_label, td_value] = tr.children;
if (td_label.innerText === 'Amount Due') {
transaction.value = td_value.innerText.replace('$', '').replace(',', '') * -1;
if (--values_to_match_remaining === 0) return transaction;
} else if (td_label.innerText === 'Due Date') {
transaction.date = time.iso(time.now(td_value.innerText, 'MM/DD/YYYY'));
if (--values_to_match_remaining === 0) return transaction;
}
}
}
console.error('Gahanna Utilities parser failed to find all data');
return transaction;
})
};