Search in sources :

Example 31 with Money

use of com.dexels.navajo.document.types.Money in project navajo by Dexels.

the class TestProperty method tesMoneyParsePresentation.

@Test
public void tesMoneyParsePresentation() {
    double d = 1300.50;
    Money m = new Money("1.300,50");
    logger.info(":: {}", m.doubleValue());
    Assert.assertEquals(d, m.doubleValue(), 0.1);
}
Also used : Money(com.dexels.navajo.document.types.Money) Test(org.junit.Test)

Example 32 with Money

use of com.dexels.navajo.document.types.Money in project navajo by Dexels.

the class TestProperty method tesMoneyParseTml.

@Test
public void tesMoneyParseTml() {
    double d = 10.30;
    Money m = new Money("10.30");
    // Strange test, but does no harm
    logger.info(":: {}", m.doubleValue());
    Assert.assertNotSame(d, m.doubleValue());
}
Also used : Money(com.dexels.navajo.document.types.Money) Test(org.junit.Test)

Example 33 with Money

use of com.dexels.navajo.document.types.Money in project navajo by Dexels.

the class TestProperty method tesNullMoneyEquals.

@Test
public void tesNullMoneyEquals() {
    Money m = new Money();
    Money mm = new Money();
    Assert.assertEquals(m, mm);
}
Also used : Money(com.dexels.navajo.document.types.Money) Test(org.junit.Test)

Example 34 with Money

use of com.dexels.navajo.document.types.Money in project navajo by Dexels.

the class TestProperty method tesMoneyProperty.

@Test
public void tesMoneyProperty() {
    BaseNavajoImpl n = new BaseNavajoImpl(NavajoFactory.getInstance());
    BaseMessageImpl m = new BaseMessageImpl(n, "Aap");
    n.addMessage(m);
    BasePropertyImpl p1 = new BasePropertyImpl(n, "Noot");
    m.addProperty(p1);
    p1.setType(Property.MONEY_PROPERTY);
    p1.setValue("10.30");
    StringWriter sw = new StringWriter();
    n.write(sw);
    StringReader sr = new StringReader(sw.toString());
    Navajo n2 = NavajoFactory.getInstance().createNavajo(sr);
    Property p2 = n2.getProperty("Aap/Noot");
    Money mon = (Money) p2.getTypedValue();
    logger.info("m: " + mon.toTmlString() + " :: " + mon.editingString() + " :: " + mon.toString());
    Assert.assertEquals(mon.toTmlString(), "10.30");
    Assert.assertEquals(mon.doubleValue(), 10.30d, 0.1);
}
Also used : BaseMessageImpl(com.dexels.navajo.document.base.BaseMessageImpl) Money(com.dexels.navajo.document.types.Money) StringWriter(java.io.StringWriter) BaseNavajoImpl(com.dexels.navajo.document.base.BaseNavajoImpl) BasePropertyImpl(com.dexels.navajo.document.base.BasePropertyImpl) StringReader(java.io.StringReader) Navajo(com.dexels.navajo.document.Navajo) Property(com.dexels.navajo.document.Property) Test(org.junit.Test)

Example 35 with Money

use of com.dexels.navajo.document.types.Money in project navajo by Dexels.

the class GetCents method evaluate.

@Override
public final Object evaluate() throws com.dexels.navajo.expression.api.TMLExpressionException {
    final Object op = this.getOperands().get(0);
    if (op == null) {
        return ("");
    }
    if (!(op instanceof Money)) {
        throw new TMLExpressionException(this, "Money argument expected");
    }
    Money mo = (Money) op;
    return MoneyToCents(mo);
}
Also used : Money(com.dexels.navajo.document.types.Money) TMLExpressionException(com.dexels.navajo.expression.api.TMLExpressionException)

Aggregations

Money (com.dexels.navajo.document.types.Money)39 Test (org.junit.Test)25 Percentage (com.dexels.navajo.document.types.Percentage)10 TMLExpressionException (com.dexels.navajo.expression.api.TMLExpressionException)8 ClockTime (com.dexels.navajo.document.types.ClockTime)6 Navajo (com.dexels.navajo.document.Navajo)5 Property (com.dexels.navajo.document.Property)5 Date (java.util.Date)5 Operand (com.dexels.navajo.document.Operand)4 Message (com.dexels.navajo.document.Message)3 NavajoException (com.dexels.navajo.document.NavajoException)3 Binary (com.dexels.navajo.document.types.Binary)3 StopwatchTime (com.dexels.navajo.document.types.StopwatchTime)3 StringWriter (java.io.StringWriter)3 DatePattern (com.dexels.navajo.document.types.DatePattern)2 SystemException (com.dexels.navajo.script.api.SystemException)2 StringReader (java.io.StringReader)2 ExpressionChangedException (com.dexels.navajo.document.ExpressionChangedException)1 PropertyTypeException (com.dexels.navajo.document.PropertyTypeException)1 BaseMessageImpl (com.dexels.navajo.document.base.BaseMessageImpl)1