Search in sources :

Example 1 with FeeFineOwnerBuilder

use of api.support.builders.FeeFineOwnerBuilder 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();
}
Also used : FeeFineOwnerBuilder(api.support.builders.FeeFineOwnerBuilder) ZonedDateTime(java.time.ZonedDateTime) NoticePolicyBuilder(api.support.builders.NoticePolicyBuilder) JsonObject(io.vertx.core.json.JsonObject) FeeFineBuilder(api.support.builders.FeeFineBuilder) CheckInByBarcodeRequestBuilder(api.support.builders.CheckInByBarcodeRequestBuilder) UUID(java.util.UUID) UUID.randomUUID(java.util.UUID.randomUUID) IndividualResource(api.support.http.IndividualResource)

Example 2 with FeeFineOwnerBuilder

use of api.support.builders.FeeFineOwnerBuilder in project mod-circulation by folio-org.

the class ScheduledAgeToLostFeeChargingApiTest method checkoutTenItems.

private Map<IndividualResource, Double> checkoutTenItems() {
    val loanToFeeMap = new LinkedHashMap<IndividualResource, Double>();
    for (int itemIndex = 0; itemIndex < 10; itemIndex++) {
        val itemIndexFinal = itemIndex;
        val servicePoint = createServicePointForItemIndex(itemIndex);
        val location = locationsFixture.basedUponExampleLocation(builder -> builder.withName("Location for sp " + itemIndexFinal).withCode("agl-loc-" + itemIndexFinal).withPrimaryServicePoint(servicePoint.getId()));
        val item = itemsFixture.basedUponNod(itemBuilder -> itemBuilder.withRandomBarcode().withPermanentLocation(location.getId()));
        val setCostFee = 10.0 + itemIndex;
        val policyBuilder = lostItemFeePoliciesFixture.ageToLostAfterOneMinutePolicy().withName("Age to lost item " + itemIndex).doNotChargeProcessingFeeWhenAgedToLost().withSetCost(setCostFee);
        useLostItemPolicy(lostItemFeePoliciesFixture.create(policyBuilder).getId());
        feeFineOwnerFixture.create(new FeeFineOwnerBuilder().withOwner("Owner " + (itemIndex + 1)).withServicePointOwner(servicePoint.getId()));
        val loan = checkOutFixture.checkOutByBarcode(item, usersFixture.charlotte());
        loanToFeeMap.put(loan, setCostFee);
    }
    return loanToFeeMap;
}
Also used : lombok.val(lombok.val) FeeFineOwnerBuilder(api.support.builders.FeeFineOwnerBuilder) LinkedHashMap(java.util.LinkedHashMap)

Example 3 with FeeFineOwnerBuilder

use of api.support.builders.FeeFineOwnerBuilder 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));
}
Also used : FeeFineOwnerBuilder(api.support.builders.FeeFineOwnerBuilder) ZonedDateTime(java.time.ZonedDateTime) ClockUtil.getZonedDateTime(org.folio.circulation.support.utils.ClockUtil.getZonedDateTime) JsonObject(io.vertx.core.json.JsonObject) LoanPolicyBuilder(api.support.builders.LoanPolicyBuilder) FeeFineBuilder(api.support.builders.FeeFineBuilder) CheckInByBarcodeRequestBuilder(api.support.builders.CheckInByBarcodeRequestBuilder) IndividualResource(api.support.http.IndividualResource) UUID(java.util.UUID) CheckInByBarcodeResponse(api.support.CheckInByBarcodeResponse) OverdueFinePolicyBuilder(api.support.builders.OverdueFinePolicyBuilder) Test(org.junit.jupiter.api.Test)

Example 4 with FeeFineOwnerBuilder

use of api.support.builders.FeeFineOwnerBuilder 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());
}
Also used : FeeFineOwnerBuilder(api.support.builders.FeeFineOwnerBuilder) JsonObject(io.vertx.core.json.JsonObject) FeeFineBuilder(api.support.builders.FeeFineBuilder) CheckInByBarcodeRequestBuilder(api.support.builders.CheckInByBarcodeRequestBuilder) IndividualResource(api.support.http.IndividualResource) UUID(java.util.UUID) Test(org.junit.jupiter.api.Test)

Example 5 with FeeFineOwnerBuilder

use of api.support.builders.FeeFineOwnerBuilder 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));
}
Also used : Address(api.support.builders.Address) CheckInByBarcodeRequestBuilder(api.support.builders.CheckInByBarcodeRequestBuilder) RequestBuilder(api.support.builders.RequestBuilder) JsonObject(io.vertx.core.json.JsonObject) FeeFineBuilder(api.support.builders.FeeFineBuilder) CheckInByBarcodeRequestBuilder(api.support.builders.CheckInByBarcodeRequestBuilder) IndividualResource(api.support.http.IndividualResource) CheckInByBarcodeResponse(api.support.CheckInByBarcodeResponse) FeeFineOwnerBuilder(api.support.builders.FeeFineOwnerBuilder) ZonedDateTime(java.time.ZonedDateTime) ClockUtil.getZonedDateTime(org.folio.circulation.support.utils.ClockUtil.getZonedDateTime) UUID(java.util.UUID) Test(org.junit.jupiter.api.Test)

Aggregations

FeeFineOwnerBuilder (api.support.builders.FeeFineOwnerBuilder)11 FeeFineBuilder (api.support.builders.FeeFineBuilder)10 IndividualResource (api.support.http.IndividualResource)10 JsonObject (io.vertx.core.json.JsonObject)10 UUID (java.util.UUID)10 Test (org.junit.jupiter.api.Test)9 CheckInByBarcodeRequestBuilder (api.support.builders.CheckInByBarcodeRequestBuilder)8 CheckInByBarcodeResponse (api.support.CheckInByBarcodeResponse)4 LoanPolicyBuilder (api.support.builders.LoanPolicyBuilder)3 ZonedDateTime (java.time.ZonedDateTime)3 ClockUtil.getZonedDateTime (org.folio.circulation.support.utils.ClockUtil.getZonedDateTime)2 Address (api.support.builders.Address)1 NoticePolicyBuilder (api.support.builders.NoticePolicyBuilder)1 OverdueFinePolicyBuilder (api.support.builders.OverdueFinePolicyBuilder)1 RequestBuilder (api.support.builders.RequestBuilder)1 LinkedHashMap (java.util.LinkedHashMap)1 UUID.randomUUID (java.util.UUID.randomUUID)1 lombok.val (lombok.val)1