use of api.support.builders.FixedDueDateSchedule in project mod-circulation by folio-org.
the class RequestsAPILoanRenewalTests method allowRenewalWithHoldsWhenProfileIsFixedUseLoanSchedule.
@Test
void allowRenewalWithHoldsWhenProfileIsFixedUseLoanSchedule() {
final ZonedDateTime from = getZonedDateTime().minusMonths(3);
final ZonedDateTime to = getZonedDateTime().plusMonths(3);
final ZonedDateTime dueDate = to.plusDays(15);
final ItemResource smallAngryPlanet = itemsFixture.basedUponSmallAngryPlanet();
final IndividualResource rebecca = usersFixture.rebecca();
checkOutFixture.checkOutByBarcode(smallAngryPlanet, rebecca);
IndividualResource schedule = loanPoliciesFixture.createSchedule(new FixedDueDateSchedulesBuilder().withId(UUID.randomUUID()).withName("Can circulate schedule").withDescription("descr").addSchedule(new FixedDueDateSchedule(from, to, dueDate)));
JsonObject holds = new JsonObject().put("renewItemsWithRequest", true);
LoanPolicyBuilder loanPolicy = new LoanPolicyBuilder().fixed(schedule.getId()).withName("Fixed with holds").withDescription("Fixed policy with holds").withHolds(holds);
useWithActiveNotice(loanPolicy);
requestsFixture.place(new RequestBuilder().hold().forItem(smallAngryPlanet).withPickupServicePointId(servicePointsFixture.cd1().getId()).by(usersFixture.charlotte()));
IndividualResource response = loansFixture.renewLoanById(smallAngryPlanet, rebecca);
assertThat(response.getJson().getString("action"), is("renewed"));
assertThat(response.getJson().getString("dueDate"), is(withinSecondsAfter(15, dueDate)));
}
use of api.support.builders.FixedDueDateSchedule in project mod-circulation by folio-org.
the class RequestsAPILoanRenewalTests method validationErrorWhenRenewalPeriodSpecifiedForFixedPolicy.
@Test
void validationErrorWhenRenewalPeriodSpecifiedForFixedPolicy() {
final ZonedDateTime from = getZonedDateTime().minusMonths(3);
final ZonedDateTime to = getZonedDateTime().plusMonths(3);
final ZonedDateTime dueDate = to.plusDays(15);
final ItemResource smallAngryPlanet = itemsFixture.basedUponSmallAngryPlanet();
final IndividualResource rebecca = usersFixture.rebecca();
checkOutFixture.checkOutByBarcode(smallAngryPlanet, rebecca);
IndividualResource schedule = loanPoliciesFixture.createSchedule(new FixedDueDateSchedulesBuilder().withId(UUID.randomUUID()).withName("Can circulate schedule").withDescription("descr").addSchedule(new FixedDueDateSchedule(from, to, dueDate)));
JsonObject holds = new JsonObject().put("renewItemsWithRequest", true);
LoanPolicyBuilder loanPolicy = new LoanPolicyBuilder().fixed(schedule.getId()).withName("Fixed with holds").withDescription("Fixed policy with holds").renewWith(Period.weeks(2)).withHolds(holds);
useWithActiveNotice(loanPolicy);
requestsFixture.place(new RequestBuilder().hold().forItem(smallAngryPlanet).withPickupServicePointId(servicePointsFixture.cd1().getId()).by(usersFixture.charlotte()));
Response response = loansFixture.attemptRenewal(422, smallAngryPlanet, rebecca);
assertThat(response.getJson(), hasErrorWith(hasMessage("Item's loan policy has fixed profile but renewal period is specified")));
}
use of api.support.builders.FixedDueDateSchedule in project mod-circulation by folio-org.
the class RequestsAPILoanRenewalTests method allowRenewalWithHoldsWhenProfileIsFixedUseRenewalSchedule.
@Test
void allowRenewalWithHoldsWhenProfileIsFixedUseRenewalSchedule() {
final ZonedDateTime from = getZonedDateTime().minusMonths(3);
final ZonedDateTime to = getZonedDateTime().plusMonths(3);
final ZonedDateTime dueDate = to.plusDays(15);
final ItemResource smallAngryPlanet = itemsFixture.basedUponSmallAngryPlanet();
final IndividualResource rebecca = usersFixture.rebecca();
checkOutFixture.checkOutByBarcode(smallAngryPlanet, rebecca);
IndividualResource schedule = loanPoliciesFixture.createSchedule(new FixedDueDateSchedulesBuilder().withId(UUID.randomUUID()).withName("Can circulate schedule").withDescription("descr").addSchedule(new FixedDueDateSchedule(from, to, dueDate)));
JsonObject holds = new JsonObject().put("renewItemsWithRequest", true);
LoanPolicyBuilder loanPolicy = new LoanPolicyBuilder().fixed(loanPoliciesFixture.createExampleFixedDueDateSchedule().getId()).renewWith(schedule.getId()).withName("Fixed with holds").withDescription("Fixed policy with holds").withHolds(holds);
useWithActiveNotice(loanPolicy);
requestsFixture.place(new RequestBuilder().hold().forItem(smallAngryPlanet).withPickupServicePointId(servicePointsFixture.cd1().getId()).by(usersFixture.charlotte()));
IndividualResource response = loansFixture.renewLoanById(smallAngryPlanet, rebecca);
assertThat(response.getJson().getString("action"), is("renewed"));
assertThat(response.getJson().getString("dueDate"), is(withinSecondsAfter(15, dueDate)));
}
use of api.support.builders.FixedDueDateSchedule in project mod-circulation by folio-org.
the class RenewalAPITests method canRenewWhenSystemDateFallsWithinSecondLimitingDueDateSchedule.
@Test
void canRenewWhenSystemDateFallsWithinSecondLimitingDueDateSchedule() {
ZonedDateTime firstScheduleStart = atStartOfDay(getZonedDateTime().minusDays(10).withZoneSameLocal(UTC));
ZonedDateTime firstScheduleEndAndDueDate = atStartOfDay(getZonedDateTime().minusDays(3).withZoneSameLocal(UTC));
ZonedDateTime secondScheduleStart = atStartOfDay(getZonedDateTime().minusDays(2).withZoneSameLocal(UTC));
ZonedDateTime secondScheduleEndAndDueDate = atStartOfDay(getZonedDateTime().plusDays(5).withZoneSameLocal(UTC));
FixedDueDateSchedulesBuilder fixedDueDateSchedules = new FixedDueDateSchedulesBuilder().withName("Fixed Due Date Schedule").addSchedule(new FixedDueDateSchedule(firstScheduleStart, firstScheduleEndAndDueDate, firstScheduleEndAndDueDate)).addSchedule(new FixedDueDateSchedule(secondScheduleStart, secondScheduleEndAndDueDate, secondScheduleEndAndDueDate));
UUID fixedDueDateSchedulesId = loanPoliciesFixture.createSchedule(fixedDueDateSchedules).getId();
LoanPolicyBuilder currentDueDateRollingPolicy = new LoanPolicyBuilder().withName("System Date Rolling Policy").rolling(Period.days(56)).limitedBySchedule(fixedDueDateSchedulesId).renewWith(Period.days(7)).renewFromSystemDate();
loanPoliciesFixture.create(currentDueDateRollingPolicy).getId();
use(currentDueDateRollingPolicy);
IndividualResource smallAngryPlanet = itemsFixture.basedUponSmallAngryPlanet();
IndividualResource jessica = usersFixture.jessica();
IndividualResource loan = checkOutFixture.checkOutByBarcode(smallAngryPlanet, jessica, getZonedDateTime().minusDays(5).withZoneSameLocal(UTC));
UUID loanId = loan.getId();
JsonObject renewedLoan = renew(smallAngryPlanet, jessica).getJson();
assertThat(renewedLoan.getString("id"), is(loanId.toString()));
assertThat("due date should be as per second fixed schedule", renewedLoan.getString("dueDate"), isEquivalentTo(secondScheduleEndAndDueDate));
}
Aggregations