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));
}
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));
}
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));
}
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));
}
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));
}
Aggregations