use of org.mifos.accounts.business.AccountFeesActionDetailEntity in project head by mifos.
the class AccountServiceIntegrationTest method getCustomerAccountWithAllTypesOfFees.
private CustomerAccountBO getCustomerAccountWithAllTypesOfFees() {
MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
CustomerAccountBO customerAccountBO = center.getCustomerAccount();
CustomerScheduleEntity customerScheduleEntity = (CustomerScheduleEntity) customerAccountBO.getAccountActionDate(Short.valueOf("1"));
FeeBO upfrontFee = TestObjectFactory.createOneTimeRateFee("Upfront Fee", FeeCategory.CENTER, Double.valueOf("20"), FeeFormula.AMOUNT, FeePayment.UPFRONT, null);
AccountFeesEntity accountUpfrontFee = new AccountFeesEntity(customerAccountBO, upfrontFee, new Double("20.0"), FeeStatus.ACTIVE.getValue(), null, customerScheduleEntity.getActionDate());
AccountTestUtils.addAccountFees(accountUpfrontFee, customerAccountBO);
AccountFeesActionDetailEntity accountUpfrontFeesaction = new CustomerFeeScheduleEntity(customerScheduleEntity, upfrontFee, accountUpfrontFee, new Money(getCurrency(), "20.0"));
customerScheduleEntity.addAccountFeesAction(accountUpfrontFeesaction);
TestObjectFactory.updateObject(center);
customerAccountBO = center.getCustomerAccount();
FeeBO periodicFee = TestObjectFactory.createPeriodicAmountFee("Periodic Fee", FeeCategory.ALLCUSTOMERS, "200", RecurrenceType.WEEKLY, Short.valueOf("1"));
AccountFeesEntity accountPeriodicFee = new AccountFeesEntity(customerAccountBO, periodicFee, new Double("200.0"), FeeStatus.INACTIVE.getValue(), null, null);
AccountTestUtils.addAccountFees(accountPeriodicFee, customerAccountBO);
TestObjectFactory.updateObject(center);
return customerAccountBO;
}
use of org.mifos.accounts.business.AccountFeesActionDetailEntity 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.AccountFeesActionDetailEntity in project head by mifos.
the class CenterServiceFacadeWebTier method retrieveChargesDetails.
@Override
public CustomerChargesDetailsDto retrieveChargesDetails(Integer customerId) {
MifosUser mifosUser = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = new UserContextFactory().create(mifosUser);
CustomerBO customerBO = this.customerDao.findCustomerById(customerId);
CustomerAccountBO customerAccount = customerBO.getCustomerAccount();
try {
personnelDao.checkAccessPermission(userContext, customerBO.getOfficeId(), customerBO.getLoanOfficerId());
} catch (AccountException e) {
throw new MifosRuntimeException("Access denied!", e);
}
List<AccountFeesDto> accountFeesDtos = new ArrayList<AccountFeesDto>();
if (!customerAccount.getAccountFees().isEmpty()) {
for (AccountFeesEntity accountFeesEntity : customerAccount.getAccountFees()) {
AccountFeesDto accountFeesDto = new AccountFeesDto(accountFeesEntity.getFees().getFeeFrequency().getFeeFrequencyType().getId(), (accountFeesEntity.getFees().getFeeFrequency().getFeePayment() != null ? accountFeesEntity.getFees().getFeeFrequency().getFeePayment().getId() : null), accountFeesEntity.getFeeStatus(), accountFeesEntity.getFees().getFeeName(), accountFeesEntity.getAccountFeeAmount().toString(), getMeetingRecurrence(accountFeesEntity.getFees().getFeeFrequency().getFeeMeetingFrequency(), userContext), accountFeesEntity.getFees().getFeeId());
accountFeesDtos.add(accountFeesDto);
}
}
CustomerScheduleDto customerSchedule = null;
CustomerScheduleEntity scheduleEntity = (CustomerScheduleEntity) customerAccount.getUpcomingInstallment();
if (scheduleEntity != null) {
Set<AccountFeesActionDetailEntity> feeEntities = scheduleEntity.getAccountFeesActionDetails();
List<AccountFeeScheduleDto> feeDtos = new ArrayList<AccountFeeScheduleDto>();
for (AccountFeesActionDetailEntity feeEntity : feeEntities) {
feeDtos.add(convertToDto(feeEntity));
}
customerSchedule = new CustomerScheduleDto(scheduleEntity.getMiscFee().toString(), scheduleEntity.getMiscFeePaid().toString(), scheduleEntity.getMiscPenalty().toString(), scheduleEntity.getMiscPenaltyPaid().toString(), feeDtos);
}
return new CustomerChargesDetailsDto(customerAccount.getNextDueAmount().toString(), customerAccount.getTotalAmountInArrears().toString(), customerAccount.getTotalAmountDue().toString(), customerAccount.getUpcomingChargesDate(), customerSchedule, accountFeesDtos);
}
use of org.mifos.accounts.business.AccountFeesActionDetailEntity in project head by mifos.
the class CustomerApplyAdjustmentActionStrutsTest method applyPayment.
private void applyPayment() throws Exception {
createInitialObjects();
accountBO = client.getCustomerAccount();
Date currentDate = new Date(System.currentTimeMillis());
CustomerAccountBO customerAccountBO = (CustomerAccountBO) accountBO;
customerAccountBO.setUserContext(userContext);
CustomerScheduleEntity accountAction = (CustomerScheduleEntity) customerAccountBO.getAccountActionDate(Short.valueOf("1"));
CustomerAccountBOTestUtils.setMiscFeePaid(accountAction, TestUtils.createMoney(100));
CustomerAccountBOTestUtils.setMiscPenaltyPaid(accountAction, TestUtils.createMoney(100));
CustomerAccountBOTestUtils.setPaymentDate(accountAction, currentDate);
accountAction.setPaymentStatus(PaymentStatus.PAID);
AccountPaymentEntity accountPaymentEntity = new AccountPaymentEntity(accountBO, TestUtils.createMoney(100), "1111", currentDate, new PaymentTypeEntity(Short.valueOf("1")), new Date(System.currentTimeMillis()));
CustomerTrxnDetailEntity accountTrxnEntity = new CustomerTrxnDetailEntity(accountPaymentEntity, AccountActionTypes.PAYMENT, Short.valueOf("1"), accountAction.getActionDate(), TestObjectFactory.getPersonnel(userContext.getId()), currentDate, TestUtils.createMoney(200), "payment done", null, TestUtils.createMoney(100), TestUtils.createMoney(100));
for (AccountFeesActionDetailEntity accountFeesActionDetailEntity : accountAction.getAccountFeesActionDetails()) {
CustomerAccountBOTestUtils.setFeeAmountPaid((CustomerFeeScheduleEntity) accountFeesActionDetailEntity, TestUtils.createMoney(100));
FeesTrxnDetailEntity feeTrxn = new FeesTrxnDetailEntity(accountTrxnEntity, accountFeesActionDetailEntity.getAccountFee(), accountFeesActionDetailEntity.getFeeAmount());
CustomerBOTestUtils.addFeesTrxnDetail(accountTrxnEntity, feeTrxn);
// totalFees = accountFeesActionDetailEntity.getFeeAmountPaid();
}
accountPaymentEntity.addAccountTrxn(accountTrxnEntity);
AccountTestUtils.addAccountPayment(accountPaymentEntity, customerAccountBO);
TestObjectFactory.updateObject(customerAccountBO);
StaticHibernateUtil.flushSession();
customerAccountBO = TestObjectFactory.getObject(CustomerAccountBO.class, customerAccountBO.getAccountId());
client = customerAccountBO.getCustomer();
SessionUtils.setAttribute(Constants.BUSINESS_KEY, client, request);
}
use of org.mifos.accounts.business.AccountFeesActionDetailEntity in project head by mifos.
the class CustomerAccountBOIntegrationTest method testGenerateMeetingSchedule.
@Test
public void testGenerateMeetingSchedule() throws Exception {
MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
List<FeeDto> feeDto = new ArrayList<FeeDto>();
FeeBO periodicFee = TestObjectFactory.createPeriodicAmountFee("Periodic Fee", FeeCategory.ALLCUSTOMERS, "100", RecurrenceType.WEEKLY, Short.valueOf("1"));
feeDto.add(new FeeDto(userContext, periodicFee));
FeeBO upfrontFee = TestObjectFactory.createOneTimeAmountFee("Upfront Fee", FeeCategory.ALLCUSTOMERS, "30", FeePayment.UPFRONT);
feeDto.add(new FeeDto(userContext, upfrontFee));
center = TestObjectFactory.createCenter("Center_Active_test", meeting, feeDto);
Date startDate = new Date(System.currentTimeMillis());
for (AccountActionDateEntity accountActionDateEntity : center.getCustomerAccount().getAccountActionDates()) {
if (accountActionDateEntity.getInstallmentId().equals(Short.valueOf("1"))) {
Assert.assertEquals(DateUtils.getDateWithoutTimeStamp(startDate.getTime()), DateUtils.getDateWithoutTimeStamp(((CustomerScheduleEntity) accountActionDateEntity).getActionDate().getTime()));
Assert.assertEquals(2, ((CustomerScheduleEntity) accountActionDateEntity).getAccountFeesActionDetails().size());
for (AccountFeesActionDetailEntity accountFeesActionDetailEntity : ((CustomerScheduleEntity) accountActionDateEntity).getAccountFeesActionDetails()) {
if (accountFeesActionDetailEntity.getFee().getFeeName().equals("Periodic Fee")) {
Assert.assertEquals(new Money(getCurrency(), "100.0"), accountFeesActionDetailEntity.getFeeAmount());
} else {
Assert.assertEquals("Upfront Fee", accountFeesActionDetailEntity.getFee().getFeeName());
Assert.assertEquals(new Money(getCurrency(), "30.0"), accountFeesActionDetailEntity.getFeeAmount());
}
}
} else if (accountActionDateEntity.getInstallmentId().equals(Short.valueOf("2"))) {
Assert.assertEquals(1, ((CustomerScheduleEntity) accountActionDateEntity).getAccountFeesActionDetails().size());
Assert.assertEquals(DateUtils.getDateWithoutTimeStamp(incrementCurrentDate(7).getTime()), DateUtils.getDateWithoutTimeStamp(((CustomerScheduleEntity) accountActionDateEntity).getActionDate().getTime()));
}
Assert.assertFalse(((CustomerScheduleEntity) accountActionDateEntity).isPaid());
}
}
Aggregations