use of org.mifos.accounts.fees.business.FeeBO in project head by mifos.
the class LoanPrdAction method getFeeViewList.
private List<FeeDto> getFeeViewList(UserContext userContext, List<FeeBO> fees) {
logger.debug("start getFeeViewList method of Loan Product Action ");
List<FeeDto> feeDtos = new ArrayList<FeeDto>();
if (fees != null && fees.size() > 0) {
for (FeeBO fee : fees) {
feeDtos.add(new FeeDto(userContext, fee));
}
}
logger.debug("getFeeViewList method of Loan Product Action called");
return feeDtos.size() > 0 ? feeDtos : null;
}
use of org.mifos.accounts.fees.business.FeeBO in project head by mifos.
the class LoanPrdAction method getFeeList.
private List<FeeBO> getFeeList(List<FeeBO> fees, String[] feesSelected) {
logger.debug("start getFeeList method of Loan Product Action ");
List<FeeBO> feeList = new ArrayList<FeeBO>();
if (feesSelected != null && feesSelected.length > 0 && fees != null && fees.size() > 0) {
for (String feeSelected : feesSelected) {
FeeBO fee = getFeeFromList(fees, feeSelected);
if (fee != null) {
feeList.add(fee);
}
}
}
logger.debug("getFeeList method of Loan Product Action called");
return feeList;
}
use of org.mifos.accounts.fees.business.FeeBO in project head by mifos.
the class LegacyLoanDaoIntegrationTest method testSaveAndGetOriginalLoanScheduleEntityWithFees.
@Test
public void testSaveAndGetOriginalLoanScheduleEntityWithFees() throws PersistenceException {
ArrayList<OriginalLoanScheduleEntity> originalLoanScheduleEntities = new ArrayList<OriginalLoanScheduleEntity>();
Date date = new Date(new java.util.Date().getTime());
Short installmentId = new Short("1");
FeeBO upfrontFee = TestObjectFactory.createOneTimeRateFee("Upfront Fee", FeeCategory.LOAN, Double.valueOf("20"), FeeFormula.AMOUNT, FeePayment.UPFRONT, null);
AccountFeesEntity accountUpfrontFee = new AccountFeesEntity(goodAccount, upfrontFee, new Double("20.0"), FeeStatus.ACTIVE.getValue(), null, date);
AccountTestUtils.addAccountFees(accountUpfrontFee, goodAccount);
TestObjectFactory.updateObject(goodAccount);
goodAccount = (LoanBO) TestObjectFactory.getObject(AccountBO.class, goodAccount.getAccountId());
LoanScheduleEntity loanScheduleEntity = new LoanScheduleEntity(goodAccount, group, installmentId, date, PaymentStatus.UNPAID, Money.zero(), Money.zero());
LoanFeeScheduleEntity feesEntity = new LoanFeeScheduleEntity(loanScheduleEntity, upfrontFee, accountUpfrontFee, Money.zero());
loanScheduleEntity.addAccountFeesAction(feesEntity);
OriginalLoanScheduleEntity originalLoanScheduleEntity = new OriginalLoanScheduleEntity(loanScheduleEntity);
OriginalLoanFeeScheduleEntity scheduleEntityFee = new OriginalLoanFeeScheduleEntity(feesEntity, originalLoanScheduleEntity);
originalLoanScheduleEntities.add(originalLoanScheduleEntity);
legacyLoanDao.saveOriginalSchedule(originalLoanScheduleEntities);
List<OriginalLoanScheduleEntity> actual = legacyLoanDao.getOriginalLoanScheduleEntity(goodAccount.getAccountId());
List<OriginalLoanFeeScheduleEntity> fees = new ArrayList<OriginalLoanFeeScheduleEntity>(actual.get(0).getAccountFeesActionDetails());
Assert.assertEquals(1, actual.size());
Assert.assertEquals(1, fees.size());
assertThat(actual, is(new OriginalLoanScheduleEntitiesMatcher(originalLoanScheduleEntities)));
assertThat(fees.get(0), is(new OriginalLoanFeeScheduleEntityMatcher(scheduleEntityFee)));
}
use of org.mifos.accounts.fees.business.FeeBO in project head by mifos.
the class LoanBO method removeFeesAssociatedWithUpcomingAndAllKnownFutureInstallments.
/**
* Remove the fee from all unpaid current or future installments, and update the loan accordingly.
*/
@Override
public final void removeFeesAssociatedWithUpcomingAndAllKnownFutureInstallments(final Short feeId, final Short personnelId) throws AccountException {
List<Short> installmentIds = getApplicableInstallmentIdsForRemoveFees();
Money totalFeeAmount;
if (installmentIds != null && installmentIds.size() != 0 && isFeeActive(feeId)) {
FeeBO fee = getAccountFeesObject(feeId);
if (havePaymentsBeenMade() && fee.doesFeeInvolveFractionalAmounts()) {
throw new AccountException(AccountExceptionConstants.CANT_REMOVE_FEE_EXCEPTION);
}
if (fee.isTimeOfDisbursement()) {
AccountFeesEntity accountFee = getAccountFees(feeId);
totalFeeAmount = accountFee.getAccountFeeAmount();
removeAccountFee(accountFee);
this.delete(accountFee);
} else {
totalFeeAmount = updateAccountActionDateEntity(installmentIds, feeId);
updateAccountFeesEntity(feeId);
}
updateTotalFeeAmount(totalFeeAmount);
String description = fee.getFeeName() + " " + AccountConstants.FEES_REMOVED;
updateAccountActivity(null, null, totalFeeAmount, null, personnelId, description);
if (!havePaymentsBeenMade()) {
LoanScheduleRounderHelper loanScheduleRounderHelper = new DefaultLoanScheduleRounderHelper();
LoanScheduleRounder loanScheduleInstallmentRounder = getLoanScheduleRounder(loanScheduleRounderHelper);
List<LoanScheduleEntity> unroundedLoanSchedules = new ArrayList<LoanScheduleEntity>();
List<LoanScheduleEntity> allExistingLoanSchedules = new ArrayList<LoanScheduleEntity>();
List<AccountActionDateEntity> installmentsToRound = getInstallmentsToRound();
for (AccountActionDateEntity installment : installmentsToRound) {
unroundedLoanSchedules.add((LoanScheduleEntity) installment);
}
List<AccountActionDateEntity> allExistingInstallments = this.getAllInstallments();
for (AccountActionDateEntity installment : allExistingInstallments) {
allExistingLoanSchedules.add((LoanScheduleEntity) installment);
}
List<LoanScheduleEntity> roundedLoanSchedules = loanScheduleInstallmentRounder.round(this.gracePeriodType.asEnum(), this.gracePeriodDuration, this.loanAmount, this.interestType.asEnum(), unroundedLoanSchedules, allExistingLoanSchedules);
// applyRounding_v2();
}
try {
ApplicationContextProvider.getBean(LegacyAccountDao.class).createOrUpdate(this);
} catch (PersistenceException e) {
throw new AccountException(e);
}
}
}
use of org.mifos.accounts.fees.business.FeeBO in project head by mifos.
the class AccountBusinessService method filterDisbursementFee.
private void filterDisbursementFee(List<FeeBO> feeList, AccountBO account) {
for (Iterator<FeeBO> iter = feeList.iterator(); iter.hasNext(); ) {
FeeBO fee = iter.next();
FeePaymentEntity feePaymentEntity = fee.getFeeFrequency().getFeePayment();
if (feePaymentEntity != null) {
Short paymentType = feePaymentEntity.getId();
if (paymentType.equals(FeePayment.TIME_OF_DISBURSEMENT.getValue())) {
AccountState accountState = account.getState();
if (accountState == AccountState.LOAN_PARTIAL_APPLICATION || accountState == AccountState.LOAN_PENDING_APPROVAL || accountState == AccountState.LOAN_APPROVED || accountState == AccountState.LOAN_DISBURSED_TO_LOAN_OFFICER) {
continue;
} else {
iter.remove();
}
}
}
}
}
Aggregations