Calc Builder Support

Calc Builder support
Public write access is disabled. Please login

Conditional Output - put negative numbers in brackets 15.01.2019 18:02


I'm doing a calculator for US visitors.
In their accounting instead of writing negative number as caclulated output they are putting it in brackets
so if i have this setup:
$field1 - number field
$field2 - number field
$field3 - inline result
and set this code: $field3 = $field1 - $field2 which results with for example 2 - 4 = -2
how to set up things so that instead of -2 it displays: (2) - number 2 in brackets

So I need a way to display all negative numbers in brackets, without minus in a front.
Positive numbers should be displayed without brackets.

Is this possible?
I tried to put my own if else code but it didn't work.
Maybe I need to use different syntax?

I found similar thread but didn't want to necro it:


Re: Conditional Output - put negative numbers in brackets 15.01.2019 18:15

if you have calcbuilder extended you could add this format directly at the excel sheet, if you feel more comfortable there than handling php code. Otherwise, you can format the code at the end of the php section (and setting the excel configuration to launch before the php code), something like this would do the work:

$field3=$field3*-1; //get rid of minus sign
$field3="(".$field3.")"; //enclose in brakets

Hope this helps, regards
Moonsoft Team
Are you satisfied with our products/services/support?
Please help us to keep improving, add a review at  joomla extensions site and  magento connect

Our clients' feedback