Skip to content

Commit

Permalink
Merge pull request #996 from sul-dlss/768-on-order-migrated-data
Browse files Browse the repository at this point in the history
Add stub on-order holdings for FOLIO for instances with only on-order holdings
  • Loading branch information
jcoyne authored Jul 21, 2023
2 parents 9e7e5e0 + 5f7603a commit d268d43
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 2 deletions.
26 changes: 25 additions & 1 deletion lib/folio_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def sirsi_holdings
public_note: item['notes']&.map { |n| ".#{n['itemNoteTypeName']&.upcase}. #{n['note']}" }&.join("\n"),
tag: item
)
end.concat(bound_with_holdings).concat(eresource_holdings)
end.concat(bound_with_holdings).concat(eresource_holdings).concat(on_order_stub_holdings)
end

# since FOLIO Bound-with records don't have items, we generate a SirsiHolding using data from the parent item and child holding
Expand Down Expand Up @@ -135,6 +135,30 @@ def eresource_holdings
Folio::EresourceHoldingsBuilder.build(hrid, holdings, marc_record)
end

def on_order_stub_holdings
return [] if items.any?

on_order_only_holdings = holdings.select do |holding|
items.none? { |item| item['holdingRecordId'] == holding['id'] } && pieces.any? { |p| p['holdingId'] == holding['id'] && p['receivingStatus'] == 'Expected' && !p['discoverySuppress'] }
end

item_location_codes = on_order_only_holdings.map { |holding| holding.dig('location', 'effectiveLocation', 'code') }.uniq

item_location_codes.map do |item_location_code|
library_code, = LocationsMap.for(item_location_code)

SirsiHolding.new(
barcode: '',
call_number: '',
scheme: '',
current_location: 'ON-ORDER',
home_location: 'ON-ORDER',
library: library_code,
tag: {}
)
end
end

def call_number_type_map(name)
case name
when /dewey/i
Expand Down
2 changes: 1 addition & 1 deletion lib/sirsi_holding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def ignored_call_number?
def temp_call_number?
return false if library == 'HV-ARCHIVE' # Call numbers in HV-ARCHIVE are not temporary

call_number.to_s.start_with?(TEMP_CALLNUM_PREFIX)
call_number.to_s.blank? || call_number.to_s.start_with?(TEMP_CALLNUM_PREFIX)
end

def e_call_number?
Expand Down
39 changes: 39 additions & 0 deletions spec/lib/folio_record_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,43 @@
end
end
end

describe '#sirsi_holdings' do
context 'with Symphony migrated data without on-order item records' do
let(:record) do
{
'instance' => {
'id' => '0e050e3f-b160-5f5d-9fdb-2d49305fbb0d'
},
'pieces' => [{ 'id' => '3b0c1675-b3ec-4bc4-888d-2519fb72b71f',
'holdingId' => '1146c4fa-5798-40e1-9b8e-92ee4c9f2ee2',
'receivingStatus' => 'Expected',
'displayOnHolding' => false }],
'holdings' => [{
'id' => '1146c4fa-5798-40e1-9b8e-92ee4c9f2ee2',
'location' => {
'effectiveLocation' => {
'code' => 'GRE-STACKS'
}
}
}],
'items' => [],
'source_record' => [{
'fields' => [
{ '001' => 'a14154194' }
]
}]
}
end

it 'creates a stub on-order item' do
expect(folio_record.sirsi_holdings.first).to have_attributes(
barcode: '',
current_location: 'ON-ORDER',
home_location: 'ON-ORDER',
library: 'GREEN'
)
end
end
end
end

0 comments on commit d268d43

Please sign in to comment.