Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Elixir
  3. money

money

MITElixirv1.13.1

An Elixir library implementing the Fowler Money pattern for safe, precise, and fun monetary operations.

Visit WebsiteGitHubGitHub
846 stars143 forks0 contributors

What is money?

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.

Target Audience

Elixir developers building applications that handle monetary transactions, financial data, or e-commerce systems where precision is critical.

Value Proposition

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.

Overview

Elixir library for working with Money safer, easier, and fun... Is an interpretation of the Fowler's Money pattern in fun.prog.

Use Cases

Best For

  • Handling monetary calculations without floating-point rounding errors
  • Building e-commerce platforms with multi-currency support
  • Storing and retrieving money values in PostgreSQL using Ecto
  • Formatting currency amounts with locale-specific symbols and separators
  • Adding custom currencies like cryptocurrencies to Elixir applications
  • Validating monetary amounts in Phoenix forms and changesets

Not Ideal For

  • Applications requiring real-time currency exchange rate APIs or dynamic financial modeling
  • Projects using databases without composite type or JSON field support for Ecto serialization
  • Teams needing out-of-the-box Ecto changeset validation without custom logic

Pros & Cons

Pros

Precision-First Arithmetic

Uses integer amounts to eliminate floating-point rounding errors, ensuring accurate calculations as demonstrated in Money.add and Money.multiply examples.

Comprehensive Currency Support

Handles ISO 4217 currencies and allows custom definitions like cryptocurrencies, with configurable symbols and exponents via custom_currencies configuration.

Seamless Ecto Integration

Provides multiple Ecto types (Amount, Composite, Map) for different database strategies, including PostgreSQL composite types and JSON serialization, detailed in the README.

Flexible Formatting

Offers extensive configuration for string representation, with options for separators, delimiters, and symbol placement through Money.to_string and global settings.

Cons

Custom Validation Required

Ecto changesets cannot use standard validate_number with money fields, necessitating custom validation logic as admitted in the troubleshooting section.

Parsing Precision Dependencies

Money.parse loses precision with large values, requiring the Decimal package as an external dependency for accurate parsing, which adds complexity.

Database Setup Complexity

Supporting multiple currencies in databases involves creating custom PostgreSQL types or using JSON maps, adding migration and setup overhead compared to simple fields.

Frequently Asked Questions

Quick Stats

Stars846
Forks143
Contributors0
Open Issues7
Last commit9 months ago
CreatedSince 2015

Tags

#elixir#financial-computing#phoenix-framework#decimal-arithmetic#ecto-integration#money-pattern#currency-handling

Built With

E
Ecto
P
PostgreSQL
E
Elixir

Links & Resources

Website

Included in

Elixir13.1k
Auto-fetched 7 hours ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub