Search in sources :

Example 1 with SavingsDetailDto

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);
}
Also used : Money(org.mifos.framework.util.helpers.Money) SavingsDetailDto(org.mifos.dto.domain.SavingsDetailDto) AccountException(org.mifos.accounts.exceptions.AccountException) UserContext(org.mifos.security.util.UserContext) RepayLoanDto(org.mifos.dto.screen.RepayLoanDto) LoanBO(org.mifos.accounts.loan.business.LoanBO) ArrayList(java.util.ArrayList) MifosUser(org.mifos.security.MifosUser) UserContextFactory(org.mifos.accounts.servicefacade.UserContextFactory) RepaymentResultsHolder(org.mifos.accounts.loan.business.RepaymentResultsHolder) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 2 with SavingsDetailDto

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;
        }
    }
}
Also used : SavingsDetailDto(org.mifos.dto.domain.SavingsDetailDto) PageExpiredException(org.mifos.framework.exceptions.PageExpiredException) ActionMessage(org.apache.struts.action.ActionMessage) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with SavingsDetailDto

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);
    }
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) SavingsDetailDto(org.mifos.dto.domain.SavingsDetailDto) ServiceException(org.mifos.framework.exceptions.ServiceException) CustomerDto(org.mifos.dto.domain.CustomerDto) ArrayList(java.util.ArrayList) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 4 with SavingsDetailDto

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);
    }
}
Also used : SavingsDetailDto(org.mifos.dto.domain.SavingsDetailDto) LoanBO(org.mifos.accounts.loan.business.LoanBO) CustomerDto(org.mifos.dto.domain.CustomerDto) ArrayList(java.util.ArrayList) UserReferenceDto(org.mifos.dto.domain.UserReferenceDto) AccountBO(org.mifos.accounts.business.AccountBO) Money(org.mifos.framework.util.helpers.Money) ServiceException(org.mifos.framework.exceptions.ServiceException) ListItem(org.mifos.application.servicefacade.ListItem) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 5 with SavingsDetailDto

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;
}
Also used : SavingsDetailDto(org.mifos.dto.domain.SavingsDetailDto) SavingsBO(org.mifos.accounts.savings.business.SavingsBO)

Aggregations

SavingsDetailDto (org.mifos.dto.domain.SavingsDetailDto)20 ArrayList (java.util.ArrayList)17 MeetingBO (org.mifos.application.meeting.business.MeetingBO)8 MifosRuntimeException (org.mifos.core.MifosRuntimeException)8 List (java.util.List)7 MifosUser (org.mifos.security.MifosUser)7 Date (java.util.Date)6 UserContext (org.mifos.security.util.UserContext)6 Test (org.junit.Test)5 AccountBO (org.mifos.accounts.business.AccountBO)5 AccountException (org.mifos.accounts.exceptions.AccountException)5 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)5 LocalDate (org.joda.time.LocalDate)4 BusinessActivityEntity (org.mifos.application.master.business.BusinessActivityEntity)4 AddressDto (org.mifos.dto.domain.AddressDto)4 CustomerAddressDto (org.mifos.dto.domain.CustomerAddressDto)4 CustomerDetailsDto (org.mifos.dto.domain.CustomerDetailsDto)4 CustomerMeetingDto (org.mifos.dto.domain.CustomerMeetingDto)4 MeetingDto (org.mifos.dto.domain.MeetingDto)4 ClientNameDetailDto (org.mifos.dto.screen.ClientNameDetailDto)4