Search in sources :

Example 1 with OverdueFinePolicyBuilder

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

the class OverdueFinePoliciesFixture method facultyStandard.

public IndividualResource facultyStandard() {
    JsonObject overdueFine = new JsonObject();
    overdueFine.put("quantity", 5.0);
    overdueFine.put("intervalId", "day");
    JsonObject overdueRecallFine = new JsonObject();
    overdueRecallFine.put("quantity", 1.0);
    overdueRecallFine.put("intervalId", "hour");
    final OverdueFinePolicyBuilder facultyStandard = new OverdueFinePolicyBuilder().withName("Faculty standard").withDescription("This is description for Faculty standard").withOverdueFine(overdueFine).withCountClosed(true).withMaxOverdueFine(50.00).withForgiveOverdueFine(false).withOverdueRecallFine(overdueRecallFine).withGracePeriodRecall(false).withMaxOverdueRecallFine(50.00);
    return overdueFinePolicyRecordCreator.createIfAbsent(facultyStandard);
}
Also used : JsonObject(io.vertx.core.json.JsonObject) OverdueFinePolicyBuilder(api.support.builders.OverdueFinePolicyBuilder)

Example 2 with OverdueFinePolicyBuilder

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

the class OverdueFinePoliciesFixture method facultyStandardDoNotCountClosed.

public IndividualResource facultyStandardDoNotCountClosed() {
    JsonObject overdueFine = new JsonObject();
    overdueFine.put("quantity", 5.0);
    overdueFine.put("intervalId", "day");
    JsonObject overdueRecallFine = new JsonObject();
    overdueRecallFine.put("quantity", 1.0);
    overdueRecallFine.put("intervalId", "hour");
    final OverdueFinePolicyBuilder overdueFinePolicyBuilder = new OverdueFinePolicyBuilder().withName("Faculty standard (don't count closed)").withDescription("This is description for Faculty standard (don't count closed)").withOverdueFine(overdueFine).withCountClosed(false).withMaxOverdueFine(50.00).withForgiveOverdueFine(false).withOverdueRecallFine(overdueRecallFine).withGracePeriodRecall(false).withMaxOverdueRecallFine(50.00);
    return overdueFinePolicyRecordCreator.createIfAbsent(overdueFinePolicyBuilder);
}
Also used : JsonObject(io.vertx.core.json.JsonObject) OverdueFinePolicyBuilder(api.support.builders.OverdueFinePolicyBuilder)

Example 3 with OverdueFinePolicyBuilder

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

the class OverdueFinePoliciesFixture method facultyStandardShouldForgiveFine.

public IndividualResource facultyStandardShouldForgiveFine() {
    JsonObject overdueFine = new JsonObject();
    overdueFine.put("quantity", 5.0);
    overdueFine.put("intervalId", "day");
    JsonObject overdueRecallFine = new JsonObject();
    overdueRecallFine.put("quantity", 1.0);
    overdueRecallFine.put("intervalId", "hour");
    final OverdueFinePolicyBuilder facultyStandard = new OverdueFinePolicyBuilder().withName("Faculty standard (should forgive overdue fine for renewals)").withDescription("This is description for Faculty standard (should forgive overdue fine for renewals)").withOverdueFine(overdueFine).withCountClosed(true).withMaxOverdueFine(50.00).withForgiveOverdueFine(true).withOverdueRecallFine(overdueRecallFine).withGracePeriodRecall(false).withMaxOverdueRecallFine(50.00);
    return overdueFinePolicyRecordCreator.createIfAbsent(facultyStandard);
}
Also used : JsonObject(io.vertx.core.json.JsonObject) OverdueFinePolicyBuilder(api.support.builders.OverdueFinePolicyBuilder)

Example 4 with OverdueFinePolicyBuilder

use of api.support.builders.OverdueFinePolicyBuilder 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 5 with OverdueFinePolicyBuilder

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

the class CirculationRulesAPITests method canPutAndGet.

@Test
void canPutAndGet() {
    UUID lp1 = UUID.randomUUID();
    UUID lp2 = UUID.randomUUID();
    UUID rp1 = UUID.randomUUID();
    UUID rp2 = UUID.randomUUID();
    UUID np1 = UUID.randomUUID();
    UUID np2 = UUID.randomUUID();
    UUID op1 = UUID.randomUUID();
    UUID op2 = UUID.randomUUID();
    UUID ip1 = UUID.randomUUID();
    UUID ip2 = UUID.randomUUID();
    loanPoliciesFixture.create(new LoanPolicyBuilder().withId(lp1).withName("Example LoanPolicy " + lp1));
    noticePoliciesFixture.create(new NoticePolicyBuilder().withId(np1).withName("Example NoticePolicy " + np1));
    requestPoliciesFixture.allowAllRequestPolicy(rp1);
    overdueFinePoliciesFixture.create(new OverdueFinePolicyBuilder().withId(op1).withName("Example OverdueFinePolicy " + op1));
    lostItemFeePoliciesFixture.create(new LostItemFeePolicyBuilder().withId(ip1).withName("Example lostItemPolicy " + ip1));
    loanPoliciesFixture.create(new LoanPolicyBuilder().withId(lp2).withName("Example LoanPolicy " + lp2));
    noticePoliciesFixture.create(new NoticePolicyBuilder().withId(np2).withName("Example NoticePolicy " + np2));
    requestPoliciesFixture.allowAllRequestPolicy(rp2);
    overdueFinePoliciesFixture.create(new OverdueFinePolicyBuilder().withId(op2).withName("Example OverdueFinePolicy " + op2));
    lostItemFeePoliciesFixture.create(new LostItemFeePolicyBuilder().withId(ip2).withName("Example lostItemPolicy " + ip2));
    String rule = String.format(CIRCULATION_RULE_TEMPLATE, lp1, rp1, np1, op1, ip1);
    setRules(rule);
    assertThat(getRulesText(), is(rule));
    rule = String.format(CIRCULATION_RULE_TEMPLATE, lp2, rp2, np2, op2, ip2);
    setRules(rule);
    assertThat(getRulesText(), is(rule));
}
Also used : LostItemFeePolicyBuilder(api.support.builders.LostItemFeePolicyBuilder) NoticePolicyBuilder(api.support.builders.NoticePolicyBuilder) LoanPolicyBuilder(api.support.builders.LoanPolicyBuilder) UUID(java.util.UUID) OverdueFinePolicyBuilder(api.support.builders.OverdueFinePolicyBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

OverdueFinePolicyBuilder (api.support.builders.OverdueFinePolicyBuilder)10 JsonObject (io.vertx.core.json.JsonObject)6 LoanPolicyBuilder (api.support.builders.LoanPolicyBuilder)5 LostItemFeePolicyBuilder (api.support.builders.LostItemFeePolicyBuilder)4 NoticePolicyBuilder (api.support.builders.NoticePolicyBuilder)4 UUID (java.util.UUID)4 Test (org.junit.jupiter.api.Test)4 CheckInByBarcodeResponse (api.support.CheckInByBarcodeResponse)1 CheckInByBarcodeRequestBuilder (api.support.builders.CheckInByBarcodeRequestBuilder)1 FeeFineBuilder (api.support.builders.FeeFineBuilder)1 FeeFineOwnerBuilder (api.support.builders.FeeFineOwnerBuilder)1 IndividualResource (api.support.http.IndividualResource)1 ZonedDateTime (java.time.ZonedDateTime)1 ClockUtil.getZonedDateTime (org.folio.circulation.support.utils.ClockUtil.getZonedDateTime)1