Search in sources :

Example 41 with AccountBO

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

the class ClientBO method updateMfiInfo.

public void updateMfiInfo(final PersonnelBO personnel, ClientMfiInfoUpdate clientMfiInfoUpdate) throws CustomerException {
    setExternalId(clientMfiInfoUpdate.getExternalId());
    setTrained(clientMfiInfoUpdate.isTrained());
    if (clientMfiInfoUpdate.getTrainedDate() != null) {
        setTrainedDate(clientMfiInfoUpdate.getTrainedDate().toDate());
    }
    setPersonnel(personnel);
    if (isActive() || isOnHold()) {
        validateLoanOfficer();
    }
    for (AccountBO account : this.getAccounts()) {
        account.setPersonnel(this.getPersonnel());
    }
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO)

Example 42 with AccountBO

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

the class CustomerBO method getDelinquentPortfolioAmount.

/*
     * This method is unused and is a candidate for removal.
     */
@Deprecated
public BigDecimal getDelinquentPortfolioAmount(MifosCurrency currency) {
    Money amountOverDue = new Money(currency);
    Money totalOutStandingAmount = new Money(currency);
    for (AccountBO accountBO : getAccounts()) {
        if (accountBO.getType() == AccountTypes.LOAN_ACCOUNT && ((LoanBO) accountBO).isAccountActive()) {
            amountOverDue = amountOverDue.add(((LoanBO) accountBO).getTotalPrincipalAmountInArrears());
            totalOutStandingAmount = totalOutStandingAmount.add(((LoanBO) accountBO).getLoanSummary().getOriginalPrincipal());
        }
    }
    if (totalOutStandingAmount.isNonZero()) {
        return amountOverDue.divide(totalOutStandingAmount);
    }
    return BigDecimal.ZERO;
}
Also used : Money(org.mifos.framework.util.helpers.Money) AccountBO(org.mifos.accounts.business.AccountBO) LoanBO(org.mifos.accounts.loan.business.LoanBO)

Example 43 with AccountBO

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

the class CustomerServiceImpl method handleChangeInMeetingSchedule.

private void handleChangeInMeetingSchedule(CustomerBO customer, final List<Days> workingDays, final List<Holiday> orderedUpcomingHolidays) throws AccountException {
    boolean lsimEnabled = this.configurationHelper.isLoanScheduleRepaymentIndependentOfCustomerMeetingEnabled();
    Set<AccountBO> accounts = customer.getAccounts();
    for (AccountBO account : accounts) {
        if (account instanceof LoanBO && lsimEnabled) {
        // do not change schedules when LSIm is on for loan accounts
        } else {
            account.handleChangeInMeetingSchedule(workingDays, orderedUpcomingHolidays, customer.isTopOfHierarchy());
            customerDao.save(account);
        }
    }
    for (CustomerBO child : customer.getChildren()) {
        handleChangeInMeetingSchedule(child, workingDays, orderedUpcomingHolidays);
    }
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) LoanBO(org.mifos.accounts.loan.business.LoanBO) CustomerBO(org.mifos.customers.business.CustomerBO)

Example 44 with AccountBO

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

the class CustomerServiceImpl method createCustomer.

private void createCustomer(CustomerBO customer, MeetingBO meeting, List<AccountFeesEntity> accountFees) {
    try {
        this.hibernateTransactionHelper.startTransaction();
        this.customerDao.save(customer);
        this.hibernateTransactionHelper.flushSession();
        // must first be saved via the customer save.
        for (AccountBO account : customer.getAccounts()) {
            if (account.isSavingsAccount()) {
                SavingsBO savingsAccount = (SavingsBO) account;
                savingsAccount.setUserContext(customer.getUserContext());
                savingsAccount.generateSystemId(customer.getOffice().getGlobalOfficeNum());
            }
        }
        this.customerDao.save(customer);
        this.hibernateTransactionHelper.flushSession();
        CalendarEvent applicableCalendarEvents = this.holidayDao.findCalendarEventsForThisYearAndNext(customer.getOfficeId());
        CustomerAccountBO customerAccount = this.customerAccountFactory.create(customer, accountFees, meeting, applicableCalendarEvents);
        customer.addAccount(customerAccount);
        this.customerDao.save(customer);
        this.hibernateTransactionHelper.flushSession();
        if (customer.getParentCustomer() != null) {
            this.customerDao.save(customer.getParentCustomer());
        }
        customer.generateGlobalCustomerNumber();
        customer.generateSearchId();
        this.customerDao.save(customer);
        if (customer.getParentCustomer() != null) {
            this.customerDao.save(customer.getParentCustomer());
        }
        this.hibernateTransactionHelper.commitTransaction();
    } catch (Exception e) {
        this.hibernateTransactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
    }
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) CalendarEvent(org.mifos.calendar.CalendarEvent) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) BusinessRuleException(org.mifos.service.BusinessRuleException) CustomerException(org.mifos.customers.exceptions.CustomerException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) AccountException(org.mifos.accounts.exceptions.AccountException) MeetingException(org.mifos.application.meeting.exceptions.MeetingException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 45 with AccountBO

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

the class CustomerBO method getOutstandingLoanAmount.

public Money getOutstandingLoanAmount(MifosCurrency currency) {
    Money amount = new Money(currency);
    Set<AccountBO> accounts = getAccounts();
    if (accounts != null) {
        for (AccountBO account : getAccounts()) {
            if (account.getType() == AccountTypes.LOAN_ACCOUNT && ((LoanBO) account).isAccountActive()) {
                Money remainingPrincipalAmount = ((LoanBO) account).getRemainingPrincipalAmount();
                if (amount.getAmount().equals(BigDecimal.ZERO)) {
                    amount = remainingPrincipalAmount;
                } else {
                    amount = amount.add(remainingPrincipalAmount);
                }
            }
        }
    }
    return amount;
}
Also used : Money(org.mifos.framework.util.helpers.Money) AccountBO(org.mifos.accounts.business.AccountBO) LoanBO(org.mifos.accounts.loan.business.LoanBO)

Aggregations

AccountBO (org.mifos.accounts.business.AccountBO)106 CustomerAccountBO (org.mifos.customers.business.CustomerAccountBO)39 LoanBO (org.mifos.accounts.loan.business.LoanBO)35 ArrayList (java.util.ArrayList)30 Money (org.mifos.framework.util.helpers.Money)30 UserContext (org.mifos.security.util.UserContext)29 Test (org.junit.Test)27 MifosRuntimeException (org.mifos.core.MifosRuntimeException)26 AccountBusinessService (org.mifos.accounts.business.service.AccountBusinessService)20 ServiceException (org.mifos.framework.exceptions.ServiceException)19 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)18 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)16 AccountException (org.mifos.accounts.exceptions.AccountException)15 MifosUser (org.mifos.security.MifosUser)14 Date (java.util.Date)13 LocalDate (org.joda.time.LocalDate)12 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)12 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)11 PersistenceException (org.mifos.framework.exceptions.PersistenceException)10 FeeBO (org.mifos.accounts.fees.business.FeeBO)9