Replace Calculation Type Result By Script (JavaScript)

I have this.

The Calculation Type is (Servicio al Cliente 12%), but it takes the 12% from the subtotal, but that subtotal has the taxes total included, i want to take the 12% from the subtotal of the products without the taxes.
I create this script.
this return the 12% service from the subtotal without the taxes

But i need to replace or modify the script that have by dafault the calculation type that takes the 12% from the subtotal with taxes.
How can i print the value of my script where appears the 12% of the calculation type.
The service calculation is in Payment screen.

Thank you, by the way.

Think your going about it the wrong way, sounds like you need to change the calculation to fixed amount and update with update calculation action using expressons.

Well, i see a methot with action and rules.

I create a new Calculation Type

the action

and its rule

But when i click the button in the payment page (Automatization Command - Button Servicio 12%) nothing happen

Am i using the Call:X method in the right way? or the return value in the script is wrong?

But if i use a value directly it works, so or is the Return value of the Script or is the CALL:X method.

The problem is solve, i create another function

and i put the Call:X method in the rule.

and now it work well

The problem was that i used String values at the begining, the last script works well if i used it in the print template, but in the rule needed a script only for number values.

1 Like

The quote would make the 12 a string, you could have tried putting 12 unquoted or parsing the input as a number in the script.