Search in sources :

Example 6 with Money

use of org.javamoney.moneta.Money in project rulesservice by genny-project.

the class MoneyHelper method mul.

public static Money mul(Money inputMoney, Number number) {
    Money result = Money.of(0, DEFAULT_CURRENCY);
    if (inputMoney != null && number != null) {
        Number numberFromMoney = inputMoney.getNumber();
        Number resultNumber = mul(number, numberFromMoney);
        result = Money.of(resultNumber, inputMoney.getCurrency());
    }
    return result;
}
Also used : Money(org.javamoney.moneta.Money)

Example 7 with Money

use of org.javamoney.moneta.Money in project rulesservice by genny-project.

the class MoneyHelper method add.

/* ARITHMETIC FUNCTIONS FOR 1 INPUT IN MONEY DATATYPE, 1 INPUT IN NUMBER DATATYPE */
public static Money add(Money inputMoney, Number number) {
    Money result = Money.of(0, DEFAULT_CURRENCY);
    if (inputMoney != null && number != null) {
        Number numberFromMoney = inputMoney.getNumber();
        Number resultNumber = add(number, numberFromMoney);
        result = Money.of(resultNumber, inputMoney.getCurrency());
    }
    return result;
}
Also used : Money(org.javamoney.moneta.Money)

Example 8 with Money

use of org.javamoney.moneta.Money in project rulesservice by genny-project.

the class FeeCalculationTest method ownerTest.

// @Test
public void ownerTest() {
    Scanner scanner = new Scanner(System.in);
    System.out.print("Enter OWNER Price   ::   ");
    String ownerPriceString = scanner.nextLine();
    Double ownerPriceDouble = Double.parseDouble(ownerPriceString);
    Money ownerPrice = Money.of(ownerPriceDouble, DEFAULT_CURRENCY_AUD);
    Money ownerFeeExcGST = Money.of(0, DEFAULT_CURRENCY_AUD);
    Money ownerFeeIncGST = Money.of(0, DEFAULT_CURRENCY_AUD);
    Money ownerPriceExcGST = Money.of(0, DEFAULT_CURRENCY_AUD);
    Money ownerPriceIncGST = Money.of(0, DEFAULT_CURRENCY_AUD);
    Money driverPriceIncGST = Money.of(0, DEFAULT_CURRENCY_AUD);
    Money driverPriceExcGST = Money.of(0, DEFAULT_CURRENCY_AUD);
    QRules rules = new QRules(null, null, null);
    /* fee calculation */
    ownerFeeExcGST = rules.calcOwnerFee(ownerPrice);
    if (ownerPrice.compareTo(Money.of(300, DEFAULT_CURRENCY_AUD)) > 0) {
        if (ownerFeeExcGST.compareTo(Money.of(100, DEFAULT_CURRENCY_AUD)) < 0) {
            ownerFeeExcGST = Money.of(100, DEFAULT_CURRENCY_AUD);
        }
    }
    ownerFeeIncGST = rules.includeGSTMoney(ownerFeeExcGST);
    /* price calculation */
    ownerPriceExcGST = ownerPrice;
    ownerPriceIncGST = rules.includeGSTMoney(ownerPriceExcGST);
    driverPriceIncGST = ownerPriceIncGST.subtract(ownerFeeIncGST);
    driverPriceExcGST = ownerPriceExcGST.subtract(ownerFeeExcGST);
    System.out.println("-------------------------------------------");
    System.out.println("OWNER");
    System.out.println("-------------------------------------------");
    System.out.println("FEES");
    System.out.println("ownerFeeExcGST  ::  " + String.valueOf(ownerFeeExcGST.getNumber().doubleValue()));
    System.out.println("ownerFeeIncGST  ::  " + ownerFeeIncGST.getNumber().doubleValue());
    System.out.println("\n");
    System.out.println("PRICES");
    System.out.println("ownerPrice         ::  " + ownerPrice.getNumber().doubleValue());
    System.out.println("ownerPriceExcGST   ::  " + ownerPriceExcGST.getNumber().doubleValue());
    System.out.println("ownerPriceIncGST   ::  " + ownerPriceIncGST.getNumber().doubleValue());
    System.out.println("driverPriceExcGST  ::  " + driverPriceExcGST.getNumber().doubleValue());
    System.out.println("driverPriceIncGST  ::  " + driverPriceIncGST.getNumber().doubleValue());
}
Also used : Scanner(java.util.Scanner) Money(org.javamoney.moneta.Money) QRules(life.genny.rules.QRules)

Example 9 with Money

use of org.javamoney.moneta.Money in project rulesservice by genny-project.

the class MoneyHelper method mul.

public static Money mul(Money inputMoney1, Money inputMoney2) {
    Money result = Money.of(0, DEFAULT_CURRENCY);
    if (inputMoney1 != null && inputMoney2 != null) {
        Number numberFromMoney = inputMoney2.getNumber();
        result = inputMoney1.multiply(numberFromMoney);
    }
    return result;
}
Also used : Money(org.javamoney.moneta.Money)

Example 10 with Money

use of org.javamoney.moneta.Money in project rulesservice by genny-project.

the class MoneyHelper method div.

public static Money div(Money inputMoney1, Money inputMoney2) {
    Money result = Money.of(0, DEFAULT_CURRENCY);
    if (inputMoney1 != null && inputMoney2 != null) {
        Number numberFromMoney = inputMoney2.getNumber();
        result = inputMoney1.divide(numberFromMoney);
    }
    return result;
}
Also used : Money(org.javamoney.moneta.Money)

Aggregations

Money (org.javamoney.moneta.Money)31 AttributeMoney (life.genny.qwanda.attribute.AttributeMoney)7 CurrencyUnit (javax.money.CurrencyUnit)4 MonetaryAmount (javax.money.MonetaryAmount)4 FastMoney (org.javamoney.moneta.FastMoney)4 Test (org.junit.Test)4 BaseEntity (life.genny.qwanda.entity.BaseEntity)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 Scanner (java.util.Scanner)2 Answer (life.genny.qwanda.Answer)2 QRules (life.genny.rules.QRules)2 Test (org.testng.annotations.Test)2 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 CurrencyConversion (javax.money.convert.CurrencyConversion)1 ExchangeRateProvider (javax.money.convert.ExchangeRateProvider)1 MonetaryAmountFormat (javax.money.format.MonetaryAmountFormat)1 AttributeBoolean (life.genny.qwanda.attribute.AttributeBoolean)1