Skip to content

Commit

Permalink
Implement test for insufficient balance in PLN (pass)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamil.jedrzejuk committed Oct 3, 2024
1 parent 9f3d9a0 commit 43e1820
Showing 1 changed file with 1 addition and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Account(

fun exchangePlnToUsd(amountPln: BigDecimal, exchangeRate: BigDecimal) {
require(amountPln > BigDecimal.ZERO) { "Amount must be greater than 0" }
require(amountPln <= balancePln) { "Insufficient PLN balance" }
val amountUsd = amountPln.divide(exchangeRate, 2, RoundingMode.HALF_EVEN)
balancePln = balancePln.subtract(amountPln)
balanceUsd = balanceUsd.add(amountUsd)
Expand Down

0 comments on commit 43e1820

Please sign in to comment.