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