CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • Monetary value display setting not producing expected results
Pages: [1]

Author Topic: Monetary value display setting not producing expected results  (Read 4349 times)

quattrosoli

  • I’m new here
  • *
  • Posts: 5
  • Karma: 1
Monetary value display setting not producing expected results
November 13, 2009, 06:58:37 pm
My CiviCRM installation on a local WAMP server shows all U.S. dollar currency amounts differently from how they are shown on the demo site (http://drupal.demo.civicrm.org).  No monetary display includes the comma that delimits thousands, and some displays show more than 2 places to the right of the decimal.

Here's an example.  If I make a query that should yield a dollar amount display such as $20,000.00 (including the comma that delineates the thousands place), what shows up is $20000.00 without the comma.   Moreover, if that number is on a contact contribution page, the contact contribution average will appear as $20000.0000 (or as many zeros to the right of the decimal as space allows).

My localization settings are identical to those in the demo site, with the monetary amount display set at the default of "%c %a"  -- which seems to be working fine -- and the monetary value display at its default of "%!i".  While troubleshooting I can change the monetary value display field from "%!i" to anything else, or even delete it altogether, but no change manifests itself in the way CiviCRM displays the monetary values. 

I am using CiviCRM 3.0 in a Drupal 6.x installation.  Any ideas what the problem could be?

Thanks in advance.

Piotr Szotkowski

  • I live on this forum
  • *****
  • Posts: 1497
  • Karma: 57
Re: Monetary value display setting not producing expected results
November 17, 2009, 02:00:00 am
When formatting the monetary value, we offload the work to the underlying operating system’s locale engine, only hinting it about what locale it should use for monetary formatting.

First, check what’s the monetary locale in your Administer → Configure → Global Settings → Localization → Monetary Locale. If that’s set to English (USA), then most probably your underlying system does not have en_US (or en) monetary locale.

In POSIX systems (Linux/Unix/OS X etc.), locale -a should show the available locales; unfortunately I’m not sure how it’s done under Windows.
If you found the above helpful, please consider helping us in return – you can even steer CiviCRM’s future and help us extend CiviCRM in ways useful to you.

quattrosoli

  • I’m new here
  • *
  • Posts: 5
  • Karma: 1
Re: Monetary value display setting not producing expected results
November 19, 2009, 03:25:53 pm
Thanks for the reply, though I'm not sure I fully understand the nature or location of the locale engine.  That is, the CiviCRM settings are correct in the localization page, which would imply that my Windows system (which is XP) does not have an en_US monetary locale. 

Of course, Windows has to have some sort of mechanism to display language, currency, and other localized data on my Windows machine (in every other program save CiviCRM).  Just to be sure, I checked the XP Control Panel settings.  One of them is Regional and Language Options, and a sub-setting shows that my system is set to "English (United States)."  The sample currency format associated with this option displays monetary values in the normal way (with a comma separating the thousands place).

So as far as I can tell my Windows system is set for the appropriate locale.  What might be the difference between the locale engine CiviCRM relies upon and the "engine" Windows uses?

Thanks again for your help with this issue.

quattrosoli

  • I’m new here
  • *
  • Posts: 5
  • Karma: 1
Re: Monetary value display setting not producing expected results
November 20, 2009, 06:20:10 pm
I transferred my CiviCRM/Drupal installation from WAMP on a local Windows machine to a DV Linux server and, voila!, the display irregularity disappeared.  So the source of the problem certainly appears to be the lack of an appropriate monetary locale in Windows, although there could be something amiss with WAMP, too.

My database cannot reside permanently on an external server, unfortunately, so I will have to bring it back to a local machine.  My next experiment will be on a local Linux machine with LAMP.  When I get some results (which will not be soon, however) I'll share them on this forum.

Piotr Szotkowski

  • I live on this forum
  • *****
  • Posts: 1497
  • Karma: 57
Re: Monetary value display setting not producing expected results
November 23, 2009, 01:21:54 am
Quote from: quattrosoli on November 20, 2009, 06:20:10 pm
I transferred my CiviCRM/Drupal installation from WAMP on a local Windows machine to a DV Linux server and, voila!, the display irregularity disappeared.  So the source of the problem certainly appears to be the lack of an appropriate monetary locale in Windows, although there could be something amiss with WAMP, too.

That’s what I thought: either lack of POSIX locale support on Windows or discrepancies between Linux and Windows. It’s a bit hard to test on our end, as we don’t have a development Windows box.

Quote
My database cannot reside permanently on an external server, unfortunately, so I will have to bring it back to a local machine.  My next experiment will be on a local Linux machine with LAMP.  When I get some results (which will not be soon, however) I'll share them on this forum.

You can also try tweaking the setlocale() calls in CRM/Core/BAO/Setting.php, CRM/Core/Config/Variables.php and CRM/Utils/Rule.php
If you found the above helpful, please consider helping us in return – you can even steer CiviCRM’s future and help us extend CiviCRM in ways useful to you.

quattrosoli

  • I’m new here
  • *
  • Posts: 5
  • Karma: 1
Re: Monetary value display setting not producing expected results
November 23, 2009, 06:54:47 pm
I adjusted Setting.php according to the PHP manual ["Note: On Windows, setlocale(LC_ALL, '') sets the locale names from the system's regional/language settings (accessible via Control Panel). "]  Both of the other files already contained "setlocale(LC_ALL)". 

Unfortunately the display problem still persists, although it is possible that I am not tweaking this call appropriately. 

Piotr Szotkowski

  • I live on this forum
  • *****
  • Posts: 1497
  • Karma: 57
Re: Monetary value display setting not producing expected results
November 24, 2009, 02:14:45 am
Hmm. Can you check whether on your Windows install CiviCRM goes at all through the money_format() call in CRM/Utils/Money.php?
If you found the above helpful, please consider helping us in return – you can even steer CiviCRM’s future and help us extend CiviCRM in ways useful to you.

quattrosoli

  • I’m new here
  • *
  • Posts: 5
  • Karma: 1
Re: Monetary value display setting not producing expected results
November 28, 2009, 05:10:39 pm
You're beyond my pay grade.  How would I check that call?

Piotr Szotkowski

  • I live on this forum
  • *****
  • Posts: 1497
  • Karma: 57
Re: Monetary value display setting not producing expected results
November 30, 2009, 05:47:54 am
The easiest way is to edit the CRM/Utils/Money.php file, go to the 89th line (the one with the money_format() call) and add something to the tune of

Code: [Select]
CRM_Core_Error::debug('$amount', $amount);

right after it (before the closing curly brace of the if block). If you then refresh any page which displays a monetary amount, you’ll either see the $amount variable printed out or see no difference (in which case it means that on your Windows setup this block is not executed because the money_format() function does not exist – and it’s the function that calls the underlying operating system’s locale).
If you found the above helpful, please consider helping us in return – you can even steer CiviCRM’s future and help us extend CiviCRM in ways useful to you.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • Monetary value display setting not producing expected results

This forum was archived on 2017-11-26.