use of org.mifos.framework.util.DateTimeService in project head by mifos.
the class LoanBO method applyMifos4948FixPayment.
/*
* Mifos-4948 specific code
*/
public void applyMifos4948FixPayment(Money totalMissedPayment) throws AccountException {
String comment = "MIFOS-4948 - Loan: " + this.getGlobalAccountNum() + " - Adding payment: " + totalMissedPayment;
try {
PersonnelBO currentUser = legacyPersonnelDao.getPersonnel((short) 1);
Date transactionDate = new DateTimeService().getCurrentJavaDateTime();
AccountPaymentEntity accountPaymentEntity = new AccountPaymentEntity(this, totalMissedPayment, null, null, getPaymentTypeEntity(Short.valueOf("1")), transactionDate);
addAccountPayment(accountPaymentEntity);
accountPaymentEntity.setComment(comment);
AccountActionTypes accountActionTypes;
String accountConstants;
if (this.getAccountState().getId().equals(AccountState.LOAN_CLOSED_WRITTEN_OFF.getValue())) {
accountActionTypes = AccountActionTypes.WRITEOFF;
accountConstants = AccountConstants.LOAN_WRITTEN_OFF;
} else {
accountActionTypes = AccountActionTypes.LOAN_RESCHEDULED;
accountConstants = AccountConstants.LOAN_RESCHEDULED;
}
makeWriteOffOrReschedulePaymentForMifos4948(accountPaymentEntity, accountConstants, accountActionTypes, currentUser);
addLoanActivity(buildLoanActivity(accountPaymentEntity.getAccountTrxns(), currentUser, accountConstants, transactionDate));
buildFinancialEntries(accountPaymentEntity.getAccountTrxns());
} catch (PersistenceException e) {
throw new AccountException(e);
}
}
use of org.mifos.framework.util.DateTimeService in project head by mifos.
the class ClientServiceFacadeWebTier method removeGroupMembership.
@Override
public void removeGroupMembership(String globalCustNum, Short loanOfficerId, String comment) {
MifosUser mifosUser = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(mifosUser);
ClientBO client = this.customerDao.findClientBySystemId(globalCustNum);
client.updateDetails(userContext);
PersonnelBO loanOfficer = null;
if (loanOfficerId != null) {
loanOfficer = this.personnelDao.findPersonnelById(loanOfficerId);
}
PersonnelBO loggedInUser = this.personnelDao.findPersonnelById(userContext.getId());
java.sql.Date commentDate = new DateTimeService().getCurrentJavaSqlDate();
CustomerNoteEntity accountNotesEntity = new CustomerNoteEntity(comment, commentDate, loggedInUser, client);
customerService.removeGroupMembership(client, loanOfficer, accountNotesEntity, userContext.getLocaleId());
}
use of org.mifos.framework.util.DateTimeService in project head by mifos.
the class CustomerServiceImpl method changeStatus.
private void changeStatus(CustomerBO customer, CustomerStatus oldStatus, CustomerStatus newStatus) throws CustomerException {
Short oldStatusId = oldStatus.getValue();
Short newStatusId = newStatus.getValue();
if (customer.isClient()) {
ClientBO client = (ClientBO) customer;
if (client.isActiveForFirstTime(oldStatusId, newStatusId)) {
if (client.getParentCustomer() != null) {
CustomerHierarchyEntity hierarchy = new CustomerHierarchyEntity(client, client.getParentCustomer());
client.addCustomerHierarchy(hierarchy);
}
CalendarEvent applicableCalendarEvents = holidayDao.findCalendarEventsForThisYearAndNext(customer.getOfficeId());
List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>(customer.getCustomerAccount().getAccountFees());
client.getCustomerAccount().createSchedulesAndFeeSchedulesForFirstTimeActiveCustomer(customer, accountFees, customer.getCustomerMeetingValue(), applicableCalendarEvents, new DateMidnight().toDateTime());
client.setCustomerActivationDate(new DateTimeService().getCurrentJavaDateTime());
if (client.getOfferingsAssociatedInCreate() != null) {
for (ClientInitialSavingsOfferingEntity clientOffering : client.getOfferingsAssociatedInCreate()) {
try {
SavingsOfferingBO savingsOffering = savingsProductDao.findById(clientOffering.getSavingsOffering().getPrdOfferingId().intValue());
if (savingsOffering.isActive()) {
List<CustomFieldDto> customerFieldsForSavings = new ArrayList<CustomFieldDto>();
client.addAccount(new SavingsBO(client.getUserContext(), savingsOffering, client, AccountState.SAVINGS_ACTIVE, savingsOffering.getRecommendedAmount(), customerFieldsForSavings));
}
} catch (AccountException pe) {
throw new CustomerException(pe);
}
}
}
new SavingsPersistence().persistSavingAccounts(client);
try {
if (client.getParentCustomer() != null) {
List<SavingsBO> savingsList = new CustomerPersistence().retrieveSavingsAccountForCustomer(client.getParentCustomer().getCustomerId());
if (client.getParentCustomer().getParentCustomer() != null) {
savingsList.addAll(new CustomerPersistence().retrieveSavingsAccountForCustomer(client.getParentCustomer().getParentCustomer().getCustomerId()));
}
for (SavingsBO savings : savingsList) {
savings.setUserContext(client.getUserContext());
if (client.getCustomerMeeting().getMeeting() != null) {
if (!(savings.getCustomer().getLevel() == CustomerLevel.GROUP && savings.getRecommendedAmntUnit().getId().equals(RecommendedAmountUnit.COMPLETE_GROUP.getValue()))) {
DateTime today = new DateTime().toDateMidnight().toDateTime();
savings.generateDepositAccountActions(client, client.getCustomerMeeting().getMeeting(), applicableCalendarEvents.getWorkingDays(), applicableCalendarEvents.getHolidays(), today);
savings.update();
}
}
}
}
} catch (PersistenceException pe) {
throw new CustomerException(pe);
} catch (AccountException ae) {
throw new CustomerException(ae);
}
}
}
}
use of org.mifos.framework.util.DateTimeService in project head by mifos.
the class CustomerAccountBO method addFeeToAccountFee.
private void addFeeToAccountFee(final Short feeId, final Double charge) {
FeeBO fee = getFeeDao().findById(feeId);
AccountFeesEntity accountFee = null;
if (fee.isPeriodic() && !isFeeAlreadyApplied(fee) || !fee.isPeriodic()) {
accountFee = new AccountFeesEntity(this, fee, charge, FeeStatus.ACTIVE.getValue(), new DateTimeService().getCurrentJavaDateTime(), null);
addAccountFees(accountFee);
} else {
accountFee = getAccountFees(fee.getFeeId());
accountFee.setFeeAmount(charge);
accountFee.setFeeStatus(FeeStatus.ACTIVE);
accountFee.setStatusChangeDate(new DateTimeService().getCurrentJavaDateTime());
}
}
use of org.mifos.framework.util.DateTimeService in project head by mifos.
the class CustomerDaoHibernate method getLastMeetingDateForCustomer.
@Override
public Date getLastMeetingDateForCustomer(final Integer customerId) {
Date meetingDate = null;
Date actionDate = new DateTimeService().getCurrentJavaSqlDate();
HashMap<String, Object> queryParameters = new HashMap<String, Object>();
queryParameters.put("CUSTOMER_ID", customerId);
queryParameters.put("ACTION_DATE", actionDate);
meetingDate = (Date) genericDao.executeUniqueResultNamedQuery(NamedQueryConstants.GET_LAST_MEETINGDATE_FOR_CUSTOMER, queryParameters);
return meetingDate;
}
Aggregations