You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ghubstan
changed the title
PG Reactive Client: new Money(new BigDecimal("-0.11")) creates positive Money(0,11)
PG Reactive Client: Cannot create Money value in Range (-1.00, 0.00)
Sep 25, 2023
Describe the bug
I cannot create a
Money
value of -0.XX, i.e., a Money value greater than -1.00, and less than 0.00. Range (-1.00 < value < 0.00)If the integer value of the Number argument is non-zero, e.g., using
Money
constructor argumentnew BigDecimal("-1.11")
works.If the integer value of the Number argument is zero, e.g., using a
Money
constructornew BigDecimal("-0.11")
does not work (as expected).I am not certain this is a bug, due to my expectation that the integerPart of a Money(-0.11) could be represented as -0.
Reproducing tests and debugger screenshots are below.
Expected behavior
Calling
new Money(new BigDecimal("-0.11"))
results in a negativeMoney(-0,11)
The Money value represents minus 11 cents, as expected.
Actual behavior
Calling
new Money(new BigDecimal("-0.11"))
results in a positiveMoney(0,11)
The Money value represents plus 11cents, not minus 11cents.
How to Reproduce?
Use a
BigDecimal
as aMoney
constructor argument.Money money = new Money(new BigDecimal("-1.11"));
Examine resulting Money in debugger:
![right-money](https://private-user-images.githubusercontent.com/36207203/270414956-3f27c988-8a66-444d-ac59-f7cee5a2e2a8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzQ1NzI2MTIsIm5iZiI6MTczNDU3MjMxMiwicGF0aCI6Ii8zNjIwNzIwMy8yNzA0MTQ5NTYtM2YyN2M5ODgtOGE2Ni00NDRkLWFjNTktZjdjZWU1YTJlMmE4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDEyMTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQxMjE5VDAxMzgzMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQyZTgwYmYxZjM4ZDlhYzlmM2Q2ODE4MDE2YjcwOGZhNWQxMTBjNTFjM2JiZjAxNWUxOWVhOGYyNmQxZTc4YzAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.JalqsDUWDXxFe3qkztbNmI5REwtJE7bIngT5TWJ30g0)
Print resulting Money value:
Money(-1.11)
. As expected I seeMoney(-1.11)
.Use a
BigDecimal
as aMoney
constructor argument.Money money = new Money(new BigDecimal("-0.11"));
Examine resulting Money in debugger:
![wrong-money](https://private-user-images.githubusercontent.com/36207203/270407389-14ecd930-48fd-4924-8b41-dd5a2127d329.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzQ1NzI2MTIsIm5iZiI6MTczNDU3MjMxMiwicGF0aCI6Ii8zNjIwNzIwMy8yNzA0MDczODktMTRlY2Q5MzAtNDhmZC00OTI0LThiNDEtZGQ1YTIxMjdkMzI5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDEyMTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQxMjE5VDAxMzgzMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTI2MjIyMWM2ZmJlMzE2MDAzNDEzZWJmMWIzOGNhMmNmM2MzNjA1MjRkNWU2NzliYjNhMDhkYjg2ODMzYjgzYjUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.RxqJft1MdVdMUPwCqBUz1TtwknSGZjNgEXxhWSz7Kis)
Print resulting Money value:
Money(0.11)
. I expect to seeMoney(-0.11)
.Below are some test cases.
Above, as expected
assertEquals(-1, money.getIntegerPart())
passes.Above, as expected
assertEquals(0, money.getIntegerPart())
passes, but I need to be able to create a Money(-0.11).Any advice?
Thanks.
Output of
uname -a
orver
Ubuntu 22.04.3 Linux 6.2.0-33-generic x86_64 x86_64 x86_64 GNU/Linux
Output of
java -version
openjdk version "17.0.7" 2023-04-18 OpenJDK Runtime Environment Temurin-17.0.7+7 (build 17.0.7+7) OpenJDK 64-Bit Server VM Temurin-17.0.7+7 (build 17.0.7+7, mixed mode, sharing)
GraalVM version (if different from Java)
No response
Quarkus version or git rev
3.2.0.Final
Build tool (ie. output of
mvnw --version
orgradlew --version
)Gradle 8.1.1
Additional information
No response
The text was updated successfully, but these errors were encountered: