use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.
the class CustomerAccountBO method getTotalAmountDue.
@Override
public Money getTotalAmountDue() {
Money totalAmt = getTotalAmountInArrears();
List<AccountActionDateEntity> dueActionDateList = getTotalDueInstallments();
if (dueActionDateList.size() > 0) {
AccountActionDateEntity nextInstallment = dueActionDateList.get(0);
totalAmt = totalAmt.add(getDueAmount(nextInstallment));
}
return totalAmt;
}
use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.
the class CustomerAccountBO method applyCharge.
@Override
public void applyCharge(final Short feeId, final Double charge) throws AccountException {
if (!isCustomerValid()) {
if (feeId.equals(Short.valueOf(AccountConstants.MISC_FEES)) || feeId.equals(Short.valueOf(AccountConstants.MISC_PENALTY))) {
throw new AccountException(AccountConstants.MISC_CHARGE_NOT_APPLICABLE);
}
addFeeToAccountFee(feeId, charge);
FeeBO fee = getFeeDao().findById(feeId);
updateCustomerActivity(feeId, new Money(((AmountFeeBO) fee).getFeeAmount().getCurrency(), charge.toString()), fee.getFeeName() + AccountConstants.APPLIED);
} else {
Money chargeAmount = new Money(getCurrency(), String.valueOf(charge));
List<AccountActionDateEntity> dueInstallments = null;
if (feeId.equals(Short.valueOf(AccountConstants.MISC_FEES)) || feeId.equals(Short.valueOf(AccountConstants.MISC_PENALTY))) {
dueInstallments = getTotalDueInstallments();
if (dueInstallments.isEmpty()) {
throw new AccountException(AccountConstants.NOMOREINSTALLMENTS);
}
applyMiscCharge(feeId, chargeAmount, dueInstallments.get(0));
} else {
dueInstallments = getTotalDueInstallments();
if (dueInstallments.isEmpty()) {
throw new AccountException(AccountConstants.NOMOREINSTALLMENTS);
}
FeeBO fee = getFeeDao().findById(feeId);
if (fee.getFeeFrequency().getFeePayment() != null) {
applyOneTimeFee(fee, chargeAmount);
} else {
applyPeriodicFee(fee, chargeAmount);
}
}
}
}
use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.
the class CustomerAccountBO method findAllUnpaidInstallmentsUpToDatePlusNextMeeting.
private List<CustomerScheduleEntity> findAllUnpaidInstallmentsUpToDatePlusNextMeeting(final Date transactionDate) {
List<AccountActionDateEntity> unpaidDates = new ArrayList<AccountActionDateEntity>();
for (AccountActionDateEntity accountActionDateEntity : getAccountActionDates()) {
if (accountActionDateEntity != null && !accountActionDateEntity.isPaid()) {
unpaidDates.add(accountActionDateEntity);
}
}
final List<CustomerScheduleEntity> customerSchedulePayments = new ArrayList<CustomerScheduleEntity>();
for (AccountActionDateEntity accountActionDateEntity : unpaidDates) {
if (!accountActionDateEntity.getActionDate().after(transactionDate)) {
customerSchedulePayments.add((CustomerScheduleEntity) accountActionDateEntity);
}
}
AccountActionDateEntity nextMeeting = null;
for (AccountActionDateEntity accountActionDateEntity : getAccountActionDates()) {
if (accountActionDateEntity != null && accountActionDateEntity.getActionDate().after(transactionDate)) {
if (nextMeeting == null || nextMeeting.getActionDate().after(accountActionDateEntity.getActionDate())) {
nextMeeting = accountActionDateEntity;
}
}
}
if (nextMeeting != null && !nextMeeting.isPaid()) {
customerSchedulePayments.add((CustomerScheduleEntity) nextMeeting);
}
Collections.sort(customerSchedulePayments, new Comparator<CustomerScheduleEntity>() {
@Override
public int compare(CustomerScheduleEntity o1, CustomerScheduleEntity o2) {
return o1.getActionDate().compareTo(o2.getActionDate());
}
});
return customerSchedulePayments;
}
use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.
the class CustomerAccountBO method waiveAmountDue.
public void waiveAmountDue() throws AccountException {
AccountActionDateEntity accountActionDateEntity = getUpcomingInstallment();
Money chargeWaived = ((CustomerScheduleEntity) accountActionDateEntity).waiveCharges();
if (chargeWaived != null && chargeWaived.isGreaterThanZero()) {
addCustomerActivity(buildCustomerActivity(chargeWaived, AccountConstants.AMNT_WAIVED, userContext.getId()));
}
}
use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.
the class CustomerAccountBO method associateFeeWithAllKnownFutureInstallments.
private void associateFeeWithAllKnownFutureInstallments(final AccountFeesEntity fee) throws AccountException {
CustomerScheduleEntity nextInstallment = (CustomerScheduleEntity) getDetailsOfNextInstallment();
createCustomerFeeScheduleForInstallment(fee, nextInstallment);
List<AccountActionDateEntity> futureInstallments = getFutureInstallments();
for (AccountActionDateEntity accountActionDateEntity : futureInstallments) {
CustomerScheduleEntity installment = (CustomerScheduleEntity) accountActionDateEntity;
createCustomerFeeScheduleForInstallment(fee, installment);
}
}
Aggregations