Skip to content

Commit

Permalink
Merge pull request #1396 from folio-org/CIRC-1981
Browse files Browse the repository at this point in the history
CIRC-1981 Print LendingLibraryCode in DCB CheckIn Print Slips
  • Loading branch information
MagzhanArtykov authored Dec 12, 2023
2 parents 089d33e + 0be1561 commit d7bd9a6
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/main/java/org/folio/circulation/domain/Item.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import static org.folio.circulation.domain.representations.ItemProperties.STATUS_PROPERTY;
import static org.folio.circulation.support.json.JsonPropertyFetcher.getBooleanProperty;
import static org.folio.circulation.support.json.JsonPropertyFetcher.getNestedStringProperty;
import static org.folio.circulation.support.json.JsonPropertyFetcher.getProperty;
import static org.folio.circulation.support.json.JsonPropertyWriter.write;

import java.util.Collection;
Expand Down Expand Up @@ -399,7 +400,11 @@ public Item withInTransitDestinationServicePoint(ServicePoint servicePoint) {
this.instance, this.materialType, this.loanType, this.description);
}

public boolean isDcbItem(){
public boolean isDcbItem() {
return getBooleanProperty(itemRepresentation, "dcbItem");
}

public String getLendingLibraryCode() {
return getProperty(itemRepresentation, "lendingLibraryCode");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ private static JsonObject createItemContext(Item item) {
.put("effectiveLocationSpecific", location.getName())
.put("effectiveLocationLibrary", location.getLibraryName())
.put("effectiveLocationCampus", location.getCampusName())
.put("effectiveLocationInstitution", location.getInstitutionName())
.put("effectiveLocationInstitution", item.isDcbItem()?item.getLendingLibraryCode():location.getInstitutionName())
.put("effectiveLocationDiscoveryDisplayName", location.getDiscoveryDisplayName());

var primaryServicePoint = location.getPrimaryServicePoint();
Expand Down
17 changes: 17 additions & 0 deletions src/test/java/api/loans/CheckInByBarcodeTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,23 @@ void canCheckInAnDcbItem() {
itemFromResponse.getString("barcode"), is(barcode));
}

@Test
void slipContainsLendingLibraryCodeForDcb() {
final UUID checkInServicePointId = servicePointsFixture.cd1().getId();
IndividualResource instance = instancesFixture.basedUponDunkirk();
IndividualResource holdings = holdingsFixture.defaultWithHoldings(instance.getId());
IndividualResource locationsResource = locationsFixture.mainFloor();
var barcode = "100002222";
var lendingLibraryCode = "11223";
final IndividualResource circulationItem = circulationItemsFixture.createCirculationItemWithLandingLibrary(barcode, holdings.getId(), locationsResource.getId(), lendingLibraryCode);

final CheckInByBarcodeResponse checkInResponse = checkInFixture.checkInByBarcode(circulationItem, ZonedDateTime.now(), checkInServicePointId);
JsonObject staffSlipContext = checkInResponse.getStaffSlipContext();
JsonObject itemContext = staffSlipContext.getJsonObject("item");

assertThat(itemContext.getString("effectiveLocationInstitution"), is(lendingLibraryCode));
}

@Test
void canCheckInAnItemWithoutAnOpenLoan() {
final UUID checkInServicePointId = servicePointsFixture.cd1().getId();
Expand Down
12 changes: 12 additions & 0 deletions src/test/java/api/support/builders/CirculationItemsBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,18 @@ public CirculationItemsBuilder withLocationId(UUID locationId) {
this.lendingLibraryCode);
}

public CirculationItemsBuilder withLendingLibraryCode(String lendingLibraryCode) {
return new CirculationItemsBuilder(
this.itemId,
this.barcode,
this.holdingId,
this.locationId,
this.materialTypeId,
this.loanTypeId,
this.isDcb,
lendingLibraryCode);
}

public CirculationItemsBuilder withLoanType(UUID loanTypeId) {
return new CirculationItemsBuilder(
this.itemId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,11 @@ public IndividualResource createCirculationItem(String barcode, UUID holdingId,
.withLocationId(locationId);
return circulationItemClient.create(circulationItemsBuilder);
}

public IndividualResource createCirculationItemWithLandingLibrary(String barcode, UUID holdingId, UUID locationId, String landingLibrary) {
CirculationItemsBuilder circulationItemsBuilder = new CirculationItemsBuilder().withBarcode(barcode).withHoldingId(holdingId)
.withLoanType(loanTypesFixture.canCirculate().getId()).withMaterialType(materialTypesFixture.book().getId())
.withLocationId(locationId).withLendingLibraryCode(landingLibrary);
return circulationItemClient.create(circulationItemsBuilder);
}
}

0 comments on commit d7bd9a6

Please sign in to comment.