mirror of
https://github.com/corda/corda.git
synced 2025-04-12 21:53:17 +00:00
Cosmetic change to Amount to display decimal places
This commit is contained in:
parent
3c4ce0a8fe
commit
5e3ff4238f
@ -58,7 +58,7 @@ data class Amount(val pennies: Long, val currency: Currency) : Comparable<Amount
|
||||
operator fun div(other: Int): Amount = Amount(pennies / other, currency)
|
||||
operator fun times(other: Int): Amount = Amount(Math.multiplyExact(pennies, other.toLong()), currency)
|
||||
|
||||
override fun toString(): String = currency.currencyCode + " " + (BigDecimal(pennies) / BigDecimal(100)).toPlainString()
|
||||
override fun toString(): String = currency.currencyCode + " " + (BigDecimal(pennies).divide(BigDecimal(100))).setScale(2).toPlainString()
|
||||
|
||||
override fun compareTo(other: Amount): Int {
|
||||
checkCurrency(other)
|
||||
|
@ -10,9 +10,17 @@ package core
|
||||
|
||||
import org.junit.Test
|
||||
import java.time.LocalDate
|
||||
import java.util.*
|
||||
|
||||
class FinanceTypesTest {
|
||||
|
||||
@Test
|
||||
fun `make sure Amount has decimal places`() {
|
||||
var x = Amount(1, Currency.getInstance("USD"))
|
||||
assert("0.01" in x.toString())
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun `schedule generator 1`() {
|
||||
var ret = BusinessCalendar.createGenericSchedule(startDate = LocalDate.of(2014, 11, 25), period = Frequency.Monthly, noOfAdditionalPeriods = 3)
|
||||
|
Loading…
x
Reference in New Issue
Block a user