-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor: Remove deposit and withdraw implementation to be fixed on next branch.
- Loading branch information
1 parent
7ad3a28
commit 5062fcc
Showing
5 changed files
with
23 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 5 additions & 6 deletions
11
...tlin/io/holixon/cqrshexagonaldemo/demoparent/transactions/domain/model/account/Account.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,20 @@ | ||
package io.holixon.cqrshexagonaldemo.demoparent.transactions.domain.model.account | ||
|
||
import io.holixon.cqrshexagonaldemo.demoparent.transactions.domain.model.customer.CustomerNumber | ||
import java.math.BigDecimal | ||
|
||
data class Account( | ||
var customerNumber: CustomerNumber, | ||
var iban: Iban, | ||
var balance: Money | ||
) { | ||
fun deposit(amount: BigDecimal) { | ||
this.balance.amount.plus(amount) | ||
fun deposit(amount: Amount) { | ||
this.balance.amount += amount.value | ||
} | ||
|
||
fun withdraw(amount: BigDecimal) { | ||
require(this.balance.amount > amount) { | ||
fun withdraw(amount: Amount) { | ||
require(this.balance.amount > amount.value) { | ||
"Cannot withdraw more than account balance" | ||
} | ||
this.balance.amount -= amount | ||
this.balance.amount -= amount.value | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...otlin/io/holixon/cqrshexagonaldemo/demoparent/transactions/domain/model/account/Amount.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package io.holixon.cqrshexagonaldemo.demoparent.transactions.domain.model.account | ||
|
||
import java.math.BigDecimal | ||
|
||
class Amount(val value: BigDecimal) { | ||
init { | ||
require(value > BigDecimal.ZERO){ | ||
"Amount must not be negative or zero" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters