use of org.folio.circulation.domain.policy.library.ClosedLibraryStrategyService in project mod-circulation by folio-org.
the class CheckOutByBarcodeResource method checkOut.
private CompletableFuture<Result<LoanAndRelatedRecords>> checkOut(LoanAndRelatedRecords relatedRecords, JsonObject request, Clients clients) {
ZonedDateTime loanDate = relatedRecords.getLoan().getLoanDate();
final ClosedLibraryStrategyService strategyService = ClosedLibraryStrategyService.using(clients, loanDate, false);
if (CHECKED_OUT_THROUGH_OVERRIDE.getValue().equals(relatedRecords.getLoan().getAction()) && relatedRecords.getLoan().hasDueDateChanged()) {
return completedFuture(succeeded(relatedRecords));
}
return completedFuture(succeeded(relatedRecords)).thenApply(r -> r.next(this::calculateDefaultInitialDueDate)).thenCompose(r -> r.after(strategyService::applyClosedLibraryDueDateManagement));
}
use of org.folio.circulation.domain.policy.library.ClosedLibraryStrategyService in project mod-circulation by folio-org.
the class RenewalResource method renew.
private CompletableFuture<Result<RenewalContext>> renew(RenewalContext renewalContext, Clients clients, CirculationErrorHandler errorHandler) {
if (errorHandler.hasAny(ITEM_DOES_NOT_EXIST, FAILED_TO_FIND_SINGLE_OPEN_LOAN, FAILED_TO_FETCH_USER)) {
return completedFuture(succeeded(renewalContext));
}
if (isRenewalBlockOverrideRequested) {
return renewThroughOverride(renewalContext).thenApply(r -> errorHandler.handleValidationResult(r, RENEWAL_VALIDATION_ERROR, renewalContext));
}
ZonedDateTime systemTime = ClockUtil.getZonedDateTime();
final ClosedLibraryStrategyService strategyService = ClosedLibraryStrategyService.using(clients, systemTime, true);
return regularRenew(renewalContext, errorHandler, systemTime).after(strategyService::applyClosedLibraryDueDateManagement);
}
Aggregations