{"id":32171453,"url":"https://github.com/mlsdev/dinero","last_synced_at":"2026-02-19T07:02:49.738Z","repository":{"id":57490174,"uuid":"197007214","full_name":"MLSDev/dinero","owner":"MLSDev","description":null,"archived":false,"fork":false,"pushed_at":"2019-09-09T21:07:29.000Z","size":77,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-21T17:55:09.825Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MLSDev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-15T13:46:14.000Z","updated_at":"2024-10-14T07:45:36.000Z","dependencies_parsed_at":"2022-09-02T12:01:23.672Z","dependency_job_id":null,"html_url":"https://github.com/MLSDev/dinero","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MLSDev/dinero","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MLSDev%2Fdinero","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MLSDev%2Fdinero/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MLSDev%2Fdinero/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MLSDev%2Fdinero/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MLSDev","download_url":"https://codeload.github.com/MLSDev/dinero/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MLSDev%2Fdinero/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29605804,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T06:47:36.664Z","status":"ssl_error","status_checked_at":"2026-02-19T06:45:47.551Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-21T17:51:27.635Z","updated_at":"2026-02-19T07:02:49.733Z","avatar_url":"https://github.com/MLSDev.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Hex Version](http://img.shields.io/hexpm/v/dinero.svg?style=flat)](https://hex.pm/packages/dinero)\n[![Hex docs](http://img.shields.io/badge/hex.pm-docs-green.svg?style=flat)](https://hexdocs.pm/dinero)\n[![Build Status](https://travis-ci.org/MLSDev/dinero.svg?branch=master)](https://travis-ci.org/MLSDev/dinero)\n\n# Dinero\n\nElixir library for working with monetary values. Dinero is slang for money.\n\n## How to use\n```elixir\n  iex\u003e ten_bucks = Dinero.new(10, :USD)\n  %Dinero{amount: 1000, currency: :USD}\n  iex\u003e twelve_bucks = Dinero.new(12, :USD)\n  %Dinero{amount: 1200, currency: :USD}\n  iex\u003e two_bucks = Dinero.subtract(twenty_bucks, ten_bucks)\n  %Dinero{amount: 200, currency: :USD}\n  iex\u003e four_bucks = Dinero.multiply(two_bucks, 2)\n  %Dinero{amount: 400, currency: :USD}\n  iex\u003e convert = Dinero.convert(four_bucks, :UAH, 26.2)\n  %Dinero{amount: 10480, currency: :UAH}\n  iex\u003e d = ~m[924.06]uah\n  %Dinero{amount: 92406, currency: :UAH}\n  iex\u003e \"Amount #{d}\"\n  \"Amount 924.06\"\n  iex\u003e Dinero.new(1.0e4, :USD) \n  %Dinero{amount: 1000000, currency: :USD}\n  iex\u003e Dinero.parse(\"1312.14\")\n  %Dinero{amount: 131214, currency: :USD}\n```\n\n### Using with Postgres\n`Dinero.Ecto.DineroWithCurrency` is an Ecto type that allows saving amount of dinero with currency to database.\n\n1. Create custom Postrgres type\n    ```elixir\n    def up do\n      execute \"CREATE TYPE public.dinero_with_currency AS (amount integer, currency char(3))\"\n    end\n    \n    def down do\n      execute \"DROP TYPE public.dinero_with_currency\"\n    end\n    ```\n2. Add column to the table\n    ```elixir\n    alter table (:products) do\n      add :price, :dinero_with_currency\n    end\n    ```\n3. Add field to the schema\n    ```elixir\n    schema \"products\" do\n      field :price, Dinero.Ecto.DineroWithCurrency\n    end\n    ```\n4. Save to DB:\n    ```elixir\n    iex\u003e Repo.insert %Product{price: Dinero.new(20, :USD)}\n    [debug] QUERY OK db=2.6ms decode=0.5ms queue=0.4ms\n      INSERT INTO \"products\" (\"price\",\"inserted_at\",\"updated_at\") VALUES ($1,$2,$3) RETURNING \"id\" [{2000, \"USD\"}, ~N[2019-07-15 12:47:38], ~N[2019-07-15 12:47:38]]\n    {:ok,\n      %EctoCustomType.Product{\n      __meta__: #Ecto.Schema.Metadata\u003c:loaded, \"products\"\u003e,\n      id: 1,\n      inserted_at: ~N[2019-07-15 12:47:38],\n      price: %Dinero{amount: 2000, currency: :USD},\n      updated_at: ~N[2019-07-15 12:47:38]\n    }}\n    ```\n5. Get from DB:\n    ```elixir\n    iex\u003e Repo.all(Product)\n    [debug] QUERY OK source=\"products\" db=1.2ms queue=1.3ms\n    SELECT p0.\"id\", p0.\"price\", p0.\"inserted_at\", p0.\"updated_at\" FROM \"products\" AS p0 []\n    [\n      %EctoCustomType.Product{\n        __meta__: #Ecto.Schema.Metadata\u003c:loaded, \"products\"\u003e,\n        id: 1,\n        inserted_at: ~N[2019-07-15 12:47:38],\n        price: %Dinero{amount: 2000, currency: :USD},\n        updated_at: ~N[2019-07-15 12:47:38]\n      }\n    ]\n\n    ```\n\n### Dinero.Sigil\n\n```elixir\n# Sigils for Dinero\nimport Dinero.Sigil\n\niex\u003e ~m[100]UAH\n%Dinero{amount: 10000, currency: :UAH}\n\n# Default currency is USD\niex\u003e ~m[100]\n%Dinero{amount: 10000, currency: :USD}\n```\n\n## Installation\n\nIt is [available in Hex](https://hex.pm/packages/dinero) and can be installed\nby adding `dinero` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:dinero, \"~\u003e 1.3\"}\n  ]\nend\n```\n\nDocumentation can be found [here](https://hexdocs.pm/dinero)\n\n## Authors\n* [Slava Fir][github-fir], MLSDev\n\n## License\nDinero is released under the MIT license. See LICENSE for details.\n\n## About MLSDev\n\n[\u003cimg src=\"https://raw.githubusercontent.com/MLSDev/development-standards/master/mlsdev-logo.png\" alt=\"MLSDev.com\"\u003e][mlsdev]\n\n[Dinero](https://github.com/MLSDev/dinero) is maintained by MLSDev, Inc. We specialize in providing all-in-one solution in mobile and web development. Our team follows Lean principles and works according to agile methodologies to deliver the best results reducing the budget for development and its timeline. \n\nFind out more [here][mlsdev] and don't hesitate to [contact us][contact]!\n\n[mlsdev]: https://mlsdev.com\n[contact]: https://mlsdev.com/contact-us\n[github-fir]: https://github.com/SlavaFir\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmlsdev%2Fdinero","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmlsdev%2Fdinero","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmlsdev%2Fdinero/lists"}