Search in sources :

Example 56 with CenterBuilder

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));
}
Also used : GroupBuilder(org.mifos.domain.builders.GroupBuilder) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) GroupBO(org.mifos.customers.group.business.GroupBO) Test(org.junit.Test)

Example 57 with CenterBuilder

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);
}
Also used : GroupBuilder(org.mifos.domain.builders.GroupBuilder) CenterBuilder(org.mifos.domain.builders.CenterBuilder) ClientBuilder(org.mifos.domain.builders.ClientBuilder)

Example 58 with CenterBuilder

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);
}
Also used : GroupBuilder(org.mifos.domain.builders.GroupBuilder) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Before(org.junit.Before)

Example 59 with CenterBuilder

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);
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) GroupBuilder(org.mifos.domain.builders.GroupBuilder) LoanProductBuilder(org.mifos.domain.builders.LoanProductBuilder) ArrayList(java.util.ArrayList) CenterBuilder(org.mifos.domain.builders.CenterBuilder) LocalDate(org.joda.time.LocalDate) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) BigDecimal(java.math.BigDecimal) FeeBuilder(org.mifos.domain.builders.FeeBuilder) RecurringSchedule(org.mifos.clientportfolio.loan.service.RecurringSchedule) CreateLoanAccount(org.mifos.clientportfolio.newloan.applicationservice.CreateLoanAccount) CreateAccountPenaltyDto(org.mifos.dto.domain.CreateAccountPenaltyDto) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) CreateAccountFeeDto(org.mifos.dto.domain.CreateAccountFeeDto) ClientBuilder(org.mifos.domain.builders.ClientBuilder)

Example 60 with CenterBuilder

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()));
}
Also used : CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) FeeBuilder(org.mifos.domain.builders.FeeBuilder) DateMidnight(org.joda.time.DateMidnight) MeetingBO(org.mifos.application.meeting.business.MeetingBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) DateTime(org.joda.time.DateTime) Date(java.util.Date) InstallmentDate(org.mifos.accounts.util.helpers.InstallmentDate) InstallmentDate(org.mifos.accounts.util.helpers.InstallmentDate) Test(org.junit.Test)

Aggregations

CenterBuilder (org.mifos.domain.builders.CenterBuilder)123 Test (org.junit.Test)98 CenterBO (org.mifos.customers.center.business.CenterBO)82 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)73 MeetingBO (org.mifos.application.meeting.business.MeetingBO)54 GroupBuilder (org.mifos.domain.builders.GroupBuilder)53 DateTime (org.joda.time.DateTime)52 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)46 ArrayList (java.util.ArrayList)42 GroupBO (org.mifos.customers.group.business.GroupBO)36 ClientBuilder (org.mifos.domain.builders.ClientBuilder)30 OfficeBO (org.mifos.customers.office.business.OfficeBO)21 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)19 CustomerException (org.mifos.customers.exceptions.CustomerException)18 FeeBuilder (org.mifos.domain.builders.FeeBuilder)18 CalendarEventBuilder (org.mifos.domain.builders.CalendarEventBuilder)17 LocalDate (org.joda.time.LocalDate)14 Before (org.junit.Before)14 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)13 ClientBO (org.mifos.customers.client.business.ClientBO)13