4

I'm working on a site where whenever a contribution is entered into civi with a decimal, it's multipled by 100. It's a lot like this old issue, except the site has not to my knowledge ever been localized and has always used USD.

In the localization settings if I change the decimal value to a comma and the thousands separator to a period and enter a contribution of $5,00 the contribution amount is 5. When I swap it back to the U.S. dollar defaults, entering 5.00 is a contribution amount of 500. I can't replicate on any other site, but I can replicate when loading the civicrm database into a clean codebase and clean wordpress site. I've tested replacing the civicrm_setting table as this seemed like it may have been the culprit but that didn't help. Any clues to where else I could look for something problematic in the database?

Site is on 5.10.3 currently, it's an older install and no one remembers when this problem started.

  • Are you able to inspect the submitted values (using your browser's developer tools, eg Firefox Network Tab > Request Params and see whether the submitted amount value is 5.00 or 500? That would help tell if the issue is clientside (before / during submission) or serverside (during processing). – Chris Burgess Apr 3 at 22:32
  • 1
    CiviCRM has some issues with amounts being multiplied because the decimal sign wasn't applied correctly. In the Netherlands we use the comma (,) as a decimal separator. This bug was fixed and introduced a regression bug which had to do with adding extra zero's. That regression bug is fixed 5.11.0 See lab.civicrm.org/dev/core/issues/407#note_14584 – Jaap Jansma - CiviCooP Apr 4 at 7:11
  • @chris-burgess -- thanks for the tip. In the request params, the value is 1.23, which is the same as what I enter. It then gets stored in the database as 123.00 – m robinson Apr 5 at 0:21
  • I've updated my test site to 5.12 and still seeing the same behavior. Suppose I'll test 5.11 in case it was somehow re-introduced as a regression? But since this site is not localized to use any currency other than USD, and I can't replicate it on a demo or other site with the same configuration, I'm more and more convinced there's something odd in the database. – m robinson Apr 5 at 0:29
5

I managed to solve this.

I looked at what adding a contribution touches in the database. I ruled out differences in the settings table, but then when I looked at civicrm_currency I found that in this database, some characters were not present, even though the encoding would support them. so for instance the civicrm_currency record (6,'INR','₨','356','Indian Rupee') in another database was (6,'INR','','356','Indian Rupee') in this one.

It's not quite clicking with me why the U.S. dollar amounts were being translated -- that record was not different at all. But swapping out the currency table with one from a different site resolved my issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.