Search in sources :

Example 6 with MifosCurrency

use of org.mifos.application.master.business.MifosCurrency in project head by mifos.

the class CustomerPersistence method getTotalAmountForGroup.

public Money getTotalAmountForGroup(final Integer groupId, final AccountState accountState) throws PersistenceException {
    MifosCurrency currency = getCurrencyForTotalAmountForGroup(groupId, accountState);
    HashMap<String, Object> params = new HashMap<String, Object>();
    params.put("customerId", groupId);
    params.put("accountState", accountState.getValue());
    BigDecimal amount = getCalculateValueFromQueryResult(executeNamedQuery(NamedQueryConstants.GET_TOTAL_AMOUNT_FOR_GROUP, params));
    Money totalAmount = new Money(currency, amount);
    return totalAmount;
}
Also used : Money(org.mifos.framework.util.helpers.Money) HashMap(java.util.HashMap) MifosCurrency(org.mifos.application.master.business.MifosCurrency) BigDecimal(java.math.BigDecimal)

Example 7 with MifosCurrency

use of org.mifos.application.master.business.MifosCurrency in project head by mifos.

the class AccountApplyPaymentActionForm method validateAmount.

protected void validateAmount(ActionErrors errors) {
    MifosCurrency currency = null;
    if (getCurrencyId() != null && AccountingRules.isMultiCurrencyEnabled()) {
        currency = AccountingRules.getCurrencyByCurrencyId(getCurrencyId());
    }
    DoubleConversionResult conversionResult = validateAmount(getAmount(), currency, AccountConstants.ACCOUNT_AMOUNT, errors, "");
    if (amountCannotBeZero() && conversionResult.getErrors().size() == 0 && !(conversionResult.getDoubleValue() > 0.0)) {
        addError(errors, AccountConstants.ACCOUNT_AMOUNT, AccountConstants.ERRORS_MUST_BE_GREATER_THAN_ZERO, getLocalizedMessage(AccountConstants.ACCOUNT_AMOUNT));
    }
}
Also used : DoubleConversionResult(org.mifos.framework.util.helpers.DoubleConversionResult) MifosCurrency(org.mifos.application.master.business.MifosCurrency)

Example 8 with MifosCurrency

use of org.mifos.application.master.business.MifosCurrency in project head by mifos.

the class ApplyAdjustmentActionForm method validateAmount.

protected void validateAmount(ActionErrors errors) {
    MifosCurrency currency = null;
    if (getCurrencyId() != null && AccountingRules.isMultiCurrencyEnabled()) {
        currency = AccountingRules.getCurrencyByCurrencyId(getCurrencyId());
    }
    DoubleConversionResult conversionResult = validateAmount(getAmount(), currency, AccountConstants.ACCOUNT_AMOUNT, errors, "");
    if (conversionResult.getErrors().size() == 0 && !(conversionResult.getDoubleValue() > 0.0)) {
        addError(errors, AccountConstants.ACCOUNT_AMOUNT, AccountConstants.ERRORS_MUST_BE_GREATER_THAN_ZERO, getLocalizedMessage(AccountConstants.ACCOUNT_AMOUNT));
    }
}
Also used : DoubleConversionResult(org.mifos.framework.util.helpers.DoubleConversionResult) MifosCurrency(org.mifos.application.master.business.MifosCurrency)

Example 9 with MifosCurrency

use of org.mifos.application.master.business.MifosCurrency in project head by mifos.

the class LoanBusinessServiceTest method shouldGenerateMonthlyInstallmentScheduleFromRepaymentScheduleUsingDailyInterest.

@Test
public void shouldGenerateMonthlyInstallmentScheduleFromRepaymentScheduleUsingDailyInterest() {
    MifosCurrency rupee = new MifosCurrency(Short.valueOf("1"), "Rupee", BigDecimal.valueOf(1), "INR");
    RepaymentScheduleInstallment installment1 = getRepaymentScheduleInstallment("25-Sep-2010", 1, "78.6", "20.4", "1", "100", "0", "0");
    RepaymentScheduleInstallment installment2 = getRepaymentScheduleInstallment("25-Oct-2010", 2, "182.8", "16.2", "1", "200", "0", "0");
    RepaymentScheduleInstallment installment3 = getRepaymentScheduleInstallment("25-Nov-2010", 3, "186.0", "13.0", "1", "200", "0", "0");
    RepaymentScheduleInstallment installment4 = getRepaymentScheduleInstallment("25-Dec-2010", 4, "452.6", "8.9", "1", "462.5", "0", "0");
    List<RepaymentScheduleInstallment> installments = asList(installment1, installment2, installment3, installment4);
    Date disbursementDate = TestUtils.getDate(25, 8, 2010);
    final Money loanAmount = new Money(rupee, "1000");
    loanBusinessService.applyDailyInterestRates(new LoanScheduleGenerationDto(disbursementDate, loanAmount, 24d, installments), false);
    assertInstallment(installment1, "78.6", "20.4");
    assertInstallment(installment2, "180.8", "18.2");
    assertInstallment(installment3, "183.9", "15.1");
    assertInstallment(installment4, "556.7", "11.0");
}
Also used : Money(org.mifos.framework.util.helpers.Money) RepaymentScheduleInstallment(org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment) MifosCurrency(org.mifos.application.master.business.MifosCurrency) Date(java.util.Date) Test(org.junit.Test)

Example 10 with MifosCurrency

use of org.mifos.application.master.business.MifosCurrency in project head by mifos.

the class InstallmentRulesValidatorTest method setupAndInjectDependencies.

@Before
public void setupAndInjectDependencies() {
    locale = new Locale("en", "GB");
    installmentBuilder = new RepaymentScheduleInstallmentBuilder(locale);
    rupee = new MifosCurrency(Short.valueOf("1"), "Rupee", BigDecimal.valueOf(1), "INR");
    installmentRulesValidator = new InstallmentRulesValidatorImpl();
    officeId = Short.valueOf("1");
}
Also used : Locale(java.util.Locale) RepaymentScheduleInstallmentBuilder(org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallmentBuilder) MifosCurrency(org.mifos.application.master.business.MifosCurrency) Before(org.junit.Before)

Aggregations

MifosCurrency (org.mifos.application.master.business.MifosCurrency)54 Money (org.mifos.framework.util.helpers.Money)26 ArrayList (java.util.ArrayList)16 Test (org.junit.Test)12 BigDecimal (java.math.BigDecimal)10 Date (java.util.Date)10 HashMap (java.util.HashMap)10 Before (org.junit.Before)8 List (java.util.List)7 Locale (java.util.Locale)7 MifosRuntimeException (org.mifos.core.MifosRuntimeException)7 RepaymentScheduleInstallment (org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment)5 RepaymentScheduleInstallmentBuilder (org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallmentBuilder)5 MeetingBO (org.mifos.application.meeting.business.MeetingBO)4 LocalDate (org.joda.time.LocalDate)3 GLCodeEntity (org.mifos.accounts.financial.business.GLCodeEntity)3 PersistenceException (org.mifos.framework.exceptions.PersistenceException)3 DoubleConversionResult (org.mifos.framework.util.helpers.DoubleConversionResult)3 BigInteger (java.math.BigInteger)2 Calendar (java.util.Calendar)2