Bugzilla – Attachment 74250 Details for
Bug 20562
issue_id is not stored in accountlines for rental fees
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20562: Pass the Koha::Checkout object to AddIssuingCharge
Bug-20562-Pass-the-KohaCheckout-object-to-AddIssui.patch (text/plain), 3.68 KB, created by
Jonathan Druart
on 2018-04-16 16:50:05 UTC
(
hide
)
Description:
Bug 20562: Pass the Koha::Checkout object to AddIssuingCharge
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2018-04-16 16:50:05 UTC
Size:
3.68 KB
patch
obsolete
>From fec8f21e366a95af44e62ef44f653c439c81c28c Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 16 Apr 2018 13:48:54 -0300 >Subject: [PATCH] Bug 20562: Pass the Koha::Checkout object to AddIssuingCharge > >We do not need to pass all those parameters, just the checkout object is >enough. >--- > C4/Circulation.pm | 16 +++++++++------- > t/db_dependent/Circulation/issue.t | 7 ++++--- > 2 files changed, 13 insertions(+), 10 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 9471e67546..1f1a431c7f 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'}, $issue->id, $charge ); >+ AddIssuingCharge( $issue, $charge ); > $item->{'charge'} = $charge; > } > >@@ -3165,23 +3165,25 @@ sub _get_discount_from_rule { > > =head2 AddIssuingCharge > >- &AddIssuingCharge( $itemno, $borrowernumber, $issue_id, $charge ) >+ &AddIssuingCharge( $checkout, $charge ) > > =cut > > sub AddIssuingCharge { >- my ( $itemnumber, $borrowernumber, $issue_id, $charge ) = @_; >+ my ( $checkout, $charge ) = @_; > >- my $nextaccntno = getnextacctno($borrowernumber); >+ # FIXME What if checkout does not exist? >+ >+ my $nextaccntno = getnextacctno($checkout->borrowernumber); > > my $manager_id = 0; > $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; > > my $accountline = Koha::Account::Line->new( > { >- borrowernumber => $borrowernumber, >- itemnumber => $itemnumber, >- issue_id => $issue_id, >+ borrowernumber => $checkout->borrowernumber, >+ itemnumber => $checkout->itemnumber, >+ issue_id => $checkout->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 e2cbf9d7d3..68160dd90b 100644 >--- a/t/db_dependent/Circulation/issue.t >+++ b/t/db_dependent/Circulation/issue.t >@@ -29,6 +29,7 @@ use C4::Context; > use C4::Items; > use C4::Members; > use C4::Reserves; >+use Koha::Checkouts; > use Koha::Database; > use Koha::DateUtils; > use Koha::Holds; >@@ -191,11 +192,10 @@ like( > qr/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/, > "Koha::Schema::Result::Issue->date_due() returns a date" > ); >-my $issue_id1 = $dbh->last_insert_id( undef, undef, 'issues', undef ); >+my $issue_id1 = $issue1->issue_id; > > my $issue2 = C4::Circulation::AddIssue( $borrower_1, 'nonexistent_barcode' ); > is( $issue2, undef, "AddIssue returns undef if no datedue is specified" ); >-my $issue_id2 = $dbh->last_insert_id( undef, undef, 'issues', undef ); > > $sth->execute; > $countissue = $sth -> fetchrow_array; >@@ -207,7 +207,8 @@ $sth = $dbh->prepare($query); > $sth->execute; > my $countaccount = $sth -> fetchrow_array; > is ($countaccount,0,"0 accountline exists"); >-my $offset = C4::Circulation::AddIssuingCharge( $item_id1, $borrower_id1, $issue_id1, 10 ); >+my $checkout = Koha::Checkouts->find( $issue_id1 ); >+my $offset = C4::Circulation::AddIssuingCharge( $checkout, 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' ); >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 20562
:
74019
|
74020
|
74021
|
74102
|
74240
|
74250
|
74253
|
74584
|
74586