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

(-)a/C4/Circulation.pm (-1 / +1 lines)
Lines 2951-2957 sub AddRenewal { Link Here
2951
    my $schema = Koha::Database->schema;
2951
    my $schema = Koha::Database->schema;
2952
    $schema->txn_do(sub{
2952
    $schema->txn_do(sub{
2953
2953
2954
        if ( !skipfinecalc && C4::Context->preference('CalculateFinesOnReturn') ) {
2954
        if ( !$skipfinecalc && C4::Context->preference('CalculateFinesOnReturn') ) {
2955
            _CalculateAndUpdateFine( { issue => $issue, item => $item_unblessed, borrower => $patron_unblessed } );
2955
            _CalculateAndUpdateFine( { issue => $issue, item => $item_unblessed, borrower => $patron_unblessed } );
2956
        }
2956
        }
2957
        _FixOverduesOnReturn( $borrowernumber, $itemnumber, undef, 'RENEWED' );
2957
        _FixOverduesOnReturn( $borrowernumber, $itemnumber, undef, 'RENEWED' );
(-)a/Koha/Account.pm (-1 / +1 lines)
Lines 125-131 sub pay { Link Here
125
            # We're ignoring the definition of $interface above, by all
125
            # We're ignoring the definition of $interface above, by all
126
            # accounts we can't rely on C4::Context::interface, so here
126
            # accounts we can't rely on C4::Context::interface, so here
127
            # we're only using what we've been explicitly passed
127
            # we're only using what we've been explicitly passed
128
            my $outcome = $fine->renew_item($params->{interface});
128
            my $outcome = $fine->renew_item({ interface => $interface });
129
            push @{$renew_outcomes}, $outcome if $outcome;
129
            push @{$renew_outcomes}, $outcome if $outcome;
130
        }
130
        }
131
131
(-)a/Koha/Account/Line.pm (-2 / +4 lines)
Lines 769-774 sub to_api_mapping { Link Here
769
        note              => 'internal_note',
769
        note              => 'internal_note',
770
    };
770
    };
771
771
772
}
773
772
=head3 renewable
774
=head3 renewable
773
775
774
    my $bool = $line->renewable;
776
    my $bool = $line->renewable;
Lines 780-787 sub renewable { Link Here
780
782
781
    return (
783
    return (
782
        $self->amountoutstanding == 0 &&
784
        $self->amountoutstanding == 0 &&
783
        $self->accounttype &&
785
        $self->debit_type_code &&
784
        $self->accounttype eq 'OVERDUE' &&
786
        $self->debit_type_code eq 'OVERDUE' &&
785
        $self->status &&
787
        $self->status &&
786
        $self->status eq 'UNRETURNED'
788
        $self->status eq 'UNRETURNED'
787
    ) ? 1 : 0;
789
    ) ? 1 : 0;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/renew_results.inc (-8 / +8 lines)
Lines 1-12 Link Here
1
[% IF renew_results && renew_results.size > 0 %]
1
[% IF renew_results && renew_results.size > 0 %]
2
    <div class="alert">
2
    <div class="alert">
3
		The fines on the following items were paid off, renewal results are displayed below:
3
        The fines on the following items were paid off, renewal results are displayed below:
4
		[% FOREACH result IN renew_results %]
4
        [% FOREACH result IN renew_results %]
5
			[% IF result.success %]
5
            [% IF result.success %]
6
				<p>[% INCLUDE 'biblio-title.inc' biblio=result.item.biblio %] ( [% result.item.barcode | html %] ): Renewed - due [% result.info | html %]</p>
6
                <p>[% INCLUDE 'biblio-title.inc' biblio=result.item.biblio %] ( [% result.item.barcode | html %] ): Renewed - due [% result.info | html %]</p>
7
			[% ELSE %]
7
            [% ELSE %]
8
				<p>[% INCLUDE 'biblio-title.inc' biblio=result.item.biblio %] ( [% result.item.barcode | html %] ): Not renewed - [% INCLUDE 'renew_strings.inc' error=result.info %]</p>
8
                <p>[% INCLUDE 'biblio-title.inc' biblio=result.item.biblio %] ( [% result.item.barcode | html %] ): Not renewed - [% INCLUDE 'renew_strings.inc' error=result.info %]</p>
9
			[% END %]
9
            [% END %]
10
		[% END %]
10
        [% END %]
11
    </div>
11
    </div>
12
[% END %]
12
[% END %]
(-)a/t/db_dependent/Circulation.t (-1 / +1 lines)
Lines 3326-3332 subtest 'AddReturn should clear items.onloan for unissued items' => sub { Link Here
3326
3326
3327
subtest 'AddRenewal and AddIssuingCharge tests' => sub {
3327
subtest 'AddRenewal and AddIssuingCharge tests' => sub {
3328
3328
3329
    plan tests => 11;
3329
    plan tests => 12;
3330
3330
3331
3331
3332
    t::lib::Mocks::mock_preference('item-level_itypes', 1);
3332
    t::lib::Mocks::mock_preference('item-level_itypes', 1);
(-)a/t/db_dependent/Koha/Account.t (-1 / +2 lines)
Lines 941-947 subtest 'pay() renews items when appropriate' => sub { Link Here
941
            borrowernumber => $patron->id,
941
            borrowernumber => $patron->id,
942
            itemnumber     => $item->id,
942
            itemnumber     => $item->id,
943
            date           => \'NOW()',
943
            date           => \'NOW()',
944
            accounttype    => 'OVERDUE',
944
            debit_type_code => 'OVERDUE',
945
            status         => 'UNRETURNED',
945
            status         => 'UNRETURNED',
946
            interface      => 'cli',
946
            interface      => 'cli',
947
            amount => '1',
947
            amount => '1',
Lines 954-959 subtest 'pay() renews items when appropriate' => sub { Link Here
954
    my $called = 0;
954
    my $called = 0;
955
    my $module = new Test::MockModule('C4::Circulation');
955
    my $module = new Test::MockModule('C4::Circulation');
956
    $module->mock('AddRenewal', sub { $called = 1; });
956
    $module->mock('AddRenewal', sub { $called = 1; });
957
    $module->mock('CanBookBeRenewed', sub { return 1; });
957
    $account->pay(
958
    $account->pay(
958
        {
959
        {
959
            amount     => '1',
960
            amount     => '1',
(-)a/t/db_dependent/Koha/Account/Line.t (-7 / +8 lines)
Lines 274-280 subtest 'apply() tests' => sub { Link Here
274
            itemnumber     => $item->id,
274
            itemnumber     => $item->id,
275
            branchcode     => $library->id,
275
            branchcode     => $library->id,
276
            date           => \'NOW()',
276
            date           => \'NOW()',
277
            accounttype    => 'OVERDUE',
277
            debit_type_code => 'OVERDUE',
278
            status         => 'UNRETURNED',
278
            status         => 'UNRETURNED',
279
            interface      => 'cli',
279
            interface      => 'cli',
280
            amount => '1',
280
            amount => '1',
Lines 287-292 subtest 'apply() tests' => sub { Link Here
287
    my $called = 0;
287
    my $called = 0;
288
    my $module = new Test::MockModule('C4::Circulation');
288
    my $module = new Test::MockModule('C4::Circulation');
289
    $module->mock('AddRenewal', sub { $called = 1; });
289
    $module->mock('AddRenewal', sub { $called = 1; });
290
    $module->mock('CanBookBeRenewed', sub { return 1; });
290
    my $credit_renew = $account->add_credit({ amount => 100, user_id => $patron->id, interface => 'commandline' });
291
    my $credit_renew = $account->add_credit({ amount => 100, user_id => $patron->id, interface => 'commandline' });
291
    my $debits_renew = Koha::Account::Lines->search({ accountlines_id => $accountline->id })->as_list;
292
    my $debits_renew = Koha::Account::Lines->search({ accountlines_id => $accountline->id })->as_list;
292
    $credit_renew->apply( { debits => $debits_renew, offset_type => 'Manual Credit' } );
293
    $credit_renew->apply( { debits => $debits_renew, offset_type => 'Manual Credit' } );
Lines 336-342 subtest 'Keep account info when related patron, staff, item or cash_register is Link Here
336
337
337
    $patron->delete;
338
    $patron->delete;
338
    $line = $line->get_from_storage;
339
    $line = $line->get_from_storage;
339
    is( $line->borro1wernumber, undef, "The account line should not be deleted when the related patron is delete");
340
    is( $line->borrowernumber, undef, "The account line should not be deleted when the related patron is delete");
340
341
341
    $register->delete;
342
    $register->delete;
342
    $line = $line->get_from_storage;
343
    $line = $line->get_from_storage;
Lines 370-376 subtest 'Renewal related tests' => sub { Link Here
370
        borrowernumber    => $patron->borrowernumber,
371
        borrowernumber    => $patron->borrowernumber,
371
        manager_id        => $staff->borrowernumber,
372
        manager_id        => $staff->borrowernumber,
372
        itemnumber        => $item->itemnumber,
373
        itemnumber        => $item->itemnumber,
373
        accounttype       => "OVERDUE",
374
        debit_type_code   => "OVERDUE",
374
        status            => "UNRETURNED",
375
        status            => "UNRETURNED",
375
        amountoutstanding => 0,
376
        amountoutstanding => 0,
376
        interface         => 'commandline',
377
        interface         => 'commandline',
Lines 380-394 subtest 'Renewal related tests' => sub { Link Here
380
    $line->amountoutstanding(5);
381
    $line->amountoutstanding(5);
381
    is( $line->renewable, 0, "Item is returned as unrenewable when it has outstanding fine" );
382
    is( $line->renewable, 0, "Item is returned as unrenewable when it has outstanding fine" );
382
    $line->amountoutstanding(0);
383
    $line->amountoutstanding(0);
383
    $line->accounttype("VOID");
384
    $line->debit_type_code("VOID");
384
    is( $line->renewable, 0, "Item is returned as unrenewable when it has the wrong account type" );
385
    is( $line->renewable, 0, "Item is returned as unrenewable when it has the wrong account type" );
385
    $line->accounttype("OVERDUE");
386
    $line->debit_type_code("OVERDUE");
386
    $line->status("RETURNED");
387
    $line->status("RETURNED");
387
    is( $line->renewable, 0, "Item is returned as unrenewable when it has the wrong account status" );
388
    is( $line->renewable, 0, "Item is returned as unrenewable when it has the wrong account status" );
388
389
389
390
390
    t::lib::Mocks::mock_preference( 'RenewAccruingItemWhenPaid', 0 );
391
    t::lib::Mocks::mock_preference( 'RenewAccruingItemWhenPaid', 0 );
391
    is ($line->renew_item, 0, 'Attempt to renew fails when syspref is not set');
392
    is ($line->renew_item, undef, 'Attempt to renew fails when syspref is not set');
392
    t::lib::Mocks::mock_preference( 'RenewAccruingItemWhenPaid', 1 );
393
    t::lib::Mocks::mock_preference( 'RenewAccruingItemWhenPaid', 1 );
393
    is_deeply(
394
    is_deeply(
394
        $line->renew_item,
395
        $line->renew_item,
Lines 414-419 subtest 'Renewal related tests' => sub { Link Here
414
    my $called = 0;
415
    my $called = 0;
415
    my $module = new Test::MockModule('C4::Circulation');
416
    my $module = new Test::MockModule('C4::Circulation');
416
    $module->mock('AddRenewal', sub { $called = 1; });
417
    $module->mock('AddRenewal', sub { $called = 1; });
418
    $module->mock('CanBookBeRenewed', sub { return 1; });
417
    $line->renew_item;
419
    $line->renew_item;
418
    is( $called, 1, 'Attempt to renew succeeds when conditions are met' );
420
    is( $called, 1, 'Attempt to renew succeeds when conditions are met' );
419
421
420
- 

Return to bug 23051