Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Minor
-
Resolution: Fixed/Completed
-
Affects Version/s: 4.0.5
-
Fix Version/s: 4.1.0
-
Component/s: None
-
Labels:None
Description
While tracking http://drupal.org/node/1248006 I have encountered the following issues with custom money fields with select options:
- Entering a value of "0" or "0.00" for an option will get stored in the DB as "0" (should be "0.00").
- CiviCRM can't tell the difference between null value and the 0 option, and will be unable to distinguish between them when selecting or retrieving options.
- Entering a value larger than 999.99, such as 20000.00 will get stored in the db as "20,000.00" (should be "20000.00")
- Attempting to modify any value larger than 999.99 will result in a fatal error (even when attempting to change it to something less than 999.99). "Sorry. A non-recoverable error has occurred. One of parameters (value: 20,000.00) is not of the type Money."
- Attempting to unset a money field by passing an empty string to CRM_Core_BAO_CustomValueTable::setValues() also results in a core error: "One of parameters (value: ) is not of the type Money." Passing the string 'null' produces the same error (but my preference would be for an empty string to work, since 'null' feels like such a hack).
Possibly unrelated, but I've also noticed that money values are represented incorrectly by CiviCRM Views Integration, and for example a contribution total_amount of 50.46 will be displayed as 50.4599999999, while a total_amount of 50.00 will be displayed as 50 (no trailing zeroes). So I believe the value is not being passed through number_format() as it probably should (or simply displaying the money string "as is" from the db with no conversion would also be an improvement).