Bugzilla – Attachment 74096 Details for
Bug 20572
Refactor AddIssuingCharges parameter to hashref
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20572: Refactor to hashref parameter
Bug-20572-Refactor-to-hashref-parameter.patch (text/plain), 3.90 KB, created by
Mark Tompsett
on 2018-04-12 13:44:48 UTC
(
hide
)
Description:
Bug 20572: Refactor to hashref parameter
Filename:
MIME Type:
Creator:
Mark Tompsett
Created:
2018-04-12 13:44:48 UTC
Size:
3.90 KB
patch
obsolete
>From 4ccc561d5565149ab307531405e123813adc9f66 Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Thu, 12 Apr 2018 13:29:15 +0000 >Subject: [PATCH] Bug 20572: Refactor to hashref parameter > >Small refactor. Added more tests to confirm no >typos snuck in. > >TEST PLAN >--------- >apply bug 20562 >perldoc C4::Circulation >-- look for the AddIssuingCharge part. >prove t/db_dependent/Circulation/issue.t >-- should pass >apply this patch >perldoc C4::Circulation >-- look for the AddIssuingCharge part. >prove t/db_dependent/Circulation/issue.t >-- should pass >--- > C4/Circulation.pm | 20 +++++++++++++++++--- > t/db_dependent/Circulation/issue.t | 15 +++++++++++++-- > 2 files changed, 30 insertions(+), 5 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index c1e8262..0da5601 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -1406,7 +1406,12 @@ 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({ >+ itemnumber => $item->{'itemnumber'}, >+ borrowernumber => $borrower->{'borrowernumber'}, >+ issue_id => $issue->id, >+ charge => $charge, >+ }); > $item->{'charge'} = $charge; > } > >@@ -3165,12 +3170,21 @@ sub _get_discount_from_rule { > > =head2 AddIssuingCharge > >- &AddIssuingCharge( $itemno, $borrowernumber, $issue_id, $charge ) >+ &AddIssuingCharge({ >+ itemnumber => $itemno, >+ borrowernumber => $borrowernumber, >+ issue_id => $issue_id, >+ charge => $charge, >+ }) > > =cut > > sub AddIssuingCharge { >- my ( $itemnumber, $borrowernumber, $issue_id, $charge ) = @_; >+ my ( $parameters ) = @_; >+ my $itemnumber = $parameters->{itemnumber}; >+ my $borrowernumber = $parameters->{borrowernumber}; >+ my $issue_id = $parameters->{issue_id}; >+ my $charge = $parameters->{charge}; > > my $nextaccntno = getnextacctno($borrowernumber); > >diff --git a/t/db_dependent/Circulation/issue.t b/t/db_dependent/Circulation/issue.t >index e2cbf9d..ef6db4f 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 => 32; >+use Test::More tests => 35; > use DateTime::Duration; > > use t::lib::Mocks; >@@ -53,6 +53,8 @@ can_ok( > ) > ); > >+use constant PI => 3.141592; >+ > #Start transaction > my $schema = Koha::Database->schema; > $schema->storage->txn_begin; >@@ -207,10 +209,19 @@ $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 $offset = C4::Circulation::AddIssuingCharge({ >+ itemnumber => $item_id1, >+ borrowernumber => $borrower_id1, >+ issue_id => $issue_id1, >+ charge => PI, >+}); > is( ref( $offset ), 'Koha::Account::Offset', "An issuing charge has been added" ); > my $charge = Koha::Account::Lines->find( $offset->debit_id ); >+is( $charge->itemnumber, $item_id1, 'Item number is set correctly for issuing charge' ); >+is( $charge->borrowernumber, $borrower_id1, 'Borrower number is set correctly for issuing charge' ); > is( $charge->issue_id, $issue_id1, 'Issue id is set correctly for issuing charge' ); >+# force typecast to keep agnostic of decimal 28,6 definition >+is( $charge->amount+0, PI, 'Charge amount is set correctly for issuing charge' ); > my $account_id = $dbh->last_insert_id( undef, undef, 'accountlines', undef ); > $sth->execute; > $countaccount = $sth -> fetchrow_array; >-- >2.1.4
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 20572
: 74096