use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.
the class LoanBO method getTotalInterestAmountInArrears.
public Money getTotalInterestAmountInArrears() {
Money amount = new Money(getCurrency());
List<AccountActionDateEntity> actionDateList = getDetailsOfInstallmentsInArrears();
for (AccountActionDateEntity accountActionDateEntity : actionDateList) {
LoanScheduleEntity loanScheduleEntity = (LoanScheduleEntity) accountActionDateEntity;
amount = amount.add(loanScheduleEntity.getInterest().subtract(loanScheduleEntity.getInterestPaid()));
}
return amount;
}
use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.
the class LoanBO method makeWriteOffOrReschedulePaymentForFutureInstallments.
private void makeWriteOffOrReschedulePaymentForFutureInstallments(final AccountPaymentEntity accountPaymentEntity, final String comments, final AccountActionTypes accountActionTypes, final PersonnelBO currentUser) {
List<AccountActionDateEntity> futureInstallmentsList = getApplicableIdsForFutureInstallmentsForWriteOffOrReschedule();
for (AccountActionDateEntity accountActionDateEntity : futureInstallmentsList) {
LoanScheduleEntity loanSchedule = (LoanScheduleEntity) accountActionDateEntity;
Money principal = loanSchedule.getPrincipalDue();
Money interest = loanSchedule.getInterestDue();
Money fees = loanSchedule.getTotalFeeDueWithMiscFeeDue();
Money penalty = loanSchedule.getPenaltyDue();
LoanTrxnDetailEntity loanTrxnDetailEntity = new LoanTrxnDetailEntity(accountPaymentEntity, accountActionTypes, loanSchedule.getInstallmentId(), loanSchedule.getActionDate(), currentUser, accountPaymentEntity.getPaymentDate(), principal, comments, null, principal, new Money(getCurrency()), new Money(getCurrency()), new Money(getCurrency()), new Money(getCurrency()), null, null);
accountPaymentEntity.addAccountTrxn(loanTrxnDetailEntity);
loanSchedule.makeEarlyRepaymentEntries(LoanConstants.DONOT_PAY_FEES_PENALTY_INTEREST, loanSchedule.getInterestDue(), accountPaymentEntity.getPaymentDate());
loanSummary.decreaseBy(null, interest, penalty, fees);
updatePaymentDetails(accountActionTypes, principal, null, null, null);
}
}
use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.
the class LoanBO method applyPeriodicFee.
/**
* The fee (new or to be updated) is applied to the given list of AccountActionDateEntity(s). Note that the entities
* are the actual entity objects referenced by the loan, so this method acts by side-effect, adding fees to the
* given entities.
*
* @param fee
* the periodic FeeBO to apply to the given AccountActionDateEntity(s)
* @param charge
* the
* @param dueInstallments
* @throws AccountException
* @throws PersistenceException
*/
private void applyPeriodicFee(final FeeBO fee, final Double charge, final List<AccountActionDateEntity> dueInstallments) throws AccountException {
// Create an AccountFeesEntity linking the loan to the given fee fee and charge if the fee hasn't been applied,
// or
// update the applied fee's AccountFeesEntity.feeAmount with the given charge. Then set the
// AccountFeeEntity.accountFeeAmount to this loan's originalInterest.
AccountFeesEntity accountFee = getAccountFee(fee, charge);
Set<AccountFeesEntity> accountFeeSet = new HashSet<AccountFeesEntity>();
accountFeeSet.add(accountFee);
populateAccountFeeAmount(accountFeeSet, loanSummary.getOriginalInterest());
// Extract the list of InstallmentDate(s) from the given AccountActionDateEntity(s). Note that
// the installmentId(s) likely do not start with 1 since the fee may be applied after some
// installment dates have passed.
List<InstallmentDate> installmentDates = new ArrayList<InstallmentDate>();
for (AccountActionDateEntity accountActionDateEntity : dueInstallments) {
installmentDates.add(new InstallmentDate(accountActionDateEntity.getInstallmentId(), accountActionDateEntity.getActionDate()));
}
// Get the full list of all loan InstallmentDate(s), past, present and future, without adjusting for holidays.
// This will work correctly only if adjusting periodic fees is done when no installments have been paid
// boolean isRepaymentIndepOfMeetingEnabled = new ConfigurationPersistence().isRepaymentIndepOfMeetingEnabled();
// List<InstallmentDate> nonAdjustedInstallmentDates = getInstallmentDates(getLoanMeeting(), noOfInstallments,
// getInstallmentSkipToStartRepayment(), isRepaymentIndepOfMeetingEnabled,
// false);
// Use handlePeriodic to adjust fee installments for holiday periods and combine multiple fee installments due
// for the
// same loan installment. Finally, apply these updated fees to the given dueInstallments list and update
// loan summary and activity tables.
/*
* old way List<FeeInstallment> feeInstallmentList = mergeFeeInstallments(handlePeriodic(accountFee,
* installmentDates, nonAdjustedInstallmentDates));
*/
// new way
ScheduledEvent loanScheduledEvent = ScheduledEventFactory.createScheduledEventFrom(this.getMeetingForAccount());
List<FeeInstallment> feeInstallmentList = FeeInstallment.createMergedFeeInstallmentsForOneFeeStartingWith(loanScheduledEvent, accountFee, dueInstallments.size(), dueInstallments.get(0).getInstallmentId());
Money totalFeeAmountApplied = applyFeeToInstallments(feeInstallmentList, dueInstallments);
updateLoanSummary(fee.getFeeId(), totalFeeAmountApplied);
updateLoanActivity(fee.getFeeId(), totalFeeAmountApplied, fee.getFeeName() + AccountConstants.APPLIED);
}
use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.
the class LoanBO method getApplicableIdsForLateInstallments.
private List<AccountActionDateEntity> getApplicableIdsForLateInstallments() {
List<AccountActionDateEntity> lateActionDateList = new ArrayList<AccountActionDateEntity>();
AccountActionDateEntity nextInstallment = getDetailsOfNextInstallment();
if (nextInstallment != null) {
for (AccountActionDateEntity accountActionDate : getAccountActionDates()) {
if (!accountActionDate.isPaid() && accountActionDate.getInstallmentId() < nextInstallment.getInstallmentId()) {
lateActionDateList.add(accountActionDate);
}
}
} else {
lateActionDateList.addAll(getAccountActionDates());
}
return lateActionDateList;
}
use of org.mifos.accounts.business.AccountActionDateEntity 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());
}
}
}
Aggregations