use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class CenterUpdateTest method rollsbackTransactionClosesSessionAndReThrowsApplicationException.
@Test(expected = CustomerException.class)
public void rollsbackTransactionClosesSessionAndReThrowsApplicationException() throws Exception {
// setup
PersonnelBO existingLoanOfficer = PersonnelBuilder.anyLoanOfficer();
UserContext userContext = TestUtils.makeUser();
CenterUpdate centerUpdate = new CenterUpdateBuilder().build();
// stubbing
when(customerDao.findCustomerById(centerUpdate.getCustomerId())).thenReturn(mockedCenter);
when(personnelDao.findPersonnelById(centerUpdate.getLoanOfficerId())).thenReturn(existingLoanOfficer);
when(mockedCenter.isLoanOfficerChanged(existingLoanOfficer)).thenReturn(false);
when(mockedCenter.getOffice()).thenReturn(new OfficeBuilder().build());
// stub
doThrow(new CustomerException(CustomerConstants.ERRORS_DUPLICATE_CUSTOMER)).when(mockedCenter).validate();
// exercise test
customerService.updateCenter(userContext, centerUpdate);
// verification
verify(hibernateTransaction).rollbackTransaction();
verify(hibernateTransaction).closeSession();
}
use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class CenterValidationTest method cannotCreateCenterWithoutALoanOfficer.
@Test
public void cannotCreateCenterWithoutALoanOfficer() {
// setup
PersonnelBO noLoanOfficer = null;
center = new CenterBuilder().withName("center1").withLoanOfficer(noLoanOfficer).build();
// exercise test
try {
center.validate();
fail("cannotCreateCenterWithoutALoanOfficer");
} catch (ApplicationException e) {
assertThat(e.getKey(), is(CustomerConstants.ERRORS_SELECT_LOAN_OFFICER));
}
}
use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class CustomerCreationDaoHibernateIntegrationTest method testShouldCreateCustomerAndCustomerAccount.
@Test
public void testShouldCreateCustomerAndCustomerAccount() throws Exception {
String displayName = "centerCascade";
Address address = null;
final List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
final List<FeeDto> fees = new ArrayList<FeeDto>();
final String externalId = null;
final Date mfiJoiningDate = new DateTime().minusDays(1).toDate();
final OfficeBO existingOffice = IntegrationTestObjectMother.sampleBranchOffice();
final PersonnelBO loanOfficer = IntegrationTestObjectMother.testUser();
UserContext userContext = new UserContext();
userContext.setId(loanOfficer.getPersonnelId());
userContext.setBranchId(existingOffice.getOfficeId());
userContext.setBranchGlobalNum(existingOffice.getGlobalOfficeNum());
center = new CenterBO(userContext, displayName, address, customFields, fees, externalId, mfiJoiningDate, existingOffice, weeklyMeeting, loanOfficer, new CustomerPersistence());
StaticHibernateUtil.startTransaction();
customerDao.save(center);
StaticHibernateUtil.flushSession();
assertThat(center.getCustomerAccount(), is(notNullValue()));
assertThat(center.getGlobalCustNum(), is(nullValue()));
}
use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class CustomerTrxnDetailEntityIntegrationTest method testGenerateReverseTrxn.
@Test
public void testGenerateReverseTrxn() throws Exception {
accountBO = client.getCustomerAccount();
Date currentDate = new Date(System.currentTimeMillis());
CustomerAccountBO customerAccountBO = (CustomerAccountBO) accountBO;
customerAccountBO.setUserContext(userContext);
CustomerScheduleEntity accountAction = (CustomerScheduleEntity) customerAccountBO.getAccountActionDate(Short.valueOf("1"));
accountAction.setMiscFeePaid(TestUtils.createMoney(100));
accountAction.setMiscPenaltyPaid(TestUtils.createMoney(100));
accountAction.setPaymentDate(currentDate);
accountAction.setPaymentStatus(PaymentStatus.PAID);
AccountPaymentEntity accountPaymentEntity = new AccountPaymentEntity(accountBO, TestUtils.createMoney(100), "1111", currentDate, new PaymentTypeEntity(Short.valueOf("1")), new Date(System.currentTimeMillis()));
CustomerTrxnDetailEntity accountTrxnEntity = new CustomerTrxnDetailEntity(accountPaymentEntity, AccountActionTypes.PAYMENT, Short.valueOf("1"), accountAction.getActionDate(), TestObjectFactory.getPersonnel(userContext.getId()), currentDate, TestUtils.createMoney(200), "payment done", null, TestUtils.createMoney(100), TestUtils.createMoney(100));
for (AccountFeesActionDetailEntity accountFeesActionDetailEntity : accountAction.getAccountFeesActionDetails()) {
CustomerAccountBOTestUtils.setFeeAmountPaid((CustomerFeeScheduleEntity) accountFeesActionDetailEntity, TestUtils.createMoney(100));
FeesTrxnDetailEntity feeTrxn = new FeesTrxnDetailEntity(accountTrxnEntity, accountFeesActionDetailEntity.getAccountFee(), accountFeesActionDetailEntity.getFeeAmount());
accountTrxnEntity.addFeesTrxnDetail(feeTrxn);
}
accountPaymentEntity.addAccountTrxn(accountTrxnEntity);
AccountTestUtils.addAccountPayment(accountPaymentEntity, customerAccountBO);
PersonnelBO loggedInUser = legacyPersonnelDao.getPersonnel(userContext.getId());
for (AccountTrxnEntity accntTrxn : customerAccountBO.findMostRecentPaymentByPaymentDate().getAccountTrxns()) {
AccountTrxnEntity reverseAccntTrxn = ((CustomerTrxnDetailEntity) accntTrxn).generateReverseTrxn(loggedInUser, "adjustment");
Assert.assertEquals(reverseAccntTrxn.getAmount(), accntTrxn.getAmount().negate());
Assert.assertEquals(loggedInUser.getPersonnelId(), reverseAccntTrxn.getPersonnel().getPersonnelId());
}
}
use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class CustomerAccountBOIntegrationTest method testUpdateInstallmentAfterAdjustment.
@Test
public void testUpdateInstallmentAfterAdjustment() throws Exception {
userContext = TestUtils.makeUser();
createInitialObjects();
applyPayment();
customerAccountBO = TestObjectFactory.getObject(CustomerAccountBO.class, customerAccountBO.getAccountId());
client = customerAccountBO.getCustomer();
customerAccountBO.setUserContext(userContext);
List<AccountTrxnEntity> reversedTrxns = AccountTestUtils.reversalAdjustment("payment adjustment done", customerAccountBO.findMostRecentPaymentByPaymentDate());
PersonnelBO loggedInUser = IntegrationTestObjectMother.testUser();
customerAccountBO.updateInstallmentAfterAdjustment(reversedTrxns, loggedInUser);
for (AccountTrxnEntity accntTrxn : reversedTrxns) {
CustomerTrxnDetailEntity custTrxn = (CustomerTrxnDetailEntity) accntTrxn;
CustomerScheduleEntity accntActionDate = (CustomerScheduleEntity) customerAccountBO.getAccountActionDate(custTrxn.getInstallmentId());
Assert.assertEquals("Misc Fee Adjusted", accntActionDate.getMiscFeePaid(), TestUtils.createMoney());
Assert.assertEquals("Misc Penalty Adjusted", accntActionDate.getMiscPenaltyPaid(), TestUtils.createMoney());
}
for (CustomerActivityEntity customerActivityEntity : customerAccountBO.getCustomerActivitDetails()) {
Assert.assertEquals("Amnt Adjusted", customerActivityEntity.getDescription());
}
}
Aggregations