use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.
the class CustomerAccountBOIntegrationTest method testGenerateMeetingScheduleForGroupWhenMeeingDatesOfCenterIsPassed.
@Ignore
@Test
public void testGenerateMeetingScheduleForGroupWhenMeeingDatesOfCenterIsPassed() throws ApplicationException, SystemException {
MeetingBO meetingBO = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
center = TestObjectFactory.createWeeklyFeeCenter("Center_Active_test", meetingBO);
changeFirstInstallmentDateToPreviousDate(center.getCustomerAccount());
center.update();
StaticHibernateUtil.flushAndClearSession();
center = TestObjectFactory.getCenter(center.getCustomerId());
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group_Active_test", CustomerStatus.GROUP_ACTIVE, center);
StaticHibernateUtil.flushAndClearSession();
center = TestObjectFactory.getCenter(center.getCustomerId());
java.util.Date nextMeetingDate = center.getCustomerAccount().getNextMeetingDate();
group = TestObjectFactory.getGroup(group.getCustomerId());
for (AccountActionDateEntity actionDateEntity : group.getCustomerAccount().getAccountActionDates()) {
if (actionDateEntity.getInstallmentId().equals(Short.valueOf("1"))) {
Assert.assertEquals(DateUtils.getDateWithoutTimeStamp(actionDateEntity.getActionDate().getTime()), DateUtils.getDateWithoutTimeStamp(nextMeetingDate.getTime()));
}
}
}
use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.
the class CustomerAccountBOIntegrationTest method testFailureMakePayment.
@Test
public void testFailureMakePayment() throws Exception {
createCenter();
CustomerAccountBO customerAccount = center.getCustomerAccount();
Assert.assertNotNull(customerAccount);
Date transactionDate = new Date(System.currentTimeMillis());
List<AccountActionDateEntity> dueActionDates = TestObjectFactory.getDueActionDatesForAccount(customerAccount.getAccountId(), transactionDate);
Assert.assertEquals("The size of the due insallments is ", dueActionDates.size(), 1);
PaymentData accountPaymentDataView = TestObjectFactory.getCustomerAccountPaymentDataView(dueActionDates, TestUtils.createMoney("100.0"), null, center.getPersonnel(), "3424324", Short.valueOf("1"), transactionDate, transactionDate);
center = TestObjectFactory.getCustomer(center.getCustomerId());
customerAccount = center.getCustomerAccount();
IntegrationTestObjectMother.applyAccountPayment(customerAccount, accountPaymentDataView);
Assert.assertEquals("The size of the payments done is", customerAccount.getAccountPayments().size(), 1);
try {
// one more for the next meeting
customerAccount.applyPayment(accountPaymentDataView);
// and the error one
customerAccount.applyPayment(accountPaymentDataView);
Assert.fail("Payment is done even though they are no dues");
} catch (AccountException ae) {
Assert.assertTrue("Payment is not allowed when there are no dues", true);
}
}
use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.
the class CustomerAccountBOIntegrationTest method testPayPartOfMiscChargePlusWeeklyFeePreviousDay.
@Test
public void testPayPartOfMiscChargePlusWeeklyFeePreviousDay() 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());
}
}
DateMidnight pDate = new DateMidnight(firstInstallment.getActionDate());
PaymentData paymentData = PaymentData.createPaymentData(new Money(getCurrency(), "120.0"), center.getPersonnel(), (short) 1, pDate.minusDays(1).toDate());
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(), "20"), customerScheduleEntity.getMiscFeePaid());
Assert.assertEquals(new Money(getCurrency(), "100"), customerScheduleEntity.getAccountFeesActionDetailsSortedByFeeId().get(0).getFeeAmount());
Assert.assertEquals(new Money(getCurrency(), "100"), customerScheduleEntity.getAccountFeesActionDetailsSortedByFeeId().get(0).getFeeAmountPaid());
}
}
}
use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.
the class CustomerAccountBOIntegrationTest method testApplyUpfrontFee.
// replaced by unit tests in CustomerAccountBOTest. Remove when we're sure that unit tests cover this
// functionality
// public void testApplyPeriodicFee() 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();
// FeeBO periodicFee = TestObjectFactory.createPeriodicAmountFee("Periodic Fee", FeeCategory.ALLCUSTOMERS, "200",
// RecurrenceType.WEEKLY, Short.valueOf("2"));
// UserContext uc = TestUtils.makeUser();
// customerAccountBO.setUserContext(uc);
//
// // exercise test
// customerAccountBO.applyCharge(periodicFee.getFeeId(), ((AmountFeeBO) periodicFee).getFeeAmount()
// .getAmountDoubleValue());
// StaticHibernateUtil.commitTransaction();
//
// // verification
// Date lastAppliedDate = null;
// for (AccountActionDateEntity accountActionDateEntity : customerAccountBO.getAccountActionDates()) {
// CustomerScheduleEntity customerScheduleEntity = (CustomerScheduleEntity) accountActionDateEntity;
// if (customerScheduleEntity.getInstallmentId() % 2 == 0) {
// //Maintenance fee only applies to installments 2, 4, 6, ...
// Assert.assertEquals(1, customerScheduleEntity.getAccountFeesActionDetails().size());
// } else {
// // Both weekly maintenance fee and weekly periodic fee apply to installments 1, 3, 5, ...
// Assert.assertEquals(2, customerScheduleEntity.getAccountFeesActionDetails().size());
// }
// lastAppliedDate = customerScheduleEntity.getActionDate();
// for (AccountFeesActionDetailEntity accountFeesActionDetailEntity : customerScheduleEntity
// .getAccountFeesActionDetails()) {
// if (accountFeesActionDetailEntity.getFee().getFeeName().equals("Periodic Fee")) {
// Assert.assertEquals(TestUtils.createMoney("200"), accountFeesActionDetailEntity.getFeeAmount());
// }
// }
// }
// customerAccountBO.getAccountFees();
// for (AccountFeesEntity accountFee : customerAccountBO.getAccountFees()) {
// if (accountFee.getFees().getFeeName().equals("Periodic Fee")) {
// Assert.assertEquals()
// }
// }
// if (customerAccountBO.getCustomerActivitDetails() != null) {
// CustomerActivityEntity customerActivityEntity = (CustomerActivityEntity) customerAccountBO
// .getCustomerActivitDetails().toArray()[0];
// Assert.assertEquals(periodicFee.getFeeName() + " applied", customerActivityEntity.getDescription());
// Assert.assertEquals(new Money(getCurrency(), "1000"), customerActivityEntity.getAmount());
// AccountFeesEntity accountFeesEntity = customerAccountBO.getAccountFees(periodicFee.getFeeId());
// Assert.assertEquals(FeeStatus.ACTIVE.getValue(), accountFeesEntity.getFeeStatus());
// Assert.assertEquals(DateUtils.getDateWithoutTimeStamp(lastAppliedDate.getTime()), DateUtils
// .getDateWithoutTimeStamp(accountFeesEntity.getLastAppliedDate().getTime()));
// }
// }
@Test
public void testApplyUpfrontFee() 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();
FeeBO upfrontFee = TestObjectFactory.createOneTimeAmountFee("Upfront Fee", FeeCategory.ALLCUSTOMERS, "20", FeePayment.UPFRONT);
UserContext uc = TestUtils.makeUser();
customerAccountBO.setUserContext(uc);
customerAccountBO.applyCharge(upfrontFee.getFeeId(), ((AmountFeeBO) upfrontFee).getFeeAmount().getAmountDoubleValue());
StaticHibernateUtil.flushAndClearSession();
Date lastAppliedDate = null;
Money amount = new Money(getCurrency(), "20");
for (AccountActionDateEntity accountActionDateEntity : customerAccountBO.getAccountActionDates()) {
CustomerScheduleEntity customerScheduleEntity = (CustomerScheduleEntity) accountActionDateEntity;
if (customerScheduleEntity.getInstallmentId().equals(Short.valueOf("1"))) {
Assert.assertEquals(2, customerScheduleEntity.getAccountFeesActionDetails().size());
lastAppliedDate = customerScheduleEntity.getActionDate();
}
}
if (customerAccountBO.getCustomerActivitDetails() != null) {
CustomerActivityEntity customerActivityEntity = (CustomerActivityEntity) customerAccountBO.getCustomerActivitDetails().toArray()[0];
Assert.assertEquals(upfrontFee.getFeeName() + " applied", customerActivityEntity.getDescription());
Assert.assertEquals(amount, customerActivityEntity.getAmount());
AccountFeesEntity accountFeesEntity = customerAccountBO.getAccountFees(upfrontFee.getFeeId());
Assert.assertEquals(FeeStatus.ACTIVE.getValue(), accountFeesEntity.getFeeStatus());
Assert.assertEquals(DateUtils.getDateWithoutTimeStamp(lastAppliedDate.getTime()), DateUtils.getDateWithoutTimeStamp(accountFeesEntity.getLastAppliedDate().getTime()));
}
}
use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.
the class CustomerAccountBOIntegrationTest method testApplyMiscChargeWithFirstInstallmentPaid.
@Test
public void testApplyMiscChargeWithFirstInstallmentPaid() 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();
for (AccountActionDateEntity accountActionDateEntity : customerAccountBO.getAccountActionDates()) {
CustomerScheduleEntity customerScheduleEntity = (CustomerScheduleEntity) accountActionDateEntity;
if (customerScheduleEntity.getInstallmentId().equals(Short.valueOf("1"))) {
customerScheduleEntity.setPaymentStatus(PaymentStatus.PAID);
}
}
UserContext uc = TestUtils.makeUser();
customerAccountBO.setUserContext(uc);
customerAccountBO.applyCharge(Short.valueOf("-1"), new Double("33"));
Money amount = new Money(getCurrency());
for (AccountActionDateEntity accountActionDateEntity : customerAccountBO.getAccountActionDates()) {
CustomerScheduleEntity customerScheduleEntity = (CustomerScheduleEntity) accountActionDateEntity;
if (customerScheduleEntity.getInstallmentId().equals(Short.valueOf("2"))) {
amount = customerScheduleEntity.getMiscFee();
Assert.assertEquals(new Money(getCurrency(), "33.0"), customerScheduleEntity.getMiscFee());
}
}
if (customerAccountBO.getCustomerActivitDetails() != null) {
CustomerActivityEntity customerActivityEntity = (CustomerActivityEntity) customerAccountBO.getCustomerActivitDetails().toArray()[0];
Assert.assertEquals(AccountConstants.MISC_FEES_APPLIED, customerActivityEntity.getDescription());
Assert.assertEquals(amount, customerActivityEntity.getAmount());
}
}
Aggregations