tags:

views:

334

answers:

1

Hello, I'm not much familiar to Java Currency type, and how it being used in Grails. Though, I'm yet to use it, I saw a tag <g:currencySelect> to use in the views. So, how do I represent it in the domain class.

class Money {
BigDecimal value
Currency currency
....
}

or is there a better sol, which compares diff money objects, format according to the locale ( ',' in EU for separator etc)

thanks in advance. Babu.

+1  A: 

You might want to take a look a the Currencies plugin. It provides a Money class for holding monetary amounts of differing currencies. They can be embedded into domain classes like so:

class CustomerTransaction {
    Date date = new Date()
    Money amount

    static embedded = ['money']
}
ataylor
Looks interesting. How would a domain class using Money look and what's the underlying column type?
armandino
thanks for both your comments.. the currency plugin gave a idea about how to implement myself..
bsreekanth