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()));
}
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);
}
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);
}
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());
}
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;
}
Aggregations