Bug 39405: (follow-up) Add the parameter borrowernumber to the overwrite_calc_fine plugin hook

This patch adds the borrowernumber as a parameter to the overwrite_calc_fine
plugin hook. E.g., the borrower is needed for calculating graduated fines.

Sponsored-by: Karlsruhe Institute of Technology (KIT)
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 936b5650c5)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
Raphael Straub 2025-04-01 13:39:01 +00:00 committed by Paul Derscheid
parent 0303621e7d
commit 6835058093
No known key found for this signature in database
GPG Key ID: C25F9FD44CED595B
3 changed files with 14 additions and 6 deletions

View File

@ -228,11 +228,12 @@ sub CalcFine {
my @fines = grep { defined $_ } Koha::Plugins->call(
'overwrite_calc_fine',
{
itemnumber => $item->{itemnumber},
categorycode => $bortype,
branchcode => $branchcode,
due_date => $due_dt,
end_date => $end_date,
itemnumber => $item->{itemnumber},
borrowernumber => $item->{borrowernumber},
categorycode => $bortype,
branchcode => $branchcode,
due_date => $due_dt,
end_date => $end_date,
}
);

View File

@ -54,6 +54,7 @@ subtest 'overwrite_calc_fine hook tests' => sub {
my $library = $builder->build_object( { class => 'Koha::Libraries', } );
my $category = $builder->build_object( { class => 'Koha::Patron::Categories', } );
my $item = $builder->build_sample_item;
my $patron = $builder->build_object( { class => 'Koha::Patrons', } );
Koha::Plugins->new->InstallPlugins();
my $test_plugin = Koha::Plugin::Test->new->disable();
@ -129,13 +130,18 @@ subtest 'overwrite_calc_fine hook tests' => sub {
$empty_value_plugin->disable();
$bad_value_plugin->disable();
my $borrowernumber = $patron->borrowernumber;
my $overdue = $item->unblessed;
$overdue->{borrowernumber} = $borrowernumber;
my $itemnumber = $item->itemnumber;
my $branchcode = $library->branchcode;
my $categorycode = $category->categorycode;
warnings_like { CalcFine( $item->unblessed, $category->categorycode, $library->branchcode, $due_date, $end_date ); }
warnings_like { CalcFine( $overdue, $category->categorycode, $library->branchcode, $due_date, $end_date ); }
[
qr/itemnumber:$itemnumber/,
qr/borrowernumber:$borrowernumber/,
qr/branchcode:$branchcode/,
qr/categorycode:$categorycode/,
qr/due_date_type:DateTime/,

View File

@ -458,6 +458,7 @@ sub overwrite_calc_fine {
my ( $self, $params ) = @_;
warn "itemnumber:" . $params->{itemnumber};
warn "borrowernumber:" . $params->{borrowernumber};
warn "branchcode:" . $params->{branchcode};
warn "categorycode:" . $params->{categorycode};
warn "due_date_type:" . ref( $params->{due_date} );