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, List<CustomerBO> activeAndOnHoldClients) {
List<AccountActionDateEntity> scheduledPayments = new ArrayList<AccountActionDateEntity>();
LocalDate activationDate = new LocalDate();
LocalDate nextInterestPostingDate = new LocalDate();
if (savingsAccountState.isActiveSavingsAccountState()) {
activationDate = new LocalDate();
ScheduledEvent scheduledEvent = ScheduledEventFactory.createScheduledEventFrom(customer.getCustomerMeetingValue());
ScheduledDateGeneration dateGeneration = new HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(calendarEvents.getWorkingDays(), calendarEvents.getHolidays());
for (CustomerBO client : activeAndOnHoldClients) {
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(client, 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 generateAccountActivationDetails.
public static SavingsAccountActivationDetail generateAccountActivationDetails(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 = 0;
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 goActiveForFristTimeAndGenerateSavingsSchedule.
/**
* use minimal constructor which generates scheduled savings payments correctly and does not
* do through this method.
*/
@Deprecated
private void goActiveForFristTimeAndGenerateSavingsSchedule(final CustomerBO customer) throws AccountException {
HolidayDao holidayDao = ApplicationContextProvider.getBean(HolidayDao.class);
CalendarEvent futureCalendarEventsApplicableToOffice = holidayDao.findCalendarEventsForThisYearAndNext(customer.getOfficeId());
this.activationDate = new DateTime(new DateTimeService().getCurrentJavaDateTime()).toDate();
List<Days> workingDays = futureCalendarEventsApplicableToOffice.getWorkingDays();
List<Holiday> holidays = futureCalendarEventsApplicableToOffice.getHolidays();
logger.debug("In SavingsBO::generateDepositAccountActions()");
// center/group with individual deposits, insert row for every client
if (this.getCustomer().getCustomerMeeting() != null && this.getCustomer().getCustomerMeeting().getMeeting() != null) {
MeetingBO depositSchedule = this.getCustomer().getCustomerMeeting().getMeeting();
if (this.getCustomer().getCustomerLevel().getId().equals(CustomerLevel.CLIENT.getValue()) || this.getCustomer().getCustomerLevel().getId().equals(CustomerLevel.GROUP.getValue()) && this.getRecommendedAmntUnit().getId().equals(RecommendedAmountUnit.COMPLETE_GROUP.getValue())) {
this.generateDepositAccountActions(this.getCustomer(), depositSchedule, workingDays, holidays, new DateTime(this.activationDate));
} else {
List<CustomerBO> children;
try {
children = this.getCustomer().getChildren(CustomerLevel.CLIENT, ChildrenStateType.ACTIVE_AND_ONHOLD);
} catch (CustomerException ce) {
throw new AccountException(ce);
}
for (CustomerBO customer1 : children) {
this.generateDepositAccountActions(customer1, depositSchedule, workingDays, holidays, new DateTime(this.activationDate));
}
}
}
InterestScheduledEvent interestPostingEvent = new SavingsInterestScheduledEventFactory().createScheduledEventFrom(this.savingsOffering.getFreqOfPostIntcalc().getMeeting());
this.nextIntPostDate = interestPostingEvent.nextMatchingDateAfter(new LocalDate(startOfFiscalYear()), new LocalDate(this.activationDate)).toDateMidnight().toDate();
}
use of org.mifos.accounts.savings.interest.schedule.SavingsInterestScheduledEventFactory in project head by mifos.
the class SavingsOfferingBO method updateSavingsDetails.
public void updateSavingsDetails(Money recommendedAmount, RecommendedAmntUnitEntity recommendedAmntUnit, Money maxAmntWithdrawl, Double interestRate, Money minAmountRequiredForInterestToBeCalculated, LocalDate updateDate) {
this.maxAmntWithdrawl = maxAmntWithdrawl;
this.recommendedAmount = recommendedAmount;
this.recommendedAmntUnit = recommendedAmntUnit;
if (interestDetailsHaveChanged(interestRate, minAmountRequiredForInterestToBeCalculated)) {
InterestScheduledEvent interestCalculationEvent = new SavingsInterestScheduledEventFactory().createScheduledEventFrom(this.getTimePerForInstcalc().getMeeting());
LocalDate nextInterestCalculationDate = interestCalculationEvent.nextMatchingDateAfter(startOfFiscalYear(updateDate), updateDate);
LocalDate startOfPeriodDate = interestCalculationEvent.findFirstDateOfPeriodForMatchingDate(nextInterestCalculationDate);
LocalDate previousInterestCalculationDate = startOfPeriodDate.minusDays(1);
LocalDate startOfPreviousPeriodDate = interestCalculationEvent.findFirstDateOfPeriodForMatchingDate(previousInterestCalculationDate);
CalendarPeriod previousInterestCalculationPeriod = new CalendarPeriod(startOfPreviousPeriodDate, previousInterestCalculationDate);
if (noHistoricalRecordExistsFor(previousInterestCalculationPeriod)) {
SavingsProductHistoricalInterestDetail historicalInterestDetail = new SavingsProductHistoricalInterestDetail(previousInterestCalculationPeriod, this.interestRate, this.minAmntForInt, this);
this.historicalInterestDetails.add(historicalInterestDetail);
}
this.interestRate = interestRate;
this.minAmntForInt = minAmountRequiredForInterestToBeCalculated;
}
}
use of org.mifos.accounts.savings.interest.schedule.SavingsInterestScheduledEventFactory in project head by mifos.
the class SavingsServiceFacadeWebTier method determinePostingPeriodResult.
private InterestPostingPeriodResult determinePostingPeriodResult(CalendarPeriod postingPeriod, SavingsBO savingsAccount, List<EndOfDayDetail> allEndOfDayDetailsForAccount) {
List<SavingsProductHistoricalInterestDetail> historicalInterestDetails = savingsAccount.getHistoricalInterestDetailsForPeriod(postingPeriod);
MifosCurrency currencyInUse = savingsAccount.getCurrency();
Money startingBalanceForPeriod = calculateAccountBalanceOn(postingPeriod.getStartDate(), allEndOfDayDetailsForAccount, currencyInUse);
InterestCalcType interestCalcType = savingsAccount.getInterestCalcType();
int accountingNumberOfInterestDaysInYear = AccountingRules.getNumberOfInterestDays();
SavingsInterestDetail interestDetail = new SavingsInterestDetail(interestCalcType, savingsAccount.getInterestRate(), accountingNumberOfInterestDaysInYear, savingsAccount.getMinAmntForInt());
InterestScheduledEvent interestCalculationEvent = new SavingsInterestScheduledEventFactory().createScheduledEventFrom(savingsAccount.getInterestCalculationMeeting());
return doCalculateInterestForPostingPeriod(postingPeriod, startingBalanceForPeriod, historicalInterestDetails, allEndOfDayDetailsForAccount, interestDetail, interestCalculationEvent);
}
Aggregations