use of org.mifos.accounts.util.helpers.PaymentData in project head by mifos.
the class CustomerAccountBOIntegrationTest method testAccountTrxnsAreZeroWhenOnlyCustomerAccountFeesAreDueForMultipleInstallments.
@Test
public void testAccountTrxnsAreZeroWhenOnlyCustomerAccountFeesAreDueForMultipleInstallments() throws Exception {
createCenter();
CustomerAccountBO customerAccount = center.getCustomerAccount();
Date transactionDate = incrementCurrentDate(14);
PaymentData paymentData = PaymentData.createPaymentData(new Money(getCurrency(), "300"), center.getPersonnel(), Short.valueOf("1"), transactionDate);
paymentData.setCustomer(center);
customerAccount.makePayment(paymentData);
// Assert.assertEquals(expectedErrorMessage, actualErrorMessage);
}
use of org.mifos.accounts.util.helpers.PaymentData in project head by mifos.
the class CustomerAccountBOIntegrationTest method testTrxnDetailEntityObjectsForMultipleInstallmentsWhenOnlyCustomerAccountChargesAreDue.
@Test
public void testTrxnDetailEntityObjectsForMultipleInstallmentsWhenOnlyCustomerAccountChargesAreDue() throws Exception {
MeetingBO weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
center = new CenterBuilder().with(weeklyMeeting).withName("Center").with(sampleBranchOffice()).withLoanOfficer(testUser()).build();
IntegrationTestObjectMother.createCenter((CenterBO) center, weeklyMeeting);
CustomerAccountBO customerAccount = center.getCustomerAccount();
final Money fiftyAmount = new Money(getCurrency(), "50.0");
final Money seventyAmount = new Money(getCurrency(), "70.0");
final Money oneHundredTwentyAmount = new Money(getCurrency(), "120.0");
final Money twoHundredFortyAmount = new Money(getCurrency(), "240.0");
for (AccountActionDateEntity accountActionDateEntity : customerAccount.getAccountActionDates()) {
CustomerScheduleEntity customerSchedule = (CustomerScheduleEntity) accountActionDateEntity;
if (customerSchedule.getInstallmentId() != 2) {
customerSchedule.setMiscFee(fiftyAmount);
customerSchedule.setMiscPenalty(seventyAmount);
}
}
Date transactionDate = incrementCurrentDate(14);
PaymentData paymentData = PaymentData.createPaymentData(twoHundredFortyAmount, center.getPersonnel(), Short.valueOf("1"), transactionDate);
paymentData.setCustomer(center);
IntegrationTestObjectMother.applyAccountPayment(customerAccount, paymentData);
if (customerAccount.getAccountPayments() != null && customerAccount.getAccountPayments().size() == 1) {
for (AccountPaymentEntity accountPaymentEntity : customerAccount.getAccountPayments()) {
final Money zeroAmount = new Money(accountPaymentEntity.getAmount().getCurrency(), "0.0");
if (accountPaymentEntity.getAccountTrxns() != null && accountPaymentEntity.getAccountTrxns().size() == 3) {
for (AccountTrxnEntity accountTrxnEntity : accountPaymentEntity.getAccountTrxns()) {
CustomerTrxnDetailEntity customerTrxnDetailEntity = (CustomerTrxnDetailEntity) accountTrxnEntity;
if (customerTrxnDetailEntity.getInstallmentId() != 2) {
Assert.assertEquals(oneHundredTwentyAmount, customerTrxnDetailEntity.getAmount());
Assert.assertEquals(oneHundredTwentyAmount, customerTrxnDetailEntity.getTotalAmount());
Assert.assertEquals(fiftyAmount, customerTrxnDetailEntity.getMiscFeeAmount());
Assert.assertEquals(seventyAmount, customerTrxnDetailEntity.getMiscPenaltyAmount());
} else {
Assert.assertEquals(zeroAmount, customerTrxnDetailEntity.getAmount());
Assert.assertEquals(zeroAmount, customerTrxnDetailEntity.getTotalAmount());
Assert.assertEquals(zeroAmount, customerTrxnDetailEntity.getMiscFeeAmount());
Assert.assertEquals(zeroAmount, customerTrxnDetailEntity.getMiscPenaltyAmount());
}
Assert.assertEquals(0, customerTrxnDetailEntity.getFeesTrxnDetails().size());
}
} else {
throw new Exception("Expected three CustomerTrxnDetailEntity, found none or not three");
}
}
} else {
throw new Exception("Expected one AccountPaymentEntity, found none or more than one");
}
}
use of org.mifos.accounts.util.helpers.PaymentData in project head by mifos.
the class CustomerAccountBOIntegrationTest method testPayMiscChargePlusWeeklyFeeExactSameDay.
@Test
public void testPayMiscChargePlusWeeklyFeeExactSameDay() throws Exception {
MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
center = TestObjectFactory.createWeeklyFeeCenter("Center_Active_test", meeting);
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group_Active_test", CustomerStatus.GROUP_ACTIVE, center);
StaticHibernateUtil.flushSession();
center = TestObjectFactory.getCustomer(center.getCustomerId());
group = TestObjectFactory.getCustomer(group.getCustomerId());
customerAccountBO = group.getCustomerAccount();
UserContext uc = TestUtils.makeUser();
customerAccountBO.setUserContext(uc);
customerAccountBO.applyCharge(Short.valueOf("-1"), new Double("33"));
CustomerScheduleEntity firstInstallment = null;
for (AccountActionDateEntity accountActionDateEntity : customerAccountBO.getAccountActionDates()) {
CustomerScheduleEntity customerScheduleEntity = (CustomerScheduleEntity) accountActionDateEntity;
if (customerScheduleEntity.getInstallmentId().equals(Short.valueOf("1"))) {
firstInstallment = customerScheduleEntity;
Assert.assertEquals(new Money(getCurrency(), "33.0"), customerScheduleEntity.getMiscFee());
}
}
PaymentData paymentData = PaymentData.createPaymentData(new Money(getCurrency(), "133.0"), center.getPersonnel(), (short) 1, firstInstallment.getActionDate());
customerAccountBO.applyPayment(paymentData);
for (AccountActionDateEntity accountActionDateEntity : customerAccountBO.getAccountActionDates()) {
CustomerScheduleEntity customerScheduleEntity = (CustomerScheduleEntity) accountActionDateEntity;
if (customerScheduleEntity.getInstallmentId().equals(Short.valueOf("1"))) {
Assert.assertEquals(new Money(getCurrency(), "33"), customerScheduleEntity.getMiscFee());
Assert.assertEquals(new Money(getCurrency(), "33"), customerScheduleEntity.getMiscFeePaid());
}
}
}
use of org.mifos.accounts.util.helpers.PaymentData in project head by mifos.
the class LoanArrearsAgingHelperIntegrationTest method testLoanWithOnePaymentMadeAndNoOverduePayments.
@Ignore
@Test
public void testLoanWithOnePaymentMadeAndNoOverduePayments() throws Exception {
LoanBO loan = setUpLoan(dateTime, AccountState.LOAN_ACTIVE_IN_BAD_STANDING);
Assert.assertNull(loan.getLoanArrearsAgingEntity());
short daysPastPaymentDate = 3;
// advance time daysOverdue past the second repayment interval
dateTime = dateTime.plusDays(repaymentInterval + daysPastPaymentDate);
new DateTimeService().setCurrentDateTimeFixed(dateTime);
runLoanArrearsThenLoanArrearsAging();
loan = legacyLoanDao.getAccount(loan.getAccountId());
Assert.assertNotNull(loan.getLoanArrearsAgingEntity());
// 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);
//jpwrunLoanArrearsThenLoanArrearsAging();
loan = legacyLoanDao.getAccount(loan.getAccountId());
Assert.assertNull(loan.getLoanArrearsAgingEntity());
Assert.assertTrue(loan.getState().equals(AccountState.LOAN_ACTIVE_IN_GOOD_STANDING));
}
use of org.mifos.accounts.util.helpers.PaymentData in project head by mifos.
the class PortfolioAtRiskCalculationIntegrationTest method createPayment.
private void createPayment(LoanBO loan, Money amountPaid) throws Exception {
Set<AccountActionDateEntity> actionDateEntities = loan.getAccountActionDates();
LoanScheduleEntity[] paymentsArray = LoanBOTestUtils.getSortedAccountActionDateEntity(actionDateEntities, 6);
PersonnelBO personnelBO = legacyPersonnelDao.getPersonnel(TestObjectFactory.getContext().getId());
LoanScheduleEntity loanSchedule = paymentsArray[0];
Short paymentTypeId = PaymentTypes.CASH.getValue();
PaymentData paymentData = PaymentData.createPaymentData(amountPaid, personnelBO, paymentTypeId, loanSchedule.getActionDate());
IntegrationTestObjectMother.applyAccountPayment(loan, paymentData);
paymentData = PaymentData.createPaymentData(amountPaid, personnelBO, paymentTypeId, loanSchedule.getActionDate());
IntegrationTestObjectMother.applyAccountPayment(loan, paymentData);
}
Aggregations