Money CCK field

published on August 9, 2007

For one of the projects I’m currently working on, we needed to be able to store monetary values. This seems utterly simple at first, but there are many details that need attention.

The obvious one: multiple currencies. Luckily, this was easily solved by using the excellent Currency module, which includes a Currency API module, written by Khalid Baheyeldin of 2BITS. The tricky part is the ability to read from and write to different number notations (and thus store the amount notation-independently). The number one thousand for example is written like 1,000 in the U.S., but it’s written like 1.000 in Belgium. In the U.S. they use a dot as the decimal separator, in Europe a comma.
The default decimal separator is the comma and the default digit group separator is the space, this is conform with ISO 31-0. A function to parse numbers (the most difficult part) is absent in PHP, one to format numbers however, is present.

You can configure the representation that should be used in the CCK widget settings. You can choose anything: a hyphen, a dash, a letter, whatever you please.

I will probably add a function to detect the used separators, which is very useful when importing data from a spreadsheet.

Comments

Rustin Phares's picture

Rustin Phares

I’ve installed the money module and created my field however, it does not show in the view.

Running the latest version of Drupal 5.3, along with the latest builds of CCK and CCK Money plus the Currency module for 5.x dated October 30th, 2007.

Any suggestions or ideas would be greatly appreciated, much thanks!

Wim Leers's picture

Wim Leers

Please post this in the issue queue, that’s the appropriate place for issues ;) :)

Rustin's picture

Rustin

No problem ;) Any direction you have on such extension with comment and/or contact fields would be like a bowl of lucky charms.

In any event, many thanks for everything :))

Bakr's picture

Dear Leers,

1) I wish you could make it for drupal 6

2) To help out with multiple selection of terms, why don’t you add an extra emppty select-list field, where we can throw the selected terms their (and a draq&drop to a small trash icon) This would be a great replacement for the basic taxonomy selection mechanism which is not effective with large taxonomies. (thousands)

3) why not (i wish) implment more visual selects, like the ones at http://www.activewidgets.com/grid/

I would make big sense for it in the following scenario:

  • I have 3000+ heirachical terms
  • Your module should a some theming rules mechanism (e.g. add-rule: {highlight/iconize that certain select element where a site-wide/user-specifc node has ever consumed that term})
  • This will help me out know where am I interms of my coverage of terms. and I can easily spot the ones(terms) which are out of my scope

I want to navigate easilty

Cheers.

Wim Leers's picture

Wim Leers

You can obviously just adress me with my first name, i.e. Wim. ;) :)

1) That will happen, of course. 2) That’s under development. 3) I’m satisfied with the current result. If you can describe what you specifically want, please create a new issue.

  • Having 3000 terms to select from will be made much easier as soon as #2 is ready.
  • That would cause more confusion than it would do good.