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

Monetary amount multiplied by 100 whenever membership data is saved

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Critical
    • Resolution: Fixed/Completed
    • Affects Version/s: 2.1.2
    • Fix Version/s: 2.2.9, 3.0
    • Component/s: CiviMember
    • Labels:
      None

      Description

      We have a custom field of type "money" in our membership record, representing the anual member fee. Whenever the record is saved, this amount gets multiplied by 100. The reason seems to be a localization issue.

      We are running CiviCRM with the German locale. In Germany, "," is the decimal separator, and "." is the "thousands" marker – just the other way around as in englisch. If I enter the amount as "12", it gets shown as "12.00" on next load, which is incorrect – it should be "12,00". This wouldn't be so bad in itself, but when i save the record, even without changing anything, next time it's shown as "1200,00". It seems that, when parsing the number back in, CiviCRM uses the correct locale info, and considers the "." as a (misplaced) thousands-marker and ignores it – which turns 12.00 into 1200.

      I have not checked if this error also happens with other numeric fields (ints). I also havn't checked if it happens when "money" is used elsewhere (though i expect it would).

      There are several options for fixing this:
      a) use the same locale info for rendering and parsing. the is the "correct" way.
      b) treat the last "," or "." as a decimal separator, unless there are more than n digits after it, where n is the precision of money amounts of the current locale. that's lenient, but may lead to input errors.
      c) reject all input that contains non-digit chars except the correct decimal separator. that's the safe way.

        Attachments

          Activity

            People

            • Assignee:
              shot Piotr Szotkowski
              Reporter:
              brightbyte Daniel Kinzler
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: