use of org.mifos.accounts.util.helpers.InstallmentDate in project head by mifos.
the class CustomerAccountBO method handlePeriodic.
@Override
protected final List<FeeInstallment> handlePeriodic(final AccountFeesEntity accountFees, final List<InstallmentDate> installmentDates, final List<InstallmentDate> nonAdjustedInstallmentDates) throws AccountException {
Money accountFeeAmount = accountFees.getAccountFeeAmount();
MeetingBO feeMeetingFrequency = accountFees.getFees().getFeeFrequency().getFeeMeetingFrequency();
List<Date> feeDates = getFeeDates(feeMeetingFrequency, nonAdjustedInstallmentDates);
ListIterator<Date> feeDatesIterator = feeDates.listIterator();
List<FeeInstallment> feeInstallmentList = new ArrayList<FeeInstallment>();
while (feeDatesIterator.hasNext()) {
Date feeDate = feeDatesIterator.next();
logger.debug("Handling periodic fee.." + feeDate);
Short installmentId = getMatchingInstallmentId(installmentDates, feeDate);
feeInstallmentList.add(buildFeeInstallment(installmentId, accountFeeAmount, accountFees));
}
return feeInstallmentList;
}
use of org.mifos.accounts.util.helpers.InstallmentDate in project head by mifos.
the class AccountBO method handleOneTime.
protected final FeeInstallment handleOneTime(final AccountFeesEntity accountFee, final List<InstallmentDate> installmentDates) {
Money accountFeeAmount = accountFee.getAccountFeeAmount();
Date feeDate = installmentDates.get(0).getInstallmentDueDate();
logger.debug("Handling OneTime fee" + feeDate);
Short installmentId = getMatchingInstallmentId(installmentDates, feeDate);
logger.debug("OneTime fee applicable installment id " + installmentId);
return buildFeeInstallment(installmentId, accountFeeAmount, accountFee);
}
use of org.mifos.accounts.util.helpers.InstallmentDate in project head by mifos.
the class AccountBO method removeInstallmentsNeedNotPay.
private void removeInstallmentsNeedNotPay(final Short installmentSkipToStartRepayment, final List<InstallmentDate> installmentDates) {
int removeCounter = 0;
for (int i = 0; i < installmentSkipToStartRepayment; i++) {
installmentDates.remove(removeCounter);
}
// re-adjust the installment ids
if (installmentSkipToStartRepayment > 0) {
int count = installmentDates.size();
for (int i = 0; i < count; i++) {
InstallmentDate instDate = installmentDates.get(i);
instDate.setInstallmentId(new Short(Integer.toString(i + 1)));
}
}
}
use of org.mifos.accounts.util.helpers.InstallmentDate in project head by mifos.
the class AccountBO method createInstallmentDates.
/**
* @deprecated - remove when loan schedules or 'installment' creation responsibility is moved out of account/loan
*/
@Deprecated
protected List<InstallmentDate> createInstallmentDates(final Short installmentToSkip, final List<Date> dueDates) {
List<InstallmentDate> installmentDates = new ArrayList<InstallmentDate>();
int installmentId = 1;
for (Date date : dueDates) {
installmentDates.add(new InstallmentDate((short) installmentId++, date));
}
removeInstallmentsNeedNotPay(installmentToSkip, installmentDates);
return installmentDates;
}
use of org.mifos.accounts.util.helpers.InstallmentDate in project head by mifos.
the class AccountBO method getInstallmentDates.
/**
* @deprecated - used to create installment dates based on 'loan meeting' and working das, holidays, moratoria etc
*
* better to pull capability of creating 'installments' out of loan into something more reuseable and isolated
*/
@Deprecated
public final List<InstallmentDate> getInstallmentDates(final MeetingBO meeting, final Short noOfInstallments, final Short installmentToSkip, final boolean isRepaymentIndepOfMeetingEnabled, final boolean adjustForHolidays) {
logger.debug("Generating intallment dates");
List<InstallmentDate> dueInstallmentDates = new ArrayList<InstallmentDate>();
if (noOfInstallments > 0) {
List<Days> workingDays = new FiscalCalendarRules().getWorkingDaysAsJodaTimeDays();
List<Holiday> holidays = new ArrayList<Holiday>();
DateTime startFromMeetingDate = new DateTime(meeting.getMeetingStartDate());
if (adjustForHolidays) {
HolidayDao holidayDao = ApplicationContextProvider.getBean(HolidayDao.class);
holidays = holidayDao.findAllHolidaysFromDateAndNext(getOffice().getOfficeId(), startFromMeetingDate.toLocalDate().toString());
}
final int occurrences = noOfInstallments + installmentToSkip;
ScheduledEvent scheduledEvent = ScheduledEventFactory.createScheduledEventFrom(meeting);
ScheduledDateGeneration dateGeneration = new HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(workingDays, holidays);
List<Date> dueDates = new ArrayList<Date>();
// FIXME - keithw - this whole area of installment creation should be pulled out of domain
DateTime startFromDayAfterAssignedMeetingDateRatherThanSkippingInstallments = startFromMeetingDate;
if (this.isLoanAccount()) {
// ensure loans that are created or disbursed on a meeting date start on next valid meeting date and not todays meeting
// ensure loans that are created or disbursed before a meeting date start on next valid meeting date
startFromDayAfterAssignedMeetingDateRatherThanSkippingInstallments = startFromMeetingDate.plusDays(1);
}
List<DateTime> installmentDates = dateGeneration.generateScheduledDates(occurrences, startFromDayAfterAssignedMeetingDateRatherThanSkippingInstallments, scheduledEvent, false);
for (DateTime installmentDate : installmentDates) {
dueDates.add(installmentDate.toDate());
}
dueInstallmentDates = createInstallmentDates(installmentToSkip, dueDates);
}
return dueInstallmentDates;
}
Aggregations