Search in sources :

Example 21 with CustomerAccountBO

use of org.mifos.customers.business.CustomerAccountBO in project head by mifos.

the class GroupBO method regenerateCustomerFeeSchedule.

public void regenerateCustomerFeeSchedule(CalendarEvent applicableCalendarEvents) {
    CustomerAccountBO customerAccount = this.getCustomerAccount();
    if (customerAccount != null) {
        List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>(customerAccount.getAccountFees());
        customerAccount.createSchedulesAndFeeSchedulesForFirstTimeActiveCustomer(this, accountFees, this.getCustomerMeetingValue(), applicableCalendarEvents, new DateMidnight().toDateTime());
    }
}
Also used : CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) DateMidnight(org.joda.time.DateMidnight) ArrayList(java.util.ArrayList) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity)

Example 22 with CustomerAccountBO

use of org.mifos.customers.business.CustomerAccountBO in project head by mifos.

the class CustomerDaoHibernate method getCustomerAccountSummaryDto.

@Override
public CustomerAccountSummaryDto getCustomerAccountSummaryDto(Integer customerId) {
    final HashMap<String, Object> queryParameters = new HashMap<String, Object>();
    queryParameters.put("customerId", customerId);
    CustomerAccountBO customerAccount = (CustomerAccountBO) genericDao.executeUniqueResultNamedQuery("customer.viewCustomerAccount", queryParameters);
    return new CustomerAccountSummaryDto(customerAccount.getGlobalAccountNum(), customerAccount.getTotalPaymentDue().toString());
}
Also used : CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) HashMap(java.util.HashMap) CustomerAccountSummaryDto(org.mifos.dto.domain.CustomerAccountSummaryDto)

Example 23 with CustomerAccountBO

use of org.mifos.customers.business.CustomerAccountBO in project head by mifos.

the class StandardAccountService method makeImportedPayments.

/**
     * method created for undo transaction import ability MIFOS-5702
     * returns Id of transaction  
     * */
public AccountBO makeImportedPayments(AccountPaymentParametersDto accountPaymentParametersDto, Integer savingsPaymentId) throws PersistenceException, AccountException {
    final int accountId = accountPaymentParametersDto.getAccountId();
    final AccountBO account = this.legacyAccountDao.getAccount(accountId);
    MifosUser mifosUser = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = new UserContextFactory().create(mifosUser);
    try {
        personnelDao.checkAccessPermission(userContext, account.getOfficeId(), account.getCustomer().getLoanOfficerId());
    } catch (AccountException e) {
        throw new MifosRuntimeException(SecurityConstants.KEY_ACTIVITY_NOT_ALLOWED, e);
    }
    monthClosingServiceFacade.validateTransactionDate(accountPaymentParametersDto.getPaymentDate().toDateMidnight().toDate());
    /**
         * Handle member payment if parent payment data not provided.
         * Situation may occur when payment is executed directly on group member account (e.g. from transaction import).
         * Loan Group Member payments should be posted after parent payment.
         */
    if (account.isGroupLoanAccountMember()) {
        AccountPaymentParametersDto parentPaymentParametersDto = this.createParentLoanPaymentData(account, accountPaymentParametersDto);
        return makeImportedPayments(parentPaymentParametersDto, savingsPaymentId);
    }
    PersonnelBO loggedInUser = ApplicationContextProvider.getBean(LegacyPersonnelDao.class).findPersonnelById(accountPaymentParametersDto.getUserMakingPayment().getUserId());
    List<InvalidPaymentReason> validationErrors = validatePayment(accountPaymentParametersDto);
    if (!(account instanceof CustomerAccountBO) && validationErrors.contains(InvalidPaymentReason.INVALID_DATE)) {
        throw new AccountException("errors.invalidTxndate");
    }
    Money overpaymentAmount = null;
    Money amount = new Money(account.getCurrency(), accountPaymentParametersDto.getPaymentAmount());
    if (account instanceof LoanBO && accountPaymentParametersDto.getPaymentOptions().contains(AccountPaymentParametersDto.PaymentOptions.ALLOW_OVERPAYMENTS) && amount.isGreaterThan(((LoanBO) account).getTotalRepayableAmount())) {
        overpaymentAmount = amount.subtract(((LoanBO) account).getTotalRepayableAmount());
        amount = ((LoanBO) account).getTotalRepayableAmount();
    }
    Date receiptDate = null;
    if (accountPaymentParametersDto.getReceiptDate() != null) {
        receiptDate = accountPaymentParametersDto.getReceiptDate().toDateMidnight().toDate();
    }
    PaymentData paymentData = account.createPaymentData(amount, accountPaymentParametersDto.getPaymentDate().toDateMidnight().toDate(), accountPaymentParametersDto.getReceiptId(), receiptDate, accountPaymentParametersDto.getPaymentType().getValue(), loggedInUser);
    if (savingsPaymentId != null) {
        AccountPaymentEntity withdrawal = legacyAccountDao.findPaymentById(savingsPaymentId);
        paymentData.setOtherTransferPayment(withdrawal);
    }
    if (accountPaymentParametersDto.getCustomer() != null) {
        paymentData.setCustomer(customerDao.findCustomerById(accountPaymentParametersDto.getCustomer().getCustomerId()));
    }
    paymentData.setComment(accountPaymentParametersDto.getComment());
    paymentData.setOverpaymentAmount(overpaymentAmount);
    if (accountPaymentParametersDto.getPaymentOptions().contains(PaymentOptions.ALLOW_OVERPAYMENTS)) {
        paymentData.setAllowOverpayment(true);
    }
    AccountPaymentEntity paymentEntity = account.applyPayment(paymentData);
    handleParentGroupLoanPayment(account, accountPaymentParametersDto, savingsPaymentId, paymentEntity);
    this.legacyAccountDao.createOrUpdate(account);
    /*
         * Return null when only overpayment is being apply
         */
    if (amount.isZero() && overpaymentAmount != null && overpaymentAmount.isGreaterThanZero()) {
        return null;
    }
    return account;
}
Also used : CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) PaymentData(org.mifos.accounts.util.helpers.PaymentData) UserContext(org.mifos.security.util.UserContext) LoanBO(org.mifos.accounts.loan.business.LoanBO) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) MifosUser(org.mifos.security.MifosUser) UserContextFactory(org.mifos.accounts.servicefacade.UserContextFactory) LegacyPersonnelDao(org.mifos.customers.personnel.persistence.LegacyPersonnelDao) AccountPaymentParametersDto(org.mifos.dto.domain.AccountPaymentParametersDto) Date(java.util.Date) LocalDate(org.joda.time.LocalDate) AccountBO(org.mifos.accounts.business.AccountBO) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) Money(org.mifos.framework.util.helpers.Money) AccountException(org.mifos.accounts.exceptions.AccountException) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 24 with CustomerAccountBO

use of org.mifos.customers.business.CustomerAccountBO in project head by mifos.

the class ApplyChargeAction method update.

@TransactionDemarcate(validateAndResetToken = true)
public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ApplyChargeActionForm applyChargeActionForm = (ApplyChargeActionForm) form;
    Short feeId = Short.valueOf(applyChargeActionForm.getFeeId());
    Double chargeAmount = 0.0;
    AccountBO account = new AccountBusinessService().getAccount(Integer.valueOf(applyChargeActionForm.getAccountId()));
    if (!(account instanceof CustomerAccountBO) && null == ((LoanBO) account).getParentAccount() && account.isGroupLoanAccount()) {
        this.accountServiceFacade.applyGroupCharge(applyChargeActionForm.getIndividualValues(), feeId, applyChargeActionForm.isPenaltyType());
    } else {
        chargeAmount = getDoubleValue(request.getParameter("charge"));
        this.accountServiceFacade.applyCharge(account.getAccountId(), feeId, chargeAmount, applyChargeActionForm.isPenaltyType());
    }
    AccountTypeCustomerLevelDto accountTypeCustomerLevel = accountServiceFacade.getAccountTypeCustomerLevelDto(account.getAccountId());
    return mapping.findForward(getDetailAccountPage(accountTypeCustomerLevel));
}
Also used : AccountTypeCustomerLevelDto(org.mifos.dto.screen.AccountTypeCustomerLevelDto) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) AccountBO(org.mifos.accounts.business.AccountBO) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) AccountBusinessService(org.mifos.accounts.business.service.AccountBusinessService) ApplyChargeActionForm(org.mifos.accounts.struts.actionforms.ApplyChargeActionForm) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 25 with CustomerAccountBO

use of org.mifos.customers.business.CustomerAccountBO in project head by mifos.

the class CustomerServiceImpl method handleChangeOfClientStatusToClosedOrCancelled.

private void handleChangeOfClientStatusToClosedOrCancelled(ClientBO client, CustomerStatusFlag customerStatusFlag, CustomerNoteEntity customerNote, PersonnelBO loggedInUser) throws AccountException {
    if (client.isClosedOrCancelled()) {
        if (client.isClientUnderGroup()) {
            CustomerBO parentCustomer = client.getParentCustomer();
            client.resetPositions(parentCustomer);
            parentCustomer.setUserContext(client.getUserContext());
            CustomerBO center = parentCustomer.getParentCustomer();
            if (center != null) {
                parentCustomer.resetPositions(center);
                center.setUserContext(client.getUserContext());
            }
        }
        CustomerAccountBO customerAccount = client.getCustomerAccount();
        if (customerAccount.isOpen()) {
            customerAccount.setUserContext(client.getUserContext());
            customerAccount.changeStatus(AccountState.CUSTOMER_ACCOUNT_INACTIVE, customerStatusFlag.getValue(), customerNote.getComment(), loggedInUser);
            customerAccount.update();
        }
    }
}
Also used : CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) CustomerBO(org.mifos.customers.business.CustomerBO)

Aggregations

CustomerAccountBO (org.mifos.customers.business.CustomerAccountBO)36 ArrayList (java.util.ArrayList)15 Test (org.junit.Test)15 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)15 MeetingBO (org.mifos.application.meeting.business.MeetingBO)12 DateTime (org.joda.time.DateTime)11 LocalDate (org.joda.time.LocalDate)11 AccountBO (org.mifos.accounts.business.AccountBO)10 CenterBuilder (org.mifos.domain.builders.CenterBuilder)10 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)10 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)9 CenterBO (org.mifos.customers.center.business.CenterBO)8 CalendarEventBuilder (org.mifos.domain.builders.CalendarEventBuilder)8 MifosRuntimeException (org.mifos.core.MifosRuntimeException)7 GroupBO (org.mifos.customers.group.business.GroupBO)7 GroupBuilder (org.mifos.domain.builders.GroupBuilder)7 AccountException (org.mifos.accounts.exceptions.AccountException)6 LoanBO (org.mifos.accounts.loan.business.LoanBO)6 UserContext (org.mifos.security.util.UserContext)6 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)5