Bug 37901: Consider illrequest_id when creating or completing

When a new PseudonymizedTransaction is created, consider the presence of illrequest_id and act on it accordingly.

Signed-off-by: Jeremy Evans <Jeremy.Evans@ukhsa.gov.uk>
Signed-off-by: Lisette Scheer <lisette@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Pedro Amorim 2025-03-03 15:30:11 -01:00 committed by Lucas Gass
parent 1b505dfa34
commit e2c8c4bdc9
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
1 changed files with 35 additions and 0 deletions

View File

@ -22,6 +22,7 @@ use List::MoreUtils qw(any);
use Koha::Database;
use Koha::Exceptions::Config;
use Koha::Patrons;
use Koha::ILL::Requests;
use base qw(Koha::Object);
@ -120,6 +121,40 @@ sub create_from_statistic {
}
}
if ( $statistic->illrequest_id ) {
my $illrequest = Koha::ILL::Requests->find( $statistic->illrequest_id );
if ($illrequest) {
my @illattributes_to_pseudonymize = qw(
type
);
my $extended_attributes_to_pseudonymize =
$illrequest->extended_attributes->search( { type => { -in => \@illattributes_to_pseudonymize } } );
while ( my $attribute = $extended_attributes_to_pseudonymize->next ) {
$self->_result->create_related(
'pseudonymized_metadata_values',
{
key => $attribute->type,
value => $attribute->value,
tablename => 'illrequestattributes',
}
);
}
if ( $illrequest->backend ) {
$self->_result->create_related(
'pseudonymized_metadata_values',
{
key => 'backend',
value => $illrequest->backend,
tablename => 'illrequestattributes',
}
);
}
}
}
return $self;
}