Search in sources :

Example 56 with MeetingBuilder

use of org.mifos.domain.builders.MeetingBuilder 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)

Example 57 with MeetingBuilder

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

the class AccountRegenerateScheduleIntegrationTestCase method testChangeThirdThursdayBiMonthlyMeetingScheduleOnADateInThirdMonthAfterMeetingDate.

@Test
public // original schedule 11/20/08, 1/15/09, 3/19/09, 5/21/09, 7/16/09, 9/17/09
void testChangeThirdThursdayBiMonthlyMeetingScheduleOnADateInThirdMonthAfterMeetingDate() throws Exception {
    List<LocalDate> expectedMeetingDates = new ArrayList<LocalDate>();
    expectedMeetingDates.add(new LocalDate(2008, NOVEMBER, 20));
    expectedMeetingDates.add(new LocalDate(2009, JANUARY, 15));
    expectedMeetingDates.add(new LocalDate(2009, MARCH, 3));
    expectedMeetingDates.add(new LocalDate(2009, MAY, 5));
    expectedMeetingDates.add(new LocalDate(2009, JULY, 7));
    expectedMeetingDates.add(new LocalDate(2009, SEPTEMBER, 1));
    LocalDate startDate = new LocalDate(2008, NOVEMBER, 20);
    LocalDate dateWhenMeetingWillBeChanged = new LocalDate(2009, FEBRUARY, 15);
    MeetingBO meeting = setupMonthlyMeeting(startDate, 2, RankOfDay.THIRD, WeekDay.THURSDAY);
    MeetingBO newMeeting = TestObjectFactory.createMeeting(new MeetingBuilder().monthly().every(2).buildMonthlyFor(RankOfDay.FIRST, WeekDay.TUESDAY));
    testChangeInMeetingScheduleForDates(meeting, newMeeting, startDate, dateWhenMeetingWillBeChanged);
    validateSchedules(expectedMeetingDates);
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) ArrayList(java.util.ArrayList) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test)

Example 58 with MeetingBuilder

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

the class AccountRegenerateScheduleIntegrationTestCase method testChangeMonthlyMeetingScheduleOnADateInFirstMonthAfterMeetingDate.

@Test
public void testChangeMonthlyMeetingScheduleOnADateInFirstMonthAfterMeetingDate() throws Exception {
    List<LocalDate> expectedMeetingDates = new ArrayList<LocalDate>();
    expectedMeetingDates.add(new LocalDate(2008, APRIL, 9));
    expectedMeetingDates.add(new LocalDate(2008, MAY, 9));
    expectedMeetingDates.add(new LocalDate(2008, JUNE, 20));
    expectedMeetingDates.add(new LocalDate(2008, JULY, 20));
    expectedMeetingDates.add(new LocalDate(2008, AUGUST, 20));
    LocalDate startDate = new LocalDate(2008, APRIL, 9);
    LocalDate dateWhenMeetingWillBeChanged = new LocalDate(2008, MAY, 31);
    MeetingBO meeting = setupMonthlyMeeting(startDate, 1, 9);
    MeetingBO newMeeting = TestObjectFactory.createMeeting(new MeetingBuilder().monthly().every(1).buildMonthlyForDayNumber(20));
    testChangeInMeetingScheduleForDates(meeting, newMeeting, startDate, dateWhenMeetingWillBeChanged);
    validateSchedules(expectedMeetingDates);
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) ArrayList(java.util.ArrayList) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test)

Example 59 with MeetingBuilder

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

the class TestSaveCollectionSheetUtils method createSampleCenterHierarchy.

/**
     * By default generates 1 center, 1 group and 1 client with 1 loan to be disbursed and 1
     * weekly account collection fee. Can be configured to add in other invalid entries.
     */
public void createSampleCenterHierarchy(Date date) throws Exception {
    MeetingBO weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
    IntegrationTestObjectMother.saveMeeting(weeklyMeeting);
    center = new CenterBuilder().withNumberOfExistingCustomersInOffice(3).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);
    AmountFeeBO weeklyPeriodicFeeForFirstClients = new FeeBuilder().appliesToClientsOnly().withFeeAmount("87.0").withName("First Client Weekly Periodic Fee").withSameRecurrenceAs(weeklyMeeting).with(sampleBranchOffice()).build();
    IntegrationTestObjectMother.saveFee(weeklyPeriodicFeeForFirstClients);
    client = new ClientBuilder().withMeeting(weeklyMeeting).withName("Client 1").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(group).buildForIntegrationTests();
    IntegrationTestObjectMother.createClient(client, weeklyMeeting);
    MeetingBO loanMeeting = TestObjectFactory.createLoanMeeting(client.getCustomerMeeting().getMeeting());
    LoanOfferingBO loanOffering = TestObjectFactory.createLoanOffering("Loan", ApplicableTo.CLIENTS, date, PrdStatus.LOAN_ACTIVE, 1200.0, 1.2, 12, InterestType.FLAT, loanMeeting);
    SecurityContext securityContext = new SecurityContextImpl();
    MifosUser principal = new MifosUserBuilder().nonLoanOfficer().withAdminRole().build();
    Authentication authentication = new TestingAuthenticationToken(principal, principal);
    securityContext.setAuthentication(authentication);
    SecurityContextHolder.setContext(securityContext);
    BigDecimal loanAmount = BigDecimal.valueOf(Double.valueOf("1200.0"));
    BigDecimal minAllowedLoanAmount = loanAmount;
    BigDecimal maxAllowedLoanAmount = loanAmount;
    Double interestRate = Double.valueOf("10.0");
    LocalDate disbursementDate = new LocalDate(date);
    int numberOfInstallments = 12;
    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>();
    CreateLoanAccount createLoanAccount = new CreateLoanAccount(client.getCustomerId(), loanOffering.getPrdOfferingId().intValue(), AccountState.LOAN_APPROVED.getValue().intValue(), loanAmount, minAllowedLoanAmount, maxAllowedLoanAmount, interestRate, disbursementDate, null, numberOfInstallments, minAllowedNumberOfInstallments, maxAllowedNumberOfInstallments, graceDuration, sourceOfFundId, loanPurposeId, collateralTypeId, collateralNotes, externalId, repaymentScheduleIndependentOfCustomerMeeting, recurringSchedule, accountFees, new ArrayList<CreateAccountPenaltyDto>());
    loan = IntegrationTestObjectMother.createClientLoan(createLoanAccount);
    loan.updateDetails(TestUtils.makeUser());
}
Also used : SecurityContextImpl(org.springframework.security.core.context.SecurityContextImpl) MeetingBO(org.mifos.application.meeting.business.MeetingBO) GroupBuilder(org.mifos.domain.builders.GroupBuilder) ArrayList(java.util.ArrayList) CenterBuilder(org.mifos.domain.builders.CenterBuilder) LocalDate(org.joda.time.LocalDate) CreateLoanAccount(org.mifos.clientportfolio.newloan.applicationservice.CreateLoanAccount) CreateAccountPenaltyDto(org.mifos.dto.domain.CreateAccountPenaltyDto) CreateAccountFeeDto(org.mifos.dto.domain.CreateAccountFeeDto) ClientBuilder(org.mifos.domain.builders.ClientBuilder) MifosUser(org.mifos.security.MifosUser) MifosUserBuilder(org.mifos.builders.MifosUserBuilder) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) BigDecimal(java.math.BigDecimal) FeeBuilder(org.mifos.domain.builders.FeeBuilder) RecurringSchedule(org.mifos.clientportfolio.loan.service.RecurringSchedule) Authentication(org.springframework.security.core.Authentication) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) SecurityContext(org.springframework.security.core.context.SecurityContext) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder)

Example 60 with MeetingBuilder

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

the class TestSaveCollectionSheetUtils method getAnotherClientFromAnotherCenter.

/*
     *
     */
private ClientBO getAnotherClientFromAnotherCenter() throws Exception {
    MeetingBO weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
    anotherCenter = new CenterBuilder().with(weeklyMeeting).withName("Another Center").with(sampleBranchOffice()).withLoanOfficer(testUser()).build();
    IntegrationTestObjectMother.saveCustomer(anotherCenter);
    anotherGroup = new GroupBuilder().withMeeting(weeklyMeeting).withName("Another Group").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(anotherCenter).build();
    IntegrationTestObjectMother.saveCustomer(anotherGroup);
    anotherClient = new ClientBuilder().withMeeting(weeklyMeeting).withName("Another Client 1").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(anotherGroup).buildForIntegrationTests();
    IntegrationTestObjectMother.saveCustomer(anotherClient);
    return anotherClient;
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) GroupBuilder(org.mifos.domain.builders.GroupBuilder) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) ClientBuilder(org.mifos.domain.builders.ClientBuilder)

Aggregations

MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)106 Test (org.junit.Test)74 MeetingBO (org.mifos.application.meeting.business.MeetingBO)74 CenterBuilder (org.mifos.domain.builders.CenterBuilder)73 DateTime (org.joda.time.DateTime)58 ArrayList (java.util.ArrayList)47 CenterBO (org.mifos.customers.center.business.CenterBO)43 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)38 LocalDate (org.joda.time.LocalDate)27 GroupBuilder (org.mifos.domain.builders.GroupBuilder)24 Before (org.junit.Before)21 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)20 FeeBuilder (org.mifos.domain.builders.FeeBuilder)20 OfficeBO (org.mifos.customers.office.business.OfficeBO)19 ClientBuilder (org.mifos.domain.builders.ClientBuilder)15 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)14 CalendarEventBuilder (org.mifos.domain.builders.CalendarEventBuilder)14 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)13 CustomerAccountBO (org.mifos.customers.business.CustomerAccountBO)11 Ignore (org.junit.Ignore)10