use of org.mifos.accounts.util.helpers.WaiveEnum in project head by mifos.
the class CenterServiceFacadeWebTier method waiveChargesDue.
@Override
public void waiveChargesDue(Integer accountId, Integer waiveType) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
try {
AccountBO account = new AccountBusinessService().getAccount(accountId);
account.updateDetails(userContext);
PersonnelBO loggedInUser = this.personnelDao.findPersonnelById(userContext.getId());
WaiveEnum waiveEnum = WaiveEnum.fromInt(waiveType);
if (account.getPersonnel() != null) {
new AccountBusinessService().checkPermissionForWaiveDue(waiveEnum, account.getType(), account.getCustomer().getLevel(), userContext, account.getOffice().getOfficeId(), account.getPersonnel().getPersonnelId());
} else {
new AccountBusinessService().checkPermissionForWaiveDue(waiveEnum, account.getType(), account.getCustomer().getLevel(), userContext, account.getOffice().getOfficeId(), userContext.getId());
}
try {
this.transactionHelper.startTransaction();
if (account instanceof LoanBO) {
((LoanBO) account).waiveAmountDue(waiveEnum);
} else if (account instanceof SavingsBO) {
((SavingsBO) account).waiveNextDepositAmountDue(loggedInUser);
} else {
((CustomerAccountBO) account).waiveAmountDue();
}
this.customerDao.save(account);
this.transactionHelper.commitTransaction();
} catch (Exception e) {
this.transactionHelper.rollbackTransaction();
throw new BusinessRuleException(account.getAccountId().toString(), e);
} finally {
this.transactionHelper.closeSession();
}
} catch (ServiceException e) {
throw new MifosRuntimeException(e);
} catch (ApplicationException e) {
throw new BusinessRuleException(e.getKey(), e);
}
}
use of org.mifos.accounts.util.helpers.WaiveEnum in project head by mifos.
the class WaiveEnumTest method shouldReturnPenaltyWaiveEnum.
@Test
public void shouldReturnPenaltyWaiveEnum() {
WaiveEnum result = WaiveEnum.fromInt(1);
assertThat(result, is(WaiveEnum.PENALTY));
}
use of org.mifos.accounts.util.helpers.WaiveEnum in project head by mifos.
the class WaiveEnumTest method shouldReturnAllWaiveEnumForValuesNotEqualToZeroOrOne.
@Test
public void shouldReturnAllWaiveEnumForValuesNotEqualToZeroOrOne() {
WaiveEnum result = WaiveEnum.fromInt(-1);
assertThat(result, is(WaiveEnum.ALL));
}
use of org.mifos.accounts.util.helpers.WaiveEnum in project head by mifos.
the class WaiveEnumTest method shouldReturnFeeWaiveEnum.
@Test
public void shouldReturnFeeWaiveEnum() {
WaiveEnum result = WaiveEnum.fromInt(0);
assertThat(result, is(WaiveEnum.FEES));
}
use of org.mifos.accounts.util.helpers.WaiveEnum in project head by mifos.
the class WaiveEnumTest method shouldReturnAllWaiveEnumForValuesNotEqualToZeroOrOne_2.
@Test
public void shouldReturnAllWaiveEnumForValuesNotEqualToZeroOrOne_2() {
WaiveEnum result = WaiveEnum.fromInt(2);
assertThat(result, is(WaiveEnum.ALL));
}
Aggregations