use of org.mifos.accounts.savings.interest.schedule.SavingsInterestScheduledEventFactory in project head by mifos.
the class SavingsBO method determineAccountActivationDetails.
public static SavingsAccountActivationDetail determineAccountActivationDetails(CustomerBO customer, SavingsOfferingBO savingsProduct, Money recommendedOrMandatoryAmount, AccountState savingsAccountState, CalendarEvent calendarEvents, LocalDate activationDate) {
List<AccountActionDateEntity> scheduledPayments = new ArrayList<AccountActionDateEntity>();
LocalDate nextInterestPostingDate = new LocalDate();
if (savingsAccountState.isActiveSavingsAccountState()) {
ScheduledEvent scheduledEvent = ScheduledEventFactory.createScheduledEventFrom(customer.getCustomerMeetingValue());
ScheduledDateGeneration dateGeneration = new HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(calendarEvents.getWorkingDays(), calendarEvents.getHolidays());
List<DateTime> depositDates = dateGeneration.generateScheduledDates(10, activationDate.toDateTimeAtStartOfDay(), scheduledEvent, false);
short installmentNumber = 1;
for (DateTime date : depositDates) {
java.sql.Date depositDueDate = new java.sql.Date(date.toDate().getTime());
AccountActionDateEntity scheduledSavingsDeposit = new SavingsScheduleEntity(customer, installmentNumber, depositDueDate, PaymentStatus.UNPAID, recommendedOrMandatoryAmount, savingsProduct.getCurrency());
scheduledPayments.add(scheduledSavingsDeposit);
}
InterestScheduledEvent interestPostingEvent = new SavingsInterestScheduledEventFactory().createScheduledEventFrom(savingsProduct.getFreqOfPostIntcalc().getMeeting());
nextInterestPostingDate = interestPostingEvent.nextMatchingDateAfter(new LocalDate(startOfFiscalYear()), activationDate);
}
return new SavingsAccountActivationDetail(activationDate, nextInterestPostingDate, scheduledPayments);
}
use of org.mifos.accounts.savings.interest.schedule.SavingsInterestScheduledEventFactory in project head by mifos.
the class SavingsBO method isTrxnDateValid.
@Override
public boolean isTrxnDateValid(Date trxnDate, Date lastMeetingDate, boolean repaymentIndependentOfMeetingEnabled) {
LocalDate transactionLocalDate = new LocalDate(trxnDate);
LocalDate today = new LocalDate();
if (AccountingRules.isBackDatedTxnAllowed()) {
if (repaymentIndependentOfMeetingEnabled) {
Date activationDate = this.getActivationDate();
return trxnDate.compareTo(DateUtils.getDateWithoutTimeStamp(activationDate)) >= 0;
}
InterestScheduledEvent postingEvent = new SavingsInterestScheduledEventFactory().createScheduledEventFrom(this.getInterestPostingMeeting());
LocalDate nextPostingDate = new LocalDate(this.nextIntPostDate);
LocalDate currentPostingPeriodStartDate = postingEvent.findFirstDateOfPeriodForMatchingDate(nextPostingDate);
if (getInterestPostingMeeting().isDaily()) {
if (lastIntPostDate == null) {
currentPostingPeriodStartDate = new LocalDate(activationDate);
} else {
currentPostingPeriodStartDate = new LocalDate(lastIntPostDate).plusDays(1);
}
}
// FIXME throw an exception with the correct reason instead of returning false
if (transactionLocalDate.isBefore(currentPostingPeriodStartDate)) {
return false;
}
LocalDate activationDate = new LocalDate(this.activationDate);
if (lastMeetingDate != null) {
LocalDate meetingDate = new LocalDate(lastMeetingDate);
return (transactionLocalDate.isAfter(meetingDate) || transactionLocalDate.isEqual(meetingDate)) && (transactionLocalDate.isAfter(activationDate) || transactionLocalDate.isEqual(activationDate));
}
return (transactionLocalDate.isAfter(activationDate) || transactionLocalDate.isEqual(activationDate)) && (transactionLocalDate.isBefore(today) || transactionLocalDate.isEqual(today));
}
return transactionLocalDate.isEqual(today);
}
Aggregations