bill payment days open bookmarklet

by Gerald Gillespie

JavaScript

(function($) {
  var today = new Date();
  var foundDates = 0;
  if (!/vendpymts.nl$/.test(window.location.pathname)) {
    if (confirm('you are not on bill payments screen. Would you like to go there?')) {
      window.location('https://system.na1.netsuite.com/app/accounting/transactions/vendpymts.nl?whence=');
    }
  }

  $('tr.uir-list-row-tr').each(
    function(r) {
      var $row = $(this);
      $row.children('td').last().each(function(r) {
        var $cell = $(this);
        if ((parseInt($cell.text()) + '') == $cell.text()) {
          return false;
        }
        var trandate = new Date($cell.text());
        var timeinmilisec = today.getTime() - trandate.getTime();
        if (trandate < today) {
          $cell.text(Math.floor(timeinmilisec / (1000 * 60 * 60 * 24)));
          foundDates++;
        }
      })

    })

  alert('Converted ' + foundDates + ' dates');
})(jQuery)