From ff16a418e4e584854a1245ba4140a1cf0fe3e826 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 | 7 ++++--- t/db_dependent/Circulation/issue.t | 8 +++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 67ee4e56fe..c1e8262bdf 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; } @@ -3165,12 +3165,12 @@ sub _get_discount_from_rule { =head2 AddIssuingCharge - &AddIssuingCharge( $itemno, $borrowernumber, $charge ) + &AddIssuingCharge( $itemno, $borrowernumber, $issue_id, $charge ) =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)