Skip to content

Commit

Permalink
all tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
charmingduchess committed Mar 5, 2025
1 parent cfa9742 commit 5833168
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions lib/requestability_resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ class RequestabilityResolver {
const deliveryInfo = itemIsInRecap
? DeliveryLocationsResolver.getRecapDeliveryInfo(item)
: DeliveryLocationsResolver.getOnsiteDeliveryInfo(item)

const numDeliveryLocations = deliveryInfo.deliveryLocation?.length
item.specRequestable = this.buildSpecRequestable(item, parentBibHasFindingAid)
item.physRequestable = this.buildPhysRequestable(item, deliveryInfo)
item.physRequestable = this.buildPhysRequestable(item, numDeliveryLocations)
item.eddRequestable = !!deliveryInfo.eddRequestable && !item.specRequestable
item.requestable = [item.eddRequestable || item.physRequestable || item.specRequestable]
return item
Expand All @@ -25,16 +25,26 @@ class RequestabilityResolver {
return elasticSearchResponse
}

static buildPhysRequestable (item, deliveryInfo) {
static buildPhysRequestable (item, numDeliveryLocations) {
let physRequestableCriteria
let physRequestable
const hasRecapCustomerCode = item.recapCustomerCode?.[0]
const itemIsInRecapMissingRecapCustomerCode = isInRecap(item) && !hasRecapCustomerCode
// recap items missing codes should default to true for phys and edd
// requestable, unless it has a non-requestable holding location
if (itemIsInRecapMissingRecapCustomerCode) physRequestableCriteria = 'Missing customer code'
if (deliveryInfo.deliveryLocation?.length > 0) physRequestableCriteria = `${(deliveryInfo.deliveryLocation?.length) || 0} delivery locations.`
physRequestable = itemIsInRecapMissingRecapCustomerCode || !!deliveryInfo.deliveryLocation?.length
if (itemIsInRecapMissingRecapCustomerCode) {
physRequestable = true
physRequestableCriteria = 'Missing customer code'
}
if (numDeliveryLocations > 0) {
physRequestableCriteria = `${numDeliveryLocations} delivery locations.`
physRequestable = true
}
if (!numDeliveryLocations) {
physRequestableCriteria = 'No delivery locations.'
physRequestable = false
}
// physRequestable = itemIsInRecapMissingRecapCustomerCode || !!deliveryInfo.deliveryLocation?.length
// items without barcodes should not be requestable
const hasBarcode = (item.identifier || []).some((identifier) => /^(urn|bf):[bB]arcode:\w+/.test(identifier))
if (isItemNyplOwned(item) && !hasBarcode) {
Expand Down

0 comments on commit 5833168

Please sign in to comment.