I've been working on trying to add a "Days Open" column and "Days Overdue" column to the statement advanced PDF template in NetSuite. However, I keep running into issues with handling the date values sourced in from NetSuite records. Trying to manipulate the date values keep resulting in unspecified errors. I'm a bit baffled as to whether or not I can even make this work now.
For example, if I apply the following to the template, it works to format any date and date/time values entered into the template:
<#setting date_format="dd-MM-yyyy">
<#setting datetime_format="dd-MM-yyyy hh:mm a">
However, if I try to work with the values as date/datetime objects, it errors. So trying to do something like the following fails:
<#assign d2 = line.duedate?long>
While this works:
<#assign d1 = .now?date?long>
Also, trying to assume the value is actually a string being passed in and converting to a date/datetime also fails. Doing the following causes an error:
<#assign d2 = line.datecol?date("M/d/yyyy")> // format used by default in NetSuite date output
The other thing that made no sense was checking against the due date and displaying a value only if there was a due date (guard against data display for statement entries that were not actually invoices). So, even if a due date was set and displayed in the completed PDF, the following failed to show correct results:
<#if line.duedate?has_content>${daysoverdue}<#else>empty</#if>
Instead of showing what would be the overdue value (at this time just a static value for testing), it would display "empty". Regardless of whether a due date value was available or not, the entire column for every row would display as though the field were empty. So, I don't know if that's related or not.
I've been poking at this for a while, and haaven't found anything useful searching so far.