Search in sources :

Example 1 with CustomerTrxnDetailEntity

use of org.mifos.customers.business.CustomerTrxnDetailEntity 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 CustomerTrxnDetailEntity

use of org.mifos.customers.business.CustomerTrxnDetailEntity in project head by mifos.

the class CustomerPenaltyAdjustmentAccountingEntry method applySpecificAccountActionEntry.

@Override
protected void applySpecificAccountActionEntry() throws FinancialException {
    CustomerTrxnDetailEntity customertrxn = (CustomerTrxnDetailEntity) financialActivity.getAccountTrxn();
    FinancialActionTypeEntity finActionMiscPenalty = FinancialActionCache.getFinancialAction(FinancialActionConstants.MISCPENALTYPOSTING);
    addAccountEntryDetails(customertrxn.getMiscPenaltyAmount(), finActionMiscPenalty, getGLcode(finActionMiscPenalty.getApplicableDebitCharts()), FinancialConstants.CREDIT);
    addAccountEntryDetails(customertrxn.getMiscPenaltyAmount(), finActionMiscPenalty, getGLcode(finActionMiscPenalty.getApplicableCreditCharts()), FinancialConstants.DEBIT);
}
Also used : CustomerTrxnDetailEntity(org.mifos.customers.business.CustomerTrxnDetailEntity) FinancialActionTypeEntity(org.mifos.accounts.financial.business.FinancialActionTypeEntity)

Example 3 with CustomerTrxnDetailEntity

use of org.mifos.customers.business.CustomerTrxnDetailEntity in project head by mifos.

the class BaseFinancialActivity method getMiscPenaltyAmount.

public Money getMiscPenaltyAmount() {
    AccountBO account = getAccountTrxn().getAccount();
    Money amount = new Money(account.getCurrency());
    if (account.getType() == AccountTypes.LOAN_ACCOUNT) {
        amount = ((LoanTrxnDetailEntity) getAccountTrxn()).getMiscPenaltyAmount();
    } else if (account.getType() == AccountTypes.CUSTOMER_ACCOUNT) {
        amount = ((CustomerTrxnDetailEntity) getAccountTrxn()).getMiscPenaltyAmount();
    }
    return amount;
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) Money(org.mifos.framework.util.helpers.Money) CustomerTrxnDetailEntity(org.mifos.customers.business.CustomerTrxnDetailEntity)

Example 4 with CustomerTrxnDetailEntity

use of org.mifos.customers.business.CustomerTrxnDetailEntity in project head by mifos.

the class CustomerAccountFeesAccountingEntry method applySpecificAccountActionEntry.

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

Example 5 with CustomerTrxnDetailEntity

use of org.mifos.customers.business.CustomerTrxnDetailEntity in project head by mifos.

the class AccountPaymentEntityIntegrationTest method testReversalAdjustment.

@Test
public void testReversalAdjustment() throws Exception {
    userContext = TestObjectFactory.getContext();
    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(customerAccountBO, 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()) {
        accountFeesActionDetailEntity.setFeeAmountPaid(TestUtils.createMoney(100));
        FeesTrxnDetailEntity feeTrxn = new FeesTrxnDetailEntity(accountTrxnEntity, accountFeesActionDetailEntity.getAccountFee(), accountFeesActionDetailEntity.getFeeAmount());
        CustomerBOTestUtils.addFeesTrxnDetail(accountTrxnEntity, feeTrxn);
    // TODO: is there anything to assert on here?
    // totalFees = accountFeesActionDetailEntity.getFeeAmountPaid();
    }
    accountPaymentEntity.addAccountTrxn(accountTrxnEntity);
    customerAccountBO.addAccountPayment(accountPaymentEntity);
    TestObjectFactory.updateObject(customerAccountBO);
    StaticHibernateUtil.flushSession();
    customerAccountBO = TestObjectFactory.getObject(CustomerAccountBO.class, customerAccountBO.getAccountId());
    client = customerAccountBO.getCustomer();
    PersonnelBO loggedInUser = legacyPersonnelDao.getPersonnel(userContext.getId());
    List<AccountTrxnEntity> reversedTrxns = customerAccountBO.findMostRecentPaymentByPaymentDate().reversalAdjustment(loggedInUser, "adjustment");
    for (AccountTrxnEntity accntTrxn : reversedTrxns) {
        CustomerTrxnDetailEntity custTrxn = (CustomerTrxnDetailEntity) accntTrxn;
        CustomerScheduleEntity accntActionDate = (CustomerScheduleEntity) customerAccountBO.getAccountActionDate(custTrxn.getInstallmentId());
        Assert.assertEquals(custTrxn.getMiscFeeAmount(), accntActionDate.getMiscFeePaid().negate());
        Assert.assertEquals(custTrxn.getMiscPenaltyAmount(), accntActionDate.getMiscPenaltyPaid().negate());
        Assert.assertEquals(loggedInUser.getPersonnelId(), custTrxn.getPersonnel().getPersonnelId());
    }
}
Also used : PaymentTypeEntity(org.mifos.application.master.business.PaymentTypeEntity) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) CustomerTrxnDetailEntity(org.mifos.customers.business.CustomerTrxnDetailEntity) CustomerScheduleEntity(org.mifos.customers.business.CustomerScheduleEntity) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) Date(java.sql.Date) Test(org.junit.Test)

Aggregations

CustomerTrxnDetailEntity (org.mifos.customers.business.CustomerTrxnDetailEntity)6 FeesTrxnDetailEntity (org.mifos.accounts.business.FeesTrxnDetailEntity)3 FinancialActionTypeEntity (org.mifos.accounts.financial.business.FinancialActionTypeEntity)3 Date (java.sql.Date)2 PaymentTypeEntity (org.mifos.application.master.business.PaymentTypeEntity)2 CustomerAccountBO (org.mifos.customers.business.CustomerAccountBO)2 CustomerScheduleEntity (org.mifos.customers.business.CustomerScheduleEntity)2 Test (org.junit.Test)1 AccountBO (org.mifos.accounts.business.AccountBO)1 AccountFeesActionDetailEntity (org.mifos.accounts.business.AccountFeesActionDetailEntity)1 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)1 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)1 Money (org.mifos.framework.util.helpers.Money)1