Search in sources :

Example 76 with SavingsBO

use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.

the class SavingsAction method create.

@TransactionDemarcate(validateAndResetToken = true)
public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    SavingsActionForm savingsActionForm = ((SavingsActionForm) form);
    logger.debug("In SavingsAction::create(), accountStateId: " + savingsActionForm.getStateSelected());
    UserContext uc = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
    CustomerBO customer = (CustomerBO) SessionUtils.getAttribute(SavingsConstants.CLIENT, request);
    Integer customerId = customer.getCustomerId();
    Integer productId = Integer.valueOf(savingsActionForm.getSelectedPrdOfferingId());
    String recommendedOrMandatoryAmount = savingsActionForm.getRecommendedAmount();
    Short accountState = Short.valueOf(savingsActionForm.getStateSelected());
    customer = this.customerDao.findCustomerById(customerId);
    checkPermissionForCreate(accountState, uc, customer.getOffice().getOfficeId(), customer.getPersonnel().getPersonnelId());
    SavingsAccountCreationDto savingsAccountCreation = new SavingsAccountCreationDto(productId, customerId, accountState, recommendedOrMandatoryAmount);
    Long savingsId = this.savingsServiceFacade.createSavingsAccount(savingsAccountCreation);
    SavingsBO saving = this.savingsDao.findById(savingsId);
    createGroupQuestionnaire.saveResponses(request, savingsActionForm, saving.getAccountId());
    request.setAttribute(SavingsConstants.GLOBALACCOUNTNUM, saving.getGlobalAccountNum());
    request.setAttribute(SavingsConstants.RECORD_OFFICE_ID, saving.getOffice().getOfficeId());
    request.setAttribute(SavingsConstants.CLIENT_NAME, customer.getDisplayName());
    request.setAttribute(SavingsConstants.CLIENT_ID, customer.getCustomerId());
    request.setAttribute(SavingsConstants.CLIENT_LEVEL, customer.getCustomerLevel().getId());
    logger.info("In SavingsAction::create(), Savings object saved successfully ");
    return mapping.findForward("create_success");
}
Also used : SavingsActionForm(org.mifos.accounts.savings.struts.actionforms.SavingsActionForm) UserContext(org.mifos.security.util.UserContext) CustomerBO(org.mifos.customers.business.CustomerBO) SavingsAccountCreationDto(org.mifos.dto.domain.SavingsAccountCreationDto) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 77 with SavingsBO

use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.

the class SavingsAction method waiveAmountDue.

@TransactionDemarcate(joinToken = true)
public ActionForward waiveAmountDue(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    logger.debug("In SavingsAction::waiveAmountDue()");
    UserContext uc = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
    SavingsBO savings = (SavingsBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    Integer versionNum = savings.getVersionNo();
    savings = this.savingsDao.findBySystemId(((SavingsActionForm) form).getGlobalAccountNum());
    checkVersionMismatch(versionNum, savings.getVersionNo());
    savings.setUserContext(uc);
    Long savingsId = savings.getAccountId().longValue();
    this.savingsServiceFacade.waiveNextDepositAmountDue(savingsId);
    return mapping.findForward("waiveAmount_success");
}
Also used : SavingsActionForm(org.mifos.accounts.savings.struts.actionforms.SavingsActionForm) UserContext(org.mifos.security.util.UserContext) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 78 with SavingsBO

use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.

the class AccountRegenerateScheduleIntegrationTestCase method validateSchedules.

private void validateSchedules(List<LocalDate> expectedMeetingDates, List<LocalDate> expectedLoanMeetingDates) {
    center = TestObjectFactory.getCenter(center.getCustomerId());
    accountBO = TestObjectFactory.getObject(LoanBO.class, accountBO.getAccountId());
    savingsBO = TestObjectFactory.getObject(SavingsBO.class, savingsBO.getAccountId());
    int count = 0;
    for (AccountActionDateEntity actionDateEntity : center.getCustomerAccount().getAccountActionDates()) {
        if (count < expectedMeetingDates.size()) {
            checkScheduleDates(expectedMeetingDates.get(count), actionDateEntity);
        }
        ++count;
    }
    log("---");
    org.junit.Assert.assertEquals(numberOfLoanInstallments, (accountBO.getAccountActionDates().size()));
    count = 0;
    for (AccountActionDateEntity actionDateEntity : accountBO.getAccountActionDates()) {
        if (count < expectedLoanMeetingDates.size()) {
            checkScheduleDates(expectedLoanMeetingDates.get(count), actionDateEntity);
        }
        ++count;
    }
    log("+++");
    count = 0;
    for (AccountActionDateEntity actionDateEntity : savingsBO.getAccountActionDates()) {
        if (count < expectedLoanMeetingDates.size()) {
            checkScheduleDates(expectedLoanMeetingDates.get(count), actionDateEntity);
        }
        ++count;
    }
    log("===");
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) LoanBO(org.mifos.accounts.loan.business.LoanBO) SavingsBO(org.mifos.accounts.savings.business.SavingsBO)

Example 79 with SavingsBO

use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.

the class AccountRegenerateScheduleIntegrationTestCase method validateSchedulesForClosedAndCancelled.

private void validateSchedulesForClosedAndCancelled(List<LocalDate> expectedMeetingDates, List<LocalDate> expectedLoanMeetingDates) {
    center = TestObjectFactory.getCenter(center.getCustomerId());
    accountBO = TestObjectFactory.getObject(LoanBO.class, accountBO.getAccountId());
    savingsBO = TestObjectFactory.getObject(SavingsBO.class, savingsBO.getAccountId());
    int count = 0;
    for (AccountActionDateEntity actionDateEntity : group.getCustomerAccount().getAccountActionDates()) {
        if (count < expectedMeetingDates.size()) {
            checkScheduleDates(expectedMeetingDates.get(count), actionDateEntity);
        }
        ++count;
    }
    log("---");
    count = 0;
    for (AccountActionDateEntity actionDateEntity : accountBO.getAccountActionDates()) {
        if (count < expectedLoanMeetingDates.size()) {
            checkScheduleDates(expectedLoanMeetingDates.get(count), actionDateEntity);
        }
        ++count;
    }
    log("+++");
    count = 0;
    for (AccountActionDateEntity actionDateEntity : savingsBO.getAccountActionDates()) {
        if (count < expectedLoanMeetingDates.size()) {
            checkScheduleDates(expectedLoanMeetingDates.get(count), actionDateEntity);
        }
        ++count;
    }
    log("===");
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) LoanBO(org.mifos.accounts.loan.business.LoanBO) SavingsBO(org.mifos.accounts.savings.business.SavingsBO)

Example 80 with SavingsBO

use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.

the class TestCollectionSheetRetrieveSavingsAccountsUtils method createSavingsAccount.

public SavingsBO createSavingsAccount(CustomerBO customer, String shortName, String amount, boolean isVoluntary, boolean isPerIndividual) {
    // johnw - unfortunately, in the current builder code, the settings for mandatory/voluntary and
    // complete_group/per_individual are set at savings account level rather than at savings offering level as in
    // the production system.  However, this method creates a good savings account
    SavingsProductBuilder savingsProductBuilder = new SavingsProductBuilder().withName(customer.getDisplayName()).withShortName(shortName);
    if (customer.getCustomerLevel().getId().compareTo(CustomerLevel.CENTER.getValue()) == 0) {
        savingsProductBuilder.appliesToCentersOnly();
    }
    if (customer.getCustomerLevel().getId().compareTo(CustomerLevel.GROUP.getValue()) == 0) {
        savingsProductBuilder.appliesToGroupsOnly();
    }
    if (customer.getCustomerLevel().getId().compareTo(CustomerLevel.CLIENT.getValue()) == 0) {
        savingsProductBuilder.appliesToClientsOnly();
    }
    SavingsOfferingBO savingsProduct = savingsProductBuilder.mandatory().withInterestRate(Double.valueOf("4.0")).buildForIntegrationTests();
    if (isVoluntary) {
        savingsProductBuilder.voluntary();
    }
    SavingsAccountBuilder savingsAccountBuilder = new SavingsAccountBuilder().withSavingsProduct(savingsProduct).withCustomer(customer).withCreatedBy(IntegrationTestObjectMother.testUser()).completeGroup().withRecommendedAmount(TestUtils.createMoney(amount));
    if (isPerIndividual) {
        savingsAccountBuilder.perIndividual();
    }
    SavingsBO savingsAccount = null;
    if (customer.getCustomerLevel().getId().compareTo(CustomerLevel.CENTER.getValue()) == 0) {
        savingsAccount = savingsAccountBuilder.buildJointSavingsAccount();
    } else {
        savingsAccount = savingsAccountBuilder.build();
    }
    IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(savingsProduct, savingsAccount);
    return savingsAccount;
}
Also used : SavingsProductBuilder(org.mifos.domain.builders.SavingsProductBuilder) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder)

Aggregations

SavingsBO (org.mifos.accounts.savings.business.SavingsBO)111 UserContext (org.mifos.security.util.UserContext)43 MifosRuntimeException (org.mifos.core.MifosRuntimeException)30 AccountException (org.mifos.accounts.exceptions.AccountException)28 LocalDate (org.joda.time.LocalDate)27 MifosUser (org.mifos.security.MifosUser)26 Test (org.junit.Test)25 Money (org.mifos.framework.util.helpers.Money)24 ArrayList (java.util.ArrayList)22 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)22 PersistenceException (org.mifos.framework.exceptions.PersistenceException)22 Date (java.util.Date)20 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)19 BusinessRuleException (org.mifos.service.BusinessRuleException)18 SavingsOfferingBO (org.mifos.accounts.productdefinition.business.SavingsOfferingBO)17 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)17 CustomerBO (org.mifos.customers.business.CustomerBO)15 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)14 ServiceException (org.mifos.framework.exceptions.ServiceException)13 InvalidDateException (org.mifos.application.admin.servicefacade.InvalidDateException)12