From 55ab52d49f23f2ecd9017d3a5dbfad2686ef360d Mon Sep 17 00:00:00 2001 From: Christina Chortaria Date: Thu, 12 Sep 2024 18:46:01 -0400 Subject: [PATCH] Set attr_reader and instance var for item_location_code Pass it to holding_data --- app/models/requests/form.rb | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/app/models/requests/form.rb b/app/models/requests/form.rb index da852313a..6d0ca835c 100644 --- a/app/models/requests/form.rb +++ b/app/models/requests/form.rb @@ -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 @@ -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 @@ -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