Search in sources :

Example 81 with LocalDate

use of org.joda.time.LocalDate in project head by mifos.

the class SavingsPostInterestTest method whenPostingInterestASingleAccountPaymentIsMade.

@Test
public void whenPostingInterestASingleAccountPaymentIsMade() {
    // setup
    InterestScheduledEvent postingSchedule = new MonthlyOnLastDayOfMonthInterestScheduledEvent(1);
    Money interestToBePosted = TestUtils.createMoney("100");
    DateTime activationDate = new DateTime().withDate(2010, 7, 20);
    DateTime nextInterestPostingDate = new DateTime().withDate(2010, 7, 31);
    savingsAccount = new SavingsAccountBuilder().active().withActivationDate(activationDate).withNextInterestPostingDateOf(nextInterestPostingDate).withSavingsProduct(savingsProduct).withCustomer(client).build();
    // pre verification
    assertTrue(savingsAccount.getAccountPayments().isEmpty());
    InterestCalculationPeriodResult calculationPeriod = new InterestCalculationPeriodResultBuilder().withCalculatedInterest("100").build();
    InterestPostingPeriodResult interestPostingPeriodResult = new InterestPostingPeriodResultBuilder().from(nextInterestPostingDate.toLocalDate()).to(nextInterestPostingDate.toLocalDate()).with(calculationPeriod).build();
    PersonnelBO createdBy = new PersonnelBuilder().build();
    // exercise
    savingsAccount.postInterest(postingSchedule, interestPostingPeriodResult, createdBy);
    // verification
    assertFalse(savingsAccount.getAccountPayments().isEmpty());
    AccountPaymentEntity interestPostingPayment = savingsAccount.getAccountPayments().get(0);
    assertThat(interestPostingPayment.getAccount(), is((AccountBO) savingsAccount));
    assertThat(interestPostingPayment.getAmount(), is(interestToBePosted));
    assertThat(interestPostingPayment.getPaymentType().getId(), is(SavingsConstants.DEFAULT_PAYMENT_TYPE));
    assertThat(new LocalDate(interestPostingPayment.getPaymentDate()), is(nextInterestPostingDate.toLocalDate()));
}
Also used : InterestPostingPeriodResult(org.mifos.accounts.savings.interest.InterestPostingPeriodResult) PersonnelBuilder(org.mifos.domain.builders.PersonnelBuilder) InterestCalculationPeriodResult(org.mifos.accounts.savings.interest.InterestCalculationPeriodResult) InterestPostingPeriodResultBuilder(org.mifos.accounts.savings.interest.InterestPostingPeriodResultBuilder) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) Money(org.mifos.framework.util.helpers.Money) AccountBO(org.mifos.accounts.business.AccountBO) MonthlyOnLastDayOfMonthInterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent) MonthlyOnLastDayOfMonthInterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent) InterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) InterestCalculationPeriodResultBuilder(org.mifos.accounts.savings.interest.InterestCalculationPeriodResultBuilder) Test(org.junit.Test)

Example 82 with LocalDate

use of org.joda.time.LocalDate in project head by mifos.

the class SavingsPostInterestTest method whenPostingInterestNextInterestPostingDateIsPopulatedWithNextPostingDate.

@Test
public void whenPostingInterestNextInterestPostingDateIsPopulatedWithNextPostingDate() {
    // setup
    InterestScheduledEvent postingSchedule = new MonthlyOnLastDayOfMonthInterestScheduledEvent(1);
    DateTime activationDate = new DateTime().withDate(2010, 7, 20);
    DateTime nextInterestPostingDate = new DateTime().withDate(2010, 7, 31);
    savingsAccount = new SavingsAccountBuilder().active().withActivationDate(activationDate).withNextInterestPostingDateOf(nextInterestPostingDate).withSavingsProduct(savingsProduct).withCustomer(client).build();
    // pre verification
    assertThat(new LocalDate(savingsAccount.getNextIntPostDate()), is(nextInterestPostingDate.toLocalDate()));
    InterestCalculationPeriodResult calculationPeriod = new InterestCalculationPeriodResultBuilder().withCalculatedInterest("100").build();
    InterestPostingPeriodResult interestPostingPeriodResult = new InterestPostingPeriodResultBuilder().from(nextInterestPostingDate.toLocalDate()).to(nextInterestPostingDate.toLocalDate()).with(calculationPeriod).build();
    PersonnelBO createdBy = new PersonnelBuilder().build();
    // exercise
    savingsAccount.postInterest(postingSchedule, interestPostingPeriodResult, createdBy);
    // verification
    assertThat(new LocalDate(savingsAccount.getNextIntPostDate()), is(endOfMonthAfter(nextInterestPostingDate)));
}
Also used : InterestPostingPeriodResult(org.mifos.accounts.savings.interest.InterestPostingPeriodResult) PersonnelBuilder(org.mifos.domain.builders.PersonnelBuilder) MonthlyOnLastDayOfMonthInterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent) InterestCalculationPeriodResult(org.mifos.accounts.savings.interest.InterestCalculationPeriodResult) MonthlyOnLastDayOfMonthInterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent) InterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) InterestPostingPeriodResultBuilder(org.mifos.accounts.savings.interest.InterestPostingPeriodResultBuilder) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) InterestCalculationPeriodResultBuilder(org.mifos.accounts.savings.interest.InterestCalculationPeriodResultBuilder) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 83 with LocalDate

use of org.joda.time.LocalDate in project head by mifos.

the class SavingsScheduleIntegrationTest method createWeeklySavingScheduleSecondInstallmentFallsInNextMeetingHoliday.

@Ignore
@Test
public void createWeeklySavingScheduleSecondInstallmentFallsInNextMeetingHoliday() throws Exception {
    buildAndPersistHoliday(expectedFirstDepositDate.plusWeeks(1), expectedFirstDepositDate.plusWeeks(1), RepaymentRuleTypes.NEXT_MEETING_OR_REPAYMENT);
    createClientSavingsAccount();
    short installmentId = 1;
    DateTime installmentDate = expectedFirstDepositDate;
    for (AccountActionDateEntity accountActionDate : getActionDatesSortedByDate(savingsAccount)) {
        SavingsScheduleEntity scheduleEntity = (SavingsScheduleEntity) accountActionDate;
        assertThat(scheduleEntity.getInstallmentId(), is(installmentId));
        if (installmentId == 2) {
            // only second installment pushed out one week.
            assertThat(new LocalDate(scheduleEntity.getActionDate()), is(new LocalDate(installmentDate.plusWeeks(1).toDate())));
        } else {
            assertThat(new LocalDate(scheduleEntity.getActionDate()), is(new LocalDate(installmentDate.toDate())));
        }
        assertThat(scheduleEntity.getDeposit().getAmountDoubleValue(), is(13.0));
        installmentId++;
        installmentDate = installmentDate.plusWeeks(1);
    }
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 84 with LocalDate

use of org.joda.time.LocalDate in project head by mifos.

the class SavingsScheduleIntegrationTest method createWeeklySavingScheduleSecondInstallmentFallsInNextWorkingDayHoliday.

@Ignore
@Test
public void createWeeklySavingScheduleSecondInstallmentFallsInNextWorkingDayHoliday() throws Exception {
    // One-day holiday on the second deposit date, Monday
    buildAndPersistHoliday(expectedFirstDepositDate.plusWeeks(1), expectedFirstDepositDate.plusWeeks(1), RepaymentRuleTypes.NEXT_WORKING_DAY);
    createClientSavingsAccount();
    short installmentId = 1;
    DateTime installmentDate = expectedFirstDepositDate;
    for (AccountActionDateEntity accountActionDate : getActionDatesSortedByDate(savingsAccount)) {
        SavingsScheduleEntity scheduleEntity = (SavingsScheduleEntity) accountActionDate;
        assertThat(scheduleEntity.getInstallmentId(), is(installmentId));
        if (installmentId == 2) {
            assertThat(new LocalDate(scheduleEntity.getActionDate()), //Tuesday after holiday
            is(new LocalDate(installmentDate.plusDays(1).toDate())));
        } else {
            assertThat(new LocalDate(scheduleEntity.getActionDate()), is(new LocalDate(installmentDate.toDate())));
        }
        assertThat(scheduleEntity.getDeposit().getAmountDoubleValue(), is(13.0));
        installmentId++;
        installmentDate = installmentDate.plusWeeks(1);
    }
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 85 with LocalDate

use of org.joda.time.LocalDate in project head by mifos.

the class SavingsScheduleIntegrationTest method createWeeklySavingScheduleSecondInstallmentFallsInMoratorium.

@Ignore
@Test
public void createWeeklySavingScheduleSecondInstallmentFallsInMoratorium() throws Exception {
    buildAndPersistHoliday(expectedFirstDepositDate.plusWeeks(1), expectedFirstDepositDate.plusWeeks(1), RepaymentRuleTypes.REPAYMENT_MORATORIUM);
    createClientSavingsAccount();
    short installmentId = 1;
    DateTime installmentDate = expectedFirstDepositDate;
    for (AccountActionDateEntity accountActionDate : getActionDatesSortedByDate(savingsAccount)) {
        SavingsScheduleEntity scheduleEntity = (SavingsScheduleEntity) accountActionDate;
        assertThat(scheduleEntity.getInstallmentId(), is(installmentId));
        if (installmentId < 2) {
            assertThat(new LocalDate(scheduleEntity.getActionDate()), is(new LocalDate(installmentDate.toDate())));
        } else {
            // second and following dates pushed out one week.
            assertThat(new LocalDate(scheduleEntity.getActionDate()), is(new LocalDate(installmentDate.plusWeeks(1).toDate())));
        }
        assertThat(scheduleEntity.getDeposit().getAmountDoubleValue(), is(13.0));
        installmentId++;
        installmentDate = installmentDate.plusWeeks(1);
    }
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

LocalDate (org.joda.time.LocalDate)1094 Test (org.testng.annotations.Test)553 BigDecimal (java.math.BigDecimal)401 DateTime (org.joda.time.DateTime)231 ArrayList (java.util.ArrayList)217 Test (org.junit.Test)187 Invoice (org.killbill.billing.invoice.api.Invoice)165 UUID (java.util.UUID)148 Account (org.killbill.billing.account.api.Account)139 InvoiceItem (org.killbill.billing.invoice.api.InvoiceItem)118 DefaultEntitlement (org.killbill.billing.entitlement.api.DefaultEntitlement)104 FixedPriceInvoiceItem (org.killbill.billing.invoice.model.FixedPriceInvoiceItem)101 RecurringInvoiceItem (org.killbill.billing.invoice.model.RecurringInvoiceItem)95 ExpectedInvoiceItemCheck (org.killbill.billing.beatrix.util.InvoiceChecker.ExpectedInvoiceItemCheck)85 DefaultInvoice (org.killbill.billing.invoice.model.DefaultInvoice)82 RepairAdjInvoiceItem (org.killbill.billing.invoice.model.RepairAdjInvoiceItem)71 ItemAdjInvoiceItem (org.killbill.billing.invoice.model.ItemAdjInvoiceItem)69 PlanPhaseSpecifier (org.killbill.billing.catalog.api.PlanPhaseSpecifier)63 Date (java.util.Date)57 MockPlan (org.killbill.billing.catalog.MockPlan)52