Search in sources :

Example 26 with ConfigurationPersistence

use of org.mifos.config.persistence.ConfigurationPersistence in project head by mifos.

the class LoanBO method updateLoan.

public void updateLoan(final Date disbursementDate, final Short noOfInstallments, final Money loanAmount, final Integer businessActivityId) throws AccountException {
    setLoanAmount(loanAmount);
    setNoOfInstallments(noOfInstallments);
    setDisbursementDate(disbursementDate);
    setBusinessActivityId(businessActivityId);
    MeetingBO meetingBO = (isIndividualLoan() ? this.getParentAccount().getLoanMeeting() : this.getLoanMeeting());
    boolean isRepaymentIndepOfMeetingEnabled = new ConfigurationPersistence().isRepaymentIndepOfMeetingEnabled();
    regeneratePaymentSchedule(isRepaymentIndepOfMeetingEnabled, meetingBO);
    update();
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) ConfigurationPersistence(org.mifos.config.persistence.ConfigurationPersistence)

Example 27 with ConfigurationPersistence

use of org.mifos.config.persistence.ConfigurationPersistence in project head by mifos.

the class DecliningBalanceEqualPrincipalWithInterestGenerator method generateEqualInstallments.

@Override
public List<InstallmentPrincipalAndInterest> generateEqualInstallments(LoanInterestCalculationDetails loanInterestCalculationDetails) {
    Money loanAmount = loanInterestCalculationDetails.getLoanAmount();
    Integer numberOfInstallments = loanInterestCalculationDetails.getNumberOfInstallments();
    Double interestFractionalRatePerInstallment = loanInterestCalculationDetails.getInterestFractionalRatePerInstallment();
    GraceType graceType = loanInterestCalculationDetails.getGraceType();
    Integer gracePeriodDuration = loanInterestCalculationDetails.getGracePeriodDuration();
    //For M5193
    int prorateValue = 0;
    List<InstallmentPrincipalAndInterest> lstInstallmntPricplIntrst = null;
    LocalDate disbursalDateInLocalDate = loanInterestCalculationDetails.getDisbursementDate();
    DateTime disbursalDate = disbursalDateInLocalDate.toDateTimeAtStartOfDay();
    List<DateTime> scheduledDates = loanInterestCalculationDetails.getLoanScheduleDates();
    if (scheduledDates.size() > 2) {
        //chek whether loanscheduledDates are there
        DateTime firstRepaymentDay = scheduledDates.get(0);
        long differenceOfTwoDatesinMilliseconds = (firstRepaymentDay.toDate().getTime() - disbursalDate.toDate().getTime());
        long noOfDays = differenceOfTwoDatesinMilliseconds / (1000 * 60 * 60 * 24);
        int noOfDaysBetweenFirstRepaymentDayAndDisbursalDate = (int) noOfDays;
        DateTime secondRepaymentDay = scheduledDates.get(1);
        long duration = (secondRepaymentDay.toDate().getTime() - firstRepaymentDay.toDate().getTime()) / (1000 * 60 * 60 * 24);
        int noOfDaysInOneSchedule = (int) duration;
        prorateValue = new ConfigurationPersistence().getConfigurationValueInteger(PRORATE_RULE);
        if (prorateValue == 1)
            lstInstallmntPricplIntrst = allDecliningEPIInstallments_v2(loanAmount, numberOfInstallments, interestFractionalRatePerInstallment, graceType, gracePeriodDuration, noOfDaysBetweenFirstRepaymentDayAndDisbursalDate, noOfDaysInOneSchedule);
    }
    if (prorateValue != 1) {
        lstInstallmntPricplIntrst = allDecliningEPIInstallments_v2(loanAmount, numberOfInstallments, interestFractionalRatePerInstallment, graceType, gracePeriodDuration);
    }
    return lstInstallmntPricplIntrst;
}
Also used : Money(org.mifos.framework.util.helpers.Money) GraceType(org.mifos.accounts.productdefinition.util.helpers.GraceType) ConfigurationPersistence(org.mifos.config.persistence.ConfigurationPersistence) InstallmentPrincipalAndInterest(org.mifos.accounts.loan.util.helpers.InstallmentPrincipalAndInterest) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime)

Example 28 with ConfigurationPersistence

use of org.mifos.config.persistence.ConfigurationPersistence in project head by mifos.

the class AccountingRules method getCurrencies.

/**
     *
     * Gets the List of currencies configured to use in Mifos,
     * the first element will be the default currency.
     *
     * @return List of currencies
     */
public static LinkedList<MifosCurrency> getCurrencies() {
    if (currencies.size() == 0) {
        currencies.add(AccountingRules.getMifosCurrency(new ConfigurationPersistence()));
        ConfigurationPersistence configurationPersistence = new ConfigurationPersistence();
        for (String currencyCode : AccountingRules.getAdditionalCurrencyCodes()) {
            currencies.add(getMifosCurrency(currencyCode, configurationPersistence));
        }
    }
    return currencies;
}
Also used : ConfigurationPersistence(org.mifos.config.persistence.ConfigurationPersistence)

Aggregations

ConfigurationPersistence (org.mifos.config.persistence.ConfigurationPersistence)28 LocalDate (org.joda.time.LocalDate)9 DateTime (org.joda.time.DateTime)8 CustomerPersistence (org.mifos.customers.persistence.CustomerPersistence)8 Date (java.util.Date)7 AccountException (org.mifos.accounts.exceptions.AccountException)6 Test (org.junit.Test)5 Money (org.mifos.framework.util.helpers.Money)5 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)4 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)4 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)4 BusinessRuleException (org.mifos.service.BusinessRuleException)4 LoanBO (org.mifos.accounts.loan.business.LoanBO)3 ConfigurationKeyValue (org.mifos.config.business.ConfigurationKeyValue)3 MifosConfigurationManager (org.mifos.config.business.MifosConfigurationManager)3 PersistenceException (org.mifos.framework.exceptions.PersistenceException)3 DateTimeService (org.mifos.framework.util.DateTimeService)3 ArrayList (java.util.ArrayList)2 After (org.junit.After)2 Before (org.junit.Before)2