use of org.mifos.dto.domain.SavingsDetailDto in project head by mifos.
the class LoanAccountServiceFacadeWebTier method retrieveLoanRepaymentDetails.
@Override
public RepayLoanDto retrieveLoanRepaymentDetails(String globalAccountNumber) {
MifosUser mifosUser = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = new UserContextFactory().create(mifosUser);
LoanBO loan = this.loanDao.findByGlobalAccountNum(globalAccountNumber);
try {
personnelDao.checkAccessPermission(userContext, loan.getOfficeId(), loan.getCustomer().getLoanOfficerId());
} catch (AccountException e) {
throw new MifosRuntimeException(e.getMessage(), e);
}
Money repaymentAmount;
Money waiverAmount;
if (loan.isDecliningBalanceInterestRecalculation()) {
RepaymentResultsHolder repaymentResultsHolder = scheduleCalculatorAdaptor.computeRepaymentAmount(loan, DateUtils.getCurrentDateWithoutTimeStamp());
repaymentAmount = new Money(loan.getCurrency(), repaymentResultsHolder.getTotalRepaymentAmount());
waiverAmount = new Money(loan.getCurrency(), repaymentResultsHolder.getWaiverAmount());
} else {
repaymentAmount = loan.getEarlyRepayAmount();
waiverAmount = loan.waiverAmount();
}
Money waivedRepaymentAmount = repaymentAmount.subtract(waiverAmount);
List<SavingsDetailDto> savingsInUse = clientServiceFacade.retrieveSavingsInUseForClient(loan.getCustomer().getCustomerId());
List<SavingsDetailDto> accountsForTransfer = new ArrayList<SavingsDetailDto>();
if (savingsInUse != null) {
for (SavingsDetailDto savingsAccount : savingsInUse) {
if (savingsAccount.getAccountStateId().equals(AccountState.SAVINGS_ACTIVE.getValue())) {
accountsForTransfer.add(savingsAccount);
}
}
}
return new RepayLoanDto(repaymentAmount.toString(), waivedRepaymentAmount.toString(), loan.isInterestWaived(), accountsForTransfer);
}
use of org.mifos.dto.domain.SavingsDetailDto in project head by mifos.
the class ClientCustActionForm method validateSelectedOfferings.
@SuppressWarnings("unchecked")
private void validateSelectedOfferings(ActionErrors errors, HttpServletRequest request) {
boolean duplicateFound = false;
for (int i = 0; i < selectedOfferings.size() - 1; i++) {
for (int j = i + 1; j < selectedOfferings.size(); j++) {
if (selectedOfferings.get(i) != null && selectedOfferings.get(j) != null && selectedOfferings.get(i).equals(selectedOfferings.get(j))) {
String selectedOffering = "";
try {
List<SavingsDetailDto> offeringsList = (List<SavingsDetailDto>) SessionUtils.getAttribute(ClientConstants.SAVINGS_OFFERING_LIST, request);
for (SavingsDetailDto savingsOffering : offeringsList) {
if (selectedOfferings.get(i).equals(savingsOffering.getPrdOfferingId())) {
selectedOffering = savingsOffering.getPrdOfferingName();
}
break;
}
} catch (PageExpiredException pee) {
}
errors.add(ClientConstants.ERRORS_DUPLICATE_OFFERING_SELECTED, new ActionMessage(ClientConstants.ERRORS_DUPLICATE_OFFERING_SELECTED, selectedOffering));
duplicateFound = true;
break;
}
}
if (duplicateFound) {
break;
}
}
}
use of org.mifos.dto.domain.SavingsDetailDto in project head by mifos.
the class WebTierAccountServiceFacade method getActiveSavingsAccountsForClientByLoanId.
@Override
public List<SavingsDetailDto> getActiveSavingsAccountsForClientByLoanId(Integer loanAccountId) {
try {
AccountBO account = accountBusinessService.getAccount(loanAccountId);
CustomerDto customer = account.getCustomer().toCustomerDto();
List<SavingsDetailDto> savingsInUse = clientServiceFacade.retrieveSavingsInUseForClient(customer.getCustomerId());
List<SavingsDetailDto> accountsForTransfer = new ArrayList<SavingsDetailDto>();
if (savingsInUse != null) {
for (SavingsDetailDto savingsAccount : savingsInUse) {
if (savingsAccount.getAccountStateId().equals(AccountState.SAVINGS_ACTIVE.getValue())) {
accountsForTransfer.add(savingsAccount);
}
}
}
return accountsForTransfer;
} catch (ServiceException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.dto.domain.SavingsDetailDto in project head by mifos.
the class WebTierAccountServiceFacade method getAccountPaymentInformation.
@Override
public AccountPaymentDto getAccountPaymentInformation(Integer accountId, String paymentType, Short localeId, UserReferenceDto userReferenceDto, Date paymentDate) {
try {
AccountBO account = accountBusinessService.getAccount(accountId);
CustomerDto customer = account.getCustomer().toCustomerDto();
List<SavingsDetailDto> savingsInUse = clientServiceFacade.retrieveSavingsInUseForClient(customer.getCustomerId());
List<SavingsDetailDto> accountsForTransfer = new ArrayList<SavingsDetailDto>();
if (savingsInUse != null) {
for (SavingsDetailDto savingsAccount : savingsInUse) {
if (savingsAccount.getAccountStateId().equals(AccountState.SAVINGS_ACTIVE.getValue())) {
accountsForTransfer.add(savingsAccount);
}
}
}
if (isLoanPayment(paymentType)) {
scheduleCalculatorAdaptor.computeExtraInterest((LoanBO) account, paymentDate);
}
UserReferenceDto accountUser = userReferenceDto;
if (account.getPersonnel() != null) {
accountUser = new UserReferenceDto(account.getPersonnel().getPersonnelId());
}
List<ListItem<Short>> paymentTypeList = constructPaymentTypeList(paymentType, localeId);
AccountTypeDto accountType = AccountTypeDto.getAccountType(account.getAccountType().getAccountTypeId());
Money totalPaymentDueMoney = account.getTotalPaymentDue();
String totalPaymentDue;
if (account instanceof LoanBO && totalPaymentDueMoney.isZero()) {
totalPaymentDue = ((LoanBO) account).getTotalRepayableAmount().toString();
} else {
totalPaymentDue = totalPaymentDueMoney.toString();
}
clearSessionAndRollback();
return new AccountPaymentDto(accountType, account.getVersionNo(), paymentTypeList, totalPaymentDue, accountUser, getLastPaymentDate(account), accountsForTransfer, customer);
} catch (ServiceException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.dto.domain.SavingsDetailDto in project head by mifos.
the class SavingsServiceFacadeWebTier method retrieveSavingsDetail.
@Override
public SavingsDetailDto retrieveSavingsDetail(String accountGlobalNum) {
SavingsBO savingsAcc = this.savingsDao.findBySystemId(accountGlobalNum);
SavingsDetailDto savingsDetailsDto = new SavingsDetailDto(savingsAcc.getGlobalAccountNum(), savingsAcc.getSavingsOffering().getPrdOfferingName(), savingsAcc.getAccountState().getId(), savingsAcc.getAccountState().getName(), savingsAcc.getSavingsBalance().toString());
return savingsDetailsDto;
}
Aggregations