Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

New Here ,
Apr 25, 2017 Apr 25, 2017

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.

TOPICS
Acrobat SDK and JavaScript
785
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 25, 2017 Apr 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 ='';

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 25, 2017 Apr 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 27, 2017 Apr 27, 2017
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines