Search in sources :

Example 21 with AccountActionDateEntity

use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.

the class CustomerAccountBO method getTotalPaymentDue.

@Override
public Money getTotalPaymentDue() {
    Money totalAmt = getTotalAmountInArrears();
    AccountActionDateEntity nextInstallment = getDetailsOfNextInstallment();
    if (nextInstallment != null && !nextInstallment.isPaid()) {
        totalAmt = totalAmt.add(getDueAmount(nextInstallment));
    }
    return totalAmt;
}
Also used : Money(org.mifos.framework.util.helpers.Money) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity)

Example 22 with AccountActionDateEntity

use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.

the class SavingsOverDueDepositsTag method buildUI.

StringBuilder buildUI(List<AccountActionDateEntity> installmentsInArrears, Locale locale) {
    StringBuilder builder = new StringBuilder();
    SavingsScheduleEntity installment = null;
    Date actionDate = null;
    Collections.sort(installmentsInArrears, new Comparator<AccountActionDateEntity>() {

        @Override
        public int compare(AccountActionDateEntity actionDate1, AccountActionDateEntity actionDate2) {
            return actionDate1.getActionDate().compareTo(actionDate2.getActionDate());
        }
    });
    for (int i = 0; i < installmentsInArrears.size(); ) {
        actionDate = installmentsInArrears.get(i).getActionDate();
        Money totalAmount = new Money(installmentsInArrears.get(i).getAccount().getCurrency());
        do {
            installment = (SavingsScheduleEntity) installmentsInArrears.get(i);
            if (!(installment.getCustomer().getCustomerLevel().getId().equals(CustomerLevel.CLIENT.getValue()) && installment.getCustomer().getStatus().equals(CustomerStatus.CLIENT_CLOSED))) {
                totalAmount = totalAmount.add(installment.getTotalDepositDue());
            }
            i++;
        } while (i < installmentsInArrears.size() && actionDate.equals(installmentsInArrears.get(i).getActionDate()));
        if (totalAmount.isGreaterThanZero()) {
            builder.append(buildDepositDueUIRow(locale, actionDate, totalAmount));
        }
    }
    return builder;
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) Money(org.mifos.framework.util.helpers.Money) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) Date(java.sql.Date)

Example 23 with AccountActionDateEntity

use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.

the class SavingsAction method getDepositDueDetails.

@TransactionDemarcate(saveToken = true)
public ActionForward getDepositDueDetails(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    logger.debug("In SavingsAction::getDepositDueDetails()");
    SavingsActionForm actionform = (SavingsActionForm) form;
    UserContext uc = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
    SessionUtils.removeAttribute(Constants.BUSINESS_KEY, request);
    String savingsSystemId = actionform.getGlobalAccountNum();
    SavingsBO savings = savingsDao.findBySystemId(savingsSystemId);
    for (AccountActionDateEntity actionDate : savings.getAccountActionDates()) {
        Hibernate.initialize(actionDate);
    }
    Hibernate.initialize(savings.getAccountNotes());
    for (AccountFlagMapping accountFlagMapping : savings.getAccountFlags()) {
        Hibernate.initialize(accountFlagMapping.getFlag());
    }
    Hibernate.initialize(savings.getAccountFlags());
    savings.setUserContext(uc);
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, savings, request);
    SavingsAccountDepositDueDto depositDueDetails = this.savingsServiceFacade.retrieveDepositDueDetails(savingsSystemId);
    return mapping.findForward("depositduedetails_success");
}
Also used : SavingsActionForm(org.mifos.accounts.savings.struts.actionforms.SavingsActionForm) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) AccountFlagMapping(org.mifos.accounts.business.AccountFlagMapping) UserContext(org.mifos.security.util.UserContext) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) SavingsAccountDepositDueDto(org.mifos.dto.screen.SavingsAccountDepositDueDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 24 with AccountActionDateEntity

use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.

the class LoanRepaymentTag method generateGroupSchedule.

private List<AccountActionDateEntity> generateGroupSchedule(List<LoanBO> memberAccounts, LoanBO parent) {
    Money principal = new Money(Money.getDefaultCurrency(), 0.0), principalPaid = new Money(Money.getDefaultCurrency(), 0.0), interest = new Money(Money.getDefaultCurrency(), 0.0), interestPaid = new Money(Money.getDefaultCurrency(), 0.0), penalty = new Money(Money.getDefaultCurrency(), 0.0), penaltyPaid = new Money(Money.getDefaultCurrency(), 0.0), extraInterest = new Money(Money.getDefaultCurrency(), 0.0), extraInterestPaid = new Money(Money.getDefaultCurrency(), 0.0), miscFee = new Money(Money.getDefaultCurrency(), 0.0), miscFeePaid = new Money(Money.getDefaultCurrency(), 0.0), miscPenalty = new Money(Money.getDefaultCurrency(), 0.0), miscPenaltyPaid = new Money(Money.getDefaultCurrency(), 0.0);
    List<List<AccountActionDateEntity>> accActionList = new ArrayList<List<AccountActionDateEntity>>();
    for (LoanBO memberLoan : memberAccounts) {
        accActionList.add(new ArrayList<AccountActionDateEntity>(memberLoan.getAccountActionDates()));
    }
    List<AccountActionDateEntity> newGroupSchedule = copyAndSetToZeroSchedule(principal, principalPaid, interest, interestPaid, penalty, extraInterest, extraInterestPaid, miscFee, miscFeePaid, miscPenalty, penaltyPaid, miscPenaltyPaid, new ArrayList<AccountActionDateEntity>(parent.getAccountActionDates()));
    for (List<AccountActionDateEntity> accList : accActionList) {
        for (int i = 0; i < accList.size(); i++) {
            LoanScheduleEntity schedule = (LoanScheduleEntity) accList.get(i);
            LoanScheduleEntity newSchedule = (LoanScheduleEntity) newGroupSchedule.get(i);
            principal = principal.add(schedule.getPrincipal());
            newSchedule.setPrincipal(newSchedule.getPrincipal().add(principal));
            principal = new Money(Money.getDefaultCurrency(), 0.0);
            principalPaid = principalPaid.add(schedule.getPrincipalPaid());
            newSchedule.setPrincipalPaid(newSchedule.getPrincipalPaid().add(principalPaid));
            principalPaid = new Money(Money.getDefaultCurrency(), 0.0);
            interest = interest.add(schedule.getInterest());
            newSchedule.setInterest(newSchedule.getInterest().add(interest));
            interest = new Money(Money.getDefaultCurrency(), 0.0);
            interestPaid = interestPaid.add(schedule.getInterestPaid());
            newSchedule.setInterestPaid(newSchedule.getInterestPaid().add(interestPaid));
            interestPaid = new Money(Money.getDefaultCurrency(), 0.0);
            penalty = penalty.add(schedule.getPenalty());
            newSchedule.setPenalty(newSchedule.getPenalty().add(penaltyPaid));
            penalty = new Money(Money.getDefaultCurrency(), 0.0);
            penaltyPaid = penaltyPaid.add(schedule.getPenaltyPaid());
            newSchedule.setPenaltyPaid(newSchedule.getPenaltyPaid().add(penaltyPaid));
            penaltyPaid = new Money(Money.getDefaultCurrency(), 0.0);
            extraInterest = extraInterest.add(schedule.getExtraInterest());
            newSchedule.setExtraInterest(newSchedule.getExtraInterest().add(extraInterest));
            extraInterest = new Money(Money.getDefaultCurrency(), 0.0);
            extraInterestPaid = extraInterestPaid.add(schedule.getExtraInterestPaid());
            newSchedule.setExtraInterestPaid(newSchedule.getExtraInterestPaid().add(extraInterestPaid));
            extraInterestPaid = new Money(Money.getDefaultCurrency(), 0.0);
            miscFee = miscFee.add(schedule.getMiscFee());
            newSchedule.setMiscFee(newSchedule.getMiscFee().add(miscFee));
            miscFee = new Money(Money.getDefaultCurrency(), 0.0);
            miscFeePaid = miscFeePaid.add(schedule.getMiscFeePaid());
            newSchedule.setMiscFeePaid(newSchedule.getMiscFeePaid().add(miscFeePaid));
            miscFeePaid = new Money(Money.getDefaultCurrency(), 0.0);
            miscPenalty = miscPenalty.add(schedule.getMiscPenalty());
            newSchedule.setMiscPenalty(newSchedule.getMiscPenalty().add(miscPenalty));
            miscPenalty = new Money(Money.getDefaultCurrency(), 0.0);
            miscPenaltyPaid = miscPenaltyPaid.add(schedule.getMiscPenaltyPaid());
            newSchedule.setMiscPenaltyPaid(newSchedule.getMiscPenaltyPaid().add(miscPenaltyPaid));
            miscPenaltyPaid = new Money(Money.getDefaultCurrency(), 0.0);
        }
    }
    return newGroupSchedule;
}
Also used : LoanScheduleEntity(org.mifos.accounts.loan.business.LoanScheduleEntity) Money(org.mifos.framework.util.helpers.Money) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) LoanBO(org.mifos.accounts.loan.business.LoanBO) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 25 with AccountActionDateEntity

use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.

the class LoanTestUtils method getSortedAccountActionDateEntity.

public static LoanScheduleEntity[] getSortedAccountActionDateEntity(Set<AccountActionDateEntity> actionDateCollection) {
    LoanScheduleEntity[] sortedList = new LoanScheduleEntity[actionDateCollection.size()];
    // Don't know whether it will always be 6 for future tests, but
    // right now it is...
    Assert.assertEquals(6, actionDateCollection.size());
    for (AccountActionDateEntity actionDateEntity : actionDateCollection) {
        sortedList[actionDateEntity.getInstallmentId().intValue() - 1] = (LoanScheduleEntity) actionDateEntity;
    }
    return sortedList;
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity)

Aggregations

AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)211 Money (org.mifos.framework.util.helpers.Money)80 Test (org.junit.Test)69 ArrayList (java.util.ArrayList)58 LocalDate (org.joda.time.LocalDate)42 Date (java.util.Date)39 DateTime (org.joda.time.DateTime)33 MeetingBO (org.mifos.application.meeting.business.MeetingBO)33 AccountException (org.mifos.accounts.exceptions.AccountException)24 PaymentData (org.mifos.accounts.util.helpers.PaymentData)24 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)21 Date (java.sql.Date)19 SavingsScheduleEntity (org.mifos.accounts.savings.business.SavingsScheduleEntity)19 LoanBO (org.mifos.accounts.loan.business.LoanBO)17 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)15 LoanScheduleEntity (org.mifos.accounts.loan.business.LoanScheduleEntity)14 UserContext (org.mifos.security.util.UserContext)14 Calendar (java.util.Calendar)13 GregorianCalendar (java.util.GregorianCalendar)13 CenterBuilder (org.mifos.domain.builders.CenterBuilder)13