Search in sources :

Example 26 with LoanBO

use of org.mifos.accounts.loan.business.LoanBO in project head by mifos.

the class LoanAccountActionStrutsTest method testUpdateSuccessWithoutRegeneratingNewRepaymentSchedule.

@Test
public void testUpdateSuccessWithoutRegeneratingNewRepaymentSchedule() throws Exception {
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    accountBO = getLoanAccount();
    LoanBO loan = (LoanBO) accountBO;
    LoanOfferingBO loanOffering = loan.getLoanOffering();
    Date firstInstallmentDate = loan.getDetailsOfNextInstallment().getActionDate();
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, loan, request);
    Date newDate = DateUtils.addWeeks(loan.getDisbursementDate(), 1);
    Date originalDate = loan.getDisbursementDate();
    setRequestPathInfo("/loanAccountAction.do");
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    addRequestParameter("method", "update");
    addRequestParameter("loanAmount", loanOffering.getEligibleLoanAmountSameForAllLoan().getDefaultLoanAmount().toString());
    addRequestParameter("interestRate", loan.getLoanOffering().getDefInterestRate().toString());
    addRequestParameter("noOfInstallments", loanOffering.getDefaultNumOfEligibleInstallmentsSameForAllLoan().toString());
    addRequestParameter("disbursementDate", DateUtils.format(newDate));
    addRequestParameter("businessActivityId", "1");
    addRequestParameter("intDedDisbursement", "0");
    addRequestParameter("gracePeriodDuration", "1");
    addRequestParameter("collateralNote", "test");
    actionPerform();
    verifyForward(ActionForwards.update_success.toString());
    loan = TestObjectFactory.getObject(LoanBO.class, loan.getAccountId());
    Assert.assertEquals("test", loan.getCollateralNote());
    Assert.assertEquals(300.0, loan.getLoanAmount().getAmount().doubleValue(), DELTA);
    Assert.assertEquals(1, loan.getGracePeriodDuration().intValue());
    Assert.assertEquals(DateUtils.format(originalDate), DateUtils.getUserLocaleDate(TestObjectFactory.getContext().getPreferredLocale(), DateUtils.toDatabaseFormat(loan.getDisbursementDate())));
    Assert.assertEquals(firstInstallmentDate, loan.getAccountActionDate(Short.valueOf("1")).getActionDate());
}
Also used : LoanBO(org.mifos.accounts.loan.business.LoanBO) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) Date(java.util.Date) Test(org.junit.Test)

Example 27 with LoanBO

use of org.mifos.accounts.loan.business.LoanBO in project head by mifos.

the class LegacyLoanDaoIntegrationTest method testFindBySystemId.

@Test
public void testFindBySystemId() throws Exception {
    LegacyLoanDao loanPersistance = legacyLoanDao;
    LoanBO loanBO = loanPersistance.findBySystemId(loanAccount.getGlobalAccountNum());
    Assert.assertEquals(loanAccount.getGlobalAccountNum(), loanBO.getGlobalAccountNum());
    Assert.assertEquals(loanAccount.getAccountId(), loanBO.getAccountId());
}
Also used : LoanBO(org.mifos.accounts.loan.business.LoanBO) LegacyLoanDao(org.mifos.accounts.loan.persistance.LegacyLoanDao) Test(org.junit.Test)

Example 28 with LoanBO

use of org.mifos.accounts.loan.business.LoanBO in project head by mifos.

the class LegacyLoanDaoIntegrationTest method testFindByExternalId.

@Test
public void testFindByExternalId() throws Exception {
    String externalId = "ABC";
    StaticHibernateUtil.startTransaction();
    loanAccount.setExternalId(externalId);
    StaticHibernateUtil.flushSession();
    LegacyLoanDao loanPersistance = legacyLoanDao;
    LoanBO loanBO = loanPersistance.findByExternalId(loanAccount.getExternalId());
    Assert.assertEquals(externalId, loanBO.getExternalId());
    Assert.assertEquals(loanAccount.getAccountId(), loanBO.getAccountId());
}
Also used : LoanBO(org.mifos.accounts.loan.business.LoanBO) LegacyLoanDao(org.mifos.accounts.loan.persistance.LegacyLoanDao) Test(org.junit.Test)

Example 29 with LoanBO

use of org.mifos.accounts.loan.business.LoanBO in project head by mifos.

the class LegacyLoanDaoIntegrationTest method testGetAccount.

@Test
public void testGetAccount() throws Exception {
    LoanBO loanBO = legacyLoanDao.getAccount(loanAccount.getAccountId());
    Assert.assertEquals(loanBO.getAccountId(), loanAccount.getAccountId());
}
Also used : LoanBO(org.mifos.accounts.loan.business.LoanBO) Test(org.junit.Test)

Example 30 with LoanBO

use of org.mifos.accounts.loan.business.LoanBO in project head by mifos.

the class LoanAccountActionIndividualLoansIntegrationTest method testShouldCallDeleteMethodIfExistingMembersRemoved.

@Test
public void testShouldCallDeleteMethodIfExistingMembersRemoved() throws Exception {
    GlimLoanUpdater glimLoanUpdaterMock = createMock(GlimLoanUpdater.class);
    LoanAccountAction loanAccountAction = new LoanAccountAction(ApplicationContextProvider.getBean(LoanBusinessService.class), new ConfigurationBusinessService(), glimLoanUpdaterMock);
    LoanBO loanMock = createMock(LoanBO.class);
    Locale locale = Locale.ENGLISH;
    expect(loanMock.getAccountId()).andReturn(2).anyTimes();
    ClientBO customerMock = createMock(ClientBO.class);
    expect(loanMock.getCustomer()).andReturn(customerMock).anyTimes();
    expect(customerMock.getGlobalCustNum()).andReturn("3").anyTimes();
    LoanAccountActionForm loanAccountActionForm = new LoanAccountActionForm();
    List<LoanAccountDetailsDto> clientDetails = new ArrayList<LoanAccountDetailsDto>();
    List<LoanBO> loans = new ArrayList<LoanBO>();
    loans.add(loanMock);
    glimLoanUpdaterMock.delete(loanMock);
    expectLastCall().atLeastOnce();
    replay(glimLoanUpdaterMock, loanMock, customerMock);
    loanAccountAction.handleIndividualLoans(loanMock, loanAccountActionForm, true, clientDetails, loans, locale);
    verify(glimLoanUpdaterMock, loanMock, customerMock);
}
Also used : Locale(java.util.Locale) LoanAccountActionForm(org.mifos.accounts.loan.struts.actionforms.LoanAccountActionForm) LoanBusinessService(org.mifos.accounts.loan.business.service.LoanBusinessService) LoanBO(org.mifos.accounts.loan.business.LoanBO) ClientBO(org.mifos.customers.client.business.ClientBO) ConfigurationBusinessService(org.mifos.config.business.service.ConfigurationBusinessService) ArrayList(java.util.ArrayList) LoanAccountDetailsDto(org.mifos.dto.domain.LoanAccountDetailsDto) Test(org.junit.Test)

Aggregations

LoanBO (org.mifos.accounts.loan.business.LoanBO)215 ArrayList (java.util.ArrayList)76 Test (org.junit.Test)62 Money (org.mifos.framework.util.helpers.Money)60 UserContext (org.mifos.security.util.UserContext)45 MifosRuntimeException (org.mifos.core.MifosRuntimeException)42 Date (java.util.Date)37 AccountException (org.mifos.accounts.exceptions.AccountException)35 AccountBO (org.mifos.accounts.business.AccountBO)34 MifosUser (org.mifos.security.MifosUser)33 BigDecimal (java.math.BigDecimal)30 HashMap (java.util.HashMap)28 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)26 LocalDate (org.joda.time.LocalDate)23 PaymentData (org.mifos.accounts.util.helpers.PaymentData)22 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)22 PersistenceException (org.mifos.framework.exceptions.PersistenceException)21 ServiceException (org.mifos.framework.exceptions.ServiceException)19 BusinessRuleException (org.mifos.service.BusinessRuleException)19 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)18