use of org.mifos.accounts.exceptions.AccountException in project head by mifos.
the class CenterServiceFacadeWebTier method retrieveChargesDetails.
@Override
public CustomerChargesDetailsDto retrieveChargesDetails(Integer customerId) {
MifosUser mifosUser = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = new UserContextFactory().create(mifosUser);
CustomerBO customerBO = this.customerDao.findCustomerById(customerId);
CustomerAccountBO customerAccount = customerBO.getCustomerAccount();
try {
personnelDao.checkAccessPermission(userContext, customerBO.getOfficeId(), customerBO.getLoanOfficerId());
} catch (AccountException e) {
throw new MifosRuntimeException("Access denied!", e);
}
List<AccountFeesDto> accountFeesDtos = new ArrayList<AccountFeesDto>();
if (!customerAccount.getAccountFees().isEmpty()) {
for (AccountFeesEntity accountFeesEntity : customerAccount.getAccountFees()) {
AccountFeesDto accountFeesDto = new AccountFeesDto(accountFeesEntity.getFees().getFeeFrequency().getFeeFrequencyType().getId(), (accountFeesEntity.getFees().getFeeFrequency().getFeePayment() != null ? accountFeesEntity.getFees().getFeeFrequency().getFeePayment().getId() : null), accountFeesEntity.getFeeStatus(), accountFeesEntity.getFees().getFeeName(), accountFeesEntity.getAccountFeeAmount().toString(), getMeetingRecurrence(accountFeesEntity.getFees().getFeeFrequency().getFeeMeetingFrequency(), userContext), accountFeesEntity.getFees().getFeeId());
accountFeesDtos.add(accountFeesDto);
}
}
CustomerScheduleDto customerSchedule = null;
CustomerScheduleEntity scheduleEntity = (CustomerScheduleEntity) customerAccount.getUpcomingInstallment();
if (scheduleEntity != null) {
Set<AccountFeesActionDetailEntity> feeEntities = scheduleEntity.getAccountFeesActionDetails();
List<AccountFeeScheduleDto> feeDtos = new ArrayList<AccountFeeScheduleDto>();
for (AccountFeesActionDetailEntity feeEntity : feeEntities) {
feeDtos.add(convertToDto(feeEntity));
}
customerSchedule = new CustomerScheduleDto(scheduleEntity.getMiscFee().toString(), scheduleEntity.getMiscFeePaid().toString(), scheduleEntity.getMiscPenalty().toString(), scheduleEntity.getMiscPenaltyPaid().toString(), feeDtos);
}
return new CustomerChargesDetailsDto(customerAccount.getNextDueAmount().toString(), customerAccount.getTotalAmountInArrears().toString(), customerAccount.getTotalAmountDue().toString(), customerAccount.getUpcomingChargesDate(), customerSchedule, accountFeesDtos);
}
use of org.mifos.accounts.exceptions.AccountException in project head by mifos.
the class ProductMixValidatorIntegrationTest method testShouldDetectProductMixConflicts.
@Test
public void testShouldDetectProductMixConflicts() throws Exception {
short PRD_OFFERING_ID_TWO = (short) 2;
LoanBO loanMock1 = createMock(LoanBO.class);
LoanBO loanMock2 = createMock(LoanBO.class);
LoanOfferingBO loanOfferingMock1 = createMock(LoanOfferingBO.class);
LoanOfferingBO loanOfferingMock2 = createMock(LoanOfferingBO.class);
expect(loanMock2.getLoanOffering()).andReturn(loanOfferingMock2);
expect(loanMock1.getLoanOffering()).andReturn(loanOfferingMock1);
expect(loanOfferingMock2.getPrdOfferingId()).andReturn(PRD_OFFERING_ID_TWO);
expect(productMixBusinessServiceMock.canProductsCoExist(loanOfferingMock2, loanOfferingMock1)).andReturn(false);
replay(loanMock1, loanMock2, loanOfferingMock1, loanOfferingMock2, productMixBusinessServiceMock);
try {
new ProductMixValidator(configServiceMock, productMixBusinessServiceMock) {
@Override
void handleConflict(LoanBO newloan, LoanBO loan) throws AccountException {
throw new AccountException("Some exception code");
}
}.validateProductMix(loanMock2, Arrays.asList(loanMock1));
Assert.fail("Product mix conflict not detected");
verify(loanMock1, loanMock2, loanOfferingMock1, loanOfferingMock2, productMixBusinessServiceMock);
} catch (AccountException e) {
}
}
use of org.mifos.accounts.exceptions.AccountException in project head by mifos.
the class CustomerAccountBOIntegrationTest method testApplyMiscChargeWithNonActiveCustomer.
@Test
public void testApplyMiscChargeWithNonActiveCustomer() throws Exception {
MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
center = TestObjectFactory.createWeeklyFeeCenter("Center_Active_test", meeting);
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group_Active_test", CustomerStatus.GROUP_PARTIAL, center);
StaticHibernateUtil.flushSession();
center = TestObjectFactory.getCustomer(center.getCustomerId());
group = TestObjectFactory.getCustomer(group.getCustomerId());
customerAccountBO = group.getCustomerAccount();
UserContext uc = TestUtils.makeUser();
customerAccountBO.setUserContext(uc);
try {
customerAccountBO.applyCharge(Short.valueOf("-1"), new Double("33"));
Assert.assertFalse(false);
} catch (AccountException e) {
Assert.assertEquals(AccountConstants.MISC_CHARGE_NOT_APPLICABLE, e.getKey());
}
}
use of org.mifos.accounts.exceptions.AccountException in project head by mifos.
the class IntegrationTestObjectMother method applyAccountPayment.
public static void applyAccountPayment(AccountBO loan, PaymentData paymentData) {
try {
StaticHibernateUtil.startTransaction();
loan.applyPayment(paymentData);
StaticHibernateUtil.commitTransaction();
} catch (AccountException e) {
StaticHibernateUtil.rollbackTransaction();
throw new RuntimeException(e);
} finally {
StaticHibernateUtil.closeSession();
}
}
use of org.mifos.accounts.exceptions.AccountException in project head by mifos.
the class LoanBO method handleArrears.
public void handleArrears() throws AccountException {
AccountStateEntity stateEntity;
try {
stateEntity = legacyMasterDao.getPersistentObject(AccountStateEntity.class, AccountStates.LOANACC_BADSTANDING);
} catch (PersistenceException e) {
throw new AccountException(e);
}
AccountStatusChangeHistoryEntity historyEntity = new AccountStatusChangeHistoryEntity(this.getAccountState(), stateEntity, this.getPersonnel(), this);
this.addAccountStatusChangeHistory(historyEntity);
this.setAccountState(stateEntity);
try {
String systemDate = DateUtils.getCurrentDate();
Date currrentDate = DateUtils.getLocaleDate(systemDate);
this.setUpdatedDate(currrentDate);
} catch (InvalidDateException ide) {
throw new AccountException(ide);
}
try {
getlegacyLoanDao().createOrUpdate(this);
} catch (PersistenceException e) {
throw new AccountException(e);
}
}
Aggregations