use of org.mifos.customers.persistence.CustomerPersistence in project head by mifos.
the class TestObjectFactory method getDueActionDatesForAccount.
public static List<AccountActionDateEntity> getDueActionDatesForAccount(final Integer accountId, final java.sql.Date transactionDate) throws Exception {
List<AccountActionDateEntity> dueActionDates = new CustomerPersistence().retrieveCustomerAccountActionDetails(accountId, transactionDate);
for (AccountActionDateEntity accountActionDate : dueActionDates) {
Hibernate.initialize(accountActionDate);
if (accountActionDate instanceof LoanScheduleEntity) {
LoanScheduleEntity loanScheduleEntity = (LoanScheduleEntity) accountActionDate;
for (AccountFeesActionDetailEntity accountFeesActionDetail : loanScheduleEntity.getAccountFeesActionDetails()) {
Hibernate.initialize(accountFeesActionDetail);
}
}
if (accountActionDate instanceof CustomerScheduleEntity) {
CustomerScheduleEntity customerScheduleEntity = (CustomerScheduleEntity) accountActionDate;
for (AccountFeesActionDetailEntity accountFeesActionDetail : customerScheduleEntity.getAccountFeesActionDetails()) {
Hibernate.initialize(accountFeesActionDetail);
}
}
}
StaticHibernateUtil.flushSession();
return dueActionDates;
}
use of org.mifos.customers.persistence.CustomerPersistence in project head by mifos.
the class LoanBO method writeOff.
@Override
protected void writeOff(Date transactionDate) throws AccountException {
try {
if (!isTrxnDateValid(transactionDate, new CustomerPersistence().getLastMeetingDateForCustomer(getCustomer().getCustomerId()), new ConfigurationPersistence().isRepaymentIndepOfMeetingEnabled())) {
throw new BusinessRuleException("errors.invalidTxndate");
}
Short personnelId = this.getUserContext().getId();
PersonnelBO currentUser = legacyPersonnelDao.getPersonnel(personnelId);
this.setUpdatedBy(personnelId);
this.setUpdatedDate(transactionDate);
AccountPaymentEntity accountPaymentEntity = new AccountPaymentEntity(this, getEarlyClosureAmount(), null, null, getPaymentTypeEntity(Short.valueOf("1")), transactionDate);
this.addAccountPayment(accountPaymentEntity);
makeEarlyRepaymentForArrears(accountPaymentEntity, AccountConstants.LOAN_WRITTEN_OFF, AccountActionTypes.WRITEOFF, currentUser);
//for past arrears installments writeOff and reschedule are the same as 'make early repayment'
//but differ in processing for future installments
makeWriteOffOrReschedulePaymentForFutureInstallments(accountPaymentEntity, AccountConstants.LOAN_WRITTEN_OFF, AccountActionTypes.WRITEOFF, currentUser);
addLoanActivity(buildLoanActivity(accountPaymentEntity.getAccountTrxns(), currentUser, AccountConstants.LOAN_WRITTEN_OFF, transactionDate));
buildFinancialEntries(accountPaymentEntity.getAccountTrxns());
// Client performance entry
updateCustomerHistoryOnWriteOff();
} catch (PersistenceException e) {
throw new AccountException(e);
}
}
use of org.mifos.customers.persistence.CustomerPersistence in project head by mifos.
the class LoanBO method reschedule.
@Override
protected void reschedule(Date transactionDate) throws AccountException {
try {
if (!isTrxnDateValid(transactionDate, new CustomerPersistence().getLastMeetingDateForCustomer(getCustomer().getCustomerId()), new ConfigurationPersistence().isRepaymentIndepOfMeetingEnabled())) {
throw new BusinessRuleException("errors.invalidTxndate");
}
Short personnelId = this.getUserContext().getId();
PersonnelBO currentUser = legacyPersonnelDao.getPersonnel(personnelId);
this.setUpdatedBy(personnelId);
this.setUpdatedDate(transactionDate);
AccountPaymentEntity accountPaymentEntity = new AccountPaymentEntity(this, getEarlyClosureAmount(), null, null, getPaymentTypeEntity(Short.valueOf("1")), transactionDate);
this.addAccountPayment(accountPaymentEntity);
makeEarlyRepaymentForArrears(accountPaymentEntity, AccountConstants.LOAN_RESCHEDULED, AccountActionTypes.LOAN_RESCHEDULED, currentUser);
//for past arrears installments writeOff and reschedule are the same as 'make early repayment'
//but differ in processing for future installments
makeWriteOffOrReschedulePaymentForFutureInstallments(accountPaymentEntity, AccountConstants.LOAN_RESCHEDULED, AccountActionTypes.LOAN_RESCHEDULED, currentUser);
addLoanActivity(buildLoanActivity(accountPaymentEntity.getAccountTrxns(), currentUser, AccountConstants.LOAN_RESCHEDULED, transactionDate));
buildFinancialEntries(accountPaymentEntity.getAccountTrxns());
// Client performance entry using the same as write off.
updateCustomerHistoryOnWriteOff();
} catch (PersistenceException e) {
throw new AccountException(e);
}
}
use of org.mifos.customers.persistence.CustomerPersistence in project head by mifos.
the class PortfolioAtRiskHelper method execute.
@Override
public void execute(long timeInMillis) throws BatchJobException {
long time1 = new DateTimeService().getCurrentDateTime().getMillis();
List<BasicGroupInfo> groupInfos = null;
List<String> errorList = new ArrayList<String>();
try {
groupInfos = new CustomerPersistence().getAllBasicGroupInfo();
} catch (Exception e) {
throw new BatchJobException(e);
}
if (groupInfos != null && !groupInfos.isEmpty()) {
int groupCount = groupInfos.size();
getLogger().info("PortfolioAtRisk: got " + groupCount + " groups to process.");
long startTime = new DateTimeService().getCurrentDateTime().getMillis();
int i = 1;
Integer groupId = null;
GroupPersistence groupPersistence = new GroupPersistence();
try {
for (BasicGroupInfo groupInfo : groupInfos) {
groupId = groupInfo.getGroupId();
String searchStr = groupInfo.getSearchId() + ".%";
double portfolioAtRisk = PortfolioAtRiskCalculation.generatePortfolioAtRiskForTask(groupId, groupInfo.getBranchId(), searchStr);
// updated_by and updated_date
if (portfolioAtRisk > -1) {
groupPersistence.updateGroupInfoAndGroupPerformanceHistoryForPortfolioAtRisk(portfolioAtRisk, groupId);
}
if (i % 500 == 0) {
long time = new DateTimeService().getCurrentDateTime().getMillis();
getLogger().info("500 groups updated in " + (time - startTime) + " milliseconds. There are " + (groupCount - i) + " more groups to be updated.");
startTime = time;
}
i++;
}
} catch (Exception e) {
getLogger().error("PortfolioAtRiskHelper execute failed with exception " + e.getClass().getName() + ": " + e.getMessage() + " at group " + groupId.toString(), e);
StaticHibernateUtil.rollbackTransaction();
errorList.add(groupId.toString());
} finally {
StaticHibernateUtil.closeSession();
}
}
long time2 = new DateTimeService().getCurrentDateTime().getMillis();
getLogger().info("PortfolioAtRiskTask ran in " + (time2 - time1) + " milliseconds");
if (errorList.size() > 0) {
throw new BatchJobException(SchedulerConstants.FAILURE, errorList);
}
}
use of org.mifos.customers.persistence.CustomerPersistence in project head by mifos.
the class CustomerTagGenerator method build.
@Override
protected StringBuilder build(AbstractBusinessObject obj, boolean selfLinkRequired, Object randomNum) {
CustomerBO customer = (CustomerBO) obj;
try {
CustomerBO customerReloaded = new CustomerPersistence().getCustomer(customer.getCustomerId());
StringBuilder strBuilder = getAssociatedGenerator().build(customerReloaded.getOffice(), randomNum);
if (strBuilder == null) {
strBuilder = new StringBuilder();
}
buildLink(strBuilder, customerReloaded, customerReloaded, selfLinkRequired, randomNum);
return strBuilder;
} catch (PersistenceException e) {
throw new RuntimeException(e);
}
}
Aggregations