use of org.mifos.customers.business.CustomerBO 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.customers.business.CustomerBO in project head by mifos.
the class LegacyAccountDao method getCoSigningClientsForGlim.
public List<CustomerBO> getCoSigningClientsForGlim(Integer accountId) throws PersistenceException {
HashMap<String, Object> queryParameters = new HashMap<String, Object>();
queryParameters.put(QueryParamConstants.ACCOUNT_ID, accountId);
List<LoanBO> loans = executeNamedQuery(NamedQueryConstants.GET_COSIGNING_CLIENTS_FOR_GLIM, queryParameters);
List<CustomerBO> clients = new ArrayList<CustomerBO>();
for (LoanBO loanBO : loans) {
clients.add(loanBO.getCustomer());
}
return clients;
}
use of org.mifos.customers.business.CustomerBO in project head by mifos.
the class SavingsBO method updateSavingsSchedule.
private void updateSavingsSchedule(final Short nextInstallmentId, final List<DateTime> meetingDates, final List<CustomerBO> children) {
short installmentId = nextInstallmentId;
for (int count = 0; count < meetingDates.size(); count++) {
for (CustomerBO customer : children) {
AccountActionDateEntity accountActionDate = getAccountActionDate(installmentId, customer.getCustomerId());
if (accountActionDate != null) {
Date meetingDate = meetingDates.get(count).toDate();
((SavingsScheduleEntity) accountActionDate).setActionDate(new java.sql.Date(meetingDate.getTime()));
}
}
installmentId++;
}
}
use of org.mifos.customers.business.CustomerBO in project head by mifos.
the class SavingsBO method generateNextSetOfMeetingDates.
public void generateNextSetOfMeetingDates(final List<Days> workingDays, final List<Holiday> holidays) throws AccountException {
CustomerBO customerBO = getCustomer();
if (customerBO.getCustomerMeeting() != null && customerBO.getCustomerMeeting().getMeeting() != null) {
MeetingBO depositSchedule = customerBO.getCustomerMeeting().getMeeting();
Date oldMeetingDate = depositSchedule.getStartDate();
Short lastInstallmentId = getLastInstallmentId();
AccountActionDateEntity lastInstallment = getAccountActionDate(lastInstallmentId);
if (lastInstallment == null) {
// a special workaround for MIFOS-5107
lastInstallment = new SavingsScheduleEntity(this, this.getCustomer(), (short) 0, new java.sql.Date(new LocalDate().minusDays(1).toDateMidnight().getMillis()), PaymentStatus.UNPAID, new Money(Money.getDefaultCurrency(), 0.0));
}
depositSchedule.setMeetingStartDate(lastInstallment.getActionDate());
if (customerBO.getCustomerLevel().getId().equals(CustomerLevel.CLIENT.getValue()) || customerBO.getCustomerLevel().getId().equals(CustomerLevel.GROUP.getValue()) && getRecommendedAmntUnit().getId().equals(RecommendedAmountUnit.COMPLETE_GROUP.getValue())) {
generateDepositAccountActions(customerBO, depositSchedule, lastInstallment, workingDays, holidays);
} else {
List<CustomerBO> children;
try {
children = getCustomer().getChildren(CustomerLevel.CLIENT, ChildrenStateType.OTHER_THAN_CLOSED);
} catch (CustomerException ce) {
throw new AccountException(ce);
}
for (CustomerBO customer : children) {
generateDepositAccountActions(customer, depositSchedule, lastInstallment, workingDays, holidays);
}
}
depositSchedule.setStartDate(oldMeetingDate);
}
}
use of org.mifos.customers.business.CustomerBO in project head by mifos.
the class SavingsBO method regenerateFutureInstallments.
@Override
protected void regenerateFutureInstallments(final AccountActionDateEntity nextInstallment, final List<Days> workingDays, final List<Holiday> holidays) throws AccountException {
MeetingBO customerMeeting = getCustomer().getCustomerMeetingValue();
ScheduledEvent scheduledEvent = ScheduledEventFactory.createScheduledEventFrom(customerMeeting);
LocalDate currentDate = new LocalDate();
LocalDate thisIntervalStartDate = customerMeeting.startDateForMeetingInterval(currentDate);
LocalDate nextMatchingDate = new LocalDate(scheduledEvent.nextEventDateAfter(thisIntervalStartDate.toDateTimeAtStartOfDay()));
DateTime futureIntervalStartDate = customerMeeting.startDateForMeetingInterval(nextMatchingDate).toDateTimeAtStartOfDay();
ScheduledDateGeneration dateGeneration = new HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(workingDays, holidays);
int numberOfInstallmentsToGenerate = getLastInstallmentId();
List<DateTime> meetingDates = dateGeneration.generateScheduledDates(numberOfInstallmentsToGenerate, futureIntervalStartDate, scheduledEvent, false);
if (getCustomer().getCustomerLevel().getId().equals(CustomerLevel.CLIENT.getValue()) || getCustomer().getCustomerLevel().getId().equals(CustomerLevel.GROUP.getValue()) && getRecommendedAmntUnit().getId().equals(RecommendedAmountUnit.COMPLETE_GROUP.getValue())) {
updateSchedule(nextInstallment.getInstallmentId(), meetingDates);
} else {
List<CustomerBO> children;
try {
children = getCustomer().getChildren(CustomerLevel.CLIENT, ChildrenStateType.OTHER_THAN_CLOSED);
} catch (CustomerException ce) {
throw new AccountException(ce);
}
updateSavingsSchedule(nextInstallment.getInstallmentId(), meetingDates, children);
}
}
Aggregations