# WordPress.org

## Calculated Fields Form[resolved] Dependent calculated field does not always show value (3 posts)

1. carsharezach
Member
Posted 1 year ago #

Hi there,

I'm having an odd issue. Most of the time, but not all of the time, the Total + Tax calculated field shows no value if the Free Wheelin' rate plan is selected on the calculator found here: http://carshare.org/trip-cost-calculator/ The really odd thing about this is that the Total + Tax is not directly dependent on the Rate Plan. Total + Tax is dependent on Subtotal and Tax Jurisdiction. Subtotal is dependent on the Rate Plan, Hours, and Time. Why would selecting Free Wheelin' Rate Plan cause the Total + Tax not to display sometimes and work fine others?

The code in the Subtotal Set Equation box is exactly as follows:
(function(){
var days=floor((fieldname3/24));
var hours=0;
var subtotal;

if (fieldname5=="Free Wheelin")
{
if (floor((fieldname3-days*24)/(39/4.5))==0) hours=fieldname3%24;
else days=days+1;
if (fieldname4<=50) subtotal=fieldname4*.33+days*39+hours*4.50;
else subtotal=50*.33+(fieldname4-50)*.2+days*39+hours*4.50;
}

if (fieldname5=="Peace of Mind")
{
if (floor((fieldname3-days*24)/(49/6.95))==0) hours=fieldname3%24;
else days=days+1;
if (fieldname4<=50) subtotal=fieldname4*.38+days*49+hours*6.95;
else subtotal=50*.38+(fieldname4-50)*.25+days*49+hours*6.95;
}

return prec(subtotal,2);

})();

The code in the Total + Tax Equation box is exactly as follows:

prec(fieldname1*fieldname6,2)

2. codepeople
Member
Plugin Author

Posted 1 year ago #

Hi,

The structure of your equation does not allow to optimize it by the plugin. So, to solve the issue you only need to select the field for Total+Tax in the form, and uncheck the attribute: "Optimize Form Equations"

Best regards.

3. carsharezach
Member
Posted 1 year ago #

That seemed to do the trick! Thank you for you help and your quick response!

This topic has been closed to new replies.