I have a coding issue that ChatGPT has not been able to figure out for me, or maybe I'm not asking it the right questions. and was hoping some of the super geniuses here could help.
This is the PHP code for a Code Field named "cb_scope3totalpaymentamount". This field takes the SUM of 3 different Decimal Number fields. These 3 fields are set up as input with the Thousands Separator as a comma and the Decimal Separator as a period. The code works great... with the exception that it will NOT add the decimal places shown in the 3 fields it is adding. This particular example should return 1,704.28, but only shows 1,704.
I have checked that the other 3 fields are indeed Decimal Number fields, and they display the decimal places on screen. What am I missing??
Code:
$totalAmountForScope3 = $user->getInt("cb_scope3depositamount", 0)
+ $user->getInt("cb_scope3additionaldepositamount", 0)
+ $user->getInt("cb_scope3finalpaymentamount", 0);
// Format the total amount with two decimal places
$formattedTotalAmountForScope3 = number_format($totalAmountForScope3, 2, '.', ',');
return $formattedTotalAmountForScope3;