4 Replies Latest reply on May 4, 2016 8:05 AM by ChadL

    Decision Calculation

    ChadL Apprentice

      I'm going through a process of requesting a JV (Journal Voucher) and closing out the JV transaction, which will allow a Request to be closed.  I have setup a collection called Process JV for collecting the dollar amounts entered for a JV.  I also have another collection called JV Completed for collection the dollar amounts of the entered completed JV's.

       

      I then have an attribute of Data Type Decimal in Request called JV Total with an After Read calculation to add up all the JVs requested for a particular Request.  I then have an attribute of Data Type Decimal in Request called JV Requested Total with an After Read calculation to add up all the completed JV's that we have closed out.  Finally, I have an attribute of Data Type Decimal in Request called JV Balance with an After Read calculation subtracting the JV Requested Total from the JV Total to give me the current balance.  Both work great and give me the correct numbers needed during testing of the calculation and on the window, which I will be describing below.

       

      In my Request process, I have the Process JV action and window to enter in the JV needed.  I then have a JV Completed action and window to ask how much was completed.  In this JV Completed window, I have the JV Balance attribute showing the correct current balance.  After the completion of this process, I have a Decision TRYING to calculate if there is still a balance left.  If so, leave the action JV Completed available.  If the balance is 0, then don't allow the JV Completed action to be an available action.  Only the Process JV action should be available if the balance is 0.

       

      The Decision calculation is what I'm having some issues with.  Maybe it's the thought process behind how I have the above setup, which is causing the Decision calculation not to run properly, or it's a limitation in the software I haven't discovered or come across yet.  I going to assume the prior, and hope someone can help me out.  =)

       

      Again, I can run the Decision calculation using the Test Calculation button and I get the correct results, but any type of calculation I enter for the Decision will not move the process forward correctly.

       

      JV Total

      import System

      static def GetAttributeValue(Request):

        JVTotal = 0.00

        for JV in Request._ProcessJVCol:

          JVTotal = JVTotal + JV._JVTotal

        return JVTotal

       

       

      JV Requested Total

      import System

      static def GetAttributeValue(Request):

        JVTotal = 0.00

        for JV in Request._JVCompletedCol:

          JVTotal = JVTotal + JV._JVTotal

        return JVTotal

       

       

      JV Balance

      import System

      static def GetAttributeValue(Request):

        Value = Request._JVTotal - Request._JVRequestedTotal

        return Value

       

       

      JV Balance Zero? (Decision Calculation in Request Process)

      ???????

        • 1. Re: Decision Calculation
          elizabethcombrink Expert

          What calculation have you tried?

           

          I would suggest rather then calculating the balance as you have done using the 2 previously calculated fields, you calculate the balance for your decision without the use of the previous calculated fields,

           

          So calculate the JVTotal and JVTotalCompleted within the calculation itself, and subtract those

           

           

          import System

          static def GetAttributeValue(Request):

           

            JVTotal = 0.00

            for JV in Request._ProcessJVCol:

              JVTotal = JVTotal + JV._JVTotal

           

           

          JVTotalCompleted = 0.00

            for JV in Request._JVCompletedCol:

              JVTotalCompleted = JVTotalCompleted+ JV._JVTotal

           

          Value = JVTotal - JVTotalCompleted

           

          return Value

           

          - please note Ive paid no attention to the correct indenting in the above

          • 2. Re: Decision Calculation
            ChadL Apprentice

            I only need to know IF there is a balance.  I have tried the below calculation (similar to what you suggested), but it gives me the following error:

             

            There has been an unexpected error. Click Continue to return to the previous page.

            There is an error in XML document (1, 1).

             

            When testing the calculation, it gives me the correct results on the two Requests I perform the test against (one with a Balance and one without).  Maybe a Decision Calculation cannot be used in this fashion.

             

            import System

            static def GetAttributeValue(Request):

                            Value = true

                            JVTotal = 0.00

                            JVCompleted = 0.00

                            for JV1 in Request._ProcessJVCol:

                                            JVTotal = JVTotal + JV1._JVTotal

                            for JV2 in Request._JVCompletedCol:

                                            JVCompleted = JVCompleted + JV2._JVTotal

                            if JVTotal - JVCompleted == 0:

                                            Value = false

                            return Value

             

            • 3. Re: Decision Calculation
              elizabethcombrink Expert

              You are mixing decimals and integers - BOO don't like that

               

              try

              if JVTotal - JVCompleted == 0.00: (instead of 0)

               

              You can do this as  condition/ precondition. Also, if you look into the details of the error message you will probably see more clues as to what is wrong.

              • 4. Re: Decision Calculation
                ChadL Apprentice

                I was just going to try that.  =)  The below calculation works!  Thanks!!!

                 

                 

                 

                import System

                static def GetAttributeValue(Request):

                     Value = true

                     JVTotal = 0.00

                     JVCompleted = 0.00

                     for JV1 in Request._ProcessJVCol:

                         JVTotal = JVTotal + JV1._JVTotal

                     for JV2 in Request._JVCompletedCol:

                         JVCompleted = JVCompleted + JV2._JVTotal

                     if JVTotal - JVCompleted == 0.00:

                     Value = false

                return Value