Bugzilla – Attachment 122981 Details for
Bug 25260
Merge 'reserves' and 'old_reserves' into a new 'holds' table
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25260: Adapt all the things
Bug-25260-Adapt-all-the-things.patch (text/plain), 257.17 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-07-20 16:35:43 UTC
(
hide
)
Description:
Bug 25260: Adapt all the things
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-07-20 16:35:43 UTC
Size:
257.17 KB
patch
obsolete
>From ddae649084e004cb8ed407fab3abb0e5370a2dc2 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 23 Apr 2020 11:03:28 -0300 >Subject: [PATCH] Bug 25260: Adapt all the things > >This patch adapts many pm and test files to work with unified holds >table. > >To test: > >1. Remove all previous holds in reserves and old_reserves tables. >2. Create 6 holds. Cancel 2 of them, fulfill one, set one in waiting and > another in transit. >CHECK => "select reserve_id, found from reserves" query in mysql should return 3 rows, where in found >column should find 'W', 'T' and another with null values. > => "select reserve_id, found from old_reserves" query in mysql should return 3 rows, where in found column you should find 2 with 'C', and one with 'F' values. >3. in mysql change reserve_id to the value of a hold in reserve table. >4. apply patches >5. updatedatabase >SUCCESS => you should get the following warning "There were 1 old reserves that could not be moved, please check '_old_reserves'" > => "select id, status, completed from holds" query in mysql should return 5 rows. > => The hold that had null value in found column, now should have 'placed' status and 0 in completed. > => The one that had 'W' in found column, now should have 'waiting' status and 0 in completed. > => The one that had 'T' in found column, now should have 'in_transit' status and 0 in completed. > => The one that had 'F' in found column, now should have 'fulfilled' status and 1 in completed. > => The unmodified cancelled hold, now should have 'cancelled' status and 1 in completed. > => "select * from _old_reserves" should give you one row with the modified hold. >6. in staff interface create, cancel, modify priorities, etc and everything should work exactly as before. > > # Run every test that has reserve and hold word wihtin > # check that you are in main koha directory > # check you have correctly setted KOHA_INTRANET_URL and KOHA_OPAC_URL environment variables > # check plack is up and running.. tests will use selenium > # prepare yourself a mug of coffe/te or take a nap.. this will take a while >7. prove $(grep -ilr -e reserve -e hold t|grep "\.t$") > > # finally >8. Sign off > >Sponsored-by: ByWater Solutions >Sponsored-by: Theke Solutions > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > C4/Circulation.pm | 43 +- > C4/Items.pm | 5 +- > C4/Letters.pm | 10 +- > C4/Members.pm | 2 +- > C4/Reserves.pm | 532 +++++++++--------- > C4/SIP/ILS/Item.pm | 15 +- > C4/SIP/ILS/Patron.pm | 4 +- > C4/SIP/ILS/Transaction/Hold.pm | 2 +- > C4/XSLT.pm | 2 +- > Koha/Acquisition/Order.pm | 2 +- > Koha/Biblio.pm | 9 +- > Koha/Hold.pm | 31 +- > Koha/Holds.pm | 31 +- > Koha/Item.pm | 20 +- > Koha/Patron.pm | 12 +- > Koha/REST/V1/Auth.pm | 20 +- > Koha/REST/V1/Holds.pm | 30 +- > Koha/Template/Plugin/Biblio.pm | 11 +- > api/v1/swagger/definitions/hold.json | 14 +- > api/v1/swagger/paths/holds.json | 12 +- > circ/circulation.pl | 2 +- > circ/returns.pl | 2 +- > .../mysql/en/mandatory/sample_notices.yml | 6 +- > .../prog/en/modules/circ/article-requests.tt | 2 +- > .../prog/en/modules/members/holdshistory.tt | 32 +- > koha-tmpl/intranet-tmpl/prog/js/holds.js | 2 +- > .../bootstrap/en/modules/opac-holdshistory.tt | 38 +- > members/holdshistory.pl | 12 +- > .../thirdparty/TalkingTech_itiva_outbound.pl | 10 +- > reserve/request.pl | 61 +- > t/Koha/Exceptions.t | 4 +- > t/Koha/REST/Plugin/Query.t | 4 +- > t/db_dependent/Circulation.t | 63 +-- > t/db_dependent/Circulation/issue.t | 5 +- > t/db_dependent/DecreaseLoanHighHolds.t | 18 +- > t/db_dependent/Hold.t | 161 +++--- > t/db_dependent/Holds.t | 108 ++-- > .../Holds/DisallowHoldIfItemsAvailable.t | 6 +- > t/db_dependent/Holds/HoldItemtypeLimit.t | 2 +- > t/db_dependent/Holds/LocalHoldsPriority.t | 16 +- > t/db_dependent/Holds/RevertWaitingStatus.t | 3 +- > t/db_dependent/Holds/WaitingReserves.t | 96 ++-- > t/db_dependent/HoldsQueue.t | 43 +- > t/db_dependent/ILSDI_Services.t | 37 +- > t/db_dependent/Items/GetItemsForInventory.t | 2 +- > t/db_dependent/Items/MoveItemFromBiblio.t | 24 +- > t/db_dependent/Koha/Acquisition/Order.t | 2 +- > t/db_dependent/Koha/Biblios.t | 18 +- > t/db_dependent/Koha/Club/Hold.t | 2 +- > t/db_dependent/Koha/Hold.t | 2 +- > t/db_dependent/Koha/Holds.t | 79 +-- > t/db_dependent/Koha/Items.t | 12 +- > t/db_dependent/Koha/Object.t | 4 +- > t/db_dependent/Koha/Objects.t | 6 +- > t/db_dependent/Koha/Patrons.t | 16 +- > t/db_dependent/Koha/Z3950Responder/Session.t | 2 +- > t/db_dependent/Koha/Z3950Responder/Session2.t | 2 +- > t/db_dependent/Letters/TemplateToolkit.t | 34 +- > t/db_dependent/Reserves.t | 158 +++--- > .../Reserves/AutoUnsuspendReserves.t | 32 +- > .../Reserves/CancelExpiredReserves.t | 230 ++++---- > t/db_dependent/Reserves/GetReserveFee.t | 14 +- > t/db_dependent/Reserves/MultiplePerRecord.t | 18 +- > t/db_dependent/Reserves/ReserveSlip.t | 27 +- > t/db_dependent/TestBuilder.t | 17 +- > t/db_dependent/XSLT.t | 9 +- > t/db_dependent/api/v1/holds.t | 100 ++-- > 67 files changed, 1202 insertions(+), 1148 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 10e17c045d..3a27f9ea3f 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -1097,7 +1097,7 @@ sub CanBookBeIssued { > # See if the item is on reserve. > my ( $restype, $res ) = C4::Reserves::CheckReserves( $item_object->itemnumber ); > if ($restype) { >- my $resbor = $res->{'borrowernumber'}; >+ my $resbor = $res->{patron_id}; > if ( $resbor ne $patron->borrowernumber ) { > my $patron = Koha::Patrons->find( $resbor ); > if ( $restype eq "Waiting" ) >@@ -1109,9 +1109,9 @@ sub CanBookBeIssued { > $needsconfirmation{'ressurname'} = $patron->surname; > $needsconfirmation{'rescardnumber'} = $patron->cardnumber; > $needsconfirmation{'resborrowernumber'} = $patron->borrowernumber; >- $needsconfirmation{'resbranchcode'} = $res->{branchcode}; >- $needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'}; >- $needsconfirmation{'reserve_id'} = $res->{reserve_id}; >+ $needsconfirmation{'resbranchcode'} = $res->{pickup_library_id}; >+ $needsconfirmation{'reswaitingdate'} = $res->{waiting_date}; >+ $needsconfirmation{'reserve_id'} = $res->{id}; > } > elsif ( $restype eq "Reserved" ) { > # The item is on reserve for someone else. >@@ -1121,8 +1121,8 @@ sub CanBookBeIssued { > $needsconfirmation{'rescardnumber'} = $patron->cardnumber; > $needsconfirmation{'resborrowernumber'} = $patron->borrowernumber; > $needsconfirmation{'resbranchcode'} = $patron->branchcode; >- $needsconfirmation{'resreservedate'} = $res->{reservedate}; >- $needsconfirmation{'reserve_id'} = $res->{reserve_id}; >+ $needsconfirmation{'resreservedate'} = $res->{created_date}; >+ $needsconfirmation{'reserve_id'} = $res->{id}; > } > elsif ( $restype eq "Transferred" ) { > # The item is determined hold being transferred for someone else. >@@ -1132,8 +1132,8 @@ sub CanBookBeIssued { > $needsconfirmation{'rescardnumber'} = $patron->cardnumber; > $needsconfirmation{'resborrowernumber'} = $patron->borrowernumber; > $needsconfirmation{'resbranchcode'} = $patron->branchcode; >- $needsconfirmation{'resreservedate'} = $res->{reservedate}; >- $needsconfirmation{'reserve_id'} = $res->{reserve_id}; >+ $needsconfirmation{'resreservedate'} = $res->{created_date}; >+ $needsconfirmation{'reserve_id'} = $res->{id}; > } > elsif ( $restype eq "Processing" ) { > # The item is determined hold being processed for someone else. >@@ -1143,8 +1143,8 @@ sub CanBookBeIssued { > $needsconfirmation{'rescardnumber'} = $patron->cardnumber; > $needsconfirmation{'resborrowernumber'} = $patron->borrowernumber; > $needsconfirmation{'resbranchcode'} = $patron->branchcode; >- $needsconfirmation{'resreservedate'} = $res->{reservedate}; >- $needsconfirmation{'reserve_id'} = $res->{reserve_id}; >+ $needsconfirmation{'resreservedate'} = $res->{created_date}; >+ $needsconfirmation{'reserve_id'} = $res->{id}; > } > } > } >@@ -1287,7 +1287,7 @@ sub checkHighHolds { > due_date => undef, > }; > >- my $holds = Koha::Holds->search( { biblionumber => $item->{'biblionumber'} } ); >+ my $holds = Koha::Holds->search( { biblio_id => $item->{'biblionumber'} } ); > > if ( $holds->count() ) { > $return_data->{outstanding} = $holds->count(); >@@ -1508,10 +1508,10 @@ sub AddIssue { > } > )->store; > if ( $transfer->reason && $transfer->reason eq 'Reserve' ) { >- my $hold = $item_object->holds->search( { found => 'T' } )->next; >+ my $hold = $item_object->holds->search( { status => 'in_transit' } )->next; > if ( $hold ) { # Is this really needed? >- $hold->set( { found => undef } )->store; >- C4::Reserves::ModReserveMinusPriority($item_object->itemnumber, $hold->reserve_id); >+ $hold->set( { status => 'placed' } )->store; >+ C4::Reserves::ModReserveMinusPriority($item_object->itemnumber, $hold->id); > } > } > } >@@ -2218,7 +2218,7 @@ sub AddReturn { > my $lookahead= C4::Context->preference('ConfirmFutureHolds'); #number of days to look for future holds > ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->itemnumber, undef, $lookahead ) unless ( $item->withdrawn ); > # if a hold is found and is waiting at another branch, change the priority back to 1 and trigger the hold (this will trigger a transfer and update the hold status properly) >- if ( $resfound and $resfound eq "Waiting" and $branch ne $resrec->{branchcode} ) { >+ if ( $resfound and $resfound eq "Waiting" and $branch ne $resrec->{pickup_library_id} ) { > my $hold = C4::Reserves::RevertWaitingStatus( { itemnumber => $item->itemnumber } ); > $resfound = 'Reserved'; > $resrec = $hold->unblessed; >@@ -2867,9 +2867,7 @@ sub CanBookBeRenewed { > > # If next hold is non priority, then check if any hold with priority (non_priority = 0) exists for the same biblionumber. > if ( $resfound && $resrec->{non_priority} ) { >- $resfound = Koha::Holds->search( >- { biblionumber => $resrec->{biblionumber}, non_priority => 0 } ) >- ->count > 0; >+ $resfound = scalar grep {!$_->{non_priority}} @{$possible_reserves}; > } > > >@@ -2879,7 +2877,7 @@ sub CanBookBeRenewed { > if ( $resfound > && C4::Context->preference('AllowRenewalIfOtherItemsAvailable') ) > { >- my $item_holds = Koha::Holds->search( { itemnumber => $itemnumber, found => undef } )->count(); >+ my $item_holds = Koha::Holds->search( { item_id => $itemnumber, status => 'placed' } )->count(); > if ($item_holds) { > # There is an item level hold on this item, no other item can fill the hold > $resfound = 1; >@@ -2888,14 +2886,14 @@ sub CanBookBeRenewed { > > # Get all other items that could possibly fill reserves > my $items = Koha::Items->search({ >- biblionumber => $resrec->{biblionumber}, >+ biblionumber => $resrec->{biblio_id}, > onloan => undef, > notforloan => 0, > -not => { itemnumber => $itemnumber } > }); > > # Get all other reserves that could have been filled by this item >- my @borrowernumbers = map { $_->{borrowernumber} } @$possible_reserves; >+ my @borrowernumbers = map { $_->{patron_id} } @$possible_reserves; > my $patrons = Koha::Patrons->search({ > borrowernumber => { -in => \@borrowernumbers } > }); >@@ -2930,7 +2928,6 @@ sub CanBookBeRenewed { > } > > return ( 0, "auto_renew" ) if $auto_renew eq "ok" && !$override_limit; # 0 if auto-renewal should not succeed >- > return ( 1, undef ); > } > >@@ -3371,7 +3368,7 @@ sub GetIssuingCharges { > $sth->execute($itemnumber); > if ( my $item_data = $sth->fetchrow_hashref ) { > $item_type = $item_data->{itemtype}; >- $charge = $item_data->{rentalcharge}; >+ $charge = $item_data->{rentalcharge} // 0; > # FIXME This should follow CircControl > my $branch = C4::Context::mybranch(); > my $patron = Koha::Patrons->find( $borrowernumber ); >diff --git a/C4/Items.pm b/C4/Items.pm >index 14774e48e1..decc4cbd44 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -602,8 +602,9 @@ sub GetItemsForInventory { > } > > if ( $ignore_waiting_holds ) { >- $query .= "LEFT JOIN reserves ON items.itemnumber = reserves.itemnumber "; >- push( @where_strings, q{(reserves.found != 'W' OR reserves.found IS NULL)} ); >+ $query .= "LEFT JOIN holds ON items.itemnumber = holds.item_id "; >+ # holds.status IS NULL <- means the join doesn't match any hold to the item >+ push( @where_strings, q{(holds.status != 'waiting' OR holds.status IS NULL)} ); > } > > if ( @$itemtypes ) { >diff --git a/C4/Letters.pm b/C4/Letters.pm >index 177a4f51f6..55e1f48ef6 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -786,7 +786,7 @@ sub _parseletter_sth { > ($table eq 'items' ) ? "SELECT * FROM $table WHERE itemnumber = ?" : > ($table eq 'issues' ) ? "SELECT * FROM $table WHERE itemnumber = ?" : > ($table eq 'old_issues' ) ? "SELECT * FROM $table WHERE itemnumber = ? ORDER BY timestamp DESC LIMIT 1" : >- ($table eq 'reserves' ) ? "SELECT * FROM $table WHERE borrowernumber = ? and biblionumber = ?" : >+ ($table eq 'holds' ) ? "SELECT * FROM $table WHERE patron_id = ? AND biblio_id = ?" : > ($table eq 'borrowers' ) ? "SELECT * FROM $table WHERE borrowernumber = ?" : > ($table eq 'branches' ) ? "SELECT * FROM $table WHERE branchcode = ?" : > ($table eq 'suggestions' ) ? "SELECT * FROM $table WHERE suggestionid = ?" : >@@ -834,8 +834,8 @@ sub _parseletter { > $values->{'dateexpiry'} = output_pref({ dt => dt_from_string( $values->{'dateexpiry'} ), dateonly => 1 }); > } > >- if ( $table eq 'reserves' && $values->{'waitingdate'} ) { >- $values->{'waitingdate'} = output_pref({ dt => dt_from_string( $values->{'waitingdate'} ), dateonly => 1 }); >+ if ( $table eq 'holds' && $values->{waiting_date} ) { >+ $values->{waiting_date} = output_pref({ dt => dt_from_string( $values->{waiting_date} ), dateonly => 1 }); > } > > if ($letter->{content} && $letter->{content} =~ /<<today>>/) { >@@ -1665,11 +1665,11 @@ sub _get_tt_params { > plural => 'orders', > pk => 'ordernumber', > }, >- reserves => { >+ holds => { > module => 'Koha::Holds', > singular => 'hold', > plural => 'holds', >- pk => 'reserve_id', >+ pk => 'id', > }, > serial => { > module => 'Koha::Serials', >diff --git a/C4/Members.pm b/C4/Members.pm >index 73b254cb5e..5f24b917db 100644 >--- a/C4/Members.pm >+++ b/C4/Members.pm >@@ -227,7 +227,7 @@ sub patronflags { > $flags{'ODUES'} = \%flaginfo; > } > >- my $waiting_holds = $patron->holds->search({ found => 'W' }); >+ my $waiting_holds = $patron->holds->search({ status => 'waiting' }); > my $nowaiting = $waiting_holds->count; > if ( $nowaiting > 0 ) { > my %flaginfo; >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 54d2b00cb0..57417704e4 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -37,12 +37,10 @@ use Koha::Calendar; > use Koha::CirculationRules; > use Koha::Database; > use Koha::DateUtils qw( dt_from_string output_pref ); >-use Koha::Hold; > use Koha::Holds; > use Koha::ItemTypes; > use Koha::Items; > use Koha::Libraries; >-use Koha::Old::Hold; > use Koha::Patrons; > use Koha::Plugins; > >@@ -190,7 +188,7 @@ sub AddReserve { > my $notes = $params->{notes}; > my $title = $params->{title}; > my $checkitem = $params->{itemnumber}; >- my $found = $params->{found}; >+ my $found = $params->{found} // 'placed'; > my $itemtype = $params->{itemtype}; > my $non_priority = $params->{non_priority}; > >@@ -221,7 +219,7 @@ sub AddReserve { > && !$item->current_holds->count ) > { > $priority = 0; >- $found = 'W'; >+ $found = 'waiting'; > } > } > >@@ -234,7 +232,7 @@ sub AddReserve { > my $waitingdate; > > # If the reserv had the waiting status, we had the value of the resdate >- if ( $found && $found eq 'W' ) { >+ if ( $found and $found eq 'waiting' ) { > $waitingdate = $resdate; > } > >@@ -244,22 +242,21 @@ sub AddReserve { > # updates take place here > my $hold = Koha::Hold->new( > { >- borrowernumber => $borrowernumber, >- biblionumber => $biblionumber, >- reservedate => $resdate, >- branchcode => $branch, >+ patron_id => $borrowernumber, >+ biblio_id => $biblionumber, >+ created_date => $resdate, >+ pickup_library_id => $branch, > priority => $priority, >- reservenotes => $notes, >- itemnumber => $checkitem, >- found => $found, >- waitingdate => $waitingdate, >- expirationdate => $expdate, >- itemtype => $itemtype, >- item_level_hold => $checkitem ? 1 : 0, >+ notes => $notes, >+ item_id => $checkitem, >+ waiting_date => $waitingdate, >+ expiration_date => $expdate, >+ item_type => $itemtype, >+ item_level => $checkitem ? 1 : 0, > non_priority => $non_priority ? 1 : 0, > } > )->store(); >- $hold->set_waiting() if $found && $found eq 'W'; >+ $hold->set_waiting() if $found eq 'waiting'; > > logaction( 'HOLDS', 'CREATE', $hold->id, Dumper($hold->unblessed) ) > if C4::Context->preference('HoldsLog'); >@@ -398,7 +395,7 @@ sub CanItemBeReserved { > > # Check that the patron doesn't have an item level hold on this item already > return { status =>'itemAlreadyOnHold' } >- if ( !$params->{ignore_hold_counts} && Koha::Holds->search( { borrowernumber => $borrowernumber, itemnumber => $itemnumber } )->count() ); >+ if ( !$params->{ignore_hold_counts} && Koha::Holds->search( { patron_id => $borrowernumber, item_id => $itemnumber, completed => 0 } )->count() ); > > # Check that patron have not checked out this biblio (if AllowHoldsOnPatronsPossessions set) > if ( !C4::Context->preference('AllowHoldsOnPatronsPossessions') >@@ -410,15 +407,15 @@ sub CanItemBeReserved { > > my $querycount = q{ > SELECT count(*) AS count >- FROM reserves >- LEFT JOIN items USING (itemnumber) >- LEFT JOIN biblioitems ON (reserves.biblionumber=biblioitems.biblionumber) >- LEFT JOIN borrowers USING (borrowernumber) >- WHERE borrowernumber = ? >+ FROM holds >+ LEFT JOIN items ON (holds.item_id=items.itemnumber) >+ LEFT JOIN biblioitems ON (holds.biblio_id=biblioitems.biblionumber) >+ LEFT JOIN borrowers ON (holds.patron_id=borrowers.borrowernumber) >+ WHERE completed = 0 and borrowernumber = ? > }; > > my $branchcode = ""; >- my $branchfield = "reserves.branchcode"; >+ my $branchfield = "holds.pickup_library_id"; > > if ( $controlbranch eq "ItemHomeLibrary" ) { > $branchfield = "items.homebranch"; >@@ -455,10 +452,11 @@ sub CanItemBeReserved { > my $holds_per_day = $rights->{holds_per_day}; > > my $search_params = { >- borrowernumber => $borrowernumber, >- biblionumber => $item->biblionumber, >+ patron_id => $borrowernumber, >+ biblio_id => $item->biblionumber, >+ completed => 0, > }; >- $search_params->{found} = undef if $params->{ignore_found_holds}; >+ $search_params->{status} = 'placed' if $params->{ignore_found_holds}; > > my $holds = Koha::Holds->search($search_params); > if ( defined $holds_per_record && $holds_per_record ne '' ){ >@@ -471,8 +469,9 @@ sub CanItemBeReserved { > } > > my $today_holds = Koha::Holds->search({ >- borrowernumber => $borrowernumber, >- reservedate => dt_from_string->date >+ patron_id => $borrowernumber, >+ created_date => dt_from_string->date, >+ completed => 0 > }); > > if (!$params->{ignore_hold_counts} && defined $holds_per_day && $holds_per_day ne '' >@@ -528,7 +527,8 @@ sub CanItemBeReserved { > if (!$params->{ignore_hold_counts} && $rule && defined( $rule->rule_value ) && $rule->rule_value ne '' ) { > my $total_holds_count = Koha::Holds->search( > { >- borrowernumber => $borrower->{borrowernumber} >+ patron_id => $borrower->{borrowernumber}, >+ completed => 0 > } > )->count(); > >@@ -606,10 +606,11 @@ sub CanReserveBeCanceledFromOpac { > my ($reserve_id, $borrowernumber) = @_; > > return unless $reserve_id and $borrowernumber; >- my $reserve = Koha::Holds->find($reserve_id) or return; >+ my $hold = Koha::Holds->find($reserve_id); >+ return unless $hold; > >- return 0 unless $reserve->borrowernumber == $borrowernumber; >- return $reserve->is_cancelable_from_opac; >+ return 0 unless $hold->patron_id == $borrowernumber; >+ return $hold->is_cancelable_from_opac; > } > > =head2 GetOtherReserves >@@ -627,19 +628,19 @@ sub GetOtherReserves { > my ( undef, $checkreserves, undef ) = CheckReserves($itemnumber); > if ($checkreserves) { > my $item = Koha::Items->find($itemnumber); >- if ( $item->holdingbranch ne $checkreserves->{'branchcode'} ) { >- $messages->{'transfert'} = $checkreserves->{'branchcode'}; >+ if ( $item->holdingbranch ne $checkreserves->{pickup_library_id} ) { >+ $messages->{'transfert'} = $checkreserves->{pickup_library_id}; > #minus priorities of others reservs > ModReserveMinusPriority( > $itemnumber, >- $checkreserves->{'reserve_id'}, >+ $checkreserves->{id}, > ); > > #launch the subroutine dotransfer > C4::Items::ModItemTransfer( > $itemnumber, > $item->holdingbranch, >- $checkreserves->{'branchcode'}, >+ $checkreserves->{pickup_library_id}, > 'Reserve' > ), > ; >@@ -650,9 +651,9 @@ sub GetOtherReserves { > $messages->{'waiting'} = 1; > ModReserveMinusPriority( > $itemnumber, >- $checkreserves->{'reserve_id'}, >+ $checkreserves->{id}, > ); >- ModReserveStatus($itemnumber,'W'); >+ ModReserveStatus($itemnumber,'waiting'); > } > > $nextreservinfo = $checkreserves; >@@ -743,25 +744,20 @@ If several reserves exist, the reserve with the lower priority is given. > ## multiple reserves for that bib can have the itemnumber set > ## the sub is only used once in the codebase. > sub GetReserveStatus { >- my ($itemnumber) = @_; >+ my ($item_id) = @_; > >- my $dbh = C4::Context->dbh; >+ my $holds_rs = Koha::Holds->search({ item_id => $item_id, completed => 0 }, { order_by => 'priority' }); > >- my ($sth, $found, $priority); >- if ( $itemnumber ) { >- $sth = $dbh->prepare("SELECT found, priority FROM reserves WHERE itemnumber = ? order by priority LIMIT 1"); >- $sth->execute($itemnumber); >- ($found, $priority) = $sth->fetchrow_array; >- } >+ if ( $holds_rs->count > 0 ) { >+ # They are sorted by priority, pick the first one >+ my $hold = $holds_rs->next; > >- if(defined $found) { >- return 'Waiting' if $found eq 'W' and $priority == 0; >- return 'Processing' if $found eq 'P'; >- return 'Finished' if $found eq 'F'; >+ return 'Waiting' if $hold->is_waiting and $hold->priority == 0; >+ return 'Processing' if $hold->is_in_processing; >+ return 'Finished' if $hold->status eq 'fulfilled'; >+ return 'Reserved' if $hold->priority > 0; > } > >- return 'Reserved' if defined $priority && $priority > 0; >- > return ''; # empty string here will remove need for checking undef, or less log lines > } > >@@ -800,7 +796,7 @@ sub CheckReserves { > my $sth; > my $select; > if (C4::Context->preference('item-level_itypes')){ >- $select = " >+ $select = " > SELECT items.biblionumber, > items.biblioitemnumber, > itemtypes.notforloan, >@@ -815,7 +811,7 @@ sub CheckReserves { > "; > } > else { >- $select = " >+ $select = " > SELECT items.biblionumber, > items.biblioitemnumber, > itemtypes.notforloan, >@@ -868,11 +864,11 @@ sub CheckReserves { > > my $priority = 10000000; > foreach my $res (@reserves) { >- if ($res->{'found'} && $res->{'found'} eq 'W') { >+ if ($res->{status} eq 'waiting') { > return ( "Waiting", $res, \@reserves ); # Found it, it is waiting >- } elsif ($res->{'found'} && $res->{'found'} eq 'P') { >+ } elsif ($res->{status} eq 'processing') { > return ( "Processing", $res, \@reserves ); # Found determinated hold, e. g. the transferred one >- } elsif ($res->{'found'} && $res->{'found'} eq 'T') { >+ } elsif ($res->{status} eq 'in_transit') { > return ( "Transferred", $res, \@reserves ); # Found determinated hold, e. g. the transferred one > } else { > my $patron; >@@ -880,7 +876,7 @@ sub CheckReserves { > my $local_hold_match; > > if ($LocalHoldsPriority) { >- $patron = Koha::Patrons->find( $res->{borrowernumber} ); >+ $patron = Koha::Patrons->find( $res->{patron_id} ); > $item = Koha::Items->find($itemnumber); > > unless ($item->exclude_from_local_holds_priority || $patron->category->exclude_from_local_holds_priority) { >@@ -888,7 +884,7 @@ sub CheckReserves { > $item->$LocalHoldsPriorityItemControl; > my $local_holds_priority_patron_branchcode = > ( $LocalHoldsPriorityPatronControl eq 'PickupLibrary' ) >- ? $res->{branchcode} >+ ? $res->{pickup_library_id} > : ( $LocalHoldsPriorityPatronControl eq 'HomeLibrary' ) > ? $patron->branchcode > : undef; >@@ -899,10 +895,10 @@ sub CheckReserves { > } > > # See if this item is more important than what we've got so far >- if ( ( $res->{'priority'} && $res->{'priority'} < $priority ) || $local_hold_match ) { >+ if ( ( $res->{priority} && $res->{priority} < $priority ) || $local_hold_match ) { > $item ||= Koha::Items->find($itemnumber); >- next if $res->{itemtype} && $res->{itemtype} ne $item->effective_itemtype; >- $patron ||= Koha::Patrons->find( $res->{borrowernumber} ); >+ next if $res->{item_type} && $res->{item_type} ne $item->effective_itemtype; >+ $patron ||= Koha::Patrons->find( $res->{patron_id} ); > my $branch = GetReservesControlBranch( $item->unblessed, $patron->unblessed ); > my $branchitemrule = C4::Circulation::GetBranchItemRule($branch,$item->effective_itemtype); > next if ($branchitemrule->{'holdallowed'} eq 'not_allowed'); >@@ -910,10 +906,10 @@ sub CheckReserves { > my $library = Koha::Libraries->find({branchcode=>$item->homebranch}); > next if (($branchitemrule->{'holdallowed'} eq 'from_local_hold_group') && (!$library->validate_hold_sibling({branchcode => $patron->branchcode}) )); > my $hold_fulfillment_policy = $branchitemrule->{hold_fulfillment_policy}; >- next if ( ($hold_fulfillment_policy eq 'holdgroup') && (!$library->validate_hold_sibling({branchcode => $res->{branchcode}})) ); >- next if ( ($hold_fulfillment_policy eq 'homebranch') && ($res->{branchcode} ne $item->$hold_fulfillment_policy) ); >- next if ( ($hold_fulfillment_policy eq 'holdingbranch') && ($res->{branchcode} ne $item->$hold_fulfillment_policy) ); >- next unless $item->can_be_transferred( { to => Koha::Libraries->find( $res->{branchcode} ) } ); >+ next if ( ($hold_fulfillment_policy eq 'holdgroup') && (!$library->validate_hold_sibling({branchcode => $res->{pickup_library_id}})) ); >+ next if ( ($hold_fulfillment_policy eq 'homebranch') && ($res->{pickup_library_id} ne $item->$hold_fulfillment_policy) ); >+ next if ( ($hold_fulfillment_policy eq 'holdingbranch') && ($res->{pickup_library_id} ne $item->$hold_fulfillment_policy) ); >+ next unless $item->can_be_transferred( { to => Koha::Libraries->find( $res->{pickup_library_id} ) } ); > $priority = $res->{'priority'}; > $highest = $res; > last if $local_hold_match; >@@ -947,20 +943,20 @@ sub CancelExpiredReserves { > my $expireWaiting = C4::Context->preference('ExpireReservesMaxPickUpDelay'); > > my $dtf = Koha::Database->new->schema->storage->datetime_parser; >- my $params = { expirationdate => { '<', $dtf->format_date($today) } }; >- $params->{found} = [ { '!=', 'W' }, undef ] unless $expireWaiting; >+ my $params = { expiration_date => { '<', $dtf->format_date($today) } }; >+ $params->{status} = [ { '!=', 'waiting' }, undef ] unless $expireWaiting; > > # FIXME To move to Koha::Holds->search_expired (?) > my $holds = Koha::Holds->search( $params ); > > while ( my $hold = $holds->next ) { >- my $calendar = Koha::Calendar->new( branchcode => $hold->branchcode ); >+ my $calendar = Koha::Calendar->new( branchcode => $hold->pickup_library_id ); > > next if !$cancel_on_holidays && $calendar->is_holiday( $today ); > > my $cancel_params = {}; > $cancel_params->{cancellation_reason} = $cancellation_reason if defined($cancellation_reason); >- if ( defined($hold->found) && $hold->found eq 'W' ) { >+ if ( $hold->is_waiting ) { > $cancel_params->{charge_cancel_fee} = 1; > } > $hold->cancel( $cancel_params ); >@@ -971,14 +967,14 @@ sub CancelExpiredReserves { > > AutoUnsuspendReserves(); > >-Unsuspends all suspended reserves with a suspend_until date from before today. >+Unsuspends all suspended reserves with a suspended_until date from before today. > > =cut > > sub AutoUnsuspendReserves { > my $today = dt_from_string(); > >- my @holds = Koha::Holds->search( { suspend_until => { '<=' => $today->ymd() } } ); >+ my @holds = Koha::Holds->search( { suspended_until_date => { '<=' => $today->ymd() } } ); > > map { $_->resume() } @holds; > } >@@ -1038,10 +1034,10 @@ sub ModReserve { > > my $hold; > unless ( $reserve_id ) { >- my $holds = Koha::Holds->search({ biblionumber => $biblionumber, borrowernumber => $borrowernumber, itemnumber => $itemnumber }); >+ my $holds = Koha::Holds->search({ biblio_id => $biblionumber, patron_id => $borrowernumber, item_id => $itemnumber }); > return unless $holds->count; # FIXME Should raise an exception > $hold = $holds->next; >- $reserve_id = $hold->reserve_id; >+ $reserve_id = $hold->id; > } > > $hold ||= Koha::Holds->find($reserve_id); >@@ -1050,21 +1046,21 @@ sub ModReserve { > $hold->cancel({ cancellation_reason => $cancellation_reason }); > } > elsif ($rank =~ /^\d+/ and $rank > 0) { >- logaction( 'HOLDS', 'MODIFY', $hold->reserve_id, Dumper($hold->unblessed) ) >+ logaction( 'HOLDS', 'MODIFY', $hold->id, Dumper($hold->unblessed) ) > if C4::Context->preference('HoldsLog'); > > my $properties = { >- priority => $rank, >- branchcode => $branchcode, >- itemnumber => $itemnumber, >- found => undef, >- waitingdate => undef >+ priority => $rank, >+ pickup_library_id => $branchcode, >+ item_id => $itemnumber, >+ status => 'placed', >+ waiting_date => undef > }; > if (exists $params->{reservedate}) { >- $properties->{reservedate} = $params->{reservedate} || undef; >+ $properties->{created_date} = $params->{reservedate} || undef; > } > if (exists $params->{expirationdate}) { >- $properties->{expirationdate} = $params->{expirationdate} || undef; >+ $properties->{expiration_date} = $params->{expirationdate} || undef; > } > > $hold->set($properties)->store(); >@@ -1076,7 +1072,7 @@ sub ModReserve { > } else { > # If the hold is suspended leave the hold suspended, but convert it to an indefinite hold. > # If the hold is not suspended, this does nothing. >- $hold->set( { suspend_until => undef } )->store(); >+ $hold->set( { suspended_until_date => undef } )->store(); > } > } > >@@ -1098,37 +1094,37 @@ whose keys are fields from the reserves table in the Koha database. > > sub ModReserveFill { > my ($res) = @_; >- my $reserve_id = $res->{'reserve_id'}; >+ my $reserve_id = $res->{'id'}; > > my $hold = Koha::Holds->find($reserve_id); > # get the priority on this record.... > my $priority = $hold->priority; > > # update the hold statuses, no need to store it though, we will be deleting it anyway >+ # FIXME: Add Koha::Hold->set_filled and add the correct log > $hold->set( > { >- found => 'F', >- priority => 0, >+ status => 'fulfilled', >+ priority => 0, >+ completed => 1, >+ completed_date => \'NOW()' > } > ); > >- logaction( 'HOLDS', 'MODIFY', $hold->reserve_id, Dumper($hold->unblessed) ) >+ logaction( 'HOLDS', 'MODIFY', $hold->id, Dumper($hold->unblessed) ) > if C4::Context->preference('HoldsLog'); > >- # FIXME Must call Koha::Hold->cancel ? => No, should call ->filled and add the correct log >- Koha::Old::Hold->new( $hold->unblessed() )->store(); >- >- $hold->delete(); >+ $hold->store(); > > if ( C4::Context->preference('HoldFeeMode') eq 'any_time_is_collected' ) { >- my $reserve_fee = GetReserveFee( $hold->borrowernumber, $hold->biblionumber ); >- ChargeReserveFee( $hold->borrowernumber, $reserve_fee, $hold->biblio->title ); >+ my $reserve_fee = GetReserveFee( $hold->patron_id, $hold->biblio_id ); >+ ChargeReserveFee( $hold->patron_id, $reserve_fee, $hold->biblio->title ); > } > > # now fix the priority on the others (if the priority wasn't > # already sorted!).... > unless ( $priority == 0 ) { >- _FixPriority( { reserve_id => $reserve_id, biblionumber => $hold->biblionumber } ); >+ _FixPriority( { reserve_id => $reserve_id, biblionumber => $hold->biblio_id } ); > } > } > >@@ -1150,7 +1146,7 @@ sub ModReserveStatus { > my ($itemnumber, $newstatus) = @_; > my $dbh = C4::Context->dbh; > >- my $query = "UPDATE reserves SET found = ?, waitingdate = NOW() WHERE itemnumber = ? AND found IS NULL AND priority = 0"; >+ my $query = "UPDATE holds SET status = ?, waiting_date = NOW() WHERE item_id = ? AND status='placed' AND priority = 0"; > my $sth_set = $dbh->prepare($query); > $sth_set->execute( $newstatus, $itemnumber ); > >@@ -1196,15 +1192,15 @@ sub ModReserveAffect { > # Find hold by id if we have it > $hold = Koha::Holds->find( $reserve_id ) if $reserve_id; > # Find item level hold for this item if there is one >- $hold ||= Koha::Holds->search( { borrowernumber => $borrowernumber, itemnumber => $itemnumber } )->next(); >+ $hold ||= Koha::Holds->search( { patron_id => $borrowernumber, item_id => $itemnumber } )->next(); > # Find record level hold if there is no item level hold >- $hold ||= Koha::Holds->search( { borrowernumber => $borrowernumber, biblionumber => $biblionumber } )->next(); >+ $hold ||= Koha::Holds->search( { patron_id => $borrowernumber, biblio_id => $biblionumber } )->next(); > > return unless $hold; > >- my $already_on_shelf = $hold->found && $hold->found eq 'W'; >+ my $already_on_shelf = $hold->status eq 'waiting'; > >- $hold->itemnumber($itemnumber); >+ $hold->item_id($itemnumber); > > if ($transferToDo) { > $hold->set_transfer(); >@@ -1214,7 +1210,7 @@ sub ModReserveAffect { > $hold->set_processing(); > } else { > $hold->set_waiting($desk_id); >- _koha_notify_reserve( $hold->reserve_id ) unless $already_on_shelf; >+ _koha_notify_reserve( $hold->id ) unless $already_on_shelf; > # Complete transfer if one exists > my $transfer = $hold->item->get_transfer; > $transfer->receive if $transfer; >@@ -1238,9 +1234,9 @@ sub ModReserveAffect { > AND q.holdingbranch = t.source_branchcode > WHERE t.reserve_id = ? > }); >- $std->execute($hold->reserve_id); >+ $std->execute($hold->id); > >- logaction( 'HOLDS', 'MODIFY', $hold->reserve_id, Dumper($hold->get_from_storage->unblessed) ) >+ logaction( 'HOLDS', 'MODIFY', $hold->id, Dumper($hold->get_from_storage->unblessed) ) > if C4::Context->preference('HoldsLog'); > > return; >@@ -1257,15 +1253,15 @@ function to cancel reserv,check other reserves, and transfer document if it's ne > sub ModReserveCancelAll { > my $messages; > my $nextreservinfo; >- my ( $itemnumber, $borrowernumber, $cancellation_reason ) = @_; >+ my ( $item_id, $patron_id, $cancellation_reason ) = @_; > > #step 1 : cancel the reservation >- my $holds = Koha::Holds->search({ itemnumber => $itemnumber, borrowernumber => $borrowernumber }); >+ my $holds = Koha::Holds->search({ item_id => $item_id, patron_id => $patron_id }); > return unless $holds->count; > $holds->next->cancel({ cancellation_reason => $cancellation_reason }); > > #step 2 launch the subroutine of the others reserves >- ( $messages, $nextreservinfo ) = GetOtherReserves($itemnumber); >+ ( $messages, $nextreservinfo ) = GetOtherReserves($item_id); > > return ( $messages, $nextreservinfo->{borrowernumber} ); > } >@@ -1279,17 +1275,17 @@ Reduce the values of queued list > =cut > > sub ModReserveMinusPriority { >- my ( $itemnumber, $reserve_id ) = @_; >+ my ( $item_id, $reserve_id ) = @_; > > #first step update the value of the first person on reserv > my $dbh = C4::Context->dbh; > my $query = " >- UPDATE reserves >- SET priority = 0 , itemnumber = ? >- WHERE reserve_id = ? >+ UPDATE holds >+ SET priority = 0 , item_id = ? >+ WHERE id = ? > "; > my $sth_upd = $dbh->prepare($query); >- $sth_upd->execute( $itemnumber, $reserve_id ); >+ $sth_upd->execute( $item_id, $reserve_id ); > # second step update all others reserves > _FixPriority({ reserve_id => $reserve_id, rank => '0' }); > } >@@ -1433,8 +1429,8 @@ sub AlterPriority { > my $hold = Koha::Holds->find( $reserve_id ); > return unless $hold; > >- if ( $hold->cancellationdate ) { >- warn "I cannot alter the priority for reserve_id $reserve_id, the reserve has been cancelled (" . $hold->cancellationdate . ')'; >+ if ( $hold->completed_date and $hold->status eq 'cancelled' ) { >+ warn "I cannot alter the priority for reserve_id $reserve_id, the reserve has been cancelled (" . $hold->completed_date . ')'; > return; > } > >@@ -1466,7 +1462,7 @@ sub ToggleLowestPriority { > > my $dbh = C4::Context->dbh; > >- my $sth = $dbh->prepare( "UPDATE reserves SET lowestPriority = NOT lowestPriority WHERE reserve_id = ?"); >+ my $sth = $dbh->prepare( "UPDATE holds SET lowest_priority = NOT lowest_priority WHERE id = ?"); > $sth->execute( $reserve_id ); > > _FixPriority({ reserve_id => $reserve_id, rank => '999999' }); >@@ -1526,9 +1522,9 @@ sub SuspendAll { > return unless ( $borrowernumber || $biblionumber ); > > my $params; >- $params->{found} = undef; >- $params->{borrowernumber} = $borrowernumber if $borrowernumber; >- $params->{biblionumber} = $biblionumber if $biblionumber; >+ $params->{status} = 'placed'; >+ $params->{patron_id} = $borrowernumber if $borrowernumber; >+ $params->{biblio_id} = $biblionumber if $biblionumber; > > my @holds = Koha::Holds->search($params); > >@@ -1588,15 +1584,11 @@ sub _FixPriority { > my $hold; > if ( $reserve_id ) { > $hold = Koha::Holds->find( $reserve_id ); >- if (!defined $hold){ >- # may have already been checked out and hold fulfilled >- $hold = Koha::Old::Holds->find( $reserve_id ); >- } > return unless $hold; > } > > unless ( $biblionumber ) { # FIXME This is a very weird API >- $biblionumber = $hold->biblionumber; >+ $biblionumber = $hold->biblio_id; > } > > if ( $rank eq "del" ) { # FIXME will crash if called without $hold >@@ -1606,10 +1598,10 @@ sub _FixPriority { > > # make sure priority for waiting or in-transit items is 0 > my $query = " >- UPDATE reserves >+ UPDATE holds > SET priority = 0 >- WHERE reserve_id = ? >- AND found IN ('W', 'T', 'P') >+ WHERE id = ? >+ AND status IN ('waiting', 'in_transit', 'processing') > "; > my $sth = $dbh->prepare($query); > $sth->execute( $reserve_id ); >@@ -1618,10 +1610,11 @@ sub _FixPriority { > > # get whats left > my $query = " >- SELECT reserve_id, borrowernumber, reservedate >- FROM reserves >- WHERE biblionumber = ? >- AND ((found <> 'W' AND found <> 'T' AND found <> 'P') OR found IS NULL) >+ SELECT id >+ FROM holds >+ WHERE biblio_id = ? >+ AND completed = 0 >+ AND status = 'placed' > ORDER BY priority ASC > "; > my $sth = $dbh->prepare($query); >@@ -1635,7 +1628,7 @@ sub _FixPriority { > my $i; > my $key = -1; # to allow for 0 to be a valid result > for ( $i = 0 ; $i < @priority ; $i++ ) { >- if ( $reserve_id && $reserve_id == $priority[$i]->{'reserve_id'} ) { >+ if ( $reserve_id && $reserve_id == $priority[$i]->{'id'} ) { > $key = $i; # save the index > last; > } >@@ -1651,25 +1644,25 @@ sub _FixPriority { > > # now fix the priority on those that are left.... > $query = " >- UPDATE reserves >+ UPDATE holds > SET priority = ? >- WHERE reserve_id = ? >+ WHERE id = ? > "; > $sth = $dbh->prepare($query); > for ( my $j = 0 ; $j < @priority ; $j++ ) { > $sth->execute( > $j + 1, >- $priority[$j]->{'reserve_id'} >+ $priority[$j]->{'id'} > ); > } > >- $sth = $dbh->prepare( "SELECT reserve_id FROM reserves WHERE lowestPriority = 1 ORDER BY priority" ); >+ $sth = $dbh->prepare( "SELECT id FROM holds WHERE lowest_priority = 1 ORDER BY priority" ); > $sth->execute(); > > unless ( $ignoreSetLowestRank ) { > while ( my $res = $sth->fetchrow_hashref() ) { > _FixPriority({ >- reserve_id => $res->{'reserve_id'}, >+ reserve_id => $res->{'id'}, > rank => '999999', > ignoreSetLowestRank => 1 > }); >@@ -1706,29 +1699,33 @@ sub _Findgroupreserve { > # TODO: consolidate at least the SELECT portion of the first 2 queries to a common $select var. > # check for exact targeted match > my $item_level_target_query = qq{ >- SELECT reserves.biblionumber AS biblionumber, >- reserves.borrowernumber AS borrowernumber, >- reserves.reservedate AS reservedate, >- reserves.branchcode AS branchcode, >- reserves.cancellationdate AS cancellationdate, >- reserves.found AS found, >- reserves.reservenotes AS reservenotes, >- reserves.priority AS priority, >- reserves.timestamp AS timestamp, >+ SELECT holds.biblio_id AS biblio_id, >+ holds.patron_id AS patron_id, >+ holds.created_date AS created_date, >+ holds.pickup_library_id AS pickup_library_id, >+ holds.completed_date AS completed_date, >+ holds.status AS status, >+ holds.notes AS notes, >+ holds.priority AS priority, >+ holds.timestamp AS timestamp, > biblioitems.biblioitemnumber AS biblioitemnumber, >- reserves.itemnumber AS itemnumber, >- reserves.reserve_id AS reserve_id, >- reserves.itemtype AS itemtype, >- reserves.non_priority AS non_priority >- FROM reserves >- JOIN biblioitems USING (biblionumber) >- JOIN hold_fill_targets USING (reserve_id) >- WHERE found IS NULL >+ holds.item_id AS item_id, >+ holds.id AS id, >+ holds.item_type AS item_type, >+ holds.non_priority AS non_priority >+ FROM holds >+ JOIN biblioitems ON (holds.biblio_id=biblioitems.biblionumber) >+ JOIN hold_fill_targets ON ( >+ holds.biblio_id=hold_fill_targets.biblionumber >+ AND holds.patron_id=hold_fill_targets.borrowernumber >+ AND holds.item_id=hold_fill_targets.itemnumber) >+ WHERE status='placed' > AND priority > 0 >- AND item_level_request = 1 >- AND hold_fill_targets.itemnumber = ? >- AND reservedate <= DATE_ADD(NOW(),INTERVAL ? DAY) >- AND suspend = 0 >+ AND completed = 0 >+ AND item_level = 1 >+ AND item_id = ? >+ AND created_date <= DATE_ADD(NOW(),INTERVAL ? DAY) >+ AND suspended = 0 > ORDER BY priority > }; > my $sth = $dbh->prepare($item_level_target_query); >@@ -1736,35 +1733,38 @@ sub _Findgroupreserve { > my @results; > if ( my $data = $sth->fetchrow_hashref ) { > push( @results, $data ) >- unless any{ $data->{borrowernumber} eq $_ } @$ignore_borrowers ; >+ unless any{ $data->{patron_id} eq $_ } @$ignore_borrowers ; > } > return @results if @results; > > # check for title-level targeted match > my $title_level_target_query = qq{ >- SELECT reserves.biblionumber AS biblionumber, >- reserves.borrowernumber AS borrowernumber, >- reserves.reservedate AS reservedate, >- reserves.branchcode AS branchcode, >- reserves.cancellationdate AS cancellationdate, >- reserves.found AS found, >- reserves.reservenotes AS reservenotes, >- reserves.priority AS priority, >- reserves.timestamp AS timestamp, >+ SELECT holds.biblio_id AS biblio_id, >+ holds.patron_id AS patron_id, >+ holds.created_date AS created_date, >+ holds.pickup_library_id AS pickup_library_id, >+ holds.completed_date AS completed_date, >+ holds.status AS status, >+ holds.notes AS notes, >+ holds.priority AS priority, >+ holds.timestamp AS timestamp, > biblioitems.biblioitemnumber AS biblioitemnumber, >- reserves.itemnumber AS itemnumber, >- reserves.reserve_id AS reserve_id, >- reserves.itemtype AS itemtype, >- reserves.non_priority AS non_priority >- FROM reserves >- JOIN biblioitems USING (biblionumber) >- JOIN hold_fill_targets USING (reserve_id) >- WHERE found IS NULL >+ holds.item_id AS item_id, >+ holds.id AS id, >+ holds.item_type AS item_type, >+ holds.non_priority AS non_priority >+ FROM holds >+ JOIN biblioitems ON (holds.biblio_id=biblioitems.biblionumber) >+ JOIN hold_fill_targets ON ( >+ holds.biblio_id=hold_fill_targets.biblionumber >+ AND holds.patron_id=hold_fill_targets.borrowernumber) >+ WHERE status='placed' > AND priority > 0 >- AND item_level_request = 0 >+ AND completed = 0 >+ AND item_level = 0 > AND hold_fill_targets.itemnumber = ? >- AND reservedate <= DATE_ADD(NOW(),INTERVAL ? DAY) >- AND suspend = 0 >+ AND created_date <= DATE_ADD(NOW(),INTERVAL ? DAY) >+ AND suspended = 0 > ORDER BY priority > }; > $sth = $dbh->prepare($title_level_target_query); >@@ -1772,30 +1772,31 @@ sub _Findgroupreserve { > @results = (); > if ( my $data = $sth->fetchrow_hashref ) { > push( @results, $data ) >- unless any{ $data->{borrowernumber} eq $_ } @$ignore_borrowers ; >+ unless any{ $data->{patron_id} eq $_ } @$ignore_borrowers ; > } > return @results if @results; > > my $query = qq{ >- SELECT reserves.biblionumber AS biblionumber, >- reserves.borrowernumber AS borrowernumber, >- reserves.reservedate AS reservedate, >- reserves.waitingdate AS waitingdate, >- reserves.branchcode AS branchcode, >- reserves.cancellationdate AS cancellationdate, >- reserves.found AS found, >- reserves.reservenotes AS reservenotes, >- reserves.priority AS priority, >- reserves.timestamp AS timestamp, >- reserves.itemnumber AS itemnumber, >- reserves.reserve_id AS reserve_id, >- reserves.itemtype AS itemtype, >- reserves.non_priority AS non_priority >- FROM reserves >- WHERE reserves.biblionumber = ? >- AND (reserves.itemnumber IS NULL OR reserves.itemnumber = ?) >- AND reserves.reservedate <= DATE_ADD(NOW(),INTERVAL ? DAY) >- AND suspend = 0 >+ SELECT holds.biblio_id AS biblio_id, >+ holds.patron_id AS patron_id, >+ holds.created_date AS created_date, >+ holds.waiting_date AS waiting_date, >+ holds.pickup_library_id AS pickup_library_id, >+ holds.completed_date AS completed_date, >+ holds.status AS status, >+ holds.notes AS notes, >+ holds.priority AS priority, >+ holds.timestamp AS timestamp, >+ holds.item_id AS item_id, >+ holds.id AS id, >+ holds.item_type AS item_type, >+ holds.non_priority AS non_priority >+ FROM holds >+ WHERE holds.biblio_id = ? >+ AND (holds.item_id IS NULL OR holds.item_id = ?) >+ AND holds.created_date <= DATE_ADD(NOW(),INTERVAL ? DAY) >+ AND suspended = 0 >+ AND completed = 0 > ORDER BY priority > }; > $sth = $dbh->prepare($query); >@@ -1803,7 +1804,7 @@ sub _Findgroupreserve { > @results = (); > while ( my $data = $sth->fetchrow_hashref ) { > push( @results, $data ) >- unless any{ $data->{borrowernumber} eq $_ } @$ignore_borrowers ; >+ unless any{ $data->{patron_id} eq $_ } @$ignore_borrowers ; > } > return @results; > } >@@ -1839,7 +1840,7 @@ The following tables are availalbe witin the notice: > sub _koha_notify_reserve { > my $reserve_id = shift; > my $hold = Koha::Holds->find($reserve_id); >- my $borrowernumber = $hold->borrowernumber; >+ my $borrowernumber = $hold->patron_id; > > my $patron = Koha::Patrons->find( $borrowernumber ); > >@@ -1851,21 +1852,21 @@ sub _koha_notify_reserve { > message_name => 'Hold_Filled' > } ); > >- my $library = Koha::Libraries->find( $hold->branchcode ); >+ my $library = Koha::Libraries->find( $hold->pickup_library_id ); > my $admin_email_address = $library->from_email_address; > $library = $library->unblessed; > > my %letter_params = ( > module => 'reserves', >- branchcode => $hold->branchcode, >+ branchcode => $hold->pickup_library_id, > lang => $patron->lang, > tables => { > 'branches' => $library, > 'borrowers' => $patron->unblessed, >- 'biblio' => $hold->biblionumber, >- 'biblioitems' => $hold->biblionumber, >- 'reserves' => $hold->unblessed, >- 'items' => $hold->itemnumber, >+ 'biblio' => $hold->biblio_id, >+ 'biblioitems' => $hold->biblio_id, >+ 'holds' => $hold->unblessed, >+ 'items' => $hold->item_id, > }, > ); > >@@ -1929,7 +1930,7 @@ sub _ShiftPriorityByDateAndPriority { > my ( $biblio, $resdate, $new_priority ) = @_; > > my $dbh = C4::Context->dbh; >- my $query = "SELECT priority FROM reserves WHERE biblionumber = ? AND ( reservedate > ? OR priority > ? ) ORDER BY priority ASC LIMIT 1"; >+ my $query = "SELECT priority FROM holds WHERE biblio_id = ? AND ( created_date > ? OR priority > ? ) AND completed = 0 ORDER BY priority ASC LIMIT 1"; > my $sth = $dbh->prepare( $query ); > $sth->execute( $biblio, $resdate, $new_priority ); > my $min_priority = $sth->fetchrow; >@@ -1937,20 +1938,20 @@ sub _ShiftPriorityByDateAndPriority { > $new_priority = $min_priority if ( $min_priority ); > > # Shift the priority up by one; works in conjunction with the next SQL statement >- $query = "UPDATE reserves >+ $query = "UPDATE holds > SET priority = priority+1 >- WHERE biblionumber = ? >- AND borrowernumber = ? >- AND reservedate = ? >- AND found IS NULL"; >+ WHERE biblio_id = ? >+ AND patron_id = ? >+ AND created_date = ? >+ AND status = 'placed'"; > my $sth_update = $dbh->prepare( $query ); > > # Select all reserves for the biblio with priority greater than $new_priority, and order greatest to least >- $query = "SELECT borrowernumber, reservedate FROM reserves WHERE priority >= ? AND biblionumber = ? ORDER BY priority DESC"; >+ $query = "SELECT patron_id, created_date FROM holds WHERE priority >= ? AND biblio_id = ? ORDER BY priority DESC"; > $sth = $dbh->prepare( $query ); > $sth->execute( $new_priority, $biblio ); > while ( my $row = $sth->fetchrow_hashref ) { >- $sth_update->execute( $biblio, $row->{borrowernumber}, $row->{reservedate} ); >+ $sth_update->execute( $biblio, $row->{patron_id}, $row->{created_date} ); > } > > return $new_priority; # so the caller knows what priority they wind up receiving >@@ -1974,9 +1975,9 @@ sub MoveReserve { > my ( $restype, $res, undef ) = CheckReserves( $itemnumber, undef, $lookahead ); > return unless $res; > >- my $biblionumber = $res->{biblionumber}; >+ my $biblionumber = $res->{biblio_id}; > >- if ($res->{borrowernumber} == $borrowernumber) { >+ if ($res->{patron_id} == $borrowernumber) { > ModReserveFill($res); > } > else { >@@ -1985,8 +1986,8 @@ sub MoveReserve { > # Find this item in the reserves > > my $borr_res = Koha::Holds->search({ >- borrowernumber => $borrowernumber, >- biblionumber => $biblionumber, >+ patron_id => $borrowernumber, >+ biblio_id => $biblionumber, > },{ > order_by => 'priority' > })->next(); >@@ -2000,7 +2001,7 @@ sub MoveReserve { > RevertWaitingStatus({ itemnumber => $itemnumber }); > } > elsif ( $cancelreserve eq 'cancel' || $cancelreserve ) { # cancel reserves on this item >- my $hold = Koha::Holds->find( $res->{reserve_id} ); >+ my $hold = Koha::Holds->find( $res->{id} ); > $hold->cancel; > } > } >@@ -2017,33 +2018,31 @@ This shifts the holds from C<$from_biblio> to C<$to_biblio> and reorders them by > sub MergeHolds { > my ( $dbh, $to_biblio, $from_biblio ) = @_; > my $sth = $dbh->prepare( >- "SELECT count(*) as reserve_count FROM reserves WHERE biblionumber = ?" >+ "SELECT count(*) as reserve_count FROM holds WHERE biblio_id = ? AND completed = 0" > ); > $sth->execute($from_biblio); > if ( my $data = $sth->fetchrow_hashref() ) { > > # holds exist on old record, if not we don't need to do anything > $sth = $dbh->prepare( >- "UPDATE reserves SET biblionumber = ? WHERE biblionumber = ?"); >+ "UPDATE holds SET biblio_id = ? WHERE biblio_id = ?"); > $sth->execute( $to_biblio, $from_biblio ); > > # Reorder by date > # don't reorder those already waiting > > $sth = $dbh->prepare( >-"SELECT * FROM reserves WHERE biblionumber = ? AND (found NOT IN ('W', 'T', 'P') OR found is NULL) ORDER BY reservedate ASC" >+ "SELECT id FROM holds WHERE biblio_id = ? AND status = 'placed' AND completed = 0 ORDER BY created_date ASC" > ); > my $upd_sth = $dbh->prepare( >-"UPDATE reserves SET priority = ? WHERE biblionumber = ? AND borrowernumber = ? >- AND reservedate = ? AND (itemnumber = ? or itemnumber is NULL) " >+ "UPDATE holds SET priority = ? WHERE id = ? " > ); > $sth->execute( $to_biblio ); > my $priority = 1; > while ( my $reserve = $sth->fetchrow_hashref() ) { > $upd_sth->execute( >- $priority, $to_biblio, >- $reserve->{'borrowernumber'}, $reserve->{'reservedate'}, >- $reserve->{'itemnumber'} >+ $priority, >+ $reserve->{'id'} > ); > $priority++; > } >@@ -2066,36 +2065,34 @@ sub MergeHolds { > > sub RevertWaitingStatus { > my ( $params ) = @_; >- my $itemnumber = $params->{'itemnumber'}; >+ my $item_id = $params->{'itemnumber'}; > >- return unless ( $itemnumber ); >- >- my $dbh = C4::Context->dbh; >+ return unless ( $item_id ); > > ## Get the waiting reserve we want to revert > my $hold = Koha::Holds->search( > { >- itemnumber => $itemnumber, >- found => { not => undef }, >+ item_id => $item_id, >+ status => 'waiting', > } > )->next; > > ## Increment the priority of all other non-waiting > ## reserves for this bib record >- my $holds = Koha::Holds->search({ biblionumber => $hold->biblionumber, priority => { '>' => 0 } }) >+ my $holds = Koha::Holds->search({ biblio_id => $hold->biblio_id, priority => { '>' => 0 } }) > ->update({ priority => \'priority + 1' }, { no_triggers => 1 }); > > ## Fix up the currently waiting reserve > $hold->set( > { >- priority => 1, >- found => undef, >- waitingdate => undef, >- itemnumber => $hold->item_level_hold ? $hold->itemnumber : undef, >+ priority => 1, >+ status => 'placed', >+ waiting_date => undef, >+ item_id => $hold->item_level ? $hold->item_id : undef, > } > )->store(); > >- _FixPriority( { biblionumber => $hold->biblionumber } ); >+ _FixPriority( { biblionumber => $hold->biblio_id } ); > > return $hold; > } >@@ -2128,27 +2125,26 @@ available within the slip: > > sub ReserveSlip { > my ($args) = @_; >- my $branchcode = $args->{branchcode}; >+ my $branchcode = $args->{branchcode}; > my $reserve_id = $args->{reserve_id}; > > my $hold = Koha::Holds->find($reserve_id); > return unless $hold; > >- my $patron = $hold->borrower; >- my $reserve = $hold->unblessed; >+ my $patron = $hold->patron; > >- return C4::Letters::GetPreparedLetter ( >- module => 'circulation', >+ return C4::Letters::GetPreparedLetter( >+ module => 'circulation', > letter_code => 'HOLD_SLIP', >- branchcode => $branchcode, >- lang => $patron->lang, >- tables => { >- 'reserves' => $reserve, >- 'branches' => $reserve->{branchcode}, >- 'borrowers' => $reserve->{borrowernumber}, >- 'biblio' => $reserve->{biblionumber}, >- 'biblioitems' => $reserve->{biblionumber}, >- 'items' => $reserve->{itemnumber}, >+ branchcode => $branchcode, >+ lang => $patron->lang, >+ tables => { >+ 'holds' => $hold->unblessed, >+ 'branches' => $hold->pickup_library_id, >+ 'borrowers' => $hold->patron_id, >+ 'biblio' => $hold->biblio_id, >+ 'biblioitems' => $hold->biblio_id, >+ 'items' => $hold->item_id, > }, > ); > } >@@ -2202,17 +2198,17 @@ sub CalculatePriority { > my ( $biblionumber, $resdate ) = @_; > > my $sql = q{ >- SELECT COUNT(*) FROM reserves >- WHERE biblionumber = ? >+ SELECT COUNT(*) FROM holds >+ WHERE biblio_id = ? > AND priority > 0 >- AND (found IS NULL OR found = '') >+ AND status='placed' > }; >- #skip found==W or found==T or found==P (waiting, transit or processing holds) >+ #skip status==waiting or status==in_transit or status==processing > if( $resdate ) { >- $sql.= ' AND ( reservedate <= ? )'; >+ $sql.= ' AND ( created_date <= ? )'; > } > else { >- $sql.= ' AND ( reservedate < NOW() )'; >+ $sql.= ' AND ( created_date < NOW() )'; > } > my $dbh = C4::Context->dbh(); > my @row = $dbh->selectrow_array( >@@ -2226,26 +2222,24 @@ sub CalculatePriority { > > =head2 IsItemOnHoldAndFound > >- my $bool = IsItemFoundHold( $itemnumber ); >+ my $bool = IsItemFoundHold( $item_id ); > > Returns true if the item is currently on hold >- and that hold has a non-null found status ( W, T, etc. ) >+ and that hold has a status of in_transit, processing >+ or waiting. > > =cut > > sub IsItemOnHoldAndFound { >- my ($itemnumber) = @_; >- >- my $rs = Koha::Database->new()->schema()->resultset('Reserve'); >+ my ($item_id) = @_; > >- my $found = $rs->count( >+ return Koha::Holds->search( > { >- itemnumber => $itemnumber, >- found => { '!=' => undef } >+ item_id => $item_id, >+ status => [ 'in_transit', 'processing', 'waiting' ], >+ completed => 0 > } >- ); >- >- return $found; >+ )->count; > } > > =head2 GetMaxPatronHoldsForRecord >diff --git a/C4/SIP/ILS/Item.pm b/C4/SIP/ILS/Item.pm >index 48df606cad..a9ae49e8c9 100644 >--- a/C4/SIP/ILS/Item.pm >+++ b/C4/SIP/ILS/Item.pm >@@ -105,7 +105,18 @@ sub new { > $self->{borrowernumber} = $patron->borrowernumber; > } > my $biblio = Koha::Biblios->find( $self->{biblionumber} ); >- my $holds = $biblio->current_holds->unblessed; >+ >+ # Holds >+ my $view_query = q{ >+ SELECT * >+ FROM >+ reserves >+ WHERE >+ biblionumber = ? >+ }; >+ >+ my $holds = C4::Context->dbh->selectall_arrayref( $view_query, { 'Slice' => {} }, $biblio->biblionumber ); >+ > $self->{hold_queue} = $holds; > $self->{hold_attached} = [( grep { defined $_->{found} and ( $_->{found} eq 'W' or $_->{found} eq 'P' or $_->{found} eq 'T' ) } @{$self->{hold_queue}} )]; > $self->{pending_queue} = [( grep {(! defined $_->{found}) or ( $_->{found} ne 'W' and $_->{found} ne 'P' and $_->{found} ne 'T' ) } @{$self->{hold_queue}} )]; >@@ -353,7 +364,7 @@ sub recall_date { > sub hold_pickup_date { > my $self = shift; > >- my $hold = Koha::Holds->find({ itemnumber => $self->{itemnumber}, found => 'W' }); >+ my $hold = Koha::Holds->find({ item_id => $self->{itemnumber}, status => 'waiting' }); > if ( $hold ) { > return $hold->expirationdate || 0; > } >diff --git a/C4/SIP/ILS/Patron.pm b/C4/SIP/ILS/Patron.pm >index e40dbdbf39..4838b325aa 100644 >--- a/C4/SIP/ILS/Patron.pm >+++ b/C4/SIP/ILS/Patron.pm >@@ -520,11 +520,11 @@ sub _get_outstanding_holds { > my $borrowernumber = shift; > > my $patron = Koha::Patrons->find( $borrowernumber ); >- my $holds = $patron->holds->search( { -or => [ { found => undef }, { found => { '!=' => 'W' } } ] } ); >+ my $holds = $patron->holds->search( { completed => 0, status => {'!=' => 'waiting'} } ); > my @holds; > while ( my $hold = $holds->next ) { > my $item; >- if ($hold->itemnumber) { >+ if ($hold->item_id) { > $item = $hold->item; > } > else { >diff --git a/C4/SIP/ILS/Transaction/Hold.pm b/C4/SIP/ILS/Transaction/Hold.pm >index 82fddf1e97..4eea0b5ad7 100644 >--- a/C4/SIP/ILS/Transaction/Hold.pm >+++ b/C4/SIP/ILS/Transaction/Hold.pm >@@ -86,7 +86,7 @@ sub drop_hold { > } > > my $item = Koha::Items->find({ barcode => $self->{item}->id }); >- my $holds = $item->holds->search({ borrowernumber => $patron->borrowernumber }); >+ my $holds = $item->holds->search({ patron_id => $patron->borrowernumber }); > > return $self unless $holds->count; > >diff --git a/C4/XSLT.pm b/C4/XSLT.pm >index 245d76b74f..2ab6a2063c 100644 >--- a/C4/XSLT.pm >+++ b/C4/XSLT.pm >@@ -315,7 +315,7 @@ sub buildKohaItemsNamespace { > $items_rs = Koha::Items->new; > } > >- my $items = $items_rs->search( $query, { prefetch => [ 'branchtransfers', 'reserves' ] } ); >+ my $items = $items_rs->search( $query, { prefetch => [ 'branchtransfers', 'holds' ] } ); > > my $shelflocations = > { map { $_->{authorised_value} => $_->{opac_description} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => "", kohafield => 'items.location' } ) }; >diff --git a/Koha/Acquisition/Order.pm b/Koha/Acquisition/Order.pm >index 090920d92c..9495e83d6f 100644 >--- a/Koha/Acquisition/Order.pm >+++ b/Koha/Acquisition/Order.pm >@@ -298,7 +298,7 @@ sub current_item_level_holds { > > return $biblio->current_holds->search( > { >- itemnumber => { >+ item_id => { > -in => \@item_numbers > } > } >diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm >index 26ee7abd96..dcf1605e54 100644 >--- a/Koha/Biblio.pm >+++ b/Koha/Biblio.pm >@@ -444,7 +444,8 @@ return the current holds placed on this record > sub holds { > my ( $self, $params, $attributes ) = @_; > $attributes->{order_by} = 'priority' unless exists $attributes->{order_by}; >- my $hold_rs = $self->_result->reserves->search( $params, $attributes ); >+ $params->{completed} = 0 unless exists $params->{completed}; >+ my $hold_rs = $self->_result->holds->search( $params, $attributes ); > return Koha::Holds->_new_from_dbic($hold_rs); > } > >@@ -461,7 +462,7 @@ sub current_holds { > my ($self) = @_; > my $dtf = Koha::Database->new->schema->storage->datetime_parser; > return $self->holds( >- { reservedate => { '<=' => $dtf->format_date(dt_from_string) } } ); >+ { completed => 0, created_date => { '<=' => $dtf->format_date(dt_from_string) } } ); > } > > =head3 biblioitem >@@ -522,8 +523,8 @@ Tells if this bibliographic record has items waiting or in transit. > sub has_items_waiting_or_intransit { > my ( $self ) = @_; > >- if ( Koha::Holds->search({ biblionumber => $self->id, >- found => ['W', 'T'] })->count ) { >+ if ( Koha::Holds->search({ biblio_id => $self->id, >+ status => ['waiting', 'in_transit'] })->count ) { > return 1; > } > >diff --git a/Koha/Hold.pm b/Koha/Hold.pm >index aae7386d75..a03113b938 100644 >--- a/Koha/Hold.pm >+++ b/Koha/Hold.pm >@@ -368,7 +368,7 @@ sub is_in_processing { > > Returns true if hold is a cancelable hold > >-Holds may be only canceled if they are not found. >+Holds may be only canceled if they are not found or completed. > > This is used from the OPAC. > >@@ -377,8 +377,11 @@ This is used from the OPAC. > sub is_cancelable_from_opac { > my ($self) = @_; > >- return 1 unless $self->is_found(); >- return 0; # if ->is_in_transit or if ->is_waiting or ->is_in_processing >+ if ( $self->completed or $self->is_found ) { >+ return 0; >+ } >+ >+ return 1; > } > > =head3 is_at_destination >@@ -590,11 +593,11 @@ sub store { > if ( !$self->in_storage ) { > if ( > C4::Context->preference('DefaultHoldExpirationdate') >- and ( not defined $self->expirationdate >- or $self->expirationdate eq '' ) >+ and ( not defined $self->expiration_date >+ or $self->expiration_date eq '' ) > ) > { >- $self->_set_default_expirationdate; >+ $self->_set_default_expiration_date; > } > } > else { >@@ -602,15 +605,15 @@ sub store { > my %updated_columns = $self->_result->get_dirty_columns; > return $self->SUPER::store unless %updated_columns; > >- if ( exists $updated_columns{reservedate} ) { >+ if ( exists $updated_columns{created_date} ) { > if ( > C4::Context->preference('DefaultHoldExpirationdate') >- and ( not exists $updated_columns{expirationdate} >- or exists $updated_columns{expirationdate} >- and $updated_columns{expirationdate} eq '' ) >+ and ( not exists $updated_columns{expiration_date} >+ or exists $updated_columns{expiration_date} >+ and $updated_columns{expiration_date} eq '' ) > ) > { >- $self->_set_default_expirationdate; >+ $self->_set_default_expiration_date; > } > } > } >@@ -618,15 +621,15 @@ sub store { > $self = $self->SUPER::store; > } > >-sub _set_default_expirationdate { >+sub _set_default_expiration_date { > my $self = shift; > > my $period = C4::Context->preference('DefaultHoldExpirationdatePeriod') || 0; > my $timeunit = > C4::Context->preference('DefaultHoldExpirationdateUnitOfTime') || 'days'; > >- $self->expirationdate( >- dt_from_string( $self->reservedate )->add( $timeunit => $period ) ); >+ $self->expiration_date( >+ dt_from_string( $self->created_date )->add( $timeunit => $period ) ); > } > > =head3 to_api_mapping >diff --git a/Koha/Holds.pm b/Koha/Holds.pm >index 05edfe5f49..26cfaed4ca 100644 >--- a/Koha/Holds.pm >+++ b/Koha/Holds.pm >@@ -36,6 +36,26 @@ Koha::Holds - Koha Hold object set class > > =cut > >+ >+=head3 filter_by_current >+ >+ my $holds_rs = Koha::Holds->filter_by_current( ... ); >+ >+Filter the resultset by current (i.e. completed = 0). >+ >+=cut >+ >+sub filter_by_current { >+ my ( $self ) = @_; >+ >+ return $self->search( >+ { >+ completed => 0 >+ } >+ ); >+} >+ >+ > =head3 waiting > > returns a set of holds that are waiting from an existing set >@@ -121,7 +141,7 @@ Items that are not: > sub get_items_that_can_fill { > my ( $self ) = @_; > >- my @biblionumbers = $self->get_column('biblionumber'); >+ my @biblionumbers = $self->get_column('biblio_id'); > > my @branchtransfers = map { $_->itemnumber } > Koha::Item::Transfers->search( >@@ -131,11 +151,14 @@ sub get_items_that_can_fill { > collapse => 1, > } > ); >- my @waiting_holds = map { $_->itemnumber } >+ my @waiting_holds = map { $_->item_id } > Koha::Holds->search( >- { 'found' => 'W' }, > { >- columns => ['itemnumber'], >+ status => 'waiting', >+ completed => 0 >+ }, >+ { >+ columns => ['item_id'], > collapse => 1, > } > ); >diff --git a/Koha/Item.pm b/Koha/Item.pm >index c653dc2583..9862b091d1 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -281,7 +281,7 @@ sub safe_to_delete { > > # check it doesn't have a waiting reserve > return "book_reserved" >- if $self->holds->search( { found => [ 'W', 'T' ] } )->count; >+ if $self->holds->search( { status => [ 'waiting', 'in_transit' ], completed => 0 } )->count; > > return "linked_analytics" > if C4::Items::GetAnalyticsCount( $self->itemnumber ) > 0; >@@ -290,7 +290,7 @@ sub safe_to_delete { > if $self->biblio->items->count == 1 > && $self->biblio->holds->search( > { >- itemnumber => undef, >+ item_id => undef, > } > )->count; > >@@ -397,7 +397,7 @@ sub checkout { > > my $holds = $item->holds(); > my $holds = $item->holds($params); >-my $holds = $item->holds({ found => 'W'}); >+my $holds = $item->holds({ status => 'waiting'}); > > Return holds attached to an item, optionally accept a hashref of params to pass to search > >@@ -405,7 +405,8 @@ Return holds attached to an item, optionally accept a hashref of params to pass > > sub holds { > my ( $self,$params ) = @_; >- my $holds_rs = $self->_result->reserves->search($params); >+ $params->{completed} = 0 unless exists $params->{completed}; >+ my $holds_rs = $self->_result->holds->search($params); > return Koha::Holds->_new_from_dbic( $holds_rs ); > } > >@@ -789,14 +790,15 @@ sub current_holds { > my $attributes = { order_by => 'priority' }; > my $dtf = Koha::Database->new->schema->storage->datetime_parser; > my $params = { >- itemnumber => $self->itemnumber, >- suspend => 0, >+ item_id => $self->itemnumber, >+ suspended => 0, > -or => [ >- reservedate => { '<=' => $dtf->format_date(dt_from_string) }, >- waitingdate => { '!=' => undef }, >+ created_date => { '<=' => $dtf->format_date(dt_from_string) }, >+ waiting_date => { '!=' => undef }, > ], >+ completed => 0 > }; >- my $hold_rs = $self->_result->reserves->search( $params, $attributes ); >+ my $hold_rs = $self->_result->holds->search( $params, $attributes ); > return Koha::Holds->_new_from_dbic($hold_rs); > } > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 941dace0df..320938fe59 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -71,9 +71,8 @@ our $RESULTSET_PATRON_ID_MAPPING = { > Message => 'borrowernumber', > MessageQueue => 'borrowernumber', > OldIssue => 'borrowernumber', >- OldReserve => 'borrowernumber', > Rating => 'borrowernumber', >- Reserve => 'borrowernumber', >+ Hold => 'patron_id', > Review => 'borrowernumber', > SearchHistory => 'userid', > Statistic => 'borrowernumber', >@@ -1205,8 +1204,9 @@ Return all the holds placed by this patron > =cut > > sub holds { >- my ($self) = @_; >- my $holds_rs = $self->_result->reserves->search( {}, { order_by => 'reservedate' } ); >+ my ($self, $params) = @_; >+ $params->{completed} = 0 unless exists $params->{completed}; >+ my $holds_rs = $self->_result->holds->search( $params, { order_by => 'created_date' } ); > return Koha::Holds->_new_from_dbic($holds_rs); > } > >@@ -1220,8 +1220,8 @@ Return all the historical holds for this patron > > sub old_holds { > my ($self) = @_; >- my $old_holds_rs = $self->_result->old_reserves->search( {}, { order_by => 'reservedate' } ); >- return Koha::Old::Holds->_new_from_dbic($old_holds_rs); >+ my $old_holds_rs = $self->_result->holds->search( { completed => 1 }, { order_by => 'created_date' } ); >+ return Koha::Holds->_new_from_dbic($old_holds_rs); > } > > =head3 return_claims >diff --git a/Koha/REST/V1/Auth.pm b/Koha/REST/V1/Auth.pm >index 2361aae361..73a133b448 100644 >--- a/Koha/REST/V1/Auth.pm >+++ b/Koha/REST/V1/Auth.pm >@@ -318,10 +318,10 @@ sub validate_query_parameters { > Allows access to object for its owner. > > There are endpoints that should allow access for the object owner even if they >-do not have the required permission, e.g. access an own reserve. This can be >+do not have the required permission, e.g. access an own hold. This can be > achieved by defining the operation as follows: > >-"/holds/{reserve_id}": { >+"/holds/{hold_id}": { > "get": { > ..., > "x-koha-authorization": { >@@ -385,7 +385,7 @@ sub check_object_ownership { > borrowernumber => \&_object_ownership_by_patron_id, > patron_id => \&_object_ownership_by_patron_id, > checkout_id => \&_object_ownership_by_checkout_id, >- reserve_id => \&_object_ownership_by_reserve_id, >+ hold_id => \&_object_ownership_by_hold_id, > }; > > foreach my $param ( keys %{ $parameters } ) { >@@ -449,20 +449,18 @@ sub _object_ownership_by_checkout_id { > && $user->borrowernumber == $issue->borrowernumber; > } > >-=head3 _object_ownership_by_reserve_id >+=head3 _object_ownership_by_hold_id > >-Finds a Koha::Hold-object by C<$reserve_id> and checks if it >+Finds a Koha::Hold-object by C<$hold_id> and checks if it > belongs to C<$user>. > >-TODO: Also compare against old_reserves >- > =cut > >-sub _object_ownership_by_reserve_id { >- my ($c, $user, $reserve_id) = @_; >+sub _object_ownership_by_hold_id { >+ my ($c, $user, $hold_id) = @_; > >- my $reserve = Koha::Holds->find($reserve_id); >- return $reserve && $user->borrowernumber == $reserve->borrowernumber; >+ my $hold = Koha::Holds->find($hold_id); >+ return $hold && $user->borrowernumber == $hold->borrowernumber; > } > > =head3 _basic_auth >diff --git a/Koha/REST/V1/Holds.pm b/Koha/REST/V1/Holds.pm >index 7541a5c653..285cb70f73 100644 >--- a/Koha/REST/V1/Holds.pm >+++ b/Koha/REST/V1/Holds.pm >@@ -45,7 +45,7 @@ sub list { > my $c = shift->openapi->valid_input or return; > > return try { >- my $holds_set = Koha::Holds->new; >+ my $holds_set = Koha::Holds->search({completed=>0}); > my $holds = $c->objects->search( $holds_set ); > return $c->render( status => 200, openapi => $holds ); > } >@@ -76,13 +76,13 @@ sub add { > my $item_type = $body->{item_type}; > my $expiration_date = $body->{expiration_date}; > my $notes = $body->{notes}; >- my $hold_date = $body->{hold_date}; >+ my $created_date = $body->{created_date}; > my $non_priority = $body->{non_priority}; > > my $overrides = $c->stash('koha.overrides'); > my $can_override = $overrides->{any} && C4::Context->preference('AllowHoldPolicyOverride'); > >- if(!C4::Context->preference( 'AllowHoldDateInFuture' ) && $hold_date) { >+ if(!C4::Context->preference( 'AllowHoldDateInFuture' ) && $created_date) { > return $c->render( > status => 400, > openapi => { error => "Hold date in future not allowed" } >@@ -194,7 +194,7 @@ sub add { > borrowernumber => $patron_id, > biblionumber => $biblio_id, > priority => $priority, >- reservation_date => $hold_date, >+ reservation_date => $created_date, > expiration_date => $expiration_date, > notes => $notes, > title => $biblio->title, >@@ -248,7 +248,7 @@ sub edit { > > return try { > my $hold_id = $c->validation->param('hold_id'); >- my $hold = Koha::Holds->find( $hold_id ); >+ my $hold = Koha::Holds->search({id=>$hold_id, completed=>0})->next; > > unless ($hold) { > return $c->render( >@@ -277,17 +277,17 @@ sub edit { > ); > } > >- $pickup_library_id //= $hold->branchcode; >+ $pickup_library_id //= $hold->pickup_library_id; > my $priority = $body->{priority} // $hold->priority; > # suspended_until can also be set to undef >- my $suspended_until = exists $body->{suspended_until} ? $body->{suspended_until} : $hold->suspend_until; >+ my $suspended_until = exists $body->{suspended_until_date} ? $body->{suspended_until_date} : $hold->suspended_until_date; > > my $params = { > reserve_id => $hold_id, > branchcode => $pickup_library_id, > rank => $priority, > suspend_until => $suspended_until ? output_pref(dt_from_string($suspended_until, 'rfc3339')) : '', >- itemnumber => $hold->itemnumber >+ itemnumber => $hold->item_id > }; > > C4::Reserves::ModReserve($params); >@@ -313,7 +313,7 @@ sub delete { > my $c = shift->openapi->valid_input or return; > > my $hold_id = $c->validation->param('hold_id'); >- my $hold = Koha::Holds->find($hold_id); >+ my $hold = Koha::Holds->search({id=>$hold_id, completed=>0})->next; > > unless ($hold) { > return $c->render( status => 404, openapi => { error => "Hold not found." } ); >@@ -342,7 +342,7 @@ sub suspend { > my $c = shift->openapi->valid_input or return; > > my $hold_id = $c->validation->param('hold_id'); >- my $hold = Koha::Holds->find($hold_id); >+ my $hold = Koha::Holds->search({id=>$hold_id, completed=>0})->next; > my $body = $c->req->json; > my $end_date = ($body) ? $body->{end_date} : undef; > >@@ -356,9 +356,9 @@ sub suspend { > $hold->discard_changes; > $c->res->headers->location( $c->req->url->to_string ); > my $suspend_end_date; >- if ($hold->suspend_until) { >+ if ($hold->suspended_until_date) { > $suspend_end_date = output_pref({ >- dt => dt_from_string( $hold->suspend_until ), >+ dt => dt_from_string( $hold->suspended_until_date ), > dateformat => 'rfc3339', > dateonly => 1 > } >@@ -390,7 +390,7 @@ sub resume { > my $c = shift->openapi->valid_input or return; > > my $hold_id = $c->validation->param('hold_id'); >- my $hold = Koha::Holds->find($hold_id); >+ my $hold = Koha::Holds->search({id=>$hold_id, completed=>0})->next; > my $body = $c->req->json; > > unless ($hold) { >@@ -416,7 +416,7 @@ sub update_priority { > my $c = shift->openapi->valid_input or return; > > my $hold_id = $c->validation->param('hold_id'); >- my $hold = Koha::Holds->find($hold_id); >+ my $hold = Koha::Holds->search({id=>$hold_id, completed=>0})->next; > > unless ($hold) { > return $c->render( >@@ -464,7 +464,7 @@ sub pickup_locations { > return try { > my $ps_set; > >- if ( $hold->itemnumber ) { >+ if ( $hold->item_id ) { > $ps_set = $hold->item->pickup_locations( { patron => $hold->patron } ); > } > else { >diff --git a/Koha/Template/Plugin/Biblio.pm b/Koha/Template/Plugin/Biblio.pm >index e9d7a73009..d07b184edc 100644 >--- a/Koha/Template/Plugin/Biblio.pm >+++ b/Koha/Template/Plugin/Biblio.pm >@@ -29,11 +29,14 @@ use Koha::ArticleRequests; > use Koha::ArticleRequest::Status; > > sub HoldsCount { >- my ( $self, $biblionumber ) = @_; >- >- my $holds = Koha::Holds->search( { biblionumber => $biblionumber } ); >+ my ( $self, $biblio_id ) = @_; > >- return $holds->count(); >+ return Koha::Holds->search( >+ { >+ biblio_id => $biblio_id, >+ completed => 0 >+ } >+ )->count; > } > > sub ArticleRequestsActiveCount { >diff --git a/api/v1/swagger/definitions/hold.json b/api/v1/swagger/definitions/hold.json >index 2fe5b6de96..676591a016 100644 >--- a/api/v1/swagger/definitions/hold.json >+++ b/api/v1/swagger/definitions/hold.json >@@ -9,7 +9,7 @@ > "type": "integer", > "description": "Internal patron identifier" > }, >- "hold_date": { >+ "created_date": { > "type": ["string", "null"], > "format": "date", > "description": "The date the hold was placed" >@@ -45,7 +45,7 @@ > }, > "status": { > "type": ["string", "null"], >- "description": "A one letter code defining what the status of the hold is after it has been confirmed" >+ "description": "the status the hold is ('placed', 'fulfilled', 'waiting', 'in_transit', 'cancelled')" > }, > "timestamp": { > "type": "string", >@@ -74,7 +74,7 @@ > "type": "boolean", > "description": "Controls if the hold is suspended" > }, >- "suspended_until": { >+ "suspended_until_date": { > "type": ["string", "null"], > "format": "date-time", > "description": "Date until which the hold has been suspended" >@@ -90,6 +90,14 @@ > "item_level": { > "type": "boolean", > "description": "If the hold is placed at item level" >+ }, >+ "completed": { >+ "type": "boolean", >+ "description": "If it has been completed (i.e. either 'fulfilled' or 'cancelled')" >+ }, >+ "completed_date": { >+ "type": ["string", "null"], >+ "description": "the date this hold was completed (fulfilled or cancelled)" > } > }, > "additionalProperties": false >diff --git a/api/v1/swagger/paths/holds.json b/api/v1/swagger/paths/holds.json >index ea5245a08e..ede93d52ea 100644 >--- a/api/v1/swagger/paths/holds.json >+++ b/api/v1/swagger/paths/holds.json >@@ -99,7 +99,7 @@ > "type": "boolean" > }, > { >- "name": "suspended_until", >+ "name": "suspended_until_date", > "in": "query", > "description": "Suspended until", > "type": "string" >@@ -228,7 +228,11 @@ > "non_priority": { > "description": "Set this hold as non priority", > "type": [ "boolean", "null" ] >- } >+ }, >+ "created_date": { >+ "type": "string", >+ "format": "date", >+ "description": "The date the hold was placed" } > }, > "required": [ "patron_id", "pickup_library_id" ], > "additionalProperties": false >@@ -320,7 +324,7 @@ > "description": "Internal library identifier for the pickup library", > "type": "string" > }, >- "suspended_until": { >+ "suspended_until_date": { > "description": "Date until which the hold has been suspended", > "type": "string", > "format": "date-time" >@@ -407,7 +411,7 @@ > "description": "Internal library identifier for the pickup library", > "type": "string" > }, >- "suspended_until": { >+ "suspended_until_date": { > "description": "Date until which the hold has been suspended", > "type": "string", > "format": "date-time" >diff --git a/circ/circulation.pl b/circ/circulation.pl >index 7988782577..b3bdad18ab 100755 >--- a/circ/circulation.pl >+++ b/circ/circulation.pl >@@ -448,7 +448,7 @@ if (@$barcodes) { > # BUILD HTML > # show all reserves of this borrower, and the position of the reservation .... > if ($patron) { >- my $holds = Koha::Holds->search( { borrowernumber => $borrowernumber } ); # FIXME must be Koha::Patron->holds >+ my $holds = Koha::Holds->search( { patron_id => $borrowernumber } ); # FIXME must be Koha::Patron->holds > my $waiting_holds = $holds->waiting; > $template->param( > holds_count => $holds->count(), >diff --git a/circ/returns.pl b/circ/returns.pl >index 914d5de35c..bcf3306f8b 100755 >--- a/circ/returns.pl >+++ b/circ/returns.pl >@@ -335,7 +335,7 @@ if ($barcode) { > if (C4::Context->preference("WaitingNotifyAtCheckin") ) { > #Check for waiting holds > my $patron = Koha::Patrons->find( $borrower->{borrowernumber} ); >- my $waiting_holds = $patron->holds->search({ found => 'W', branchcode => $userenv_branch })->count; >+ my $waiting_holds = $patron->holds->waiting->search({ pickup_library_id => $userenv_branch })->count; > if ($waiting_holds > 0) { > $template->param( > waiting_holds => $waiting_holds, >diff --git a/installer/data/mysql/en/mandatory/sample_notices.yml b/installer/data/mysql/en/mandatory/sample_notices.yml >index db40a3a4cc..6a03192dc7 100644 >--- a/installer/data/mysql/en/mandatory/sample_notices.yml >+++ b/installer/data/mysql/en/mandatory/sample_notices.yml >@@ -459,10 +459,10 @@ tables: > - "<ul>" > - " <li><<items.barcode>></li>" > - " <li><<items.itemcallnumber>></li>" >- - " <li><<reserves.waitingdate>></li>" >+ - " <li><<holds.waiting_date>></li>" > - "</ul>" > - "<p>Notes:" >- - "<pre><<reserves.reservenotes>></pre>" >+ - "<pre><<holds.notes>></pre>" > - "</p>" > - "" > >@@ -1261,7 +1261,7 @@ tables: > message_transport_type: email > lang: default > content: >- - "Dear [% borrower.firstname %] [% borrower.surname %],\n\nThe following holds are waiting at [% branch.branchname %]:\n\n[% FOREACH hold IN holds %]\n [% hold.biblio.title %] : waiting since [% hold.waitingdate | $KohaDates %]\n[% END %]" >+ - "Dear [% borrower.firstname %] [% borrower.surname %],\n\nThe following holds are waiting at [% branch.branchname %]:\n\n[% FOREACH hold IN holds %]\n [% hold.biblio.title %] : waiting since [% hold.waiting_date | $KohaDates %]\n[% END %]" > > - module: serial > code: SERIAL_ALERT >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt >index 61e94ca026..90e1d4bee0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt >@@ -53,7 +53,7 @@ > [% END %] > [% BLOCK item_status %] > [% IF myitem.onloan %]<span>Checked out</span> >- [% ELSIF myitem.holds({ found => ['W', 'T'] }).count > 0 %]<span>On hold</span> >+ [% ELSIF myitem.holds({ status => ['waiting', 'in_transit'] }).count > 0 %]<span>On hold</span> > [% ELSIF myitem.notforloan > 0 OR myitem.itemtype.notforloan %]<span>Not for loan</span> > [% ELSIF myitem.notforloan < 0 %]<span>On order</span> > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt >index bd2aad334f..058c269aa3 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt >@@ -74,41 +74,41 @@ > <td>[% INCLUDE 'biblio-title.inc' biblio=hold.biblio link = 1 %]</td> > <td>[% hold.biblio.author | html %]</td> > <td>[% hold.item.barcode | html %]</td> >- <td>[% Branches.GetName( hold.branchcode ) | html %]</td> >- <td data-order="[% hold.reservedate | html %]">[% hold.reservedate | $KohaDates %]</td> >- <td data-order="[% hold.expirationdate | html %]"> >- [% hold.expirationdate | $KohaDates %] >+ <td>[% Branches.GetName( hold.pickup_library_id ) | html %]</td> >+ <td data-order="[% hold.created_date | html %]">[% hold.created_date | $KohaDates %]</td> >+ <td data-order="[% hold.expiration_date | html %]"> >+ [% hold.expiration_date | $KohaDates %] > </td> >- <td data-order="[% hold.waitingdate | html %]"> >- [% hold.waitingdate | $KohaDates %] >+ <td data-order="[% hold.waiting_date | html %]"> >+ [% hold.waiting_date | $KohaDates %] > </td> >- <td data-order="[% hold.cancellationdate | html %]"> >- [% hold.cancellationdate | $KohaDates %] >+ <td data-order="[% hold.completed_date | html %]"> >+ [% hold.completed_date | $KohaDates %] > </td> > [% IF show_itemtype_column %] > <td> >- [% IF hold.itemtype %] >- [% ItemTypes.GetDescription( hold.itemtype ) | html %] >+ [% IF hold.item_type %] >+ [% ItemTypes.GetDescription( hold.item_type ) | html %] > [% ELSE %] > <span>Any item type</span> > [% END %] > </td> > [% END %] > <td> >- [% IF hold.found == 'F' %] >+ [% IF hold.status == 'fulfilled' %] > Fulfilled >- [% ELSIF hold.cancellationdate %] >+ [% ELSIF hold.status == 'cancelled' %] > Cancelled > [% IF hold.cancellation_reason %] > ([% AuthorisedValues.GetByCode('HOLD_CANCELLATION', hold.cancellation_reason) | html %]) > [% END %] >- [% ELSIF hold.found == 'W' %] >+ [% ELSIF hold.status == 'waiting' %] > Waiting >- [% ELSIF hold.found == 'P' %] >+ [% ELSIF hold.status == 'processing' %] > Processing >- [% ELSIF hold.found == 'T' %] >+ [% ELSIF hold.status == 'in_transit' %] > In transit >- [% ELSE %] >+ [% ELSIF hold.status == 'placed' %] > Pending > [% END %] > </td> >diff --git a/koha-tmpl/intranet-tmpl/prog/js/holds.js b/koha-tmpl/intranet-tmpl/prog/js/holds.js >index e076fa5536..998bd5aca0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/holds.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/holds.js >@@ -77,7 +77,7 @@ $(document).ready(function() { > }, > { > "mDataProp": function( oObj ) { >- if( oObj.branches.length > 1 && oObj.found !== 'W' && oObj.found !== 'T' ){ >+ if( oObj.branches.length > 1 && oObj.status !== 'waiting' && oObj.status !== 'in_transit' ){ > var branchSelect='<select priority='+oObj.priority+' class="hold_location_select" reserve_id="'+oObj.reserve_id+'" name="pick-location">'; > for ( var i=0; i < oObj.branches.length; i++ ){ > var selectedbranch; >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-holdshistory.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-holdshistory.tt >index 01e409b45e..d598efbb54 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-holdshistory.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-holdshistory.tt >@@ -107,23 +107,27 @@ > <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% hold.biblio.biblionumber | uri %]">[% INCLUDE 'biblio-title.inc' biblio=hold.biblio %]</a></td> > <td>[% hold.biblio.author | html %]</td> > <td>[% hold.item.barcode | html %]</td> >- <td>[% Branches.GetName( hold.branchcode ) | html %]</td> >- <td data-order="[% hold.reservedate | html %]">[% hold.reservedate | $KohaDates %]</td> >- <td data-order="[% hold.expirationdate | html %]"> >- [% IF hold.expirationdate %] >- [% hold.expirationdate | $KohaDates %] >+ <td>[% Branches.GetName( hold.pickup_library_id ) | html %]</td> >+ <td data-order="[% hold.created_date | html %]">[% hold.created_date | $KohaDates %]</td> >+ <td data-order="[% hold.expiration_date | html %]"> >+ [% IF hold.expiration_date %] >+ [% hold.expiration_date | $KohaDates %] > [% END %] > </td> >- <td data-order="[% hold.waitingdate | html %]"> >- [% IF hold.waitingdate %] >- [% hold.waitingdate | $KohaDates %] >- [% END %] >- </td> >- <td data-order="[% hold.cancellationdate | html %]"> >- [% IF hold.cancellationdate %] >- [% hold.cancellationdate | $KohaDates %] >+ <td data-order="[% hold.waiting_date | html %]"> >+ [% IF hold.waiting_date %] >+ [% hold.waiting_date | $KohaDates %] > [% END %] > </td> >+ [% IF hold.status == 'cancelled' %] >+ <td data-order="[% hold.completed_date | html %]"> >+ [% IF hold.completed_date %] >+ [% hold.completed_date | $KohaDates %] >+ [% END %] >+ </td> >+ [% ELSE %] >+ <td></td> >+ [% END %] > [% IF show_itemtype_column %] > <td> > [% IF hold.itemtype %] >@@ -134,13 +138,13 @@ > </td> > [% END %] > <td> >- [% IF hold.found == 'F' %] >+ [% IF hold.status == 'fulfilled' %] > Fulfilled >- [% ELSIF hold.cancellationdate %] >+ [% ELSIF hold.status == 'cancelled' %] > Cancelled >- [% ELSIF hold.found == 'W' %] >+ [% ELSIF hold.status == 'waiting' %] > Waiting >- [% ELSIF hold.found == 'T' %] >+ [% ELSIF hold.status == 'in_transit' %] > In transit > [% ELSE %] > Pending >diff --git a/members/holdshistory.pl b/members/holdshistory.pl >index 8564c09a69..edcc707b4a 100755 >--- a/members/holdshistory.pl >+++ b/members/holdshistory.pl >@@ -53,7 +53,6 @@ unless ( $patron ) { > } > > my $holds; >-my $old_holds; > > if ( $borrowernumber eq C4::Context->preference('AnonymousPatron') ){ > # use of 'eq' in the above comparison is intentional -- the >@@ -61,21 +60,12 @@ if ( $borrowernumber eq C4::Context->preference('AnonymousPatron') ){ > $template->param( is_anonymous => 1 ); > } else { > $holds = $patron->holds; >- $old_holds = $patron->old_holds; >- >- while (my $hold = $holds->next) { >- push @all_holds, $hold; >- } >- >- while (my $hold = $old_holds->next) { >- push @all_holds, $hold; >- } > } > > $template->param( > holdshistoryview => 1, > patron => $patron, >- holds => \@all_holds, >+ holds => $holds > ); > > output_html_with_http_headers $input, $cookie, $template->output; >diff --git a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl b/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl >index fedc3cf888..72f3363cc5 100755 >--- a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl >+++ b/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl >@@ -314,17 +314,17 @@ sub GetWaitingHolds { > my $patron_branchcode_filter = $patron_branchcode ? "AND borrowers.branchcode = '$patron_branchcode'" : q{}; > > my $query = "SELECT borrowers.borrowernumber, borrowers.cardnumber, borrowers.title as patron_title, borrowers.firstname, borrowers.surname, borrowers.categorycode, >- borrowers.phone, borrowers.email, borrowers.branchcode, biblio.biblionumber, biblio.title, items.barcode, reserves.waitingdate, >- reserves.branchcode AS site, branches.branchname AS site_name, >+ borrowers.phone, borrowers.email, borrowers.branchcode, biblio.biblionumber, biblio.title, items.barcode, holds.waiting_date, >+ holds.pickup_library_id AS site, branches.branchname AS site_name, > TO_DAYS(NOW())-TO_DAYS(reserves.waitingdate) AS days_since_waiting >- FROM borrowers JOIN reserves USING (borrowernumber) >+ FROM borrowers JOIN holds ON (borrowers.borrowernumber=holds.patron_id) > JOIN items USING (itemnumber) > JOIN biblio ON (biblio.biblionumber = items.biblionumber) >- JOIN branches ON (reserves.branchcode = branches.branchcode) >+ JOIN branches ON (holds.pickup_library_id = branches.branchcode) > JOIN borrower_message_preferences USING (borrowernumber) > JOIN borrower_message_transport_preferences USING (borrower_message_preference_id) > JOIN message_attributes USING (message_attribute_id) >- WHERE ( reserves.found = 'W' ) >+ WHERE ( holds.status = 'waiting' ) > AND message_transport_type = 'itiva' > AND message_name = 'Hold_Filled' > $patron_branchcode_filter >diff --git a/reserve/request.pl b/reserve/request.pl >index a4563f34bb..87b83e3526 100755 >--- a/reserve/request.pl >+++ b/reserve/request.pl >@@ -347,9 +347,9 @@ foreach my $biblionumber (@biblionumbers) { > # the patron places must be item level > my $holds = Koha::Holds->search( > { >- borrowernumber => $patron->borrowernumber, >- biblionumber => $biblionumber, >- found => undef, >+ patron_id => $patron->borrowernumber, >+ biblio_id => $biblionumber, >+ status => 'placed', > } > ); > $force_hold_level = $holds->forced_hold_level(); >@@ -366,7 +366,12 @@ foreach my $biblionumber (@biblionumbers) { > } > > >- my $count = Koha::Holds->search( { biblionumber => $biblionumber } )->count(); >+ my $count = Koha::Holds->search( >+ { >+ biblio_id => $biblionumber, >+ completed => 0 >+ } >+ )->count(); > my $totalcount = $count; > > # FIXME think @optionloop, is maybe obsolete, or must be switchable by a systeme preference fixed rank or not >@@ -511,13 +516,13 @@ foreach my $biblionumber (@biblionumbers) { > my $item_object = Koha::Items->find( $itemnumber ); > my $holds = $item_object->current_holds; > if ( my $first_hold = $holds->next ) { >- my $p = Koha::Patrons->find( $first_hold->borrowernumber ); >+ my $p = Koha::Patrons->find( $first_hold->patron_id ); > > $item->{backgroundcolor} = 'reserved'; >- $item->{reservedate} = output_pref({ dt => dt_from_string( $first_hold->reservedate ), dateonly => 1 }); # FIXME Should be formatted in the template >+ $item->{reservedate} = output_pref({ dt => dt_from_string( $first_hold->created_date ), dateonly => 1 }); # FIXME Should be formatted in the template > $item->{ReservedFor} = $p; >- $item->{ExpectedAtLibrary} = $first_hold->branchcode; >- $item->{waitingdate} = $first_hold->waitingdate; >+ $item->{ExpectedAtLibrary} = $first_hold->pickup_library_id; >+ $item->{waitingdate} = $first_hold->waiting_date; > } > > # Management of the notforloan document >@@ -645,7 +650,13 @@ foreach my $biblionumber (@biblionumbers) { > > # existingreserves building > my @reserveloop; >- my @reserves = Koha::Holds->search( { biblionumber => $biblionumber }, { order_by => 'priority' } ); >+ my @reserves = Koha::Holds->search( >+ { >+ biblio_id => $biblionumber, >+ completed => 0 >+ }, >+ { order_by => 'priority' } >+ ); > foreach my $res ( > sort { > my $a_found = $a->found() || ''; >@@ -671,8 +682,8 @@ foreach my $biblionumber (@biblionumbers) { > $reserve{'holdingbranch'} = $res->item()->holdingbranch(); > $reserve{'biblionumber'} = $res->item()->biblionumber(); > $reserve{'barcodenumber'} = $res->item()->barcode(); >- $reserve{'wbrcode'} = $res->branchcode(); >- $reserve{'itemnumber'} = $res->itemnumber(); >+ $reserve{'wbrcode'} = $res->pickup_library_id; >+ $reserve{'itemnumber'} = $res->item_id; > $reserve{'wbrname'} = $res->branch()->branchname(); > $reserve{'atdestination'} = $res->is_at_destination(); > $reserve{'desk_name'} = ( $res->desk() ) ? $res->desk()->desk_name() : '' ; >@@ -688,24 +699,24 @@ foreach my $biblionumber (@biblionumbers) { > } > } > >- $reserve{'expirationdate'} = $res->expirationdate; >- $reserve{'date'} = $res->reservedate; >- $reserve{'borrowernumber'} = $res->borrowernumber(); >- $reserve{'biblionumber'} = $res->biblionumber(); >+ $reserve{'expirationdate'} = $res->expiration_date; >+ $reserve{'date'} = $res->created_date; >+ $reserve{'borrowernumber'} = $res->patron_id; >+ $reserve{'biblionumber'} = $res->biblio_id; > $reserve{'patron'} = $res->borrower; >- $reserve{'notes'} = $res->reservenotes(); >- $reserve{'waiting_date'} = $res->waitingdate(); >+ $reserve{'notes'} = $res->notes; >+ $reserve{'waiting_date'} = $res->waiting_date; > $reserve{'ccode'} = $res->item() ? $res->item()->ccode() : undef; > $reserve{'barcode'} = $res->item() ? $res->item()->barcode() : undef; >- $reserve{'priority'} = $res->priority(); >- $reserve{'lowestPriority'} = $res->lowestPriority(); >+ $reserve{'priority'} = $res->priority; >+ $reserve{'lowestPriority'} = $res->lowest_priority; > $reserve{'optionloop'} = \@optionloop; >- $reserve{'suspend'} = $res->suspend(); >- $reserve{'suspend_until'} = $res->suspend_until(); >- $reserve{'reserve_id'} = $res->reserve_id(); >- $reserve{itemtype} = $res->itemtype(); >- $reserve{branchcode} = $res->branchcode(); >- $reserve{non_priority} = $res->non_priority(); >+ $reserve{'suspend'} = $res->suspended; >+ $reserve{'suspend_until'} = $res->suspended_until_date; >+ $reserve{'reserve_id'} = $res->id; >+ $reserve{itemtype} = $res->item_type; >+ $reserve{branchcode} = $res->pickup_library_id; >+ $reserve{non_priority} = $res->non_priority; > $reserve{object} = $res; > > push( @reserveloop, \%reserve ); >diff --git a/t/Koha/Exceptions.t b/t/Koha/Exceptions.t >index 3ffb34b299..86985bf961 100755 >--- a/t/Koha/Exceptions.t >+++ b/t/Koha/Exceptions.t >@@ -28,12 +28,12 @@ subtest 'Koha::Exceptions::Hold tests' => sub { > use_ok('Koha::Exceptions::Hold'); > > throws_ok >- { Koha::Exceptions::Hold::CannotSuspendFound->throw( status => 'W' ); } >+ { Koha::Exceptions::Hold::CannotSuspendFound->throw( status => 'waiting' ); } > 'Koha::Exceptions::Hold::CannotSuspendFound', > 'Exception is thrown :-D'; > > # stringify the exception >- is( "$@", 'Found hold cannot be suspended. Status=W', 'Exception stringified correctly' ); >+ is( "$@", 'Found hold cannot be suspended. Status=waiting', 'Exception stringified correctly' ); > > throws_ok > { Koha::Exceptions::Hold::CannotSuspendFound->throw( "Manual message exception" ) } >diff --git a/t/Koha/REST/Plugin/Query.t b/t/Koha/REST/Plugin/Query.t >index c52914a7bf..88e8baa955 100755 >--- a/t/Koha/REST/Plugin/Query.t >+++ b/t/Koha/REST/Plugin/Query.t >@@ -108,7 +108,7 @@ get '/dbic_merge_sorting_date' => sub { > $attributes = $c->dbic_merge_sorting( > { > attributes => $attributes, >- params => { _match => 'exact', _order_by => [ '-hold_date' ] }, >+ params => { _match => 'exact', _order_by => [ '-created_date' ] }, > result_set => $result_set > } > ); >@@ -343,7 +343,7 @@ subtest 'dbic_merge_sorting() tests' => sub { > ->json_is( '/a' => 'a', 'Existing values are kept (a)' ) > ->json_is( '/b' => 'b', 'Existing values are kept (b)' )->json_is( > '/order_by' => [ >- { -desc => 'reservedate' } >+ { -desc => 'created_date' } > ] > ); > >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 8aa5d4c970..b690dafefa 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -507,7 +507,7 @@ subtest "CanBookBeRenewed tests" => sub { > my $expdate = undef; > my $notes = ''; > my $checkitem = undef; >- my $found = undef; >+ my $found = 'placed'; > > my $issue = AddIssue( $renewing_borrower, $item_1->barcode); > my $datedue = dt_from_string( $issue->date_due() ); >@@ -535,8 +535,7 @@ subtest "CanBookBeRenewed tests" => sub { > reservation_date => $resdate, > expiration_date => $expdate, > notes => $notes, >- itemnumber => $checkitem, >- found => $found, >+ itemnumber => $checkitem > } > ); > >@@ -566,31 +565,31 @@ subtest "CanBookBeRenewed tests" => sub { > is( $renewokay, 1, 'Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds'); > > # Now let's add an item level hold, we should no longer be able to renew the item >- my $hold = Koha::Database->new()->schema()->resultset('Reserve')->create( >+ my $hold = Koha::Hold->new( > { >- borrowernumber => $hold_waiting_borrowernumber, >- biblionumber => $biblio->biblionumber, >- itemnumber => $item_1->itemnumber, >- branchcode => $branch, >- priority => 3, >+ patron_id => $hold_waiting_borrowernumber, >+ biblio_id => $biblio->biblionumber, >+ item_id => $item_1->itemnumber, >+ pickup_library_id => $branch, >+ priority => 3, > } >- ); >+ )->store; > ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber); > is( $renewokay, 0, 'Bug 13919 - Renewal possible with item level hold on item'); > $hold->delete(); > > # Now let's add a waiting hold on the 3rd item, it's no longer available tp check out by just anyone, so we should no longer > # be able to renew these items >- $hold = Koha::Database->new()->schema()->resultset('Reserve')->create( >+ $hold = Koha::Hold->new( > { >- borrowernumber => $hold_waiting_borrowernumber, >- biblionumber => $biblio->biblionumber, >- itemnumber => $item_3->itemnumber, >- branchcode => $branch, >+ patron_id => $hold_waiting_borrowernumber, >+ biblio_id => $biblio->biblionumber, >+ item_id => $item_3->itemnumber, >+ pickup_library_id => $branch, > priority => 0, >- found => 'W' >+ status => 'waiting' > } >- ); >+ )->store; > ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber); > is( $renewokay, 0, 'Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds'); > ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_2->itemnumber); >@@ -605,15 +604,15 @@ subtest "CanBookBeRenewed tests" => sub { > is( $renewokay, 0, '(Bug 10663) Cannot renew, reserved'); > is( $error, 'on_reserve', '(Bug 10663) Cannot renew, reserved (returned error is on_reserve)'); > >- my $reserveid = Koha::Holds->search({ biblionumber => $biblio->biblionumber, borrowernumber => $reserving_borrowernumber })->next->reserve_id; >+ my $reserveid = Koha::Holds->search({ biblio_id => $biblio->biblionumber, patron_id => $reserving_borrowernumber })->next->id; > my $reserving_borrower = Koha::Patrons->find( $reserving_borrowernumber )->unblessed; > AddIssue($reserving_borrower, $item_3->barcode); > my $reserve = $dbh->selectrow_hashref( >- 'SELECT * FROM old_reserves WHERE reserve_id = ?', >+ 'SELECT * FROM holds WHERE id = ? AND completed = 1', > { Slice => {} }, > $reserveid > ); >- is($reserve->{found}, 'F', 'hold marked completed when checking out item that fills it'); >+ is($reserve->{status}, 'fulfilled', 'hold marked completed when checking out item that fills it'); > > # Item-level hold, renewal test > AddReserve( >@@ -775,7 +774,7 @@ subtest "CanBookBeRenewed tests" => sub { > $fines = Koha::Account::Lines->search( { borrowernumber => $renewing_borrower->{borrowernumber}, itemnumber => $item_7->itemnumber } ); > $fines->delete(); > >- $hold = Koha::Holds->search({ biblionumber => $biblio->biblionumber, borrowernumber => $reserving_borrowernumber })->next; >+ $hold = Koha::Holds->search({ biblio_id => $biblio->biblionumber, patron_id => $reserving_borrowernumber })->next; > $hold->cancel; > > # Bug 14101 >@@ -3450,7 +3449,7 @@ subtest 'Set waiting flag' => sub { > my ( $res, $rr ) = AddReturn( $item->barcode, $library_1->{branchcode} ); > ModReserveAffect( $item->itemnumber, undef, $do_transfer, $reserve_id ); > my $hold = Koha::Holds->find( $reserve_id ); >- is( $hold->found, 'T', 'Hold is in transit' ); >+ is( $hold->status, 'in_transit', 'Hold is in transit' ); > > my ( $status ) = CheckReserves($item->itemnumber); > is( $status, 'Transferred', 'Hold is not waiting yet'); >@@ -3460,7 +3459,7 @@ subtest 'Set waiting flag' => sub { > AddReturn( $item->barcode, $library_2->{branchcode} ); > ModReserveAffect( $item->itemnumber, undef, $do_transfer, $reserve_id ); > $hold = Koha::Holds->find( $reserve_id ); >- is( $hold->found, 'W', 'Hold is waiting' ); >+ is( $hold->status, 'waiting', 'Hold is waiting' ); > ( $status ) = CheckReserves($item->itemnumber); > is( $status, 'Waiting', 'Now the hold is waiting'); > >@@ -3468,12 +3467,12 @@ subtest 'Set waiting flag' => sub { > set_userenv( $library_1 ); > (undef, my $messages, undef, undef ) = AddReturn ( $item->barcode, $library_1->{branchcode} ); > $hold = Koha::Holds->find( $reserve_id ); >- is( $hold->found, undef, 'Hold is no longer marked waiting' ); >+ is( $hold->status, 'placed', 'Hold is no longer marked waiting' ); > is( $hold->priority, 1, "Hold is now priority one again"); >- is( $hold->waitingdate, undef, "Hold no longer has a waiting date"); >- is( $hold->itemnumber, $item->itemnumber, "Hold has retained its' itemnumber"); >+ is( $hold->waiting_date, undef, "Hold no longer has a waiting date"); >+ is( $hold->item_id, $item->itemnumber, "Hold has retained its' itemnumber"); > is( $messages->{ResFound}->{ResFound}, "Reserved", "Hold is still returned"); >- is( $messages->{ResFound}->{found}, undef, "Hold is no longer marked found in return message"); >+ is( $messages->{ResFound}->{status}, 'placed', "Hold is no longer marked found in return message"); > is( $messages->{ResFound}->{priority}, 1, "Hold is priority 1 in return message"); > }; > >@@ -4331,13 +4330,13 @@ subtest 'Filling a hold should cancel existing transfer' => sub { > biblionumber => $item->biblionumber, > itemnumber => $item->itemnumber > }); >- my $reserves = Koha::Holds->search({ itemnumber => $item->itemnumber }); >+ my $reserves = Koha::Holds->search({ item_id => $item->itemnumber }); > is( $reserves->count, 1, "Reserve is placed"); > ( undef, $message ) = AddReturn( $item->barcode, $libraryA->branchcode, undef, undef ); > my $reserve = $reserves->next; >- ModReserveAffect( $item->itemnumber, $patron->borrowernumber, 0, $reserve->reserve_id ); >+ ModReserveAffect( $item->itemnumber, $patron->borrowernumber, 0, $reserve->id ); > $reserve->discard_changes; >- ok( $reserve->found eq 'W', "Reserve is marked waiting" ); >+ ok( $reserve->status eq 'waiting', "Reserve is marked waiting" ); > is( Koha::Item::Transfers->search({ itemnumber => $item->itemnumber, datearrived => undef })->count, 0, "No outstanding transfers when hold is waiting"); > }; > >@@ -4794,7 +4793,7 @@ subtest 'Checkout should correctly terminate a transfer' => sub { > GetOtherReserves( $item->itemnumber ) > ; # To put the Reason, it's what does returns.pl... > my $hold = Koha::Holds->find($reserve_id); >- is( $hold->found, 'T', 'Hold is in transit' ); >+ is( $hold->status, 'in_transit', 'Hold is in transit' ); > my $transfer = $item->get_transfer; > is( $transfer->frombranch, $library_1->branchcode ); > is( $transfer->tobranch, $library_2->branchcode ); >@@ -4805,7 +4804,7 @@ subtest 'Checkout should correctly terminate a transfer' => sub { > $transfer = $transfer->get_from_storage; > isnt( $transfer->datearrived, undef ); > $hold = $hold->get_from_storage; >- is( $hold->found, undef, 'Hold is waiting' ); >+ is( $hold->status, 'placed', 'Hold is waiting' ); > is( $hold->priority, 1, ); > }; > >diff --git a/t/db_dependent/Circulation/issue.t b/t/db_dependent/Circulation/issue.t >index d4fb82b55b..6293110226 100755 >--- a/t/db_dependent/Circulation/issue.t >+++ b/t/db_dependent/Circulation/issue.t >@@ -68,8 +68,7 @@ $dbh->do(q|DELETE FROM borrowers|); > $dbh->do(q|DELETE FROM categories|); > $dbh->do(q|DELETE FROM accountlines|); > $dbh->do(q|DELETE FROM circulation_rules|); >-$dbh->do(q|DELETE FROM reserves|); >-$dbh->do(q|DELETE FROM old_reserves|); >+$dbh->do(q|DELETE FROM holds|); > $dbh->do(q|DELETE FROM statistics|); > > # Generate sample datas >@@ -484,7 +483,7 @@ my $reserve_id = AddReserve( > ok( $reserve_id, 'The reserve should have been inserted' ); > AddIssue( $borrower_2, $barcode_1, dt_from_string, 'cancel' ); > my $hold = Koha::Holds->find( $reserve_id ); >-is( $hold, undef, 'The reserve should have been correctly cancelled' ); >+is( $hold->status, 'cancelled', 'The reserve should have been correctly cancelled' ); > > # Unseen rewnewals > t::lib::Mocks::mock_preference('UnseenRenewals', 1); >diff --git a/t/db_dependent/DecreaseLoanHighHolds.t b/t/db_dependent/DecreaseLoanHighHolds.t >index 8bb0fdce6e..39e0b0ab30 100755 >--- a/t/db_dependent/DecreaseLoanHighHolds.t >+++ b/t/db_dependent/DecreaseLoanHighHolds.t >@@ -88,16 +88,16 @@ for my $i ( 0 .. 5 ) { > my $patron = $patrons[$i]; > my $hold = Koha::Hold->new( > { >- borrowernumber => $patron->id, >- biblionumber => $biblio->id, >- branchcode => $library->{branchcode}, >+ patron_id => $patron->id, >+ biblio_id => $biblio->id, >+ pickup_library_id => $library->{branchcode}, > } > )->store(); > } > > my $item = shift(@items); > my $patron = shift(@patrons); >-my $patron_hold = Koha::Holds->find({ borrowernumber => $patron->borrowernumber, biblionumber => $item->biblionumber }); >+my $patron_hold = Koha::Holds->find({ patron_id => $patron->borrowernumber, biblio_id => $item->biblionumber }); > > Koha::CirculationRules->set_rules( > { >@@ -169,9 +169,9 @@ for my $i ( 5 .. 10 ) { > my $patron = $patrons[$i]; > my $hold = Koha::Hold->new( > { >- borrowernumber => $patron->id, >- biblionumber => $biblio->id, >- branchcode => $library->{branchcode}, >+ patron_id => $patron->id, >+ biblio_id => $biblio->id, >+ pickup_library_id => $library->{branchcode}, > } > )->store(); > } >@@ -218,11 +218,11 @@ $unholdable->store(); > $data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr ); > is( $data->{exceeded}, 1, "Should exceed threshold with one withdrawn item" ); > >-$patron_hold->found('F')->store; >+$patron_hold->set_waiting(); > # 11 holds, threshold is 2 over 9 holdable items = 11 > $data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr ); > is( $data->{exceeded}, 1, "Should exceed threshold with one withdrawn item" ); >-$patron_hold->found(undef)->store; >+$patron_hold->status('placed')->store; > > t::lib::Mocks::mock_preference('CircControl', 'PatronLibrary'); > >diff --git a/t/db_dependent/Hold.t b/t/db_dependent/Hold.t >index fb983caca5..cee2a3c372 100755 >--- a/t/db_dependent/Hold.t >+++ b/t/db_dependent/Hold.t >@@ -66,13 +66,14 @@ $item->store(); > > my $hold = Koha::Hold->new( > { >- biblionumber => $biblionumber, >- itemnumber => $item->id(), >- reservedate => '2017-01-01', >- waitingdate => '2000-01-01', >- borrowernumber => $borrower->{borrowernumber}, >- branchcode => $branches[1]->{branchcode}, >- suspend => 0, >+ biblio_id => $biblionumber, >+ item_id => $item->id(), >+ created_date => '2017-01-01', >+ waiting_date => '2000-01-01', >+ patron_id => $borrower->{borrowernumber}, >+ pickup_library_id => $branches[1]->{branchcode}, >+ suspended => 0, >+ status => 'placed' > } > ); > $hold->store(); >@@ -83,22 +84,22 @@ my $today = dt_from_string; > is( $hold->age(), $today->delta_days( dt_from_string( '2017-01-01' ) )->in_units( 'days') , "Age of hold is days from reservedate to now if calendar ignored"); > is( $hold->age(1), $today->delta_days( dt_from_string( '2017-01-01' ) )->in_units( 'days' ) - 1 , "Age of hold is days from reservedate to now minus 1 if calendar used"); > >-is( $hold->suspend, 0, "Hold is not suspended" ); >+is( $hold->suspended, 0, "Hold is not suspended" ); > $hold->suspend_hold(); >-is( $hold->suspend, 1, "Hold is suspended" ); >+is( $hold->suspended, 1, "Hold is suspended" ); > $hold->resume(); >-is( $hold->suspend, 0, "Hold is not suspended" ); >+is( $hold->suspended, 0, "Hold is not suspended" ); > my $dt = dt_from_string(); > $hold->suspend_hold( $dt ); > $dt->truncate( to => 'day' ); >-is( $hold->suspend, 1, "Hold is suspended" ); >-is( $hold->suspend_until, "$dt", "Hold is suspended with a date, truncation takes place automatically" ); >+is( $hold->suspended, 1, "Hold is suspended" ); >+is( $hold->suspended_until_date, "$dt", "Hold is suspended with a date, truncation takes place automatically" ); > $hold->suspend_hold; >-is( $hold->suspend, 1, "Hold is suspended" ); >-is( $hold->suspend_until, undef, "Hold is suspended without a date" ); >+is( $hold->suspended, 1, "Hold is suspended" ); >+is( $hold->suspended_until_date, undef, "Hold is suspended without a date" ); > $hold->resume(); >-is( $hold->suspend, 0, "Hold is not suspended" ); >-is( $hold->suspend_until, undef, "Hold no longer has suspend_until date" ); >+is( $hold->suspended, 0, "Hold is not suspended" ); >+is( $hold->suspended_until_date, undef, "Hold no longer has suspend_until date" ); > > $item = $hold->item(); > >@@ -107,37 +108,37 @@ ok( $hold_borrower, 'Got hold borrower' ); > is( $hold_borrower->borrowernumber(), $borrower->{borrowernumber}, 'Hold borrower matches correct borrower' ); > > t::lib::Mocks::mock_preference( 'ReservesMaxPickUpDelay', '5' ); >-$hold->found('T'); >+$hold->status('in_transit'); > isnt( $hold->is_waiting, 1, 'The hold is not waiting (T)' ); > is( $hold->is_found, 1, 'The hold is found'); > is( $hold->is_in_transit, 1, 'The hold is in transit' ); > >-$hold->found('P'); >+$hold->status('processing'); > is( $hold->is_found, 1, 'The hold is found'); > is( $hold->is_in_processing, 1, 'The hold is in processing' ); > >-$hold->found(q{}); >+$hold->status('placed'); > isnt( $hold->is_waiting, 1, 'The hold is not waiting (W)' ); > is( $hold->is_found, 0, 'The hold is not found' ); > ok( !$hold->is_in_transit, 'The hold is not in transit' ); > ok( !$hold->is_in_processing, 'The hold is not in processing' ); > > # Test method is_cancelable_from_opac >-$hold->found(undef); >+$hold->status('placed'); > is( $hold->is_cancelable_from_opac, 1, "Unfound hold is cancelable" ); >-$hold->found('W'); >+$hold->status('waiting'); > is( $hold->is_cancelable_from_opac, 0, "Waiting hold is not cancelable" ); >-$hold->found('T'); >+$hold->status('in_transit'); > is( $hold->is_cancelable_from_opac, 0, "In transit hold is not cancelable" ); >-$hold->found('P'); >+$hold->status('processing'); > is( $hold->is_cancelable_from_opac, 0, "In processing hold is not cancelable" ); > > # Test method is_at_destination >-$hold->found(undef); >+$hold->status('placed'); > ok( !$hold->is_at_destination(), "Unfound hold cannot be at destination" ); >-$hold->found('T'); >+$hold->status('in_transit'); > ok( !$hold->is_at_destination(), "In transit hold cannot be at destination" ); >-$hold->found('W'); >+$hold->status('waiting'); > ok( !$hold->is_at_destination(), "Waiting hold where hold branchcode is not the same as the item's holdingbranch is not at destination" ); > $item->holdingbranch( $branches[1]->{branchcode} ); > ok( $hold->is_at_destination(), "Waiting hold where hold branchcode is the same as the item's holdingbranch is at destination" ); >@@ -162,64 +163,62 @@ subtest "store() tests" => sub { > 'years' ); > > my $hold = Koha::Hold->new( >- { >- biblionumber => $biblio->biblionumber, >- itemnumber => $item->id, >- reservedate => '2020-11-30', >- waitingdate => '2020-11-30', >- borrowernumber => $borrower->borrowernumber, >- branchcode => $library->branchcode, >- suspend => 0, >+ { biblio_id => $biblio->biblionumber, >+ item_id => $item->id, >+ created_date => '2020-11-30', >+ waiting_date => '2020-11-30', >+ patron_id => $borrower->borrowernumber, >+ pickup_library_id => $library->branchcode, >+ suspended => 0, > } > )->store; > $hold->discard_changes; > > my $expected_date = >- dt_from_string( $hold->reservedate )->add( years => 2 ); >- is( $hold->expirationdate, >+ dt_from_string( $hold->created_date )->add( years => 2 ); >+ is( $hold->expiration_date, > $expected_date->ymd, 'Default expiration date for new hold is correctly set.' ); > > my $passed_date = >- dt_from_string( $hold->reservedate )->add( months => 2 ); >+ dt_from_string( $hold->created_date )->add( months => 2 ); > $hold = Koha::Hold->new( >- { >- biblionumber => $biblio->biblionumber, >- itemnumber => $item->id, >- reservedate => '2020-11-30', >- expirationdate => $passed_date->ymd, >- waitingdate => '2020-11-30', >- borrowernumber => $borrower->borrowernumber, >- branchcode => $library->branchcode, >- suspend => 0, >+ { biblio_id => $biblio->biblionumber, >+ item_id => $item->id, >+ created_date => '2020-11-30', >+ expiration_date => $passed_date->ymd, >+ waiting_date => '2020-11-30', >+ patron_id => $borrower->borrowernumber, >+ pickup_library_id => $library->branchcode, >+ suspended => 0, > } > )->store; > $hold->discard_changes; > >- is( $hold->expirationdate, >+ is( $hold->expiration_date, > $passed_date->ymd, 'Passed expiration date for new hold is correctly set.' ); > > $passed_date->add( months => 1 ); >- $hold->expirationdate($passed_date->ymd)->store(); >+ $hold->expiration_date($passed_date->ymd)->store(); > $hold->discard_changes; > >- is( $hold->expirationdate, >+ is( $hold->expiration_date, > $passed_date->ymd, 'Passed expiration date when updating hold is correctly set.' ); > >- $hold->reservedate($passed_date->ymd)->store(); >+ $hold->created_date($passed_date->ymd)->store(); > $hold->discard_changes; > >- is( $hold->expirationdate, >+ is( $hold->expiration_date, > $passed_date->add( years => 2 )->ymd, 'Default expiration date correctly set on reservedate update.' ); > > $hold->set( > { >- reservedate => $passed_date->ymd, >- expirationdate => $passed_date->add( weeks => 2 )->ymd >+ created_date => $passed_date->ymd, >+ expiration_date => $passed_date->add( weeks => 2 )->ymd > } > )->store(); > $hold->discard_changes; > >- is( $hold->expirationdate, >+ is( $hold->expiration_date, > $passed_date->ymd, 'Passed expiration date when updating hold correctly set (Passing both reservedate and expirationdate.' ); > > $schema->storage->txn_rollback(); >@@ -234,31 +233,31 @@ subtest "delete() tests" => sub { > # Disable logging > t::lib::Mocks::mock_preference( 'HoldsLog', 0 ); > >- my $hold = $builder->build({ source => 'Reserve' }); >+ my $hold = $builder->build_object({ class => 'Koha::Holds' }); >+ my $hold_id = $hold->id; >+ my $deleted = $hold->delete; > >- my $hold_object = Koha::Holds->find( $hold->{ reserve_id } ); >- my $deleted = $hold_object->delete; > is( ref($deleted), 'Koha::Hold', 'Koha::Hold->delete should return the Koha::Hold object if the hold has been correctly deleted' ); >- is( Koha::Holds->search({ reserve_id => $hold->{ reserve_id } })->count, 0, >+ is( Koha::Holds->search({ id => $hold_id })->count, 0, > "Koha::Hold->delete should have deleted the hold" ); > > my $number_of_logs = $schema->resultset('ActionLog')->search( >- { module => 'HOLDS', action => 'DELETE', object => $hold->{ reserve_id } } )->count; >+ { module => 'HOLDS', action => 'DELETE', object => $hold_id } )->count; > is( $number_of_logs, 0, 'With HoldsLogs, Koha::Hold->delete shouldn\'t have been logged' ); > > # Enable logging > t::lib::Mocks::mock_preference( 'HoldsLog', 1 ); > >- $hold = $builder->build({ source => 'Reserve' }); >+ $hold = $builder->build_object({ class => 'Koha::Holds' }); >+ $hold_id = $hold->id; >+ $deleted = $hold->delete; > >- $hold_object = Koha::Holds->find( $hold->{ reserve_id } ); >- $deleted = $hold_object->delete; > is( ref($deleted), 'Koha::Hold', 'Koha::Hold->delete should return a Koha::Hold object if the hold has been correctly deleted' ); >- is( Koha::Holds->search({ reserve_id => $hold->{ reserve_id } })->count, 0, >+ is( Koha::Holds->search({ id => $hold_id })->count, 0, > "Koha::Hold->delete should have deleted the hold" ); > > $number_of_logs = $schema->resultset('ActionLog')->search( >- { module => 'HOLDS', action => 'DELETE', object => $hold->{ reserve_id } } )->count; >+ { module => 'HOLDS', action => 'DELETE', object => $hold_id } )->count; > is( $number_of_logs, 1, 'With HoldsLogs, Koha::Hold->delete should have been logged' ); > > $schema->storage->txn_rollback(); >@@ -274,8 +273,14 @@ subtest 'suspend() tests' => sub { > t::lib::Mocks::mock_preference( 'HoldsLog', 0 ); > > my $hold = $builder->build_object( >- { class => 'Koha::Holds', >- value => { found => undef, suspend => 0, suspend_until => undef, waitingdate => undef } >+ { >+ class => 'Koha::Holds', >+ value => { >+ status => 'placed', >+ suspended => 0, >+ suspended_until_date => undef, >+ waiting_date => undef >+ } > } > ); > >@@ -284,7 +289,7 @@ subtest 'suspend() tests' => sub { > is( ref($suspended) , 'Koha::Hold', 'suspend returns the Koha::Hold object' ); > is( $suspended->id, $hold->id, 'suspend returns the same object' ); > ok( $suspended->is_suspended, 'The hold is suspended' ); >- is( $suspended->suspend_until, undef, 'It is an indefinite suspension' ); >+ is( $suspended->suspended_until_date, undef, 'It is an indefinite suspension' ); > > # resume the hold > $suspended->resume; >@@ -296,7 +301,7 @@ subtest 'suspend() tests' => sub { > is( ref($suspended) , 'Koha::Hold', 'suspend returns the Koha::Hold object' ); > is( $suspended->id, $hold->id, 'suspend returns the same object' ); > ok( $suspended->is_suspended, 'The hold is suspended' ); >- is( $suspended->suspend_until, $date->truncate( to => 'day' ), 'It is an indefinite suspension' ); >+ is( $suspended->suspended_until_date, $date->truncate( to => 'day' ), 'It is an indefinite suspension' ); > > # resume the hold > $suspended->resume; >@@ -309,7 +314,7 @@ subtest 'suspend() tests' => sub { > 'Koha::Exceptions::Hold::CannotSuspendFound', > 'Exception is thrown when a found hold is tried to suspend'; > >- is( $@->status, 'W', 'Exception gets the \'status\' parameter set correctly' ); >+ is( $@->status, 'waiting', 'Exception gets the \'status\' parameter set correctly' ); > > # set hold found=T > $hold->set_transfer; >@@ -318,7 +323,7 @@ subtest 'suspend() tests' => sub { > 'Koha::Exceptions::Hold::CannotSuspendFound', > 'Exception is thrown when a found hold is tried to suspend'; > >- is( $@->status, 'T', 'Exception gets the \'status\' parameter set correctly' ); >+ is( $@->status, 'in_transit', 'Exception gets the \'status\' parameter set correctly' ); > > # set hold found=T > $hold->set_processing(); >@@ -333,7 +338,7 @@ subtest 'suspend() tests' => sub { > $holds_module->mock( 'is_found', 1 ); > > # bad data case >- $hold->found('X'); >+ $hold->status('cancelled'); > throws_ok > { $hold->suspend_hold } > 'Koha::Exceptions::Hold::CannotSuspendFound', >@@ -341,8 +346,8 @@ subtest 'suspend() tests' => sub { > > is( $@->error, 'Unhandled data exception on found hold (id=' > . $hold->id >- . ', found=' >- . $hold->found >+ . ', status=' >+ . $hold->status > . ')' , 'Exception gets the \'status\' parameter set correctly' ); > > $holds_module->unmock( 'is_found' ); >@@ -354,8 +359,14 @@ subtest 'suspend() tests' => sub { > { module => 'HOLDS', action => 'SUSPEND', object => $hold->id } )->count; > > $hold = $builder->build_object( >- { class => 'Koha::Holds', >- value => { suspend => 0, suspend_until => undef, waitingdate => undef, found => undef } >+ { >+ class => 'Koha::Holds', >+ value => { >+ suspended => 0, >+ suspended_until_date => undef, >+ waiting_date => undef, >+ status => 'placed' >+ } > } > ); > >diff --git a/t/db_dependent/Holds.t b/t/db_dependent/Holds.t >index 0710eda149..df76cf97f5 100755 >--- a/t/db_dependent/Holds.t >+++ b/t/db_dependent/Holds.t >@@ -48,7 +48,7 @@ my $category = $builder->build({ source => 'Category' }); > my $borrowers_count = 5; > > $dbh->do('DELETE FROM itemtypes'); >-$dbh->do('DELETE FROM reserves'); >+$dbh->do('DELETE FROM holds'); > $dbh->do('DELETE FROM circulation_rules'); > my $insert_sth = $dbh->prepare('INSERT INTO itemtypes (itemtype) VALUES (?)'); > $insert_sth->execute('CAN'); >@@ -98,10 +98,10 @@ is( $holds->next->priority, 5, "Reserve 5 has a priority of 5" ); > my $item = Koha::Items->find( $itemnumber ); > $holds = $item->current_holds; > my $first_hold = $holds->next; >-my $reservedate = $first_hold->reservedate; >-my $borrowernumber = $first_hold->borrowernumber; >-my $branch_1code = $first_hold->branchcode; >-my $reserve_id = $first_hold->reserve_id; >+my $reservedate = $first_hold->created_date; >+my $borrowernumber = $first_hold->patron_id; >+my $branch_1code = $first_hold->pickup_library_id; >+my $reserve_id = $first_hold->id; > is( $reservedate, output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), "holds_placed_today should return a valid reserve date"); > is( $borrowernumber, $borrowernumbers[0], "holds_placed_today should return a valid borrowernumber"); > is( $branch_1code, $branch_1, "holds_placed_today should return a valid branchcode"); >@@ -118,21 +118,21 @@ ok( $hold_item == $hold->item(), "item method returns stashed item" ); > my $hold_branch = $hold->branch(); > ok( $hold_branch, "Got branch using branch() method" ); > ok( $hold_branch == $hold->branch(), "branch method returns stashed branch" ); >-my $hold_found = $hold->found(); >-$hold->set({ found => 'W'})->store(); >+my $hold_found = $hold->status(); >+$hold->set({ status => 'waiting' })->store(); > is( Koha::Holds->waiting()->count(), 1, "Koha::Holds->waiting returns waiting holds" ); > is( Koha::Holds->unfilled()->count(), 4, "Koha::Holds->unfilled returns unfilled holds" ); > > my $patron = Koha::Patrons->find( $borrowernumbers[0] ); > $holds = $patron->holds; >-is( $holds->next->borrowernumber, $borrowernumbers[0], "Test Koha::Patron->holds"); >+is( $holds->next->patron_id, $borrowernumbers[0], "Test Koha::Patron->holds"); > > > $holds = $item->current_holds; > $first_hold = $holds->next; >-$borrowernumber = $first_hold->borrowernumber; >-$branch_1code = $first_hold->branchcode; >-$reserve_id = $first_hold->reserve_id; >+$borrowernumber = $first_hold->patron_id; >+$branch_1code = $first_hold->pickup_library_id; >+$reserve_id = $first_hold->id; > > ModReserve({ > reserve_id => $reserve_id, >@@ -144,8 +144,8 @@ ModReserve({ > > $hold = Koha::Holds->find( $reserve_id ); > ok( $hold->priority eq '4', "Test ModReserve, priority changed correctly" ); >-ok( $hold->suspend, "Test ModReserve, suspend hold" ); >-is( $hold->suspend_until, '2013-01-01 00:00:00', "Test ModReserve, suspend until date" ); >+ok( $hold->suspended, "Test ModReserve, suspend hold" ); >+is( $hold->suspended_until_date, '2013-01-01 00:00:00', "Test ModReserve, suspend until date" ); > > ModReserve({ # call without reserve_id > rank => '3', >@@ -158,15 +158,15 @@ ok( $hold->priority eq '3', "Test ModReserve, priority changed correctly" ); > > ToggleSuspend( $reserve_id ); > $hold = Koha::Holds->find( $reserve_id ); >-ok( ! $hold->suspend, "Test ToggleSuspend(), no date" ); >+ok( ! $hold->suspended, "Test ToggleSuspend(), no date" ); > > ToggleSuspend( $reserve_id, '2012-01-01' ); > $hold = Koha::Holds->find( $reserve_id ); >-is( $hold->suspend_until, '2012-01-01 00:00:00', "Test ToggleSuspend(), with date" ); >+is( $hold->suspended_until_date, '2012-01-01 00:00:00', "Test ToggleSuspend(), with date" ); > > AutoUnsuspendReserves(); > $hold = Koha::Holds->find( $reserve_id ); >-ok( ! $hold->suspend, "Test AutoUnsuspendReserves()" ); >+ok( ! $hold->suspended, "Test AutoUnsuspendReserves()" ); > > SuspendAll( > borrowernumber => $borrowernumber, >@@ -175,8 +175,8 @@ SuspendAll( > suspend_until => '2012-01-01', > ); > $hold = Koha::Holds->find( $reserve_id ); >-is( $hold->suspend, 1, "Test SuspendAll()" ); >-is( $hold->suspend_until, '2012-01-01 00:00:00', "Test SuspendAll(), with date" ); >+is( $hold->suspended, 1, "Test SuspendAll()" ); >+is( $hold->suspended_until_date, '2012-01-01 00:00:00', "Test SuspendAll(), with date" ); > > SuspendAll( > borrowernumber => $borrowernumber, >@@ -184,8 +184,8 @@ SuspendAll( > suspend => 0, > ); > $hold = Koha::Holds->find( $reserve_id ); >-is( $hold->suspend, 0, "Test resuming with SuspendAll()" ); >-is( $hold->suspend_until, undef, "Test resuming with SuspendAll(), should have no suspend until date" ); >+is( $hold->suspended, 0, "Test resuming with SuspendAll()" ); >+is( $hold->suspended_until_date, undef, "Test resuming with SuspendAll(), should have no suspend until date" ); > > # Add a new hold for the borrower whose hold we canceled earlier, this time at the bib level > AddReserve( >@@ -198,26 +198,26 @@ is( $hold->suspend_until, undef, "Test resuming with SuspendAll(), should have n > > $patron = Koha::Patrons->find( $borrowernumber ); > $holds = $patron->holds; >-my $reserveid = Koha::Holds->search({ biblionumber => $biblio->biblionumber, borrowernumber => $borrowernumbers[0] })->next->reserve_id; >+my $reserveid = Koha::Holds->search({ biblio_id => $biblio->biblionumber, patron_id => $borrowernumbers[0] })->next->id; > ModReserveMinusPriority( $itemnumber, $reserveid ); > $holds = $patron->holds; >-is( $holds->search({ itemnumber => $itemnumber })->count, 1, "Test ModReserveMinusPriority()" ); >+is( $holds->search({ item_id => $itemnumber })->count, 1, "Test ModReserveMinusPriority()" ); > > $holds = $biblio->holds; > $hold = $holds->next; >-AlterPriority( 'top', $hold->reserve_id, undef, 2, 1, 6 ); >+AlterPriority( 'top', $hold->id, undef, 2, 1, 6 ); > $hold = Koha::Holds->find( $reserveid ); > is( $hold->priority, '1', "Test AlterPriority(), move to top" ); > >-AlterPriority( 'down', $hold->reserve_id, undef, 2, 1, 6 ); >+AlterPriority( 'down', $hold->id, undef, 2, 1, 6 ); > $hold = Koha::Holds->find( $reserveid ); > is( $hold->priority, '2', "Test AlterPriority(), move down" ); > >-AlterPriority( 'up', $hold->reserve_id, 1, 3, 1, 6 ); >+AlterPriority( 'up', $hold->id, 1, 3, 1, 6 ); > $hold = Koha::Holds->find( $reserveid ); > is( $hold->priority, '1', "Test AlterPriority(), move up" ); > >-AlterPriority( 'bottom', $hold->reserve_id, undef, 2, 1, 6 ); >+AlterPriority( 'bottom', $hold->id, undef, 2, 1, 6 ); > $hold = Koha::Holds->find( $reserveid ); > is( $hold->priority, '6', "Test AlterPriority(), move to bottom" ); > >@@ -317,7 +317,7 @@ ok( > } > ); > >- my $hhh = Koha::Holds->search({ biblionumber => $biblio->biblionumber }); >+ my $hhh = Koha::Holds->search({ biblio_id => $biblio->biblionumber }); > my $hold3 = Koha::Holds->find( $reserveid3 ); > is( $hold3->priority, 3, "The 3rd hold should have a priority set to 3" ); > ModReserve({ reserve_id => $reserveid1, rank => 'del' }); >@@ -332,9 +332,9 @@ ok( defined( ( CheckReserves($itemnumber) )[1] ), "Hold can be trapped for damag > > $hold = Koha::Hold->new( > { >- borrowernumber => $borrowernumbers[0], >- itemnumber => $itemnumber, >- biblionumber => $biblio->biblionumber, >+ patron_id => $borrowernumbers[0], >+ item_id => $itemnumber, >+ biblio_id => $biblio->biblionumber, > } > )->store(); > is( CanItemBeReserved( $borrowernumbers[0], $itemnumber )->{status}, >@@ -349,17 +349,17 @@ ok( !defined( ( CheckReserves($itemnumber) )[1] ), "Hold cannot be trapped for d > # Items that are not for loan, but holdable should not be trapped until they are available for loan > t::lib::Mocks::mock_preference( 'TrapHoldsOnOrder', 0 ); > Koha::Items->find($itemnumber)->damaged(0)->notforloan(-1)->store; >-Koha::Holds->search({ biblionumber => $biblio->id })->delete(); >+Koha::Holds->search({ biblio_id => $biblio->id })->delete(); > is( CanItemBeReserved( $borrowernumbers[0], $itemnumber)->{status}, 'OK', "Patron can place hold on item that is not for loan but holdable ( notforloan < 0 )" ); > $hold = Koha::Hold->new( > { >- borrowernumber => $borrowernumbers[0], >- itemnumber => $itemnumber, >- biblionumber => $biblio->biblionumber, >- found => undef, >- priority => 1, >- reservedate => dt_from_string, >- branchcode => $branch_1, >+ patron_id => $borrowernumbers[0], >+ item_id => $itemnumber, >+ biblio_id => $biblio->biblionumber, >+ priority => 1, >+ pickup_library_id => $branch_1, >+ completed => 0, >+ created_date => \'NOW()', > } > )->store(); > ok( !defined( ( CheckReserves($itemnumber) )[1] ), "Hold cannot be trapped for item that is not for loan but holdable ( notforloan < 0 )" ); >@@ -474,7 +474,7 @@ subtest 'CanItemBeReserved' => sub { > my $itemnumber_2_cannot = $builder->build_sample_item({ homebranch => $branch_1, holdingbranch => $branch_1, itype => $itemtype_cant, biblionumber => $biblionumber_can })->itemnumber; > my $itemnumber_3_cannot = $builder->build_sample_item({ homebranch => $branch_1, holdingbranch => $branch_1, itype => $itemtype_cant_record, biblionumber => $biblionumber_record_cannot })->itemnumber; > >- Koha::Holds->search({borrowernumber => $borrowernumbers[0]})->delete; >+ Koha::Holds->search({patron_id => $borrowernumbers[0]})->delete; > > t::lib::Mocks::mock_preference('item-level_itypes', 1); > is( >@@ -510,7 +510,7 @@ subtest 'CanItemBeReserved' => sub { > my $itemnumber_21 = $builder->build_sample_item({ homebranch => $branch_1, holdingbranch => $branch_1, itype => $itemtype_can, biblionumber => $biblionumber_2 })->itemnumber; > my $itemnumber_22 = $builder->build_sample_item({ homebranch => $branch_1, holdingbranch => $branch_1, itype => $itemtype_can, biblionumber => $biblionumber_2 })->itemnumber; > >- Koha::Holds->search({borrowernumber => $borrowernumbers[0]})->delete; >+ Koha::Holds->search({patron_id => $borrowernumbers[0]})->delete; > > # Biblio-level hold > AddReserve({ >@@ -527,7 +527,7 @@ subtest 'CanItemBeReserved' => sub { > ); > } > >- Koha::Holds->search({borrowernumber => $borrowernumbers[0]})->delete; >+ Koha::Holds->search({patron_id => $borrowernumbers[0]})->delete; > # Item-level hold > AddReserve({ > branch => $branch_1, >@@ -669,7 +669,7 @@ is(CanItemBeReserved($borrowernumbers[0], $itemnumber)->{status}, 'OK', > t::lib::Mocks::mock_preference( 'item-level_itypes', 1 ); > t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'PatronLibrary' ); > >-$dbh->do('DELETE FROM reserves'); >+$dbh->do('DELETE FROM holds'); > $dbh->do('DELETE FROM issues'); > $dbh->do('DELETE FROM items'); > $dbh->do('DELETE FROM biblio'); >@@ -715,7 +715,7 @@ t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'PatronLibrary' ); > subtest 'Test max_holds per library/patron category' => sub { > plan tests => 6; > >- $dbh->do('DELETE FROM reserves'); >+ $dbh->do('DELETE FROM holds'); > > $biblio = $builder->build_sample_biblio; > $itemnumber = $builder->build_sample_item({ library => $branch_1, biblionumber => $biblio->biblionumber})->itemnumber; >@@ -743,7 +743,7 @@ subtest 'Test max_holds per library/patron category' => sub { > } > > my $count = >- Koha::Holds->search( { borrowernumber => $borrowernumbers[0] } )->count(); >+ Koha::Holds->search( { patron_id => $borrowernumbers[0] } )->count(); > is( $count, 3, 'Patron now has 3 holds' ); > > my $ret = CanItemBeReserved( $borrowernumbers[0], $itemnumber ); >@@ -928,7 +928,7 @@ subtest 'CanItemBeReserved / holds_per_day tests' => sub { > # Update last hold so reservedate is in the past, so 2 holds, but different day > $hold = Koha::Holds->find($res_id); > my $yesterday = dt_from_string() - DateTime::Duration->new( days => 1 ); >- $hold->reservedate($yesterday)->store; >+ $hold->created_date($yesterday)->store; > > is_deeply( > CanItemBeReserved( $patron->borrowernumber, $itemnumber_2 ), >@@ -1578,14 +1578,16 @@ subtest 'CanItemBeReserved rule precedence tests' => sub { > { status => 'OK' }, > 'Patron of specified category can place 1 hold on specified itemtype' > ); >- my $hold = $builder->build_object({ class => 'Koha::Holds', value => { >- biblionumber => $item2->biblionumber, >- itemnumber => $item2->itemnumber, >- found => undef, >- priority => 1, >- branchcode => $library->branchcode, >- borrowernumber => $patron->borrowernumber, >- }}); >+ >+ AddReserve( >+ { >+ branchcode => $library->branchcode, >+ borrowernumber => $patron->borrowernumber, >+ biblionumber => $item2->biblionumber, >+ priority => 1, >+ itemnumber => $item2->itemnumber, >+ } >+ ); > is_deeply( > CanItemBeReserved( $patron->borrowernumber, $item->itemnumber, $library->branchcode ), > { status => 'tooManyReserves', limit => 1 }, >diff --git a/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t b/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t >index 18031c15d0..1ebaa1bc5c 100755 >--- a/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t >+++ b/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t >@@ -290,10 +290,10 @@ my $itemtype2 = $builder->build( > my $item3 = $builder->build_sample_item( { itype => $itemtype2 } ); > > my $hold = $builder->build( >- { source => 'Reserve', >+ { source => 'Hold', > value => { >- itemnumber => $item3->itemnumber, >- found => 'T' >+ item_id => $item3->itemnumber, >+ status => 'in_transit' > } > } > ); >diff --git a/t/db_dependent/Holds/HoldItemtypeLimit.t b/t/db_dependent/Holds/HoldItemtypeLimit.t >index 9157320694..548e990048 100755 >--- a/t/db_dependent/Holds/HoldItemtypeLimit.t >+++ b/t/db_dependent/Holds/HoldItemtypeLimit.t >@@ -57,7 +57,7 @@ my $right_itemtype = $itemtype1->{itemtype}; > my $wrong_itemtype = $itemtype2->{itemtype}; > my $borrowernumber = $borrower->{borrowernumber}; > my $branchcode = $library->{branchcode}; >-$dbh->do("DELETE FROM reserves"); >+$dbh->do("DELETE FROM holds"); > $dbh->do("DELETE FROM issues"); > $dbh->do("DELETE FROM items"); > $dbh->do("DELETE FROM biblio"); >diff --git a/t/db_dependent/Holds/LocalHoldsPriority.t b/t/db_dependent/Holds/LocalHoldsPriority.t >index a125d3eab1..a7e52fc715 100755 >--- a/t/db_dependent/Holds/LocalHoldsPriority.t >+++ b/t/db_dependent/Holds/LocalHoldsPriority.t >@@ -85,29 +85,29 @@ my ($status, $reserve, $all_reserves); > > t::lib::Mocks::mock_preference( 'LocalHoldsPriority', 0 ); > ($status, $reserve, $all_reserves) = CheckReserves($itemnumber); >-ok( $reserve->{borrowernumber} eq $borrowernumbers[0], "Received expected results with LocalHoldsPriority disabled" ); >+ok( $reserve->{patron_id} eq $borrowernumbers[0], "Received expected results with LocalHoldsPriority disabled" ); > > t::lib::Mocks::mock_preference( 'LocalHoldsPriority', 1 ); > > t::lib::Mocks::mock_preference( 'LocalHoldsPriorityPatronControl', 'PickupLibrary' ); > t::lib::Mocks::mock_preference( 'LocalHoldsPriorityItemControl', 'homebranch' ); > ($status, $reserve, $all_reserves) = CheckReserves($itemnumber); >-ok( $reserve->{borrowernumber} eq $borrowernumbers[2], "Received expected results with PickupLibrary/homebranch" ); >+ok( $reserve->{patron_id} eq $borrowernumbers[2], "Received expected results with PickupLibrary/homebranch" ); > > t::lib::Mocks::mock_preference( 'LocalHoldsPriorityPatronControl', 'PickupLibrary' ); > t::lib::Mocks::mock_preference( 'LocalHoldsPriorityItemControl', 'holdingbranch' ); > ($status, $reserve, $all_reserves) = CheckReserves($itemnumber); >-ok( $reserve->{borrowernumber} eq $borrowernumbers[1], "Received expected results with PickupLibrary/holdingbranch" ); >+ok( $reserve->{patron_id} eq $borrowernumbers[1], "Received expected results with PickupLibrary/holdingbranch" ); > > t::lib::Mocks::mock_preference( 'LocalHoldsPriorityPatronControl', 'HomeLibrary' ); > t::lib::Mocks::mock_preference( 'LocalHoldsPriorityItemControl', 'holdingbranch' ); > ($status, $reserve, $all_reserves) = CheckReserves($itemnumber); >-ok( $reserve->{borrowernumber} eq $borrowernumbers[2], "Received expected results with HomeLibrary/holdingbranch" ); >+ok( $reserve->{patron_id} eq $borrowernumbers[2], "Received expected results with HomeLibrary/holdingbranch" ); > > t::lib::Mocks::mock_preference( 'LocalHoldsPriorityPatronControl', 'HomeLibrary' ); > t::lib::Mocks::mock_preference( 'LocalHoldsPriorityItemControl', 'homebranch' ); > ($status, $reserve, $all_reserves) = CheckReserves($itemnumber); >-ok( $reserve->{borrowernumber} eq $borrowernumbers[3], "Received expected results with HomeLibrary/homebranch" ); >+ok( $reserve->{patron_id} eq $borrowernumbers[3], "Received expected results with HomeLibrary/homebranch" ); > > $schema->storage->txn_rollback; > >@@ -161,7 +161,7 @@ subtest "exclude from local holds" => sub { > > my ($status, $reserve, $all_reserves); > ($status, $reserve, $all_reserves) = CheckReserves($item1->itemnumber); >- is($reserve->{borrowernumber}, $patron_nex_l1->borrowernumber, "Patron not excluded with local holds priorities is next checkout"); >+ is($reserve->{patron_id}, $patron_nex_l1->borrowernumber, "Patron not excluded with local holds priorities is next checkout"); > > Koha::Holds->delete; > >@@ -183,7 +183,7 @@ subtest "exclude from local holds" => sub { > ); > > ($status, $reserve, $all_reserves) = CheckReserves($item1->itemnumber); >- is($reserve->{borrowernumber}, $patron_nex_l2->borrowernumber, "Local patron is excluded from priority"); >+ is($reserve->{patron_id}, $patron_nex_l2->borrowernumber, "Local patron is excluded from priority"); > > Koha::Holds->delete; > >@@ -205,7 +205,7 @@ subtest "exclude from local holds" => sub { > ); > > ($status, $reserve, $all_reserves) = CheckReserves($item2->itemnumber); >- is($reserve->{borrowernumber}, $patron_nex_l2->borrowernumber, "Patron from other library is next checkout because item is excluded"); >+ is($reserve->{patron_id}, $patron_nex_l2->borrowernumber, "Patron from other library is next checkout because item is excluded"); > > $schema->storage->txn_rollback; > }; >diff --git a/t/db_dependent/Holds/RevertWaitingStatus.t b/t/db_dependent/Holds/RevertWaitingStatus.t >index 4dab0f3b70..abfbf14f9e 100755 >--- a/t/db_dependent/Holds/RevertWaitingStatus.t >+++ b/t/db_dependent/Holds/RevertWaitingStatus.t >@@ -34,8 +34,7 @@ $schema->storage->txn_begin; > my $builder = t::lib::TestBuilder->new; > my $dbh = C4::Context->dbh; > >-$dbh->do("DELETE FROM reserves"); >-$dbh->do("DELETE FROM old_reserves"); >+$dbh->do("DELETE FROM holds"); > > my $branchcode = $builder->build( { source => 'Branch' } )->{branchcode}; > my $itemtype = $builder->build( >diff --git a/t/db_dependent/Holds/WaitingReserves.t b/t/db_dependent/Holds/WaitingReserves.t >index 7536b30b48..29eb54de63 100755 >--- a/t/db_dependent/Holds/WaitingReserves.t >+++ b/t/db_dependent/Holds/WaitingReserves.t >@@ -18,7 +18,7 @@ $schema->storage->txn_begin; > my $dbh = C4::Context->dbh; > $dbh->do(q{DELETE FROM special_holidays}); > $dbh->do(q{DELETE FROM repeatable_holidays}); >-$dbh->do("DELETE FROM reserves"); >+$dbh->do(q{DELETE FROM holds}); > > my $builder = t::lib::TestBuilder->new(); > >@@ -77,16 +77,17 @@ $reserve1_reservedate->subtract(days => 20); > my $reserve1_expirationdate = $today->clone; > $reserve1_expirationdate->add(days => 6); > >-my $reserve1 = $builder->build({ >- source => 'Reserve', >+my $r = $builder->build_object({ >+ class => 'Koha::Holds', > value => { >- borrowernumber => $patron1->{borrowernumber}, >- reservedate => $reserve1_reservedate->ymd, >- expirationdate => undef, >- biblionumber => $biblio->biblionumber, >- branchcode => 'LIB1', >+ patron_id => $patron1->{borrowernumber}, >+ created_date => $reserve1_reservedate->ymd, >+ expiration_date => undef, >+ biblio_id => $biblio->biblionumber, >+ pickup_library_id => 'LIB1', > priority => 1, >- found => '', >+ status => 'placed', >+ completed => 0 > }, > }); > >@@ -94,44 +95,46 @@ t::lib::Mocks::mock_preference('ExpireReservesMaxPickUpDelay', 1); > t::lib::Mocks::mock_preference('ReservesMaxPickUpDelay', 6); > > ModReserveAffect( $item1->itemnumber, $patron1->{borrowernumber}); >-my $r = Koha::Holds->find($reserve1->{reserve_id}); >+$r->discard_changes; > >-is($r->waitingdate, $today->ymd, 'Waiting date should be set to today' ); >-is($r->expirationdate, $reserve1_expirationdate->ymd, 'Expiration date should be set to today + 6' ); >-is($r->found, 'W', 'Reserve status is now "waiting"' ); >+is($r->waiting_date, $today->ymd, 'Waiting date should be set to today' ); >+is($r->expiration_date, $reserve1_expirationdate->ymd, 'Expiration date should be set to today + 6' ); >+is($r->status, 'waiting', 'Reserve status is now "waiting"' ); > is($r->priority, 0, 'Priority should be 0' ); >-is($r->itemnumber, $item1->itemnumber, 'Item number should be set correctly' ); >+is($r->item_id, $item1->itemnumber, 'Item number should be set correctly' ); > >-my $reserve2 = $builder->build({ >- source => 'Reserve', >+my $r2 = $builder->build_object({ >+ class => 'Koha::Holds', > value => { >- borrowernumber => $patron2->{borrowernumber}, >- reservedate => $reserve1_reservedate->ymd, >- expirationdate => undef, >- biblionumber => $biblio2->biblionumber, >- branchcode => 'LIB1', >+ patron_id => $patron2->{borrowernumber}, >+ created_date => $reserve1_reservedate->ymd, >+ expiration_date => undef, >+ biblio_id => $biblio2->biblionumber, >+ pickup_library_id => 'LIB1', > priority => 1, >- found => '', >+ status => 'placed', >+ completed => 0 > }, > }); > > ModReserveAffect( $item2->itemnumber, $patron2->{borrowernumber}, 1); >-my $r2 = Koha::Holds->find($reserve2->{reserve_id}); >+$r2->discard_changes; > >-is($r2->found, 'T', '2nd reserve - Reserve status is now "To transfer"' ); >+is($r2->status, 'in_transit', '2nd reserve - Reserve status is now "To transfer"' ); > is($r2->priority, 0, '2nd reserve - Priority should be 0' ); >-is($r2->itemnumber, $item2->itemnumber, '2nd reserve - Item number should be set correctly' ); >+is($r2->item_id, $item2->itemnumber, '2nd reserve - Item number should be set correctly' ); > >-my $reserve3 = $builder->build({ >- source => 'Reserve', >+my $r3 = $builder->build_object({ >+ class => 'Koha::Holds', > value => { >- borrowernumber => $patron2->{borrowernumber}, >- reservedate => $reserve1_reservedate->ymd, >- expirationdate => undef, >- biblionumber => $biblio3->biblionumber, >- branchcode => 'LIB1', >+ patron_id => $patron2->{borrowernumber}, >+ created_date => $reserve1_reservedate->ymd, >+ expiration_date => undef, >+ biblio_id => $biblio3->biblionumber, >+ pickup_library_id => 'LIB1', > priority => 1, >- found => '', >+ status => 'placed', >+ completed => 0 > }, > }); > >@@ -174,29 +177,30 @@ ModReserveAffect( $item3->itemnumber, $patron2->{borrowernumber}); > my $expected_expiration = $today->clone; > $expected_expiration->add(days => 8); > >-my $r3 = Koha::Holds->find($reserve3->{reserve_id}); >-is($r3->expirationdate, $expected_expiration->ymd, 'Expiration date should be set to today + 7' ); >+$r3->discard_changes; >+is($r3->expiration_date, $expected_expiration->ymd, 'Expiration date should be set to today + 7' ); > > my $reserve4_reservedate = $today->clone; > my $requested_expiredate = $today->clone()->add(days => 6); > >-my $reserve4 = $builder->build({ >- source => 'Reserve', >+my $r4 = $builder->build_object({ >+ class => 'Koha::Holds', > value => { >- borrowernumber => $patron2->{borrowernumber}, >- reservedate => $reserve4_reservedate->ymd, >- expirationdate => $requested_expiredate->ymd, >- biblionumber => $biblio4->biblionumber, >- branchcode => 'LIB1', >+ patron_id => $patron2->{borrowernumber}, >+ created_date => $reserve4_reservedate->ymd, >+ expiration_date => $requested_expiredate->ymd, >+ biblio_id => $biblio4->biblionumber, >+ pickup_library_id => 'LIB1', > priority => 1, >- found => '', >+ status => 'placed', >+ completed => 0 > }, > }); > > t::lib::Mocks::mock_preference('ReservesMaxPickUpDelay', 10); >-ModReserveAffect( $item4->itemnumber, $patron2->{borrowernumber}, 0, $reserve4->{reserve_id}); >+ModReserveAffect( $item4->itemnumber, $patron2->{borrowernumber}, 0, $r4->id ); > >-my $r4 = Koha::Holds->find($reserve4->{reserve_id}); >-is($r4->expirationdate, $requested_expiredate->ymd, 'Requested expiration date should be kept' ); >+$r4->discard_changes; >+is($r4->expiration_date, $requested_expiredate->ymd, 'Requested expiration date should be kept' ); > > $schema->storage->txn_rollback; >diff --git a/t/db_dependent/HoldsQueue.t b/t/db_dependent/HoldsQueue.t >index 30f4ec3eae..9b4208a674 100755 >--- a/t/db_dependent/HoldsQueue.t >+++ b/t/db_dependent/HoldsQueue.t >@@ -111,7 +111,7 @@ foreach ( $borrower_branchcode, $least_cost_branch_code, @other_branches ) { > } > > # Remove existing reserves, makes debugging easier >-$dbh->do("DELETE FROM reserves"); >+$dbh->do("DELETE FROM holds"); > my $bibitems = undef; > my $priority = 1; > # Make a reserve >@@ -124,7 +124,7 @@ AddReserve( > } > ); > # $resdate, $expdate, $notes, $title, $checkitem, $found >-$dbh->do("UPDATE reserves SET reservedate = DATE_SUB( reservedate, INTERVAL 1 DAY )"); >+$dbh->do("UPDATE holds SET created_date = DATE_SUB( created_date, INTERVAL 1 DAY )"); > > # Tests > my $use_cost_matrix_sth = $dbh->prepare("UPDATE systempreferences SET value = ? WHERE variable = 'UseTransportCostMatrix'"); >@@ -289,14 +289,14 @@ $items_insert_sth->execute( $barcode + 0, $branchcodes[0], $branchcodes[0] ); > $items_insert_sth->execute( $barcode + 1, $branchcodes[1], $branchcodes[1] ); > $items_insert_sth->execute( $barcode + 2, $branchcodes[1], $branchcodes[1] ); > >-$dbh->do("DELETE FROM reserves"); >+$dbh->do("DELETE FROM holds"); > my $sth = $dbh->prepare(q{ >- INSERT INTO reserves ( >- borrowernumber, >- biblionumber, >- branchcode, >+ INSERT INTO holds ( >+ patron_id, >+ biblio_id, >+ pickup_library_id, > priority, >- reservedate >+ created_date > ) VALUES ( ?,?,?,?, CURRENT_DATE() ) > }); > $sth->execute( $borrower1->{borrowernumber}, $biblionumber, $branchcodes[0], 1 ); >@@ -384,7 +384,7 @@ $dbh->do("DELETE FROM issues"); > t::lib::Mocks::mock_preference('LocalHoldsPriorityPatronControl', 'HomeLibrary'); > t::lib::Mocks::mock_preference('LocalHoldsPriorityItemControl', 'homebranch'); > C4::Context->clear_syspref_cache(); >-$dbh->do("DELETE FROM reserves"); >+$dbh->do("DELETE FROM holds"); > $sth->execute( $borrower1->{borrowernumber}, $biblionumber, $branchcodes[0], 1 ); > $sth->execute( $borrower2->{borrowernumber}, $biblionumber, $branchcodes[0], 2 ); > $sth->execute( $borrower3->{borrowernumber}, $biblionumber, $branchcodes[0], 3 ); >@@ -402,7 +402,7 @@ t::lib::Mocks::mock_preference('LocalHoldsPriorityPatronControl', 'HomeLibrary') > t::lib::Mocks::mock_preference('LocalHoldsPriorityItemControl', 'holdingbranch'); > t::lib::Mocks::mock_preference( 'UseBranchTransferLimits', '1' ); > C4::Context->clear_syspref_cache(); >-$dbh->do("DELETE FROM reserves"); >+$dbh->do("DELETE FROM holds"); > $sth->execute( $borrower1->{borrowernumber}, $biblionumber, $branchcodes[0], 1 ); > $sth->execute( $borrower2->{borrowernumber}, $biblionumber, $branchcodes[1], 2 ); > >@@ -444,7 +444,7 @@ t::lib::Mocks::mock_preference( 'UseBranchTransferLimits', '0' ); > t::lib::Mocks::mock_preference('LocalHoldsPriorityPatronControl', 'HomeLibrary'); > t::lib::Mocks::mock_preference('LocalHoldsPriorityItemControl', 'holdingbranch'); > C4::Context->clear_syspref_cache(); >-$dbh->do("DELETE FROM reserves"); >+$dbh->do("DELETE FROM holds"); > $sth->execute( $borrower1->{borrowernumber}, $biblionumber, $branchcodes[0], 1 ); > $sth->execute( $borrower2->{borrowernumber}, $biblionumber, $branchcodes[0], 2 ); > $sth->execute( $borrower3->{borrowernumber}, $biblionumber, $branchcodes[0], 3 ); >@@ -461,7 +461,7 @@ is( $holds_queue->[0]->{cardnumber}, $borrower3->{cardnumber}, "Holds queue givi > t::lib::Mocks::mock_preference('LocalHoldsPriorityPatronControl', 'PickupLibrary'); > t::lib::Mocks::mock_preference('LocalHoldsPriorityItemControl', 'holdingbranch'); > C4::Context->clear_syspref_cache(); >-$dbh->do("DELETE FROM reserves"); >+$dbh->do("DELETE FROM holds"); > $sth->execute( $borrower1->{borrowernumber}, $biblionumber, $branchcodes[0], 1 ); > $sth->execute( $borrower2->{borrowernumber}, $biblionumber, $branchcodes[0], 2 ); > $sth->execute( $borrower3->{borrowernumber}, $biblionumber, $branchcodes[2], 3 ); >@@ -478,7 +478,7 @@ is( $holds_queue->[0]->{cardnumber}, $borrower3->{cardnumber}, "Holds queue givi > t::lib::Mocks::mock_preference('LocalHoldsPriorityPatronControl', 'PickupLibrary'); > t::lib::Mocks::mock_preference('LocalHoldsPriorityItemControl', 'homebranch'); > C4::Context->clear_syspref_cache(); >-$dbh->do("DELETE FROM reserves"); >+$dbh->do("DELETE FROM holds"); > $sth->execute( $borrower1->{borrowernumber}, $biblionumber, $branchcodes[0], 1 ); > $sth->execute( $borrower2->{borrowernumber}, $biblionumber, $branchcodes[0], 2 ); > $sth->execute( $borrower3->{borrowernumber}, $biblionumber, $branchcodes[2], 3 ); >@@ -501,7 +501,7 @@ $borrowernumber = $borrower3->{borrowernumber}; > my $library_A = $library1->{branchcode}; > my $library_B = $library2->{branchcode}; > my $library_C = $borrower3->{branchcode}; >-$dbh->do("DELETE FROM reserves"); >+$dbh->do("DELETE FROM holds"); > $dbh->do("DELETE FROM issues"); > $dbh->do("DELETE FROM items"); > $dbh->do("DELETE FROM biblio"); >@@ -566,7 +566,7 @@ $itemtype = $builder->build({ source => 'Itemtype', value => { notforloan => 0 } > $borrowernumber = $borrower2->{borrowernumber}; > $library_A = $library1->{branchcode}; > $library_B = $library2->{branchcode}; >-$dbh->do("DELETE FROM reserves"); >+$dbh->do("DELETE FROM holds"); > $dbh->do("DELETE FROM issues"); > $dbh->do("DELETE FROM items"); > $dbh->do("DELETE FROM biblio"); >@@ -619,7 +619,7 @@ $borrowernumber = $borrower3->{borrowernumber}; > $library_A = $library1->{branchcode}; > $library_B = $library2->{branchcode}; > $library_C = $library3->{branchcode}; >-$dbh->do("DELETE FROM reserves"); >+$dbh->do("DELETE FROM holds"); > $dbh->do("DELETE FROM issues"); > $dbh->do("DELETE FROM items"); > $dbh->do("DELETE FROM biblio"); >@@ -829,7 +829,7 @@ my $wrong_itemtype = $builder->build({ source => 'Itemtype', value => { notforlo > my $right_itemtype = $builder->build({ source => 'Itemtype', value => { notforloan => 0 } })->{itemtype}; > $borrowernumber = $borrower3->{borrowernumber}; > my $branchcode = $library1->{branchcode}; >-$dbh->do("DELETE FROM reserves"); >+$dbh->do("DELETE FROM holds"); > $dbh->do("DELETE FROM issues"); > $dbh->do("DELETE FROM items"); > $dbh->do("DELETE FROM biblio"); >@@ -1205,7 +1205,7 @@ subtest "Test Local Holds Priority - Ensure no duplicate requests in holds queue > > $dbh->do("DELETE FROM tmp_holdsqueue"); > $dbh->do("DELETE FROM hold_fill_targets"); >- $dbh->do("DELETE FROM reserves"); >+ $dbh->do("DELETE FROM holds"); > $dbh->do("DELETE FROM circulation_rules"); > Koha::Biblios->delete(); > >@@ -1719,17 +1719,16 @@ subtest 'Remove holds on check-in match' => sub { > AND q.holdingbranch = t.source_branchcode > WHERE t.reserve_id = ? > }); >- $sth->execute($hold->reserve_id); >+ $sth->execute($hold->id); > my ($count_1) = $sth->fetchrow_array; > > is( $count_1, 1, "Holds queue has one element" ); > > AddReturn( $item->barcode, $item->homebranch, undef, dt_from_string ); > >- ModReserveAffect( $item->itemnumber, $hold->borrowernumber, 0, >- $hold->reserve_id ); >+ ModReserveAffect( $item->itemnumber, $hold->patron_id, 0, $hold->id ); > >- $sth->execute($hold->reserve_id); >+ $sth->execute($hold->id); > my ($count_2) = $sth->fetchrow_array; > > is( $count_2, 0, >diff --git a/t/db_dependent/ILSDI_Services.t b/t/db_dependent/ILSDI_Services.t >index 97a2062ce1..f1ac8f8196 100755 >--- a/t/db_dependent/ILSDI_Services.t >+++ b/t/db_dependent/ILSDI_Services.t >@@ -326,11 +326,12 @@ subtest 'Holds test' => sub { > $item->damaged(0)->store; > > my $hold = $builder->build({ >- source => 'Reserve', >+ source => 'Hold', > value => { >- borrowernumber => $patron->{borrowernumber}, >- biblionumber => $item->biblionumber, >- itemnumber => $item->itemnumber >+ patron_id => $patron->{borrowernumber}, >+ biblio_id => $item->biblionumber, >+ item_id => $item->itemnumber, >+ completed => 0 > } > }); > >@@ -551,15 +552,15 @@ subtest 'Holds test for branch transfer limits' => sub { > > $reply = C4::ILSDI::Services::HoldItem( $query ); > is( $reply->{code}, undef, "Item hold, Item can be transferred" ); >- my $hold = Koha::Holds->search({ itemnumber => $item->itemnumber, borrowernumber => $patron->{borrowernumber} })->next; >- is( $hold->branchcode, $pickup_branch->{branchcode}, 'The library id is correctly set' ); >+ my $hold = Koha::Holds->search({ item_id => $item->itemnumber, patron_id => $patron->{borrowernumber} })->next; >+ is( $hold->pickup_library_id, $pickup_branch->{branchcode}, 'The library id is correctly set' ); > > Koha::Holds->search()->delete(); > > $reply = C4::ILSDI::Services::HoldTitle( $query ); > is( $reply->{code}, undef, "Record hold, Item con be transferred" ); >- $hold = Koha::Holds->search({ biblionumber => $item->biblionumber, borrowernumber => $patron->{borrowernumber} })->next; >- is( $hold->branchcode, $pickup_branch->{branchcode}, 'The library id is correctly set' ); >+ $hold = Koha::Holds->search({ biblio_id => $item->biblionumber, patron_id => $patron->{borrowernumber} })->next; >+ is( $hold->pickup_library_id, $pickup_branch->{branchcode}, 'The library id is correctly set' ); > > $schema->storage->txn_rollback; > }; >@@ -605,19 +606,19 @@ subtest 'Holds test with start_date and end_date' => sub { > > my $reply = C4::ILSDI::Services::HoldItem( $query ); > is ($reply->{pickup_location}, $pickup_library->branchname, "Item hold with date parameters was placed"); >- my $hold = Koha::Holds->search({ biblionumber => $item->biblionumber})->next(); >- is( $hold->biblionumber, $item->biblionumber, "correct biblionumber"); >- is( $hold->reservedate, '2020-03-20', "Item hold has correct start date" ); >- is( $hold->expirationdate, '2020-04-22', "Item hold has correct end date" ); >+ my $hold = Koha::Holds->search({ biblio_id => $item->biblionumber})->next(); >+ is( $hold->biblio_id, $item->biblionumber, "correct biblionumber"); >+ is( $hold->created_date, '2020-03-20', "Item hold has correct start date" ); >+ is( $hold->expiration_date, '2020-04-22', "Item hold has correct end date" ); > > $hold->delete(); > > $reply = C4::ILSDI::Services::HoldTitle( $query ); > is ($reply->{pickup_location}, $pickup_library->branchname, "Record hold with date parameters was placed"); >- $hold = Koha::Holds->search({ biblionumber => $item->biblionumber})->next(); >- is( $hold->biblionumber, $item->biblionumber, "correct biblionumber"); >- is( $hold->reservedate, '2020-03-20', "Record hold has correct start date" ); >- is( $hold->expirationdate, '2020-04-22', "Record hold has correct end date" ); >+ $hold = Koha::Holds->search({ biblio_id => $item->biblionumber})->next(); >+ is( $hold->biblio_id, $item->biblionumber, "correct biblionumber"); >+ is( $hold->created_date, '2020-03-20', "Record hold has correct start date" ); >+ is( $hold->expiration_date, '2020-04-22', "Record hold has correct end date" ); > > $schema->storage->txn_rollback; > }; >@@ -655,9 +656,9 @@ subtest 'GetRecords' => sub { > }); > > my $hold = $builder->build({ >- source => 'Reserve', >+ source => 'Hold', > value => { >- biblionumber => $item->biblionumber, >+ biblio_id => $item->biblionumber, > } > }); > >diff --git a/t/db_dependent/Items/GetItemsForInventory.t b/t/db_dependent/Items/GetItemsForInventory.t >index b5c2b97bd2..904406ab15 100755 >--- a/t/db_dependent/Items/GetItemsForInventory.t >+++ b/t/db_dependent/Items/GetItemsForInventory.t >@@ -112,7 +112,7 @@ subtest 'Skip items with waiting holds' => sub { > biblionumber => $item_1->biblionumber, > priority => 1, > itemnumber => $item_1->itemnumber, >- found => 'W' >+ found => 'waiting' > } > ); > C4::Reserves::AddReserve( >diff --git a/t/db_dependent/Items/MoveItemFromBiblio.t b/t/db_dependent/Items/MoveItemFromBiblio.t >index 7a3cf2b639..6e8e449059 100755 >--- a/t/db_dependent/Items/MoveItemFromBiblio.t >+++ b/t/db_dependent/Items/MoveItemFromBiblio.t >@@ -43,18 +43,18 @@ my $item3 = $builder->build_sample_item( > > > my $bib_level_hold_not_to_move = $builder->build( >- { source => 'Reserve', >- value => { biblionumber => $from_biblio->biblionumber, }, >+ { source => 'Hold', >+ value => { biblio_id => $from_biblio->biblionumber, }, > } > ); > my $item_level_hold_not_to_move = $builder->build( >- { source => 'Reserve', >- value => { biblionumber => $from_biblio->biblionumber, itemnumber => $item1->itemnumber }, >+ { source => 'Hold', >+ value => { biblio_id => $from_biblio->biblionumber, item_id => $item1->itemnumber }, > } > ); > my $item_level_hold_to_move = $builder->build( >- { source => 'Reserve', >- value => { biblionumber => $from_biblio->biblionumber, itemnumber => $item2->itemnumber }, >+ { source => 'Hold', >+ value => { biblio_id => $from_biblio->biblionumber, item_id => $item2->itemnumber }, > } > ); > >@@ -73,13 +73,13 @@ is( $get_item2->biblionumber, $to_biblio->biblionumber, 'The item2 should have b > my $get_item3 = Koha::Items->find( $item3->itemnumber ); > is( $get_item3->biblionumber, $to_biblio->biblionumber, 'The item3 should not have been moved' ); > >-my $get_bib_level_hold = Koha::Holds->find( $bib_level_hold_not_to_move->{reserve_id} ); >-my $get_item_level_hold_1 = Koha::Holds->find( $item_level_hold_not_to_move->{reserve_id} ); >-my $get_item_level_hold_2 = Koha::Holds->find( $item_level_hold_to_move->{reserve_id} ); >+my $get_bib_level_hold = Koha::Holds->find( $bib_level_hold_not_to_move->{id} ); >+my $get_item_level_hold_1 = Koha::Holds->find( $item_level_hold_not_to_move->{id} ); >+my $get_item_level_hold_2 = Koha::Holds->find( $item_level_hold_to_move->{id} ); > >-is( $get_bib_level_hold->biblionumber, $from_biblio->biblionumber, 'MoveItemFromBiblio should not have moved the biblio-level hold' ); >-is( $get_item_level_hold_1->biblionumber, $from_biblio->biblionumber, 'MoveItemFromBiblio should not have moved the item-level hold placed on item 1' ); >-is( $get_item_level_hold_2->biblionumber, $to_biblio->biblionumber, 'MoveItemFromBiblio should have moved the item-level hold placed on item 2' ); >+is( $get_bib_level_hold->biblio_id, $from_biblio->biblionumber, 'MoveItemFromBiblio should not have moved the biblio-level hold' ); >+is( $get_item_level_hold_1->biblio_id, $from_biblio->biblionumber, 'MoveItemFromBiblio should not have moved the item-level hold placed on item 1' ); >+is( $get_item_level_hold_2->biblio_id, $to_biblio->biblionumber, 'MoveItemFromBiblio should have moved the item-level hold placed on item 2' ); > > $schema->storage->txn_rollback; > >diff --git a/t/db_dependent/Koha/Acquisition/Order.t b/t/db_dependent/Koha/Acquisition/Order.t >index dd2138405f..e51617e5b1 100755 >--- a/t/db_dependent/Koha/Acquisition/Order.t >+++ b/t/db_dependent/Koha/Acquisition/Order.t >@@ -860,7 +860,7 @@ subtest 'cancel() tests' => sub { > borrowernumber => $patron->borrowernumber, > biblionumber => $biblio_id, > itemnumber => $item_3->id, >- found => 'W', >+ found => 'waiting', > } > ); > >diff --git a/t/db_dependent/Koha/Biblios.t b/t/db_dependent/Koha/Biblios.t >index d19e8f3c0d..b02e753eda 100755 >--- a/t/db_dependent/Koha/Biblios.t >+++ b/t/db_dependent/Koha/Biblios.t >@@ -77,7 +77,7 @@ subtest 'holds + current_holds' => sub { > my $holds = $biblio->holds; > is( ref($holds), 'Koha::Holds', '->holds should return a Koha::Holds object' ); > is( $holds->count, 1, '->holds should only return 1 hold' ); >- is( $holds->next->borrowernumber, $patron->borrowernumber, '->holds should return the correct hold' ); >+ is( $holds->next->patron_id, $patron->borrowernumber, '->holds should return the correct hold' ); > $holds->delete; > > # Add a hold in the future >@@ -98,25 +98,25 @@ subtest 'holds + current_holds' => sub { > }; > > subtest 'waiting_or_in_transit' => sub { >+ > plan tests => 4; >+ > my $item = $builder->build_sample_item; >- my $reserve = $builder->build({ >- source => 'Reserve', >+ my $hold = $builder->build_object({ >+ class => 'Koha::Holds', > value => { >- biblionumber => $item->biblionumber, >- found => undef >+ biblio_id => $item->biblionumber, > } > }); > >- $reserve = Koha::Holds->find($reserve->{reserve_id}); > $biblio = $item->biblio; > > is($biblio->has_items_waiting_or_intransit, 0, 'Item is neither waiting nor in transit'); > >- $reserve->found('W')->store; >+ $hold->set_waiting(); > is($biblio->has_items_waiting_or_intransit, 1, 'Item is waiting'); > >- $reserve->found('T')->store; >+ $hold->set_transfer(); > is($biblio->has_items_waiting_or_intransit, 1, 'Item is in transit'); > > my $transfer = $builder->build({ >@@ -128,7 +128,7 @@ subtest 'waiting_or_in_transit' => sub { > } > }); > my $t = Koha::Database->new()->schema()->resultset( 'Branchtransfer' )->find($transfer->{branchtransfer_id}); >- $reserve->found(undef)->store; >+ $hold->status('placed')->store; > is($biblio->has_items_waiting_or_intransit, 1, 'Item has transfer'); > }; > >diff --git a/t/db_dependent/Koha/Club/Hold.t b/t/db_dependent/Koha/Club/Hold.t >index 9c88f1049e..5ec23a4bbd 100755 >--- a/t/db_dependent/Koha/Club/Hold.t >+++ b/t/db_dependent/Koha/Club/Hold.t >@@ -131,7 +131,7 @@ subtest 'add' => sub { > > my $hold = Koha::Holds->find($patron_hold->hold_id); > >- is($patron_hold->patron_id, $hold->borrowernumber, 'Patron must be the same'); >+ is($patron_hold->patron_id, $hold->patron_id, 'Patron must be the same'); > > $schema->storage->txn_rollback; > } >diff --git a/t/db_dependent/Koha/Hold.t b/t/db_dependent/Koha/Hold.t >index 336905d877..23befeaf89 100755 >--- a/t/db_dependent/Koha/Hold.t >+++ b/t/db_dependent/Koha/Hold.t >@@ -127,7 +127,7 @@ subtest 'set_pickup_location() tests' => sub { > > $item_hold->set_pickup_location({ library_id => $library_1->branchcode, force => 1 }); > $item_hold->discard_changes; >- is( $item_hold->branchcode, $library_1->branchcode, 'branchcode changed because of \'force\'' ); >+ is( $item_hold->pickup_library_id, $library_1->branchcode, 'branchcode changed because of \'force\'' ); > > $ret = $item_hold->set_pickup_location({ library_id => $library_2->id }); > is( ref($ret), 'Koha::Hold', 'self is returned' ); >diff --git a/t/db_dependent/Koha/Holds.t b/t/db_dependent/Koha/Holds.t >index ee82b490ef..00de77cdd4 100755 >--- a/t/db_dependent/Koha/Holds.t >+++ b/t/db_dependent/Koha/Holds.t >@@ -61,7 +61,9 @@ subtest 'DB constraints' => sub { > }; > > subtest 'cancel' => sub { >- plan tests => 12; >+ >+ plan tests => 13; >+ > my $biblioitem = $builder->build_object( { class => 'Koha::Biblioitems' } ); > my $library = $builder->build_object( { class => 'Koha::Libraries' } ); > my $itemtype = $builder->build_object( { class => 'Koha::ItemTypes', value => { rentalcharge => 0 } } ); >@@ -102,7 +104,7 @@ subtest 'cancel' => sub { > > # There are 3 holds on this records > my $nb_of_holds = >- Koha::Holds->search( { biblionumber => $item->biblionumber } )->count; >+ Koha::Holds->search( { biblio_id => $item->biblionumber } )->count; > is( $nb_of_holds, 3, > 'There should have 3 holds placed on this biblio record' ); > my $first_hold = $holds[0]; >@@ -116,14 +118,18 @@ subtest 'cancel' => sub { > # Remove the second hold, only 2 should still exist in DB and priorities must have been updated > my $is_cancelled = $second_hold->cancel; > is( ref($is_cancelled), 'Koha::Hold', >- 'Koha::Hold->cancel should return the Koha::Hold (?)' ) >+ 'Koha::Hold->cancel should return the Koha::Hold (?)' ); >+ $second_hold->discard_changes; > ; # This is can reconsidered >- is( $second_hold->in_storage, 0, >- 'The hold has been cancelled and does not longer exist in DB' ); >+ is( $second_hold->in_storage, 1, >+ 'The hold has been cancelled and still exists on the DB' ); >+ is( $second_hold->status, 'cancelled', "Status is 'cancelled'" ); >+ ok( $second_hold->completed, 'Hold marked as comleted' ); >+ > $nb_of_holds = >- Koha::Holds->search( { biblionumber => $item->biblionumber } )->count; >+ Koha::Holds->search( { biblio_id => $item->biblionumber, completed => 0 } )->count; > is( $nb_of_holds, 2, >- 'a hold has been cancelled, there should have only 2 holds placed on this biblio record' >+ 'a hold has been cancelled, there should have only 2 (not completed) holds placed on this biblio record' > ); > > # discard_changes to refetch >@@ -166,7 +172,7 @@ subtest 'cancel' => sub { > }; > > subtest 'waiting hold' => sub { >- plan tests => 1; >+ plan tests => 2; > my $patron = $builder->build_object({ class => 'Koha::Patrons' }); > my $reserve_id = C4::Reserves::AddReserve( > { >@@ -176,12 +182,13 @@ subtest 'cancel' => sub { > priority => 1, > title => "title for fee", > itemnumber => $item->itemnumber, >- found => 'W', >+ status => 'waiting', > } > ); >- Koha::Holds->find( $reserve_id )->cancel; >- my $hold_old = Koha::Old::Holds->find( $reserve_id ); >- is( $hold_old->found, 'W', 'The found column should have been kept and a hold is cancelled' ); >+ my $hold = Koha::Holds->find( $reserve_id ); >+ $hold->cancel->discard_changes; >+ is( $hold->status, 'cancelled', 'The found column should have been kept and a hold is cancelled' ); >+ ok( $hold->completed, 'Hold is marked as completed' ); > }; > > subtest 'HoldsLog' => sub { >@@ -208,50 +215,6 @@ subtest 'cancel' => sub { > $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'HOLDS', action => 'CANCEL', object => $reserve_id } )->count; > is( $number_of_logs, 1, 'With HoldsLog, Koha::Hold->cancel should have logged' ); > }; >- >- subtest 'rollback' => sub { >- plan tests => 3; >- my $patron_category = $builder->build_object( >- { >- class => 'Koha::Patron::Categories', >- value => { reservefee => 0 } >- } >- ); >- my $patron = $builder->build_object( >- { >- class => 'Koha::Patrons', >- value => { categorycode => $patron_category->categorycode } >- } >- ); >- my $hold_info = { >- branchcode => $library->branchcode, >- borrowernumber => $patron->borrowernumber, >- biblionumber => $item->biblionumber, >- priority => 1, >- title => "title for fee", >- itemnumber => $item->itemnumber, >- }; >- >- t::lib::Mocks::mock_preference( 'ExpireReservesMaxPickUpDelayCharge',42 ); >- my $reserve_id = C4::Reserves::AddReserve($hold_info); >- my $hold = Koha::Holds->find($reserve_id); >- >- # Add a row with the same id to make the cancel fails >- Koha::Old::Hold->new( $hold->unblessed )->store; >- >- warning_like { >- eval { $hold->cancel( { charge_cancel_fee => 1 } ) }; >- } >- qr{.*DBD::mysql::st execute failed: Duplicate entry.*}, >- 'DBD should have raised an error about dup primary key'; >- >- $hold = Koha::Holds->find($reserve_id); >- is( ref($hold), 'Koha::Hold', 'The hold should not have been deleted' ); >- is( $patron->account->balance, 0, >-'If the hold has not been cancelled, the patron should not have been charged' >- ); >- }; >- > }; > > subtest 'cancel with reason' => sub { >@@ -455,7 +418,7 @@ subtest 'get_items_that_can_fill' => sub { > borrowernumber => $patron_2->borrowernumber, > biblionumber => $biblio->biblionumber, > priority => 0, >- found => 'W', >+ found => 'waiting', > itemnumber => $item_1->itemnumber, > } > ); >@@ -477,7 +440,7 @@ subtest 'get_items_that_can_fill' => sub { > > my $holds = Koha::Holds->search( > { >- reserve_id => [ $reserve_id_1, $reserve_id_2, $waiting_reserve_id, ] >+ id => [ $reserve_id_1, $reserve_id_2, $waiting_reserve_id, ] > } > ); > >diff --git a/t/db_dependent/Koha/Items.t b/t/db_dependent/Koha/Items.t >index e3e7205e21..8949b28333 100755 >--- a/t/db_dependent/Koha/Items.t >+++ b/t/db_dependent/Koha/Items.t >@@ -1382,14 +1382,14 @@ subtest 'holds' => sub { > biblionumber => $biblio->biblionumber, > }); > is($item->holds->count, 0, "Nothing returned if no holds"); >- my $hold1 = $builder->build({ source => 'Reserve', value => { itemnumber=>$item->itemnumber, found => 'T' }}); >- my $hold2 = $builder->build({ source => 'Reserve', value => { itemnumber=>$item->itemnumber, found => 'W' }}); >- my $hold3 = $builder->build({ source => 'Reserve', value => { itemnumber=>$item->itemnumber, found => 'W' }}); >+ my $hold1 = $builder->build({ source => 'Hold', value => { item_id=>$item->itemnumber, status => 'in_transit', completed => 0 }}); >+ my $hold2 = $builder->build({ source => 'Hold', value => { item_id=>$item->itemnumber, status => 'waiting', completed => 0 }}); >+ my $hold3 = $builder->build({ source => 'Hold', value => { item_id=>$item->itemnumber, status => 'waiting', completed => 0 }}); > > is($item->holds()->count,3,"Three holds found"); >- is($item->holds({found => 'W'})->count,2,"Two waiting holds found"); >- is_deeply($item->holds({found => 'T'})->next->unblessed,$hold1,"Found transit holds matches the hold"); >- is($item->holds({found => undef})->count, 0,"Nothing returned if no matching holds"); >+ is($item->holds({status => 'waiting'})->count,2,"Two waiting holds found"); >+ is_deeply($item->holds({status => 'in_transit'})->next->unblessed,$hold1,"Found transit holds matches the hold"); >+ is($item->holds({status => 'placed'})->count, 0,"Nothing returned if no matching holds"); > }; > > subtest 'biblio' => sub { >diff --git a/t/db_dependent/Koha/Object.t b/t/db_dependent/Koha/Object.t >index 64d3f1d9ea..55485d3580 100755 >--- a/t/db_dependent/Koha/Object.t >+++ b/t/db_dependent/Koha/Object.t >@@ -272,7 +272,7 @@ subtest "to_api() tests" => sub { > > my $biblio = $builder->build_sample_biblio(); > my $item = $builder->build_sample_item({ biblionumber => $biblio->biblionumber }); >- my $hold = $builder->build_object({ class => 'Koha::Holds', value => { itemnumber => $item->itemnumber } }); >+ my $hold = $builder->build_object({ class => 'Koha::Holds', value => { item_id => $item->itemnumber, completed => 0 } }); > > my $embeds = { 'items' => {} }; > >@@ -297,7 +297,7 @@ subtest "to_api() tests" => sub { > ok(exists $biblio_api->{items}, 'Items where embedded in biblio results'); > is($biblio_api->{items}->[0]->{item_id}, $item->itemnumber, 'Item still matches'); > ok(exists $biblio_api->{items}->[0]->{holds}, 'Holds info should be embedded'); >- is($biblio_api->{items}->[0]->{holds}->[0]->{hold_id}, $hold->reserve_id, 'Hold matches'); >+ is($biblio_api->{items}->[0]->{holds}->[0]->{hold_id}, $hold->id, 'Hold matches'); > is_deeply($biblio_api->{biblioitem}, $biblio->biblioitem->to_api, 'More than one root'); > > my $hold_api = $hold->to_api( >diff --git a/t/db_dependent/Koha/Objects.t b/t/db_dependent/Koha/Objects.t >index 554b631741..bce94cf249 100755 >--- a/t/db_dependent/Koha/Objects.t >+++ b/t/db_dependent/Koha/Objects.t >@@ -338,7 +338,7 @@ subtest "to_api() tests" => sub { > my $hold_1 = $builder->build_object( > { > class => 'Koha::Holds', >- value => { itemnumber => $item_1->itemnumber } >+ value => { item_id => $item_1->itemnumber, completed => 0 } > } > ); > >@@ -347,7 +347,7 @@ subtest "to_api() tests" => sub { > my $hold_2 = $builder->build_object( > { > class => 'Koha::Holds', >- value => { itemnumber => $item_2->itemnumber } >+ value => { item_id => $item_2->itemnumber, completed => 0 } > } > ); > >@@ -391,7 +391,7 @@ subtest "to_api() tests" => sub { > ok(exists $biblio_api->{items}, 'Items where embedded in biblio results'); > is($biblio_api->{items}->[0]->{item_id}, $items[$i]->itemnumber, 'Item still matches'); > ok(exists $biblio_api->{items}->[0]->{holds}, 'Holds info should be embedded'); >- is($biblio_api->{items}->[0]->{holds}->[0]->{hold_id}, $holds[$i]->reserve_id, 'Hold matches'); >+ is($biblio_api->{items}->[0]->{holds}->[0]->{hold_id}, $holds[$i]->id, 'Hold matches'); > > $i++; > } >diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index 59c6a8a075..f084ceffa3 100755 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -469,8 +469,8 @@ subtest "delete" => sub { > my $patron = $builder->build( { source => 'Borrower' } ); > my $retrieved_patron = Koha::Patrons->find( $patron->{borrowernumber} ); > my $hold = $builder->build( >- { source => 'Reserve', >- value => { borrowernumber => $patron->{borrowernumber} } >+ { source => 'Hold', >+ value => { patron_id => $patron->{borrowernumber}, completed => 0 } > } > ); > my $list = $builder->build( >@@ -485,9 +485,9 @@ subtest "delete" => sub { > > is( Koha::Patrons->find( $patron->{borrowernumber} ), undef, 'Koha::Patron->delete should have deleted the patron' ); > >- is (Koha::Old::Holds->search( { reserve_id => $hold->{ reserve_id } } )->count, 1, q|Koha::Patron->delete should have cancelled patron's holds| ); >+ is (Koha::Holds->search( { id => $hold->{id}, status => 'cancelled' } )->count, 1, q|Koha::Patron->delete should have cancelled patron's holds| ); > >- is( Koha::Holds->search( { borrowernumber => $patron->{borrowernumber} } )->count, 0, q|Koha::Patron->delete should have cancelled patron's holds 2| ); >+ is( Koha::Holds->search( { patron_id => $patron->{borrowernumber}, completed => 0 } )->count, 0, q|Koha::Patron->delete should have cancelled patron's holds 2| ); > > is( Koha::Virtualshelves->search( { owner => $patron->{borrowernumber} } )->count, 0, q|Koha::Patron->delete should have deleted patron's lists| ); > >@@ -993,8 +993,8 @@ subtest 'holds and old_holds' => sub { > is( $holds->count, 2, 'There should be 2 holds placed by this patron' ); > > my $old_holds = $patron->old_holds; >- is( ref($old_holds), 'Koha::Old::Holds', >- 'Koha::Patron->old_holds should return a Koha::Old::Holds objects' ); >+ is( ref($old_holds), 'Koha::Holds', >+ 'Koha::Patron->old_holds should return a Koha::Holds objects' ); > is( $old_holds->count, 0, 'There should not be any old holds yet'); > > my $hold = $holds->next; >@@ -1606,7 +1606,7 @@ subtest 'BorrowersLog tests' => sub { > $schema->storage->txn_rollback; > > subtest 'Test Koha::Patrons::merge' => sub { >- plan tests => 110; >+ plan tests => 106; > > my $schema = Koha::Database->new()->schema(); > >@@ -2028,7 +2028,7 @@ subtest 'lock' => sub { > my $patron2 = $builder->build_object( { class => 'Koha::Patrons' } ); > my $hold = $builder->build_object({ > class => 'Koha::Holds', >- value => { borrowernumber => $patron1->borrowernumber }, >+ value => { patron_id => $patron1->borrowernumber, completed => 0 }, > }); > > t::lib::Mocks::mock_preference( 'FailedLoginAttempts', 3 ); >diff --git a/t/db_dependent/Koha/Z3950Responder/Session.t b/t/db_dependent/Koha/Z3950Responder/Session.t >index b48ac0cc76..343015bf19 100755 >--- a/t/db_dependent/Koha/Z3950Responder/Session.t >+++ b/t/db_dependent/Koha/Z3950Responder/Session.t >@@ -32,7 +32,7 @@ subtest 'add_item_status' => sub { > my ( $itemtag, $itemsubfield ) = C4::Biblio::GetMarcFromKohaField( "items.itemnumber" ); > my $item_marc_1 = C4::Items::GetMarcItem( $item_1->biblionumber, $item_1->itemnumber ); > my $item_field_1 = scalar $item_marc_1->field($itemtag); >- $builder->build({ source => 'Reserve', value=> { itemnumber => $item_1->itemnumber } }); >+ $builder->build({ source => 'Hold', value=> { item_id => $item_1->itemnumber } }); > $builder->build( > { > source => 'Branchtransfer', >diff --git a/t/db_dependent/Koha/Z3950Responder/Session2.t b/t/db_dependent/Koha/Z3950Responder/Session2.t >index 71ba26ec3e..0fbab360e6 100755 >--- a/t/db_dependent/Koha/Z3950Responder/Session2.t >+++ b/t/db_dependent/Koha/Z3950Responder/Session2.t >@@ -55,7 +55,7 @@ subtest 'add_item_status' => sub { > ); > my $item_marc_1 = C4::Items::GetMarcItem( $item_1->biblionumber, $item_1->itemnumber ); > my $item_field_1 = scalar $item_marc_1->field('952'); >- $builder->build({ source => 'Reserve', value=> { itemnumber => $item_1->itemnumber } }); >+ $builder->build({ source => 'Hold', value=> { item_id => $item_1->itemnumber } }); > $builder->build( > { > source => 'Branchtransfer', >diff --git a/t/db_dependent/Letters/TemplateToolkit.t b/t/db_dependent/Letters/TemplateToolkit.t >index 7e72517eb6..0f206f9a55 100755 >--- a/t/db_dependent/Letters/TemplateToolkit.t >+++ b/t/db_dependent/Letters/TemplateToolkit.t >@@ -70,8 +70,8 @@ my $hold = $builder->build_object( > { > class => 'Koha::Holds', > value => { >- borrowernumber => $patron->{borrowernumber}, >- biblionumber => $item->biblionumber >+ patron_id => $patron->{borrowernumber}, >+ biblio_id => $item->biblionumber > } > } > ); >@@ -191,18 +191,21 @@ $prepared_letter = GetPreparedLetter( > is( $prepared_letter->{content}, $news->id(), 'News object used correctly for content' ); > is( $prepared_letter->{title}, $news->id(), 'News object used correctly for title' ); > >-$sth->execute( "TEST_HOLD", "[% hold.borrowernumber %]", "[% hold.id %]" ); >+$sth->execute( "TEST_HOLD", "[% hold.patron_id %]", "[% hold.id %]" ); > $prepared_letter = GetPreparedLetter( > ( > module => 'test', > letter_code => 'TEST_HOLD', > tables => { >- reserves => { borrowernumber => $patron->{borrowernumber}, biblionumber => $item->biblionumber }, >+ holds => { >+ patron_id => $patron->{borrowernumber}, >+ biblio_id => $item->biblionumber >+ }, > }, > ) > ); >-is( $prepared_letter->{content}, $hold->id(), 'Hold object used correctly for content' ); >-is( $prepared_letter->{title}, $hold->borrowernumber, 'Hold object used correctly for title' ); >+is( $prepared_letter->{content}, $hold->id, 'Hold object used correctly for content' ); >+is( $prepared_letter->{title}, $hold->patron_id, 'Hold object used correctly for title' ); > > eval { > $prepared_letter = GetPreparedLetter( >@@ -210,13 +213,13 @@ eval { > module => 'test', > letter_code => 'TEST_HOLD', > tables => { >- reserves => [ $patron->{borrowernumber}, $item->biblionumber ], >+ holds => [ $patron->{borrowernumber}, $item->biblionumber ], > }, > ) > ) > }; > my $croak = $@; >-like( $croak, qr{^Multiple foreign keys \(table reserves\) should be passed using an hashref.*}, "GetPreparedLetter should not be called with arrayref for multiple FK" ); >+like( $croak, qr{^Multiple foreign keys \(table holds\) should be passed using an hashref.*}, "GetPreparedLetter should not be called with arrayref for multiple FK" ); > > # Bug 16942 > $prepared_letter = GetPreparedLetter( >@@ -228,8 +231,8 @@ $prepared_letter = GetPreparedLetter( > 'borrowers' => $patron, > 'biblio' => $item->biblionumber, > 'biblioitems' => $item->biblioitemnumber, >- 'reserves' => $hold->unblessed, >- 'items' => $hold->itemnumber, >+ 'holds' => $hold->unblessed, >+ 'items' => $hold->item_id, > } > ) > ); >@@ -302,7 +305,6 @@ subtest 'regression tests' => sub { > my $patron = $builder->build( { source => 'Borrower' } ); > my $item1 = $builder->build_sample_item( > { >- barcode => 'a_t_barcode', > library => $library->{branchcode}, > itype => 'BK', > itemcallnumber => 'itemcallnumber1', >@@ -312,7 +314,6 @@ subtest 'regression tests' => sub { > $item1 = $item1->unblessed; > my $item2 = $builder->build_sample_item( > { >- barcode => 'another_t_barcode', > library => $library->{branchcode}, > itype => 'BK', > itemcallnumber => 'itemcallnumber2', >@@ -322,7 +323,6 @@ subtest 'regression tests' => sub { > $item2 = $item2->unblessed; > my $item3 = $builder->build_sample_item( > { >- barcode => 'another_t_barcode_3', > library => $library->{branchcode}, > itype => 'BK', > itemcallnumber => 'itemcallnumber3', >@@ -572,10 +572,10 @@ You have [% count %] items due > <ul> > <li><<items.barcode>></li> > <li><<items.itemcallnumber>></li> >- <li><<reserves.waitingdate>></li> >+ <li><<holds.waiting_date>></li> > </ul> > <p>Notes: >-<pre><<reserves.reserve_id>>=<<reserves.reservenotes>></pre> >+<pre><<holds.id>>=<<holds.notes>></pre> > </p> > EOF > >@@ -606,10 +606,10 @@ EOF > <ul> > <li>[% item.barcode %]</li> > <li>[% item.itemcallnumber %]</li> >- <li>[% hold.waitingdate | \$KohaDates %]</li> >+ <li>[% hold.waiting_date | \$KohaDates %]</li> > </ul> > <p>Notes: >-<pre>[% hold.reserve_id %]=[% hold.reservenotes %]</pre> >+<pre>[% hold.id %]=[% hold.notes %]</pre> > </p> > EOF > >diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t >index e748f115f4..9c81c7b584 100755 >--- a/t/db_dependent/Reserves.t >+++ b/t/db_dependent/Reserves.t >@@ -123,7 +123,7 @@ my ($status, $reserve, $all_reserves) = CheckReserves($item->itemnumber, $barcod > > is($status, "Reserved", "CheckReserves Test 1"); > >-ok(exists($reserve->{reserve_id}), 'CheckReserves() include reserve_id in its response'); >+ok(exists($reserve->{id}), 'CheckReserves() include reserve_id in its response'); > > ($status, $reserve, $all_reserves) = CheckReserves($item->itemnumber); > is($status, "Reserved", "CheckReserves Test 2"); >@@ -267,14 +267,14 @@ ModReserveAffect($itemnum_cpl, $requesters{$branch_3}, 0); > > # Now it should have different priorities. > my $biblio = Koha::Biblios->find( $bibnum2 ); >-my $holds = $biblio->holds({}, { order_by => 'reserve_id' });; >+my $holds = $biblio->holds({ completed => 0 }, { order_by => 'id' });; > is($holds->next->priority, 0, 'Item is correctly waiting'); > is($holds->next->priority, 1, 'Item is correctly priority 1'); > is($holds->next->priority, 2, 'Item is correctly priority 2'); > >-my @reserves = Koha::Holds->search({ borrowernumber => $requesters{$branch_3} })->waiting(); >+my @reserves = Koha::Holds->search({ patron_id => $requesters{$branch_3} })->waiting(); > is( @reserves, 1, 'GetWaiting got only the waiting reserve' ); >-is( $reserves[0]->borrowernumber(), $requesters{$branch_3}, 'GetWaiting got the reserve for the correct borrower' ); >+is( $reserves[0]->patron_id(), $requesters{$branch_3}, 'GetWaiting got the reserve for the correct borrower' ); > > > $dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum2)); >@@ -312,7 +312,7 @@ my $messages; > # the one placed by the CPL patron, as the other two patron's hold > # requests cannot be filled by that item per policy. > (undef, $messages, undef, undef) = AddReturn('bug10272_CPL', $branch_2); >-is( $messages->{ResFound}->{borrowernumber}, >+is( $messages->{ResFound}->{patron_id}, > $requesters{$branch_1}, > 'restrictive library\'s items only fill requests by own patrons (bug 10272)'); > >@@ -324,19 +324,18 @@ is( $messages->{ResFound}->{borrowernumber}, > t::lib::Mocks::mock_preference( 'LocalHoldsPriority', '' ); > > (undef, $messages, undef, undef) = AddReturn('bug10272_FPL', $branch_2); >-is( $messages->{ResFound}->{borrowernumber}, >+is( $messages->{ResFound}->{patron_id}, > $requesters{$branch_3}, > 'for generous library, its items fill first hold request in line (bug 10272)'); > > $biblio = Koha::Biblios->find( $biblionumber ); > $holds = $biblio->holds; > is($holds->count, 1, "Only one reserves for this biblio"); >-$holds->next->reserve_id; > > # Tests for bug 9761 (ConfirmFutureHolds): new CheckReserves lookahead parameter, and corresponding change in AddReturn > # Note that CheckReserve uses its lookahead parameter and does not check ConfirmFutureHolds pref (it should be passed if needed like AddReturn does) > # Test 9761a: Add a reserve without date, CheckReserve should return it >-$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum)); >+$dbh->do("DELETE FROM holds WHERE biblio_id=?",undef,($bibnum)); > AddReserve( > { > branchcode => $branch_1, >@@ -414,7 +413,7 @@ ok(defined($letter), 'can successfully generate hold slip (bug 10949)'); > > # Tests for bug 9788: Does Koha::Item->current_holds return a future wait? > # 9788a: current_holds does not return future next available hold >-$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum)); >+$dbh->do("DELETE FROM holds WHERE biblio_id=?",undef,($bibnum)); > t::lib::Mocks::mock_preference('ConfirmFutureHolds', 2); > t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1); > $resdate= dt_from_string(); >@@ -432,10 +431,10 @@ AddReserve( > > $holds = $item->current_holds; > my $dtf = Koha::Database->new->schema->storage->datetime_parser; >-my $future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } ); >+my $future_holds = $holds->search({ created_date => { '>' => $dtf->format_date( dt_from_string ) } } ); > is( $future_holds->count, 0, 'current_holds does not return a future next available hold'); > # 9788b: current_holds does not return future item level hold >-$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum)); >+$dbh->do("DELETE FROM holds WHERE biblio_id=?",undef,($bibnum)); > AddReserve( > { > branchcode => $branch_1, >@@ -446,15 +445,15 @@ AddReserve( > itemnumber => $item->itemnumber, > } > ); #item level hold >-$future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } ); >+$future_holds = $holds->search({ created_date => { '>' => $dtf->format_date( dt_from_string ) } } ); > is( $future_holds->count, 0, 'current_holds does not return a future item level hold' ); > # 9788c: current_holds returns future wait (confirmed future hold) > ModReserveAffect( $item->itemnumber, $requesters{$branch_1} , 0); #confirm hold >-$future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } ); >+$future_holds = $holds->search({ created_date => { '>' => $dtf->format_date( dt_from_string ) } } ); > is( $future_holds->count, 1, 'current_holds returns a future wait (confirmed future hold)' ); > # End of tests for bug 9788 > >-$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum)); >+$dbh->do("DELETE FROM holds WHERE biblio_id=?",undef,($bibnum)); > # Tests for CalculatePriority (bug 8918) > my $p = C4::Reserves::CalculatePriority($bibnum2); > is($p, 4, 'CalculatePriority should now return priority 4'); >@@ -469,7 +468,7 @@ AddReserve( > $p = C4::Reserves::CalculatePriority($bibnum2); > is($p, 5, 'CalculatePriority should now return priority 5'); > #some tests on bibnum >-$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum)); >+$dbh->do("DELETE FROM holds WHERE biblio_id=?",undef,($bibnum)); > $p = C4::Reserves::CalculatePriority($bibnum); > is($p, 1, 'CalculatePriority should now return priority 1'); > #add a new reserve and confirm it to waiting >@@ -519,7 +518,7 @@ is($p, 3, 'CalculatePriority should now return priority 3'); > # End of tests for bug 8918 > > # Tests for cancel reserves by users from OPAC. >-$dbh->do('DELETE FROM reserves', undef, ($bibnum)); >+$dbh->do('DELETE FROM holds', undef, ($bibnum)); > AddReserve( > { > branchcode => $branch_1, >@@ -534,9 +533,9 @@ is( CanReserveBeCanceledFromOpac(), undef, > 'CanReserveBeCanceledFromOpac should return undef if called without any parameter' > ); > is( >- CanReserveBeCanceledFromOpac( $canres->{resserve_id} ), >+ CanReserveBeCanceledFromOpac( $canres->{id} ), > undef, >- 'CanReserveBeCanceledFromOpac should return undef if called without the reserve_id' >+ 'CanReserveBeCanceledFromOpac should return undef if called without the id' > ); > is( > CanReserveBeCanceledFromOpac( undef, $requesters{CPL} ), >@@ -544,18 +543,18 @@ is( > 'CanReserveBeCanceledFromOpac should return undef if called without borrowernumber' > ); > >-my $cancancel = CanReserveBeCanceledFromOpac($canres->{reserve_id}, $requesters{$branch_1}); >+my $cancancel = CanReserveBeCanceledFromOpac($canres->{id}, $requesters{$branch_1}); > is($cancancel, 1, 'Can user cancel its own reserve'); > >-$cancancel = CanReserveBeCanceledFromOpac($canres->{reserve_id}, $requesters{$branch_2}); >+$cancancel = CanReserveBeCanceledFromOpac($canres->{id}, $requesters{$branch_2}); > is($cancancel, 0, 'Other user cant cancel reserve'); > > ModReserveAffect($item->itemnumber, $requesters{$branch_1}, 1); >-$cancancel = CanReserveBeCanceledFromOpac($canres->{reserve_id}, $requesters{$branch_1}); >+$cancancel = CanReserveBeCanceledFromOpac($canres->{id}, $requesters{$branch_1}); > is($cancancel, 0, 'Reserve in transfer status cant be canceled'); > >-$dbh->do('DELETE FROM reserves', undef, ($bibnum)); >-is( CanReserveBeCanceledFromOpac($canres->{resserve_id}, $requesters{$branch_1}), undef, >+$dbh->do('DELETE FROM holds', undef, ($bibnum)); >+is( CanReserveBeCanceledFromOpac($canres->{id}, $requesters{$branch_1}), undef, > 'Cannot cancel a deleted hold' ); > > AddReserve( >@@ -569,7 +568,7 @@ AddReserve( > (undef, $canres, undef) = CheckReserves($item->itemnumber); > > ModReserveAffect($item->itemnumber, $requesters{$branch_1}, 0); >-$cancancel = CanReserveBeCanceledFromOpac($canres->{reserve_id}, $requesters{$branch_1}); >+$cancancel = CanReserveBeCanceledFromOpac($canres->{id}, $requesters{$branch_1}); > is($cancancel, 0, 'Reserve in waiting status cant be canceled'); > > # End of tests for bug 12876 >@@ -637,7 +636,7 @@ Koha::CirculationRules->set_rules( > > # tests for MoveReserve in relation to ConfirmFutureHolds (BZ 14526) > # hold from A pos 1, today, no fut holds: MoveReserve should fill it >-$dbh->do('DELETE FROM reserves', undef, ($bibnum)); >+$dbh->do('DELETE FROM holds'); > t::lib::Mocks::mock_preference('ConfirmFutureHolds', 0); > t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1); > AddReserve( >@@ -658,7 +657,7 @@ AddReserve( > borrowernumber => $borrowernumber, > biblionumber => $bibnum, > priority => 1, >- found => 'W', >+ found => 'waiting', > } > ); > MoveReserve( $item->itemnumber, $borrowernumber ); >@@ -680,7 +679,7 @@ AddReserve( > MoveReserve( $item->itemnumber, $borrowernumber ); > ($status)=CheckReserves( $item->itemnumber, undef, 1 ); > is( $status, 'Reserved', 'MoveReserve did not fill future hold'); >-$dbh->do('DELETE FROM reserves', undef, ($bibnum)); >+$dbh->do('DELETE FROM holds', undef, ($bibnum)); > # hold from A pos 1, tomorrow, fut holds=2: MoveReserve should fill it > t::lib::Mocks::mock_preference('ConfirmFutureHolds', 2); > AddReserve( >@@ -724,7 +723,7 @@ AddReserve( > MoveReserve( $item->itemnumber, $borrowernumber ); > ($status)=CheckReserves( $item->itemnumber, undef, 3 ); > is( $status, 'Reserved', 'MoveReserve did not fill future hold of 3 days'); >-$dbh->do('DELETE FROM reserves', undef, ($bibnum)); >+$dbh->do('DELETE FROM holds', undef, ($bibnum)); > > $cache->clear_from_cache("MarcStructure-0-$frameworkcode"); > $cache->clear_from_cache("MarcStructure-1-$frameworkcode"); >@@ -832,13 +831,13 @@ subtest 'ReservesNeedReturns' => sub { > t::lib::Mocks::mock_preference('ReservesNeedReturns', 1); # Test with feature disabled > my $hold = place_item_hold( $patron, $item, $library, $priority ); > is( $hold->priority, $priority, 'If ReservesNeedReturns is 1, priority must not have been set to changed' ); >- is( $hold->found, undef, 'If ReservesNeedReturns is 1, found must not have been set waiting' ); >+ is( $hold->status, 'placed', 'If ReservesNeedReturns is 1, status must not have been set waiting' ); > $hold->delete; > >- t::lib::Mocks::mock_preference('ReservesNeedReturns', 0); # '0' means 'Automatically mark a hold as found and waiting' >+ t::lib::Mocks::mock_preference('ReservesNeedReturns', 0); # '0' means 'Automatically mark a hold as status and waiting' > $hold = place_item_hold( $patron, $item, $library, $priority ); > is( $hold->priority, 0, 'If ReservesNeedReturns is 0 and no other status, priority must have been set to 0' ); >- is( $hold->found, 'W', 'If ReservesNeedReturns is 0 and no other status, found must have been set waiting' ); >+ is( $hold->status, 'waiting', 'If ReservesNeedReturns is 0 and no other status, status must have been set waiting' ); > $hold->delete; > > $item->onloan('2010-01-01')->store; >@@ -854,11 +853,11 @@ subtest 'ReservesNeedReturns' => sub { > t::lib::Mocks::mock_preference('AllowHoldsOnDamagedItems', 1); # '0' means damaged holds not allowed > $hold = place_item_hold( $patron, $item, $library, $priority ); > is( $hold->priority, 0, 'If ReservesNeedReturns is 0 and damaged holds allowed, priority must have been set to 0' ); >- is( $hold->found, 'W', 'If ReservesNeedReturns is 0 and damaged holds allowed, found must have been set waiting' ); >+ is( $hold->status, 'waiting', 'If ReservesNeedReturns is 0 and damaged holds allowed, status must have been set waiting' ); > $hold->delete; > > my $hold_1 = place_item_hold( $patron, $item, $library, $priority ); >- is( $hold_1->found, 'W', 'First hold on item is set to waiting with ReservesNeedReturns set to 0' ); >+ is( $hold_1->status, 'waiting', 'First hold on item is set to waiting with ReservesNeedReturns set to 0' ); > is( $hold_1->priority, 0, 'First hold on item is set to waiting with ReservesNeedReturns set to 0' ); > $hold = place_item_hold( $patron_2, $item, $library, $priority ); > is( $hold->priority, 1, 'If ReservesNeedReturns is 0 but item already on hold priority must be set to 1' ); >@@ -875,21 +874,21 @@ subtest 'ReservesNeedReturns' => sub { > }); > $item->damaged(0)->store; > $hold = place_item_hold( $patron, $item, $library, $priority ); >- is( $hold->found, undef, 'If ReservesNeedReturns is 0 but item in transit the hold must not be set to waiting' ); >+ is( $hold->status, 'placed', 'If ReservesNeedReturns is 0 but item in transit the hold must not be set to waiting' ); > is( $hold->priority, 1, 'If ReservesNeedReturns is 0 but item in transit the hold must not be set to waiting' ); > $hold->delete; > $transfer->delete; > > $hold = place_item_hold( $patron, $item, $library, $priority ); > is( $hold->priority, 0, 'If ReservesNeedReturns is 0 and no other status, priority must have been set to 0' ); >- is( $hold->found, 'W', 'If ReservesNeedReturns is 0 and no other status, found must have been set waiting' ); >+ is( $hold->status, 'waiting', 'If ReservesNeedReturns is 0 and no other status, found must have been set waiting' ); > $hold_1 = place_item_hold( $patron, $item, $library, $priority ); > is( $hold_1->priority, 1, 'If ReservesNeedReturns is 0 but item has a hold priority is 1' ); >- $hold_1->suspend(1)->store; # We suspend the hold >+ $hold_1->suspended(1)->store; # We suspend the hold > $hold->delete; # Delete the waiting hold > $hold = place_item_hold( $patron, $item, $library, $priority ); > is( $hold->priority, 0, 'If ReservesNeedReturns is 0 and other hold(s) suspended, priority must have been set to 0' ); >- is( $hold->found, 'W', 'If ReservesNeedReturns is 0 and other hold(s) suspended, found must have been set waiting' ); >+ is( $hold->status, 'waiting', 'If ReservesNeedReturns is 0 and other hold(s) suspended, found must have been set waiting' ); > > > >@@ -935,6 +934,9 @@ subtest 'reserves.item_level_hold' => sub { > > subtest 'item level hold' => sub { > plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ > my $reserve_id = AddReserve( > { > branchcode => $item->homebranch, >@@ -946,20 +948,19 @@ subtest 'reserves.item_level_hold' => sub { > ); > > my $hold = Koha::Holds->find($reserve_id); >- is( $hold->item_level_hold, 1, 'item_level_hold should be set when AddReserve is called with a specific item' ); >+ is( $hold->item_level, 1, 'item_level should be set when AddReserve is called with a specific item' ); > >- # Mark it waiting >- ModReserveAffect( $item->itemnumber, $patron->borrowernumber, 1 ); >+ ModReserveAffect( $item->itemnumber, $patron->borrowernumber ); > > # Revert the waiting status > C4::Reserves::RevertWaitingStatus( > { itemnumber => $item->itemnumber } ); > >- $hold = Koha::Holds->find($reserve_id); >+ $hold->discard_changes; > >- is( $hold->itemnumber, $item->itemnumber, 'Itemnumber should not be removed when the waiting status is revert' ); >+ is( $hold->item_id, $item->itemnumber, 'Itemnumber should not be removed when the waiting status is revert' ); > >- $hold->delete; # cleanup >+ $schema->storage->txn_rollback; > }; > > subtest 'biblio level hold' => sub { >@@ -974,19 +975,19 @@ subtest 'reserves.item_level_hold' => sub { > ); > > my $hold = Koha::Holds->find($reserve_id); >- is( $hold->item_level_hold, 0, 'item_level_hold should not be set when AddReserve is called without a specific item' ); >+ is( $hold->item_level, 0, 'item_level should not be set when AddReserve is called without a specific item' ); > > # Mark it waiting >- ModReserveAffect( $item->itemnumber, $patron->borrowernumber, 1 ); >+ ModReserveAffect( $item->itemnumber, $patron->borrowernumber ); > > $hold = Koha::Holds->find($reserve_id); >- is( $hold->itemnumber, $item->itemnumber, 'Itemnumber should be set on hold confirmation' ); >+ is( $hold->item_id, $item->itemnumber, 'Itemnumber should be set on hold confirmation' ); > > # Revert the waiting status > C4::Reserves::RevertWaitingStatus( { itemnumber => $item->itemnumber } ); > > $hold = Koha::Holds->find($reserve_id); >- is( $hold->itemnumber, undef, 'Itemnumber should be removed when the waiting status is revert' ); >+ is( $hold->item_id, undef, 'Itemnumber should be removed when the waiting status is revert' ); > > $hold->delete; > }; >@@ -1024,16 +1025,16 @@ subtest 'MoveReserve additional test' => sub { > itemnumber => $item_1->itemnumber, > } > ); >- is($patron_1->holds->next()->reserve_id, $reserve_1, "The 1st patron has a hold"); >- is($patron_2->holds->next()->reserve_id, $reserve_2, "The 2nd patron has a hold"); >+ is($patron_1->holds->next()->id, $reserve_1, "The 1st patron has a hold"); >+ is($patron_2->holds->next()->id, $reserve_2, "The 2nd patron has a hold"); > > # Fake the holds queue > $dbh->do(q{INSERT INTO hold_fill_targets VALUES (?, ?, ?, ?, ?,?)},undef,($patron_1->borrowernumber,$biblio->biblionumber,$item_1->itemnumber,$item_1->homebranch,0,$reserve_1)); > > # The 2nd hold should be filed even if the item is preselected for the first hold > MoveReserve($item_1->itemnumber,$patron_2->borrowernumber); >- is($patron_2->holds->count, 0, "The 2nd patrons no longer has a hold"); >- is($patron_2->old_holds->next()->reserve_id, $reserve_2, "The 2nd patrons hold was filled and moved to old holds"); >+ is($patron_2->holds({ completed => 0 })->count, 0, "The 2nd patrons no longer has a hold"); >+ is($patron_2->holds({ completed => 1 })->next()->id, $reserve_2, "The 2nd patrons hold was filled and moved to old holds"); > > }; > >@@ -1089,18 +1090,12 @@ subtest 'CheckReserves additional tests' => sub { > { > class => "Koha::Holds", > value => { >- found => undef, > priority => 1, >- itemnumber => undef, >- biblionumber => $item->biblionumber, >- waitingdate => undef, >- cancellationdate => undef, >- item_level_hold => 0, >- lowestPriority => 0, >- expirationdate => undef, >- suspend_until => undef, >- suspend => 0, >- itemtype => undef, >+ item_id => undef, >+ biblio_id => $item->biblionumber, >+ item_level => 0, >+ lowest_priority => 0, >+ expiration_date => undef, > } > } > ); >@@ -1108,19 +1103,13 @@ subtest 'CheckReserves additional tests' => sub { > { > class => "Koha::Holds", > value => { >- found => undef, > priority => 2, >- biblionumber => $item->biblionumber, >- borrowernumber => $reserve1->borrowernumber, >- itemnumber => undef, >- waitingdate => undef, >- cancellationdate => undef, >- item_level_hold => 0, >- lowestPriority => 0, >- expirationdate => undef, >- suspend_until => undef, >- suspend => 0, >- itemtype => undef, >+ item_id => $item->biblionumber, >+ patron_id => $reserve1->patron_id, >+ item_id => undef, >+ suspended_until => undef, >+ suspended => 0, >+ item_type => undef, > } > } > ); >@@ -1129,8 +1118,8 @@ subtest 'CheckReserves additional tests' => sub { > { > source => 'TmpHoldsqueue', > value => { >- borrowernumber => $reserve1->borrowernumber, >- biblionumber => $reserve1->biblionumber, >+ borrowernumber => $reserve1->patron_id, >+ biblionumber => $reserve1->biblio_id, > } > } > ); >@@ -1138,23 +1127,20 @@ subtest 'CheckReserves additional tests' => sub { > { > source => 'HoldFillTarget', > value => { >- borrowernumber => $reserve1->borrowernumber, >- biblionumber => $reserve1->biblionumber, >+ borrowernumber => $reserve1->patron_id, >+ biblionumber => $reserve1->biblio_id, > itemnumber => $item->itemnumber, > item_level_request => 0, > } > } > ); > >- ModReserveAffect( $item->itemnumber, $reserve1->borrowernumber, 1, >- $reserve1->reserve_id ); >- my ( $status, $matched_reserve, $possible_reserves ) = >- CheckReserves( $item->itemnumber ); >+ ModReserveAffect( $item->itemnumber, $reserve1->patron_id, 1, $reserve1->id ); >+ my ( $status, $matched_reserve, $possible_reserves ) = CheckReserves( $item->itemnumber ); > > is( $status, 'Transferred', "We found a reserve" ); >- is( $matched_reserve->{reserve_id}, >- $reserve1->reserve_id, "We got the Transit reserve" ); >- is( scalar @$possible_reserves, 2, 'We do get both reserves' ); >+ is( $matched_reserve->{id}, $reserve1->id, 'We got the Transit reserve' ); >+ is( scalar @$possible_reserves, 2, 'We do get both reserves' ); > > my $patron_B = $builder->build_object({ class => "Koha::Patrons" }); > my $item_A = $builder->build_sample_item; >@@ -1327,7 +1313,7 @@ subtest 'ModReserveAffect logging' => sub { > ok( $hold->is_waiting, 'Hold has been set waiting' ); > isnt( $hold->timestamp, $previous_timestamp, 'The timestamp has been modified' ); > >- my $log = Koha::ActionLogs->search({ module => 'HOLDS', action => 'MODIFY', object => $hold->reserve_id })->next; >+ my $log = Koha::ActionLogs->search({ module => 'HOLDS', action => 'MODIFY', object => $hold->id })->next; > my $expected = sprintf q{'timestamp' => '%s'}, $hold->timestamp; > like( $log->info, qr{$expected}, 'Timestamp logged is the current one' ); > }; >diff --git a/t/db_dependent/Reserves/AutoUnsuspendReserves.t b/t/db_dependent/Reserves/AutoUnsuspendReserves.t >index 4d24794825..3952986327 100755 >--- a/t/db_dependent/Reserves/AutoUnsuspendReserves.t >+++ b/t/db_dependent/Reserves/AutoUnsuspendReserves.t >@@ -43,10 +43,10 @@ subtest 'AutoUnsuspendReserves test' => sub { > my $hold_1 = $builder->build_object({ > class => 'Koha::Holds', > value => { >- expirationdate => undef, >- cancellationdate => undef, >+ expiration_date => undef, >+ completed_date => undef, > priority => 5, >- found => undef, >+ status => 'placed', > }, > }); > >@@ -56,10 +56,10 @@ subtest 'AutoUnsuspendReserves test' => sub { > my $hold_2 = $builder->build_object({ > class => 'Koha::Holds', > value => { >- expirationdate => undef, >- cancellationdate => undef, >+ expiration_date => undef, >+ completed_date => undef, > priority => 6, >- found => undef, >+ status => 'placed', > }, > }); > >@@ -84,11 +84,11 @@ subtest 'AutoUnsuspendReserves test' => sub { > my $hold_3 = $builder->build_object( > { class => 'Koha::Holds', > value => { >- expirationdate => undef, >- cancellationdate => undef, >- priority => 5, >- found => undef, >- suspend_until => undef, >+ expiration_date => undef, >+ completed_date => undef, >+ priority => 5, >+ status => 'placed', >+ suspended_until_date => undef, > } > } > ); >@@ -121,10 +121,10 @@ subtest 'AutoUnsuspendReserves test' => sub { > my $hold_4 = $builder->build_object( > { class => 'Koha::Holds', > value => { >- expirationdate => undef, >- cancellationdate => undef, >- priority => 5, >- found => undef >+ expiration_date => undef, >+ completed_date => undef, >+ priority => 5, >+ status => 'placed' > } > } > ); >@@ -137,7 +137,7 @@ subtest 'AutoUnsuspendReserves test' => sub { > AutoUnsuspendReserves(); > > $hold_4->discard_changes; >- ok(!defined($hold_4->suspend_until), 'Hold suspended until today should be unsuspended.'); >+ ok(!defined($hold_4->suspended_until_date), 'Hold suspended until today should be unsuspended.'); > > my $new_logs_count = $schema->resultset('ActionLog') > ->search( { module => 'HOLDS', action => 'RESUME' } )->count; >diff --git a/t/db_dependent/Reserves/CancelExpiredReserves.t b/t/db_dependent/Reserves/CancelExpiredReserves.t >index 27a583b6f1..67c6d8d723 100755 >--- a/t/db_dependent/Reserves/CancelExpiredReserves.t >+++ b/t/db_dependent/Reserves/CancelExpiredReserves.t >@@ -16,7 +16,7 @@ my $schema = Koha::Database->new->schema; > $schema->storage->txn_begin; > > subtest 'CancelExpiredReserves tests incl. holidays' => sub { >- plan tests => 4; >+ plan tests => 6; > > my $builder = t::lib::TestBuilder->new(); > >@@ -33,52 +33,62 @@ subtest 'CancelExpiredReserves tests incl. holidays' => sub { > $reserve1_expirationdate->add(days => 1); > > # Reserve not expired >- my $reserve1 = $builder->build({ >- source => 'Reserve', >- value => { >- reservedate => $reserve_reservedate, >- expirationdate => $reserve1_expirationdate, >- cancellationdate => undef, >- priority => 0, >- found => 'W', >- }, >- }); >+ my $reserve1 = $builder->build_object( >+ { >+ class => 'Koha::Holds', >+ value => { >+ created_date => $reserve_reservedate, >+ expiration_date => $reserve1_expirationdate, >+ completed_date => undef, >+ priority => 0, >+ status => 'waiting', >+ completed => 0, >+ }, >+ } >+ ); > > CancelExpiredReserves(); >- my $r1 = Koha::Holds->find($reserve1->{reserve_id}); >+ my $r1 = Koha::Holds->find($reserve1->id); > ok($r1, 'Reserve 1 should not be canceled.'); > > my $reserve2_expirationdate = $today->clone; > $reserve2_expirationdate->subtract(days => 1); > > # Reserve expired >- my $reserve2 = $builder->build({ >- source => 'Reserve', >- value => { >- reservedate => $reserve_reservedate, >- expirationdate => $reserve2_expirationdate, >- cancellationdate => undef, >- priority => 0, >- found => 'W', >- }, >- }); >+ my $reserve2 = $builder->build_object( >+ { >+ class => 'Koha::Holds', >+ value => { >+ created_date => $reserve_reservedate, >+ expiration_date => $reserve2_expirationdate, >+ completed_date => undef, >+ priority => 0, >+ status => 'waiting', >+ completed => 0, >+ }, >+ } >+ ); > > CancelExpiredReserves(); >- my $r2 = Koha::Holds->find($reserve2->{reserve_id}); >- is($r2, undef,'reserve 2 should be canceled.'); >+ my $r2 = Koha::Holds->find($reserve2->id); >+ is(ref($r2), 'Koha::Hold', 'reserve 2 is still there.'); >+ is($r2->status, 'cancelled', 'reserve 2 should be canceled.'); >+ is($r2->completed, 1, 'reserve 2 should be completed.'); > > # Reserve expired on holiday >- my $reserve3 = $builder->build({ >- source => 'Reserve', >- value => { >- reservedate => $reserve_reservedate, >- expirationdate => $reserve2_expirationdate, >- branchcode => 'LIB1', >- cancellationdate => undef, >- priority => 0, >- found => 'W', >- }, >- }); >+ my $reserve3 = $builder->build_object( >+ { >+ class => 'Koha::Holds', >+ value => { >+ created_date => $reserve_reservedate, >+ expiration_date => $reserve2_expirationdate, >+ pickup_library_id => 'LIB1', >+ completed_date => undef, >+ priority => 0, >+ status => 'waiting', >+ }, >+ } >+ ); > > Koha::Caches->get_instance()->flush_all(); > my $holiday = $builder->build({ >@@ -94,13 +104,13 @@ subtest 'CancelExpiredReserves tests incl. holidays' => sub { > }); > > CancelExpiredReserves(); >- my $r3 = Koha::Holds->find($reserve3->{reserve_id}); >- ok($r3,'Reserve 3 should not be canceled.'); >+ $reserve3->discard_changes; >+ is($reserve3->status, 'waiting','Reserve 3 should not be canceled.'); > > t::lib::Mocks::mock_preference('ExpireReservesOnHolidays', 1); > CancelExpiredReserves(); >- $r3 = Koha::Holds->find($reserve3->{reserve_id}); >- is($r3, undef,'Reserve 3 should be canceled.'); >+ $reserve3->discard_changes; >+ is($reserve3->status, 'cancelled', 'Reserve 3 should be cancelled.'); > }; > > subtest 'Test handling of waiting reserves by CancelExpiredReserves' => sub { >@@ -119,45 +129,51 @@ subtest 'Test handling of waiting reserves by CancelExpiredReserves' => sub { > my $expdate = dt_from_string->add( days => -2 ); > my $notexpdate = dt_from_string->add( days => 2 ); > >- my $hold1 = Koha::Hold->new({ >- branchcode => $branchcode, >- borrowernumber => $borrowernumber, >- biblionumber => $item->biblionumber, >- priority => 1, >- reservedate => $resdate, >- expirationdate => $notexpdate, >- found => undef, >- })->store; >- >- my $hold2 = Koha::Hold->new({ >- branchcode => $branchcode, >- borrowernumber => $borrowernumber, >- biblionumber => $item->biblionumber, >- priority => 2, >- reservedate => $resdate, >- expirationdate => $expdate, >- found => undef, >- })->store; >- >- my $hold3 = Koha::Hold->new({ >- branchcode => $branchcode, >- borrowernumber => $borrowernumber, >- biblionumber => $item->biblionumber, >- itemnumber => $itemnumber, >- priority => 0, >- reservedate => $resdate, >- expirationdate => $expdate, >- found => 'W', >- })->store; >+ my $hold1 = Koha::Hold->new( >+ { >+ pickup_library_id => $branchcode, >+ patron_id => $borrowernumber, >+ biblio_id => $item->biblionumber, >+ priority => 1, >+ created_date => $resdate, >+ expiration_date => $notexpdate, >+ status => 'placed', >+ } >+ )->store; >+ >+ my $hold2 = Koha::Hold->new( >+ { >+ pickup_library_id => $branchcode, >+ patron_id => $borrowernumber, >+ biblio_id => $item->biblionumber, >+ priority => 2, >+ created_date => $resdate, >+ expiration_date => $expdate, >+ status => 'placed', >+ } >+ )->store; >+ >+ my $hold3 = Koha::Hold->new( >+ { >+ pickup_library_id => $branchcode, >+ patron_id => $borrowernumber, >+ biblio_id => $item->biblionumber, >+ item_id => $itemnumber, >+ priority => 0, >+ created_date => $resdate, >+ expiration_date => $expdate, >+ status => 'waiting', >+ } >+ )->store; > > t::lib::Mocks::mock_preference( 'ExpireReservesMaxPickUpDelay', 0 ); > CancelExpiredReserves(); >- my $count1 = Koha::Holds->search->count; >+ my $count1 = Koha::Holds->search({ completed => 0 })->count; > is( $count1, 2, 'Only the non-waiting expired holds should be cancelled'); > > t::lib::Mocks::mock_preference( 'ExpireReservesMaxPickUpDelay', 1 ); > CancelExpiredReserves(); >- my $count2 = Koha::Holds->search->count; >+ my $count2 = Koha::Holds->search({ completed => 0 })->count; > is( $count2, 1, 'Also the waiting expired hold should be cancelled now'); > > }; >@@ -169,58 +185,66 @@ subtest 'Test handling of in transit reserves by CancelExpiredReserves' => sub { > > t::lib::Mocks::mock_preference( 'ExpireReservesMaxPickUpDelay', 1 ); > my $expdate = dt_from_string->add( days => -2 ); >- my $reserve = $builder->build({ >- source => 'Reserve', >+ my $reserve = $builder->build_object({ >+ class => 'Koha::Holds', > value => { >- expirationdate => '2018-01-01', >- found => 'T', >- cancellationdate => undef, >- suspend => 0, >- suspend_until => undef >+ expiration_date => '2018-01-01', >+ status => 'in_transit', >+ suspended => 0, >+ completed => 0, >+ cancellation_date => undef, >+ suspended_until_date => undef, > } > }); >- my $count = Koha::Holds->search->count; >+ >+ my $active = Koha::Holds->search({ completed => 0 }); >+ my $count = $active->count; >+ > CancelExpiredReserves(); >- is(Koha::Holds->search->count, $count-1, "Transit hold is cancelled if ExpireReservesMaxPickUpDelay set"); >+ is($active->count, $count-1, "Transit hold is cancelled if ExpireReservesMaxPickUpDelay set"); > > t::lib::Mocks::mock_preference( 'ExpireReservesMaxPickUpDelay', 0 ); >- my $reserve2 = $builder->build({ >- source => 'Reserve', >+ my $reserve2 = $builder->build_object({ >+ class => 'Koha::Holds', > value => { >- expirationdate => '2018-01-01', >- found => 'T', >- cancellationdate => undef, >- suspend => 0, >- suspend_until => undef >+ expiration_date => '2018-01-01', >+ status => 'in_transit', >+ cancellation_date => undef, >+ suspended => 0, >+ suspended_until_date => undef, >+ completed => 0, > } > }); > CancelExpiredReserves(); >- is(Koha::Holds->search->count, $count-1, "Transit hold is cancelled if ExpireReservesMaxPickUpDelay unset"); >+ is($active->count, $count-1, "Transit hold is cancelled if ExpireReservesMaxPickUpDelay unset"); > > }; > > subtest 'Test handling of cancellation reason if passed' => sub { >- plan tests => 2; >+ plan tests => 3; > > my $builder = t::lib::TestBuilder->new(); > > my $expdate = dt_from_string->add( days => -2 ); >- my $reserve = $builder->build({ >- source => 'Reserve', >- value => { >- expirationdate => '2018-01-01', >- found => 'T', >- cancellationdate => undef, >- suspend => 0, >- suspend_until => undef >+ my $hold = $builder->build_object( >+ { class => 'Koha::Holds', >+ value => { >+ expiration_date => '2018-01-01', >+ status => 'in_transit', >+ cancellation_date => undef, >+ suspended => 0, >+ suspend_until_date => undef >+ } > } >- }); >- my $reserve_id = $reserve->{reserve_id}; >- my $count = Koha::Holds->search->count; >+ ); >+ >+ # Cancel the hold > CancelExpiredReserves("EXPIRED"); >- is(Koha::Holds->search->count, $count-1, "Hold is cancelled when reason is passed"); >- my $old_reserve = Koha::Old::Holds->find($reserve_id); >- is($old_reserve->cancellation_reason, 'EXPIRED', "Hold cancellation_reason was set correctly"); >+ $hold->discard_changes; >+ >+ is( $hold->status, 'cancelled', "Hold is cancelled when reason is passed"); >+ is( $hold->completed, 1, "Hold is completed"); >+ is( $hold->cancellation_reason, 'EXPIRED', "Hold cancellation_reason was set correctly"); > }; > > $schema->storage->txn_rollback; >diff --git a/t/db_dependent/Reserves/GetReserveFee.t b/t/db_dependent/Reserves/GetReserveFee.t >index f53f7c154f..701d9651de 100755 >--- a/t/db_dependent/Reserves/GetReserveFee.t >+++ b/t/db_dependent/Reserves/GetReserveFee.t >@@ -119,19 +119,19 @@ subtest 'Integration with AddReserve' => sub { > plan tests => 3; > > t::lib::Mocks::mock_preference('HoldFeeMode', 'not_always'); >- $dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); >+ $dbh->do( "DELETE FROM holds WHERE biblio_id=?", undef, $biblio->biblionumber ); > $dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->{borrowernumber} ); > addreserve( $patron1->{borrowernumber} ); > is( acctlines( $patron1->{borrowernumber} ), 0, 'not_always - No fee charged for patron 1 if not issued' ); > > t::lib::Mocks::mock_preference('HoldFeeMode', 'any_time_is_placed'); >- $dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); >+ $dbh->do( "DELETE FROM holds WHERE biblio_id=?", undef, $biblio->biblionumber ); > $dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->{borrowernumber} ); > addreserve( $patron1->{borrowernumber} ); > is( acctlines( $patron1->{borrowernumber} ), 1, 'any_time_is_placed - Patron should be always charged' ); > > t::lib::Mocks::mock_preference('HoldFeeMode', 'any_time_is_collected'); >- $dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); >+ $dbh->do( "DELETE FROM holds WHERE biblio_id=?", undef, $biblio->biblionumber ); > $dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->{borrowernumber} ); > addreserve( $patron1->{borrowernumber} ); > is( acctlines( $patron1->{borrowernumber} ), 0, 'any_time_is_collected - Patron should not be charged when placing a hold' ); >@@ -143,12 +143,12 @@ subtest 'Integration with AddReserve' => sub { > C4::Circulation::AddIssue( $patron2, $item1->barcode, '2015-12-31', 0, undef, 0, {} ); > > t::lib::Mocks::mock_preference('HoldFeeMode', 'not_always'); >- $dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); >+ $dbh->do( "DELETE FROM holds WHERE biblio_id=?", undef, $biblio->biblionumber ); > $dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->{borrowernumber} ); > addreserve( $patron1->{borrowernumber} ); > is( acctlines( $patron1->{borrowernumber} ), 0, 'not_always - Patron should not be charged if items are not all checked out' ); > >- $dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); >+ $dbh->do( "DELETE FROM holds WHERE biblio_id=?", undef, $biblio->biblionumber ); > $dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->{borrowernumber} ); > addreserve( $patron3->{borrowernumber} ); > addreserve( $patron1->{borrowernumber} ); >@@ -156,7 +156,7 @@ subtest 'Integration with AddReserve' => sub { > is( acctlines( $patron1->{borrowernumber} ), 1, 'not_always - Patron should be charged if all the items are not checked out and at least 1 hold is already placed' ); > > C4::Circulation::AddIssue( $patron3, $item2->barcode, '2015-12-31', 0, undef, 0, {} ); >- $dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); >+ $dbh->do( "DELETE FROM holds WHERE biblio_id=?", undef, $biblio->biblionumber ); > $dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->{borrowernumber} ); > addreserve( $patron1->{borrowernumber} ); > is( acctlines( $patron1->{borrowernumber} ), 1, 'not_always - Patron should be charged if all items are checked out' ); >@@ -167,7 +167,7 @@ subtest 'Integration with AddIssue' => sub { > plan tests => 5; > > $dbh->do( "DELETE FROM issues WHERE borrowernumber = ?", undef, $patron1->{borrowernumber} ); >- $dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); >+ $dbh->do( "DELETE FROM holds WHERE biblio_id=?", undef, $biblio->biblionumber ); > $dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->{borrowernumber} ); > > t::lib::Mocks::mock_preference('HoldFeeMode', 'not_always'); >diff --git a/t/db_dependent/Reserves/MultiplePerRecord.t b/t/db_dependent/Reserves/MultiplePerRecord.t >index 07f7ea9aba..96b5ec1cd1 100755 >--- a/t/db_dependent/Reserves/MultiplePerRecord.t >+++ b/t/db_dependent/Reserves/MultiplePerRecord.t >@@ -184,25 +184,25 @@ is( $max, 9, 'GetMaxPatronHoldsForRecord returns max of 9 because Library specif > > Koha::CirculationRules->delete(); > >-my $holds = Koha::Holds->search( { borrowernumber => $patron->{borrowernumber} } ); >+my $holds = Koha::Holds->search( { patron_id => $patron->{borrowernumber} } ); > is( $holds->forced_hold_level, undef, "No holds does not force an item or record level hold" ); > > # Test Koha::Holds::forced_hold_level > my $hold = Koha::Hold->new({ >- borrowernumber => $patron->{borrowernumber}, >- reservedate => '1981-06-10', >- biblionumber => $biblio->biblionumber, >- branchcode => $library->{branchcode}, >+ patron_id => $patron->{borrowernumber}, >+ created_date => '1981-06-10', >+ biblio_id => $biblio->biblionumber, >+ pickup_library_id => $library->{branchcode}, > priority => 1, > })->store(); > >-$holds = Koha::Holds->search( { borrowernumber => $patron->{borrowernumber} } ); >+$holds = Koha::Holds->search( { patron_id => $patron->{borrowernumber} } ); > is( $holds->forced_hold_level, 'record', "Record level hold forces record level holds" ); > >-$hold->itemnumber( $item1->itemnumber ); >+$hold->item_id( $item1->itemnumber ); > $hold->store(); > >-$holds = Koha::Holds->search( { borrowernumber => $patron->{borrowernumber} } ); >+$holds = Koha::Holds->search( { patron_id => $patron->{borrowernumber} } ); > is( $holds->forced_hold_level, 'item', "Item level hold forces item level holds" ); > > $hold->delete(); >@@ -247,7 +247,7 @@ ok( $hold_id, 'Second hold was placed' ); > $can = CanBookBeReserved($patron->{borrowernumber}, $biblio->biblionumber); > is( $can->{status}, 'tooManyHoldsForThisRecord', 'Third hold exceeds limit of holds per record' ); > >-Koha::Holds->find($hold_id)->found("W")->store; >+Koha::Holds->find($hold_id)->set_waiting; > $can = CanBookBeReserved($patron->{borrowernumber}, $biblio->biblionumber); > is( $can->{status}, 'tooManyHoldsForThisRecord', 'Third hold exceeds limit of holds per record' ); > >diff --git a/t/db_dependent/Reserves/ReserveSlip.t b/t/db_dependent/Reserves/ReserveSlip.t >index 03b5731644..a90f364a10 100755 >--- a/t/db_dependent/Reserves/ReserveSlip.t >+++ b/t/db_dependent/Reserves/ReserveSlip.t >@@ -31,7 +31,7 @@ $schema->storage->txn_begin; > > my $dbh = C4::Context->dbh; > $dbh->do(q|DELETE FROM letter|); >-$dbh->do(q|DELETE FROM reserves|); >+$dbh->do(q|DELETE FROM holds|); > > my $builder = t::lib::TestBuilder->new(); > my $library = $builder->build( >@@ -66,24 +66,25 @@ my $item2 = $builder->build_sample_item( > > my $hold1 = Koha::Hold->new( > { >- biblionumber => $biblio->biblionumber, >- itemnumber => $item1->itemnumber, >- waitingdate => '2000-01-01', >- borrowernumber => $patron->{borrowernumber}, >- branchcode => $library->{branchcode}, >+ biblio_id => $biblio->biblionumber, >+ item_id => $item1->itemnumber, >+ waiting_date => '2000-01-01', >+ patron_id => $patron->{borrowernumber}, >+ pickup_library_id => $library->{branchcode}, > } > )->store; > > my $hold2 = Koha::Hold->new( > { >- biblionumber => $biblio->biblionumber, >- itemnumber => $item2->itemnumber, >- waitingdate => '2000-01-01', >- borrowernumber => $patron->{borrowernumber}, >- branchcode => $library->{branchcode}, >+ biblio_id => $biblio->biblionumber, >+ item_id => $item2->itemnumber, >+ waiting_date => '2000-01-01', >+ patron_id => $patron->{borrowernumber}, >+ pickup_library_id => $library->{branchcode}, > } > )->store; > >+ > my $letter = $builder->build( > { > source => 'Letter', >@@ -101,13 +102,13 @@ my $letter = $builder->build( > is ( ReserveSlip(), undef, "No hold slip returned if invalid or undef borrowernumber and/or biblionumber" ); > is ( ReserveSlip({ > branchcode => $library->{branchcode}, >- reserve_id => $hold1->reserve_id, >+ reserve_id => $hold1->id, > })->{code}, > 'HOLD_SLIP', "Get a hold slip from library, patron and biblio" ); > > is (ReserveSlip({ > branchcode => $library->{branchcode}, >- reserve_id => $hold1->reserve_id, >+ reserve_id => $hold1->id, > })->{content}, > sprintf( "Hold found for %s: Please pick up %s with barcode %s at %s.", $patron->{firstname}, $biblio->title, $item1->barcode, $library->{branchcode}),"Hold slip contains correctly parsed content"); > >diff --git a/t/db_dependent/TestBuilder.t b/t/db_dependent/TestBuilder.t >index f97626c06b..c5ff46911d 100755 >--- a/t/db_dependent/TestBuilder.t >+++ b/t/db_dependent/TestBuilder.t >@@ -67,9 +67,13 @@ subtest 'Start with some trivial tests' => sub { > subtest 'Build all sources' => sub { > plan tests => 1; > >+ my $excluded_sources = { >+ Reserve => 1, # view >+ OldReserve => 1, # view >+ }; > my @sources = $builder->schema->sources; > my @source_in_failure; >- for my $source ( @sources ) { >+ for my $source ( grep { not $excluded_sources->{$_} } @sources ) { > my $res; > # Skip the source if it is a view > next if $schema->source($source)->isa('DBIx::Class::ResultSource::View'); >@@ -250,11 +254,11 @@ subtest 'Test build with NULL values' => sub { > is( $info->{is_nullable} && $item && !defined( $item->{barcode} ), 1, > 'Barcode can be NULL' ); > # Nullable FK >- $params = { source => 'Reserve', value => { itemnumber => undef }}; >- my $reserve = $builder->build( $params ); >- $info = $schema->source( 'Reserve' )->column_info( 'itemnumber' ); >- is( $reserve && $info->{is_nullable} && $info->{is_foreign_key} && >- !defined( $reserve->{itemnumber} ), 1, 'Nullable FK' ); >+ $params = { source => 'Hold', value => { item_id => undef }}; >+ my $hold = $builder->build( $params ); >+ $info = $schema->source( 'Hold' )->column_info( 'item_id' ); >+ is( $hold && $info->{is_nullable} && $info->{is_foreign_key} && >+ !defined( $hold->{item_id} ), 1, 'Nullable FK' ); > }; > > >@@ -396,6 +400,7 @@ subtest 'build_object() tests' => sub { > $module =~ s|^.*/(Koha.*)\.pm$|$1|; > $module =~ s|/|::|g; > next if $module eq 'Koha::Objects'; >+ next if $module eq 'Koha::Old::Holds'; #This is a view now > eval "require $module"; > my $object = $builder->build_object( { class => $module } ); > is( ref($object), $module->object_class, "Testing $module" ); >diff --git a/t/db_dependent/XSLT.t b/t/db_dependent/XSLT.t >index 521578947b..35d3bfd82e 100755 >--- a/t/db_dependent/XSLT.t >+++ b/t/db_dependent/XSLT.t >@@ -117,10 +117,11 @@ subtest 'buildKohaItemsNamespace status tests' => sub { > like($xml,qr{<status>In transit</status>},"In-transit status takes precedence over Damaged"); > > my $hold = $builder->build_object({ class => 'Koha::Holds', value => { >- biblionumber => $item->biblionumber, >- itemnumber => $item->itemnumber, >- found => 'W', >- priority => 0, >+ biblio_id => $item->biblionumber, >+ item_id => $item->itemnumber, >+ status => 'waiting', >+ priority => 0, >+ completed => 0, > } > }); > $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]); >diff --git a/t/db_dependent/api/v1/holds.t b/t/db_dependent/api/v1/holds.t >index 5abba54739..cfbe2b2b98 100755 >--- a/t/db_dependent/api/v1/holds.t >+++ b/t/db_dependent/api/v1/holds.t >@@ -162,8 +162,8 @@ my $post_data = { > expiration_date => output_pref( { dt => $expiration_date, dateformat => 'rfc3339', dateonly => 1 } ), > }; > my $patch_data = { >- priority => 2, >- suspended_until => output_pref( { dt => $suspended_until, dateformat => 'rfc3339' } ), >+ priority => 2, >+ suspended_until_date => output_pref( { dt => $suspended_until, dateformat => 'rfc3339' } ), > }; > > subtest "Test endpoints without authentication" => sub { >@@ -320,7 +320,7 @@ subtest 'test AllowHoldDateInFuture' => sub { > > plan tests => 6; > >- $dbh->do('DELETE FROM reserves'); >+ $dbh->do('DELETE FROM holds'); > > my $future_hold_date = DateTime->now->add(days => 10)->truncate( to => 'day' ); > >@@ -329,8 +329,8 @@ subtest 'test AllowHoldDateInFuture' => sub { > biblio_id => $biblio_1->biblionumber, > item_id => $item_1->itemnumber, > pickup_library_id => $branchcode, >- expiration_date => output_pref( { dt => $expiration_date, dateformat => 'rfc3339', dateonly => 1 } ), >- hold_date => output_pref( { dt => $future_hold_date, dateformat => 'rfc3339', dateonly => 1 } ), >+ expiration_date => output_pref({ dt => $expiration_date, dateformat => 'rfc3339', dateonly => 1 }), >+ created_date => output_pref({ dt => $future_hold_date, dateformat => 'rfc3339', dateonly => 1 }), > }; > > t::lib::Mocks::mock_preference( 'AllowHoldDateInFuture', 0 ); >@@ -349,7 +349,7 @@ subtest 'test AllowHoldDateInFuture' => sub { > > $t->post_ok( "//$userid_3:$password@/api/v1/holds" => json => $post_data ) > ->status_is(201) >- ->json_is('/hold_date', output_pref({ dt => $future_hold_date, dateformat => 'rfc3339', dateonly => 1 })); >+ ->json_is('/created_date', output_pref({ dt => $future_hold_date, dateformat => 'rfc3339', dateonly => 1 })); > }; > > $schema->storage->txn_rollback; >@@ -471,7 +471,12 @@ subtest 'suspend and resume tests' => sub { > > my $hold = $builder->build_object( > { class => 'Koha::Holds', >- value => { suspend => 0, suspend_until => undef, waitingdate => undef, found => undef } >+ value => { >+ suspended => 0, >+ waiting_date => undef, >+ suspended_until_date => undef, >+ completed => 0 >+ } > } > ); > >@@ -482,7 +487,7 @@ subtest 'suspend and resume tests' => sub { > $hold->discard_changes; # refresh object > > ok( $hold->is_suspended, 'Hold is suspended' ); >- $t->json_is('/end_date', undef, 'Hold suspension has no end date'); >+ $t->json_is('/suspended_until_date', undef, 'Hold suspension has no end date'); > > my $end_date = output_pref({ > dt => dt_from_string( undef ), >@@ -498,7 +503,7 @@ subtest 'suspend and resume tests' => sub { > $t->json_is( > '/end_date', > output_pref({ >- dt => dt_from_string( $hold->suspend_until ), >+ dt => dt_from_string( $hold->suspended_until_date ), > dateformat => 'rfc3339', > dateonly => 1 > }), >@@ -531,13 +536,13 @@ subtest 'suspend and resume tests' => sub { > > $t->post_ok( "//$userid:$password@/api/v1/holds/" . $hold->id . "/suspension" ) > ->status_is( 400, 'Cannot suspend waiting hold' ) >- ->json_is( '/error', 'Found hold cannot be suspended. Status=W' ); >+ ->json_is( '/error', 'Found hold cannot be suspended. Status=waiting' ); > > $hold->set_transfer->discard_changes; > > $t->post_ok( "//$userid:$password@/api/v1/holds/" . $hold->id . "/suspension" ) > ->status_is( 400, 'Cannot suspend hold on transfer' ) >- ->json_is( '/error', 'Found hold cannot be suspended. Status=T' ); >+ ->json_is( '/error', 'Found hold cannot be suspended. Status=in_transit' ); > > $schema->storage->txn_rollback; > }; >@@ -837,20 +842,23 @@ subtest 'pickup_locations() tests' => sub { > { > class => 'Koha::Holds', > value => { >- itemnumber => undef, >- biblionumber => $item->biblionumber, >- borrowernumber => $patron->borrowernumber >+ item_id => undef, >+ biblio_id => $item->biblionumber, >+ patron_id => $patron->borrowernumber, >+ completed => 0, > } > } > ); >+ > # item-level hold > my $hold_2 = $builder->build_object( > { > class => 'Koha::Holds', > value => { >- itemnumber => $item->itemnumber, >- biblionumber => $item->biblionumber, >- borrowernumber => $patron->borrowernumber >+ item_id => $item->itemnumber, >+ biblio_id => $item->biblionumber, >+ patron_id => $patron->borrowernumber, >+ completed => 0, > } > } > ); >@@ -943,10 +951,11 @@ subtest 'edit() tests' => sub { > { > class => "Koha::Holds", > value => { >- biblionumber => $biblio->biblionumber, >- branchcode => $library_3->branchcode, >- itemnumber => undef, >- priority => 1, >+ biblio_id => $biblio->biblionumber, >+ pickup_library_id => $library_3->branchcode, >+ item_id => undef, >+ priority => 1, >+ completed => 0, > } > } > ); >@@ -970,7 +979,7 @@ subtest 'edit() tests' => sub { > ->json_is({ error => 'The supplied pickup location is not valid' }); > > $biblio_hold->discard_changes; >- is( $biblio_hold->branchcode, $library_3->branchcode, 'branchcode remains untouched' ); >+ is( $biblio_hold->pickup_library_id, $library_3->branchcode, 'pickup_library_id remains untouched' ); > > $t->patch_ok( "//$userid:$password@/api/v1/holds/" . $biblio_hold->id > => { 'x-koha-override' => 'any' } >@@ -991,7 +1000,7 @@ subtest 'edit() tests' => sub { > ->status_is(200); > > $biblio_hold->discard_changes; >- is( $biblio_hold->branchcode, $library_2->id, 'Pickup location changed correctly' ); >+ is( $biblio_hold->pickup_library_id, $library_2->id, 'Pickup location changed correctly' ); > > $t->put_ok( "//$userid:$password@/api/v1/holds/" > . $biblio_hold->id >@@ -999,17 +1008,18 @@ subtest 'edit() tests' => sub { > ->status_is(200); > > $biblio_hold->discard_changes; >- is( $biblio_hold->branchcode, $library_2->id, 'Pickup location changed correctly' ); >+ is( $biblio_hold->pickup_library_id, $library_2->id, 'Pickup location changed correctly' ); > > # Test item-level holds > my $item_hold = $builder->build_object( > { > class => "Koha::Holds", > value => { >- biblionumber => $biblio->biblionumber, >- branchcode => $library_3->branchcode, >- itemnumber => $item->itemnumber, >- priority => 1, >+ biblio_id => $biblio->biblionumber, >+ pickup_library_id => $library_3->branchcode, >+ item_id => $item->itemnumber, >+ priority => 1, >+ completed => 0, > } > } > ); >@@ -1033,7 +1043,7 @@ subtest 'edit() tests' => sub { > ->json_is({ error => 'The supplied pickup location is not valid' }); > > $item_hold->discard_changes; >- is( $item_hold->branchcode, $library_3->branchcode, 'branchcode remains untouched' ); >+ is( $item_hold->pickup_library_id, $library_3->branchcode, 'branchcode remains untouched' ); > > $t->patch_ok( "//$userid:$password@/api/v1/holds/" . $item_hold->id > => { 'x-koha-override' => 'any' } >@@ -1059,7 +1069,7 @@ subtest 'edit() tests' => sub { > ->status_is(200); > > $item_hold->discard_changes; >- is( $item_hold->branchcode, $library_2->id, 'Pickup location changed correctly' ); >+ is( $item_hold->pickup_library_id, $library_2->id, 'Pickup location changed correctly' ); > > $schema->storage->txn_rollback; > }; >@@ -1131,10 +1141,10 @@ subtest 'add() tests' => sub { > { > class => "Koha::Holds", > value => { >- biblionumber => $biblio->biblionumber, >- branchcode => $library_3->branchcode, >- itemnumber => undef, >- priority => 1, >+ biblio_id => $biblio->biblionumber, >+ pickup_library_id => $library_3->branchcode, >+ item_id => undef, >+ priority => 1, > } > } > ); >@@ -1160,10 +1170,10 @@ subtest 'add() tests' => sub { > { > class => "Koha::Holds", > value => { >- biblionumber => $biblio->biblionumber, >- branchcode => $library_3->branchcode, >- itemnumber => $item->itemnumber, >- priority => 1, >+ biblio_id => $biblio->biblionumber, >+ pickup_library_id => $library_3->branchcode, >+ item_id => $item->itemnumber, >+ priority => 1, > } > } > ); >@@ -1250,7 +1260,7 @@ subtest 'PUT /holds/{hold_id}/pickup_location tests' => sub { > ->status_is(200) > ->json_is({ pickup_library_id => $library_2->branchcode }); > >- is( $hold->discard_changes->branchcode->branchcode, $library_2->branchcode, 'pickup library adjusted correctly' ); >+ is( $hold->discard_changes->pickup_library_id, $library_2->branchcode, 'pickup library adjusted correctly' ); > > $t->put_ok( "//$userid:$password@/api/v1/holds/" > . $hold->id >@@ -1258,7 +1268,7 @@ subtest 'PUT /holds/{hold_id}/pickup_location tests' => sub { > ->status_is(400) > ->json_is({ error => '[The supplied pickup location is not valid]' }); > >- is( $hold->discard_changes->branchcode->branchcode, $library_2->branchcode, 'pickup library unchanged' ); >+ is( $hold->discard_changes->pickup_library_id, $library_2->branchcode, 'pickup library unchanged' ); > > # item-level hold > $hold = Koha::Holds->find( >@@ -1280,7 +1290,7 @@ subtest 'PUT /holds/{hold_id}/pickup_location tests' => sub { > ->status_is(400) > ->json_is({ error => '[The supplied pickup location is not valid]' }); > >- is( $hold->discard_changes->branchcode->branchcode, $library_1->branchcode, 'pickup library unchanged' ); >+ is( $hold->discard_changes->pickup_library_id, $library_1->branchcode, 'pickup library unchanged' ); > > t::lib::Mocks::mock_preference( 'AllowHoldPolicyOverride', 1 ); > >@@ -1293,7 +1303,7 @@ subtest 'PUT /holds/{hold_id}/pickup_location tests' => sub { > ->status_is(200) > ->json_is({ pickup_library_id => $library_2->branchcode }); > >- is( $hold->discard_changes->branchcode->branchcode, $library_2->branchcode, 'pickup library changed' ); >+ is( $hold->discard_changes->pickup_library_id, $library_2->branchcode, 'pickup library changed' ); > > t::lib::Mocks::mock_preference( 'AllowHoldPolicyOverride', 0 ); > >@@ -1303,7 +1313,7 @@ subtest 'PUT /holds/{hold_id}/pickup_location tests' => sub { > ->status_is(200) > ->json_is({ pickup_library_id => $library_2->branchcode }); > >- is( $hold->discard_changes->branchcode->branchcode, $library_2->branchcode, 'pickup library adjusted correctly' ); >+ is( $hold->discard_changes->pickup_library_id, $library_2->branchcode, 'pickup library adjusted correctly' ); > > $t->put_ok( "//$userid:$password@/api/v1/holds/" > . $hold->id >@@ -1311,7 +1321,7 @@ subtest 'PUT /holds/{hold_id}/pickup_location tests' => sub { > ->status_is(400) > ->json_is({ error => '[The supplied pickup location is not valid]' }); > >- is( $hold->discard_changes->branchcode->branchcode, $library_2->branchcode, 'invalid pickup library not used' ); >+ is( $hold->discard_changes->pickup_library_id, $library_2->branchcode, 'invalid pickup library not used' ); > > $t->put_ok( "//$userid:$password@/api/v1/holds/" > . $hold->id >@@ -1321,7 +1331,7 @@ subtest 'PUT /holds/{hold_id}/pickup_location tests' => sub { > ->status_is(400) > ->json_is({ error => '[The supplied pickup location is not valid]' }); > >- is( $hold->discard_changes->branchcode->branchcode, $library_2->branchcode, 'invalid pickup library not used, even if x-koha-override is passed' ); >+ is( $hold->discard_changes->pickup_library_id, $library_2->branchcode, 'invalid pickup library not used, even if x-koha-override is passed' ); > > $schema->storage->txn_rollback; > }; >-- >2.32.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 25260
:
103984
|
103985
|
103986
|
103987
|
103988
|
103989
|
103990
|
103991
|
103992
|
103993
|
104053
|
104054
|
104055
|
104056
|
104057
|
117745
|
117746
|
117747
|
117748
|
117749
|
117750
|
117751
|
122761
|
122762
|
122763
|
122764
|
122765
|
122766
|
122767
|
122787
|
122788
|
122789
|
122790
|
122791
|
122792
|
122793
|
122976
|
122977
|
122978
|
122979
|
122980
|
122981
|
122982
|
122983
|
123071
|
123072
|
123073
|
123074
|
123075
|
123076
|
123077
|
123078
|
123079
|
123080
|
123257
|
123258
|
123259
|
123260
|
123261
|
123396