This queue is for tickets about the Data-Money CPAN distribution.

Report information
The Basics
Id:
77921
Status:
resolved
Priority:
Low/Low
Queue:

People
Owner:
ANELSON [...] cpan.org
Requestors:
adamlounds [...] gmail.com
Cc:
AdminCc:

BugTracker
Severity:
Important
Broken in:
0.04
Fixed in:
(no value)



Subject: Does not honour FRAC_DIGITS like math::currency
Some currencies (eg japanese yen) have a non-hundredth currency subunit, however Data::Money assumes that frac_unit is always two. e.g. as_float, while saying it has been jacked from math::currency, has a hardcoded bfround(-2) (math::currency uses the locale frac_unit). So BHD, KWD etc lose the ability to have three decimal places, and yen always have decimal places added even though there are no subunits of yen (rin and sen were removed in 1953) my $dm = Data::Money->new( value => '1.234', code => 'JPY' ); is( $dm->as_float, '1', 'yen have no subunits' ); fails when it should pass. Similarly, my $dm = Data::Money->new( value => '1.234', code => 'BHD' ); is( $dm->as_float, '1.234', 'Bahraini Dinar have one thousand fils' );
This should be fixed in 0.05, which I just sent to CPAN. If you want to grab it from github, it's at holophrastic/data-money (or gphat/data-money, once I sync our trees back up). Thanks for the report, and please let me know if you have any other issues! On Wed Jun 20 07:49:41 2012, adamlounds@gmail.com wrote:
Show quoted text
> Some currencies (eg japanese yen) have a non-hundredth currency > subunit, however Data::Money assumes that frac_unit is always two. > > e.g. as_float, while saying it has been jacked from math::currency, > has a hardcoded > bfround(-2) (math::currency uses the locale frac_unit). So BHD, KWD > etc lose the ability to > have three decimal places, and yen always have decimal places added > even though there are > no subunits of yen (rin and sen were removed in 1953) > > my $dm = Data::Money->new( value => '1.234', code => 'JPY' ); > is( $dm->as_float, '1', 'yen have no subunits' ); > > fails when it should pass. > > Similarly, > my $dm = Data::Money->new( value => '1.234', code => 'BHD' ); > is( $dm->as_float, '1.234', 'Bahraini Dinar have one thousand fils' );
From: adamlounds@gmail.com
wow, thanks for the quick fix :-)


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.