Search in sources :

Example 1 with SavingsProductBuilder

use of org.mifos.domain.builders.SavingsProductBuilder in project head by mifos.

the class SavingsDaoHibernateIntegrationTest method testShouldFindOnlyMandatorySavingsAccountsForCentersOrGroupThatToBePaidIndividuallyByTheirClients.

@Test
public void testShouldFindOnlyMandatorySavingsAccountsForCentersOrGroupThatToBePaidIndividuallyByTheirClients() {
    // setup
    savingsProduct = new SavingsProductBuilder().voluntary().appliesToGroupsOnly().withShortName("SP1").buildForIntegrationTests();
    savingsAccount = new SavingsAccountBuilder().completeGroup().perIndividual().withSavingsProduct(savingsProduct).withCustomer(group).withCreatedBy(IntegrationTestObjectMother.testUser()).build();
    IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(savingsProduct, savingsAccount);
    secondSavingsProduct = new SavingsProductBuilder().mandatory().withShortName("SP2").appliesToCentersOnly().withName("testSavingPrd2").buildForIntegrationTests();
    secondSavingsAccount = new SavingsAccountBuilder().withSavingsProduct(secondSavingsProduct).withCustomer(center).withCreatedBy(IntegrationTestObjectMother.testUser()).build();
    IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(secondSavingsProduct, secondSavingsAccount);
    // exercise test
    List<CollectionSheetCustomerSavingDto> mandatorySavingAccounts = savingsDao.findAllMandatorySavingAccountsForIndividualChildrenOfCentersOrGroupsWithPerIndividualStatusForCustomerHierarchy(customerHierarchyParams);
    // verification
    assertThat(mandatorySavingAccounts.size(), is(1));
}
Also used : SavingsProductBuilder(org.mifos.domain.builders.SavingsProductBuilder) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) CollectionSheetCustomerSavingDto(org.mifos.application.servicefacade.CollectionSheetCustomerSavingDto) Test(org.junit.Test)

Example 2 with SavingsProductBuilder

use of org.mifos.domain.builders.SavingsProductBuilder in project head by mifos.

the class SavingsAccountAdjustmentAndInterestCalculationServiceFacadeIntegrationTest method shouldHaveCorrectBalanceAfterDepositAndAdjustment.

@Test
public void shouldHaveCorrectBalanceAfterDepositAndAdjustment() throws Exception {
    createCenterGroupClientHierarchy(aWeeklyMeeting);
    SavingsOfferingBO savingsProduct = new SavingsProductBuilder().mandatory().withMandatoryAmount("33.0").appliesToClientsOnly().buildForIntegrationTests();
    SavingsBO savingsAccount = new SavingsAccountBuilder().active().withActivationDate(mondayTwoWeeksAgo()).withSavingsProduct(savingsProduct).withCustomer(client).withCreatedBy(IntegrationTestObjectMother.testUser()).withBalanceOf(TestUtils.createMoney("0")).withDepositOn("20", new DateTime()).build();
    IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(savingsProduct, savingsAccount);
    Long savingsId = Long.valueOf(savingsAccount.getAccountId());
    Double adjustedAmount = Double.valueOf("35");
    String note = "I entered 20 but it should of being 35 which is an overpayment of the mandatory sum.";
    SavingsAdjustmentDto savingsAdjustment = new SavingsAdjustmentDto(savingsId, adjustedAmount, note, savingsAccount.getLastPmnt().getPaymentId(), new LocalDate(savingsAccount.getLastPmnt().getPaymentDate()));
    // exercise test
    this.savingsServiceFacade.adjustTransaction(savingsAdjustment);
    // verification
    savingsAccount = IntegrationTestObjectMother.findSavingsAccountById(savingsId);
    assertThat(savingsAccount.getSavingsBalance(), is(TestUtils.createMoney("35")));
}
Also used : SavingsProductBuilder(org.mifos.domain.builders.SavingsProductBuilder) SavingsAdjustmentDto(org.mifos.dto.domain.SavingsAdjustmentDto) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 3 with SavingsProductBuilder

use of org.mifos.domain.builders.SavingsProductBuilder in project head by mifos.

the class SavingsAccountSchedulesIntegrationTest method shouldGenerateSavingsAccountSchedulesForActiveClientsOfGroupWhenUsingPerIndividualSetting.

@Test
public void shouldGenerateSavingsAccountSchedulesForActiveClientsOfGroupWhenUsingPerIndividualSetting() throws Exception {
    createCenterGroupClientHierarchy(aWeeklyMeeting);
    SavingsOfferingBO savingsProduct = new SavingsProductBuilder().mandatory().withMandatoryAmount("33.0").appliesToGroupsOnly().trackedPerIndividual().buildForIntegrationTests();
    SavingsBO savingsAccount = new SavingsAccountBuilder().active().withActivationDate(mondayTwoWeeksAgo()).withSavingsProduct(savingsProduct).withCustomer(group).withMember(client).withCreatedBy(IntegrationTestObjectMother.testUser()).buildJointSavingsAccount();
    IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(savingsProduct, savingsAccount);
    List<AccountActionDateEntity> savingSchedules = savingsAccount.getAccountActionDatesSortedByInstallmentId();
    for (AccountActionDateEntity savingSchedule : savingSchedules) {
        assertThat("saving schedule should be generated for active client belong to group savings account", savingSchedule.getCustomer().getCustomerId(), is(client.getCustomerId()));
    }
}
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 4 with SavingsProductBuilder

use of org.mifos.domain.builders.SavingsProductBuilder in project head by mifos.

the class SavingsAccountSchedulesIntegrationTest method shouldNotGenerateSavingsAccountSchedulesForCenterWithoutActiveClients.

@Test
public void shouldNotGenerateSavingsAccountSchedulesForCenterWithoutActiveClients() throws Exception {
    createCenterAndGroupHierarchyWithNoClients(aWeeklyMeeting);
    SavingsOfferingBO savingsProduct = new SavingsProductBuilder().mandatory().withMandatoryAmount("33.0").appliesToCentersOnly().buildForIntegrationTests();
    SavingsBO savingsAccount = new SavingsAccountBuilder().active().withActivationDate(mondayTwoWeeksAgo()).withSavingsProduct(savingsProduct).withCustomer(center).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 5 with SavingsProductBuilder

use of org.mifos.domain.builders.SavingsProductBuilder in project head by mifos.

the class SavingsWithdrawalTest method savingsBalanceIsDecrementedByTotalAmountWithdrawn.

@Test
public void savingsBalanceIsDecrementedByTotalAmountWithdrawn() throws AccountException {
    // setup
    final Money startingBalance = new Money(TestUtils.RUPEE, "80.0");
    savingsProduct = new SavingsProductBuilder().withMaxWithdrawalAmount(new Money(TestUtils.RUPEE, "50.0")).buildForUnitTests();
    savingsAccount = savingsAccountBuilder.withSavingsProduct(savingsProduct).withBalanceOf(startingBalance).buildForUnitTests();
    final Money amountToWithdraw = new Money(TestUtils.RUPEE, "25.0");
    // stubbing
    when(accountPayment.getAmount()).thenReturn(amountToWithdraw);
    // exercise test
    savingsAccount.withdraw(accountPayment, payingCustomer);
    // verification
    assertThat(savingsAccount.getSavingsBalance(), is(startingBalance.subtract(amountToWithdraw)));
}
Also used : Money(org.mifos.framework.util.helpers.Money) SavingsProductBuilder(org.mifos.domain.builders.SavingsProductBuilder) Test(org.junit.Test)

Aggregations

SavingsProductBuilder (org.mifos.domain.builders.SavingsProductBuilder)32 Test (org.junit.Test)26 SavingsAccountBuilder (org.mifos.domain.builders.SavingsAccountBuilder)19 SavingsOfferingBO (org.mifos.accounts.productdefinition.business.SavingsOfferingBO)14 Money (org.mifos.framework.util.helpers.Money)14 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)9 LocalDate (org.joda.time.LocalDate)6 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)6 DateTime (org.joda.time.DateTime)5 Before (org.junit.Before)4 CollectionSheetCustomerSavingDto (org.mifos.application.servicefacade.CollectionSheetCustomerSavingDto)4 ClientBuilder (org.mifos.domain.builders.ClientBuilder)4 Date (java.util.Date)3 Ignore (org.junit.Ignore)3 SavingsScheduleEntity (org.mifos.accounts.savings.business.SavingsScheduleEntity)3 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)3 SavingsScheduleBuilder (org.mifos.domain.builders.SavingsScheduleBuilder)3 MeetingBO (org.mifos.application.meeting.business.MeetingBO)2 RecommendedAmntUnitEntity (org.mifos.accounts.productdefinition.business.RecommendedAmntUnitEntity)1 Holiday (org.mifos.application.holiday.business.Holiday)1