use of org.mifos.domain.builders.CenterBuilder in project head by mifos.
the class CenterValidationTest method cannotCreateCenterWithFeeThatHasDifferentPeriod.
@Test
public void cannotCreateCenterWithFeeThatHasDifferentPeriod() {
// setup
DateTime today = new DateTime();
MeetingBuilder aWeeklyMeeting = new MeetingBuilder().customerMeeting().weekly();
CenterBO center = new CenterBuilder().withName("center1").withLoanOfficer(anyLoanOfficer()).with(aWeeklyMeeting).withMfiJoiningDate(today).build();
MeetingBuilder aMonthlyMeeting = new MeetingBuilder().periodicFeeMeeting().monthly();
AmountFeeBO montlyPeriodicFee = new FeeBuilder().appliesToCenterOnly().with(aMonthlyMeeting).build();
AccountFeesEntity accountFee = new AccountFeesEntity(null, montlyPeriodicFee, montlyPeriodicFee.getFeeAmount().getAmountDoubleValue());
List<AccountFeesEntity> centerAccountFees = new ArrayList<AccountFeesEntity>();
centerAccountFees.add(accountFee);
// exercise test
try {
center.validateMeetingAndFees(centerAccountFees);
fail("cannotCreateCenterWithFeeThatHasDifferentPeriod");
} catch (ApplicationException e) {
assertThat(e.getKey(), is(CustomerConstants.ERRORS_FEE_FREQUENCY_MISMATCH));
}
}
use of org.mifos.domain.builders.CenterBuilder in project head by mifos.
the class CenterValidationTest method cannotCreateCenterWithoutABranch.
@Test
public void cannotCreateCenterWithoutABranch() {
// setup
DateTime today = new DateTime();
MeetingBuilder customerMeeting = new MeetingBuilder().customerMeeting();
OfficeBO noBranch = null;
CenterBO center = new CenterBuilder().withName("center1").withLoanOfficer(anyLoanOfficer()).with(customerMeeting).withMfiJoiningDate(today).with(noBranch).build();
// exercise test
try {
center.validate();
fail("cannotCreateCenterWithoutABranch");
} catch (ApplicationException e) {
assertThat(e.getKey(), is(CustomerConstants.INVALID_OFFICE));
}
}
use of org.mifos.domain.builders.CenterBuilder in project head by mifos.
the class CenterUpdateTest method cannotUpdateCenterWithDifferentVersion.
@Test
public void cannotUpdateCenterWithDifferentVersion() {
// setup
int differentVersionNum = -1;
CenterBO existingCenter = new CenterBuilder().withLoanOfficer(PersonnelBuilder.anyLoanOfficer()).withVersion(differentVersionNum).build();
UserContext userContext = TestUtils.makeUser();
CenterUpdate centerUpdate = new CenterUpdateBuilder().build();
// stub
when(customerDao.findCustomerById(centerUpdate.getCustomerId())).thenReturn(existingCenter);
// exercise test
try {
customerService.updateCenter(userContext, centerUpdate);
fail("cannotUpdateCenterWithDifferentVersion");
} catch (ApplicationException e) {
assertThat(e.getKey(), is(Constants.ERROR_VERSION_MISMATCH));
}
}
use of org.mifos.domain.builders.CenterBuilder in project head by mifos.
the class TestCollectionSheetRetrieveSavingsAccountsUtils method createSampleCenterHierarchy.
/**
* By default generates 1 center with a mandatory savings account (center savings accounts are always
* PER_INDIVIDUAL)
*
* 1 group with a voluntary COMPLETE_GROUP savings account
*
* 1 client with a mandatory savings account
*
* 1 group with a mandatory PER_INDIVIDUAL savings account
*
* 1 client with a voluntary savings account
*/
public void createSampleCenterHierarchy() throws Exception {
// TODO - correct clientBuilder so that when there are "PER_INDIVIDUAL" savings accounts relevant to it... a
// saving schedule is created.
//
// As a work-around for this problem... the two "PER_INDIVIDUAL" savings accounts (centerSavingsAccount and
// groupPerIndividualSavingsAccount) are created last... this kicks of a process that creates schedules for all
// the relevant clients.
MeetingBO weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
IntegrationTestObjectMother.saveMeeting(weeklyMeeting);
center = new CenterBuilder().withNumberOfExistingCustomersInOffice(3).with(weeklyMeeting).withName("Savings Center").with(sampleBranchOffice()).withLoanOfficer(testUser()).build();
IntegrationTestObjectMother.createCenter(center, weeklyMeeting);
if (!onlyCreateCenterAndItsSavingsAccount) {
groupCompleteGroup = new GroupBuilder().withMeeting(weeklyMeeting).withName("Savings Group Complete Group").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(center).build();
IntegrationTestObjectMother.createGroup(groupCompleteGroup, weeklyMeeting);
groupCompleteGroupSavingsAccount = createSavingsAccount(groupCompleteGroup, "gvcg", "2.0", true, false);
MeetingBO weeklyClientMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
groupCompleteGroup.setMeeting(weeklyClientMeeting);
clientOfGroupCompleteGroup = new ClientBuilder().withSearchId(center.getSearchId() + ".1.1").withMeeting(weeklyClientMeeting).withName("Savings Client Of Group Complete Group").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(groupCompleteGroup).buildForIntegrationTests();
IntegrationTestObjectMother.createClient(clientOfGroupCompleteGroup, weeklyClientMeeting);
clientOfGroupCompleteGroupSavingsAccount = createSavingsAccount(clientOfGroupCompleteGroup, "clm", "3.0", false, false);
groupPerIndividual = new GroupBuilder().withMeeting(weeklyMeeting).withName("Savings Group Per Individual").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(center).build();
IntegrationTestObjectMother.createGroup(groupPerIndividual, weeklyMeeting);
clientOfGroupPerIndividual = new ClientBuilder().withSearchId(center.getSearchId() + ".2.1").withMeeting(weeklyMeeting).withName("Savings Client Of Group Per Individual").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(groupPerIndividual).buildForIntegrationTests();
IntegrationTestObjectMother.createClient(clientOfGroupPerIndividual, weeklyMeeting);
clientOfGroupPerIndividualSavingsAccount = createSavingsAccount(clientOfGroupPerIndividual, "clv", "5.0", true, false);
groupPerIndividualSavingsAccount = createSavingsAccount(groupPerIndividual, "gmi", "4.0", false, true);
}
centerSavingsAccount = createSavingsAccount(center, "cemi", "1.0", false, false);
}
use of org.mifos.domain.builders.CenterBuilder in project head by mifos.
the class CustomerDaoHibernateIntegrationTest method setUp.
@Before
public void setUp() throws Exception {
databaseCleaner.clean();
weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
IntegrationTestObjectMother.saveMeeting(weeklyMeeting);
weeklyPeriodicFeeForCenterOnly = new FeeBuilder().appliesToCenterOnly().withFeeAmount("100.0").withName("Center Weekly Periodic Fee").withSameRecurrenceAs(weeklyMeeting).with(sampleBranchOffice()).build();
IntegrationTestObjectMother.saveFee(weeklyPeriodicFeeForCenterOnly);
center = new CenterBuilder().with(weeklyMeeting).withName("Center").with(sampleBranchOffice()).withLoanOfficer(testUser()).build();
IntegrationTestObjectMother.createCenter((CenterBO) center, weeklyMeeting);
weeklyPeriodicFeeForGroupOnly = new FeeBuilder().appliesToGroupsOnly().withFeeAmount("50.0").withName("Group Weekly Periodic Fee").withSameRecurrenceAs(weeklyMeeting).with(sampleBranchOffice()).build();
IntegrationTestObjectMother.saveFee(weeklyPeriodicFeeForGroupOnly);
group = new GroupBuilder().withMeeting(weeklyMeeting).withName("Group").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withFee(weeklyPeriodicFeeForGroupOnly).withParentCustomer(center).build();
IntegrationTestObjectMother.createGroup(group, weeklyMeeting);
weeklyPeriodicFeeForClientsOnly = new FeeBuilder().appliesToClientsOnly().withFeeAmount("10.0").withName("Client Weekly Periodic Fee").withSameRecurrenceAs(weeklyMeeting).with(sampleBranchOffice()).build();
IntegrationTestObjectMother.saveFee(weeklyPeriodicFeeForClientsOnly);
activeClient = new ClientBuilder().active().withMeeting(weeklyMeeting).withName("Active Client").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(group).buildForIntegrationTests();
Address address = new Address("a", "b", "c", "gdynia", "pomorskie", "PL", "81-661", "0-89 222 33");
activeClient.setCustomerAddressDetail(new CustomerAddressDetailEntity(activeClient, address));
IntegrationTestObjectMother.createClient(activeClient, weeklyMeeting);
weeklyPeriodicFeeForSecondClient = new FeeBuilder().appliesToClientsOnly().withFeeAmount("10.0").withName("Inactive Client Periodic Fee").withSameRecurrenceAs(weeklyMeeting).with(sampleBranchOffice()).build();
IntegrationTestObjectMother.saveFee(weeklyPeriodicFeeForSecondClient);
pendingClient = new ClientBuilder().pendingApproval().withMeeting(weeklyMeeting).withName("Pending Client").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(group).buildForIntegrationTests();
IntegrationTestObjectMother.createClient(pendingClient, weeklyMeeting);
}
Aggregations