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());
}
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();
}
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);
}
}
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"));
}
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());
}
Aggregations