use of org.folio.circulation.domain.RequestQueue in project mod-circulation by folio-org.
the class RollingLoanPolicyRenewalDueDateCalculationTests method shouldFailWhenDurationIsInvalid.
@ParameterizedTest
@ValueSource(strings = { "0", "-1" })
void shouldFailWhenDurationIsInvalid(int duration) {
final JsonObject representation = new LoanPolicyBuilder().rolling(Period.minutes(duration)).withName("Invalid Loan Policy").create();
LoanPolicy loanPolicy = LoanPolicy.from(representation);
ZonedDateTime loanDate = ZonedDateTime.of(2018, 3, 14, 11, 14, 54, 0, UTC);
Loan loan = loanFor(loanDate, loanDate, loanPolicy);
CirculationErrorHandler errorHandler = new OverridingErrorHandler(null);
renew(loan, getZonedDateTime(), new RequestQueue(Collections.emptyList()), errorHandler);
assertTrue(matchErrorReason(errorHandler, String.format("the duration \"%s\" in the loan policy is invalid", duration)));
}
use of org.folio.circulation.domain.RequestQueue in project mod-circulation by folio-org.
the class UnknownLoanPolicyProfileTests method shouldFailRenewalCalculationForNonRollingProfile.
@Test
void shouldFailRenewalCalculationForNonRollingProfile() {
LoanPolicy loanPolicy = LoanPolicy.from(new LoanPolicyBuilder().withName("Invalid Loan Policy").withLoansProfile("Unknown profile").create());
ZonedDateTime loanDate = ZonedDateTime.of(2018, 3, 14, 11, 14, 54, 0, UTC);
Loan loan = new LoanBuilder().open().withLoanDate(loanDate).asDomainObject().withLoanPolicy(loanPolicy);
CirculationErrorHandler errorHandler = new OverridingErrorHandler(null);
renew(loan, ClockUtil.getZonedDateTime(), new RequestQueue(Collections.emptyList()), errorHandler);
assertTrue(errorHandler.getErrors().keySet().stream().map(ValidationErrorFailure.class::cast).anyMatch(httpFailure -> httpFailure.hasErrorWithReason("profile \"Unknown profile\" in the loan policy is not recognised")));
}
use of org.folio.circulation.domain.RequestQueue in project mod-circulation by folio-org.
the class ChangeDueDateResource method unsetDueDateChangedByRecallIfNoOpenRecallsInQueue.
private LoanAndRelatedRecords unsetDueDateChangedByRecallIfNoOpenRecallsInQueue(LoanAndRelatedRecords loanAndRelatedRecords) {
RequestQueue queue = loanAndRelatedRecords.getRequestQueue();
Loan loan = loanAndRelatedRecords.getLoan();
log.info("Loan {} prior to flag check: {}", loan.getId(), loan.asJson().toString());
if (loan.wasDueDateChangedByRecall() && !queue.hasOpenRecalls()) {
log.info("Loan {} registers as having due date change flag set to true and no open recalls in queue.", loan.getId());
return loanAndRelatedRecords.withLoan(loan.unsetDueDateChangedByRecall());
} else {
log.info("Loan {} registers as either not having due date change flag set to true or as having open recalls in queue.", loan.getId());
return loanAndRelatedRecords;
}
}
use of org.folio.circulation.domain.RequestQueue in project mod-circulation by folio-org.
the class CheckInProcessAdapter method updateRequestQueue.
CompletableFuture<Result<RequestQueue>> updateRequestQueue(CheckInContext context) {
final RequestQueue requestQueue = context.getRequestQueue();
final Item item = context.getItem();
final String checkInServicePointId = context.getCheckInServicePointId().toString();
return requestQueueUpdate.onCheckIn(requestQueue, item, checkInServicePointId);
}
use of org.folio.circulation.domain.RequestQueue in project mod-circulation by folio-org.
the class CheckOutByBarcodeResource method calculateDefaultInitialDueDate.
private Result<LoanAndRelatedRecords> calculateDefaultInitialDueDate(LoanAndRelatedRecords loanAndRelatedRecords) {
Loan loan = loanAndRelatedRecords.getLoan();
LoanPolicy loanPolicy = loan.getLoanPolicy();
RequestQueue requestQueue = loanAndRelatedRecords.getRequestQueue();
return loanPolicy.calculateInitialDueDate(loan, requestQueue).map(loan::changeDueDate).map(loanAndRelatedRecords::withLoan);
}
Aggregations