Bug 22321: Update holds borrowernumber when ILL request borrowernumber changes

To test:
1. prove t/db_dependent/Illrequests.t

Signed-off-by: Magnus Enger <magnus@libriotech.no>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Lari Taskula 2022-02-14 11:16:31 +00:00 committed by Tomas Cohen Arazi
parent 794b2dd81c
commit c10aaa9d33
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
1 changed files with 21 additions and 0 deletions

View File

@ -1758,8 +1758,29 @@ possibly records the fact that something happened
sub store {
my ( $self, $attrs ) = @_;
my %updated_columns = $self->_result->get_dirty_columns;
my @holds;
if( defined $updated_columns{'borrowernumber'} and
Koha::Patrons->find( $updated_columns{'borrowernumber'} ) )
{
# borrowernumber has changed
my $old_illreq = $self->get_from_storage;
@holds = Koha::Holds->search( {
borrowernumber => $old_illreq->borrowernumber,
biblionumber => $self->biblio_id,
} )->as_list;
}
my $ret = $self->SUPER::store;
if ( scalar @holds ) {
# move holds to the changed borrowernumber
foreach my $hold ( @holds ) {
$hold->borrowernumber( $updated_columns{'borrowernumber'} )->store;
}
}
$attrs->{log_origin} = 'core';
if ($ret && defined $attrs) {