Search in sources :

Example 11 with MifosCurrency

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

the class LoanBusinessServiceTest method shouldGenerateWeeklyInstallmentScheduleFromRepaymentScheduleUsingDailyInterest.

@Test
public void shouldGenerateWeeklyInstallmentScheduleFromRepaymentScheduleUsingDailyInterest() {
    MifosCurrency rupee = new MifosCurrency(Short.valueOf("1"), "Rupee", BigDecimal.valueOf(1), "INR");
    RepaymentScheduleInstallment installment1 = getRepaymentScheduleInstallment("01-Sep-2010", 1, "194.4", "4.6", "1", "100", "0", "0");
    RepaymentScheduleInstallment installment2 = getRepaymentScheduleInstallment("08-Sep-2010", 2, "195.3", "3.7", "1", "200", "0", "0");
    RepaymentScheduleInstallment installment3 = getRepaymentScheduleInstallment("15-Sep-2010", 3, "196.2", "2.8", "1", "200", "0", "0");
    RepaymentScheduleInstallment installment4 = getRepaymentScheduleInstallment("22-Sep-2010", 4, "414.1", "1.9", "1", "417.0", "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, "94.4", "4.6");
    assertInstallment(installment2, "194.8", "4.2");
    assertInstallment(installment3, "195.7", "3.3");
    assertInstallment(installment4, "515.0", "2.4");
}
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 12 with MifosCurrency

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

the class ViewOrganizationSettingsServiceFacadeWebTier method getCurrencies.

private List<Properties> getCurrencies() {
    List<Properties> currencies = new ArrayList<Properties>();
    for (MifosCurrency currency : AccountingRules.getCurrencies()) {
        Properties currencyRules = new Properties();
        currencyRules.setProperty("code", currency.getCurrencyCode());
        currencyRules.setProperty("digitsAfterDecimal", AccountingRules.getDigitsAfterDecimal(currency).toString());
        currencyRules.setProperty("finalRoundOffMultiple", AccountingRules.getFinalRoundOffMultiple(currency).toString());
        currencyRules.setProperty("initialRoundOffMultiple", AccountingRules.getInitialRoundOffMultiple(currency).toString());
        currencies.add(currencyRules);
    }
    return currencies;
}
Also used : ArrayList(java.util.ArrayList) Properties(java.util.Properties) MifosCurrency(org.mifos.application.master.business.MifosCurrency)

Example 13 with MifosCurrency

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

the class SavingsServiceFacadeWebTier method determinePostingPeriodResult.

private InterestPostingPeriodResult determinePostingPeriodResult(CalendarPeriod postingPeriod, SavingsBO savingsAccount, List<EndOfDayDetail> allEndOfDayDetailsForAccount) {
    List<SavingsProductHistoricalInterestDetail> historicalInterestDetails = savingsAccount.getHistoricalInterestDetailsForPeriod(postingPeriod);
    MifosCurrency currencyInUse = savingsAccount.getCurrency();
    Money startingBalanceForPeriod = calculateAccountBalanceOn(postingPeriod.getStartDate(), allEndOfDayDetailsForAccount, currencyInUse);
    InterestCalcType interestCalcType = savingsAccount.getInterestCalcType();
    int accountingNumberOfInterestDaysInYear = AccountingRules.getNumberOfInterestDays();
    SavingsInterestDetail interestDetail = new SavingsInterestDetail(interestCalcType, savingsAccount.getInterestRate(), accountingNumberOfInterestDaysInYear, savingsAccount.getMinAmntForInt());
    InterestScheduledEvent interestCalculationEvent = new SavingsInterestScheduledEventFactory().createScheduledEventFrom(savingsAccount.getInterestCalculationMeeting());
    return doCalculateInterestForPostingPeriod(postingPeriod, startingBalanceForPeriod, historicalInterestDetails, allEndOfDayDetailsForAccount, interestDetail, interestCalculationEvent);
}
Also used : SavingsInterestScheduledEventFactory(org.mifos.accounts.savings.interest.schedule.SavingsInterestScheduledEventFactory) Money(org.mifos.framework.util.helpers.Money) InterestCalcType(org.mifos.accounts.productdefinition.util.helpers.InterestCalcType) InterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent) SavingsInterestDetail(org.mifos.accounts.savings.interest.SavingsInterestDetail) SavingsProductHistoricalInterestDetail(org.mifos.accounts.savings.interest.SavingsProductHistoricalInterestDetail) MifosCurrency(org.mifos.application.master.business.MifosCurrency)

Example 14 with MifosCurrency

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

the class SavingsServiceFacadeWebTier method withdrawalMakesBalanceNegativeOnDate.

private boolean withdrawalMakesBalanceNegativeOnDate(SavingsBO savingsAccount, Money amount, LocalDate trxnDate) {
    List<EndOfDayDetail> allEndOfDayDetailsForAccount = savingsDao.retrieveAllEndOfDayDetailsFor(savingsAccount.getCurrency(), savingsAccount.getAccountId().longValue());
    MifosCurrency currencyInUse = savingsAccount.getCurrency();
    Money balanceOnDateOfWithdrawal = calculateAccountBalanceOn(trxnDate.plusDays(1), allEndOfDayDetailsForAccount, currencyInUse);
    return amount.isGreaterThan(balanceOnDateOfWithdrawal);
}
Also used : Money(org.mifos.framework.util.helpers.Money) EndOfDayDetail(org.mifos.accounts.savings.interest.EndOfDayDetail) MifosCurrency(org.mifos.application.master.business.MifosCurrency)

Example 15 with MifosCurrency

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

the class AccountingRules method getMifosCurrency.

public static MifosCurrency getMifosCurrency(String currencyCode, ConfigurationPersistence configurationPersistence) {
    MifosCurrency currency = configurationPersistence.getCurrency(currencyCode);
    if (currency == null) {
        throw new RuntimeException("Can't find in the database the currency define in the config file " + currencyCode);
    }
    Short digitsAfterDecimal = getDigitsAfterDecimal(currency);
    BigDecimal amountToBeRoundedTo = getAmountToBeRoundedTo(currency.getRoundingAmount());
    return new MifosCurrency(currency.getCurrencyId(), currency.getCurrencyName(), amountToBeRoundedTo, currencyCode);
}
Also used : MifosRuntimeException(org.mifos.core.MifosRuntimeException) MifosCurrency(org.mifos.application.master.business.MifosCurrency) BigDecimal(java.math.BigDecimal)

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