Search in sources :

Example 61 with AccountBO

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

the class ClientServiceFacadeWebTier method convertFeeViewsToAccountFeeEntities.

private List<AccountFeesEntity> convertFeeViewsToAccountFeeEntities(List<ApplicableAccountFeeDto> feesToApply) {
    List<AccountFeesEntity> feesForCustomerAccount = new ArrayList<AccountFeesEntity>();
    for (ApplicableAccountFeeDto feeDto : feesToApply) {
        FeeBO fee = this.feeDao.findById(feeDto.getFeeId().shortValue());
        Double feeAmount = new LocalizationConverter().getDoubleValueForCurrentLocale(feeDto.getAmount());
        AccountBO nullReferenceForNow = null;
        AccountFeesEntity accountFee = new AccountFeesEntity(nullReferenceForNow, fee, feeAmount);
        feesForCustomerAccount.add(accountFee);
    }
    return feesForCustomerAccount;
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) LocalizationConverter(org.mifos.framework.util.LocalizationConverter) ArrayList(java.util.ArrayList) FeeBO(org.mifos.accounts.fees.business.FeeBO) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto)

Example 62 with AccountBO

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

the class ClientServiceFacadeWebTier method getClientAccountPayments.

@Override
public List<AccountPaymentDto> getClientAccountPayments(String globalAccountNum) {
    List<AccountPaymentDto> clientAccountPayments = new ArrayList<AccountPaymentDto>();
    try {
        AccountBO account = legacyAccountDao.findBySystemId(globalAccountNum);
        List<AccountPaymentEntity> clientAccountPaymentsEntities = account.getAccountPayments();
        for (AccountPaymentEntity accountPaymentEntity : clientAccountPaymentsEntities) {
            clientAccountPayments.add(accountPaymentEntity.toScreenDto());
        }
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
    return clientAccountPayments;
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) ArrayList(java.util.ArrayList) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) PersistenceException(org.mifos.framework.exceptions.PersistenceException) AccountPaymentDto(org.mifos.dto.screen.AccountPaymentDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 63 with AccountBO

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

the class CenterServiceFacadeWebTier method retrieveAccountTransactionHistory.

@Override
public List<TransactionHistoryDto> retrieveAccountTransactionHistory(String globalAccountNum) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    try {
        AccountBO account = new AccountBusinessService().findBySystemId(globalAccountNum);
        CustomerBO customerBO = account.getCustomer();
        account.updateDetails(userContext);
        personnelDao.checkAccessPermission(userContext, customerBO.getOfficeId(), customerBO.getLoanOfficerId());
        List<TransactionHistoryDto> transactionHistories = account.getTransactionHistoryView();
        for (TransactionHistoryDto transactionHistoryDto : transactionHistories) {
            transactionHistoryDto.setUserPrefferedPostedDate(DateUtils.getUserLocaleDate(userContext.getPreferredLocale(), transactionHistoryDto.getPostedDate().toString()));
            transactionHistoryDto.setUserPrefferedTransactionDate(DateUtils.getUserLocaleDate(userContext.getPreferredLocale(), transactionHistoryDto.getTransactionDate().toString()));
        }
        return transactionHistories;
    } catch (ServiceException e) {
        throw new MifosRuntimeException(e);
    } catch (AccountException e) {
        throw new MifosRuntimeException("Access denied!", e);
    }
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) AccountBusinessService(org.mifos.accounts.business.service.AccountBusinessService) ServiceException(org.mifos.framework.exceptions.ServiceException) AccountException(org.mifos.accounts.exceptions.AccountException) UserContext(org.mifos.security.util.UserContext) CustomerBO(org.mifos.customers.business.CustomerBO) MifosUser(org.mifos.security.MifosUser) TransactionHistoryDto(org.mifos.dto.screen.TransactionHistoryDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 64 with AccountBO

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

the class CenterServiceFacadeWebTier method retrieveAllClosedAccounts.

@Override
public List<ClosedAccountDto> retrieveAllClosedAccounts(Integer customerId) {
    List<ClosedAccountDto> closedAccounts = new ArrayList<ClosedAccountDto>();
    List<AccountBO> allClosedAccounts = this.customerDao.retrieveAllClosedLoanAndSavingsAccounts(customerId);
    for (AccountBO account : allClosedAccounts) {
        LocalDate closedDate = new LocalDate(account.getClosedDate());
        ClosedAccountDto closedAccount = new ClosedAccountDto(account.getAccountId(), account.getGlobalAccountNum(), account.getType().getValue().intValue(), account.getState().getValue().intValue(), closedDate);
        closedAccounts.add(closedAccount);
    }
    return closedAccounts;
}
Also used : ClosedAccountDto(org.mifos.dto.screen.ClosedAccountDto) AccountBO(org.mifos.accounts.business.AccountBO) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) ArrayList(java.util.ArrayList) LocalDate(org.joda.time.LocalDate)

Example 65 with AccountBO

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

the class ApplyAdjustment method listPossibleAdjustments.

@TransactionDemarcate(joinToken = true)
public ActionForward listPossibleAdjustments(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ApplyAdjustmentActionForm appAdjustActionForm = (ApplyAdjustmentActionForm) form;
    this.resetActionFormFields(appAdjustActionForm);
    AccountBO accnt = getBizService().findBySystemId(appAdjustActionForm.getGlobalAccountNum());
    boolean decliningRecalculation = false;
    if (accnt instanceof LoanBO) {
        LoanBO loan = (LoanBO) accnt;
        if (loan.getInterestType().getId().equals(InterestType.DECLINING_PB.getValue())) {
            decliningRecalculation = true;
        }
    }
    List<AccountPaymentEntity> payments = accnt.getAccountPayments();
    ArrayList<AdjustablePaymentDto> adjustablePayments = new ArrayList<AdjustablePaymentDto>();
    int i = 1;
    for (AccountPaymentEntity payment : payments) {
        //ommit disbursal payment
        if (!payment.getAmount().equals(Money.zero()) && i != payments.size()) {
            AdjustablePaymentDto adjustablePaymentDto = new AdjustablePaymentDto(payment.getPaymentId(), payment.getAmount(), payment.getPaymentType().getName(), payment.getPaymentDate(), payment.getReceiptDate(), payment.getReceiptNumber());
            adjustablePayments.add(adjustablePaymentDto);
            if (decliningRecalculation) {
                //only last payment
                break;
            }
        }
        i++;
    }
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, accnt, request);
    SessionUtils.setAttribute(Constants.POSSIBLE_ADJUSTMENTS, adjustablePayments, request);
    request.setAttribute("method", "loadAdjustment");
    return mapping.findForward("loadadjustments_success");
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) ApplyAdjustmentActionForm(org.mifos.accounts.struts.actionforms.ApplyAdjustmentActionForm) AdjustablePaymentDto(org.mifos.accounts.business.AdjustablePaymentDto) LoanBO(org.mifos.accounts.loan.business.LoanBO) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) ArrayList(java.util.ArrayList) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

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