use of org.mifos.framework.util.DateTimeService in project head by mifos.
the class CustomerAccountBO method createCustomerFeeScheduleForInstallment.
private void createCustomerFeeScheduleForInstallment(final AccountFeesEntity fee, CustomerScheduleEntity nextInstallment) throws AccountException {
CustomerFeeScheduleEntity accountFeesaction = new CustomerFeeScheduleEntity(nextInstallment, fee.getFees(), fee, fee.getAccountFeeAmount());
accountFeesaction.setFeeAmountPaid(new Money(fee.getAccountFeeAmount().getCurrency(), "0.0"));
nextInstallment.addAccountFeesAction(accountFeesaction);
String description = fee.getFees().getFeeName() + " " + AccountConstants.FEES_APPLIED;
try {
addCustomerActivity(new CustomerActivityEntity(this, ApplicationContextProvider.getBean(LegacyPersonnelDao.class).getPersonnel(Short.valueOf("1")), fee.getAccountFeeAmount(), description, new DateTimeService().getCurrentJavaDateTime()));
} catch (PersistenceException e) {
throw new AccountException(e);
}
}
use of org.mifos.framework.util.DateTimeService in project head by mifos.
the class CustomerAccountBO method updateCustomerActivity.
private void updateCustomerActivity(final Short chargeType, final Money charge, final String comments) throws AccountException {
try {
PersonnelBO personnel = ApplicationContextProvider.getBean(LegacyPersonnelDao.class).getPersonnel(getUserContext().getId());
CustomerActivityEntity customerActivityEntity = null;
if (chargeType != null && chargeType.equals(Short.valueOf(AccountConstants.MISC_PENALTY))) {
customerActivityEntity = new CustomerActivityEntity(this, personnel, charge, AccountConstants.MISC_PENALTY_APPLIED, new DateTimeService().getCurrentJavaDateTime());
} else if (chargeType != null && chargeType.equals(Short.valueOf(AccountConstants.MISC_FEES))) {
customerActivityEntity = new CustomerActivityEntity(this, personnel, charge, AccountConstants.MISC_FEES_APPLIED, new DateTimeService().getCurrentJavaDateTime());
} else {
customerActivityEntity = new CustomerActivityEntity(this, personnel, charge, comments, new DateTimeService().getCurrentJavaDateTime());
}
addCustomerActivity(customerActivityEntity);
} catch (PersistenceException e) {
throw new AccountException(e);
}
}
use of org.mifos.framework.util.DateTimeService in project head by mifos.
the class CustomerAccountBO method applyOneTimeFee.
private void applyOneTimeFee(final FeeBO fee, final Money charge, final AccountActionDateEntity accountActionDateEntity) throws AccountException {
CustomerScheduleEntity customerScheduleEntity = (CustomerScheduleEntity) accountActionDateEntity;
AccountFeesEntity accountFee = new AccountFeesEntity(this, fee, charge.getAmountDoubleValue(), FeeStatus.ACTIVE.getValue(), new DateTimeService().getCurrentJavaDateTime(), null);
List<AccountActionDateEntity> customerScheduleList = new ArrayList<AccountActionDateEntity>();
customerScheduleList.add(customerScheduleEntity);
List<InstallmentDate> installmentDates = new ArrayList<InstallmentDate>();
installmentDates.add(new InstallmentDate(accountActionDateEntity.getInstallmentId(), accountActionDateEntity.getActionDate()));
List<FeeInstallment> feeInstallmentList = new ArrayList<FeeInstallment>();
feeInstallmentList.add(handleOneTime(accountFee, installmentDates));
Money totalFeeAmountApplied = applyFeeToInstallments(feeInstallmentList, customerScheduleList);
updateCustomerActivity(fee.getFeeId(), totalFeeAmountApplied, fee.getFeeName() + AccountConstants.APPLIED);
accountFee.setFeeStatus(FeeStatus.ACTIVE);
}
use of org.mifos.framework.util.DateTimeService in project head by mifos.
the class CustomerAccountBO method updateFee.
public void updateFee(final AccountFeesEntity fee, final FeeBO feeBO) throws BatchJobException {
boolean feeApplied = isFeeAlreadyApplied(fee, feeBO);
if (!feeApplied) {
// update this account fee
try {
if (feeBO.getFeeChangeType().equals(FeeChangeType.AMOUNT_AND_STATUS_UPDATED)) {
if (!feeBO.isActive()) {
removeFeesAssociatedWithUpcomingAndAllKnownFutureInstallments(feeBO.getFeeId(), Short.valueOf("1"));
fee.changeFeesStatus(FeeStatus.INACTIVE, new DateTimeService().getCurrentJavaDateTime());
updateAccountFee(fee, (AmountFeeBO) feeBO);
} else {
// generate repayment schedule and enable fee
fee.changeFeesStatus(FeeStatus.ACTIVE, new DateTimeService().getCurrentJavaDateTime());
updateAccountFee(fee, (AmountFeeBO) feeBO);
associateFeeWithAllKnownFutureInstallments(fee);
}
} else if (feeBO.getFeeChangeType().equals(FeeChangeType.STATUS_UPDATED)) {
if (!feeBO.isActive()) {
removeFeesAssociatedWithUpcomingAndAllKnownFutureInstallments(feeBO.getFeeId(), Short.valueOf("1"));
} else {
fee.changeFeesStatus(FeeStatus.ACTIVE, new DateTimeService().getCurrentJavaDateTime());
associateFeeWithAllKnownFutureInstallments(fee);
}
} else if (feeBO.getFeeChangeType().equals(FeeChangeType.AMOUNT_UPDATED)) {
updateAccountFee(fee, (AmountFeeBO) feeBO);
updateUpcomingAndFutureInstallments(fee);
}
} catch (PropertyNotFoundException e) {
throw new BatchJobException(e);
} catch (AccountException e) {
throw new BatchJobException(e);
}
}
}
use of org.mifos.framework.util.DateTimeService in project head by mifos.
the class ApplyHolidayChangesHelper method reschedule.
private void reschedule(Holiday holiday, AccountBatch accountBatch) throws PersistenceException {
long rescheduleStartTime = new DateTimeService().getCurrentDateTime().getMillis();
List<Object[]> accountIdsArray = accountBatch.getAccountIdsWithDatesIn(holiday);
accountCount = accountIdsArray.size();
logMessage("No. of " + accountBatch.getAccountTypeName() + " Accounts to Process: " + accountCount + " : Query took: " + (new DateTimeService().getCurrentDateTime().getMillis() - rescheduleStartTime) + " ms");
rollingStartTime = new DateTimeService().getCurrentDateTime().getMillis();
currentRecordNumber = 0;
StaticHibernateUtil.getSessionTL();
StaticHibernateUtil.startTransaction();
for (Object[] accountIds : accountIdsArray) {
Integer accountId = (Integer) accountIds[0];
Short officeId = (Short) accountIds[1];
Integer meetingId = (Integer) accountIds[2];
currentRecordNumber++;
ScheduledDateGeneration officeScheduledDateGeneration = getScheduledDateGeneration(officeId);
DateTime amendedThruDate = holiday.getThruDate();
// Normal holidays only affect installments between the fromDate and thruDate
if (holiday.getRepaymentRuleType().getValue().equals(RepaymentRuleTypes.REPAYMENT_MORATORIUM.getValue())) {
amendedThruDate = holiday.getThruDate().plusYears(10);
}
List<AccountActionDateEntity> futureAffectedInstallments = accountBatch.getAffectedInstallments(accountId, holiday.getFromDate(), amendedThruDate);
MeetingBO meeting = (MeetingBO) StaticHibernateUtil.getSessionTL().get(MeetingBO.class, meetingId);
rescheduleDatesForNewHolidays(officeScheduledDateGeneration, futureAffectedInstallments, meeting);
houseKeeping();
}
StaticHibernateUtil.commitTransaction();
long rescheduleEndTime = new DateTimeService().getCurrentDateTime().getMillis();
String message = "" + currentRecordNumber + " updated, " + (accountCount - currentRecordNumber) + " remaining, batch time: " + (rescheduleEndTime - rollingStartTime) + " ms";
logMessage(message);
String finalMessage = accountBatch.getAccountTypeName() + " accounts Processed in: " + (rescheduleEndTime - rescheduleStartTime) + " ms";
logMessage(finalMessage);
}
Aggregations