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

(-)a/C4/SIP/ILS.pm (-2 / +6 lines)
Lines 271-280 sub pay_fee { Link Here
271
        $trans->screen_msg('Invalid patron barcode.');
271
        $trans->screen_msg('Invalid patron barcode.');
272
        return $trans;
272
        return $trans;
273
    }
273
    }
274
    my $ok = $trans->pay( $patron->{borrowernumber}, $fee_amt, $pay_type, $fee_id, $is_writeoff, $disallow_overpayment );
274
    my $trans_result = $trans->pay( $patron->{borrowernumber}, $fee_amt, $pay_type, $fee_id, $is_writeoff, $disallow_overpayment );
275
    my $ok = $trans_result->{ok};
275
    $trans->ok($ok);
276
    $trans->ok($ok);
276
277
277
    return $trans;
278
    return {
279
        status       => $trans,
280
        pay_response => $trans_result->{pay_response}
281
    };
278
}
282
}
279
283
280
sub add_hold {
284
sub add_hold {
(-)a/C4/SIP/ILS/Transaction/FeePayment.pm (-6 / +14 lines)
Lines 57-69 sub pay { Link Here
57
    my $account = Koha::Account->new( { patron_id => $borrowernumber } );
57
    my $account = Koha::Account->new( { patron_id => $borrowernumber } );
58
58
59
    if ($disallow_overpayment) {
59
    if ($disallow_overpayment) {
60
        return 0 if $account->balance < $amt;
60
        return { ok => 0 } if $account->balance < $amt;
61
    }
61
    }
62
62
63
    if ($fee_id) {
63
    if ($fee_id) {
64
        my $fee = Koha::Account::Lines->find($fee_id);
64
        my $fee = Koha::Account::Lines->find($fee_id);
65
        if ( $fee ) {
65
        if ( $fee ) {
66
            $account->pay(
66
            my $pay_response = $account->pay(
67
                {
67
                {
68
                    amount       => $amt,
68
                    amount       => $amt,
69
                    type         => $type,
69
                    type         => $type,
Lines 72-85 sub pay { Link Here
72
                    interface    => C4::Context->interface
72
                    interface    => C4::Context->interface
73
                }
73
                }
74
            );
74
            );
75
            return 1;
75
            return {
76
                ok           => 1,
77
                pay_response => $pay_response
78
            };
76
        }
79
        }
77
        else {
80
        else {
78
            return 0;
81
            return {
82
                ok => 0
83
            };
79
        }
84
        }
80
    }
85
    }
81
    else {
86
    else {
82
        $account->pay(
87
        my $pay_response = $account->pay(
83
            {
88
            {
84
                amount       => $amt,
89
                amount       => $amt,
85
                type         => $type,
90
                type         => $type,
Lines 87-93 sub pay { Link Here
87
                interface    => C4::Context->interface
92
                interface    => C4::Context->interface
88
            }
93
            }
89
        );
94
        );
90
        return 1;
95
        return {
96
            ok           => 1,
97
            pay_response => $pay_response
98
        };
91
    }
99
    }
92
}
100
}
93
101
(-)a/C4/SIP/Sip/MsgType.pm (-1 / +41 lines)
Lines 20-25 use CGI qw ( -utf8 ); Link Here
20
use C4::Auth qw(&check_api_auth);
20
use C4::Auth qw(&check_api_auth);
21
21
22
use Koha::Patron::Attributes;
22
use Koha::Patron::Attributes;
23
use Koha::Items;
23
24
24
use UNIVERSAL::can;
25
use UNIVERSAL::can;
25
26
Lines 1103-1109 sub handle_fee_paid { Link Here
1103
1104
1104
    $ils->check_inst_id( $inst_id, "handle_fee_paid" );
1105
    $ils->check_inst_id( $inst_id, "handle_fee_paid" );
1105
1106
1106
    $status = $ils->pay_fee( $patron_id, $patron_pwd, $fee_amt, $fee_type, $pay_type, $fee_id, $trans_id, $currency, $is_writeoff, $disallow_overpayment );
1107
    my $pay_result = $ils->pay_fee( $patron_id, $patron_pwd, $fee_amt, $fee_type, $pay_type, $fee_id, $trans_id, $currency, $is_writeoff, $disallow_overpayment );
1108
    $status = $pay_result->{status};
1109
    my $pay_response = $pay_result->{pay_response};
1110
1111
    my $failmap = {
1112
        "no_item" => "No matching item could be found",
1113
        "no_checkout" => "Item is not checked out",
1114
        "too_soon" => "Cannot yet be renewed",
1115
        "too_many" => "Renewed the maximum number of times",
1116
        "auto_too_soon" => "Scheduled for automatic renewal and cannot yet be renewed",
1117
        "auto_too_late" => "Scheduled for automatic renewal and cannot yet be any more",
1118
        "auto_account_expired" => "Scheduled for automatic renewal and cannot be renewed because the patron's account has expired",
1119
        "auto_renew" => "Scheduled for automatic renewal",
1120
        "auto_too_much_oweing" => "Scheduled for automatic renewal",
1121
        "on_reserve" => "On hold for another patron",
1122
        "patron_restricted" => "Patron is currently restricted",
1123
        "item_denied_renewal" => "Item is not allowed renewal",
1124
        "onsite_checkout" => "Item is an onsite checkout"
1125
    };
1126
    my @success = ();
1127
    my @fail = ();
1128
    foreach my $result( @{$pay_response->{renew_result}} ) {
1129
        my $item = Koha::Items->find({ itemnumber => $result->{itemnumber} });
1130
        if ($result->{success}) {
1131
            push @success, '"' . $item->biblio->title . '"';
1132
        } else {
1133
            push @fail, '"' . $item->biblio->title . '" : ' . $failmap->{$result->{error}};
1134
        }
1135
    }
1136
1137
    my $msg = "";
1138
    if (scalar @success > 0) {
1139
        $msg.="The following items were renewed: " . join(", ", @success) . ". ";
1140
    }
1141
    if (scalar @fail > 0) {
1142
        $msg.="The following items were not renewed: " . join(", ", @fail) . ".";
1143
    }
1144
    if (length $msg > 0) {
1145
        $status->screen_msg($status->screen_msg . " $msg");
1146
    }
1107
1147
1108
    $resp .= ( $status->ok ? 'Y' : 'N' ) . timestamp;
1148
    $resp .= ( $status->ok ? 'Y' : 'N' ) . timestamp;
1109
    $resp .= add_field( FID_INST_ID,   $inst_id, $server );
1149
    $resp .= add_field( FID_INST_ID,   $inst_id, $server );
(-)a/Koha/Account.pm (-53 / +17 lines)
Lines 97-106 sub pay { Link Here
97
        && !defined($cash_register) );
97
        && !defined($cash_register) );
98
98
99
    my @fines_paid; # List of account lines paid on with this payment
99
    my @fines_paid; # List of account lines paid on with this payment
100
    # Item numbers that have had a fine paid where the line has a accounttype
100
101
    # of OVERDUE and a status of UNRETURNED. We might want to try and renew
101
    # The outcome of any attempted item renewals as a result of fines being
102
    # these items.
102
    # paid off
103
    my $overdue_unreturned = {};
103
    my $renew_outcomes = [];
104
104
105
    my $balance_remaining = $amount; # Set it now so we can adjust the amount if necessary
105
    my $balance_remaining = $amount; # Set it now so we can adjust the amount if necessary
106
    $balance_remaining ||= 0;
106
    $balance_remaining ||= 0;
Lines 119-134 sub pay { Link Here
119
        $fine->amountoutstanding($new_amountoutstanding)->store();
119
        $fine->amountoutstanding($new_amountoutstanding)->store();
120
        $balance_remaining = $balance_remaining - $amount_to_pay;
120
        $balance_remaining = $balance_remaining - $amount_to_pay;
121
121
122
        # If we need to make a note of the item associated with this line,
122
        # Attempt to renew the item associated with this debit if
123
        # in order that we can potentially renew it, do so.
123
        # appropriate
124
        if (
124
        if ($fine->renewable) {
125
            $new_amountoutstanding == 0 &&
125
            # We're ignoring the definition of $interface above, by all
126
            $fine->accounttype &&
126
            # accounts we can't rely on C4::Context::interface, so here
127
            $fine->accounttype eq 'OVERDUE' &&
127
            # we're only using what we've been explicitly passed
128
            $fine->status &&
128
            my $outcome = $fine->renew_item($params->{interface});
129
            $fine->status eq 'UNRETURNED'
129
            push @{$renew_outcomes}, $outcome if $outcome;
130
        ) {
131
            $overdue_unreturned->{$fine->itemnumber} = $fine;
132
        }
130
        }
133
131
134
        # Same logic exists in Koha::Account::Line::apply
132
        # Same logic exists in Koha::Account::Line::apply
Lines 193-206 sub pay { Link Here
193
191
194
        # If we need to make a note of the item associated with this line,
192
        # If we need to make a note of the item associated with this line,
195
        # in order that we can potentially renew it, do so.
193
        # in order that we can potentially renew it, do so.
196
        if (
194
        my $amt = $old_amountoutstanding - $amount_to_pay;
197
            $old_amountoutstanding - $amount_to_pay == 0 &&
195
        if ($fine->renewable) {
198
            $fine->accounttype &&
196
            my $outcome = $fine->renew_item;
199
            $fine->accounttype eq 'OVERDUE' &&
197
            push @{$renew_outcomes}, $outcome;
200
            $fine->status &&
201
            $fine->status eq 'UNRETURNED'
202
        ) {
203
            $overdue_unreturned->{$fine->itemnumber} = $fine;
204
        }
198
        }
205
199
206
        if (   $fine->amountoutstanding == 0
200
        if (   $fine->amountoutstanding == 0
Lines 283-318 sub pay { Link Here
283
        }
277
        }
284
    );
278
    );
285
279
286
    # If we have overdue unreturned items that have had payments made
287
    # against them, check whether the balance on those items is now zero
288
    # and, if the syspref is set, renew them
289
    # Same logic exists in Koha::Account::Line::apply
290
    if (
291
        C4::Context->preference('RenewAccruingItemWhenPaid') &&
292
        keys %{$overdue_unreturned}
293
    ) {
294
        foreach my $itemnumber (keys %{$overdue_unreturned}) {
295
            # Only do something if this item has no fines left on it
296
            my $fine = C4::Overdues::GetFine( $itemnumber, $self->{patron_id} );
297
            next if $fine && $fine > 0;
298
299
            my ( $renew_ok, $error ) =
300
                C4::Circulation::CanBookBeRenewed(
301
                    $self->{patron_id}, $itemnumber
302
                );
303
            if ( $renew_ok ) {
304
                C4::Circulation::AddRenewal(
305
                    $self->{patron_id},
306
                    $itemnumber,
307
                    $library_id,
308
                    undef,
309
                    undef,
310
                    1
311
                );
312
            }
313
        }
314
    }
315
316
    if ( C4::Context->preference("FinesLog") ) {
280
    if ( C4::Context->preference("FinesLog") ) {
317
        logaction(
281
        logaction(
318
            "FINES", 'CREATE',
282
            "FINES", 'CREATE',
Lines 360-366 sub pay { Link Here
360
        }
324
        }
361
    }
325
    }
362
326
363
    return $payment->id;
327
    return { payment_id => $payment->id, renew_result => $renew_outcomes };
364
}
328
}
365
329
366
=head3 add_credit
330
=head3 add_credit
(-)a/Koha/Account/Line.pm (-46 / +96 lines)
Lines 452-462 sub apply { Link Here
452
452
453
    my $schema = Koha::Database->new->schema;
453
    my $schema = Koha::Database->new->schema;
454
454
455
    # Item numbers that have had a fine paid where the line has a accounttype
456
    # of OVERDUE and a status of UNRETURNED. We might want to try and renew
457
    # these items.
458
    my $overdue_unreturned = {};
459
460
    $schema->txn_do( sub {
455
    $schema->txn_do( sub {
461
        for my $debit ( @{$debits} ) {
456
        for my $debit ( @{$debits} ) {
462
457
Lines 489-505 sub apply { Link Here
489
            $self->amountoutstanding( $available_credit * -1 )->store;
484
            $self->amountoutstanding( $available_credit * -1 )->store;
490
            $debit->amountoutstanding( $owed - $amount_to_cancel )->store;
485
            $debit->amountoutstanding( $owed - $amount_to_cancel )->store;
491
486
492
            # If we need to make a note of the item associated with this line,
487
            # Attempt to renew the item associated with this debit if
493
            # in order that we can potentially renew it, do so.
488
            # appropriate
494
            # Same logic existing in Koha::Account::pay
489
            if ($debit->renewable) {
495
            if (
490
                $debit->renew_item($params->{interface});
496
                $debit->amountoutstanding == 0 &&
497
                $debit->accounttype &&
498
                $debit->accounttype eq 'OVERDUE' &&
499
                $debit->status &&
500
                $debit->status eq 'UNRETURNED'
501
            ) {
502
                $overdue_unreturned->{$debit->itemnumber} = $debit;
503
            }
491
            }
504
492
505
            # Same logic exists in Koha::Account::pay
493
            # Same logic exists in Koha::Account::pay
Lines 514-549 sub apply { Link Here
514
        }
502
        }
515
    });
503
    });
516
504
517
    # If we have overdue unreturned items that have had payments made
518
    # against them, check whether the balance on those items is now zero
519
    # and, if the syspref is set, renew them
520
    # Same logic existing in Koha::Account::pay
521
    if (
522
        C4::Context->preference('RenewAccruingItemWhenPaid') &&
523
        keys %{$overdue_unreturned}
524
    ) {
525
        foreach my $itemnumber (keys %{$overdue_unreturned}) {
526
            # Only do something if this item has no fines left on it
527
            my $fine = C4::Overdues::GetFine( $itemnumber, $self->borrowernumber );
528
            next if $fine && $fine > 0;
529
530
            my ( $renew_ok, $error ) =
531
                C4::Circulation::CanBookBeRenewed(
532
                    $self->borrowernumber, $itemnumber
533
                );
534
            if ( $renew_ok ) {
535
                C4::Circulation::AddRenewal(
536
                    $self->borrowernumber,
537
                    $itemnumber,
538
                    $overdue_unreturned->{$itemnumber}->{branchcode},
539
                    undef,
540
                    undef,
541
                    1
542
                );
543
            }
544
        }
545
    }
546
547
    return $available_credit;
505
    return $available_credit;
548
}
506
}
549
507
Lines 809-814 sub to_api_mapping { Link Here
809
        manager_id        => 'user_id',
767
        manager_id        => 'user_id',
810
        note              => 'internal_note',
768
        note              => 'internal_note',
811
    };
769
    };
770
771
=head3 renewable
772
773
    my $bool = $line->renewable;
774
775
=cut
776
777
sub renewable {
778
    my ($self) = @_;
779
780
    return (
781
        $self->amountoutstanding == 0 &&
782
        $self->accounttype &&
783
        $self->accounttype eq 'OVERDUE' &&
784
        $self->status &&
785
        $self->status eq 'UNRETURNED'
786
    ) ? 1 : 0;
787
}
788
789
=head3 renew_item
790
791
    my $renew_result = $line->renew_item;
792
793
Conditionally attempt to renew an item and return the outcome. This is
794
as a consequence of the fine on an item being fully paid off
795
796
=cut
797
798
sub renew_item {
799
    my ($self, $params) = @_;
800
801
    my $outcome = {};
802
803
    # We want to reject the call to renew if any of these apply:
804
    # - The RenewAccruingItemWhenPaid syspref is off
805
    # - The line item doesn't have an item attached to it
806
    # - The line item doesn't have a patron attached to it
807
    #
808
    # - The RenewAccruingItemInOpac syspref is off
809
    # AND
810
    # - There is an interface param passed and it's value is 'opac'
811
812
    if (
813
        !C4::Context->preference('RenewAccruingItemWhenPaid') ||
814
        !$self->item ||
815
        !$self->patron ||
816
        (
817
            !C4::Context->preference('RenewAccruingItemInOpac') &&
818
            $params->{interface} &&
819
            $params->{interface} eq 'opac'
820
        )
821
    ) {
822
        return;
823
    }
824
825
    my $itemnumber = $self->item->itemnumber;
826
    my $borrowernumber = $self->patron->borrowernumber;
827
    # Only do something if this item has no fines left on it
828
    my $fine = C4::Overdues::GetFine($itemnumber, $borrowernumber);
829
    if ($fine && $fine > 0) {
830
        return {
831
            itemnumber => $itemnumber,
832
            error      => 'has_fine',
833
            success    => 0
834
        };
835
    }
836
    my ( $can_renew, $error ) = C4::Circulation::CanBookBeRenewed(
837
        $borrowernumber,
838
        $itemnumber
839
    );
840
    if ( $can_renew ) {
841
        my $due_date = C4::Circulation::AddRenewal(
842
            $borrowernumber,
843
            $itemnumber,
844
            $self->{branchcode},
845
            undef,
846
            undef,
847
            1
848
        );
849
        return {
850
            itemnumber => $itemnumber,
851
            due_date   => $due_date,
852
            success    => 1
853
        };
854
    } else {
855
        return {
856
            itemnumber => $itemnumber,
857
            error      => $error,
858
            success    => 0
859
        };
860
    }
861
812
}
862
}
813
863
814
=head2 Internal methods
864
=head2 Internal methods
(-)a/Koha/REST/V1/Patrons/Account.pm (-1 / +1 lines)
Lines 130-136 sub add_credit { Link Here
130
        my $outstanding_credit = $credit->amountoutstanding;
130
        my $outstanding_credit = $credit->amountoutstanding;
131
        if ($debits) {
131
        if ($debits) {
132
            # pay them!
132
            # pay them!
133
            $outstanding_credit = $credit->apply({ debits => [ $debits->as_list ], offset_type => 'payment' });
133
            $outstanding_credit = $credit->apply({ debits => [ $debits->as_list ], offset_type => 'payment' })->{outstanding_amount};
134
        }
134
        }
135
135
136
        if ($outstanding_credit) {
136
        if ($outstanding_credit) {
(-)a/installer/data/mysql/atomicupdate/bug_23051_add_RenewAccruingItemInOpac_syspref.perl (+8 lines)
Line 0 Link Here
1
$DBversion = 'XXX'; # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
3
4
    $dbh->do( q| INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type) VALUES ('RenewAccruingItemInOpac', '0', 'If enabled, when the fines on an item accruing is paid off in the OPAC via a payment plugin, attempt to renew that item. If the syspref "RenewalPeriodBase" is set to "due date", renewed items may still be overdue', '', 'YesNo'); | );
5
6
    SetVersion( $DBversion );
7
    print "Upgrade to $DBversion done (Bug 23051 - Add RenewAccruingItemInOpac syspref)\n";
8
}
(-)a/installer/data/mysql/atomicupdate/bug_23051_add_RenewAccruingItemWhenPaid_syspref.perl (-1 / +1 lines)
Lines 1-7 Link Here
1
$DBversion = 'XXX'; # will be replaced by the RM
1
$DBversion = 'XXX'; # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
2
if( CheckVersion( $DBversion ) ) {
3
3
4
    $dbh->do( q| INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type) VALUES ('RenewAccruingItemWhenPaid', '0', 'If enabled, when the fines on an item accruing is paid off, attempt to renew that item', '', 'YesNo'); | );
4
    $dbh->do( q| INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type) VALUES ('RenewAccruingItemWhenPaid', '0', 'If enabled, when the fines on an item accruing is paid off, attempt to renew that item. If the syspref "RenewalPeriodBase" is set to "due date", renewed items may still be overdue', '', 'YesNo'); | );
5
5
6
    SetVersion( $DBversion );
6
    SetVersion( $DBversion );
7
    print "Upgrade to $DBversion done (Bug 23051 - Add RenewAccruingItemWhenPaid syspref)\n";
7
    print "Upgrade to $DBversion done (Bug 23051 - Add RenewAccruingItemWhenPaid syspref)\n";
(-)a/installer/data/mysql/sysprefs.sql (-1 / +2 lines)
Lines 515-521 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
515
('RandomizeHoldsQueueWeight','0',NULL,'if ON, the holds queue in circulation will be randomized, either based on all location codes, or by the location codes specified in StaticHoldsQueueWeight','YesNo'),
515
('RandomizeHoldsQueueWeight','0',NULL,'if ON, the holds queue in circulation will be randomized, either based on all location codes, or by the location codes specified in StaticHoldsQueueWeight','YesNo'),
516
('RecordLocalUseOnReturn','0',NULL,'If ON, statistically record returns of unissued items as local use, instead of return','YesNo'),
516
('RecordLocalUseOnReturn','0',NULL,'If ON, statistically record returns of unissued items as local use, instead of return','YesNo'),
517
('RefundLostOnReturnControl','CheckinLibrary','CheckinLibrary|ItemHomeBranch|ItemHoldingBranch','If a lost item is returned, choose which branch to pick rules for refunding.','Choice'),
517
('RefundLostOnReturnControl','CheckinLibrary','CheckinLibrary|ItemHomeBranch|ItemHoldingBranch','If a lost item is returned, choose which branch to pick rules for refunding.','Choice'),
518
('RenewAccruingItemWhenPaid','0','','If enabled, when the fines on an item accruing is paid off, attempt to renew that item','YesNo'),
518
('RenewAccruingItemWhenPaid','0','','If enabled, when the fines on an item accruing is paid off, attempt to renew that item. If the syspref "RenewalPeriodBase" is set to "due date", renewed items may still be overdue','YesNo'),
519
('RenewAccruingItemInOpac','0','','If enabled, when the fines on an item accruing is paid off in the OPAC via a payment plugin, attempt to renew that item. If the syspref "RenewalPeriodBase" is set to "due date", renewed items may still be overdue','YesNo'),
519
('RenewalLog','0','','If ON, log information about renewals','YesNo'),
520
('RenewalLog','0','','If ON, log information about renewals','YesNo'),
520
('RenewalPeriodBase','date_due','date_due|now','Set whether the renewal date should be counted from the date_due or from the moment the Patron asks for renewal ','Choice'),
521
('RenewalPeriodBase','date_due','date_due|now','Set whether the renewal date should be counted from the date_due or from the moment the Patron asks for renewal ','Choice'),
521
('RenewalSendNotice','0','',NULL,'YesNo'),
522
('RenewalSendNotice','0','',NULL,'YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/renew_results.inc (+12 lines)
Line 0 Link Here
1
[% IF renew_results && renew_results.size > 0 %]
2
    <div class="alert">
3
		The fines on the following items were paid off, renewal results are displayed below:
4
		[% FOREACH result IN renew_results %]
5
			[% IF result.success %]
6
				<p>[% INCLUDE 'biblio-title.inc' biblio=result.item.biblio %] ( [% result.item.barcode | html %] ): Renewed - due [% result.info | html %]</p>
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>
9
			[% END %]
10
		[% END %]
11
    </div>
12
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/renew_strings.inc (+32 lines)
Line 0 Link Here
1
[% SWITCH error %]
2
[% CASE 'no_item' %]
3
    No matching item could be found
4
[% CASE 'no_checkout' %]
5
    Item is not checked out
6
[% CASE 'too_soon' %]
7
    Cannot yet be renewed
8
[% CASE 'too_many' %]
9
    Renewed the maximum number of times
10
[% CASE 'auto_too_soon' %]
11
    Scheduled for automatic renewal and cannot yet be renewed
12
[% CASE 'auto_too_late' %]
13
    Scheduled for automatic renewal and cannot yet be any more
14
[% CASE 'auto_account_expired' %]
15
    Scheduled for automatic renewal and cannot be renewed because the patron's account has expired
16
[% CASE 'auto_renew' %]
17
    Scheduled for automatic renewal
18
[% CASE 'auto_too_much_oweing' %]
19
    Scheduled for automatic renewal
20
[% CASE 'on_reserve' %]
21
    On hold for another patron
22
[% CASE 'patron_restricted' %]
23
    Patron is currently restricted
24
[% CASE 'item_denied_renewal' %]
25
    Item is not allowed renewal
26
[% CASE 'onsite_checkout' %]
27
    Item is an onsite checkout
28
[% CASE 'has_fine' %]
29
    Item has an outstanding fine
30
[% CASE %]
31
    Unknown error
32
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (-1 / +8 lines)
Lines 493-499 Circulation: Link Here
493
              choices:
493
              choices:
494
                  yes: Renew
494
                  yes: Renew
495
                  no: "Don't renew"
495
                  no: "Don't renew"
496
            - the item automatically.
496
            - the item automatically. If the syspref "RenewalPeriodBase" is set to "due date", renewed items may still be overdue.
497
        -
498
            - If a patron pays off all fines on an overdue item that is accruing fines in the OPAC via a payment plugin
499
            - pref: RenewAccruingItemInOpac
500
              choices:
501
                  yes: Renew
502
                  no: "Don't renew"
503
            - the item automatically. If the syspref "RenewalPeriodBase" is set to "due date", renewed items may still be overdue.
497
        -
504
        -
498
            - pref: ItemsDeniedRenewal
505
            - pref: ItemsDeniedRenewal
499
              type: textarea
506
              type: textarea
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt (+1 lines)
Lines 39-44 Link Here
39
    <li><a href="/cgi-bin/koha/members/mancredit.pl?borrowernumber=[% patron.borrowernumber | uri %]" >Create manual credit</a></li>
39
    <li><a href="/cgi-bin/koha/members/mancredit.pl?borrowernumber=[% patron.borrowernumber | uri %]" >Create manual credit</a></li>
40
</ul>
40
</ul>
41
<div class="tabs-container">
41
<div class="tabs-container">
42
[% INCLUDE 'renew_results.inc' renew_results=renew_results %]
42
<!-- The table with the account items -->
43
<!-- The table with the account items -->
43
<table id="table_account_fines">
44
<table id="table_account_fines">
44
    <thead>
45
    <thead>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt (+1 lines)
Lines 40-45 Link Here
40
    <form action="/cgi-bin/koha/members/pay.pl" method="post" id="pay-fines-form">
40
    <form action="/cgi-bin/koha/members/pay.pl" method="post" id="pay-fines-form">
41
    <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.borrowernumber | html %]" />
41
    <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.borrowernumber | html %]" />
42
<p><span class="checkall"><a id="CheckAll" href="#"><i class="fa fa-check"></i> Select all</a></span> | <span class="clearall"><a id="CheckNone" href="#"><i class="fa fa-remove"></i> Clear all</a></span></p>
42
<p><span class="checkall"><a id="CheckAll" href="#"><i class="fa fa-check"></i> Select all</a></span> | <span class="clearall"><a id="CheckNone" href="#"><i class="fa fa-remove"></i> Clear all</a></span></p>
43
[% INCLUDE 'renew_results.inc' renew_results=renew_results %]
43
<table id="finest">
44
<table id="finest">
44
<thead>
45
<thead>
45
<tr>
46
<tr>
(-)a/members/boraccount.pl (+20 lines)
Lines 23-28 Link Here
23
# along with Koha; if not, see <http://www.gnu.org/licenses>.
23
# along with Koha; if not, see <http://www.gnu.org/licenses>.
24
24
25
use Modern::Perl;
25
use Modern::Perl;
26
use URI::Escape;
26
27
27
use C4::Auth;
28
use C4::Auth;
28
use C4::Output;
29
use C4::Output;
Lines 32-37 use C4::Accounts; Link Here
32
use Koha::Cash::Registers;
33
use Koha::Cash::Registers;
33
use Koha::Patrons;
34
use Koha::Patrons;
34
use Koha::Patron::Categories;
35
use Koha::Patron::Categories;
36
use Koha::Items;
35
37
36
my $input=new CGI;
38
my $input=new CGI;
37
39
Lines 53-58 my $borrowernumber = $input->param('borrowernumber'); Link Here
53
my $payment_id     = $input->param('payment_id');
55
my $payment_id     = $input->param('payment_id');
54
my $change_given   = $input->param('change_given');
56
my $change_given   = $input->param('change_given');
55
my $action         = $input->param('action') || '';
57
my $action         = $input->param('action') || '';
58
my @renew_results  = $input->param('renew_result');
56
59
57
my $logged_in_user = Koha::Patrons->find( $loggedinuser );
60
my $logged_in_user = Koha::Patrons->find( $loggedinuser );
58
my $library_id = C4::Context->userenv->{'branch'};
61
my $library_id = C4::Context->userenv->{'branch'};
Lines 164-169 if($total <= 0){ Link Here
164
        $totalcredit = 1;
167
        $totalcredit = 1;
165
}
168
}
166
169
170
# Populate an arrayref with everything we need to display any
171
# renew errors that occurred based on what we were passed
172
my $renew_results_display = [];
173
foreach my $renew_result(@renew_results) {
174
    my ($itemnumber, $success, $info) = split(/,/, $renew_result);
175
    my $item = Koha::Items->find($itemnumber);
176
    if ($success) {
177
        $info = uri_unescape($info);
178
    }
179
    push @{$renew_results_display}, {
180
        item    => $item,
181
        success => $success,
182
        info    => $info
183
    };
184
}
185
167
$template->param(
186
$template->param(
168
    patron              => $patron,
187
    patron              => $patron,
169
    finesview           => 1,
188
    finesview           => 1,
Lines 172-177 $template->param( Link Here
172
    accounts            => \@accountlines,
191
    accounts            => \@accountlines,
173
    payment_id          => $payment_id,
192
    payment_id          => $payment_id,
174
    change_given        => $change_given,
193
    change_given        => $change_given,
194
    renew_results       => $renew_results_display,
175
);
195
);
176
196
177
output_html_with_http_headers $input, $cookie, $template->output;
197
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/members/pay.pl (+19 lines)
Lines 39-44 use C4::Stats; Link Here
39
use C4::Koha;
39
use C4::Koha;
40
use C4::Overdues;
40
use C4::Overdues;
41
use Koha::Patrons;
41
use Koha::Patrons;
42
use Koha::Items;
42
43
43
use Koha::Patron::Categories;
44
use Koha::Patron::Categories;
44
use URI::Escape;
45
use URI::Escape;
Lines 65-70 if ( !$borrowernumber ) { Link Here
65
66
66
my $payment_id = $input->param('payment_id');
67
my $payment_id = $input->param('payment_id');
67
our $change_given = $input->param('change_given');
68
our $change_given = $input->param('change_given');
69
our @renew_results = $input->multi_param('renew_result');
68
70
69
# get borrower details
71
# get borrower details
70
my $logged_in_user = Koha::Patrons->find( $loggedinuser );
72
my $logged_in_user = Koha::Patrons->find( $loggedinuser );
Lines 135-144 for (@names) { Link Here
135
    }
137
    }
136
}
138
}
137
139
140
# Populate an arrayref with everything we need to display any
141
# renew results that occurred based on what we were passed
142
my $renew_results_display = [];
143
foreach my $renew_result(@renew_results) {
144
    my ($itemnumber, $success, $info) = split(/,/, $renew_result);
145
    my $item = Koha::Items->find($itemnumber);
146
    if ($success) {
147
        $info = uri_unescape($info);
148
    }
149
    push @{$renew_results_display}, {
150
        item => $item,
151
        success => $success,
152
        info => $info
153
    };
154
}
155
138
$template->param(
156
$template->param(
139
    finesview  => 1,
157
    finesview  => 1,
140
    payment_id => $payment_id,
158
    payment_id => $payment_id,
141
    change_given => $change_given,
159
    change_given => $change_given,
160
    renew_results => $renew_results_display
142
);
161
);
143
162
144
add_accounts_to_template();
163
add_accounts_to_template();
(-)a/members/paycollect.pl (-7 / +29 lines)
Lines 34-39 use Koha::Patron::Categories; Link Here
34
use Koha::AuthorisedValues;
34
use Koha::AuthorisedValues;
35
use Koha::Account;
35
use Koha::Account;
36
use Koha::Token;
36
use Koha::Token;
37
use Koha::DateUtils;
37
38
38
my $input = CGI->new();
39
my $input = CGI->new();
39
40
Lines 177-185 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
177
                token  => scalar $input->param('csrf_token'),
178
                token  => scalar $input->param('csrf_token'),
178
            });
179
            });
179
180
181
        my $url;
182
        my $pay_result;
180
        if ($pay_individual) {
183
        if ($pay_individual) {
181
            my $line = Koha::Account::Lines->find($accountlines_id);
184
            my $line = Koha::Account::Lines->find($accountlines_id);
182
            $payment_id = $account->pay(
185
            $pay_result = $account->pay(
183
                {
186
                {
184
                    lines        => [$line],
187
                    lines        => [$line],
185
                    amount       => $total_paid,
188
                    amount       => $total_paid,
Lines 190-197 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
190
                    cash_register => $registerid
193
                    cash_register => $registerid
191
                }
194
                }
192
            );
195
            );
193
            print $input->redirect(
196
            $payment_id = $pay_result->{payment_id};
194
                "/cgi-bin/koha/members/pay.pl?borrowernumber=$borrowernumber&payment_id=$payment_id&change_given=$change_given");
197
198
            $url = "/cgi-bin/koha/members/pay.pl";
195
        } else {
199
        } else {
196
            if ($selected_accts) {
200
            if ($selected_accts) {
197
                if ( $total_paid > $total_due ) {
201
                if ( $total_paid > $total_due ) {
Lines 202-208 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
202
                } else {
206
                } else {
203
                    my $note = $input->param('selected_accts_notes');
207
                    my $note = $input->param('selected_accts_notes');
204
208
205
                    $payment_id = $account->pay(
209
                    $pay_result = $account->pay(
206
                        {
210
                        {
207
                            type         => $type,
211
                            type         => $type,
208
                            amount       => $total_paid,
212
                            amount       => $total_paid,
Lines 213-224 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
213
                            payment_type => $payment_type,
217
                            payment_type => $payment_type,
214
                            cash_register => $registerid
218
                            cash_register => $registerid
215
                        }
219
                        }
216
                      );
220
                    );
217
                }
221
                }
222
                $payment_id = $pay_result->{payment_id};
218
            }
223
            }
219
            else {
224
            else {
220
                my $note = $input->param('selected_accts_notes');
225
                my $note = $input->param('selected_accts_notes');
221
                $payment_id = $account->pay(
226
                $pay_result = $payment_id = $account->pay(
222
                    {
227
                    {
223
                        amount       => $total_paid,
228
                        amount       => $total_paid,
224
                        library_id   => $library_id,
229
                        library_id   => $library_id,
Lines 230-238 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
230
                    }
235
                    }
231
                );
236
                );
232
            }
237
            }
238
            $payment_id = $pay_result->{payment_id};
233
239
234
            print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber&payment_id=$payment_id&change_given=$change_given");
240
            $url = "/cgi-bin/koha/members/boraccount.pl";
241
        }
242
        # It's possible renewals took place, parse any renew results
243
        # and pass on
244
        my @renew_result = ();
245
        foreach my $ren( @{$pay_result->{renew_result}} ) {
246
            my $str = "renew_result=$ren->{itemnumber},$ren->{success},";
247
            my $app = $ren->{success} ?
248
                uri_escape(
249
                    output_pref({ dt => $ren->{due_date}, as_due_date => 1 })
250
                ) : $ren->{error};
251
                push @renew_result, "${str}${app}";
235
        }
252
        }
253
        my $append = scalar @renew_result ? '&' . join('&', @renew_result) : '';
254
255
        $url .= "?borrowernumber=$borrowernumber&payment_id=$payment_id&change_given=${change_given}${append}";
256
257
        print $input->redirect($url);
236
    }
258
    }
237
} else {
259
} else {
238
    $total_paid = '0.00';    #TODO not right with pay_individual
260
    $total_paid = '0.00';    #TODO not right with pay_individual
(-)a/t/db_dependent/Accounts.t (-8 / +8 lines)
Lines 214-220 subtest "Koha::Account::pay tests" => sub { Link Here
214
    my $borrowernumber = $borrower->borrowernumber;
214
    my $borrowernumber = $borrower->borrowernumber;
215
    my $data = '20.00';
215
    my $data = '20.00';
216
    my $payment_note = '$20.00 payment note';
216
    my $payment_note = '$20.00 payment note';
217
    my $id = $account->pay( { amount => $data, note => $payment_note, payment_type => "TEST_TYPE" } );
217
    my $id = $account->pay( { amount => $data, note => $payment_note, payment_type => "TEST_TYPE" } )->{payment_id};
218
218
219
    my $accountline = Koha::Account::Lines->find( $id );
219
    my $accountline = Koha::Account::Lines->find( $id );
220
    is( $accountline->payment_type, "TEST_TYPE", "Payment type passed into pay is set in account line correctly" );
220
    is( $accountline->payment_type, "TEST_TYPE", "Payment type passed into pay is set in account line correctly" );
Lines 294-300 subtest "Koha::Account::pay tests" => sub { Link Here
294
    is($note,'$200.00 payment note', '$200.00 payment note is registered');
294
    is($note,'$200.00 payment note', '$200.00 payment note is registered');
295
295
296
    my $line3 = $account->add_debit({ type => 'ACCOUNT', amount => 42, interface => 'commandline' });
296
    my $line3 = $account->add_debit({ type => 'ACCOUNT', amount => 42, interface => 'commandline' });
297
    my $payment_id = $account->pay( { lines => [$line3], amount => 42 } );
297
    my $payment_id = $account->pay( { lines => [$line3], amount => 42 } )->{payment_id};
298
    my $payment = Koha::Account::Lines->find( $payment_id );
298
    my $payment = Koha::Account::Lines->find( $payment_id );
299
    is( $payment->amount()+0, -42, "Payment paid the specified fine" );
299
    is( $payment->amount()+0, -42, "Payment paid the specified fine" );
300
    $line3 = Koha::Account::Lines->find( $line3->id );
300
    $line3 = Koha::Account::Lines->find( $line3->id );
Lines 376-382 subtest "Koha::Account::pay writeoff tests" => sub { Link Here
376
            amount => 42,
376
            amount => 42,
377
            type   => 'WRITEOFF',
377
            type   => 'WRITEOFF',
378
        }
378
        }
379
    );
379
    )->{payment_id};
380
380
381
    $line->_result->discard_changes();
381
    $line->_result->discard_changes();
382
382
Lines 1111-1117 subtest "Koha::Account::Offset credit & debit tests" => sub { Link Here
1111
            lines  => [$line1, $line2],
1111
            lines  => [$line1, $line2],
1112
            amount => 30,
1112
            amount => 30,
1113
        }
1113
        }
1114
    );
1114
    )->{payment_id};
1115
1115
1116
    # Test debit and credit methods for Koha::Account::Offset
1116
    # Test debit and credit methods for Koha::Account::Offset
1117
    my $account_offset = Koha::Account::Offsets->find( { credit_id => $id, debit_id => $line1->id } );
1117
    my $account_offset = Koha::Account::Offsets->find( { credit_id => $id, debit_id => $line1->id } );
Lines 1177-1191 subtest "Payment notice tests" => sub { Link Here
1177
    $letter->store();
1177
    $letter->store();
1178
1178
1179
    t::lib::Mocks::mock_preference('UseEmailReceipts', '0');
1179
    t::lib::Mocks::mock_preference('UseEmailReceipts', '0');
1180
    my $id = $account->pay( { amount => 1 } );
1180
    my $id = $account->pay( { amount => 1 } )->{payment_id};
1181
    is( Koha::Notice::Messages->search()->count(), 0, 'Notice for payment not sent if UseEmailReceipts is disabled' );
1181
    is( Koha::Notice::Messages->search()->count(), 0, 'Notice for payment not sent if UseEmailReceipts is disabled' );
1182
1182
1183
    $id = $account->pay( { amount => 1, type => 'WRITEOFF' } );
1183
    $id = $account->pay( { amount => 1, type => 'WRITEOFF' } )->{payment_id};
1184
    is( Koha::Notice::Messages->search()->count(), 0, 'Notice for writeoff not sent if UseEmailReceipts is disabled' );
1184
    is( Koha::Notice::Messages->search()->count(), 0, 'Notice for writeoff not sent if UseEmailReceipts is disabled' );
1185
1185
1186
    t::lib::Mocks::mock_preference('UseEmailReceipts', '1');
1186
    t::lib::Mocks::mock_preference('UseEmailReceipts', '1');
1187
1187
1188
    $id = $account->pay( { amount => 12, library_id => $branchcode } );
1188
    $id = $account->pay( { amount => 12, library_id => $branchcode } )->{payment_id};
1189
    my $notice = Koha::Notice::Messages->search()->next();
1189
    my $notice = Koha::Notice::Messages->search()->next();
1190
    is( $notice->subject, 'Account payment', 'Notice subject is correct for payment' );
1190
    is( $notice->subject, 'Account payment', 'Notice subject is correct for payment' );
1191
    is( $notice->letter_code, 'ACCOUNT_PAYMENT', 'Notice letter code is correct for payment' );
1191
    is( $notice->letter_code, 'ACCOUNT_PAYMENT', 'Notice letter code is correct for payment' );
Lines 1196-1202 subtest "Payment notice tests" => sub { Link Here
1196
    $letter->content('[%- USE Price -%]A writeoff of [% credit.amount * -1 | $Price %] has been applied to your account. Your [% branch.branchcode %]');
1196
    $letter->content('[%- USE Price -%]A writeoff of [% credit.amount * -1 | $Price %] has been applied to your account. Your [% branch.branchcode %]');
1197
    $letter->store();
1197
    $letter->store();
1198
1198
1199
    $id = $account->pay( { amount => 13, type => 'WRITEOFF', library_id => $branchcode  } );
1199
    $id = $account->pay( { amount => 13, type => 'WRITEOFF', library_id => $branchcode  } )->{payment_id};
1200
    $notice = Koha::Notice::Messages->search()->next();
1200
    $notice = Koha::Notice::Messages->search()->next();
1201
    is( $notice->subject, 'Account writeoff', 'Notice subject is correct for payment' );
1201
    is( $notice->subject, 'Account writeoff', 'Notice subject is correct for payment' );
1202
    is( $notice->letter_code, 'ACCOUNT_WRITEOFF', 'Notice letter code is correct for writeoff' );
1202
    is( $notice->letter_code, 'ACCOUNT_WRITEOFF', 'Notice letter code is correct for writeoff' );
(-)a/t/db_dependent/Koha/Account.t (-3 / +3 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 11;
22
use Test::More tests => 12;
23
use Test::MockModule;
23
use Test::MockModule;
24
use Test::Exception;
24
use Test::Exception;
25
25
Lines 685-696 subtest 'pay() tests' => sub { Link Here
685
    my $context = Test::MockModule->new('C4::Context');
685
    my $context = Test::MockModule->new('C4::Context');
686
    $context->mock( 'userenv', { branch => $library->id } );
686
    $context->mock( 'userenv', { branch => $library->id } );
687
687
688
    my $credit_1_id = $account->pay({ amount => 200 });
688
    my $credit_1_id = $account->pay({ amount => 200 })->{payment_id};
689
    my $credit_1    = Koha::Account::Lines->find( $credit_1_id );
689
    my $credit_1    = Koha::Account::Lines->find( $credit_1_id );
690
690
691
    is( $credit_1->branchcode, undef, 'No branchcode is set if library_id was not passed' );
691
    is( $credit_1->branchcode, undef, 'No branchcode is set if library_id was not passed' );
692
692
693
    my $credit_2_id = $account->pay({ amount => 150, library_id => $library->id });
693
    my $credit_2_id = $account->pay({ amount => 150, library_id => $library->id })->{payment_id};
694
    my $credit_2    = Koha::Account::Lines->find( $credit_2_id );
694
    my $credit_2    = Koha::Account::Lines->find( $credit_2_id );
695
695
696
    is( $credit_2->branchcode, $library->id, 'branchcode set because library_id was passed' );
696
    is( $credit_2->branchcode, $library->id, 'branchcode set because library_id was passed' );
(-)a/t/db_dependent/Koha/Account/Line.t (-4 / +78 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 11;
22
use Test::More tests => 12;
23
use Test::Exception;
23
use Test::Exception;
24
use Test::MockModule;
24
use Test::MockModule;
25
25
Lines 288-294 subtest 'apply() tests' => sub { Link Here
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
    my $credit_renew = $account->add_credit({ amount => 100, user_id => $patron->id, interface => 'commandline' });
290
    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 });
291
    my $debits_renew = Koha::Account::Lines->search({ accountlines_id => $accountline->id })->as_list;
292
    $credit_renew->apply( { debits => $debits_renew, offset_type => 'Manual Credit' } );
292
    $credit_renew->apply( { debits => $debits_renew, offset_type => 'Manual Credit' } );
293
293
294
    is( $called, 1, 'RenewAccruingItemWhenPaid causes C4::Circulation::AddRenew to be called when appropriate' );
294
    is( $called, 1, 'RenewAccruingItemWhenPaid causes C4::Circulation::AddRenew to be called when appropriate' );
Lines 345-350 subtest 'Keep account info when related patron, staff, item or cash_register is Link Here
345
    $schema->storage->txn_rollback;
345
    $schema->storage->txn_rollback;
346
};
346
};
347
347
348
subtest 'Renewal related tests' => sub {
349
350
    plan tests => 7;
351
352
    $schema->storage->txn_begin;
353
354
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
355
    my $staff = $builder->build_object( { class => 'Koha::Patrons' } );
356
    my $item = $builder->build_object({ class => 'Koha::Items' });
357
    my $issue = $builder->build_object(
358
        {
359
            class => 'Koha::Checkouts',
360
            value => {
361
                itemnumber      => $item->itemnumber,
362
                onsite_checkout => 0,
363
                renewals        => 99,
364
                auto_renew      => 0
365
            }
366
        }
367
    );
368
    my $line = Koha::Account::Line->new(
369
    {
370
        borrowernumber    => $patron->borrowernumber,
371
        manager_id        => $staff->borrowernumber,
372
        itemnumber        => $item->itemnumber,
373
        accounttype       => "OVERDUE",
374
        status            => "UNRETURNED",
375
        amountoutstanding => 0,
376
        interface         => 'commandline',
377
    })->store;
378
379
    is( $line->renewable, 1, "Item is returned as renewable when it meets the conditions" );
380
    $line->amountoutstanding(5);
381
    is( $line->renewable, 0, "Item is returned as unrenewable when it has outstanding fine" );
382
    $line->amountoutstanding(0);
383
    $line->accounttype("VOID");
384
    is( $line->renewable, 0, "Item is returned as unrenewable when it has the wrong account type" );
385
    $line->accounttype("OVERDUE");
386
    $line->status("RETURNED");
387
    is( $line->renewable, 0, "Item is returned as unrenewable when it has the wrong account status" );
388
389
390
    t::lib::Mocks::mock_preference( 'RenewAccruingItemWhenPaid', 0 );
391
    is ($line->renew_item, 0, 'Attempt to renew fails when syspref is not set');
392
    t::lib::Mocks::mock_preference( 'RenewAccruingItemWhenPaid', 1 );
393
    is_deeply(
394
        $line->renew_item,
395
        {
396
            itemnumber => $item->itemnumber,
397
            error      => 'too_many',
398
            success    => 0
399
        },
400
        'Attempt to renew fails when CanBookBeRenewed returns false'
401
    );
402
    $issue->delete;
403
    $issue = $builder->build_object(
404
        {
405
            class => 'Koha::Checkouts',
406
            value => {
407
                itemnumber      => $item->itemnumber,
408
                onsite_checkout => 0,
409
                renewals        => 0,
410
                auto_renew      => 0
411
            }
412
        }
413
    );
414
    my $called = 0;
415
    my $module = new Test::MockModule('C4::Circulation');
416
    $module->mock('AddRenewal', sub { $called = 1; });
417
    $line->renew_item;
418
    is( $called, 1, 'Attempt to renew succeeds when conditions are met' );
419
420
    $schema->storage->txn_rollback;
421
};
422
348
subtest 'adjust() tests' => sub {
423
subtest 'adjust() tests' => sub {
349
424
350
    plan tests => 29;
425
    plan tests => 29;
Lines 606-612 subtest "void() tests" => sub { Link Here
606
            lines  => [$line1, $line2],
681
            lines  => [$line1, $line2],
607
            amount => 30,
682
            amount => 30,
608
        }
683
        }
609
    );
684
    )->{payment_id};
610
685
611
    my $account_payment = Koha::Account::Lines->find( $id );
686
    my $account_payment = Koha::Account::Lines->find( $id );
612
687
613
- 

Return to bug 23051