use of org.mifos.service.BusinessRuleException in project head by mifos.
the class FeeServiceFacadeWebTier method updateFee.
@Override
public void updateFee(FeeUpdateRequest feeUpdateRequest) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = new UserContextFactory().create(user);
try {
this.feeService.update(feeUpdateRequest, userContext);
} catch (ApplicationException e) {
throw new BusinessRuleException(e.getKey(), e);
}
}
use of org.mifos.service.BusinessRuleException in project head by mifos.
the class FeeServiceFacadeWebTier method parameters.
private FeeParameters parameters() {
try {
List<GLCodeEntity> glCodes = generalLedgerDao.retreiveGlCodesBy(FinancialActionConstants.FEEPOSTING, FinancialConstants.CREDIT);
List<CategoryTypeEntity> categories = this.feeDao.doRetrieveFeeCategories();
List<FeeFormulaEntity> formulas = this.feeDao.retrieveFeeFormulae();
List<FeeFrequencyTypeEntity> frequencies = this.feeDao.retrieveFeeFrequencies();
List<FeePaymentEntity> timesOfCharging = this.feeDao.retrieveFeePayments();
List<MasterDataEntity> timesOfChargeingCustomer = new ArrayList<MasterDataEntity>();
for (MasterDataEntity timeOfCharging : timesOfCharging) {
if (timeOfCharging.getId().equals(FeePayment.UPFRONT.getValue())) {
timesOfChargeingCustomer.add(timeOfCharging);
}
}
return new FeeParameters(listToMap(categories), listToMap(timesOfCharging), listToMap(timesOfChargeingCustomer), listToMap(formulas), listToMap(frequencies), glCodesToMap(glCodes));
} catch (FinancialException e) {
throw new BusinessRuleException(e.getKey(), e);
}
}
use of org.mifos.service.BusinessRuleException in project head by mifos.
the class LoanBO method waiveOverdueChargesFromMemberAccounts.
public void waiveOverdueChargesFromMemberAccounts(String chargeType) {
for (LoanBO member : getMemberAccounts()) {
List<AccountActionDateEntity> memberAccountActionDateList = member.getApplicableIdsForNextInstallmentAndArrears();
List<LoanScheduleEntity> overdueMemberAccountActionDateEntities = new ArrayList<LoanScheduleEntity>();
for (AccountActionDateEntity accountActionDateEntity : memberAccountActionDateList) {
if (accountActionDateEntity.getActionDate().before(DateUtils.getCurrentDateWithoutTimeStamp())) {
overdueMemberAccountActionDateEntities.add((LoanScheduleEntity) accountActionDateEntity);
}
}
Money principal = new Money(getCurrency());
Money interest = new Money(getCurrency());
Money fee = new Money(getCurrency());
Money penalty = new Money(getCurrency());
if (chargeType == LoanConstants.FEE_WAIVED) {
for (LoanScheduleEntity memberAccountActionDateEntity : overdueMemberAccountActionDateEntities) {
fee = fee.add(memberAccountActionDateEntity.waiveFeeCharges());
}
member.updateTotalFeeAmount(fee);
} else if (chargeType == LoanConstants.PENALTY_WAIVED) {
for (LoanScheduleEntity memberAccountActionDateEntity : overdueMemberAccountActionDateEntities) {
penalty = penalty.add(memberAccountActionDateEntity.waivePenaltyCharges());
}
member.updateTotalPenaltyAmount(penalty);
}
try {
member.updateAccountActivity(principal, interest, fee, penalty, userContext.getId(), chargeType);
} catch (AccountException e) {
throw new BusinessRuleException(e.getKey());
}
}
}
use of org.mifos.service.BusinessRuleException in project head by mifos.
the class HolidayServiceImpl method create.
@Override
public void create(HolidayDetails holidayDetails, List<Short> officeIds) {
HolidayBO holiday = HolidayBO.fromDto(holidayDetails);
holiday.validate();
List<OfficeBO> offices = new ArrayList<OfficeBO>();
for (Short officeId : officeIds) {
OfficeBO office = officeDao.findOfficeById(officeId);
offices.add(office);
if (office.hasChildWithAnyOf(officeIds)) {
throw new BusinessRuleException(HolidayConstants.HOLIDAY_CREATION_EXCEPTION);
// "Holidays can only be associated with one level of office in an office hierarchy."
}
}
try {
hibernateTransactionHelper.startTransaction();
this.holidayDao.save(holiday);
for (OfficeBO office : offices) {
office.addHoliday(holiday);
}
hibernateTransactionHelper.commitTransaction();
} catch (Exception e) {
hibernateTransactionHelper.rollbackTransaction();
} finally {
hibernateTransactionHelper.closeSession();
}
}
use of org.mifos.service.BusinessRuleException in project head by mifos.
the class ImportTransactionsServiceFacadeWebTier method undoFullImport.
@Override
public void undoFullImport(String importTransactionsFileName) {
MifosUser mifosUser = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = new UserContextFactory().create(mifosUser);
TreeSet<String> accountsWithAdjustedPayments = new TreeSet<String>();
try {
ImportedFilesEntity filesEntity = this.importedFilesService.getImportedFileByName(importTransactionsFileName);
List<AccountTrxnEntity> trxUndo = new ArrayList<AccountTrxnEntity>(filesEntity.getImportedTrxn());
List<ImportedAccPaymentDto> accPaymentList = new ArrayList<ImportedAccPaymentDto>();
for (AccountTrxnEntity trxn : trxUndo) {
try {
validateForAdjustedPayments(trxn, accountsWithAdjustedPayments);
accPaymentList.add(new ImportedAccPaymentDto(trxn.getAccount().getGlobalAccountNum(), trxn.getAccountPayment().getPaymentId()));
} catch (BusinessRuleException e) {
//nothing to do
}
}
for (ImportedAccPaymentDto accDto : accPaymentList) {
try {
this.accountServiceFacade.applyHistoricalAdjustment(accDto.getGlobalNum(), accDto.getPaymentId(), IMPORT_UNDONE, userContext.getId(), null);
} catch (MifosRuntimeException e) {
// TODO: validation will be added with MIFOS-5779
}
}
this.importedFilesService.saveImportedFileName(filesEntity.getFileName(), filesEntity.getSubmittedBy(), null, Boolean.TRUE, filesEntity.getUndoable());
} catch (Exception e) {
throw new MifosRuntimeException(e);
}
}
Aggregations