use of org.mifos.domain.builders.CenterBuilder in project head by mifos.
the class CustomerAccountGenerateNextSetOfMeetingDatesTest method canGenerateTenSchedulesMatchingMeetingRecurrenceWhenNoPreviousSchedulesExisted.
@Test
public void canGenerateTenSchedulesMatchingMeetingRecurrenceWhenNoPreviousSchedulesExisted() throws Exception {
// use default setup
customer = new CenterBuilder().inActive().build();
customerAccount = CustomerAccountBO.createNew(customer, accountFees, customer.getCustomerMeetingValue(), calendarEvent);
DateTime lastScheduledDate = new DateTime().toDateMidnight().toDateTime();
ScheduledEvent scheduledEvent = ScheduledEventFactory.createScheduledEventFrom(customer.getCustomerMeetingValue());
// pre verification
assertThat(customerAccount.getAccountActionDates().isEmpty(), is(true));
// stubbing
List<DateTime> generatedDates = elevenDatesStartingFromAndIncluding(lastScheduledDate, scheduledEvent);
when(scheduledDateGeneration.generateScheduledDates(anyInt(), (DateTime) anyObject(), (ScheduledEvent) anyObject(), anyBoolean())).thenReturn(generatedDates);
// exercise test
customerAccount.generateNextSetOfMeetingDates(scheduledDateGeneration);
// verification
assertThat(customerAccount.getAccountActionDates().isEmpty(), is(false));
assertThat(customerAccount.getAccountActionDates().size(), is(10));
}
use of org.mifos.domain.builders.CenterBuilder in project head by mifos.
the class CustomerAccountGenerateNextSetOfMeetingDatesTest method canGenerateNextSetOfMeetingScheduleOnTopOfPreviousMeetingScheduleWithRecurringFees.
@Test
public void canGenerateNextSetOfMeetingScheduleOnTopOfPreviousMeetingScheduleWithRecurringFees() {
// use default setup
MeetingBuilder weeklyMeetingBuilder = new MeetingBuilder().customerMeeting().weekly().every(1);
MeetingBO customerMeeting = weeklyMeetingBuilder.build();
customer = new CenterBuilder().active().with(customerMeeting).build();
AmountFeeBO recurringFee = new FeeBuilder().appliesToAllCustomers().periodic().with(weeklyMeetingBuilder).withFeeAmount("3.0").build();
AccountFeesEntity recurringFeeEntity = new AccountFeesEntity(null, recurringFee, recurringFee.getFeeAmount().getAmountDoubleValue());
recurringFeeEntity = spy(recurringFeeEntity);
when(recurringFeeEntity.getAccountFeeId()).thenReturn(1);
accountFees = new ArrayList<AccountFeesEntity>();
accountFees.add(recurringFeeEntity);
customerAccount = CustomerAccountBO.createNew(customer, accountFees, customerMeeting, calendarEvent);
// setup
AccountFeesEntity sameButDifferentRecurringFeeEntity = new AccountFeesEntity(customerAccount, recurringFee, recurringFee.getFeeAmount().getAmountDoubleValue());
sameButDifferentRecurringFeeEntity = spy(sameButDifferentRecurringFeeEntity);
customerAccount.getAccountFees().clear();
customerAccount.addAccountFees(sameButDifferentRecurringFeeEntity);
when(sameButDifferentRecurringFeeEntity.getAccountFeeId()).thenReturn(1);
List<AccountActionDateEntity> schedules = new ArrayList<AccountActionDateEntity>(customerAccount.getAccountActionDates());
DateTime lastScheduledDate = new DateTime(schedules.get(9).getActionDate());
ScheduledEvent scheduledEvent = ScheduledEventFactory.createScheduledEventFrom(customer.getCustomerMeetingValue());
// stubbing
List<DateTime> generatedDates = elevenDatesStartingFromAndIncluding(lastScheduledDate, scheduledEvent);
when(scheduledDateGeneration.generateScheduledDates(anyInt(), (DateTime) anyObject(), (ScheduledEvent) anyObject(), anyBoolean())).thenReturn(generatedDates);
// exercise test
customerAccount.generateNextSetOfMeetingDates(scheduledDateGeneration);
assertThat(customerAccount.getAccountActionDates().size(), is(20));
}
use of org.mifos.domain.builders.CenterBuilder in project head by mifos.
the class CustomerAccountGenerateNextSetOfMeetingDatesTest method canGenerateNextSetOfMeetingDatesWithFreshlyGeneratedSchedule.
@Test
public void canGenerateNextSetOfMeetingDatesWithFreshlyGeneratedSchedule() {
// use default setup
MeetingBO customerMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).build();
customer = new CenterBuilder().active().with(customerMeeting).build();
customerAccount = CustomerAccountBO.createNew(customer, accountFees, customerMeeting, calendarEvent);
// pre verification
assertThat(customerAccount.getAccountActionDates().size(), is(10));
// setup
List<AccountActionDateEntity> schedules = new ArrayList<AccountActionDateEntity>(customerAccount.getAccountActionDates());
DateTime lastScheduledDate = new DateTime(schedules.get(9).getActionDate());
ScheduledEvent scheduledEvent = ScheduledEventFactory.createScheduledEventFrom(customer.getCustomerMeetingValue());
// stubbing
List<DateTime> generatedDates = elevenDatesStartingFromAndIncluding(lastScheduledDate, scheduledEvent);
when(scheduledDateGeneration.generateScheduledDates(anyInt(), (DateTime) anyObject(), (ScheduledEvent) anyObject(), anyBoolean())).thenReturn(generatedDates);
// exercise test
customerAccount.generateNextSetOfMeetingDates(scheduledDateGeneration);
//verification
assertThat(customerAccount.getAccountActionDates().size(), is(20));
}
use of org.mifos.domain.builders.CenterBuilder in project head by mifos.
the class CustomerSearchIdGenerationTest method removeGroupMembershipTest.
@Test
public void removeGroupMembershipTest() throws Exception {
// setup
short localeId = 1;
CustomerStatusUpdate customerStatusUpdate = new CustomerStatusUpdateBuilder().with(CustomerStatus.GROUP_CANCELLED).build();
PersonnelBO loanOfficer = PersonnelBuilder.anyLoanOfficer();
CenterBO existingCenter = new CenterBuilder().withLoanOfficer(loanOfficer).active().withNumberOfExistingCustomersInOffice(1).build();
GroupBO existingGroup = new GroupBuilder().pendingApproval().withParentCustomer(existingCenter).withVersion(customerStatusUpdate.getVersionNum()).build();
ClientBO existingClient = new ClientBuilder().withParentCustomer(existingGroup).pendingApproval().buildForUnitTests();
existingGroup.addChild(existingClient);
UserContext userContext = TestUtils.makeUser();
existingGroup.setUserContext(userContext);
existingClient.setUserContext(userContext);
existingClient.setCustomerDao(customerDao);
// stubbing
when(configurationPersistence.isGlimEnabled()).thenReturn(false);
when(customerDao.retrieveLastSearchIdValueForNonParentCustomersInOffice(anyShort())).thenReturn(3);
existingClient = spy(existingClient);
int customer_id = 22;
when(existingClient.getCustomerId()).thenReturn(customer_id);
// exercise test
assertThat(existingClient.getSearchId(), is("1.1.1.1"));
customerService.removeGroupMembership(existingClient, loanOfficer, accountNotesEntity, localeId);
// verification
assertThat(existingClient.getSearchId(), is("1." + customer_id));
}
use of org.mifos.domain.builders.CenterBuilder in project head by mifos.
the class CustomerAccountBOIntegrationTest method testTrxnDetailEntityObjectsForMultipleInstallmentsWhenOnlyCustomerAccountChargesAreDue.
@Test
public void testTrxnDetailEntityObjectsForMultipleInstallmentsWhenOnlyCustomerAccountChargesAreDue() throws Exception {
MeetingBO weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
center = new CenterBuilder().with(weeklyMeeting).withName("Center").with(sampleBranchOffice()).withLoanOfficer(testUser()).build();
IntegrationTestObjectMother.createCenter((CenterBO) center, weeklyMeeting);
CustomerAccountBO customerAccount = center.getCustomerAccount();
final Money fiftyAmount = new Money(getCurrency(), "50.0");
final Money seventyAmount = new Money(getCurrency(), "70.0");
final Money oneHundredTwentyAmount = new Money(getCurrency(), "120.0");
final Money twoHundredFortyAmount = new Money(getCurrency(), "240.0");
for (AccountActionDateEntity accountActionDateEntity : customerAccount.getAccountActionDates()) {
CustomerScheduleEntity customerSchedule = (CustomerScheduleEntity) accountActionDateEntity;
if (customerSchedule.getInstallmentId() != 2) {
customerSchedule.setMiscFee(fiftyAmount);
customerSchedule.setMiscPenalty(seventyAmount);
}
}
Date transactionDate = incrementCurrentDate(14);
PaymentData paymentData = PaymentData.createPaymentData(twoHundredFortyAmount, center.getPersonnel(), Short.valueOf("1"), transactionDate);
paymentData.setCustomer(center);
IntegrationTestObjectMother.applyAccountPayment(customerAccount, paymentData);
if (customerAccount.getAccountPayments() != null && customerAccount.getAccountPayments().size() == 1) {
for (AccountPaymentEntity accountPaymentEntity : customerAccount.getAccountPayments()) {
final Money zeroAmount = new Money(accountPaymentEntity.getAmount().getCurrency(), "0.0");
if (accountPaymentEntity.getAccountTrxns() != null && accountPaymentEntity.getAccountTrxns().size() == 3) {
for (AccountTrxnEntity accountTrxnEntity : accountPaymentEntity.getAccountTrxns()) {
CustomerTrxnDetailEntity customerTrxnDetailEntity = (CustomerTrxnDetailEntity) accountTrxnEntity;
if (customerTrxnDetailEntity.getInstallmentId() != 2) {
Assert.assertEquals(oneHundredTwentyAmount, customerTrxnDetailEntity.getAmount());
Assert.assertEquals(oneHundredTwentyAmount, customerTrxnDetailEntity.getTotalAmount());
Assert.assertEquals(fiftyAmount, customerTrxnDetailEntity.getMiscFeeAmount());
Assert.assertEquals(seventyAmount, customerTrxnDetailEntity.getMiscPenaltyAmount());
} else {
Assert.assertEquals(zeroAmount, customerTrxnDetailEntity.getAmount());
Assert.assertEquals(zeroAmount, customerTrxnDetailEntity.getTotalAmount());
Assert.assertEquals(zeroAmount, customerTrxnDetailEntity.getMiscFeeAmount());
Assert.assertEquals(zeroAmount, customerTrxnDetailEntity.getMiscPenaltyAmount());
}
Assert.assertEquals(0, customerTrxnDetailEntity.getFeesTrxnDetails().size());
}
} else {
throw new Exception("Expected three CustomerTrxnDetailEntity, found none or not three");
}
}
} else {
throw new Exception("Expected one AccountPaymentEntity, found none or more than one");
}
}
Aggregations