Skip to main content
Participant
April 25, 2017
Question

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

  • April 25, 2017
  • 2 replies
  • 826 views

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.

This topic has been closed for replies.

2 replies

Participant
April 27, 2017

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

Inspiring
April 25, 2017

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 ='';

Participant
April 25, 2017

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?