Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-15835

Event registrations total amounts with decimals stored incorrectly when CiviCRM thousands separator is a dot

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Trivial
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.5.5
    • Fix Version/s: 4.6
    • Component/s: CiviContribute, CiviEvent
    • Labels:
      None
    • Documentation Required?:
      None

      Description

      This occurs only if CiviCRM is set with thousands separator as a dot, a normal configuration in spanish and catalan installations.

      When a total amount for an event contains a decimal value and we submit the registration, then the amount is stored incorrectly in the database. For example:

      If the total amount is 150.50 then is stored as 1505 in the entity_financial_trxn table.

      I inspect as far I know and I found that the problem comes from the cleanMoney function in CRM/Utils/Rule.php, specifically the following lines:

      // ugly fix for CRM-6391: do not drop the thousand separator if
      // it looks like it’s separating decimal part (because a given
      // value undergoes a second cleanMoney() call, for example)

      if ($mon_thousands_sep != '.' or substr($value, -3, 1) != '.')

      { $value = str_replace($mon_thousands_sep, '', $value); }

      The input value of $value at the entry of this lines is 105.5 and the output value is 1505.

      The backtrace to this point is

      CRM/Event/Form/Participant.php >
      1045: CRM_Price_BAO_PriceSet::processAmount($this->_values['fee'],
      CRM/Price/BAO/PriceSet.php >
      785: CRM_Price_BAO_LineItem::format($id, $params, $field, $lineItem);
      CRM/Price/BAO/LineItem.php >
      260: $price = CRM_Utils_Rule::cleanMoney($price);

      From there I no longer dared to change anything for fear it may affect other functionalities of the CiviCRM.

      Someone may end up giving a push to fix the bug?

        Attachments

          Activity

            People

            • Assignee:
              atif.shaikh Atif Shaikh
              Reporter:
              francescbassas Francesc Bassas i Bullich
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: