Coder Social home page Coder Social logo

currint's People

Contributors

andrewgodwin avatar bar avatar ebmshenfield avatar kevinastone avatar michaelmanganiello-eb avatar renaudvisage avatar vartec avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

currint's Issues

Currency.format_decimal returns incorrect value if divisor is not a power of 10 (e.g. MRO)

currint version: 1.6.1

Currency.format_decimal returns an incorrect value if divisor is set, and it is not a power of 10. Instead of returning a decimal number representing the fractional number of major units, it returns the number of minor units on the right side of the decimal.

This impacts currencies like the Mauritanian ouguiya (MRO), whose minor unit is 1/5th the value of the major unit (1.2 ouguiya (major) = 6 khoum (minor)). For example, currencies['MRO'].format_decimal(6) produces '1.1' (1 ouguiya and half a khoum) instead of '1.2'.

To reproduce:

from currint import currencies

currencies['MRO'].format_decimal(6)
# '-1.1' ๐Ÿ˜ž

# Passing back in the result of `format_decimal` into `major_to_minor_value` raises a value error
# ".1" is intepreted as half a khoum
currencies['MRO'].major_to_minor_value(Decimal('1.1'))
# ValueError: Cannot convert major amount Decimal('1.1') to minor amount; would result in fractional amount of minor unit)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.