View | Details | Raw Unified | Return to bug 24759
Collapse All | Expand All

(-)a/C4/Circulation.pm (-1 / +1 lines)
Lines 3052-3058 sub AddRenewal { Link Here
3052
        # Add the renewal to stats
3052
        # Add the renewal to stats
3053
        UpdateStats(
3053
        UpdateStats(
3054
            {
3054
            {
3055
                branch         => $item_object->renewalbranch({branch => $branch}),
3055
                branch         => $item_object->renewal_branchcode({branch => $branch}),
3056
                type           => 'renew',
3056
                type           => 'renew',
3057
                amount         => $charge,
3057
                amount         => $charge,
3058
                itemnumber     => $itemnumber,
3058
                itemnumber     => $itemnumber,
(-)a/Koha/Item.pm (-8 / +8 lines)
Lines 490-519 sub as_marc_field { Link Here
490
    return $field;
490
    return $field;
491
}
491
}
492
492
493
=head3 renewalbranch
493
=head3 renewal_branchcode
494
494
495
Returns the branch to be recorded in statistics renewal of the item
495
Returns the branchcode to be recorded in statistics renewal of the item
496
496
497
=cut
497
=cut
498
498
499
sub renewalbranch {
499
sub renewal_branchcode {
500
500
501
    my ($self, $params ) = @_;
501
    my ($self, $params ) = @_;
502
502
503
    my $interface = C4::Context->interface;
503
    my $interface = C4::Context->interface;
504
    my $branchcode;
504
    my $branchcode;
505
    if ( $interface eq 'opac' ){
505
    if ( $interface eq 'opac' ){
506
        my $renewalbranch = C4::Context->preference('OpacRenewalBranch');
506
        my $renewal_branchcode = C4::Context->preference('OpacRenewalBranch');
507
        if( !defined $renewalbranch || $renewalbranch eq 'opacrenew' ){
507
        if( !defined $renewal_branchcode || $renewal_branchcode eq 'opacrenew' ){
508
            $branchcode = 'OPACRenew';
508
            $branchcode = 'OPACRenew';
509
        }
509
        }
510
        elsif ( $renewalbranch eq 'itemhomebranch' ) {
510
        elsif ( $renewal_branchcode eq 'itemhomebranch' ) {
511
            $branchcode = $self->homebranch;
511
            $branchcode = $self->homebranch;
512
        }
512
        }
513
        elsif ( $renewalbranch eq 'patronhomebranch' ) {
513
        elsif ( $renewal_branchcode eq 'patronhomebranch' ) {
514
            $branchcode = $self->checkout->patron->branchcode;
514
            $branchcode = $self->checkout->patron->branchcode;
515
        }
515
        }
516
        elsif ( $renewalbranch eq 'checkoutbranch' ) {
516
        elsif ( $renewal_branchcode eq 'checkoutbranch' ) {
517
            $branchcode = $self->checkout->branchcode;
517
            $branchcode = $self->checkout->branchcode;
518
        }
518
        }
519
        else {
519
        else {
(-)a/t/db_dependent/Koha/Item.t (-15 / +14 lines)
Lines 330-336 subtest 'pickup_locations' => sub { Link Here
330
    $schema->storage->txn_rollback;
330
    $schema->storage->txn_rollback;
331
};
331
};
332
332
333
subtest 'renewalbranch' => sub {
333
subtest 'renewal_branchcode' => sub {
334
    plan tests => 15;
334
    plan tests => 15;
335
335
336
    $schema->storage->txn_begin;
336
    $schema->storage->txn_begin;
Lines 348-378 subtest 'renewalbranch' => sub { Link Here
348
    C4::Context->interface( 'intranet' );
348
    C4::Context->interface( 'intranet' );
349
    t::lib::Mocks::mock_userenv({ branchcode => $branch->branchcode });
349
    t::lib::Mocks::mock_userenv({ branchcode => $branch->branchcode });
350
350
351
    is( $item->renewalbranch, $branch->branchcode, "If interface not opac, we get the branch from context");
351
    is( $item->renewal_branchcode, $branch->branchcode, "If interface not opac, we get the branch from context");
352
    is( $item->renewalbranch({ branch => "PANDA"}), $branch->branchcode, "If interface not opac, we get the branch from context even if we pass one in");
352
    is( $item->renewal_branchcode({ branch => "PANDA"}), $branch->branchcode, "If interface not opac, we get the branch from context even if we pass one in");
353
    C4::Context->set_userenv(51, 'userid4tests', undef, 'firstname', 'surname', undef, undef, 0, undef, undef, undef ); #mock userenv doesn't let us set null branch
353
    C4::Context->set_userenv(51, 'userid4tests', undef, 'firstname', 'surname', undef, undef, 0, undef, undef, undef ); #mock userenv doesn't let us set null branch
354
    is( $item->renewalbranch({ branch => "PANDA"}), "PANDA", "If interface not opac, we get the branch we pass one in if context not set");
354
    is( $item->renewal_branchcode({ branch => "PANDA"}), "PANDA", "If interface not opac, we get the branch we pass one in if context not set");
355
355
356
    C4::Context->interface( 'opac' );
356
    C4::Context->interface( 'opac' );
357
357
358
    t::lib::Mocks::mock_preference('OpacRenewalBranch', undef);
358
    t::lib::Mocks::mock_preference('OpacRenewalBranch', undef);
359
    is( $item->renewalbranch, 'OPACRenew', "If interface opac and OpacRenewalBranch undef, we get OPACRenew");
359
    is( $item->renewal_branchcode, 'OPACRenew', "If interface opac and OpacRenewalBranch undef, we get OPACRenew");
360
    is( $item->renewalbranch({branch=>'COW'}), 'OPACRenew', "If interface opac and OpacRenewalBranch undef, we get OPACRenew even if branch passed");
360
    is( $item->renewal_branchcode({branch=>'COW'}), 'OPACRenew', "If interface opac and OpacRenewalBranch undef, we get OPACRenew even if branch passed");
361
361
362
    t::lib::Mocks::mock_preference('OpacRenewalBranch', 'none');
362
    t::lib::Mocks::mock_preference('OpacRenewalBranch', 'none');
363
    is( $item->renewalbranch, '', "If interface opac and OpacRenewalBranch is none, we get blank string");
363
    is( $item->renewal_branchcode, '', "If interface opac and OpacRenewalBranch is none, we get blank string");
364
    is( $item->renewalbranch({branch=>'COW'}), '', "If interface opac and OpacRenewalBranch is none, we get blank string even if branch passed");
364
    is( $item->renewal_branchcode({branch=>'COW'}), '', "If interface opac and OpacRenewalBranch is none, we get blank string even if branch passed");
365
365
366
    t::lib::Mocks::mock_preference('OpacRenewalBranch', 'checkoutbranch');
366
    t::lib::Mocks::mock_preference('OpacRenewalBranch', 'checkoutbranch');
367
    is( $item->renewalbranch, $checkout->branchcode, "If interface opac and OpacRenewalBranch set to checkoutbranch, we get branch of checkout");
367
    is( $item->renewal_branchcode, $checkout->branchcode, "If interface opac and OpacRenewalBranch set to checkoutbranch, we get branch of checkout");
368
    is( $item->renewalbranch({branch=>'MONKEY'}), $checkout->branchcode, "If interface opac and OpacRenewalBranch set to checkoutbranch, we get branch of checkout even if branch passed");
368
    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");
369
369
370
    t::lib::Mocks::mock_preference('OpacRenewalBranch','patronhomebranch');
370
    t::lib::Mocks::mock_preference('OpacRenewalBranch','patronhomebranch');
371
    is( $item->renewalbranch, $checkout->patron->branchcode, "If interface opac and OpacRenewalBranch set to patronbranch, we get branch of patron");
371
    is( $item->renewal_branchcode, $checkout->patron->branchcode, "If interface opac and OpacRenewalBranch set to patronbranch, we get branch of patron");
372
    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");
372
    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");
373
373
374
    t::lib::Mocks::mock_preference('OpacRenewalBranch','itemhomebranch');
374
    t::lib::Mocks::mock_preference('OpacRenewalBranch','itemhomebranch');
375
    is( $item->renewalbranch, $item->homebranch, "If interface opac and OpacRenewalBranch set to itemhomebranch, we get homebranch of item");
375
    is( $item->renewal_branchcode, $item->homebranch, "If interface opac and OpacRenewalBranch set to itemhomebranch, we get homebranch of item");
376
    is( $item->renewalbranch({branch=>'MANATEE'}), $item->homebranch, "If interface opac and OpacRenewalBranch set to itemhomebranch, we get homebranch of item even if branch passed");
376
    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");
377
377
378
};
378
};
379
- 

Return to bug 24759