Search in sources :

Example 6 with PaymentData

use of org.mifos.accounts.util.helpers.PaymentData in project head by mifos.

the class LoanBOForReversalIntegrationTest method applyPaymentForLoan.

private void applyPaymentForLoan() throws AccountException {
    loan = retrieveLoanAccount();
    loan.setUserContext(userContext);
    List<AccountActionDateEntity> accntActionDates = new ArrayList<AccountActionDateEntity>();
    accntActionDates.addAll(loan.getAccountActionDates());
    Date currentDate = new Date(System.currentTimeMillis());
    PaymentData paymentData = TestObjectFactory.getLoanAccountPaymentData(accntActionDates, TestUtils.createMoney(200), null, loan.getPersonnel(), "receiptNum", Short.valueOf("1"), currentDate, currentDate);
    IntegrationTestObjectMother.applyAccountPayment(loan, paymentData);
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) PaymentData(org.mifos.accounts.util.helpers.PaymentData) ArrayList(java.util.ArrayList) Date(java.util.Date)

Example 7 with PaymentData

use of org.mifos.accounts.util.helpers.PaymentData in project head by mifos.

the class AccountBOIntegrationTest method testAdjustmentForClosedAccnt.

@Test
public void testAdjustmentForClosedAccnt() throws Exception {
    Date currentDate = new Date(System.currentTimeMillis());
    LoanBO loan = groupLoan;
    loan.setUserContext(TestUtils.makeUser());
    List<AccountActionDateEntity> accntActionDates = new ArrayList<AccountActionDateEntity>();
    accntActionDates.addAll(loan.getAccountActionDates());
    PaymentData accountPaymentDataView = TestObjectFactory.getLoanAccountPaymentData(accntActionDates, TestUtils.createMoney(712), null, loan.getPersonnel(), "receiptNum", Short.valueOf("1"), currentDate, currentDate);
    IntegrationTestObjectMother.applyAccountPayment(loan, accountPaymentDataView);
    loan.setAccountState(new AccountStateEntity(AccountState.LOAN_CLOSED_OBLIGATIONS_MET));
    TestObjectFactory.updateObject(loan);
    try {
        PersonnelBO loggedInUser = IntegrationTestObjectMother.testUser();
        loan.adjustPmnt("loan account has been adjusted by test code", loggedInUser);
    } catch (AccountException e) {
        Assert.assertEquals("exception.accounts.ApplicationException.CannotAdjust", e.getKey());
    }
}
Also used : PaymentData(org.mifos.accounts.util.helpers.PaymentData) AccountException(org.mifos.accounts.exceptions.AccountException) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) LoanBO(org.mifos.accounts.loan.business.LoanBO) ArrayList(java.util.ArrayList) Date(java.sql.Date) Test(org.junit.Test)

Example 8 with PaymentData

use of org.mifos.accounts.util.helpers.PaymentData in project head by mifos.

the class AccountBOIntegrationTest method testGetTransactionHistoryViewByOtherUser.

@Test
public void testGetTransactionHistoryViewByOtherUser() throws Exception {
    Date currentDate = new Date(System.currentTimeMillis());
    LoanBO loan = groupLoan;
    loan.setUserContext(TestUtils.makeUser());
    List<AccountActionDateEntity> accntActionDates = new ArrayList<AccountActionDateEntity>();
    accntActionDates.addAll(loan.getAccountActionDates());
    PersonnelBO personnel = legacyPersonnelDao.getPersonnel(Short.valueOf("2"));
    PaymentData accountPaymentDataView = TestObjectFactory.getLoanAccountPaymentData(accntActionDates, TestUtils.createMoney(100), null, personnel, "receiptNum", Short.valueOf("1"), currentDate, currentDate);
    IntegrationTestObjectMother.applyAccountPayment(loan, accountPaymentDataView);
    loan = TestObjectFactory.getObject(LoanBO.class, loan.getAccountId());
    loan.setUserContext(TestUtils.makeUser());
    List<TransactionHistoryDto> trxnHistlist = loan.getTransactionHistoryView();
    Assert.assertNotNull("Account TrxnHistoryView list object should not be null", trxnHistlist);
    Assert.assertTrue("Account TrxnHistoryView list object Size should be greater than zero", trxnHistlist.size() > 0);
    for (TransactionHistoryDto transactionHistoryDto : trxnHistlist) {
        Assert.assertEquals(transactionHistoryDto.getPostedBy(), personnel.getDisplayName());
    }
    StaticHibernateUtil.flushSession();
    groupLoan = TestObjectFactory.getObject(LoanBO.class, loan.getAccountId());
}
Also used : PaymentData(org.mifos.accounts.util.helpers.PaymentData) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) LoanBO(org.mifos.accounts.loan.business.LoanBO) ArrayList(java.util.ArrayList) TransactionHistoryDto(org.mifos.dto.screen.TransactionHistoryDto) Date(java.sql.Date) Test(org.junit.Test)

Example 9 with PaymentData

use of org.mifos.accounts.util.helpers.PaymentData in project head by mifos.

the class AccountBOIntegrationTest method testUpdatePerformanceHistoryOnAdjustment.

@Test
public void testUpdatePerformanceHistoryOnAdjustment() throws Exception {
    Date currentDate = new Date(System.currentTimeMillis());
    List<AccountActionDateEntity> accntActionDates = new ArrayList<AccountActionDateEntity>();
    PaymentData paymentData1 = TestObjectFactory.getLoanAccountPaymentData(accntActionDates, TestUtils.createMoney(212), null, groupLoan.getPersonnel(), "receiptNum", Short.valueOf("1"), currentDate, currentDate);
    IntegrationTestObjectMother.applyAccountPayment(groupLoan, paymentData1);
    IntegrationTestObjectMother.saveLoanAccount(groupLoan);
    LoanBO loan = IntegrationTestObjectMother.findLoanBySystemId(groupLoan.getGlobalAccountNum());
    PaymentData paymentData2 = TestObjectFactory.getLoanAccountPaymentData(null, TestUtils.createMoney(600), null, loan.getPersonnel(), "receiptNum", Short.valueOf("1"), currentDate, currentDate);
    IntegrationTestObjectMother.applyAccountPayment(loan, paymentData2);
    IntegrationTestObjectMother.saveLoanAccount(groupLoan);
    groupLoan = IntegrationTestObjectMother.findLoanBySystemId(groupLoan.getGlobalAccountNum());
    groupLoan.setUserContext(TestUtils.makeUser());
    PersonnelBO loggedInUser = IntegrationTestObjectMother.testUser();
    groupLoan.adjustPmnt("loan account has been adjusted by test code", loggedInUser);
    IntegrationTestObjectMother.saveLoanAccount(groupLoan);
}
Also used : PaymentData(org.mifos.accounts.util.helpers.PaymentData) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) LoanBO(org.mifos.accounts.loan.business.LoanBO) ArrayList(java.util.ArrayList) Date(java.sql.Date) Test(org.junit.Test)

Example 10 with PaymentData

use of org.mifos.accounts.util.helpers.PaymentData in project head by mifos.

the class LoanAdjustmentsIntegrationTest method makePayment.

private void makePayment(LoanBO loan, String amount) throws Exception {
    PaymentData paymentData = PaymentData.createPaymentData(new Money(loan.getCurrency(), amount), testUser(), (short) 1, new DateTime().toDate());
    IntegrationTestObjectMother.applyAccountPayment(loan, paymentData);
}
Also used : PaymentData(org.mifos.accounts.util.helpers.PaymentData) Money(org.mifos.framework.util.helpers.Money) DateTime(org.joda.time.DateTime)

Aggregations

PaymentData (org.mifos.accounts.util.helpers.PaymentData)59 Money (org.mifos.framework.util.helpers.Money)34 Test (org.junit.Test)32 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)24 Date (java.util.Date)22 AccountException (org.mifos.accounts.exceptions.AccountException)22 LoanBO (org.mifos.accounts.loan.business.LoanBO)22 ArrayList (java.util.ArrayList)19 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)18 Date (java.sql.Date)17 MeetingBO (org.mifos.application.meeting.business.MeetingBO)15 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)15 LocalDate (org.joda.time.LocalDate)11 UserContext (org.mifos.security.util.UserContext)11 BigDecimal (java.math.BigDecimal)10 SavingsPaymentData (org.mifos.accounts.util.helpers.SavingsPaymentData)9 MifosRuntimeException (org.mifos.core.MifosRuntimeException)8 MifosUser (org.mifos.security.MifosUser)7 AccountTrxnEntity (org.mifos.accounts.business.AccountTrxnEntity)6 DateTimeService (org.mifos.framework.util.DateTimeService)6