integer and numeric numeric custom fields incorrectly assumed to be monetary
Created by: lcdservices
There are a few issues related to integer and numeric custom fields. To reproduce, create an integer and numeric custom field and expose via a profile on a grant application.
- on the form, all numeric fields are converted to a decimal to two places. for example, if you enter "2" and tab away from the field, it will be converted to "2.00". the code affecting this is here: https://github.com/JMAConsulting/biz.jmaconsulting.grantapplications/blob/master/templates/CRM/Grant/Form/Grant/Main.tpl#L102 A simple solution is to move that line into the else clause just prior. that way Int fields are not affected, but Float fields are. However -- I think that still assumes too much, as it forces all Float (numeric) fields to two decimals, which may not be desired.
- when advancing to the Confirm step, all Integer and Numeric fields are converted to a monetary value (two decimals with the currency symbol). this is happening here: https://github.com/JMAConsulting/biz.jmaconsulting.grantapplications/blob/master/CRM/Grant/Form/Grant/Confirm.php#L218 I started to work on a fix, but it requires a fair amount of refactoring, and I'm not sure your ultimate intent. The root of the problem is here: https://github.com/JMAConsulting/biz.jmaconsulting.grantapplications/blob/master/CRM/Grant/Form/Grant/Main.php#L228 ...where all Int/Float/Monetary fields are basically assumed to be monetary and shouldn't be.
Honestly, I would probably just alter the code in Main.php to just condition on Money type fields, then then simplify the code downstream on both the Main.tpl and Confirm.php files. Only Money type fields should be treated as such.