use of org.folio.circulation.domain.Loan in project mod-circulation by folio-org.
the class OverrideRenewalTest method shouldUseOverrideDateWhenReachedNumberOfRenewalsAndNewDueDateBeforeCurrent.
@Test
void shouldUseOverrideDateWhenReachedNumberOfRenewalsAndNewDueDateBeforeCurrent() {
final ZonedDateTime overrideDueDate = ClockUtil.getZonedDateTime().plusWeeks(2);
final LoanPolicy loanPolicy = LoanPolicy.from(rollingPolicy().limitedRenewals(1).create());
final Loan loan = Loan.from(new JsonObject().put("renewalCount", 2)).changeDueDate(ClockUtil.getZonedDateTime().plusWeeks(1).plusSeconds(1)).withItem(createCheckedOutItem()).withLoanPolicy(loanPolicy);
final Result<Loan> renewedLoan = renew(loan, overrideDueDate);
assertDueDate(overrideDueDate, renewedLoan);
assertEquals(CHECKED_OUT, renewedLoan.value().getItem().getStatus());
}
use of org.folio.circulation.domain.Loan in project mod-circulation by folio-org.
the class OverrideRenewalTest method overrideDateIsRequiredWhenReachedNumberOfRenewalsAndNewDueDateBeforeCurrent.
@Test
void overrideDateIsRequiredWhenReachedNumberOfRenewalsAndNewDueDateBeforeCurrent() {
final LoanPolicy loanPolicy = LoanPolicy.from(rollingPolicy().limitedRenewals(1).create());
final Loan loan = Loan.from(new JsonObject().put("renewalCount", 2)).changeDueDate(ClockUtil.getZonedDateTime().plusDays(8)).withLoanPolicy(loanPolicy);
final Result<Loan> renewedLoan = renew(loan, null);
assertThat(renewedLoan, hasValidationError(hasMessage(NEW_DUE_DATE_IS_REQUIRED_ERROR)));
}
use of org.folio.circulation.domain.Loan in project mod-circulation by folio-org.
the class OverrideRenewalTest method shouldUseOverrideDateWhenLoanIsNotLoanable.
@Test
void shouldUseOverrideDateWhenLoanIsNotLoanable() {
final ZonedDateTime overrideDate = ClockUtil.getZonedDateTime().plusMonths(1);
final JsonObject loanPolicyJson = new LoanPolicyBuilder().withLoanable(false).create();
final Result<Loan> renewedLoan = renew(LoanPolicy.from(loanPolicyJson), overrideDate);
assertDueDate(overrideDate, renewedLoan);
assertEquals(CHECKED_OUT, renewedLoan.value().getItem().getStatus());
}
use of org.folio.circulation.domain.Loan in project mod-circulation by folio-org.
the class OverrideRenewalTest method nonLoanableAgedToLostItemShouldBeProperlyRenewed.
@Test
void nonLoanableAgedToLostItemShouldBeProperlyRenewed() {
final ZonedDateTime newDueDate = ClockUtil.getZonedDateTime().plusWeeks(1);
final ZonedDateTime ageToLostDate = ClockUtil.getZonedDateTime();
final LoanPolicy loanPolicy = LoanPolicy.from(new LoanPolicyBuilder().withLoanable(false).create());
final Loan loan = Loan.from(new JsonObject()).withItem(createCheckedOutItem()).withLoanPolicy(loanPolicy);
loan.ageOverdueItemToLost(ageToLostDate).setAgedToLostDelayedBilling(false, ageToLostDate.plusDays(1));
final Result<Loan> renewedLoan = renew(loan, newDueDate);
assertDueDate(newDueDate, renewedLoan);
assertEquals(CHECKED_OUT, renewedLoan.value().getItem().getStatus());
assertThat(renewedLoan.value().asJson(), allOf(hasNoJsonPath("agedToLostDelayedBilling.lostItemHasBeenBilled"), hasNoJsonPath("agedToLostDelayedBilling.dateLostItemShouldBeBilled")));
}
use of org.folio.circulation.domain.Loan in project mod-circulation by folio-org.
the class OverrideRenewalTest method overrideDateIsRequiredWhenLoanIsNotLoanable.
@Test
void overrideDateIsRequiredWhenLoanIsNotLoanable() {
final JsonObject loanPolicyJson = new LoanPolicyBuilder().withLoanable(false).create();
final Result<Loan> renewedLoan = renew(LoanPolicy.from(loanPolicyJson), null);
assertThat(renewedLoan, hasValidationError(hasMessage(OVERRIDE_DUE_DATE_MUST_BE_SPECIFIED_ERROR)));
}
Aggregations