@@ -, +, @@ --- C4/Circulation.pm | 2 +- Koha/Item.pm | 16 ++++++++-------- t/db_dependent/Koha/Item.t | 28 ++++++++++++++-------------- 3 files changed, 23 insertions(+), 23 deletions(-) --- a/C4/Circulation.pm +++ a/C4/Circulation.pm @@ -3052,7 +3052,7 @@ sub AddRenewal { # Add the renewal to stats UpdateStats( { - branch => $item_object->renewalbranch({branch => $branch}), + branch => $item_object->renewal_branchcode({branch => $branch}), type => 'renew', amount => $charge, itemnumber => $itemnumber, --- a/Koha/Item.pm +++ a/Koha/Item.pm @@ -490,30 +490,30 @@ sub as_marc_field { return $field; } -=head3 renewalbranch +=head3 renewal_branchcode -Returns the branch to be recorded in statistics renewal of the item +Returns the branchcode to be recorded in statistics renewal of the item =cut -sub renewalbranch { +sub renewal_branchcode { my ($self, $params ) = @_; my $interface = C4::Context->interface; my $branchcode; if ( $interface eq 'opac' ){ - my $renewalbranch = C4::Context->preference('OpacRenewalBranch'); - if( !defined $renewalbranch || $renewalbranch eq 'opacrenew' ){ + my $renewal_branchcode = C4::Context->preference('OpacRenewalBranch'); + if( !defined $renewal_branchcode || $renewal_branchcode eq 'opacrenew' ){ $branchcode = 'OPACRenew'; } - elsif ( $renewalbranch eq 'itemhomebranch' ) { + elsif ( $renewal_branchcode eq 'itemhomebranch' ) { $branchcode = $self->homebranch; } - elsif ( $renewalbranch eq 'patronhomebranch' ) { + elsif ( $renewal_branchcode eq 'patronhomebranch' ) { $branchcode = $self->checkout->patron->branchcode; } - elsif ( $renewalbranch eq 'checkoutbranch' ) { + elsif ( $renewal_branchcode eq 'checkoutbranch' ) { $branchcode = $self->checkout->branchcode; } else { --- a/t/db_dependent/Koha/Item.t +++ a/t/db_dependent/Koha/Item.t @@ -330,7 +330,7 @@ subtest 'pickup_locations' => sub { $schema->storage->txn_rollback; }; -subtest 'renewalbranch' => sub { +subtest 'renewal_branchcode' => sub { plan tests => 15; $schema->storage->txn_begin; @@ -348,31 +348,31 @@ subtest 'renewalbranch' => sub { C4::Context->interface( 'intranet' ); t::lib::Mocks::mock_userenv({ branchcode => $branch->branchcode }); - is( $item->renewalbranch, $branch->branchcode, "If interface not opac, we get the branch from context"); - is( $item->renewalbranch({ branch => "PANDA"}), $branch->branchcode, "If interface not opac, we get the branch from context even if we pass one in"); + is( $item->renewal_branchcode, $branch->branchcode, "If interface not opac, we get the branch from context"); + is( $item->renewal_branchcode({ branch => "PANDA"}), $branch->branchcode, "If interface not opac, we get the branch from context even if we pass one in"); C4::Context->set_userenv(51, 'userid4tests', undef, 'firstname', 'surname', undef, undef, 0, undef, undef, undef ); #mock userenv doesn't let us set null branch - is( $item->renewalbranch({ branch => "PANDA"}), "PANDA", "If interface not opac, we get the branch we pass one in if context not set"); + is( $item->renewal_branchcode({ branch => "PANDA"}), "PANDA", "If interface not opac, we get the branch we pass one in if context not set"); C4::Context->interface( 'opac' ); t::lib::Mocks::mock_preference('OpacRenewalBranch', undef); - is( $item->renewalbranch, 'OPACRenew', "If interface opac and OpacRenewalBranch undef, we get OPACRenew"); - is( $item->renewalbranch({branch=>'COW'}), 'OPACRenew', "If interface opac and OpacRenewalBranch undef, we get OPACRenew even if branch passed"); + is( $item->renewal_branchcode, 'OPACRenew', "If interface opac and OpacRenewalBranch undef, we get OPACRenew"); + is( $item->renewal_branchcode({branch=>'COW'}), 'OPACRenew', "If interface opac and OpacRenewalBranch undef, we get OPACRenew even if branch passed"); t::lib::Mocks::mock_preference('OpacRenewalBranch', 'none'); - is( $item->renewalbranch, '', "If interface opac and OpacRenewalBranch is none, we get blank string"); - is( $item->renewalbranch({branch=>'COW'}), '', "If interface opac and OpacRenewalBranch is none, we get blank string even if branch passed"); + is( $item->renewal_branchcode, '', "If interface opac and OpacRenewalBranch is none, we get blank string"); + is( $item->renewal_branchcode({branch=>'COW'}), '', "If interface opac and OpacRenewalBranch is none, we get blank string even if branch passed"); t::lib::Mocks::mock_preference('OpacRenewalBranch', 'checkoutbranch'); - is( $item->renewalbranch, $checkout->branchcode, "If interface opac and OpacRenewalBranch set to checkoutbranch, we get branch of checkout"); - is( $item->renewalbranch({branch=>'MONKEY'}), $checkout->branchcode, "If interface opac and OpacRenewalBranch set to checkoutbranch, we get branch of checkout even if branch passed"); + is( $item->renewal_branchcode, $checkout->branchcode, "If interface opac and OpacRenewalBranch set to checkoutbranch, we get branch of checkout"); + is( $item->renewal_branchcode({branch=>'MONKEY'}), $checkout->branchcode, "If interface opac and OpacRenewalBranch set to checkoutbranch, we get branch of checkout even if branch passed"); t::lib::Mocks::mock_preference('OpacRenewalBranch','patronhomebranch'); - is( $item->renewalbranch, $checkout->patron->branchcode, "If interface opac and OpacRenewalBranch set to patronbranch, we get branch of patron"); - is( $item->renewalbranch({branch=>'TURKEY'}), $checkout->patron->branchcode, "If interface opac and OpacRenewalBranch set to patronbranch, we get branch of patron even if branch passed"); + is( $item->renewal_branchcode, $checkout->patron->branchcode, "If interface opac and OpacRenewalBranch set to patronbranch, we get branch of patron"); + is( $item->renewal_branchcode({branch=>'TURKEY'}), $checkout->patron->branchcode, "If interface opac and OpacRenewalBranch set to patronbranch, we get branch of patron even if branch passed"); t::lib::Mocks::mock_preference('OpacRenewalBranch','itemhomebranch'); - is( $item->renewalbranch, $item->homebranch, "If interface opac and OpacRenewalBranch set to itemhomebranch, we get homebranch of item"); - is( $item->renewalbranch({branch=>'MANATEE'}), $item->homebranch, "If interface opac and OpacRenewalBranch set to itemhomebranch, we get homebranch of item even if branch passed"); + is( $item->renewal_branchcode, $item->homebranch, "If interface opac and OpacRenewalBranch set to itemhomebranch, we get homebranch of item"); + is( $item->renewal_branchcode({branch=>'MANATEE'}), $item->homebranch, "If interface opac and OpacRenewalBranch set to itemhomebranch, we get homebranch of item even if branch passed"); }; --