mirror of
https://github.com/corda/corda.git
synced 2025-05-31 14:40:52 +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 div(other: Int): Amount = Amount(pennies / other, currency)
|
||||||
operator fun times(other: Int): Amount = Amount(Math.multiplyExact(pennies, other.toLong()), 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 {
|
override fun compareTo(other: Amount): Int {
|
||||||
checkCurrency(other)
|
checkCurrency(other)
|
||||||
|
@ -10,9 +10,17 @@ package core
|
|||||||
|
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import java.time.LocalDate
|
import java.time.LocalDate
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
class FinanceTypesTest {
|
class FinanceTypesTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `make sure Amount has decimal places`() {
|
||||||
|
var x = Amount(1, Currency.getInstance("USD"))
|
||||||
|
assert("0.01" in x.toString())
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `schedule generator 1`() {
|
fun `schedule generator 1`() {
|
||||||
var ret = BusinessCalendar.createGenericSchedule(startDate = LocalDate.of(2014, 11, 25), period = Frequency.Monthly, noOfAdditionalPeriods = 3)
|
var ret = BusinessCalendar.createGenericSchedule(startDate = LocalDate.of(2014, 11, 25), period = Frequency.Monthly, noOfAdditionalPeriods = 3)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user