Search in sources :

Example 46 with PaymentData

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

the class LoanArrearsAgingHelperIntegrationTest method testLoanWithOnePartialPayment.

/**
     * unsure why its failing.
     */
@Ignore
@Test
public void testLoanWithOnePartialPayment() throws Exception {
    LoanBO loan = setUpLoan(dateTime, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING);
    Assert.assertNull(loan.getLoanArrearsAgingEntity());
    short daysOverdue = 3;
    dateTime = dateTime.plusDays(repaymentInterval + daysOverdue);
    new DateTimeService().setCurrentDateTimeFixed(dateTime);
    // make one payment of 8. Interest is paid off first, so 2 goes to interest and 6 to principal
    int principalPayment = 6;
    int interestPayment = 2;
    // paymentAmount == 8
    int paymentAmount = interestPayment + principalPayment;
    PaymentData paymentData = PaymentData.createPaymentData(new Money(Configuration.getInstance().getSystemConfig().getCurrency(), "" + paymentAmount), 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 - principalPayment)), loanArrearsAgingEntity.getUnpaidPrincipal());
    Assert.assertEquals(new Money(getCurrency(), "" + (totalInterest - interestPayment)), loanArrearsAgingEntity.getUnpaidInterest());
    Assert.assertEquals(new Money(getCurrency(), "" + (principalForOneInstallment - principalPayment)), loanArrearsAgingEntity.getOverduePrincipal());
    Assert.assertEquals(new Money(getCurrency(), "0"), loanArrearsAgingEntity.getOverdueInterest());
    Assert.assertEquals(new Money(getCurrency(), "" + (principalForOneInstallment - principalPayment)), 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)

Example 47 with PaymentData

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

the class SavingsBOIntegrationTest method testSuccessfulApplyPaymentWhenNoDepositDue.

@Test
public void testSuccessfulApplyPaymentWhenNoDepositDue() throws Exception {
    createInitialObjects();
    savingsOffering = helper.createSavingsOffering("dfasdasd1", "sad1");
    savings = helper.createSavingsAccount("000X00000000013", savingsOffering, group, AccountStates.SAVINGS_ACC_APPROVED, userContext);
    savings.setUserContext(TestObjectFactory.getContext());
    PersonnelBO loggedInUser = IntegrationTestObjectMother.testUser();
    savings.changeStatus(AccountState.SAVINGS_CANCELLED, null, "", loggedInUser);
    StaticHibernateUtil.getSessionTL().clear();
    savings = savingsDao.findById(savings.getAccountId());
    Money enteredAmount = new Money(currency, "100.0");
    PaymentData paymentData = PaymentData.createPaymentData(enteredAmount, savings.getPersonnel(), Short.valueOf("1"), new Date(System.currentTimeMillis()));
    paymentData.setCustomer(group);
    paymentData.setReceiptDate(new Date(System.currentTimeMillis()));
    paymentData.setReceiptNum("34244");
    paymentData.addAccountPaymentData(getSavingsPaymentdata(null));
    IntegrationTestObjectMother.applyAccountPayment(savings, paymentData);
    savings = savingsDao.findById(savings.getAccountId());
    Assert.assertEquals(AccountStates.SAVINGS_ACC_APPROVED, savings.getAccountState().getId().shortValue());
    Assert.assertEquals(TestUtils.createMoney(100.0), savings.getSavingsBalance());
    Assert.assertEquals(1, savings.getSavingsActivityDetails().size());
}
Also used : Money(org.mifos.framework.util.helpers.Money) PaymentData(org.mifos.accounts.util.helpers.PaymentData) SavingsPaymentData(org.mifos.accounts.util.helpers.SavingsPaymentData) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) Date(java.util.Date) Test(org.junit.Test)

Example 48 with PaymentData

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

the class SavingsBOIntegrationTest method testSuccessfulWithdraw.

@Test
public void testSuccessfulWithdraw() throws AccountException, Exception {
    MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
    center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
    client1 = TestObjectFactory.createClient("Client", CustomerStatus.CLIENT_ACTIVE, group);
    savingsOffering = helper.createSavingsOffering("dfasdasd1", "sad1");
    savings = TestObjectFactory.createSavingsAccount("43245434", client1, Short.valueOf("16"), new Date(System.currentTimeMillis()), savingsOffering);
    savings = (SavingsBO) legacyAccountDao.getAccount(savings.getAccountId());
    savings.setSavingsBalance(TestUtils.createMoney("100.0"));
    Money enteredAmount = new Money(currency, "100.0");
    PaymentData paymentData = PaymentData.createPaymentData(enteredAmount, savings.getPersonnel(), Short.valueOf("1"), new Date(System.currentTimeMillis()));
    paymentData.setCustomer(client1);
    paymentData.setReceiptDate(new Date(System.currentTimeMillis()));
    paymentData.setReceiptNum("34244");
    boolean persist = true;
    savings.withdraw(paymentData, persist);
    Assert.assertEquals(TestUtils.createMoney(), savings.getSavingsBalance());
    Assert.assertEquals(1, savings.getSavingsActivityDetails().size());
    savings.getAccountPayments().clear();
}
Also used : Money(org.mifos.framework.util.helpers.Money) PaymentData(org.mifos.accounts.util.helpers.PaymentData) SavingsPaymentData(org.mifos.accounts.util.helpers.SavingsPaymentData) MeetingBO(org.mifos.application.meeting.business.MeetingBO) Date(java.util.Date) Test(org.junit.Test)

Example 49 with PaymentData

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

the class TestObjectFactory method getLoanAccountPaymentData.

public static PaymentData getLoanAccountPaymentData(final List<AccountActionDateEntity> accountActions, final Money totalAmount, final CustomerBO customer, final PersonnelBO personnel, final String receiptNum, final Short paymentId, final Date receiptDate, final Date transactionDate) {
    PaymentData paymentData = PaymentData.createPaymentData(totalAmount, personnel, paymentId, transactionDate);
    paymentData.setCustomer(customer);
    paymentData.setReceiptDate(receiptDate);
    paymentData.setReceiptNum(receiptNum);
    return paymentData;
}
Also used : PaymentData(org.mifos.accounts.util.helpers.PaymentData) CustomerAccountPaymentData(org.mifos.accounts.util.helpers.CustomerAccountPaymentData)

Example 50 with PaymentData

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

the class TestObjectFactory method getCustomerAccountPaymentDataView.

public static PaymentData getCustomerAccountPaymentDataView(final List<AccountActionDateEntity> accountActions, final Money totalAmount, final CustomerBO customer, final PersonnelBO personnel, final String receiptNum, final Short paymentId, final Date receiptDate, final Date transactionDate) {
    PaymentData paymentData = PaymentData.createPaymentData(totalAmount, personnel, paymentId, transactionDate);
    paymentData.setCustomer(customer);
    paymentData.setReceiptDate(receiptDate);
    paymentData.setReceiptNum(receiptNum);
    for (AccountActionDateEntity actionDate : accountActions) {
        CustomerAccountPaymentData customerAccountPaymentData = new CustomerAccountPaymentData(actionDate);
        paymentData.addAccountPaymentData(customerAccountPaymentData);
    }
    return paymentData;
}
Also used : PaymentData(org.mifos.accounts.util.helpers.PaymentData) CustomerAccountPaymentData(org.mifos.accounts.util.helpers.CustomerAccountPaymentData) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) CustomerAccountPaymentData(org.mifos.accounts.util.helpers.CustomerAccountPaymentData)

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