Skip to content

Commit

Permalink
CIRC-2050 set returnDate for lost loans
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-barannyk committed Apr 8, 2024
1 parent 533b373 commit 5592ad8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/main/java/org/folio/circulation/domain/Loan.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -78,7 +79,7 @@ private CompletableFuture<Result<Loan>> 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)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -142,7 +143,7 @@ private CompletableFuture<Result<Loan>> closeLoanAsLostAndPaidAndPublishEvent(Lo
}

private CompletableFuture<Result<Loan>> closeLoanAsLostAndPaidAndUpdateInStorage(Loan loan) {
loan.closeLoanAsLostAndPaid();
loan.closeLoanAsLostAndPaid(ClockUtil.getZonedDateTime());
return storeLoanAndItem.updateLoanAndItemInStorage(loan);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -322,7 +323,7 @@ private CompletableFuture<Result<Loan>> closeLoanAsLostAndPaid(LoanToChargeFees
final Loan loan = loanToChargeFees.getLoan();

loan.setLostItemHasBeenBilled();
loan.closeLoanAsLostAndPaid();
loan.closeLoanAsLostAndPaid(ClockUtil.getZonedDateTime());

return storeLoanAndItem.updateLoanAndItemInStorage(loan);
}
Expand Down

0 comments on commit 5592ad8

Please sign in to comment.