Search in sources :

Example 1 with FeesTrxnDetailEntity

use of org.mifos.accounts.business.FeesTrxnDetailEntity in project head by mifos.

the class CustomerFeesAdjustmentAccountingEntry method applySpecificAccountActionEntry.

@Override
protected void applySpecificAccountActionEntry() throws FinancialException {
    CustomerTrxnDetailEntity customertrxn = (CustomerTrxnDetailEntity) financialActivity.getAccountTrxn();
    Set<FeesTrxnDetailEntity> feesTrxn = customertrxn.getFeesTrxnDetails();
    Iterator<FeesTrxnDetailEntity> iterFees = feesTrxn.iterator();
    FinancialActionTypeEntity finActionFee = getFinancialAction(FinancialActionConstants.FEEPOSTING);
    while (iterFees.hasNext()) {
        FeesTrxnDetailEntity feeTrxn = iterFees.next();
        addAccountEntryDetails(feeTrxn.getFeeAmount(), finActionFee, feeTrxn.getAccountFees().getFees().getGlCode(), FinancialConstants.DEBIT);
        addAccountEntryDetails(feeTrxn.getFeeAmount(), finActionFee, getGLcode(finActionFee.getApplicableDebitCharts()), FinancialConstants.CREDIT);
    }
    // For Misc Fee
    FinancialActionTypeEntity finActionMiscFee = FinancialActionCache.getFinancialAction(FinancialActionConstants.CUSTOMERACCOUNTMISCFEESPOSTING);
    addAccountEntryDetails(customertrxn.getMiscFeeAmount(), finActionMiscFee, getGLcode(finActionMiscFee.getApplicableDebitCharts()), FinancialConstants.CREDIT);
    addAccountEntryDetails(customertrxn.getMiscFeeAmount(), finActionMiscFee, getGLcode(finActionMiscFee.getApplicableCreditCharts()), FinancialConstants.DEBIT);
}
Also used : CustomerTrxnDetailEntity(org.mifos.customers.business.CustomerTrxnDetailEntity) FinancialActionTypeEntity(org.mifos.accounts.financial.business.FinancialActionTypeEntity) FeesTrxnDetailEntity(org.mifos.accounts.business.FeesTrxnDetailEntity)

Example 2 with FeesTrxnDetailEntity

use of org.mifos.accounts.business.FeesTrxnDetailEntity in project head by mifos.

the class FeesAdjustmentAccountingEntry method applySpecificAccountActionEntry.

@Override
protected void applySpecificAccountActionEntry() throws FinancialException {
    LoanTrxnDetailEntity loanTrxn = (LoanTrxnDetailEntity) financialActivity.getAccountTrxn();
    Set<FeesTrxnDetailEntity> feesTrxn = loanTrxn.getFeesTrxnDetails();
    Iterator<FeesTrxnDetailEntity> iterFees = feesTrxn.iterator();
    FinancialActionTypeEntity finActionFee = getFinancialAction(FinancialActionConstants.FEEPOSTING);
    while (iterFees.hasNext()) {
        FeesTrxnDetailEntity feeTrxn = iterFees.next();
        addAccountEntryDetails(feeTrxn.getFeeAmount(), finActionFee, feeTrxn.getAccountFees().getFees().getGlCode(), FinancialConstants.DEBIT);
        addAccountEntryDetails(feeTrxn.getFeeAmount(), finActionFee, getGLcode(finActionFee.getApplicableDebitCharts()), FinancialConstants.CREDIT);
    }
    // For Misc Fee
    FinancialActionTypeEntity finActionMiscFee = FinancialActionCache.getFinancialAction(FinancialActionConstants.MISCFEEPOSTING);
    addAccountEntryDetails(loanTrxn.getMiscFeeAmount(), finActionMiscFee, getGLcode(finActionMiscFee.getApplicableDebitCharts()), FinancialConstants.CREDIT);
    addAccountEntryDetails(loanTrxn.getMiscFeeAmount(), finActionMiscFee, getGLcode(finActionMiscFee.getApplicableCreditCharts()), FinancialConstants.DEBIT);
}
Also used : FinancialActionTypeEntity(org.mifos.accounts.financial.business.FinancialActionTypeEntity) LoanTrxnDetailEntity(org.mifos.accounts.loan.business.LoanTrxnDetailEntity) FeesTrxnDetailEntity(org.mifos.accounts.business.FeesTrxnDetailEntity)

Example 3 with FeesTrxnDetailEntity

use of org.mifos.accounts.business.FeesTrxnDetailEntity in project head by mifos.

the class CustomerTrxnDetailEntityIntegrationTest method testGenerateReverseTrxn.

@Test
public void testGenerateReverseTrxn() throws Exception {
    accountBO = client.getCustomerAccount();
    Date currentDate = new Date(System.currentTimeMillis());
    CustomerAccountBO customerAccountBO = (CustomerAccountBO) accountBO;
    customerAccountBO.setUserContext(userContext);
    CustomerScheduleEntity accountAction = (CustomerScheduleEntity) customerAccountBO.getAccountActionDate(Short.valueOf("1"));
    accountAction.setMiscFeePaid(TestUtils.createMoney(100));
    accountAction.setMiscPenaltyPaid(TestUtils.createMoney(100));
    accountAction.setPaymentDate(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());
        accountTrxnEntity.addFeesTrxnDetail(feeTrxn);
    }
    accountPaymentEntity.addAccountTrxn(accountTrxnEntity);
    AccountTestUtils.addAccountPayment(accountPaymentEntity, customerAccountBO);
    PersonnelBO loggedInUser = legacyPersonnelDao.getPersonnel(userContext.getId());
    for (AccountTrxnEntity accntTrxn : customerAccountBO.findMostRecentPaymentByPaymentDate().getAccountTrxns()) {
        AccountTrxnEntity reverseAccntTrxn = ((CustomerTrxnDetailEntity) accntTrxn).generateReverseTrxn(loggedInUser, "adjustment");
        Assert.assertEquals(reverseAccntTrxn.getAmount(), accntTrxn.getAmount().negate());
        Assert.assertEquals(loggedInUser.getPersonnelId(), reverseAccntTrxn.getPersonnel().getPersonnelId());
    }
}
Also used : PaymentTypeEntity(org.mifos.application.master.business.PaymentTypeEntity) AccountTrxnEntity(org.mifos.accounts.business.AccountTrxnEntity) AccountFeesActionDetailEntity(org.mifos.accounts.business.AccountFeesActionDetailEntity) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) Date(java.sql.Date) FeesTrxnDetailEntity(org.mifos.accounts.business.FeesTrxnDetailEntity) Test(org.junit.Test)

Example 4 with FeesTrxnDetailEntity

use of org.mifos.accounts.business.FeesTrxnDetailEntity in project head by mifos.

the class CustomerAccountBOIntegrationTest method testTrxnDetailEntityObjectsForMultipleInstallmentsWhenBothCustomerAccountChargesAndFeesAreDue.

@Test
public void testTrxnDetailEntityObjectsForMultipleInstallmentsWhenBothCustomerAccountChargesAndFeesAreDue() throws Exception {
    createCenter();
    FeeBO extraFee = TestObjectFactory.createPeriodicAmountFee("extra fee", FeeCategory.ALLCUSTOMERS, "5.5", RecurrenceType.WEEKLY, Short.valueOf("1"));
    CustomerAccountBO customerAccount = center.getCustomerAccount();
    AccountFeesEntity extraAccountFeesEntity = new AccountFeesEntity(customerAccount, extraFee, 11.66);
    // FIXME: a fee is being added by exposing an internal data structure and adding it directly to it
    customerAccount.getAccountFeesIncludingInactiveFees().add(extraAccountFeesEntity);
    final Money eightAmount = new Money(getCurrency(), "8.0");
    final Money fiftyAmount = new Money(getCurrency(), "50.0");
    final Money seventyAmount = new Money(getCurrency(), "70.0");
    final Money oneHundredTwentyAmount = new Money(getCurrency(), "120.0");
    for (AccountActionDateEntity accountActionDateEntity : customerAccount.getAccountActionDates()) {
        CustomerScheduleEntity customerSchedule = (CustomerScheduleEntity) accountActionDateEntity;
        if (customerSchedule.getInstallmentId() == 2) {
            customerSchedule.setMiscFee(fiftyAmount);
            customerSchedule.setMiscPenalty(seventyAmount);
        }
        if (customerSchedule.getInstallmentId() == 3) {
            CustomerAccountBOTestUtils.applyPeriodicFees(customerSchedule, extraAccountFeesEntity.getFees().getFeeId(), new Money(getCurrency(), "8"));
        }
    }
    Date transactionDate = incrementCurrentDate(14);
    PaymentData paymentData = PaymentData.createPaymentData(new Money(getCurrency(), "428"), 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(accountPaymentEntity.getAmount().getCurrency(), "0.0");
            final Money OneHundredAmount = new Money(accountPaymentEntity.getAmount().getCurrency(), "100.0");
            if (accountPaymentEntity.getAccountTrxns() != null && accountPaymentEntity.getAccountTrxns().size() == 3) {
                for (AccountTrxnEntity accountTrxnEntity : accountPaymentEntity.getAccountTrxns()) {
                    CustomerTrxnDetailEntity customerTrxnDetailEntity = (CustomerTrxnDetailEntity) accountTrxnEntity;
                    if (customerTrxnDetailEntity.getInstallmentId() == 2) {
                        Assert.assertEquals(oneHundredTwentyAmount, customerTrxnDetailEntity.getAmount());
                        Assert.assertEquals(oneHundredTwentyAmount, customerTrxnDetailEntity.getTotalAmount());
                        Assert.assertEquals(fiftyAmount, customerTrxnDetailEntity.getMiscFeeAmount());
                        Assert.assertEquals(seventyAmount, customerTrxnDetailEntity.getMiscPenaltyAmount());
                    } else {
                        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() < 3) {
                        for (FeesTrxnDetailEntity feesTrxnDetailEntity : customerTrxnDetailEntity.getFeesTrxnDetails()) {
                            if (feesTrxnDetailEntity.getAccountFees().getAccountFeeId() == extraAccountFeesEntity.getAccountFeeId()) {
                                Assert.assertEquals(eightAmount, feesTrxnDetailEntity.getFeeAmount());
                            } else {
                                Assert.assertEquals(OneHundredAmount, feesTrxnDetailEntity.getFeeAmount());
                            }
                        }
                    } else {
                        throw new Exception("Expected one FeesTrxnDetailEntity, found none or more than two");
                    }
                }
            } 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");
    }
}
Also used : PaymentData(org.mifos.accounts.util.helpers.PaymentData) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) Date(java.sql.Date) SystemException(org.mifos.framework.exceptions.SystemException) AccountException(org.mifos.accounts.exceptions.AccountException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) Money(org.mifos.framework.util.helpers.Money) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) AccountTrxnEntity(org.mifos.accounts.business.AccountTrxnEntity) FeeBO(org.mifos.accounts.fees.business.FeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) FeesTrxnDetailEntity(org.mifos.accounts.business.FeesTrxnDetailEntity) Test(org.junit.Test)

Example 5 with FeesTrxnDetailEntity

use of org.mifos.accounts.business.FeesTrxnDetailEntity in project head by mifos.

the class CustomerAccountBOIntegrationTest method applyPayment.

private void applyPayment() throws Exception {
    client = TestObjectFactory.createClient("Client_Active_test", CustomerStatus.CLIENT_ACTIVE, group);
    customerAccountBO = client.getCustomerAccount();
    Date currentDate = new Date(System.currentTimeMillis());
    customerAccountBO.setUserContext(userContext);
    CustomerScheduleEntity accountAction = (CustomerScheduleEntity) customerAccountBO.getAccountActionDate(Short.valueOf("1"));
    accountAction.setMiscFeePaid(TestUtils.createMoney(100));
    accountAction.setMiscPenaltyPaid(TestUtils.createMoney(100));
    accountAction.setPaymentDate(currentDate);
    accountAction.setPaymentStatus(PaymentStatus.PAID);
    AccountPaymentEntity accountPaymentEntity = new AccountPaymentEntity(customerAccountBO, TestUtils.createMoney(300), "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(300), "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());
        accountTrxnEntity.addFeesTrxnDetail(feeTrxn);
    }
    accountPaymentEntity.addAccountTrxn(accountTrxnEntity);
    AccountTestUtils.addAccountPayment(accountPaymentEntity, customerAccountBO);
    TestObjectFactory.updateObject(customerAccountBO);
    StaticHibernateUtil.flushSession();
}
Also used : PaymentTypeEntity(org.mifos.application.master.business.PaymentTypeEntity) AccountFeesActionDetailEntity(org.mifos.accounts.business.AccountFeesActionDetailEntity) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) Date(java.sql.Date) FeesTrxnDetailEntity(org.mifos.accounts.business.FeesTrxnDetailEntity)

Aggregations

FeesTrxnDetailEntity (org.mifos.accounts.business.FeesTrxnDetailEntity)16 Date (java.sql.Date)6 AccountFeesActionDetailEntity (org.mifos.accounts.business.AccountFeesActionDetailEntity)6 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)6 AccountTrxnEntity (org.mifos.accounts.business.AccountTrxnEntity)5 FinancialActionTypeEntity (org.mifos.accounts.financial.business.FinancialActionTypeEntity)4 LoanTrxnDetailEntity (org.mifos.accounts.loan.business.LoanTrxnDetailEntity)4 Money (org.mifos.framework.util.helpers.Money)4 Test (org.junit.Test)3 AccountException (org.mifos.accounts.exceptions.AccountException)3 PaymentTypeEntity (org.mifos.application.master.business.PaymentTypeEntity)3 CustomerTrxnDetailEntity (org.mifos.customers.business.CustomerTrxnDetailEntity)3 PaymentData (org.mifos.accounts.util.helpers.PaymentData)2 ApplicationException (org.mifos.framework.exceptions.ApplicationException)2 SystemException (org.mifos.framework.exceptions.SystemException)2 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 LocalDate (org.joda.time.LocalDate)1 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)1