use of org.mifos.accounts.business.AccountBO in project head by mifos.
the class AccountServiceIntegrationTest method getLoanAccountWithAllTypesOfFees.
private AccountBO getLoanAccountWithAllTypesOfFees() {
accountBO = getLoanAccount();
LoanScheduleEntity loanScheduleEntity = (LoanScheduleEntity) accountBO.getAccountActionDate(Short.valueOf("1"));
FeeBO upfrontFee = TestObjectFactory.createOneTimeRateFee("Upfront Fee", FeeCategory.LOAN, Double.valueOf("20"), FeeFormula.AMOUNT, FeePayment.UPFRONT, null);
AccountFeesEntity accountUpfrontFee = new AccountFeesEntity(accountBO, upfrontFee, new Double("20.0"), FeeStatus.ACTIVE.getValue(), null, loanScheduleEntity.getActionDate());
AccountTestUtils.addAccountFees(accountUpfrontFee, accountBO);
AccountFeesActionDetailEntity accountUpfrontFeesaction = new LoanFeeScheduleEntity(loanScheduleEntity, upfrontFee, accountUpfrontFee, new Money(getCurrency(), "20.0"));
loanScheduleEntity.addAccountFeesAction(accountUpfrontFeesaction);
TestObjectFactory.updateObject(accountBO);
accountBO = TestObjectFactory.getObject(AccountBO.class, accountBO.getAccountId());
loanScheduleEntity = (LoanScheduleEntity) accountBO.getAccountActionDate(Short.valueOf("1"));
FeeBO timeOfDisbursementFees = TestObjectFactory.createOneTimeAmountFee("Disbursement Fee", FeeCategory.LOAN, "30", FeePayment.TIME_OF_DISBURSEMENT);
AccountFeesEntity accountDisbursementFee = new AccountFeesEntity(accountBO, timeOfDisbursementFees, new Double("30.0"), FeeStatus.ACTIVE.getValue(), null, loanScheduleEntity.getActionDate());
AccountTestUtils.addAccountFees(accountDisbursementFee, accountBO);
AccountFeesActionDetailEntity accountDisbursementFeesaction = new LoanFeeScheduleEntity(loanScheduleEntity, timeOfDisbursementFees, accountDisbursementFee, new Money(getCurrency(), "30.0"));
loanScheduleEntity.addAccountFeesAction(accountDisbursementFeesaction);
TestObjectFactory.updateObject(accountBO);
accountBO = TestObjectFactory.getObject(AccountBO.class, accountBO.getAccountId());
loanScheduleEntity = (LoanScheduleEntity) accountBO.getAccountActionDate(Short.valueOf("1"));
FeeBO firstLoanRepaymentFee = TestObjectFactory.createOneTimeAmountFee("First Loan Repayment Fee", FeeCategory.LOAN, "40", FeePayment.TIME_OF_FIRSTLOANREPAYMENT);
AccountFeesEntity accountFirstLoanRepaymentFee = new AccountFeesEntity(accountBO, firstLoanRepaymentFee, new Double("40.0"), FeeStatus.ACTIVE.getValue(), null, loanScheduleEntity.getActionDate());
AccountTestUtils.addAccountFees(accountFirstLoanRepaymentFee, accountBO);
AccountFeesActionDetailEntity accountTimeOfFirstLoanRepaymentFeesaction = new LoanFeeScheduleEntity(loanScheduleEntity, firstLoanRepaymentFee, accountFirstLoanRepaymentFee, new Money(getCurrency(), "40.0"));
loanScheduleEntity.addAccountFeesAction(accountTimeOfFirstLoanRepaymentFeesaction);
TestObjectFactory.updateObject(accountBO);
accountBO = TestObjectFactory.getObject(AccountBO.class, accountBO.getAccountId());
FeeBO periodicFee = TestObjectFactory.createPeriodicAmountFee("Periodic Fee", FeeCategory.LOAN, "200", RecurrenceType.WEEKLY, Short.valueOf("1"));
AccountFeesEntity accountPeriodicFee = new AccountFeesEntity(accountBO, periodicFee, new Double("200.0"), FeeStatus.INACTIVE.getValue(), null, null);
AccountTestUtils.addAccountFees(accountPeriodicFee, accountBO);
TestObjectFactory.updateObject(accountBO);
return accountBO;
}
use of org.mifos.accounts.business.AccountBO in project head by mifos.
the class AccountServiceIntegrationTest method testGetAppllicableFeesForInstallmentStartingOnCurrentDate.
@Test
@Ignore
public void testGetAppllicableFeesForInstallmentStartingOnCurrentDate() throws Exception {
AccountBusinessService accountBusinessService = new AccountBusinessService();
accountBO = getLoanAccountWithAllTypesOfFees();
StaticHibernateUtil.flushSession();
center = TestObjectFactory.getCustomer(center.getCustomerId());
group = TestObjectFactory.getCustomer(group.getCustomerId());
accountBO = TestObjectFactory.getObject(AccountBO.class, accountBO.getAccountId());
StaticHibernateUtil.flushAndClearSession();
UserContext uc = TestUtils.makeUser();
List<ApplicableCharge> applicableChargeList = accountBusinessService.getAppllicableFees(accountBO.getAccountId(), uc);
Assert.assertEquals(4, applicableChargeList.size());
for (ApplicableCharge applicableCharge : applicableChargeList) {
if (applicableCharge.getFeeName().equalsIgnoreCase("Upfront Fee")) {
Assert.assertEquals(new Money(getCurrency(), "20.0"), new Money(getCurrency(), applicableCharge.getAmountOrRate()));
Assert.assertNotNull(applicableCharge.getFormula());
Assert.assertNull(applicableCharge.getPeriodicity());
} else if (applicableCharge.getFeeName().equalsIgnoreCase("Periodic Fee")) {
Assert.assertEquals(new Money(getCurrency(), "200.0"), new Money(getCurrency(), applicableCharge.getAmountOrRate()));
Assert.assertNull(applicableCharge.getFormula());
Assert.assertNotNull(applicableCharge.getPeriodicity());
} else if (applicableCharge.getFeeName().equalsIgnoreCase("Misc Fee")) {
Assert.assertNull(applicableCharge.getAmountOrRate());
Assert.assertNull(applicableCharge.getFormula());
Assert.assertNull(applicableCharge.getPeriodicity());
}
}
}
use of org.mifos.accounts.business.AccountBO in project head by mifos.
the class AccountServiceIntegrationTest method testGetAppllicableFeesForInstallmentStartingAfterCurrentDate.
@Test
public void testGetAppllicableFeesForInstallmentStartingAfterCurrentDate() throws Exception {
AccountBusinessService accountBusinessService = new AccountBusinessService();
accountBO = getLoanAccountWithAllTypesOfFees();
incrementInstallmentDate(accountBO, 1, Short.valueOf("1"));
accountBO.setUserContext(TestObjectFactory.getContext());
PersonnelBO loggedInUser = IntegrationTestObjectMother.testUser();
accountBO.changeStatus(AccountState.LOAN_DISBURSED_TO_LOAN_OFFICER, null, "", loggedInUser);
TestObjectFactory.updateObject(accountBO);
StaticHibernateUtil.flushSession();
center = TestObjectFactory.getCustomer(center.getCustomerId());
group = TestObjectFactory.getCustomer(group.getCustomerId());
StaticHibernateUtil.flushAndClearSession();
accountBO = TestObjectFactory.getObject(AccountBO.class, accountBO.getAccountId());
UserContext uc = TestUtils.makeUser();
List<ApplicableCharge> applicableChargeList = accountBusinessService.getAppllicableFees(accountBO.getAccountId(), uc);
Assert.assertEquals(3, applicableChargeList.size());
for (ApplicableCharge applicableCharge : applicableChargeList) {
if (applicableCharge.getFeeName().equalsIgnoreCase("Periodic Fee")) {
Assert.assertEquals(new Money(getCurrency(), "200.0"), new Money(getCurrency(), applicableCharge.getAmountOrRate()));
Assert.assertNull(applicableCharge.getFormula());
Assert.assertNotNull(applicableCharge.getPeriodicity());
} else if (applicableCharge.getFeeName().equalsIgnoreCase("Misc Fee")) {
Assert.assertNull(applicableCharge.getAmountOrRate());
Assert.assertNull(applicableCharge.getFormula());
Assert.assertNull(applicableCharge.getPeriodicity());
}
}
}
use of org.mifos.accounts.business.AccountBO in project head by mifos.
the class CenterServiceFacadeWebTier method waiveChargesOverDue.
@Override
public void waiveChargesOverDue(Integer accountId, Integer waiveType) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
try {
AccountBO account = new AccountBusinessService().getAccount(accountId);
account.updateDetails(userContext);
WaiveEnum waiveEnum = WaiveEnum.fromInt(waiveType);
if (account.getPersonnel() != null) {
new AccountBusinessService().checkPermissionForWaiveDue(waiveEnum, account.getType(), account.getCustomer().getLevel(), userContext, account.getOffice().getOfficeId(), account.getPersonnel().getPersonnelId());
} else {
new AccountBusinessService().checkPermissionForWaiveDue(waiveEnum, account.getType(), account.getCustomer().getLevel(), userContext, account.getOffice().getOfficeId(), userContext.getId());
}
this.transactionHelper.startTransaction();
account.waiveAmountOverDue(waiveEnum);
this.customerDao.save(account);
this.transactionHelper.commitTransaction();
} catch (ServiceException e) {
this.transactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} catch (ApplicationException e) {
this.transactionHelper.rollbackTransaction();
throw new BusinessRuleException(e.getKey(), e);
} finally {
this.transactionHelper.closeSession();
}
}
use of org.mifos.accounts.business.AccountBO in project head by mifos.
the class CenterServiceFacadeWebTier method createAccountFeeEntities.
private List<AccountFeesEntity> createAccountFeeEntities(List<CreateAccountFeeDto> feesToApply) {
List<AccountFeesEntity> feesForCustomerAccount = new ArrayList<AccountFeesEntity>();
for (CreateAccountFeeDto feeDto : feesToApply) {
FeeBO fee = feeDao.findById(feeDto.getFeeId().shortValue());
Double feeAmount = new LocalizationConverter().getDoubleValueForCurrentLocale(feeDto.getAmount());
AccountBO nullReferenceForNow = null;
AccountFeesEntity accountFee = new AccountFeesEntity(nullReferenceForNow, fee, feeAmount);
feesForCustomerAccount.add(accountFee);
}
return feesForCustomerAccount;
}
Aggregations