Search in sources :

Example 16 with PaymentData

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

the class SavingsApplyAdjustmentActionStrutsTest method createSavingsAccountWithPayment.

private SavingsBO createSavingsAccountWithPayment(String globalAccountNum, SavingsOfferingBO savingsOffering, CustomerBO group, AccountState state) throws Exception {
    SavingsBO savings = TestObjectFactory.createSavingsAccount(globalAccountNum, group, state, new Date(), savingsOffering, userContext);
    PaymentData paymentData = PaymentData.createPaymentData(new Money(getCurrency(), "100"), savings.getPersonnel(), Short.valueOf("1"), new Date(System.currentTimeMillis()));
    paymentData.setCustomer(group);
    paymentData.setReceiptDate(new Date(System.currentTimeMillis()));
    paymentData.setReceiptNum("34244");
    AccountActionDateEntity accountActionDate = null;
    paymentData.addAccountPaymentData(new SavingsPaymentData(accountActionDate));
    IntegrationTestObjectMother.applyAccountPayment(savings, paymentData);
    return savingsDao.findById(savings.getAccountId());
}
Also used : SavingsPaymentData(org.mifos.accounts.util.helpers.SavingsPaymentData) SavingsPaymentData(org.mifos.accounts.util.helpers.SavingsPaymentData) PaymentData(org.mifos.accounts.util.helpers.PaymentData) Money(org.mifos.framework.util.helpers.Money) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) Date(java.util.Date)

Example 17 with PaymentData

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

the class BulkEntryPersistenceIntegrationTest method testSuccessfulApplyPayment.

@Test
public void testSuccessfulApplyPayment() throws Exception {
    MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
    center = TestObjectFactory.createWeeklyFeeCenter("Center_Active", meeting);
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
    Date startDate = new Date(System.currentTimeMillis());
    LoanOfferingBO loanOffering = TestObjectFactory.createLoanOffering(startDate, meeting);
    account = TestObjectFactory.createLoanAccount("42423142341", group, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, startDate, loanOffering);
    StaticHibernateUtil.flushSession();
    account = legacyAccountDao.getAccount(account.getAccountId());
    Assert.assertEquals(((LoanBO) account).getLoanOffering().getPrdOfferingName(), "Loan");
    List<AccountActionDateEntity> accntActionDates = new ArrayList<AccountActionDateEntity>();
    accntActionDates.add(account.getAccountActionDates().iterator().next());
    Date currentDate = startDate;
    PaymentData paymentData = TestObjectFactory.getLoanAccountPaymentData(accntActionDates, TestUtils.createMoney("100.0"), null, account.getPersonnel(), "423423", Short.valueOf("1"), currentDate, currentDate);
    try {
        IntegrationTestObjectMother.applyAccountPayment(account, paymentData);
        Assert.assertEquals(((LoanBO) account).getLoanSummary().getFeesPaid(), TestUtils.createMoney("100.0"));
    } catch (Exception e) {
        e.printStackTrace();
    }
    account.getAccountPayments().clear();
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) PaymentData(org.mifos.accounts.util.helpers.PaymentData) MeetingBO(org.mifos.application.meeting.business.MeetingBO) LoanBO(org.mifos.accounts.loan.business.LoanBO) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) ArrayList(java.util.ArrayList) Date(java.util.Date) AccountException(org.mifos.accounts.exceptions.AccountException) Test(org.junit.Test)

Example 18 with PaymentData

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

the class BulkEntryPersistenceIntegrationTest method testFailureApplyPayment.

@Test
public void testFailureApplyPayment() throws Exception {
    Date startDate = new Date(System.currentTimeMillis());
    MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
    center = TestObjectFactory.createWeeklyFeeCenter("Center_Active", meeting);
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
    LoanOfferingBO loanOffering = TestObjectFactory.createLoanOffering(startDate, meeting);
    account = TestObjectFactory.createLoanAccount("42423142341", group, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, startDate, loanOffering);
    StaticHibernateUtil.flushSession();
    account = legacyAccountDao.getAccount(account.getAccountId());
    Assert.assertEquals(((LoanBO) account).getLoanOffering().getPrdOfferingName(), "Loan");
    for (AccountActionDateEntity actionDate : account.getAccountActionDates()) {
        if (actionDate.getInstallmentId().equals(Short.valueOf("1"))) {
            actionDate.setPaymentStatus(PaymentStatus.PAID);
        }
    }
    List<AccountActionDateEntity> accntActionDates = new ArrayList<AccountActionDateEntity>();
    accntActionDates.addAll(account.getAccountActionDates());
    PaymentData paymentData = TestObjectFactory.getLoanAccountPaymentData(accntActionDates, TestUtils.createMoney("3000.0"), null, account.getPersonnel(), "423423", Short.valueOf("1"), startDate, startDate);
    try {
        account.applyPayment(paymentData);
        Assert.fail("should throw exception");
    } catch (AccountException be) {
        Assert.assertNotNull(be);
        Assert.assertEquals(be.getKey(), "errors.makePayment");
        Assert.assertTrue(true);
    }
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) PaymentData(org.mifos.accounts.util.helpers.PaymentData) AccountException(org.mifos.accounts.exceptions.AccountException) MeetingBO(org.mifos.application.meeting.business.MeetingBO) LoanBO(org.mifos.accounts.loan.business.LoanBO) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) ArrayList(java.util.ArrayList) Date(java.util.Date) Test(org.junit.Test)

Example 19 with PaymentData

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

the class BulkEntryPersistenceIntegrationTest method testSuccessfulLoanUpdate.

@Test
public void testSuccessfulLoanUpdate() throws Exception {
    Date startDate = new Date(System.currentTimeMillis());
    MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
    center = TestObjectFactory.createWeeklyFeeCenter("Center_Active", meeting);
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
    LoanOfferingBO loanOffering = TestObjectFactory.createLoanOffering(startDate, meeting);
    account = TestObjectFactory.createLoanAccount("42423142341", group, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, startDate, loanOffering);
    StaticHibernateUtil.flushSession();
    account = legacyAccountDao.getAccount(account.getAccountId());
    Assert.assertEquals(((LoanBO) account).getLoanOffering().getPrdOfferingName(), "Loan");
    List<AccountActionDateEntity> accntActionDates = new ArrayList<AccountActionDateEntity>();
    accntActionDates.add(account.getAccountActionDates().iterator().next());
    Date currentDate = startDate;
    PaymentData paymentData = TestObjectFactory.getLoanAccountPaymentData(accntActionDates, TestUtils.createMoney("100.0"), null, account.getPersonnel(), "423423", Short.valueOf("1"), currentDate, currentDate);
    IntegrationTestObjectMother.applyAccountPayment(account, paymentData);
    Assert.assertEquals(((LoanBO) account).getLoanSummary().getFeesPaid(), TestUtils.createMoney("100.0"));
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) PaymentData(org.mifos.accounts.util.helpers.PaymentData) MeetingBO(org.mifos.application.meeting.business.MeetingBO) LoanBO(org.mifos.accounts.loan.business.LoanBO) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) ArrayList(java.util.ArrayList) Date(java.util.Date) Test(org.junit.Test)

Example 20 with PaymentData

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

the class LoanArrearsAgingHelperIntegrationTest method testLoanWithOnePaymentMadeAndOneOverduePayments.

/**
     * unsure why its failing.
     */
@Ignore
@Test
public void testLoanWithOnePaymentMadeAndOneOverduePayments() throws Exception {
    LoanBO loan = setUpLoan(dateTime, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING);
    Assert.assertNull(loan.getLoanArrearsAgingEntity());
    short daysOverdue = 3;
    // advance time daysOverdue past the second repayment interval
    dateTime = dateTime.plusDays(2 * repaymentInterval + daysOverdue);
    new DateTimeService().setCurrentDateTimeFixed(dateTime);
    // make one payment, so we should still be one payment behind after that
    PaymentData paymentData = PaymentData.createPaymentData(new Money(Configuration.getInstance().getSystemConfig().getCurrency(), "" + onePayment), loan.getPersonnel(), Short.valueOf("1"), dateTime.toDate());
    IntegrationTestObjectMother.applyAccountPayment(loan, paymentData);
    runLoanArrearsThenLoanArrearsAging();
    StaticHibernateUtil.flushAndClearSession();
    loan = legacyLoanDao.getAccount(loan.getAccountId());
    Assert.assertNotNull(loan.getLoanArrearsAgingEntity());
    LoanArrearsAgingEntity loanArrearsAgingEntity = loan.getLoanArrearsAgingEntity();
    Assert.assertEquals(new Money(getCurrency(), "" + (loanAmount - principalForOneInstallment)), loanArrearsAgingEntity.getUnpaidPrincipal());
    Assert.assertEquals(new Money(getCurrency(), "" + (totalInterest - interestForOneInstallment)), loanArrearsAgingEntity.getUnpaidInterest());
    Assert.assertEquals(new Money(getCurrency(), "" + principalForOneInstallment), loanArrearsAgingEntity.getOverduePrincipal());
    Assert.assertEquals(new Money(getCurrency(), "" + interestForOneInstallment), loanArrearsAgingEntity.getOverdueInterest());
    Assert.assertEquals(new Money(getCurrency(), "" + (principalForOneInstallment + interestForOneInstallment)), loanArrearsAgingEntity.getOverdueBalance());
    Assert.assertEquals(Short.valueOf(daysOverdue), loanArrearsAgingEntity.getDaysInArrears());
}
Also used : PaymentData(org.mifos.accounts.util.helpers.PaymentData) Money(org.mifos.framework.util.helpers.Money) LoanBO(org.mifos.accounts.loan.business.LoanBO) LoanArrearsAgingEntity(org.mifos.accounts.loan.business.LoanArrearsAgingEntity) DateTimeService(org.mifos.framework.util.DateTimeService) Ignore(org.junit.Ignore) Test(org.junit.Test)

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