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

(-)a/C4/Circulation.pm (-3 / +4 lines)
Lines 1406-1412 sub AddIssue { Link Here
1406
           # If it costs to borrow this book, charge it to the patron's account.
1406
           # If it costs to borrow this book, charge it to the patron's account.
1407
            my ( $charge, $itemtype ) = GetIssuingCharges( $item->{'itemnumber'}, $borrower->{'borrowernumber'} );
1407
            my ( $charge, $itemtype ) = GetIssuingCharges( $item->{'itemnumber'}, $borrower->{'borrowernumber'} );
1408
            if ( $charge > 0 ) {
1408
            if ( $charge > 0 ) {
1409
                AddIssuingCharge( $item->{'itemnumber'}, $borrower->{'borrowernumber'}, $charge );
1409
                AddIssuingCharge( $item->{'itemnumber'}, $borrower->{'borrowernumber'}, $issue->id, $charge );
1410
                $item->{'charge'} = $charge;
1410
                $item->{'charge'} = $charge;
1411
            }
1411
            }
1412
1412
Lines 3165-3176 sub _get_discount_from_rule { Link Here
3165
3165
3166
=head2 AddIssuingCharge
3166
=head2 AddIssuingCharge
3167
3167
3168
  &AddIssuingCharge( $itemno, $borrowernumber, $charge )
3168
  &AddIssuingCharge( $itemno, $borrowernumber, $issue_id, $charge )
3169
3169
3170
=cut
3170
=cut
3171
3171
3172
sub AddIssuingCharge {
3172
sub AddIssuingCharge {
3173
    my ( $itemnumber, $borrowernumber, $charge ) = @_;
3173
    my ( $itemnumber, $borrowernumber, $issue_id, $charge ) = @_;
3174
3174
3175
    my $nextaccntno = getnextacctno($borrowernumber);
3175
    my $nextaccntno = getnextacctno($borrowernumber);
3176
3176
Lines 3181-3186 sub AddIssuingCharge { Link Here
3181
        {
3181
        {
3182
            borrowernumber    => $borrowernumber,
3182
            borrowernumber    => $borrowernumber,
3183
            itemnumber        => $itemnumber,
3183
            itemnumber        => $itemnumber,
3184
            issue_id          => $issue_id,
3184
            accountno         => $nextaccntno,
3185
            accountno         => $nextaccntno,
3185
            amount            => $charge,
3186
            amount            => $charge,
3186
            amountoutstanding => $charge,
3187
            amountoutstanding => $charge,
(-)a/t/db_dependent/Circulation/issue.t (-4 / +5 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 31;
20
use Test::More tests => 32;
21
use DateTime::Duration;
21
use DateTime::Duration;
22
22
23
use t::lib::Mocks;
23
use t::lib::Mocks;
Lines 207-214 $sth = $dbh->prepare($query); Link Here
207
$sth->execute;
207
$sth->execute;
208
my $countaccount = $sth -> fetchrow_array;
208
my $countaccount = $sth -> fetchrow_array;
209
is ($countaccount,0,"0 accountline exists");
209
is ($countaccount,0,"0 accountline exists");
210
is( ref( C4::Circulation::AddIssuingCharge( $item_id1, $borrower_id1, 10 ) ),
210
my $offset = C4::Circulation::AddIssuingCharge( $item_id1, $borrower_id1, $issue_id1, 10 );
211
    'Koha::Account::Offset', "An issuing charge has been added" );
211
is( ref( $offset ), 'Koha::Account::Offset', "An issuing charge has been added" );
212
my $charge = Koha::Account::Lines->find( $offset->debit_id );
213
is( $charge->issue_id, $issue_id1, 'Issue id is set correctly for issuing charge' );
212
my $account_id = $dbh->last_insert_id( undef, undef, 'accountlines', undef );
214
my $account_id = $dbh->last_insert_id( undef, undef, 'accountlines', undef );
213
$sth->execute;
215
$sth->execute;
214
$countaccount = $sth -> fetchrow_array;
216
$countaccount = $sth -> fetchrow_array;
215
- 

Return to bug 20562