diff --git a/CHANGELOG.md b/CHANGELOG.md index b1d46db2..e7e75a48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,9 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [4.7.0] +### Added +- Add new SIP config option hold_notification. Defaults to enabled, set to 0 to disable ## [4.6.0] [r23.04] ### Added diff --git a/lib/Libki.pm b/lib/Libki.pm index 03348ff6..123217b3 100644 --- a/lib/Libki.pm +++ b/lib/Libki.pm @@ -11,7 +11,7 @@ use DateTime::Format::MySQL; use DateTime; use File::Slurp; -our $VERSION = '4.5.0'; +our $VERSION = '4.7.0'; # Set flags and add plugins for the application. # diff --git a/lib/Libki/SIP.pm b/lib/Libki/SIP.pm index 8935ec85..d75ca8d1 100644 --- a/lib/Libki/SIP.pm +++ b/lib/Libki/SIP.pm @@ -371,19 +371,23 @@ sub sip_message_to_hashref { $patron_status->{too_many_items_billed} = substr( $patron_status_field, 13, 1 ); - my $hold_items_count = substr( $fixed_fields, 37, 4 ); - my $unavailable_holds_count = substr( $fixed_fields, 57, 4 ); - pop(@parts); my %fields = map { substr( $_, 0, 2 ) => substr( $_, 2 ) } @parts; $fields{patron_status} = $patron_status; - my $ils = $config->{SIP}->{ILS}; - $fields{hold_items_count} - = $ils eq 'Koha' ? $hold_items_count - : $ils eq 'Evergreen' ? $hold_items_count - $unavailable_holds_count - : $hold_items_count; + $fields{hold_items_count} = 0; + my $hold_notification = $config->{SIP}->{hold_notification} // 1; + if ($hold_notification) { + my $hold_items_count = substr( $fixed_fields, 37, 4 ); + my $unavailable_holds_count = substr( $fixed_fields, 57, 4 ); + + my $ils = $config->{SIP}->{ILS}; + $fields{hold_items_count} + = $ils eq 'Koha' ? $hold_items_count + : $ils eq 'Evergreen' ? $hold_items_count - $unavailable_holds_count + : $hold_items_count; + } return \%fields; }