Search in sources :

Example 6 with FixedDueDateSchedule

use of api.support.builders.FixedDueDateSchedule in project mod-circulation by folio-org.

the class FixedLoanPolicyCheckOutDueDateCalculationTests method shouldUseMiddleScheduleAvailableWhenLoanDateFits.

@Test
void shouldUseMiddleScheduleAvailableWhenLoanDateFits() {
    final FixedDueDateSchedule expectedSchedule = FixedDueDateSchedule.wholeMonth(2018, 2);
    LoanPolicy loanPolicy = LoanPolicy.from(new LoanPolicyBuilder().fixed(UUID.randomUUID()).create()).withDueDateSchedules(new FixedDueDateSchedulesBuilder().addSchedule(FixedDueDateSchedule.wholeMonth(2018, 1)).addSchedule(expectedSchedule).addSchedule(FixedDueDateSchedule.wholeMonth(2018, 3)).create());
    ZonedDateTime loanDate = ZonedDateTime.of(2018, 2, 27, 16, 23, 43, 0, UTC);
    Loan loan = loanFor(loanDate);
    final Result<ZonedDateTime> calculationResult = loanPolicy.calculateInitialDueDate(loan, null);
    assertThat(calculationResult.value(), is(expectedSchedule.due));
}
Also used : FixedDueDateSchedulesBuilder(api.support.builders.FixedDueDateSchedulesBuilder) Loan(org.folio.circulation.domain.Loan) ZonedDateTime(java.time.ZonedDateTime) LoanPolicyBuilder(api.support.builders.LoanPolicyBuilder) FixedDueDateSchedule(api.support.builders.FixedDueDateSchedule) Test(org.junit.jupiter.api.Test)

Example 7 with FixedDueDateSchedule

use of api.support.builders.FixedDueDateSchedule in project mod-circulation by folio-org.

the class FixedLoanPolicyCheckOutDueDateCalculationTests method shouldUseLastScheduleAvailableWhenLoanDateFits.

@Test
void shouldUseLastScheduleAvailableWhenLoanDateFits() {
    final FixedDueDateSchedule expectedSchedule = FixedDueDateSchedule.wholeMonth(2018, 3);
    LoanPolicy loanPolicy = LoanPolicy.from(new LoanPolicyBuilder().fixed(UUID.randomUUID()).create()).withDueDateSchedules(new FixedDueDateSchedulesBuilder().addSchedule(FixedDueDateSchedule.wholeMonth(2018, 1)).addSchedule(FixedDueDateSchedule.wholeMonth(2018, 2)).addSchedule(expectedSchedule).create());
    ZonedDateTime loanDate = ZonedDateTime.of(2018, 3, 12, 7, 15, 23, 0, UTC);
    Loan loan = loanFor(loanDate);
    final Result<ZonedDateTime> calculationResult = loanPolicy.calculateInitialDueDate(loan, null);
    assertThat(calculationResult.value(), is(expectedSchedule.due));
}
Also used : FixedDueDateSchedulesBuilder(api.support.builders.FixedDueDateSchedulesBuilder) Loan(org.folio.circulation.domain.Loan) ZonedDateTime(java.time.ZonedDateTime) LoanPolicyBuilder(api.support.builders.LoanPolicyBuilder) FixedDueDateSchedule(api.support.builders.FixedDueDateSchedule) Test(org.junit.jupiter.api.Test)

Example 8 with FixedDueDateSchedule

use of api.support.builders.FixedDueDateSchedule in project mod-circulation by folio-org.

the class FixedLoanPolicyRenewalDueDateCalculationTests method shouldUseAlternateScheduleWhenAvailable.

@Test
void shouldUseAlternateScheduleWhenAvailable() {
    final FixedDueDateSchedule expectedSchedule = FixedDueDateSchedule.wholeYear(2018);
    LoanPolicy loanPolicy = LoanPolicy.from(new LoanPolicyBuilder().fixed(UUID.randomUUID()).renewWith(UUID.randomUUID()).create()).withDueDateSchedules(new FixedDueDateSchedulesBuilder().addSchedule(FixedDueDateSchedule.wholeMonth(2018, 1)).addSchedule(FixedDueDateSchedule.wholeMonth(2018, 2)).create()).withAlternateRenewalSchedules(new FixedDueDateSchedulesBuilder().addSchedule(expectedSchedule).create());
    Loan loan = existingLoan(loanPolicy);
    ZonedDateTime renewalDate = ZonedDateTime.of(2018, 2, 5, 14, 22, 32, 0, UTC);
    Result<Loan> result = renew(loan, renewalDate, new RequestQueue(Collections.emptyList()), new OverridingErrorHandler(null));
    assertThat(result.value().getDueDate(), is(expectedSchedule.due));
}
Also used : FixedDueDateSchedulesBuilder(api.support.builders.FixedDueDateSchedulesBuilder) Loan(org.folio.circulation.domain.Loan) ZonedDateTime(java.time.ZonedDateTime) RequestQueue(org.folio.circulation.domain.RequestQueue) OverridingErrorHandler(org.folio.circulation.resources.handlers.error.OverridingErrorHandler) LoanPolicyBuilder(api.support.builders.LoanPolicyBuilder) FixedDueDateSchedule(api.support.builders.FixedDueDateSchedule) Test(org.junit.jupiter.api.Test)

Example 9 with FixedDueDateSchedule

use of api.support.builders.FixedDueDateSchedule in project mod-circulation by folio-org.

the class FixedLoanPolicyRenewalDueDateCalculationTests method shouldUseFirstScheduleAvailableWhenLoanDateFits.

@Test
void shouldUseFirstScheduleAvailableWhenLoanDateFits() {
    final FixedDueDateSchedule expectedSchedule = FixedDueDateSchedule.wholeMonth(2018, 2);
    LoanPolicy loanPolicy = LoanPolicy.from(new LoanPolicyBuilder().fixed(UUID.randomUUID()).create()).withDueDateSchedules(new FixedDueDateSchedulesBuilder().addSchedule(expectedSchedule).addSchedule(FixedDueDateSchedule.wholeMonth(2018, 3)).addSchedule(FixedDueDateSchedule.wholeMonth(2018, 4)).create());
    Loan loan = new LoanBuilder().open().withLoanDate(ZonedDateTime.of(2018, 1, 20, 13, 45, 21, 0, UTC)).withDueDate(ZonedDateTime.of(2018, 1, 31, 23, 59, 59, 0, UTC)).asDomainObject().withLoanPolicy(loanPolicy);
    ZonedDateTime renewalDate = ZonedDateTime.of(2018, 2, 8, 11, 14, 54, 0, UTC);
    Result<Loan> result = renew(loan, renewalDate, new RequestQueue(Collections.emptyList()), new OverridingErrorHandler(null));
    assertThat(result.value().getDueDate(), is(expectedSchedule.due));
}
Also used : LoanBuilder(api.support.builders.LoanBuilder) FixedDueDateSchedulesBuilder(api.support.builders.FixedDueDateSchedulesBuilder) Loan(org.folio.circulation.domain.Loan) ZonedDateTime(java.time.ZonedDateTime) RequestQueue(org.folio.circulation.domain.RequestQueue) OverridingErrorHandler(org.folio.circulation.resources.handlers.error.OverridingErrorHandler) LoanPolicyBuilder(api.support.builders.LoanPolicyBuilder) FixedDueDateSchedule(api.support.builders.FixedDueDateSchedule) Test(org.junit.jupiter.api.Test)

Example 10 with FixedDueDateSchedule

use of api.support.builders.FixedDueDateSchedule in project mod-circulation by folio-org.

the class FixedLoanPolicyRenewalDueDateCalculationTests method shouldUseLastScheduleAvailableWhenLoanDateFits.

@Test
void shouldUseLastScheduleAvailableWhenLoanDateFits() {
    final FixedDueDateSchedule expectedSchedule = FixedDueDateSchedule.wholeMonth(2018, 3);
    LoanPolicy loanPolicy = LoanPolicy.from(new LoanPolicyBuilder().fixed(UUID.randomUUID()).create()).withDueDateSchedules(new FixedDueDateSchedulesBuilder().addSchedule(FixedDueDateSchedule.wholeMonth(2018, 1)).addSchedule(FixedDueDateSchedule.wholeMonth(2018, 2)).addSchedule(expectedSchedule).create());
    Loan loan = existingLoan(loanPolicy);
    ZonedDateTime renewalDate = ZonedDateTime.of(2018, 3, 12, 7, 15, 23, 0, UTC);
    Result<Loan> result = renew(loan, renewalDate, new RequestQueue(Collections.emptyList()), new OverridingErrorHandler(null));
    assertThat(result.value().getDueDate(), is(expectedSchedule.due));
}
Also used : FixedDueDateSchedulesBuilder(api.support.builders.FixedDueDateSchedulesBuilder) Loan(org.folio.circulation.domain.Loan) ZonedDateTime(java.time.ZonedDateTime) RequestQueue(org.folio.circulation.domain.RequestQueue) OverridingErrorHandler(org.folio.circulation.resources.handlers.error.OverridingErrorHandler) LoanPolicyBuilder(api.support.builders.LoanPolicyBuilder) FixedDueDateSchedule(api.support.builders.FixedDueDateSchedule) Test(org.junit.jupiter.api.Test)

Aggregations

FixedDueDateSchedule (api.support.builders.FixedDueDateSchedule)14 FixedDueDateSchedulesBuilder (api.support.builders.FixedDueDateSchedulesBuilder)14 LoanPolicyBuilder (api.support.builders.LoanPolicyBuilder)14 ZonedDateTime (java.time.ZonedDateTime)14 Test (org.junit.jupiter.api.Test)14 Loan (org.folio.circulation.domain.Loan)9 IndividualResource (api.support.http.IndividualResource)5 JsonObject (io.vertx.core.json.JsonObject)5 ClockUtil.getZonedDateTime (org.folio.circulation.support.utils.ClockUtil.getZonedDateTime)5 RequestBuilder (api.support.builders.RequestBuilder)4 ItemResource (api.support.http.ItemResource)4 RequestQueue (org.folio.circulation.domain.RequestQueue)4 OverridingErrorHandler (org.folio.circulation.resources.handlers.error.OverridingErrorHandler)4 Response (org.folio.circulation.support.http.client.Response)2 LoanBuilder (api.support.builders.LoanBuilder)1 ZoneOffset (java.time.ZoneOffset)1 UUID (java.util.UUID)1