manwar / Data-Money

Money/currency with formatting and overloading.
Artistic License 2.0
4 stars 3 forks source link

Feature request: constructor with the amount in pennies #11

Open DrHyde opened 3 years ago

DrHyde commented 3 years ago

It would be useful to be able to create a Data::Money object, passing the value in pennies, and for Data::Money to do the hard work of figuring out whether there are 100 or 1000 pennies in the currency unit. For example, the Bahrain Dinar consists 1000 fils, so code that accepts an amount in pennies from elsewhere and naively assumes it can just divide by 100 to get a suitable value is incorrect.

DrHyde commented 3 years ago

The new constructor should also cope with currencies which don't have sub-units such as JPY

duffee commented 3 years ago

The rationale for this feature is that the payments company, Stripe, works in sub-units of the currency which presents interesting edge cases for the currencies where 100 sub-units != unit (such as JPY, ISK, KRW, CLP and a handful of others)