An Elixir library implementing the Fowler Money pattern for safe, precise, and fun monetary operations.
Money is an Elixir library that provides a safe and precise way to represent and manipulate monetary values. It implements Martin Fowler's Money pattern using integer amounts to avoid floating-point rounding errors, ensuring accuracy in financial calculations. The library includes currency handling, database serialization via Ecto, and flexible formatting options.
Elixir developers building applications that handle monetary transactions, financial data, or e-commerce systems where precision is critical.
Developers choose Money for its robust implementation of the Fowler Money pattern, seamless Ecto integration for multiple database strategies, and its functional approach that eliminates common currency representation errors.
Elixir library for working with Money safer, easier, and fun... Is an interpretation of the Fowler's Money pattern in fun.prog.
Uses integer amounts to eliminate floating-point rounding errors, ensuring accurate calculations as demonstrated in Money.add and Money.multiply examples.
Handles ISO 4217 currencies and allows custom definitions like cryptocurrencies, with configurable symbols and exponents via custom_currencies configuration.
Provides multiple Ecto types (Amount, Composite, Map) for different database strategies, including PostgreSQL composite types and JSON serialization, detailed in the README.
Offers extensive configuration for string representation, with options for separators, delimiters, and symbol placement through Money.to_string and global settings.
Ecto changesets cannot use standard validate_number with money fields, necessitating custom validation logic as admitted in the troubleshooting section.
Money.parse loses precision with large values, requiring the Decimal package as an external dependency for accurate parsing, which adds complexity.
Supporting multiple currencies in databases involves creating custom PostgreSQL types or using JSON maps, adding migration and setup overhead compared to simple fields.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.