Changing the value to negative I have a content type of invoice. This also has a drop down list (list text) to let the user pick one of three types - receivable , payable and proforma.

I also have it so I'm getting the amount, vat and total of the invoice.

However, what I need to do is change the value of the invoice amount, vat, and total when the user picks payable from the drop down menu to a negative value. For example, I fill out the invoice make it payable and I enter 2000 in the amount, 230 in vat and 2300 in total fields. I need these values to become negative when I run aggregator plus on them so instead of adding these numbers it subtracts them instead.

I was wondering if I can do this using rules, or do I create a new module to do this, or if I add a function to the template.php file. Any ideas of what is easiest and best
In my opinion, the most elegant solution would be to leave the original values and to define how you operate with them (adding, substracting, etc.) at the Aggregator Plus level, but I am not familiar with that module, and I don't know how easy it would be to extend it.

If you want to modify the value of these fields before saving the node, there are at least two possibilities I can think of:


Using Rules (it involves creating some custom PHP code). The following example (using increment instead of changing the sign) can give you a hint: https://www.drupal.org/node/1389074
Creating a custom module and implementing hook_node_presave(), in order to modify the fields before they are written to the database.


Hope that helps,