Bugzilla – Attachment 47770 Details for
Bug 12748
Serials - two issues with status of "Expected"
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug12748 - Fixes duplicate serials with an "expected" status bug
Bug12748---Fixes-duplicate-serials-with-an-expecte.patch (text/plain), 4.23 KB, created by
Rémi Mayrand-Provencher
on 2016-02-08 20:11:53 UTC
(
hide
)
Description:
Bug12748 - Fixes duplicate serials with an "expected" status bug
Filename:
MIME Type:
Creator:
Rémi Mayrand-Provencher
Created:
2016-02-08 20:11:53 UTC
Size:
4.23 KB
patch
obsolete
>From 3a32e1cea171c81e466eaa9e8e0f782b9b32a090 Mon Sep 17 00:00:00 2001 >From: remi <remi.mayrand-provencher@inLibro.com> >Date: Tue, 11 Aug 2015 11:10:45 -0400 >Subject: [PATCH] Bug12748 - Fixes duplicate serials with an "expected" status > bug > >Added a new sub to Serials.pm to be able to get serials with their statuses. > Now the sub ModSerialStatus checks for other serials with an "expected" status before doing anything. > > Also modified Serials.t to be able to test those changes. > > Test Plan > 1) Apply patch > 2) Run ./t/db_dependent/Serials.t > 3) Validate that there are no errors > 4) Go on "Serial collection information" page for a serial of your choice > 5) Click on "Generate next" > 6) Change the status of the original serial from "late" to "expected" > 7) Change the newly generated serial from "expected" to "delete" > 8) Validate that there are no new serials created by instruction 7 and that the serial was deleted > 9) Run ./t/db_dependent/Serials.t > >With QA Fixes > >- Use the constant instead of the code (1 vs EXPECTED) >- Avoid interpolation in query >- use selectall_arrayref instead of fetchall_arrayref > >Signed-off-by: Liz Rea <liz@catalyst.net.nz> > >https://bugs.koha-community.org/show_bug.cgi?id=12478 >--- > C4/Serials.pm | 24 ++++++++++++++++++++++-- > t/db_dependent/Serials.t | 5 ++++- > 2 files changed, 26 insertions(+), 3 deletions(-) > mode change 100644 => 100755 t/db_dependent/Serials.t > >diff --git a/C4/Serials.pm b/C4/Serials.pm >index c09a198..029c10d 100644 >--- a/C4/Serials.pm >+++ b/C4/Serials.pm >@@ -1175,8 +1175,10 @@ sub ModSerialStatus { > } > } > >- # create new waited entry if needed (ie : was a "waited" and has changed) >- if ( $oldstatus == EXPECTED && $status != EXPECTED ) { >+ # create new expected entry if needed (ie : was "expected" and has changed) >+ # BUG 12748: Check if there are no other expected issues. >+ my $otherIssueExpected = scalar findSerialByStatus(EXPECTED, $subscriptionid); >+ if ( !$otherIssueExpected && $oldstatus == EXPECTED && $status != EXPECTED ) { > my $subscription = GetSubscription($subscriptionid); > my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern}); > >@@ -2687,6 +2689,24 @@ sub _can_do_on_subscription { > return 0; > } > >+=head2 findSerialByStatus >+ >+ @serials = findSerialByStatus($status, $subscriptionid); >+ >+ Returns an array of serials matching a given status and subscription id. >+ >+=cut >+ >+sub findSerialByStatus{ >+ my($status, $subscriptionid) = @_; >+ my $dbh = C4::Context->dbh; >+ my $query = q| SELECT * from serial >+ WHERE status = ? >+ AND subscriptionid = ? >+ |; >+ my $serials = $dbh->selectall_arrayref( $query, { Slice => {} }, $status, $subscriptionid ); >+ return @$serials; >+} > 1; > __END__ > >diff --git a/t/db_dependent/Serials.t b/t/db_dependent/Serials.t >old mode 100644 >new mode 100755 >index 1f3ebb0..b350ccd >--- a/t/db_dependent/Serials.t >+++ b/t/db_dependent/Serials.t >@@ -15,7 +15,7 @@ use C4::Bookseller; > use C4::Biblio; > use C4::Budgets; > use Koha::DateUtils; >-use Test::More tests => 45; >+use Test::More tests => 48; > > BEGIN { > use_ok('C4::Serials'); >@@ -173,6 +173,7 @@ is(C4::Serials::ModSubscriptionHistory(), undef, 'test modding subscription hist > > is(C4::Serials::ModSerialStatus(),undef, 'test modding serials'); > >+is(C4::Serials::findSerialByStatus(), 0, 'test finding serial by status with no parameters'); > is(C4::Serials::NewIssue(), undef, 'test getting 0 when nothing is entered'); > > is(C4::Serials::HasSubscriptionStrictlyExpired(), undef, 'test if the subscriptions has expired'); >@@ -218,6 +219,8 @@ for my $status ( @statuses ) { > $counter++; > } > # Here we have 15 serials with statuses : 2*2 + 5*3 + 2*4 + 1*41 + 1*42 + 1*43 + 1*44 + 1*5 + 1*1 >+my @serialsByStatus = C4::Serials::findSerialByStatus(2,$subscriptionid); >+is(@serialsByStatus,2,"findSerialByStatus returns all serials with chosen status"); > ( $total_issues, @serials ) = C4::Serials::GetSerials( $subscriptionid ); > is( $total_issues, @statuses + 1, "GetSerials returns total_issues" ); > my @arrived_missing = map { my $status = $_->{status}; ( grep { /^$status$/ } qw( 2 4 41 42 43 44 5 ) ) ? $_ : () } @serials; >-- >1.9.1
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 12748
:
41228
|
41230
|
41371
|
41451
|
44533
|
46091
|
47770
|
47771
|
47773
|
47774
|
47775
|
47776
|
52356
|
52357
|
52358
|
52359
|
52360