From 5592ad8a9982d62521f1b0fd5c291075288859fd Mon Sep 17 00:00:00 2001 From: Roman_Barannyk Date: Mon, 8 Apr 2024 13:36:59 +0300 Subject: [PATCH] CIRC-2050 set returnDate for lost loans --- src/main/java/org/folio/circulation/domain/Loan.java | 3 ++- .../circulation/services/CloseLoanWithLostItemService.java | 3 ++- .../folio/circulation/services/LostItemFeeChargingService.java | 3 ++- .../agedtolost/ChargeLostFeesWhenAgedToLostService.java | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/folio/circulation/domain/Loan.java b/src/main/java/org/folio/circulation/domain/Loan.java index 3cfe4827b3..49d4b45770 100644 --- a/src/main/java/org/folio/circulation/domain/Loan.java +++ b/src/main/java/org/folio/circulation/domain/Loan.java @@ -740,9 +740,10 @@ public FeeAmount getRemainingFeeFineAmount() { .orElse(noFeeAmount()); } - public void closeLoanAsLostAndPaid() { + public void closeLoanAsLostAndPaid(ZonedDateTime returnDate) { log.debug("closeLoanAsLostAndPaid:: "); closeLoan(CLOSED_LOAN); + changeReturnDate(returnDate); changeItemStatusForItemAndLoan(ItemStatus.LOST_AND_PAID); } diff --git a/src/main/java/org/folio/circulation/services/CloseLoanWithLostItemService.java b/src/main/java/org/folio/circulation/services/CloseLoanWithLostItemService.java index d85062664a..2f7f0a1405 100644 --- a/src/main/java/org/folio/circulation/services/CloseLoanWithLostItemService.java +++ b/src/main/java/org/folio/circulation/services/CloseLoanWithLostItemService.java @@ -21,6 +21,7 @@ import org.folio.circulation.infrastructure.storage.loans.LoanRepository; import org.folio.circulation.infrastructure.storage.loans.LostItemPolicyRepository; import org.folio.circulation.support.results.Result; +import org.folio.circulation.support.utils.ClockUtil; public class CloseLoanWithLostItemService { @@ -78,7 +79,7 @@ private CompletableFuture> closeLoanAsLostAndPaid(Loan loan, } boolean wasLoanOpen = loan.isOpen(); - loan.closeLoanAsLostAndPaid(); + loan.closeLoanAsLostAndPaid(ClockUtil.getZonedDateTime()); return new StoreLoanAndItem(loanRepository, itemRepository).updateLoanAndItemInStorage(loan) .thenCompose(r -> r.after(l -> publishLoanClosedEvent(l, wasLoanOpen, eventPublisher))); diff --git a/src/main/java/org/folio/circulation/services/LostItemFeeChargingService.java b/src/main/java/org/folio/circulation/services/LostItemFeeChargingService.java index d63a2d7099..f83b7af407 100644 --- a/src/main/java/org/folio/circulation/services/LostItemFeeChargingService.java +++ b/src/main/java/org/folio/circulation/services/LostItemFeeChargingService.java @@ -40,6 +40,7 @@ import org.folio.circulation.services.support.CreateAccountCommand; import org.folio.circulation.support.Clients; import org.folio.circulation.support.results.Result; +import org.folio.circulation.support.utils.ClockUtil; import lombok.AllArgsConstructor; import lombok.Getter; @@ -142,7 +143,7 @@ private CompletableFuture> closeLoanAsLostAndPaidAndPublishEvent(Lo } private CompletableFuture> closeLoanAsLostAndPaidAndUpdateInStorage(Loan loan) { - loan.closeLoanAsLostAndPaid(); + loan.closeLoanAsLostAndPaid(ClockUtil.getZonedDateTime()); return storeLoanAndItem.updateLoanAndItemInStorage(loan); } diff --git a/src/main/java/org/folio/circulation/services/agedtolost/ChargeLostFeesWhenAgedToLostService.java b/src/main/java/org/folio/circulation/services/agedtolost/ChargeLostFeesWhenAgedToLostService.java index 67f8a55bd4..1f64c80827 100644 --- a/src/main/java/org/folio/circulation/services/agedtolost/ChargeLostFeesWhenAgedToLostService.java +++ b/src/main/java/org/folio/circulation/services/agedtolost/ChargeLostFeesWhenAgedToLostService.java @@ -61,6 +61,7 @@ import org.folio.circulation.support.fetching.PageableFetcher; import org.folio.circulation.support.http.client.CqlQuery; import org.folio.circulation.support.results.Result; +import org.folio.circulation.support.utils.ClockUtil; import lombok.val; @@ -322,7 +323,7 @@ private CompletableFuture> closeLoanAsLostAndPaid(LoanToChargeFees final Loan loan = loanToChargeFees.getLoan(); loan.setLostItemHasBeenBilled(); - loan.closeLoanAsLostAndPaid(); + loan.closeLoanAsLostAndPaid(ClockUtil.getZonedDateTime()); return storeLoanAndItem.updateLoanAndItemInStorage(loan); }