3 Replies Latest reply on Apr 27, 2017 1:52 AM by leont55235345

    I trying to build a invoice template, how do I stack "if 0" actions? Or can you even do that?

    leont55235345

      I’m building an invoice template.

      I have an “Hr” column and a “Cost” column.

      The actions I want the “Cost” Column to perform are as followed:

      (Hr = number of hours work, 18 = Hourly rates)

      • “Hr” * 18 =?
      • If the return is “0” OR no calculation, show blank.
      • If “0” “0” OR no calculation, allow for manual entry of cost.
      • Allow entry, show, and calculate (+ and -) of positive and negative numbers.
      • Show negative numbers in “Red” and show format with -. (-$100) for prints.

       

      Current Scripting for Hr1-14:

      Calculate>Simplified Filed Notation.

      Hr*18

       

      Validate>Run Custom Validation script.

      if (event.value<0){event.target.textColor=color.red}

      else{event.target.textColor=color.black}

       

      if (event.value ==0) event.value ='';

      else event.value = defalt;

       

      (Note: Above Script was found on Adobe Forums)

       

       

      At the end of the “cost” column, they are added or subtracted to show a “Grant Total.”

      • The “Grand Total” adds up but does not subtract changes, update, or is wrong.
      • I need “Grand Total” to Add and Subtract with changes and Subtract discounts.

       

      Current Scripting for Hr1-14:

      Calculate>Value is the>Sum (+).

      Cost1, Cost2, Cost3, Cost4, Cost5, Cost6, Cost7, Cost8, Cost9, Cost10, Cost11, Cost12, Cost13, Cost14,

       

      I try to make it as easy as possible to understand what I am working on and what the aim is, however, if this is still unclear I can email you the file as you see what is going on.

        • 1. Re: I trying to build a invoice template, how do I stack "if 0" actions? Or can you even do that?
          gkaiseril MVP & Adobe Community Professional

          Have opened the Acrobat JavaScript console to see there are any errors?

           

          I would change:

           

          if (event.value ==0) event.value ='';

          else event.value = defalt;

           

          to:

           

          if (event.value ==0) event.value ='';

          • 2. Re: I trying to build a invoice template, how do I stack "if 0" actions? Or can you even do that?
            leont55235345 Level 1

            Your new script helped the with the "Grand Total" calculations.

             

            However, only when the "Hr" box is "empty". 

            With a "0" value or the "Hr" is reduced, the "Gand Total" will be wrong. 

            To correct the "Grand Total", you must go back and enter a "0" then go back and delete the "0" for the "Hr" box.

             

            Also, the display of negative values is deactivated.

            Is a when to say, "if the value is less than "0" show in red with a negative sign?

            Or am I asking too much of this grogram?

            • 3. Re: I trying to build a invoice template, how do I stack "if 0" actions? Or can you even do that?
              leont55235345 Level 1

              KO! So I kinda gave up on having only one "Cost" column that does everything. So I opted for two. "Cost1" and "cost2" and "Sub1" and "Sub2". This also ended up simplifying the coding too. 

              Below it a list of the code I used in each section as well as an image to help you understand the flow.

               

              Fields using:     Rate, Qty, Hr: , Cost1 , Cost2, Sub Hr, Sub1, Sub2, Grand Total.

              Command:       If the value is empty / "0", show as empty.

              Script used:

              ( Validations > Custom )

              if (event.value ==0)

                         event.value ='';

               

              Fields using:     Hr: , Cost1 , Cost2, Sub Hr, Sub1, Sub2, Grand Total.

              Command:       If the greater than "0", show as Black. If the less than "0", show as Red "-" .

              Script used:

              ( Validations > Custom )

              if (event.value<0)

                  {event.target.textColor=color.red}

              else{event.target.textColor=color.black}

               

              Fields using:     Rate.

              Command:      (Each row is marked as Column and row#)  multiply the hourly rate by the number of hours worked = ? in each row.

              Script used:

              ( Calculations > Simplified )

              Hr# * Rate

               

              Fields using:     Grand Total.

              Command:       Show      the full cost of everything and remove any discounts,

              Script used:

              ( Calculations > Simplified )

              Sub1+Sub2

               

               Leon Invoice temp diagram.jpg