-
Notifications
You must be signed in to change notification settings - Fork 25
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
base: master
Are you sure you want to change the base?
Changes from 4 commits
60242f0
c39f8ef
ac8ee99
df5267f
ae0f2ce
9391b4a
9185e2f
b8b54d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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()) | ||
.unlimitedRenewals() | ||
.renewFromSystemDate()).getId(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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")))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this neccessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(); | ||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done