use of org.mifos.accounts.savings.business.SavingsScheduleEntity in project head by mifos.
the class SavingsBOIntegrationTest method testGetDetailsOfInstallmentsInArrearsWithPaymentDone.
@Test
public void testGetDetailsOfInstallmentsInArrearsWithPaymentDone() throws Exception {
savings = getSavingsAccount();
AccountActionDateEntity accountActionDateEntity = savings.getAccountActionDate(Short.valueOf("1"));
((SavingsScheduleEntity) accountActionDateEntity).setActionDate(offSetCurrentDate(1));
accountActionDateEntity.setPaymentStatus(PaymentStatus.PAID);
savings = (SavingsBO) saveAndFetch(savings);
Assert.assertEquals(savings.getDetailsOfInstallmentsInArrears().size(), 0);
}
use of org.mifos.accounts.savings.business.SavingsScheduleEntity in project head by mifos.
the class SavingsBOIntegrationTest method testIsTrxnDateValid_AfterFirstMeeting.
@Test
public void testIsTrxnDateValid_AfterFirstMeeting() throws Exception {
createInitialObjects();
savingsOffering = TestObjectFactory.createSavingsProduct("dfasdasd1", "sad1", RecommendedAmountUnit.COMPLETE_GROUP);
savings = helper.createSavingsAccount(savingsOffering, group, AccountState.SAVINGS_ACTIVE, userContext);
savings = TestObjectFactory.getObject(SavingsBO.class, savings.getAccountId());
int i = -5;
for (AccountActionDateEntity actionDate : savings.getAccountActionDates()) {
((SavingsScheduleEntity) actionDate).setActionDate(offSetCurrentDate(i--));
}
savings.update();
savings = TestObjectFactory.getObject(SavingsBO.class, savings.getAccountId());
java.util.Date trxnDate = offSetCurrentDate(-5);
Date meetingDate = new CustomerPersistence().getLastMeetingDateForCustomer(savings.getCustomer().getCustomerId());
boolean repaymentIndependentOfMeetingEnabled = new ConfigurationPersistence().isRepaymentIndepOfMeetingEnabled();
if (AccountingRules.isBackDatedTxnAllowed()) {
Assert.assertTrue(savings.isTrxnDateValid(trxnDate, meetingDate, repaymentIndependentOfMeetingEnabled));
} else {
Assert.assertFalse(savings.isTrxnDateValid(trxnDate, meetingDate, repaymentIndependentOfMeetingEnabled));
}
group = TestObjectFactory.getGroup(group.getCustomerId());
}
use of org.mifos.accounts.savings.business.SavingsScheduleEntity in project head by mifos.
the class SavingsPaymentStrategyForMandatorySavingsAccountsTest method whenDepositAmountIsInExcessOfTotalDepositDueTheExcessAmountIsReturnedInRemainingAmount.
@Test
public void whenDepositAmountIsInExcessOfTotalDepositDueTheExcessAmountIsReturnedInRemainingAmount() {
// setup
final Money balanceBeforeDeposit = new Money(TestUtils.RUPEE, "0.0");
final Money fullDepositAmount = new Money(TestUtils.RUPEE, "80.0");
final Date dateOfDeposit = new DateTime().toDate();
final SavingsScheduleEntity unpaidSaving1 = new SavingsScheduleBuilder().withInstallmentNumber(1).withAccount(savingsAccount).withCustomer(payingCustomer).withDepositDue(new Money(TestUtils.RUPEE, "10.0")).build();
final SavingsScheduleEntity unpaidSaving2 = new SavingsScheduleBuilder().withInstallmentNumber(2).withAccount(savingsAccount).withCustomer(payingCustomer).withDepositDue(new Money(TestUtils.RUPEE, "50.0")).build();
final List<SavingsScheduleEntity> unpaidDepositsForPayingCustomer = Arrays.asList(unpaidSaving1, unpaidSaving2);
// stubbing
when(accountPayment.getAmount()).thenReturn(fullDepositAmount);
when(accountPayment.getPaymentDate()).thenReturn(dateOfDeposit);
// exercise test
final Money remainingAmount = paymentStrategy.makeScheduledPayments(accountPayment, unpaidDepositsForPayingCustomer, payingCustomer, SavingsType.MANDATORY, balanceBeforeDeposit);
// verification
assertThat(remainingAmount, is(new Money(TestUtils.RUPEE, "20.0")));
}
use of org.mifos.accounts.savings.business.SavingsScheduleEntity in project head by mifos.
the class SavingsPaymentStrategyForVoluntarySavingsAccountsTest method whenNoUnpaidScheduledInstallmentsExistTheFullAmountOfTheDepositIsReturned.
@Test
public void whenNoUnpaidScheduledInstallmentsExistTheFullAmountOfTheDepositIsReturned() {
// setup
final Money balanceBeforeDeposit = new Money(TestUtils.RUPEE, "0.0");
final Money fullDepositAmount = new Money(TestUtils.RUPEE, "100.0");
final Date dateOfDeposit = new DateTime().toDate();
final List<SavingsScheduleEntity> unpaidDepositsForPayingCustomer = Arrays.asList();
// stubbing
when(accountPayment.getAmount()).thenReturn(fullDepositAmount);
when(accountPayment.getPaymentDate()).thenReturn(dateOfDeposit);
// exercise test
final Money remainingAmount = paymentStrategy.makeScheduledPayments(accountPayment, unpaidDepositsForPayingCustomer, payingCustomer, SavingsType.VOLUNTARY, balanceBeforeDeposit);
// verification
assertThat(remainingAmount, is(fullDepositAmount));
}
use of org.mifos.accounts.savings.business.SavingsScheduleEntity in project head by mifos.
the class SavingsPaymentStrategyForVoluntarySavingsAccountsTest method whenUnpaidScheduledInstallmentsExistAllAreMarkedAsPaid.
@Test
public void whenUnpaidScheduledInstallmentsExistAllAreMarkedAsPaid() {
// setup
final Money balanceBeforeDeposit = new Money(TestUtils.RUPEE, "0.0");
final Money fullDepositAmount = new Money(TestUtils.RUPEE, "100.0");
final Date dateOfDeposit = new DateTime().toDate();
final SavingsScheduleEntity unpaidSaving1 = new SavingsScheduleBuilder().withInstallmentNumber(1).withAccount(savingsAccount).withCustomer(payingCustomer).build();
final SavingsScheduleEntity unpaidSaving2 = new SavingsScheduleBuilder().withInstallmentNumber(2).withAccount(savingsAccount).withCustomer(payingCustomer).build();
final List<SavingsScheduleEntity> unpaidDepositsForPayingCustomer = Arrays.asList(unpaidSaving1, unpaidSaving2);
// stubbing
when(accountPayment.getAmount()).thenReturn(fullDepositAmount);
when(accountPayment.getPaymentDate()).thenReturn(dateOfDeposit);
// exercise test
paymentStrategy.makeScheduledPayments(accountPayment, unpaidDepositsForPayingCustomer, payingCustomer, SavingsType.VOLUNTARY, balanceBeforeDeposit);
// verification
assertThat(unpaidSaving1.isPaid(), is(true));
assertThat(unpaidSaving2.isPaid(), is(true));
}
Aggregations