use of org.mifos.domain.builders.CenterBuilder in project head by mifos.
the class GroupTransferToCenterTest method transferingGroupToCenterInSameBranchIncrementsMaxChildCountOfNewParentAndDoesNotDecrementsMaxChildCountOfOldParent.
@Test
public void transferingGroupToCenterInSameBranchIncrementsMaxChildCountOfNewParentAndDoesNotDecrementsMaxChildCountOfOldParent() throws Exception {
CenterBO fromCenter = new CenterBuilder().withName("fromCenter").build();
GroupBO groupForTransfer = new GroupBuilder().withParentCustomer(fromCenter).active().build();
fromCenter.addChild(groupForTransfer);
CenterBO centerWithNoChildren = new CenterBuilder().withName("receivingCenter").build();
// pre-verification
assertThat(centerWithNoChildren.getMaxChildCount(), is(0));
assertThat(centerWithNoChildren.getChildren().size(), is(0));
assertThat(groupForTransfer.getParentCustomer().getMaxChildCount(), is(1));
// exercise test
groupForTransfer.transferTo(centerWithNoChildren);
// verification
assertThat(centerWithNoChildren.getMaxChildCount(), is(1));
assertThat(fromCenter.getMaxChildCount(), is(1));
}
use of org.mifos.domain.builders.CenterBuilder in project head by mifos.
the class SavingsIntPostingHelperIntegrationTest method createCenterGroupClientHierarchy.
private void createCenterGroupClientHierarchy(MeetingBO meetingFrequency) throws CustomerException {
center = new CenterBuilder().withName("Savings Center").with(meetingFrequency).with(sampleBranchOffice()).withLoanOfficer(testUser()).withActivationDate(mondayTwoWeeksAgo()).build();
IntegrationTestObjectMother.createCenter(center, meetingFrequency);
group = new GroupBuilder().withName("Group").withMeeting(meetingFrequency).withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(center).build();
IntegrationTestObjectMother.createGroup(group, meetingFrequency);
client = new ClientBuilder().withName("Client 1").active().withMeeting(meetingFrequency).withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(group).buildForIntegrationTests();
IntegrationTestObjectMother.createClient(client, meetingFrequency);
}
use of org.mifos.domain.builders.CenterBuilder in project head by mifos.
the class ClientPhotoServiceDatabaseIntegrationTest method setUp.
@Before
public void setUp() throws CustomerException {
this.clientPhotoService = new ClientPhotoServiceDatabase();
this.clientPhotoService.setGenericDao(this.genericDao);
this.clientPhotoService.setHibernateTransactionHelper(this.hibernateTransactionHelper);
this.weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
IntegrationTestObjectMother.saveMeeting(weeklyMeeting);
this.testCenter = new CenterBuilder().with(this.weeklyMeeting).withName("Center Photo").with(sampleBranchOffice()).withLoanOfficer(testUser()).build();
IntegrationTestObjectMother.createCenter(this.testCenter, this.weeklyMeeting);
this.testGroup = new GroupBuilder().withMeeting(this.weeklyMeeting).withName("Group Photo").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(this.testCenter).build();
IntegrationTestObjectMother.createGroup(this.testGroup, this.weeklyMeeting);
this.testClient = new ClientBuilder().withMeeting(this.weeklyMeeting).withName("Client 1").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(this.testGroup).buildForIntegrationTests();
IntegrationTestObjectMother.createClient(this.testClient, this.weeklyMeeting);
}
use of org.mifos.domain.builders.CenterBuilder in project head by mifos.
the class LoanAdjustmentsIntegrationTest method createLoan.
private LoanBO createLoan() throws Exception {
MeetingBO weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
IntegrationTestObjectMother.saveMeeting(weeklyMeeting);
center = new CenterBuilder().with(weeklyMeeting).withName("Center").with(sampleBranchOffice()).withLoanOfficer(testUser()).build();
IntegrationTestObjectMother.createCenter(center, weeklyMeeting);
group = new GroupBuilder().withMeeting(weeklyMeeting).withName("Group").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(center).build();
IntegrationTestObjectMother.createGroup(group, weeklyMeeting);
client = new ClientBuilder().withMeeting(weeklyMeeting).withName("Client").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(group).buildForIntegrationTests();
IntegrationTestObjectMother.createClient(client, weeklyMeeting);
LoanOfferingBO loanOffering = new LoanProductBuilder().withName("Adjust Loan Product").withMeeting(weeklyMeeting).buildForIntegrationTests();
IntegrationTestObjectMother.createProduct(loanOffering);
AmountFeeBO periodicFee = new FeeBuilder().appliesToLoans().periodic().withFeeAmount("10.0").withName("Periodic Fee").with(sampleBranchOffice()).build();
IntegrationTestObjectMother.saveFee(periodicFee);
BigDecimal loanAmount = BigDecimal.valueOf(Double.valueOf("1000.0"));
BigDecimal minAllowedLoanAmount = loanAmount;
BigDecimal maxAllowedLoanAmount = loanAmount;
Double interestRate = loanOffering.getDefInterestRate();
LocalDate disbursementDate = new LocalDate();
int numberOfInstallments = 10;
int minAllowedNumberOfInstallments = loanOffering.getEligibleInstallmentSameForAllLoan().getMaxNoOfInstall();
int maxAllowedNumberOfInstallments = loanOffering.getEligibleInstallmentSameForAllLoan().getMaxNoOfInstall();
int graceDuration = 0;
Integer sourceOfFundId = null;
Integer loanPurposeId = null;
Integer collateralTypeId = null;
String collateralNotes = null;
String externalId = null;
boolean repaymentScheduleIndependentOfCustomerMeeting = false;
RecurringSchedule recurringSchedule = null;
List<CreateAccountFeeDto> accountFees = new ArrayList<CreateAccountFeeDto>();
accountFees.add(new CreateAccountFeeDto(periodicFee.getFeeId().intValue(), periodicFee.getFeeAmount().toString()));
CreateLoanAccount createLoanAccount = new CreateLoanAccount(client.getCustomerId(), loanOffering.getPrdOfferingId().intValue(), AccountState.LOAN_ACTIVE_IN_GOOD_STANDING.getValue().intValue(), loanAmount, minAllowedLoanAmount, maxAllowedLoanAmount, interestRate, disbursementDate, null, numberOfInstallments, minAllowedNumberOfInstallments, maxAllowedNumberOfInstallments, graceDuration, sourceOfFundId, loanPurposeId, collateralTypeId, collateralNotes, externalId, repaymentScheduleIndependentOfCustomerMeeting, recurringSchedule, accountFees, new ArrayList<CreateAccountPenaltyDto>());
return IntegrationTestObjectMother.createClientLoan(createLoanAccount);
}
use of org.mifos.domain.builders.CenterBuilder in project head by mifos.
the class AccountGetFeeDatesIntegrationTest method getScheduledDatesForFeesForGivenCustomerForWeeklySchedules.
@Test
public void getScheduledDatesForFeesForGivenCustomerForWeeklySchedules() throws Exception {
// setup
DateTime firstTuesdayInstallmentDate = new DateMidnight().toDateTime().withDate(2010, 4, 20);
weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).withStartDate(firstTuesdayInstallmentDate).build();
IntegrationTestObjectMother.saveMeeting(weeklyMeeting);
MeetingBuilder weeklyMeetingForFees = new MeetingBuilder().periodicFeeMeeting().weekly().every(1).withStartDate(firstTuesdayInstallmentDate);
weeklyPeriodicFeeForCenterOnly = new FeeBuilder().appliesToCenterOnly().withFeeAmount("100.0").withName("Center Weekly Periodic Fee").with(weeklyMeetingForFees).with(sampleBranchOffice()).build();
IntegrationTestObjectMother.saveFee(weeklyPeriodicFeeForCenterOnly);
center = new CenterBuilder().with(weeklyMeeting).withName("Center").with(sampleBranchOffice()).withLoanOfficer(testUser()).build();
IntegrationTestObjectMother.createCenter(center, weeklyMeeting, weeklyPeriodicFeeForCenterOnly);
center = customerDao.findCenterBySystemId(center.getGlobalCustNum());
DateTime meetingStartDate = firstTuesdayInstallmentDate.minusDays(7);
MeetingBO feeMeetingFrequency = new MeetingBuilder().periodicFeeMeeting().weekly().every(1).occuringOnA(WeekDay.MONDAY).startingFrom(meetingStartDate.toDate()).build();
InstallmentDate installment1 = new InstallmentDate(Short.valueOf("1"), firstTuesdayInstallmentDate.toDate());
InstallmentDate installment2 = new InstallmentDate(Short.valueOf("2"), firstTuesdayInstallmentDate.plusWeeks(1).toDate());
InstallmentDate installment3 = new InstallmentDate(Short.valueOf("3"), firstTuesdayInstallmentDate.plusWeeks(2).toDate());
InstallmentDate installment4 = new InstallmentDate(Short.valueOf("4"), firstTuesdayInstallmentDate.plusWeeks(3).toDate());
List<InstallmentDate> installmentDates = Arrays.asList(installment1, installment2, installment3, installment4);
// exercise test
CustomerAccountBO customerAccount = center.getCustomerAccount();
List<Date> feeDates = customerAccount.getFeeDates(feeMeetingFrequency, installmentDates);
// verification
assertThat(feeDates.get(0), is(firstTuesdayInstallmentDate.toDate()));
assertThat(feeDates.get(1), is(firstTuesdayInstallmentDate.plusWeeks(1).toDate()));
assertThat(feeDates.get(2), is(firstTuesdayInstallmentDate.plusWeeks(2).toDate()));
assertThat(feeDates.get(3), is(firstTuesdayInstallmentDate.plusWeeks(3).toDate()));
}
Aggregations