Search in sources :

Example 1 with LostItemFeeRefundService

use of org.folio.circulation.services.LostItemFeeRefundService in project mod-circulation by folio-org.

the class DeclareLostResource method declareItemLost.

private CompletableFuture<Result<Loan>> declareItemLost(DeclareItemLostRequest request, Clients clients, WebContext context) {
    final var itemRepository = new ItemRepository(clients);
    final var userRepository = new UserRepository(clients);
    final var loanRepository = new LoanRepository(clients, itemRepository, userRepository);
    final var storeLoanAndItem = new StoreLoanAndItem(loanRepository, itemRepository);
    final var lostItemFeeService = new LostItemFeeChargingService(clients, storeLoanAndItem, new LostItemFeeRefundService(clients, itemRepository, userRepository, loanRepository));
    return loanRepository.getById(request.getLoanId()).thenApply(LoanValidator::refuseWhenLoanIsClosed).thenApply(this::refuseWhenItemIsAlreadyDeclaredLost).thenCompose(declareItemLost(request, clients)).thenCompose(r -> r.after(storeLoanAndItem::updateLoanAndItemInStorage)).thenCompose(r -> r.after(loan -> lostItemFeeService.chargeLostItemFees(loan, request, context.getUserId())));
}
Also used : UserRepository(org.folio.circulation.infrastructure.storage.users.UserRepository) Clients(org.folio.circulation.support.Clients) DeclareItemLostRequest(org.folio.circulation.domain.representations.DeclareItemLostRequest) LoanRepository(org.folio.circulation.infrastructure.storage.loans.LoanRepository) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) WebContext(org.folio.circulation.support.http.server.WebContext) MappingFunctions.when(org.folio.circulation.support.results.MappingFunctions.when) Router(io.vertx.ext.web.Router) CompletableFuture(java.util.concurrent.CompletableFuture) ValidationErrorFailure.singleValidationError(org.folio.circulation.support.ValidationErrorFailure.singleValidationError) LostItemFeeChargingService(org.folio.circulation.services.LostItemFeeChargingService) RoutingContext(io.vertx.ext.web.RoutingContext) Function(java.util.function.Function) NotesRepository(org.folio.circulation.infrastructure.storage.notes.NotesRepository) LoanValidator(org.folio.circulation.domain.validation.LoanValidator) ItemRepository(org.folio.circulation.infrastructure.storage.inventory.ItemRepository) LostItemFeeRefundService(org.folio.circulation.services.LostItemFeeRefundService) NoteCreator(org.folio.circulation.domain.notes.NoteCreator) Result.succeeded(org.folio.circulation.support.results.Result.succeeded) Loan(org.folio.circulation.domain.Loan) MappingFunctions.toFixedValue(org.folio.circulation.support.results.MappingFunctions.toFixedValue) Result(org.folio.circulation.support.results.Result) Result.ofAsync(org.folio.circulation.support.results.Result.ofAsync) EventPublisher(org.folio.circulation.services.EventPublisher) StringUtils.defaultIfBlank(org.apache.commons.lang.StringUtils.defaultIfBlank) CompletionStage(java.util.concurrent.CompletionStage) StoreLoanAndItem(org.folio.circulation.StoreLoanAndItem) NoContentResponse(org.folio.circulation.support.http.server.NoContentResponse) HttpClient(io.vertx.core.http.HttpClient) ItemRepository(org.folio.circulation.infrastructure.storage.inventory.ItemRepository) StoreLoanAndItem(org.folio.circulation.StoreLoanAndItem) UserRepository(org.folio.circulation.infrastructure.storage.users.UserRepository) LostItemFeeChargingService(org.folio.circulation.services.LostItemFeeChargingService) LostItemFeeRefundService(org.folio.circulation.services.LostItemFeeRefundService) LoanValidator(org.folio.circulation.domain.validation.LoanValidator) LoanRepository(org.folio.circulation.infrastructure.storage.loans.LoanRepository)

Example 2 with LostItemFeeRefundService

use of org.folio.circulation.services.LostItemFeeRefundService in project mod-circulation by folio-org.

the class CheckInProcessAdapter method newInstance.

public static CheckInProcessAdapter newInstance(Clients clients, ItemRepository itemRepository, UserRepository userRepository, LoanRepository loanRepository, RequestRepository requestRepository, RequestQueueRepository requestQueueRepository) {
    final var itemFinder = new ItemByBarcodeInStorageFinder(itemRepository);
    final SingleOpenLoanForItemInStorageFinder singleOpenLoanFinder = new SingleOpenLoanForItemInStorageFinder(loanRepository, userRepository, true);
    final var overdueFineService = new OverdueFineService(new OverdueFinePolicyRepository(clients), itemRepository, new FeeFineOwnerRepository(clients), new FeeFineRepository(clients), ScheduledNoticesRepository.using(clients), new OverduePeriodCalculatorService(new CalendarRepository(clients), new LoanPolicyRepository(clients)), new FeeFineFacade(clients));
    return new CheckInProcessAdapter(itemFinder, singleOpenLoanFinder, new LoanCheckInService(), requestQueueRepository, new UpdateItem(itemRepository), UpdateRequestQueue.using(clients, requestRepository, requestQueueRepository), loanRepository, new ServicePointRepository(clients), userRepository, new AddressTypeRepository(clients), new LogCheckInService(clients), overdueFineService, FeeFineScheduledNoticeService.using(clients), new LostItemFeeRefundService(clients, itemRepository, userRepository, loanRepository), new EventPublisher(clients.pubSubPublishingService()));
}
Also used : FeeFineFacade(org.folio.circulation.services.FeeFineFacade) EventPublisher(org.folio.circulation.services.EventPublisher) FeeFineOwnerRepository(org.folio.circulation.infrastructure.storage.feesandfines.FeeFineOwnerRepository) CalendarRepository(org.folio.circulation.infrastructure.storage.CalendarRepository) OverdueFineService(org.folio.circulation.domain.OverdueFineService) ItemByBarcodeInStorageFinder(org.folio.circulation.storage.ItemByBarcodeInStorageFinder) LostItemFeeRefundService(org.folio.circulation.services.LostItemFeeRefundService) ServicePointRepository(org.folio.circulation.infrastructure.storage.ServicePointRepository) FeeFineRepository(org.folio.circulation.infrastructure.storage.feesandfines.FeeFineRepository) OverduePeriodCalculatorService(org.folio.circulation.domain.OverduePeriodCalculatorService) SingleOpenLoanForItemInStorageFinder(org.folio.circulation.storage.SingleOpenLoanForItemInStorageFinder) UpdateItem(org.folio.circulation.domain.UpdateItem) AddressTypeRepository(org.folio.circulation.infrastructure.storage.users.AddressTypeRepository) LoanPolicyRepository(org.folio.circulation.infrastructure.storage.loans.LoanPolicyRepository) LogCheckInService(org.folio.circulation.services.LogCheckInService) LoanCheckInService(org.folio.circulation.domain.LoanCheckInService) OverdueFinePolicyRepository(org.folio.circulation.infrastructure.storage.loans.OverdueFinePolicyRepository)

Aggregations

EventPublisher (org.folio.circulation.services.EventPublisher)2 LostItemFeeRefundService (org.folio.circulation.services.LostItemFeeRefundService)2 HttpClient (io.vertx.core.http.HttpClient)1 Router (io.vertx.ext.web.Router)1 RoutingContext (io.vertx.ext.web.RoutingContext)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 CompletableFuture.completedFuture (java.util.concurrent.CompletableFuture.completedFuture)1 CompletionStage (java.util.concurrent.CompletionStage)1 Function (java.util.function.Function)1 StringUtils.defaultIfBlank (org.apache.commons.lang.StringUtils.defaultIfBlank)1 StoreLoanAndItem (org.folio.circulation.StoreLoanAndItem)1 Loan (org.folio.circulation.domain.Loan)1 LoanCheckInService (org.folio.circulation.domain.LoanCheckInService)1 OverdueFineService (org.folio.circulation.domain.OverdueFineService)1 OverduePeriodCalculatorService (org.folio.circulation.domain.OverduePeriodCalculatorService)1 UpdateItem (org.folio.circulation.domain.UpdateItem)1 NoteCreator (org.folio.circulation.domain.notes.NoteCreator)1 DeclareItemLostRequest (org.folio.circulation.domain.representations.DeclareItemLostRequest)1 LoanValidator (org.folio.circulation.domain.validation.LoanValidator)1 CalendarRepository (org.folio.circulation.infrastructure.storage.CalendarRepository)1