Skip to content

Commit

Permalink
Set attr_reader and instance var for item_location_code
Browse files Browse the repository at this point in the history
Pass it to holding_data
  • Loading branch information
christinach committed Sep 13, 2024
1 parent 68f02e5 commit 55ab52d
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions app/models/requests/form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,9 @@ def build_requestable_from_mfhd_items(requestable_items:, holding_id:, mfhd_item
requestable_items.compact
end

def holding_data(item, holding_id)
def holding_data(item, holding_id, item_location_code)
if item["in_temp_library"] && item["temp_location_code"] != "RES_SHARE$IN_RS_REQ"
holdings[item_loc]
holdings[item_location_code]
else
holdings[holding_id]
end
Expand All @@ -263,12 +263,12 @@ def holding_data(item, holding_id)
# Item we get from the 'load_items' live call to bibdata
def build_requestable_mfhd_item(holding_id, item, barcodesort)
return if item['on_reserve'] == 'Y'

item['status_label'] = barcodesort[item['barcode']][:status_label] unless barcodesort.empty?
item_current_location = item_current_location(item)
params = build_requestable_params(
item: item.with_indifferent_access,
holding: Holding.new(mfhd_id: holding_id.to_sym.to_s, holding_data: holding_data(item, holding_id)),
location: item_current_location(item)
holding: Holding.new(mfhd_id: holding_id.to_sym.to_s, holding_data: holding_data(item, holding_id, item_location_code)),
location: item_current_location
)
Requests::Requestable.new(**params)
end
Expand Down Expand Up @@ -345,12 +345,13 @@ def items_to_symbols(items = [])
end

def item_current_location(item)
item_location_code = if item['in_temp_library']
item['temp_location_code']
else
item['location']
end
@item_location_code = if item['in_temp_library']
item['temp_location_code']
else
item['location']
end
get_current_location(item_location_code:)
end
attr_reader :item_location_code
end
end

0 comments on commit 55ab52d

Please sign in to comment.