Skip to content

Commit

Permalink
Merge pull request #385 from NYPL/SCC-4088
Browse files Browse the repository at this point in the history
SCC-4088
  • Loading branch information
danamansana authored May 28, 2024
2 parents cf48206 + 985f593 commit 51d7f19
Show file tree
Hide file tree
Showing 5 changed files with 864 additions and 9 deletions.
11 changes: 10 additions & 1 deletion lib/delivery-locations-resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,16 @@ class DeliveryLocationsResolver {
// location is not requestable:
let deliveryLocation
let eddRequestable
if (!isItemNyplOwned(item) || this.requestableBasedOnHoldingLocation(item)) {
const hasRecapCustomerCode = item.recapCustomerCode && item.recapCustomerCode[0]
const nyplItem = isItemNyplOwned(item)
if (!hasRecapCustomerCode) {
const requestableBasedOnHoldingLocation = nyplItem ? this.requestableBasedOnHoldingLocation(item) : true
// the length of the list of delivery locations is checked later to determine physical requestability
// In case of an offsite item with no recap customer code, we want this to be based on holding location
// so we put a placeholder '' in case it is requestable based on holding location
deliveryLocation = requestableBasedOnHoldingLocation ? [''] : []
eddRequestable = requestableBasedOnHoldingLocation
} else if (!nyplItem || this.requestableBasedOnHoldingLocation(item)) {
deliveryLocation = this.deliveryLocationsByRecapCustomerCode(item.recapCustomerCode[0])
eddRequestable = this.__eddRequestableByCustomerCode(item.recapCustomerCode[0])
} else {
Expand Down
13 changes: 6 additions & 7 deletions lib/requestability_resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ class RequestabilityResolver {
const itemIsInRecap = isInRecap(item)
let physRequestableCriteria
const hasRecapCustomerCode = item.recapCustomerCode && item.recapCustomerCode[0]
if (itemIsInRecap && !hasRecapCustomerCode) {
if (itemIsInRecap) {
// recap items missing codes should default to true for phys and edd
// requestable.
physRequestableCriteria = 'Missing customer code'
deliveryInfo = { eddRequestable: true, deliveryLocation: [''] }
} else if (itemIsInRecap && hasRecapCustomerCode) {
// requestable, unless it has a non-requestable holding location
deliveryInfo = DeliveryLocationsResolver.getRecapDeliveryInfo(item)
physRequestableCriteria = `${deliveryInfo.deliveryLocation &&
deliveryInfo.deliveryLocation.length || 0} delivery locations.`
physRequestableCriteria = hasRecapCustomerCode
? `${deliveryInfo.deliveryLocation &&
deliveryInfo.deliveryLocation.length || 0} delivery locations.`
: 'Missing customer code'
} else if (!itemIsInRecap) {
deliveryInfo = DeliveryLocationsResolver.getOnsiteDeliveryInfo(item)
physRequestableCriteria = `${deliveryInfo.deliveryLocation &&
Expand Down
22 changes: 21 additions & 1 deletion test/delivery-locations-resolver.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var sampleItems = {
],
'holdingLocation': [
{
'id': 'loc:scff3',
'id': 'loc:scff2',
'prefLabel': 'Schomburg Center - Research & Reference - Desk'
}
],
Expand Down Expand Up @@ -502,4 +502,24 @@ describe('Delivery-locations-resolver', function () {
).to.equal(true)
})
})
describe('getRecapDeliveryInfo', function () {
it('returns empty deliveryLocation and eddRequestable false based on holding location when missing recapCustomerCode', function () {
const resolved = DeliveryLocationsResolver.getRecapDeliveryInfo({
holdingLocation: [{ id: 'loc:rccd8' }],
uri: 'i14747243'
})
expect(resolved.deliveryLocation.length).to.equal(0)
expect(resolved.eddRequestable).to.equal(false)
})

it('returns empty string delivery location and eddRequestable true based on holding location when missing recapCustomerCode', function () {
const resolved = DeliveryLocationsResolver.getRecapDeliveryInfo({
holdingLocation: [{ id: 'loc:rcpm2' }],
uri: 'i14747243'
})
expect(resolved.deliveryLocation.length).to.equal(1)
expect(resolved.deliveryLocation[0]).to.equal('')
expect(resolved.eddRequestable).to.equal(true)
})
})
})
Loading

0 comments on commit 51d7f19

Please sign in to comment.