Skip to content
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 2136 floating collections #3

Merged
merged 3 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions ramls/examples/loan.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
{
"name": "Steve Jones"
}
]
],
"primaryContributor" : "Steve Jones"
},
"loanPolicyId" : "e9af4ba4-6801-4722-be45-d7a49d13564d",
"loanPolicy": {
Expand All @@ -37,7 +38,9 @@
"firstName" : "FirstName",
"lastName" : "LastName",
"middleName" : "MiddleName",
"barcode" : "102322966933815"
"barcode" : "102322966933815",
"preferredFirstName" : "preferredFirstName",
"patronGroup" : "3684a786-6671-4268-8ed0-9db82ebca60b"
},
"loanDate": "2017-03-01T23:11:00.000Z",
"dueDate": "2017-04-01T23:11:00.000Z",
Expand Down
15 changes: 15 additions & 0 deletions ramls/loan.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@
"description": "barcode used to identify the borrower (read only, defined by the server)",
"type": "string",
"readonly": true
},
"preferredFirstName": {
"description": "preferred first name of the borrower (read only, defined by the server)",
"type": "string",
"readonly": true
},
"patronGroup": {
"description": "current patron group of the borrower (read only, defined by the server)",
"type": "string",
"readonly": true
}
},
"additionalProperties": false
Expand Down Expand Up @@ -158,6 +168,11 @@
"additionalProperties": false
}
},
"primaryContributor": {
"description": "primary contributor of the item",
"type": "string",
"readonly": true
},
"holdingsRecordId": {
"description": "The ID of the holdings for the item",
"type": "string",
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/org/folio/circulation/domain/Item.java
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,9 @@ public String getFloatDestinationLocationId() {
}

public boolean canFloatThroughCheckInServicePoint() {
return getLocation() != null &&
getLocation().isFloatingCollection()
return getLocation() != null
&& getLocation().isFloatingCollection()
&& getFloatDestinationLocation() != null
&& getFloatDestinationLocation().getId() != null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ private void additionalBorrowerProperties(JsonObject loanRepresentation, User bo
borrowerSummary.put("lastName", borrower.getLastName());
borrowerSummary.put("middleName", borrower.getMiddleName());
borrowerSummary.put("barcode", borrower.getBarcode());

borrowerSummary.put("preferredFirstName",borrower.getPreferredFirstName());
borrowerSummary.put("patronGroup",borrower.getPatronGroupId());
loanRepresentation.put(BORROWER, borrowerSummary);

additionalPatronGroupProperties(loanRepresentation, borrower.getPatronGroup());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public JsonObject createItemSummary(Item item) {
write(itemSummary, "title", item.isDcbItem() ? item.getDcbItemTitle() : item.getTitle());
write(itemSummary, "barcode", item.getBarcode());
write(itemSummary, "contributors", mapContributorNamesToJson(item));
write(itemSummary, "primaryContributor",item.getPrimaryContributorName());
write(itemSummary, "callNumber", item.getCallNumber());
write(itemSummary, "enumeration", item.getEnumeration());
write(itemSummary, "chronology", item.getChronology());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public CompletableFuture<Result<Item>> updateItem(Item item) {
if (item.isInStatus(IN_TRANSIT)) {
write(updatedItemRepresentation, IN_TRANSIT_DESTINATION_SERVICE_POINT_ID,
item.getInTransitDestinationServicePointId());
} else if (item.canFloatThroughCheckInServicePoint()) {
} else if (item.isInStatus(AVAILABLE) && item.canFloatThroughCheckInServicePoint()) {
remove(updatedItemRepresentation, TEMPORARY_LOCATION_ID);
write(updatedItemRepresentation, TEMPORARY_LOCATION_ID,
item.getFloatDestinationLocationId());
Expand Down
15 changes: 15 additions & 0 deletions src/test/java/api/loans/LoanAPITests.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,21 @@ void createLoanForDcbUserAndDcbItem() {
loan.getString("isDcb"), is("true"));
}

@Test
void canGetLoansWithAdditionalFieldsRequiredForDueDateSlip() {
loansFixture.createLoan(itemsFixture.basedUponSmallAngryPlanet(), usersFixture.KimJames());
JsonObject loan = loansFixture.getLoans().getFirst();

assertThat("Borrower has preferredFirstName",
loan.getJsonObject("borrower").containsKey("preferredFirstName"), is(true));

assertThat("Borrower has patronGroup",
loan.getJsonObject("borrower").containsKey("patronGroup"), is(true));

assertThat("Item has primaryContributor",
loan.getJsonObject("item").containsKey("primaryContributor"), is(true));
}

@Test
void canGetLoanWithoutOpenFeesFines() {
UUID id = UUID.randomUUID();
Expand Down
7 changes: 7 additions & 0 deletions src/test/java/api/support/fixtures/UserExamples.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ static UserBuilder basedUponGroot() {
.withActive(true);
}

static UserBuilder basedUponJames() {
return new UserBuilder()
.withBarcode("6430530304")
.withPreferredFirstName("kim", "james", "kimJ")
.withActive(true);
}

static UserBuilder basedUponCharlotteBroadwell() {
return new UserBuilder()
.withName("Broadwell", "Charlotte")
Expand Down
6 changes: 6 additions & 0 deletions src/test/java/api/support/fixtures/UsersFixture.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static api.support.fixtures.UserExamples.basedUponCharlotteBroadwell;
import static api.support.fixtures.UserExamples.basedUponGroot;
import static api.support.fixtures.UserExamples.basedUponHenryHanks;
import static api.support.fixtures.UserExamples.basedUponJames;
import static api.support.fixtures.UserExamples.basedUponJamesRodwell;
import static api.support.fixtures.UserExamples.basedUponJessicaPontefract;
import static api.support.fixtures.UserExamples.basedUponRebeccaStuart;
Expand Down Expand Up @@ -40,6 +41,11 @@ public UserResource groot() {
.inGroupFor(patronGroupsFixture.regular()));
}

public UserResource KimJames() {
return createIfAbsent(basedUponJames()
.inGroupFor(patronGroupsFixture.staff()));
}

public UserResource james() {
return createIfAbsent(basedUponJamesRodwell()
.inGroupFor(patronGroupsFixture.regular()));
Expand Down