Skip to content

Commit 7e0e017

Browse files
committed
Fix Money.within/2 when min and max are the same. Closes #177
1 parent 7dcf61c commit 7e0e017

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,17 @@
22

33
**Note** `ex_money` 5.17.0 and later is supported on Elixir 1.12 and later versions only.
44

5+
## Money v5.19.1
6+
7+
This is the changelog for Money v5.19.1 released on January 22nd, 2025. For older changelogs please consult the release tag on [GitHub](https://github.com/kipcole9/money/tags)
8+
9+
### Bux Fixes
10+
11+
* Fixes `Money.within/3` when `min` and `max` are the same. Thanks to @joewunderlich for the report. Closes #177.
12+
513
## Money v5.19.0
614

7-
This is the changelog for Money v5.19.0 released on January 1st, 2024. For older changelogs please consult the release tag on [GitHub](https://github.com/kipcole9/money/tags)
15+
This is the changelog for Money v5.19.0 released on January 1st, 2025. For older changelogs please consult the release tag on [GitHub](https://github.com/kipcole9/money/tags)
816

917
### Deprecations
1018

lib/money.ex

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1554,6 +1554,12 @@ defmodule Money do
15541554
iex> Money.within?(Money.new(:USD, 10), Money.new(:USD, 50), Money.new(:USD, 200))
15551555
false
15561556
1557+
iex> Money.within?(Money.new(:USD, 10), Money.new(:USD, 50), Money.new(:USD, 50))
1558+
false
1559+
1560+
iex> Money.within?(Money.new(:USD, 50), Money.new(:USD, 50), Money.new(:USD, 50))
1561+
true
1562+
15571563
iex> Money.within?(Money.new(:USD, 100), Money.new(:USD, 300), Money.new(:USD, 200))
15581564
** (ArgumentError) Minimum must be less than maximum. Found Money.new(:USD, "300") and Money.new(:USD, "200")
15591565
@@ -1570,7 +1576,7 @@ defmodule Money do
15701576
%__MODULE__{currency: same_currency} = minimum,
15711577
%__MODULE__{currency: same_currency} = maximum
15721578
) do
1573-
if compare(minimum, maximum) == :lt do
1579+
if compare(minimum, maximum) in [:lt, :eq] do
15741580
compare(money, minimum) in [:gt, :eq] && compare(money, maximum) in [:lt, :eq]
15751581
else
15761582
raise ArgumentError,

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule Money.Mixfile do
22
use Mix.Project
33

4-
@version "5.19.0"
4+
@version "5.19.1"
55

66
def project do
77
[

mix.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"makeup_erlang": {:hex, :makeup_erlang, "1.0.1", "c7f58c120b2b5aa5fd80d540a89fdf866ed42f1f3994e4fe189abebeab610839", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "8a89a1eeccc2d798d6ea15496a6e4870b75e014d1af514b1b71fa33134f57814"},
3030
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"},
3131
"mimerl": {:hex, :mimerl, "1.3.0", "d0cd9fc04b9061f82490f6581e0128379830e78535e017f7780f37fea7545726", [:rebar3], [], "hexpm", "a1e15a50d1887217de95f0b9b0793e32853f7c258a5cd227650889b38839fe9d"},
32-
"nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"},
32+
"nimble_parsec": {:hex, :nimble_parsec, "1.4.1", "f41275a0354c736db4b1d255b5d2a27c91028e55c21ea3145b938e22649ffa3f", [:mix], [], "hexpm", "605e44204998f138d6e13be366c8e81af860e726c8177caf50067e1b618fe522"},
3333
"parse_trans": {:hex, :parse_trans, "3.4.1", "6e6aa8167cb44cc8f39441d05193be6e6f4e7c2946cb2759f015f8c56b76e5ff", [:rebar3], [], "hexpm", "620a406ce75dada827b82e453c19cf06776be266f5a67cff34e1ef2cbb60e49a"},
3434
"phoenix_html": {:hex, :phoenix_html, "4.2.0", "83a4d351b66f472ebcce242e4ae48af1b781866f00ef0eb34c15030d4e2069ac", [:mix], [], "hexpm", "9713b3f238d07043583a94296cc4bbdceacd3b3a6c74667f4df13971e7866ec8"},
3535
"poison": {:hex, :poison, "6.0.0", "9bbe86722355e36ffb62c51a552719534257ba53f3271dacd20fbbd6621a583a", [:mix], [{:decimal, "~> 2.1", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "bb9064632b94775a3964642d6a78281c07b7be1319e0016e1643790704e739a2"},

0 commit comments

Comments
 (0)