Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
Make withdraw return correct result type
Browse files Browse the repository at this point in the history
Fixes #16
  • Loading branch information
Flibio committed Aug 21, 2016
1 parent 59fdf02 commit 45a5450
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ name=EconomyLite
owner=Flibio
inceptionYear=2015
currentYear=2016
version=2.2.5
version=2.2.6
apiVersion=4.1.0-SNAPSHOT
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,10 @@ public TransactionResult deposit(Currency currency, BigDecimal amount, Cause cau
public TransactionResult withdraw(Currency currency, BigDecimal amount, Cause cause, Set<Context> contexts) {
BigDecimal newBal = getBalance(currency).subtract(amount);
// Check if the new balance is in bounds
if (newBal.compareTo(BigDecimal.ZERO) == -1 || newBal.compareTo(BigDecimal.valueOf(999999999)) == 1) {
if (newBal.compareTo(BigDecimal.ZERO) == -1) {
return resultAndEvent(this, amount, currency, ResultType.ACCOUNT_NO_FUNDS, TransactionTypes.WITHDRAW);
}
if (newBal.compareTo(BigDecimal.valueOf(999999999)) == 1) {
return resultAndEvent(this, amount, currency, ResultType.ACCOUNT_NO_SPACE, TransactionTypes.WITHDRAW);
}
if (playerService.withdraw(uuid, amount, currency, cause)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,10 @@ public TransactionResult deposit(Currency currency, BigDecimal amount, Cause cau
public TransactionResult withdraw(Currency currency, BigDecimal amount, Cause cause, Set<Context> contexts) {
BigDecimal newBal = getBalance(currency).subtract(amount);
// Check if the new balance is in bounds
if (newBal.compareTo(BigDecimal.ZERO) == -1 || newBal.compareTo(BigDecimal.valueOf(999999999)) == 1) {
if (newBal.compareTo(BigDecimal.ZERO) == -1) {
return resultAndEvent(this, amount, currency, ResultType.ACCOUNT_NO_FUNDS, TransactionTypes.WITHDRAW);
}
if (newBal.compareTo(BigDecimal.valueOf(999999999)) == 1) {
return resultAndEvent(this, amount, currency, ResultType.ACCOUNT_NO_SPACE, TransactionTypes.WITHDRAW);
}
if (virtualService.withdraw(name, amount, currency, cause)) {
Expand Down

0 comments on commit 45a5450

Please sign in to comment.