Bugzilla – Attachment 165154 Details for
Bug 35994
New acquisition status method to see if biblio record is still in acquisition
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35994: Add $biblio->acq_status
Bug-35994-Add-biblio-acqstatus.patch (text/plain), 4.10 KB, created by
Marcel de Rooy
on 2024-04-19 07:40:27 UTC
(
hide
)
Description:
Bug 35994: Add $biblio->acq_status
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2024-04-19 07:40:27 UTC
Size:
4.10 KB
patch
obsolete
>From cb3c5a707ef46b5c5d9baf33f5ed5cd27a0bfbfa Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 22 Feb 2024 12:48:55 +0000 >Subject: [PATCH] Bug 35994: Add $biblio->acq_status >Content-Type: text/plain; charset=utf-8 > >This allows you to see quickly if a biblio has linked orders or not. >And if they are all cancelled, or some still in processing, or some >are complete (and the rest cancelled). > >Test plan: >Run t/db_dependent/Koha/Biblio.t > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > Koha/Biblio.pm | 26 ++++++++++++++++++++++++++ > t/db_dependent/Koha/Biblio.t | 25 +++++++++++++++++++------ > 2 files changed, 45 insertions(+), 6 deletions(-) > >diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm >index aa8dfe8ea2..a5a73138f6 100644 >--- a/Koha/Biblio.pm >+++ b/Koha/Biblio.pm >@@ -158,6 +158,32 @@ sub uncancelled_orders { > return $self->orders->filter_out_cancelled; > } > >+=head3 acq_status >+ >+ print $biblio->acq_status; >+ >+ This status can be: >+ - unlinked: not any linked order found in the system >+ - acquired: some lines are complete, rest is cancelled >+ - cancelled: all lines are cancelled >+ - processing: some lines are active or new >+ >+=cut >+ >+sub acq_status { >+ my ($self) = @_; >+ my $orders = $self->orders; >+ unless ( $orders->count ) { >+ return 'unlinked'; >+ } elsif ( !$self->uncancelled_orders->count ) { >+ return 'cancelled'; >+ } elsif ( $orders->search( { orderstatus => [ 'new', 'ordered', 'partial' ] } )->count ) { >+ return 'processing'; >+ } else { >+ return 'acquired'; # some lines must be complete here >+ } >+} >+ > =head3 tickets > > my $tickets = $biblio->tickets(); >diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t >index a50267922c..9b8ff475d4 100755 >--- a/t/db_dependent/Koha/Biblio.t >+++ b/t/db_dependent/Koha/Biblio.t >@@ -896,9 +896,9 @@ subtest 'get_volumes_query' => sub { > ); > }; > >-subtest 'orders() and uncancelled_orders() tests' => sub { >+subtest '->orders, ->uncancelled_orders and ->acq_status tests' => sub { > >- plan tests => 5; >+ plan tests => 9; > > $schema->storage->txn_begin; > >@@ -919,8 +919,9 @@ subtest 'orders() and uncancelled_orders() tests' => sub { > { > class => 'Koha::Acquisition::Orders', > value => { >- biblionumber => $biblio->biblionumber, >- datecancellationprinted => '2019-12-31' >+ biblionumber => $biblio->biblionumber, >+ datecancellationprinted => '2019-12-31', >+ orderstatus => 'cancelled', > } > } > ); >@@ -930,8 +931,11 @@ subtest 'orders() and uncancelled_orders() tests' => sub { > { > class => 'Koha::Acquisition::Orders', > value => { >- biblionumber => $biblio->biblionumber, >- datecancellationprinted => undef >+ biblionumber => $biblio->biblionumber, >+ datecancellationprinted => undef, >+ orderstatus => 'ordered', >+ quantity => 1, >+ quantityreceived => 0, > } > } > ); >@@ -943,6 +947,15 @@ subtest 'orders() and uncancelled_orders() tests' => sub { > is( ref($uncancelled_orders), 'Koha::Acquisition::Orders', 'Result type is correct' ); > is( $orders->count, $uncancelled_orders->count + 2, '->uncancelled_orders->count returns the right count' ); > >+ # Check acq status >+ is( $biblio->acq_status, 'processing', 'Processing for presence of ordered lines' ); >+ $orders->filter_by_active->update( { orderstatus => 'new' } ); >+ is( $biblio->acq_status, 'processing', 'Still processing for presence of new lines' ); >+ $orders->filter_out_cancelled->update( { orderstatus => 'complete' } ); >+ is( $biblio->acq_status, 'acquired', 'Acquired: some complete, rest cancelled' ); >+ $orders->cancel; >+ is( $biblio->acq_status, 'cancelled', 'Cancelled for only cancelled lines' ); >+ > $schema->storage->txn_rollback; > }; > >-- >2.30.2
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 35994
:
162334
|
162335
|
165154
|
165155
|
165224
|
165225
|
166510
|
166537
|
166538
|
166539