Bugzilla – Attachment 173346 Details for
Bug 38175
Improve bookings behavior with new status field
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38175: (QA follow-up) Add cancelled handling to find_booking
Bug-38175-QA-follow-up-Add-cancelled-handling-to-f.patch (text/plain), 4.82 KB, created by
Martin Renvoize (ashimema)
on 2024-10-25 11:10:12 UTC
(
hide
)
Description:
Bug 38175: (QA follow-up) Add cancelled handling to find_booking
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-10-25 11:10:12 UTC
Size:
4.82 KB
patch
obsolete
>From b28e165b7ccbeb9c105226ef052bae65fae18d6d Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 25 Oct 2024 12:04:24 +0100 >Subject: [PATCH] Bug 38175: (QA follow-up) Add cancelled handling to > find_booking > >We need to also exclude cancelled bookings from the find_booking routine >used at checkout. > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/Item.pm | 59 ++++++++++++++++++++++---------------- > t/db_dependent/Koha/Item.t | 17 ++++++++++- > 2 files changed, 50 insertions(+), 26 deletions(-) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index f82b9b65a59..090fea55148 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -605,9 +605,9 @@ implementation. > sub find_booking { > my ( $self, $params ) = @_; > >- my $checkout_date = $params->{checkout_date}; >- my $due_date = $params->{due_date}; >- my $biblio = $self->biblio; >+ my $start_date = $params->{checkout_date}; >+ my $end_date = $params->{due_date}; >+ my $biblio = $self->biblio; > > my $rule = Koha::CirculationRules->get_effective_rule( > { >@@ -617,33 +617,41 @@ sub find_booking { > } > ); > my $preparation_period = $rule ? $rule->rule_value : 0; >- $due_date = $due_date->clone->add( days => $preparation_period ); >+ $end_date = $end_date->clone->add( days => $preparation_period ); > > my $dtf = Koha::Database->new->schema->storage->datetime_parser; > my $bookings = $biblio->bookings( >- [ >- # Proposed checkout starts during booked period >- start_date => { >- '-between' => [ >- $dtf->format_datetime($checkout_date), >- $dtf->format_datetime($due_date) >- ] >- }, >+ { >+ '-and' => [ >+ { >+ '-or' => [ > >- # Proposed checkout is due during booked period >- end_date => { >- '-between' => [ >- $dtf->format_datetime($checkout_date), >- $dtf->format_datetime($due_date) >- ] >- }, >+ # Proposed checkout starts during booked period >+ start_date => { >+ '-between' => [ >+ $dtf->format_datetime($start_date), >+ $dtf->format_datetime($end_date) >+ ] >+ }, > >- # Proposed checkout would contain the booked period >- { >- start_date => { '<' => $dtf->format_datetime($checkout_date) }, >- end_date => { '>' => $dtf->format_datetime($due_date) } >- } >- ], >+ # Proposed checkout is due during booked period >+ end_date => { >+ '-between' => [ >+ $dtf->format_datetime($start_date), >+ $dtf->format_datetime($end_date) >+ ] >+ }, >+ >+ # Proposed checkout would contain the booked period >+ { >+ start_date => { '<' => $dtf->format_datetime($start_date) }, >+ end_date => { '>' => $dtf->format_datetime($end_date) } >+ } >+ ] >+ }, >+ { status => { '-not_in' => [ 'cancelled', 'completed' ] } } >+ ] >+ }, > { order_by => { '-asc' => 'start_date' } } > ); > >@@ -668,6 +676,7 @@ sub find_booking { > > # Booking for another item > elsif ( defined( $booking->item_id ) ) { >+ > # Due for another booking, remove from pool > delete $loanable_items->{ $booking->item_id }; > next; >diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t >index 5c3be2b91cb..41385050310 100755 >--- a/t/db_dependent/Koha/Item.t >+++ b/t/db_dependent/Koha/Item.t >@@ -2897,7 +2897,7 @@ subtest 'bookings' => sub { > }; > > subtest 'find_booking' => sub { >- plan tests => 7; >+ plan tests => 8; > > $schema->storage->txn_begin; > >@@ -3004,6 +3004,21 @@ subtest 'find_booking' => sub { > "Koha::Item->find_booking returns the current booking not a future one" > ); > >+ # Cancelled booking >+ $booking2->status('cancelled')->store(); >+ $found_booking = $item->find_booking( >+ { >+ checkout_date => dt_from_string(), >+ due_date => dt_from_string()->add( days => 7 ), >+ } >+ ); >+ >+ is( >+ $found_booking, >+ undef, >+ "Koha::Item->find_booking returns undefined when the current booking is cancelled and the future booking is out of range" >+ ); >+ > subtest "Preparation period handling" => sub { > plan tests => 3; > >-- >2.47.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 38175
:
172770
|
172771
|
172772
|
172773
|
172814
|
172815
|
172816
|
172817
|
172880
|
172881
|
172882
|
172883
|
172884
|
173172
|
173173
|
173174
|
173175
|
173176
|
173177
|
173178
|
173201
|
173202
|
173203
| 173346 |
173915