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;
}
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;
}
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());
}
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;
}
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;
}
Aggregations