Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CIRC-1482 create test for overdue recall fine calculation when recall… #1074

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
74 changes: 74 additions & 0 deletions src/test/java/api/loans/CheckInByBarcodeTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -1369,6 +1369,80 @@ void overdueFineCalculatedCorrectlyWhenHourlyFeeFinePolicyIsApplied() {
homeLocation.getJson().getString("name"), ownerId, feeFineId, 7.0));
}

@Test
void overdueRecallFineCalculatedCorrectlyWhenRecallRequestCreated() {
double maxOverdueFine = 5.0;
double maxOverdueRecallFine = 30.0;
double overdueRecallFine = 6.0;
configurationsFixture.enableTlrFeature();
useFallbackPolicies(
loanPoliciesFixture.create(new LoanPolicyBuilder()
.withId(UUID.randomUUID())
.withName("1 minute policy")
.withDescription("Can circulate item")
.rolling(Period.minutes(1))
.withGracePeriod(Period.zeroDurationPeriod())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this line? Don't we hae zero grace period by default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

.unlimitedRenewals()
.renewFromSystemDate()).getId(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this, keeping in mind that we don't use renew in this test?

requestPoliciesFixture.allowAllRequestPolicy().getId(),
noticePoliciesFixture.activeNotice().getId(),
overdueFinePoliciesFixture.create(new OverdueFinePolicyBuilder()
.withId(UUID.randomUUID())
.withName("One per minute overdue fine and overdue recall fine policy")
.withCountClosed(true)
.withGracePeriodRecall(false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this line? Don't we have zero grace period by default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

.withOverdueFine(
new JsonObject()
.put("quantity", 1.0)
.put("intervalId", "minute"))
.withMaxOverdueFine(maxOverdueFine)
.withOverdueRecallFine(new JsonObject()
.put("quantity", overdueRecallFine)
.put("intervalId", "minute"))
.withMaxOverdueRecallFine(maxOverdueRecallFine)
.withCountClosed(false)).getId(),
lostItemFeePoliciesFixture.facultyStandard().getId()
);
final IndividualResource homeLocation = locationsFixture.mainFloor();
final IndividualResource nod = itemsFixture.basedUponNod(item ->
item.withPermanentLocation(homeLocation.getId()));

ZonedDateTime checkOutDate = ZonedDateTime.of(2020, 1, 18, 18, 0, 0, 0, UTC);
ZonedDateTime requestDate = ZonedDateTime.of(2020, 1, 19, 18, 0, 0, 0, UTC);
ZonedDateTime checkInDate = ZonedDateTime.of(2020, 1, 22, 15, 30, 0, 0, UTC);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about making the checkin date in minutes after the request date, so that we can see that the amount of overdue recall fees is really different?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


checkOutFixture.checkOutByBarcode(nod, usersFixture.james(), checkOutDate);
requestsFixture.placeItemLevelHoldShelfRequest(
nod, usersFixture.steve(), requestDate, "Recall");

UUID ownerId = UUID.randomUUID();
feeFineOwnersClient.create(new FeeFineOwnerBuilder()
.withId(ownerId)
.withOwner("fee-fine-owner")
.withServicePointOwner(Collections.singletonList(new JsonObject()
.put("value", homeLocation.getJson().getString("primaryServicePoint"))
.put("label", "label"))));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this neccessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


UUID feeFineId = UUID.randomUUID();
feeFinesClient.create(new FeeFineBuilder()
.withId(feeFineId)
.withFeeFineType("Overdue fine")
.withOwnerId(ownerId)
.withAutomatic(true));

CheckInByBarcodeResponse checkInResponse =
checkInFixture.checkInByBarcode(nod, checkInDate, servicePointsFixture.cd1().getId());

waitAtMost(1, SECONDS)
.until(accountsClient::getAll, hasSize(1));

List<JsonObject> createdAccounts = accountsClient.getAll();

assertThat("Fee/fine record should be created", createdAccounts, hasSize(1));
assertThat(createdAccounts.get(0), isValidOverdueFine(checkInResponse.getLoan(), nod,
homeLocation.getJson().getString("name"), ownerId, feeFineId, maxOverdueRecallFine));
}

@Test
void canCheckInLostAndPaidItem() {
final ItemResource item = itemsFixture.basedUponNod();
Expand Down