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);
}
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);
}
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);
}
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));
}
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));
}
Aggregations