Search in sources :

Example 6 with CustomerTrxnDetailEntity

use of org.mifos.customers.business.CustomerTrxnDetailEntity 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);
}
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) AccountFeesActionDetailEntity(org.mifos.accounts.business.AccountFeesActionDetailEntity) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) Date(java.sql.Date) FeesTrxnDetailEntity(org.mifos.accounts.business.FeesTrxnDetailEntity)

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