3 Replies Latest reply: Jun 16, 2009 5:38 AM by pguerett RSS

    Calculating/rounding numeric fields--Payperiod and Hourly

    Hollywoodstarrs Community Member

      Problem #1

      I have 4 objects that are linked together. Field (1) Other-dropdown (2) Salary-numericfield  (3) payPeriod-numericfield  (4) perHour-numericfield

      -the Salary-numericfield uses the Other selection to calculate the Hourly pay & Pay period amounts.

      • if ( Other.rawValue == "Normal" )

                {

                     payPeriod.rawValue = (salary.rawValue) / (26);

                     perHour.rawValue = (salary.rawValue) / (2080);

                }

       

      Now you know the basic outline of what I am trying to do.  My question is this; How do I get the payPeriod to populate based on the perHour displayed value?  When I say "face value" I mean this; the perHour numeric field automatically populates an answer that automatically rounds the perHour field displayed number to the .00 value if the answer needs it. example 30.038 ----> 30.04, but holds the original rawValue for other calculations,   now I need to take 30.04 and populate the payPeriod numerfield (30.04 * 80) not (30.038 * 80) which keeps happening. The Java Script above shows how I originally set this up but do to the rounding it does not always agree. I am open to restructuring the code. I have tried functions, and calculate event for the perHour field ie.. payPeriod.rawValue = (perHour.rawValue * 80), which doesnt work.  I have another example of the rounding problem I am having below.

      ( 30.04 * 2080) = $62,483.20  and (30.038 * 2080) = $62,479.04.  Any immediate answer is much appreciated.

       

      Problem #2

      I have a similar set up to the above code but with a new multiple. This multiple is a percentage numeric field called FTE. I will present the set up for your understanding. My question is; I need the FTE value to dictate the calucation that will occur and I would like to understand if this is correct? Also, with the solution to Problem #1, will I have to change the solution for Problem #2?

       

      • if (Other.rawValue == "Normal" )

           {

                var total = ( FTE.rawValue)

                {

                     if (total > .24 )

                          payPeriod.rawValue = (salary.rawValue) / (26) * (FTE.rawValue);

                          perHour.rawValue = (salary.rawValue) / (2080) * (FTE.rawValue);

                     if (total < .25 )

                          payPeriod.rawValue = (salary.rawValue) / (26);

                          perHour.rawValue = (salary.rawValue) / (2080);

                }

           }