use of org.mifos.accounts.business.FeesTrxnDetailEntity 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.FeesTrxnDetailEntity in project head by mifos.
the class CustomerAccountBOIntegrationTest method testTrxnDetailEntityObjectsForMultipleInstallmentsWhenOnlyCustomerAccountFeesAreDue.
@Test
public void testTrxnDetailEntityObjectsForMultipleInstallmentsWhenOnlyCustomerAccountFeesAreDue() throws Exception {
createCenter();
CustomerAccountBO customerAccount = center.getCustomerAccount();
Date transactionDate = incrementCurrentDate(14);
PaymentData paymentData = PaymentData.createPaymentData(new Money(getCurrency(), "300"), center.getPersonnel(), Short.valueOf("1"), transactionDate);
paymentData.setCustomer(center);
IntegrationTestObjectMother.applyAccountPayment(customerAccount, paymentData);
if (customerAccount.getAccountPayments() != null && customerAccount.getAccountPayments().size() == 1) {
for (AccountPaymentEntity accountPaymentEntity : customerAccount.getAccountPayments()) {
final Money zeroAmount = new Money(getCurrency(), "0.0");
final Money OneHundredAmount = new Money(getCurrency(), "100.0");
if (accountPaymentEntity.getAccountTrxns() != null && accountPaymentEntity.getAccountTrxns().size() == 3) {
for (AccountTrxnEntity accountTrxnEntity : accountPaymentEntity.getAccountTrxns()) {
CustomerTrxnDetailEntity customerTrxnDetailEntity = (CustomerTrxnDetailEntity) accountTrxnEntity;
Assert.assertEquals(zeroAmount, customerTrxnDetailEntity.getAmount());
Assert.assertEquals(zeroAmount, customerTrxnDetailEntity.getTotalAmount());
Assert.assertEquals(zeroAmount, customerTrxnDetailEntity.getMiscFeeAmount());
Assert.assertEquals(zeroAmount, customerTrxnDetailEntity.getMiscPenaltyAmount());
if (customerTrxnDetailEntity.getFeesTrxnDetails() != null && customerTrxnDetailEntity.getFeesTrxnDetails().size() == 1) {
for (FeesTrxnDetailEntity feesTrxnDetailEntity : customerTrxnDetailEntity.getFeesTrxnDetails()) {
Assert.assertEquals(OneHundredAmount, feesTrxnDetailEntity.getFeeAmount());
}
} else {
throw new Exception("Expected one FeesTrxnDetailEntity, found none or more than one");
}
}
} else {
throw new Exception("Expected three CustomerTrxnDetailEntity, found none or not three");
}
}
} else {
throw new Exception("Expected one AccountPaymentEntity, found none or more than one");
}
}
use of org.mifos.accounts.business.FeesTrxnDetailEntity in project head by mifos.
the class TestObjectFactory method deleteAccountPayment.
private static void deleteAccountPayment(final AccountPaymentEntity accountPayment, final Session session) {
Set<AccountTrxnEntity> loanTrxns = accountPayment.getAccountTrxns();
for (AccountTrxnEntity accountTrxn : loanTrxns) {
if (accountTrxn instanceof LoanTrxnDetailEntity) {
LoanTrxnDetailEntity loanTrxn = (LoanTrxnDetailEntity) accountTrxn;
for (FeesTrxnDetailEntity feesTrxn : loanTrxn.getFeesTrxnDetails()) {
session.delete(feesTrxn);
}
for (FinancialTransactionBO financialTrxn : loanTrxn.getFinancialTransactions()) {
session.delete(financialTrxn);
}
session.delete(loanTrxn);
}
}
session.delete(accountPayment);
}
use of org.mifos.accounts.business.FeesTrxnDetailEntity in project head by mifos.
the class LoanBO method buildLoanActivity.
private LoanActivityEntity buildLoanActivity(final Collection<AccountTrxnEntity> accountTrxnDetails, final PersonnelBO personnel, String comments, final Date trxnDate) {
Date activityDate = trxnDate;
Money principal = new Money(getCurrency());
Money interest = new Money(getCurrency());
Money penalty = new Money(getCurrency());
Money fees = new Money(getCurrency());
for (AccountTrxnEntity accountTrxn : accountTrxnDetails) {
if (!accountTrxn.isTrxnForReversalOfLoanDisbursal()) {
LoanTrxnDetailEntity loanTrxn = (LoanTrxnDetailEntity) accountTrxn;
principal = principal.add(removeSign(loanTrxn.getPrincipalAmount()));
interest = interest.add(removeSign(loanTrxn.getInterestAmount()));
penalty = penalty.add(removeSign(loanTrxn.getPenaltyAmount())).add(removeSign(loanTrxn.getMiscPenaltyAmount()));
fees = fees.add(removeSign(loanTrxn.getMiscFeeAmount()));
for (FeesTrxnDetailEntity feesTrxn : loanTrxn.getFeesTrxnDetails()) {
fees = fees.add(removeSign(feesTrxn.getFeeAmount()));
}
}
if (accountTrxn.isTrxnForReversalOfLoanDisbursal() || accountTrxn.getAccountActionEntity().getId().equals(AccountActionTypes.LOAN_REVERSAL.getValue())) {
comments = "Loan Reversal";
}
}
Money interestOutstanding = loanSummary.getOriginalInterest().subtract(loanSummary.getInterestPaid());
if (isDecliningBalanceInterestRecalculation()) {
for (LoanScheduleEntity loanScheduleEntity : getLoanScheduleEntities()) {
interestOutstanding = interestOutstanding.add(loanScheduleEntity.getExtraInterest());
}
}
return new LoanActivityEntity(this, personnel, comments, principal, loanSummary.getOriginalPrincipal().subtract(loanSummary.getPrincipalPaid()), interest, interestOutstanding, fees, loanSummary.getOriginalFees().subtract(loanSummary.getFeesPaid()), penalty, loanSummary.getOriginalPenalty().subtract(loanSummary.getPenaltyPaid()), activityDate);
}
use of org.mifos.accounts.business.FeesTrxnDetailEntity in project head by mifos.
the class LoanTrxnDetailEntity method generateReverseTrxn.
@Override
protected AccountTrxnEntity generateReverseTrxn(PersonnelBO loggedInUser, String adjustmentComment) throws AccountException {
logger.debug("Inside generate reverse transaction method of loan trxn detail");
String comment = null;
if (null == adjustmentComment) {
comment = getComments();
} else {
comment = adjustmentComment;
}
LoanTrxnDetailEntity reverseAccntTrxn;
reverseAccntTrxn = new LoanTrxnDetailEntity(getAccountPayment(), getReverseTransctionActionType(), getInstallmentId(), getDueDate(), loggedInUser, getActionDate(), getAmount().negate(), comment, this, getPrincipalAmount().negate(), getInterestAmount().negate(), getPenaltyAmount().negate(), getMiscFeeAmount().negate(), getMiscPenaltyAmount().negate(), null, null);
reverseAccntTrxn.setCalculatedInterestOnPayment(this.getCalculatedInterestOnPayment());
if (null != getFeesTrxnDetails() && getFeesTrxnDetails().size() > 0) {
logger.debug("Before generating reverse entries for fees");
for (FeesTrxnDetailEntity feeTrxnDetail : getFeesTrxnDetails()) {
reverseAccntTrxn.addFeesTrxnDetail(feeTrxnDetail.generateReverseTrxn(reverseAccntTrxn));
}
logger.debug("after generating reverse entries for fees");
}
if (null != getPenaltiesTrxnDetails() && getPenaltiesTrxnDetails().size() > 0) {
logger.debug("Before generating reverse entries for penalties");
for (PenaltiesTrxnDetailEntity penaltyTrxnDetail : getPenaltiesTrxnDetails()) {
reverseAccntTrxn.addPenaltiesTrxnDetail(penaltyTrxnDetail.generateReverseTrxn(reverseAccntTrxn));
}
logger.debug("after generating reverse entries for penalties");
}
return reverseAccntTrxn;
}
Aggregations