From 28ec66b3fe3b90e4de5c16e848824eb829f6a7ce Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Sun, 8 Apr 2018 07:11:11 +0000 Subject: [PATCH] Bug 20562: issue_id is not stored in accountlines for rental fees To recreate: 1 - Assign a charge to an item type 2 - Checkout an item of that type to a patron 3 - View the accountlines table for that patron SELECT * FROM accountlines WHERE accounttype='Rent' and borrowernumber=##; 4 - Note there is no issue_id Test Plan: 1) Apply this patch 2) prove t/db_dependent/Circulation/issue.t --- C4/Circulation.pm | 5 +++-- t/db_dependent/Circulation/issue.t | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 67ee4e56fe..e8ff815257 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1406,7 +1406,7 @@ sub AddIssue { # If it costs to borrow this book, charge it to the patron's account. my ( $charge, $itemtype ) = GetIssuingCharges( $item->{'itemnumber'}, $borrower->{'borrowernumber'} ); if ( $charge > 0 ) { - AddIssuingCharge( $item->{'itemnumber'}, $borrower->{'borrowernumber'}, $charge ); + AddIssuingCharge( $item->{'itemnumber'}, $borrower->{'borrowernumber'}, $issue->id, $charge ); $item->{'charge'} = $charge; } @@ -3170,7 +3170,7 @@ sub _get_discount_from_rule { =cut sub AddIssuingCharge { - my ( $itemnumber, $borrowernumber, $charge ) = @_; + my ( $itemnumber, $borrowernumber, $issue_id, $charge ) = @_; my $nextaccntno = getnextacctno($borrowernumber); @@ -3181,6 +3181,7 @@ sub AddIssuingCharge { { borrowernumber => $borrowernumber, itemnumber => $itemnumber, + issue_id => $issue_id, accountno => $nextaccntno, amount => $charge, amountoutstanding => $charge, diff --git a/t/db_dependent/Circulation/issue.t b/t/db_dependent/Circulation/issue.t index 0986d0283a..e2cbf9d7d3 100644 --- a/t/db_dependent/Circulation/issue.t +++ b/t/db_dependent/Circulation/issue.t @@ -17,7 +17,7 @@ use Modern::Perl; -use Test::More tests => 31; +use Test::More tests => 32; use DateTime::Duration; use t::lib::Mocks; @@ -207,8 +207,10 @@ $sth = $dbh->prepare($query); $sth->execute; my $countaccount = $sth -> fetchrow_array; is ($countaccount,0,"0 accountline exists"); -is( ref( C4::Circulation::AddIssuingCharge( $item_id1, $borrower_id1, 10 ) ), - 'Koha::Account::Offset', "An issuing charge has been added" ); +my $offset = C4::Circulation::AddIssuingCharge( $item_id1, $borrower_id1, $issue_id1, 10 ); +is( ref( $offset ), 'Koha::Account::Offset', "An issuing charge has been added" ); +my $charge = Koha::Account::Lines->find( $offset->debit_id ); +is( $charge->issue_id, $issue_id1, 'Issue id is set correctly for issuing charge' ); my $account_id = $dbh->last_insert_id( undef, undef, 'accountlines', undef ); $sth->execute; $countaccount = $sth -> fetchrow_array; -- 2.15.1 (Apple Git-101)