use of api.support.builders.FeeFineBuilder in project mod-circulation by folio-org.
the class OverdueFineScheduledNoticesProcessingTests method generateOverdueFine.
private void generateOverdueFine(TriggeringEvent triggeringEvent, JsonObject... patronNoticeConfigs) {
NoticePolicyBuilder noticePolicyBuilder = new NoticePolicyBuilder().withName("Patron notice policy with fee/fine notices").withFeeFineNotices(Arrays.asList(patronNoticeConfigs));
use(noticePolicyBuilder);
templateFixture.createDummyNoticeTemplate(TEMPLATE_IDS.get(UPON_AT));
templateFixture.createDummyNoticeTemplate(TEMPLATE_IDS.get(AFTER));
UUID checkInServicePointId = servicePointsFixture.cd1().getId();
IndividualResource location = locationsFixture.basedUponExampleLocation(builder -> builder.withPrimaryServicePoint(checkInServicePointId));
IndividualResource user = usersFixture.james();
userId = user.getId();
IndividualResource item = itemsFixture.basedUponNod(builder -> builder.withPermanentLocation(location.getId()));
itemId = item.getId();
JsonObject servicePointOwner = new JsonObject().put("value", checkInServicePointId.toString()).put("label", "Service Desk 1");
feeFineOwnersClient.create(new FeeFineOwnerBuilder().withId(randomUUID()).withOwner("test owner").withServicePointOwner(Collections.singletonList(servicePointOwner)));
feeFinesClient.create(new FeeFineBuilder().withId(randomUUID()).withFeeFineType(OVERDUE_FINE).withAutomatic(true));
final ZonedDateTime checkOutDate = ClockUtil.getZonedDateTime().minusYears(1);
final ZonedDateTime checkInDate = checkOutDate.plusMonths(1);
IndividualResource checkOutResponse = checkOutFixture.checkOutByBarcode(item, user, checkOutDate);
loanId = UUID.fromString(checkOutResponse.getJson().getString("id"));
switch(triggeringEvent) {
case OVERDUE_FINE_RETURNED:
checkInFixture.checkInByBarcode(new CheckInByBarcodeRequestBuilder().forItem(item).on(checkInDate).at(checkInServicePointId));
break;
case OVERDUE_FINE_RENEWED:
loansFixture.renewLoan(item, user);
break;
default:
break;
}
List<JsonObject> accounts = Awaitility.await().atMost(1, TimeUnit.SECONDS).until(accountsClient::getAll, hasSize(1));
assertThat("Fee/fine record should have been created", accounts, hasSize(1));
account = Account.from(accounts.get(0));
accountId = UUID.fromString(account.getId());
List<JsonObject> actions = Awaitility.await().atMost(1, TimeUnit.SECONDS).until(feeFineActionsClient::getAll, hasSize(1));
assertThat("Fee/fine action record should have been created", actions, hasSize(1));
action = FeeFineAction.from(actions.get(0));
actionId = UUID.fromString(action.getId());
actionDateTime = action.getDateAction();
}
use of api.support.builders.FeeFineBuilder in project mod-circulation by folio-org.
the class CheckInByBarcodeTests method overdueFineCalculatedCorrectlyWhenHourlyFeeFinePolicyIsApplied.
@Test
void overdueFineCalculatedCorrectlyWhenHourlyFeeFinePolicyIsApplied() {
useFallbackPolicies(loanPoliciesFixture.create(new LoanPolicyBuilder().withId(UUID.randomUUID()).withName("Three days policy").withDescription("Can circulate item").rolling(Period.days(3)).unlimitedRenewals().renewFromSystemDate()).getId(), requestPoliciesFixture.allowAllRequestPolicy().getId(), noticePoliciesFixture.activeNotice().getId(), overdueFinePoliciesFixture.create(new OverdueFinePolicyBuilder().withId(UUID.randomUUID()).withName("One per hour overdue fine policy").withOverdueFine(new JsonObject().put("quantity", 1.0).put("intervalId", "hour")).withCountClosed(false)).getId(), lostItemFeePoliciesFixture.facultyStandard().getId());
final IndividualResource james = usersFixture.james();
final UUID checkInServicePointId = servicePointsFixture.cd1().getId();
final IndividualResource homeLocation = locationsFixture.basedUponExampleLocation(item -> item.withPrimaryServicePoint(checkInServicePointId));
final IndividualResource nod = itemsFixture.basedUponNod(item -> item.withPermanentLocation(homeLocation.getId()));
ZonedDateTime checkOutDate = ZonedDateTime.of(2020, 1, 18, 18, 0, 0, 0, UTC);
ZonedDateTime checkInDate = ZonedDateTime.of(2020, 1, 22, 15, 30, 0, 0, UTC);
checkOutFixture.checkOutByBarcode(nod, james, checkOutDate);
JsonObject servicePointOwner = new JsonObject();
servicePointOwner.put("value", homeLocation.getJson().getString("primaryServicePoint"));
servicePointOwner.put("label", "label");
UUID ownerId = UUID.randomUUID();
feeFineOwnersClient.create(new FeeFineOwnerBuilder().withId(ownerId).withOwner("fee-fine-owner").withServicePointOwner(Collections.singletonList(servicePointOwner)));
UUID feeFineId = UUID.randomUUID();
feeFinesClient.create(new FeeFineBuilder().withId(feeFineId).withFeeFineType("Overdue fine").withOwnerId(ownerId).withAutomatic(true).withDefaultAmount(1.0));
CheckInByBarcodeResponse checkInResponse = checkInFixture.checkInByBarcode(new CheckInByBarcodeRequestBuilder().forItem(nod).on(checkInDate).at(checkInServicePointId));
JsonObject checkedInLoan = checkInResponse.getLoan();
waitAtMost(1, SECONDS).until(accountsClient::getAll, hasSize(1));
List<JsonObject> createdAccounts = accountsClient.getAll();
assertThat("Fee/fine record should be created", createdAccounts, hasSize(1));
JsonObject account = createdAccounts.get(0);
assertThat(account, isValidOverdueFine(checkedInLoan, nod, homeLocation.getJson().getString("name"), ownerId, feeFineId, 7.0));
}
use of api.support.builders.FeeFineBuilder in project mod-circulation by folio-org.
the class CheckInByBarcodeTests method shouldNotCreateOverdueFineWithResolutionFoundByLibrary.
@Test
void shouldNotCreateOverdueFineWithResolutionFoundByLibrary() {
useFallbackPolicies(loanPoliciesFixture.canCirculateRolling().getId(), requestPoliciesFixture.allowAllRequestPolicy().getId(), noticePoliciesFixture.activeNotice().getId(), overdueFinePoliciesFixture.facultyStandardDoNotCountClosed().getId(), lostItemFeePoliciesFixture.facultyStandard().getId());
final IndividualResource james = usersFixture.james();
final UUID checkInServicePointId = servicePointsFixture.cd1().getId();
final IndividualResource homeLocation = locationsFixture.basedUponExampleLocation(item -> item.withPrimaryServicePoint(checkInServicePointId));
final IndividualResource nod = itemsFixture.basedUponNod(item -> item.withPermanentLocation(homeLocation.getId()));
checkOutFixture.checkOutByBarcode(nod, james, ZonedDateTime.of(2020, 1, 1, 12, 0, 0, 0, UTC));
JsonObject servicePointOwner = new JsonObject();
servicePointOwner.put("value", homeLocation.getJson().getString("primaryServicePoint"));
servicePointOwner.put("label", "label");
UUID ownerId = UUID.randomUUID();
feeFineOwnersClient.create(new FeeFineOwnerBuilder().withId(ownerId).withOwner("fee-fine-owner").withServicePointOwner(Collections.singletonList(servicePointOwner)));
UUID feeFineId = UUID.randomUUID();
feeFinesClient.create(new FeeFineBuilder().withId(feeFineId).withFeeFineType("Overdue fine").withOwnerId(ownerId));
checkInFixture.checkInByBarcode(new CheckInByBarcodeRequestBuilder().forItem(nod).on(ZonedDateTime.of(2020, 1, 25, 12, 0, 0, 0, UTC)).at(checkInServicePointId).claimedReturnedResolution("Found by library"));
waitAtLeast(1, SECONDS).until(accountsClient::getAll, empty());
waitAtLeast(1, SECONDS).until(feeFineActionsClient::getAll, empty());
}
use of api.support.builders.FeeFineBuilder in project mod-circulation by folio-org.
the class CheckInByBarcodeTests method overdueRecallFineShouldBeChargedWhenItemIsOverdueAfterRecall.
@Test
void overdueRecallFineShouldBeChargedWhenItemIsOverdueAfterRecall() {
useFallbackPolicies(loanPoliciesFixture.canCirculateRolling().getId(), requestPoliciesFixture.allowAllRequestPolicy().getId(), noticePoliciesFixture.activeNotice().getId(), overdueFinePoliciesFixture.facultyStandardDoNotCountClosed().getId(), lostItemFeePoliciesFixture.facultyStandard().getId());
final IndividualResource james = usersFixture.james();
final UUID checkInServicePointId = servicePointsFixture.cd1().getId();
final IndividualResource homeLocation = locationsFixture.basedUponExampleLocation(item -> item.withPrimaryServicePoint(checkInServicePointId));
final IndividualResource nod = itemsFixture.basedUponNod(item -> item.withPermanentLocation(homeLocation.getId()));
ZonedDateTime checkOutDate = ZonedDateTime.of(2020, 1, 15, 0, 0, 0, 0, UTC);
ZonedDateTime recallRequestExpirationDate = checkOutDate.plusDays(5);
ZonedDateTime checkInDate = checkOutDate.plusDays(10);
mockClockManagerToReturnFixedDateTime(ZonedDateTime.of(2020, 1, 18, 0, 0, 0, 0, UTC));
checkOutFixture.checkOutByBarcode(nod, james, checkOutDate);
Address address = SiriusBlack();
IndividualResource requester = usersFixture.steve(builder -> builder.withAddress(address));
requestsFixture.place(new RequestBuilder().withId(UUID.randomUUID()).open().recall().forItem(nod).by(requester).fulfilToHoldShelf().withRequestExpiration(toLocalDate(recallRequestExpirationDate)).withHoldShelfExpiration(toLocalDate(recallRequestExpirationDate)).withPickupServicePointId(UUID.fromString(homeLocation.getJson().getString("primaryServicePoint"))).withTags(new RequestBuilder.Tags(asList("new", "important"))));
JsonObject servicePointOwner = new JsonObject();
servicePointOwner.put("value", homeLocation.getJson().getString("primaryServicePoint"));
servicePointOwner.put("label", "label");
UUID ownerId = UUID.randomUUID();
feeFineOwnersClient.create(new FeeFineOwnerBuilder().withId(ownerId).withOwner("fee-fine-owner").withServicePointOwner(Collections.singletonList(servicePointOwner)));
UUID feeFineId = UUID.randomUUID();
feeFinesClient.create(new FeeFineBuilder().withId(feeFineId).withFeeFineType("Overdue fine").withOwnerId(ownerId).withAutomatic(true));
CheckInByBarcodeResponse checkInResponse = checkInFixture.checkInByBarcode(new CheckInByBarcodeRequestBuilder().forItem(nod).on(checkInDate).at(checkInServicePointId));
JsonObject checkedInLoan = checkInResponse.getLoan();
final var createdAccounts = waitAtMost(1, SECONDS).until(accountsClient::getAll, hasSize(1));
mockClockManagerToReturnDefaultDateTime();
JsonObject account = createdAccounts.get(0);
assertThat(account, isValidOverdueFine(checkedInLoan, nod, homeLocation.getJson().getString("name"), ownerId, feeFineId, 10.0));
}
use of api.support.builders.FeeFineBuilder in project mod-circulation by folio-org.
the class CheckInByBarcodeTests method overdueFineIsNotCreatedWhenThereIsNoOwnerForServicePoint.
@Test
void overdueFineIsNotCreatedWhenThereIsNoOwnerForServicePoint() {
useFallbackPolicies(loanPoliciesFixture.canCirculateRolling().getId(), requestPoliciesFixture.allowAllRequestPolicy().getId(), noticePoliciesFixture.activeNotice().getId(), overdueFinePoliciesFixture.facultyStandardDoNotCountClosed().getId(), lostItemFeePoliciesFixture.facultyStandard().getId());
final IndividualResource james = usersFixture.james();
final UUID checkInServicePointId = servicePointsFixture.cd1().getId();
final IndividualResource homeLocation = locationsFixture.basedUponExampleLocation(item -> item.withPrimaryServicePoint(checkInServicePointId));
final IndividualResource nod = itemsFixture.basedUponNod(item -> item.withPermanentLocation(homeLocation.getId()));
checkOutFixture.checkOutByBarcode(nod, james, ZonedDateTime.of(2020, 1, 1, 12, 0, 0, 0, UTC));
final UUID servicePointForOwner = servicePointsFixture.cd2().getId();
JsonObject servicePointOwner = new JsonObject();
servicePointOwner.put("value", servicePointForOwner.toString());
servicePointOwner.put("label", "label");
UUID ownerId = UUID.randomUUID();
feeFineOwnersClient.create(new FeeFineOwnerBuilder().withId(ownerId).withOwner("fee-fine-owner").withServicePointOwner(Collections.singletonList(servicePointOwner)));
UUID feeFineId = UUID.randomUUID();
feeFinesClient.create(new FeeFineBuilder().withId(feeFineId).withFeeFineType("Overdue fine").withOwnerId(ownerId).withAutomatic(true));
checkInFixture.checkInByBarcode(new CheckInByBarcodeRequestBuilder().forItem(nod).on(ZonedDateTime.of(2020, 1, 25, 12, 0, 0, 0, UTC)).at(checkInServicePointId));
waitAtMost(1, SECONDS);
List<JsonObject> createdAccounts = accountsClient.getAll();
assertThat("No fee/fine records should have been created", createdAccounts, hasSize(0));
}
Aggregations