Bugzilla – Attachment 66999 Details for
Bug 19280
CanBookBeIssued must take a Koha::Patron in parameter
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19280: Pass a Koha::Patron to CanBookBeIssued
Bug-19280-Pass-a-KohaPatron-to-CanBookBeIssued.patch (text/plain), 27.66 KB, created by
Jonathan Druart
on 2017-09-08 15:54:40 UTC
(
hide
)
Description:
Bug 19280: Pass a Koha::Patron to CanBookBeIssued
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2017-09-08 15:54:40 UTC
Size:
27.66 KB
patch
obsolete
>From 06a2d2ebb19b5ca3de4adcaba516bb8c650aa49e Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 8 Sep 2017 12:51:28 -0300 >Subject: [PATCH] Bug 19280: Pass a Koha::Patron to CanBookBeIssued > >We need to make subroutine from C4 use more Koha::Object objects >Seeing bug 19276, starting here is a good start. > >Test plan: >The tests should still pass. >--- > C4/Circulation.pm | 52 +++++++++++----------- > C4/ILSDI/Services.pm | 2 +- > circ/circulation.pl | 2 +- > opac/sco/sco-main.pl | 10 ++--- > t/db_dependent/Circulation.t | 20 ++++----- > .../Circulation/NoIssuesChargeGuarantees.t | 6 +-- > t/db_dependent/Circulation/SwitchOnSiteCheckouts.t | 13 +++--- > t/db_dependent/Circulation/dateexpiry.t | 15 +++---- > t/db_dependent/DecreaseLoanHighHolds.t | 7 +-- > t/db_dependent/Patron/Borrower_PrevCheckout.t | 4 +- > t/db_dependent/rollingloans.t | 6 +-- > 11 files changed, 68 insertions(+), 69 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 6ac795c..bcbbbe7 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -565,7 +565,7 @@ sub TooMany { > > =head2 CanBookBeIssued > >- ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $borrower, >+ ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, > $barcode, $duedate, $inprocess, $ignore_reserves, $params ); > > Check if a book can be issued. >@@ -574,7 +574,7 @@ C<$issuingimpossible> and C<$needsconfirmation> are some hashref. > > =over 4 > >-=item C<$borrower> hash with borrower informations (from Koha::Patron->unblessed) >+=item C<$patron> is a Koha::Patron > > =item C<$barcode> is the bar code of the book being issued. > >@@ -665,7 +665,7 @@ if the borrower borrows to much things > =cut > > sub CanBookBeIssued { >- my ( $borrower, $barcode, $duedate, $inprocess, $ignore_reserves, $params ) = @_; >+ my ( $patron, $barcode, $duedate, $inprocess, $ignore_reserves, $params ) = @_; > my %needsconfirmation; # filled with problems that needs confirmations > my %issuingimpossible; # filled with problems that causes the issue to be IMPOSSIBLE > my %alerts; # filled with messages that shouldn't stop issuing, but the librarian should be aware of. >@@ -679,6 +679,7 @@ sub CanBookBeIssued { > my $biblioitem = GetBiblioItemData($item->{biblioitemnumber}); > $item->{'itemtype'}=$item->{'itype'}; > my $dbh = C4::Context->dbh; >+ my $patron_unblessed = $patron->unblessed; > > # MANDATORY CHECKS - unless item exists, nothing else matters > unless ( $item->{barcode} ) { >@@ -696,9 +697,9 @@ sub CanBookBeIssued { > unless ( $duedate ) { > my $issuedate = $now->clone(); > >- my $branch = _GetCircControlBranch($item,$borrower); >+ my $branch = _GetCircControlBranch($item, $patron_unblessed); > my $itype = ( C4::Context->preference('item-level_itypes') ) ? $item->{'itype'} : $biblioitem->{'itemtype'}; >- $duedate = CalcDateDue( $issuedate, $itype, $branch, $borrower ); >+ $duedate = CalcDateDue( $issuedate, $itype, $branch, $patron_unblessed ); > > # Offline circ calls AddIssue directly, doesn't run through here > # So issuingimpossible should be ok. >@@ -716,7 +717,6 @@ sub CanBookBeIssued { > # > # BORROWER STATUS > # >- my $patron = Koha::Patrons->find( $borrower->{borrowernumber} ); > if ( $patron->category->category_type eq 'X' && ( $item->{barcode} )) { > # stats only borrower -- add entry to statistics table, and return issuingimpossible{STATS} = 1 . > &UpdateStats({ >@@ -724,14 +724,14 @@ sub CanBookBeIssued { > type => 'localuse', > itemnumber => $item->{'itemnumber'}, > itemtype => $item->{'itype'}, >- borrowernumber => $borrower->{'borrowernumber'}, >+ borrowernumber => $patron->borrowernumber, > ccode => $item->{'ccode'}} > ); > ModDateLastSeen( $item->{'itemnumber'} ); > return( { STATS => 1 }, {}); > } > >- my $flags = C4::Members::patronflags( $borrower ); >+ my $flags = C4::Members::patronflags( $patron_unblessed ); > if ( ref $flags ) { > if ( $flags->{GNA} ) { > $issuingimpossible{GNA} = 1; >@@ -743,10 +743,10 @@ sub CanBookBeIssued { > $issuingimpossible{DEBARRED} = 1; > } > } >- if ( !defined $borrower->{dateexpiry} || $borrower->{'dateexpiry'} eq '0000-00-00') { >+ if ( !defined $patron->dateexpiry || $patron->dateexpiry eq '0000-00-00') { > $issuingimpossible{EXPIRED} = 1; > } else { >- my $expiry_dt = dt_from_string( $borrower->{dateexpiry}, 'sql', 'floating' ); >+ my $expiry_dt = dt_from_string( $patron->dateexpiry, 'sql', 'floating' ); > $expiry_dt->truncate( to => 'day'); > my $today = $now->clone()->truncate(to => 'day'); > $today->set_time_zone( 'floating' ); >@@ -761,7 +761,7 @@ sub CanBookBeIssued { > > # DEBTS > my ($balance, $non_issue_charges, $other_charges) = >- C4::Members::GetMemberAccountBalance( $borrower->{'borrowernumber'} ); >+ C4::Members::GetMemberAccountBalance( $patron->borrowernumber ); > > my $amountlimit = C4::Context->preference("noissuescharge"); > my $allowfineoverride = C4::Context->preference("AllowFineOverride"); >@@ -771,8 +771,7 @@ sub CanBookBeIssued { > my $no_issues_charge_guarantees = C4::Context->preference("NoIssuesChargeGuarantees"); > $no_issues_charge_guarantees = undef unless looks_like_number( $no_issues_charge_guarantees ); > if ( defined $no_issues_charge_guarantees ) { >- my $p = Koha::Patrons->find( $borrower->{borrowernumber} ); >- my @guarantees = $p->guarantees(); >+ my @guarantees = $patron->guarantees(); > my $guarantees_non_issues_charges; > foreach my $g ( @guarantees ) { > my ( $b, $n, $o ) = C4::Members::GetMemberAccountBalance( $g->id ); >@@ -811,7 +810,7 @@ sub CanBookBeIssued { > $alerts{OTHER_CHARGES} = sprintf( "%.2f", $other_charges ); > } > >- $patron = Koha::Patrons->find( $borrower->{borrowernumber} ); >+ $patron = Koha::Patrons->find( $patron->borrowernumber ); # FIXME Refetch just in case, to avoid regressions. But must not be needed > if ( my $debarred_date = $patron->is_debarred ) { > # patron has accrued fine days or has a restriction. $count is a date > if ($debarred_date eq '9999-12-31') { >@@ -836,8 +835,8 @@ sub CanBookBeIssued { > C4::Context->preference('SwitchOnSiteCheckouts') > and $issue > and $issue->onsite_checkout >- and $issue->borrowernumber == $borrower->{'borrowernumber'} ? 1 : 0 ); >- my $toomany = TooMany( $borrower, $item->{biblionumber}, $item, { onsite_checkout => $onsite_checkout, switch_onsite_checkout => $switch_onsite_checkout, } ); >+ and $issue->borrowernumber == $patron->borrowernumber ? 1 : 0 ); >+ my $toomany = TooMany( $patron_unblessed, $item->{biblionumber}, $item, { onsite_checkout => $onsite_checkout, switch_onsite_checkout => $switch_onsite_checkout, } ); > # if TooMany max_allowed returns 0 the user doesn't have permission to check out this book > if ( $toomany ) { > if ( $toomany->{max_allowed} == 0 ) { >@@ -857,7 +856,7 @@ sub CanBookBeIssued { > # > # CHECKPREVCHECKOUT: CHECK IF ITEM HAS EVER BEEN LENT TO PATRON > # >- $patron = Koha::Patrons->find($borrower->{borrowernumber}); >+ $patron = Koha::Patrons->find( $patron->borrowernumber ); # FIXME Refetch just in case, to avoid regressions. But must not be needed > my $wants_check = $patron->wants_check_for_previous_checkout; > $needsconfirmation{PREVISSUE} = 1 > if ($wants_check and $patron->do_check_for_previous_checkout($item)); >@@ -924,8 +923,8 @@ sub CanBookBeIssued { > $issuingimpossible{ITEMNOTSAMEBRANCH} = 1; > $issuingimpossible{'itemhomebranch'} = $item->{C4::Context->preference("HomeOrHoldingBranch")}; > } >- $needsconfirmation{BORRNOTSAMEBRANCH} = $borrower->{'branchcode'} >- if ( $borrower->{'branchcode'} ne $userenv->{branch} ); >+ $needsconfirmation{BORRNOTSAMEBRANCH} = $patron->branchcode >+ if ( $patron->branchcode ne $userenv->{branch} ); > } > } > # >@@ -934,7 +933,7 @@ sub CanBookBeIssued { > my $rentalConfirmation = C4::Context->preference("RentalFeesCheckoutConfirmation"); > > if ( $rentalConfirmation ){ >- my ($rentalCharge) = GetIssuingCharges( $item->{'itemnumber'}, $borrower->{'borrowernumber'} ); >+ my ($rentalCharge) = GetIssuingCharges( $item->{'itemnumber'}, $patron->borrowernumber ); > if ( $rentalCharge > 0 ){ > $needsconfirmation{RENTALCHARGE} = $rentalCharge; > } >@@ -943,7 +942,7 @@ sub CanBookBeIssued { > # > # CHECK IF BOOK ALREADY ISSUED TO THIS BORROWER > # >- if ( $issue && $issue->borrowernumber eq $borrower->{'borrowernumber'} ){ >+ if ( $issue && $issue->borrowernumber eq $patron->borrowernumber ){ > > # Already issued to current borrower. > # If it is an on-site checkout if it can be switched to a normal checkout >@@ -954,7 +953,7 @@ sub CanBookBeIssued { > $messages{ONSITE_CHECKOUT_WILL_BE_SWITCHED} = 1; > } else { > my ($CanBookBeRenewed,$renewerror) = CanBookBeRenewed( >- $borrower->{'borrowernumber'}, >+ $patron->borrowernumber, > $item->{'itemnumber'}, > ); > if ( $CanBookBeRenewed == 0 ) { # no more renewals allowed >@@ -995,7 +994,7 @@ sub CanBookBeIssued { > my ( $restype, $res ) = C4::Reserves::CheckReserves( $item->{'itemnumber'} ); > if ($restype) { > my $resbor = $res->{'borrowernumber'}; >- if ( $resbor ne $borrower->{'borrowernumber'} ) { >+ if ( $resbor ne $patron->borrowernumber ) { > my $patron = Koha::Patrons->find( $resbor ); > if ( $restype eq "Waiting" ) > { >@@ -1025,7 +1024,7 @@ sub CanBookBeIssued { > > ## CHECK AGE RESTRICTION > my $agerestriction = $biblioitem->{'agerestriction'}; >- my ($restriction_age, $daysToAgeRestriction) = GetAgeRestriction( $agerestriction, $borrower ); >+ my ($restriction_age, $daysToAgeRestriction) = GetAgeRestriction( $agerestriction, $patron->unblessed ); > if ( $daysToAgeRestriction && $daysToAgeRestriction > 0 ) { > if ( C4::Context->preference('AgeRestrictionOverride') ) { > $needsconfirmation{AGE_RESTRICTION} = "$agerestriction"; >@@ -1037,7 +1036,7 @@ sub CanBookBeIssued { > > ## check for high holds decreasing loan period > if ( C4::Context->preference('decreaseLoanHighHolds') ) { >- my $check = checkHighHolds( $item, $borrower ); >+ my $check = checkHighHolds( $item, $patron_unblessed ); > > if ( $check->{exceeded} ) { > if ($override_high_holds) { >@@ -1070,9 +1069,10 @@ sub CanBookBeIssued { > require C4::Serials; > my $is_a_subscription = C4::Serials::CountSubscriptionFromBiblionumber($biblionumber); > unless ($is_a_subscription) { >+ # FIXME Should be $patron->checkouts($args); > my $checkouts = Koha::Checkouts->search( > { >- borrowernumber => $borrower->{borrowernumber}, >+ borrowernumber => $patron->borrowernumber, > biblionumber => $biblionumber, > }, > { >diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm >index f42a86b..118f3c3 100644 >--- a/C4/ILSDI/Services.pm >+++ b/C4/ILSDI/Services.pm >@@ -550,7 +550,7 @@ sub GetServices { > my $barcode = $item->{'barcode'} || ''; > $barcode = barcodedecode($barcode) if ( $barcode && C4::Context->preference('itemBarcodeInputFilter') ); > if ($barcode) { >- my ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $borrower, $barcode ); >+ my ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $barcode ); > > # TODO push @availablefor, 'loan'; > } >diff --git a/circ/circulation.pl b/circ/circulation.pl >index 130d350..b3df74e 100755 >--- a/circ/circulation.pl >+++ b/circ/circulation.pl >@@ -315,7 +315,7 @@ if (@$barcodes) { > my $template_params = { barcode => $barcode }; > # always check for blockers on issuing > my ( $error, $question, $alerts, $messages ) = CanBookBeIssued( >- $patron->unblessed, >+ $patron, > $barcode, $datedue, > $inprocess, > undef, >diff --git a/opac/sco/sco-main.pl b/opac/sco/sco-main.pl >index d6e4176..4a14858 100755 >--- a/opac/sco/sco-main.pl >+++ b/opac/sco/sco-main.pl >@@ -108,10 +108,10 @@ if (C4::Context->preference('SelfCheckoutByLogin') && !$patronid) { > ($resval, $patronid) = checkpw($dbh, $patronlogin, $patronpw); > } > >-my $borrower; >+my ( $borrower, $patron ); > if ( $patronid ) { >- $borrower = Koha::Patrons->find( { cardnumber => $patronid } ); >- $borrower = $borrower->unblessed if $borrower; >+ $patron = Koha::Patrons->find( { cardnumber => $patronid } ); >+ $borrower = $patron->unblessed if $patron; > } > > my $currencySymbol = ""; >@@ -130,11 +130,11 @@ if ($op eq "logout") { > elsif ( $op eq "returnbook" && $allowselfcheckreturns ) { > my ($doreturn) = AddReturn( $barcode, $branch ); > } >-elsif ( $borrower and $op eq "checkout" ) { >+elsif ( $patron and $op eq "checkout" ) { > my $impossible = {}; > my $needconfirm = {}; > ( $impossible, $needconfirm ) = CanBookBeIssued( >- $borrower, >+ $patron, > $barcode, > undef, > 0, >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 98f6790..163e89d 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -1135,8 +1135,8 @@ subtest 'CanBookBeIssued & AllowReturnToBranch' => sub { > my $homebranch = $builder->build( { source => 'Branch' } ); > my $holdingbranch = $builder->build( { source => 'Branch' } ); > my $otherbranch = $builder->build( { source => 'Branch' } ); >- my $patron_1 = $builder->build( { source => 'Borrower' } ); >- my $patron_2 = $builder->build( { source => 'Borrower' } ); >+ my $patron_1 = $builder->build_object( { class => 'Koha::Patrons' } ); >+ my $patron_2 = $builder->build_object( { class => 'Koha::Patrons' } ); > > my $biblioitem = $builder->build( { source => 'Biblioitem' } ); > my $item = $builder->build( >@@ -1155,7 +1155,7 @@ subtest 'CanBookBeIssued & AllowReturnToBranch' => sub { > > set_userenv($holdingbranch); > >- my $issue = AddIssue( $patron_1, $item->{barcode} ); >+ my $issue = AddIssue( $patron_1->unblessed, $item->{barcode} ); > is( ref($issue), 'Koha::Schema::Result::Issue' ); # FIXME Should be Koha::Checkout > > my ( $error, $question, $alerts ); >@@ -1300,7 +1300,7 @@ subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub { > plan tests => 8; > > my $library = $builder->build( { source => 'Branch' } ); >- my $patron = $builder->build( { source => 'Borrower', value => { gonenoaddress => undef, lost => undef, debarred => undef, borrowernotes => "" } } ); >+ my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { gonenoaddress => undef, lost => undef, debarred => undef, borrowernotes => "" } } ); > > my $biblioitem_1 = $builder->build( { source => 'Biblioitem' } ); > my $item_1 = $builder->build( >@@ -1335,7 +1335,7 @@ subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub { > > # Patron cannot issue item_1, they have overdues > my $yesterday = DateTime->today( time_zone => C4::Context->tz() )->add( days => -1 ); >- my $issue = AddIssue( $patron, $item_1->{barcode}, $yesterday ); # Add an overdue >+ my $issue = AddIssue( $patron->unblessed, $item_1->{barcode}, $yesterday ); # Add an overdue > > t::lib::Mocks::mock_preference( 'OverduesBlockCirc', 'confirmation' ); > ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); >@@ -1349,12 +1349,12 @@ subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub { > > # Patron cannot issue item_1, they are debarred > my $tomorrow = DateTime->today( time_zone => C4::Context->tz() )->add( days => 1 ); >- Koha::Patron::Debarments::AddDebarment( { borrowernumber => $patron->{borrowernumber}, expiration => $tomorrow } ); >+ Koha::Patron::Debarments::AddDebarment( { borrowernumber => $patron->borrowernumber, expiration => $tomorrow } ); > ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); > is( keys(%$question) + keys(%$alerts), 0, 'No key for question and alert ' . keys(%$question) . ' ' . keys(%$alerts) ); > is( $error->{USERBLOCKEDWITHENDDATE}, output_pref( { dt => $tomorrow, dateformat => 'sql', dateonly => 1 } ), 'USERBLOCKEDWITHENDDATE should be tomorrow' ); > >- Koha::Patron::Debarments::AddDebarment( { borrowernumber => $patron->{borrowernumber} } ); >+ Koha::Patron::Debarments::AddDebarment( { borrowernumber => $patron->borrowernumber } ); > ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); > is( keys(%$question) + keys(%$alerts), 0, 'No key for question and alert ' . keys(%$question) . ' ' . keys(%$alerts) ); > is( $error->{USERBLOCKEDNOENDDATE}, '9999-12-31', 'USERBLOCKEDNOENDDATE should be 9999-12-31 for unlimited debarments' ); >@@ -1398,7 +1398,7 @@ subtest 'CanBookBeIssued + Statistic patrons "X"' => sub { > } > ); > >- my ( $error, $question, $alerts ) = CanBookBeIssued( $patron->unblessed, $item_1->{barcode} ); >+ my ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_1->{barcode} ); > is( $error->{STATS}, 1, '"Error" flag "STATS" must be set if CanBookBeIssued is called with a statistic patron (category_type=X)' ); > > # TODO There are other tests to provide here >@@ -1516,7 +1516,7 @@ subtest 'CanBookBeIssued + AllowMultipleIssuesOnABiblio' => sub { > plan tests => 5; > > my $library = $builder->build( { source => 'Branch' } ); >- my $patron = $builder->build( { source => 'Borrower' } ); >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); > > my $biblioitem = $builder->build( { source => 'Biblioitem' } ); > my $biblionumber = $biblioitem->{biblionumber}; >@@ -1546,7 +1546,7 @@ subtest 'CanBookBeIssued + AllowMultipleIssuesOnABiblio' => sub { > ); > > my ( $error, $question, $alerts ); >- my $issue = AddIssue( $patron, $item_1->{barcode}, dt_from_string->add( days => 1 ) ); >+ my $issue = AddIssue( $patron->unblessed, $item_1->{barcode}, dt_from_string->add( days => 1 ) ); > > t::lib::Mocks::mock_preference('AllowMultipleIssuesOnABiblio', 0); > ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); >diff --git a/t/db_dependent/Circulation/NoIssuesChargeGuarantees.t b/t/db_dependent/Circulation/NoIssuesChargeGuarantees.t >index 1fc8aa0..6a63929 100644 >--- a/t/db_dependent/Circulation/NoIssuesChargeGuarantees.t >+++ b/t/db_dependent/Circulation/NoIssuesChargeGuarantees.t >@@ -40,16 +40,16 @@ my $item = $builder->build( > } > ); > >-my $patron = $builder->build( >+my $patron = $builder->build_object( > { >- source => 'Borrower', >+ class => 'Koha::Patrons', > } > ); > my $guarantee = $builder->build( > { > source => 'Borrower', > value => { >- guarantorid => $patron->{borrowernumber}, >+ guarantorid => $patron->borrowernumber, > } > } > ); >diff --git a/t/db_dependent/Circulation/SwitchOnSiteCheckouts.t b/t/db_dependent/Circulation/SwitchOnSiteCheckouts.t >index 3397e23..c05bdfe 100644 >--- a/t/db_dependent/Circulation/SwitchOnSiteCheckouts.t >+++ b/t/db_dependent/Circulation/SwitchOnSiteCheckouts.t >@@ -50,13 +50,14 @@ my $branch = $builder->build({ > source => 'Branch', > }); > >-my $patron = $builder->build({ >- source => 'Borrower', >+my $patron = $builder->build_object({ >+ class => 'Koha::Patrons', > value => { > branchcode => $branch->{branchcode}, > debarred => undef, > }, > }); >+my $patron_unblessed = $patron->unblessed; > > my $biblio = $builder->build({ > source => 'Biblio', >@@ -90,12 +91,12 @@ my $issuingrule = $builder->build({ > }); > > C4::Context->_new_userenv ('DUMMY_SESSION_ID'); >-C4::Context->set_userenv($patron->{borrowernumber}, $patron->{userid}, 'usercnum', 'First name', 'Surname', $branch->{branchcode}, 'My Library', 0); >+C4::Context->set_userenv($patron->borrowernumber, $patron->userid, 'usercnum', 'First name', 'Surname', $branch->{branchcode}, 'My Library', 0); > > t::lib::Mocks::mock_preference('AllowTooManyOverride', 0); > > # Add onsite checkout >-C4::Circulation::AddIssue( $patron, $item->{barcode}, dt_from_string, undef, dt_from_string, undef, { onsite_checkout => 1 } ); >+C4::Circulation::AddIssue( $patron_unblessed, $item->{barcode}, dt_from_string, undef, dt_from_string, undef, { onsite_checkout => 1 } ); > > my ( $impossible, $messages ); > t::lib::Mocks::mock_preference('SwitchOnSiteCheckouts', 0); >@@ -106,7 +107,7 @@ t::lib::Mocks::mock_preference('SwitchOnSiteCheckouts', 1); > ( $impossible, undef, undef, $messages ) = C4::Circulation::CanBookBeIssued( $patron, $item->{barcode} ); > is( $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED}, 1, 'If SwitchOnSiteCheckouts, switch the on-site checkout' ); > is( exists $impossible->{TOO_MANY}, '', 'If SwitchOnSiteCheckouts, switch the on-site checkout' ); >-C4::Circulation::AddIssue( $patron, $item->{barcode}, undef, undef, undef, undef, { switch_onsite_checkout => 1 } ); >+C4::Circulation::AddIssue( $patron_unblessed, $item->{barcode}, undef, undef, undef, undef, { switch_onsite_checkout => 1 } ); > my $issue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } ); > is( $issue->onsite_checkout, 0, 'The issue should have been switched to a regular checkout' ); > my $five_days_after = dt_from_string->add( days => 5 )->set( hour => 23, minute => 59, second => 0 ); >@@ -126,7 +127,7 @@ my $another_item = $builder->build({ > }, > }); > >-C4::Circulation::AddIssue( $patron, $another_item->{barcode}, dt_from_string, undef, dt_from_string, undef, { onsite_checkout => 1 } ); >+C4::Circulation::AddIssue( $patron_unblessed, $another_item->{barcode}, dt_from_string, undef, dt_from_string, undef, { onsite_checkout => 1 } ); > ( $impossible, undef, undef, $messages ) = C4::Circulation::CanBookBeIssued( $patron, $another_item->{barcode} ); > is( $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED}, 1, 'Specific case 1 - Switch is allowed' ); > is( exists $impossible->{TOO_MANY}, '', 'Specific case 1 - Switch is allowed' ); >diff --git a/t/db_dependent/Circulation/dateexpiry.t b/t/db_dependent/Circulation/dateexpiry.t >index dbb7e0b..c5e6498 100644 >--- a/t/db_dependent/Circulation/dateexpiry.t >+++ b/t/db_dependent/Circulation/dateexpiry.t >@@ -45,12 +45,11 @@ subtest 'Tests for CalcDateDue related to dateexpiry' => sub { > > sub can_book_be_issued { > my $item = $builder->build( { source => 'Item' } ); >- my $patron = $builder->build( >- { source => 'Borrower', >+ my $patron = $builder->build_object( >+ { class => 'Koha::Patrons', > value => { dateexpiry => '9999-12-31' } > } > ); >- $patron->{flags} = C4::Members::patronflags( $patron ); > my $duration = gettimeofday(); > my ( $issuingimpossible, $needsconfirmation ) = C4::Circulation::CanBookBeIssued( $patron, $item->{barcode} ); > $duration = gettimeofday() - $duration; >@@ -58,23 +57,21 @@ sub can_book_be_issued { > is( not( exists $issuingimpossible->{EXPIRED} ), 1, 'The patron should not be considered as expired if dateexpiry is 9999-*' ); > > $item = $builder->build( { source => 'Item' } ); >- $patron = $builder->build( >- { source => 'Borrower', >+ $patron = $builder->build_object( >+ { class => 'Koha::Patrons', > value => { dateexpiry => '0000-00-00' } > } > ); >- $patron->{flags} = C4::Members::patronflags( $patron ); > ( $issuingimpossible, $needsconfirmation ) = C4::Circulation::CanBookBeIssued( $patron, $item->{barcode} ); > is( $issuingimpossible->{EXPIRED}, 1, 'The patron should be considered as expired if dateexpiry is 0000-00-00' ); > > my $tomorrow = dt_from_string->add_duration( DateTime::Duration->new( days => 1 ) ); > $item = $builder->build( { source => 'Item' } ); >- $patron = $builder->build( >- { source => 'Borrower', >+ $patron = $builder->build_object( >+ { class => 'Koha::Patrons', > value => { dateexpiry => output_pref( { dt => $tomorrow, dateonly => 1, dateformat => 'sql' } ) }, > } > ); >- $patron->{flags} = C4::Members::patronflags( $patron ); > ( $issuingimpossible, $needsconfirmation ) = C4::Circulation::CanBookBeIssued( $patron, $item->{barcode} ); > is( not( exists $issuingimpossible->{EXPIRED} ), 1, 'The patron should not be considered as expired if dateexpiry is tomorrow' ); > >diff --git a/t/db_dependent/DecreaseLoanHighHolds.t b/t/db_dependent/DecreaseLoanHighHolds.t >index 00d1b9f..c860566 100755 >--- a/t/db_dependent/DecreaseLoanHighHolds.t >+++ b/t/db_dependent/DecreaseLoanHighHolds.t >@@ -19,7 +19,7 @@ use Modern::Perl; > > use C4::Circulation; > use Koha::Database; >-use Koha::Patron; >+use Koha::Patrons; > use Koha::Biblio; > use Koha::Item; > use Koha::Holds; >@@ -183,10 +183,11 @@ is( $data->{exceeded}, 1, "Should exceed threshold with one withdrawn item" ); > > t::lib::Mocks::mock_preference('CircControl', 'PatronLibrary'); > >-my ( undef, $needsconfirmation ) = CanBookBeIssued( $patron_hr, $item->barcode ); >+my $patron_object = Koha::Patrons->find( $patron_hr->{borrowernumber} ); >+my ( undef, $needsconfirmation ) = CanBookBeIssued( $patron_object, $item->barcode ); > ok( $needsconfirmation->{HIGHHOLDS}, "High holds checkout needs confirmation" ); > >-( undef, $needsconfirmation ) = CanBookBeIssued( $patron_hr, $item->barcode, undef, undef, undef, { override_high_holds => 1 } ); >+( undef, $needsconfirmation ) = CanBookBeIssued( $patron_object, $item->barcode, undef, undef, undef, { override_high_holds => 1 } ); > ok( !$needsconfirmation->{HIGHHOLDS}, "High holds checkout does not need confirmation" ); > > $schema->storage->txn_rollback(); >diff --git a/t/db_dependent/Patron/Borrower_PrevCheckout.t b/t/db_dependent/Patron/Borrower_PrevCheckout.t >index 956f58a..3c70525 100644 >--- a/t/db_dependent/Patron/Borrower_PrevCheckout.t >+++ b/t/db_dependent/Patron/Borrower_PrevCheckout.t >@@ -379,7 +379,7 @@ test_it($cpvPmappings, "PostReturn"); > > # Our Patron > my $CBBI_patron = $builder->build({source => 'Borrower'}); >-$patron = Koha::Patrons->find( $CBBI_patron->{borrowernumber} )->unblessed; >+$patron = Koha::Patrons->find( $CBBI_patron->{borrowernumber} ); > # Our Items > my $new_item = $builder->build({ > source => 'Item', >@@ -399,7 +399,7 @@ my $prev_item = $builder->build({ > }); > # Second is Checked Out > BAIL_OUT("CanBookBeIssued Issue failed") >- unless AddIssue($patron, $prev_item->{barcode}); >+ unless AddIssue($patron->unblessed, $prev_item->{barcode}); > > # Mappings > my $CBBI_mappings = [ >diff --git a/t/db_dependent/rollingloans.t b/t/db_dependent/rollingloans.t >index 75ec17f..17ff8db 100644 >--- a/t/db_dependent/rollingloans.t >+++ b/t/db_dependent/rollingloans.t >@@ -46,9 +46,9 @@ SKIP: { > sub try_issue { > my ($cardnumber, $item ) = @_; > my $issuedate = '2011-05-16'; >- my $borrower = Koha::Patrons->find( { cardnumber => $cardnumber } )->unblessed; >- my ($issuingimpossible,$needsconfirmation) = CanBookBeIssued( $borrower, $item ); >- my $issue = AddIssue($borrower, $item, undef, 0, $issuedate); >+ my $patron = Koha::Patrons->find( { cardnumber => $cardnumber } ); >+ my ($issuingimpossible,$needsconfirmation) = CanBookBeIssued( $patron, $item ); >+ my $issue = AddIssue($patron->unblessed, $item, undef, 0, $issuedate); > return dt_from_string( $issue->due_date() ); > } > >-- >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 19280
:
66999
|
68533
|
68534
|
68916
|
70287
|
70291
|
70292