Sometimes you require a custom Rounding function to meet your needs. For example, you may very well want to track employee hours, but need to be consistent and round each decimal entries.
The script below allows you to round in increments of .25 so if you were entering hours each .25 = 15 minutes on the hour.
float Calculations.FrankUp(float Hours)
{
HI = input.Hours.toLong();
Gap = (input.Hours - HI).round(2);
if ((Gap <= 0.25) && (Gap > 0.0))
{
return (HI + 0.25).round(2);
}
else if ((Gap <= 0.5) && (Gap > 0.25))
{
return (HI + 0.5).round(2);
}
else if ((Gap <= 0.75) && (Gap > 0.5))
{
return (HI + 0.75).round(2);
}
else if (Gap > 0.75)
{
return (HI + 1.0).round(2);
}
else if (Gap == 0)
{
return (HI + 0.0);
}
return Gap;
}
No comments:
Post a Comment