Search in sources :

Example 51 with SavingsOfferingBO

use of org.mifos.accounts.productdefinition.business.SavingsOfferingBO in project head by mifos.

the class ClientCreationTest method throwsCheckedExceptionWhenValidationForDuplicateNameOrGovernmentId.

@Test(expected = CustomerException.class)
public void throwsCheckedExceptionWhenValidationForDuplicateNameOrGovernmentId() throws Exception {
    String displayName = "Test Name";
    Date dob = new Date();
    String govtId = "44354323543";
    // setup
    List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>();
    List<SavingsOfferingBO> noSavings = new ArrayList<SavingsOfferingBO>();
    // stubbing
    Mockito.when(mockedClient.getDisplayName()).thenReturn(displayName);
    Mockito.when(mockedClient.getDateOfBirth()).thenReturn(dob);
    Mockito.when(mockedClient.getGovernmentId()).thenReturn(govtId);
    doThrow(new CustomerException(CustomerConstants.DUPLICATE_GOVT_ID_EXCEPTION)).when(customerDao).validateClientForDuplicateNameOrGovtId(displayName, dob, govtId);
    // exercise test
    customerService.createClient(mockedClient, meeting, accountFees, noSavings);
    // verify
    verify(customerDao).validateClientForDuplicateNameOrGovtId(mockedClient.getDisplayName(), mockedClient.getDateOfBirth(), mockedClient.getGovernmentId());
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) ArrayList(java.util.ArrayList) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Date(java.util.Date) Test(org.junit.Test)

Example 52 with SavingsOfferingBO

use of org.mifos.accounts.productdefinition.business.SavingsOfferingBO in project head by mifos.

the class ClientCreationTest method throwsCheckedExceptionWhenClientValidationFails.

@Test(expected = CustomerException.class)
public void throwsCheckedExceptionWhenClientValidationFails() throws Exception {
    // setup
    List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>();
    List<SavingsOfferingBO> noSavings = new ArrayList<SavingsOfferingBO>();
    // stubbing
    doThrow(new CustomerException(ClientConstants.ERRORS_GROUP_CANCELLED)).when(mockedClient).validate();
    // exercise test
    customerService.createClient(mockedClient, meeting, accountFees, noSavings);
    // verify
    verify(mockedClient).validate();
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) ArrayList(java.util.ArrayList) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Test(org.junit.Test)

Example 53 with SavingsOfferingBO

use of org.mifos.accounts.productdefinition.business.SavingsOfferingBO in project head by mifos.

the class SavingsAccountSchedulesIntegrationTest method shouldNotGenerateSavingsAccountSchedulesForGroupWithoutActiveClients.

@Test
public void shouldNotGenerateSavingsAccountSchedulesForGroupWithoutActiveClients() throws Exception {
    createCenterAndGroupHierarchyWithNoClients(aWeeklyMeeting);
    SavingsOfferingBO savingsProduct = new SavingsProductBuilder().mandatory().withMandatoryAmount("33.0").appliesToGroupsOnly().trackedPerIndividual().buildForIntegrationTests();
    SavingsBO savingsAccount = new SavingsAccountBuilder().active().withActivationDate(mondayTwoWeeksAgo()).withSavingsProduct(savingsProduct).withCustomer(group).withCreatedBy(IntegrationTestObjectMother.testUser()).buildJointSavingsAccount();
    IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(savingsProduct, savingsAccount);
    List<AccountActionDateEntity> savingSchedules = savingsAccount.getAccountActionDatesSortedByInstallmentId();
    assertTrue(savingSchedules.isEmpty());
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) 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) Test(org.junit.Test)

Example 54 with SavingsOfferingBO

use of org.mifos.accounts.productdefinition.business.SavingsOfferingBO in project head by mifos.

the class SavingsBOIntegrationTest method testGetOverDueDepositAmountForVoluntaryAccounts.

@Test
public void testGetOverDueDepositAmountForVoluntaryAccounts() throws Exception {
    MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
    SavingsOfferingBO savingsOffering = helper.createSavingsOffering("dfasdasd1", "sad1");
    center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
    client1 = TestObjectFactory.createClient("Client", CustomerStatus.CLIENT_ACTIVE, group);
    savings = TestObjectFactory.createSavingsAccount("43245434", client1, Short.valueOf("16"), new Date(System.currentTimeMillis()), savingsOffering);
    Session session = StaticHibernateUtil.getSessionTL();
    StaticHibernateUtil.startTransaction();
    SavingsScheduleEntity accountActionDate = (SavingsScheduleEntity) savings.getAccountActionDate((short) 1);
    accountActionDate.setDepositPaid(TestUtils.createMoney("100.0"));
    session.update(savings);
    StaticHibernateUtil.flushSession();
    Assert.assertEquals(getRoundedMoney(0.00), savings.getOverDueDepositAmount(accountActionDate.getActionDate()));
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) Date(java.util.Date) Session(org.hibernate.Session) Test(org.junit.Test)

Example 55 with SavingsOfferingBO

use of org.mifos.accounts.productdefinition.business.SavingsOfferingBO in project head by mifos.

the class SavingsBOIntegrationTest method testGetOverDueDepositAmountForMandatoryAccounts.

@Test
public void testGetOverDueDepositAmountForMandatoryAccounts() throws Exception {
    MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
    MeetingBO meetingIntCalc = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
    MeetingBO meetingIntPost = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
    SavingsOfferingBO savingsOffering = TestObjectFactory.createSavingsProduct("SavingPrd1", ApplicableTo.GROUPS, new Date(System.currentTimeMillis()), PrdStatus.SAVINGS_ACTIVE, 300.0, RecommendedAmountUnit.PER_INDIVIDUAL, 1.2, 200.0, 200.0, SavingsType.MANDATORY, InterestCalcType.MINIMUM_BALANCE, meetingIntCalc, meetingIntPost);
    center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
    client1 = TestObjectFactory.createClient("Client", CustomerStatus.CLIENT_ACTIVE, group);
    savings = TestObjectFactory.createSavingsAccount("43245434", client1, Short.valueOf("16"), new Date(System.currentTimeMillis()), savingsOffering);
    Session session = StaticHibernateUtil.getSessionTL();
    StaticHibernateUtil.startTransaction();
    SavingsScheduleEntity accountActionDate = (SavingsScheduleEntity) savings.getAccountActionDate((short) 1);
    accountActionDate.setDepositPaid(TestUtils.createMoney("100.0"));
    session.update(savings);
    StaticHibernateUtil.flushSession();
    accountActionDate = (SavingsScheduleEntity) savings.getAccountActionDate((short) 3);
    Assert.assertEquals(getRoundedMoney(300.00), savings.getOverDueDepositAmount(accountActionDate.getActionDate()));
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) Date(java.util.Date) Session(org.hibernate.Session) Test(org.junit.Test)

Aggregations

SavingsOfferingBO (org.mifos.accounts.productdefinition.business.SavingsOfferingBO)63 Test (org.junit.Test)33 ArrayList (java.util.ArrayList)20 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)17 SavingsProductBuilder (org.mifos.domain.builders.SavingsProductBuilder)14 MeetingBO (org.mifos.application.meeting.business.MeetingBO)11 LocalDate (org.joda.time.LocalDate)10 SavingsAccountBuilder (org.mifos.domain.builders.SavingsAccountBuilder)10 Date (java.util.Date)9 UserContext (org.mifos.security.util.UserContext)9 Date (java.sql.Date)8 DateTime (org.joda.time.DateTime)8 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)8 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)8 SavingsTestHelper (org.mifos.accounts.savings.util.helpers.SavingsTestHelper)8 MifosRuntimeException (org.mifos.core.MifosRuntimeException)8 CustomerException (org.mifos.customers.exceptions.CustomerException)7 Money (org.mifos.framework.util.helpers.Money)7 AccountException (org.mifos.accounts.exceptions.AccountException)6 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)5