From 303deda8d3ecf93c5efeb7e3afca01a771c22c83 Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Tue, 7 Dec 2021 09:41:01 +0000 Subject: [PATCH] Bug 41649: Set magnetic_media in SIP responses The `magnetic_media` flag was never set, it can be set from `sip_media_type` if it's present. `sip_media_type` is set via the Authorized Values system. Checkins will not be sorted correctly by Biblioteca without this flag. Sponsored-by: OpenFifth Signed-off-by: Marcus Michel Signed-off-by: Kyle M Hall Signed-off-by: Pedro Amorim --- C4/SIP/ILS/Item.pm | 7 ++++++- C4/SIP/Sip/MsgType.pm | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/C4/SIP/ILS/Item.pm b/C4/SIP/ILS/Item.pm index 4aadb99f22..36d505c396 100644 --- a/C4/SIP/ILS/Item.pm +++ b/C4/SIP/ILS/Item.pm @@ -106,7 +106,12 @@ sub new { my $it = $item->effective_itemtype; $self->{itemtype} = $it; my $itemtype = Koha::Database->new()->schema()->resultset('Itemtype')->find($it); - $self->{sip_media_type} = $itemtype->sip_media_type() if $itemtype; + if ($itemtype) { + $self->{sip_media_type} = $itemtype->sip_media_type; + if ( defined( $self->{sip_media_type} ) && $self->{sip_media_type} =~ m/^(00[4578]|010)/ ) { + $self->{magnetic_media} = 1; + } + } # check if its on issue and if so get the borrower my $issue = Koha::Checkouts->find( { itemnumber => $item->itemnumber } ); diff --git a/C4/SIP/Sip/MsgType.pm b/C4/SIP/Sip/MsgType.pm index d86c0bfbf1..4c3884599d 100644 --- a/C4/SIP/Sip/MsgType.pm +++ b/C4/SIP/Sip/MsgType.pm @@ -756,7 +756,7 @@ sub handle_checkin { $resp .= 'U'; } - $resp .= $status->alert ? 'Y' : 'N'; + $resp .= ( $status->alert || $item->magnetic_media ) ? 'Y' : 'N'; $resp .= timestamp; $resp .= add_field( FID_INST_ID, $inst_id, $server ); $resp .= add_field( FID_ITEM_ID, $item_id, $server );