Looked through that function. The Days_Late in the DWH_INV_TASK and the Days Late being calculated by this function seem to be two different metrics. The function seems to be calculating the days that a task is late to start. Whereas the column in the DWH_INV_TASK table is documented to be calculating the days that a task is late to finish.
I haven't done a test to determine if that is indeed how it is..
Also, the documentation on that function is as below:
/* ****************************************************************************************************************************
* If there is a Baseline and Start Date is not equal to Baseline Start Date, then Start Date - Baseline Start Date *
* (This calculates days late positive or negative based on baseline). *
* *
* If there is a Baseline and Start Date equals Baseline Start Date and Project Progress (or Task Status) is 'Not Started' *
* and the Start Date is before Today's Date, then Today's Date - Start Date (This calculates days late positive if the *
* project/task isn't late according to the baseline, but it's 'Not Started' and it is has a start date before today's date). *
* *
* If there is no Baseline and Project Progress (or Task Status) is 'Not Started' and the Start Date is before Today's Date, *
* then Today's Date - Start Date (This calculates days late positive if there is not any baseline and the project/task isn't *
* started and it is has a start date before today's date). *
******************************************************************************************************************************/