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());
}
}
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;
}
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);
}
}
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);
}
}
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;
}
Aggregations