Bugzilla – Attachment 75725 Details for
Bug 17656
Irregularities in serial prediction pattern are planned only for current subscription
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17656: Update irregularities on multi-renewals
Bug-17656-Update-irregularities-on-multi-renewals.patch (text/plain), 8.93 KB, created by
Alex Arnaud
on 2018-06-01 08:05:35 UTC
(
hide
)
Description:
Bug 17656: Update irregularities on multi-renewals
Filename:
MIME Type:
Creator:
Alex Arnaud
Created:
2018-06-01 08:05:35 UTC
Size:
8.93 KB
patch
obsolete
>From db34a2ce74bc0244341cf4e5e099377f63b8d751 Mon Sep 17 00:00:00 2001 >From: Alex Arnaud <alex.arnaud@biblibre.com> >Date: Tue, 15 May 2018 09:09:38 +0000 >Subject: [PATCH] Bug 17656: Update irregularities on multi-renewals > >--- > Koha/Subscription.pm | 42 +++++ > .../prog/en/modules/serials/subscription-renew.tt | 4 +- > serials/subscription-renew.pl | 4 + > t/db_dependent/Koha/Subscription.t | 1 - > t/db_dependent/Koha/Subscription/Irregularities.t | 175 +++++++++++++++++++++ > 5 files changed, 224 insertions(+), 2 deletions(-) > create mode 100644 t/db_dependent/Koha/Subscription/Irregularities.t > >diff --git a/Koha/Subscription.pm b/Koha/Subscription.pm >index f00e88c..a99c380 100644 >--- a/Koha/Subscription.pm >+++ b/Koha/Subscription.pm >@@ -24,6 +24,9 @@ use Carp; > use Koha::Database; > use Koha::Biblios; > use Koha::Acquisition::Booksellers; >+use Koha::DateUtils; >+ >+use Date::Calc qw( Delta_Days ); > > use base qw(Koha::Object); > >@@ -152,6 +155,45 @@ sub lengthtype { > } > } > >+=head3 update_irregularities >+ >+$subscription->update_irregularities >+ >+=cut >+ >+sub guess_irregularities { >+ my ($self) = @_; >+ >+ my @irregularities; >+ my %permanent_irregularities = map { $_ => 1 } $self->permanent_irregularities; >+ >+ my $schema = Koha::Database->new->schema; >+ my $frequency = $schema->resultset('SubscriptionFrequency')->find($self->periodicity); >+ >+ my $enddate = $self->enddate; >+ my $nextexpected = C4::Serials::GetNextExpected($self->id); >+ my $date = $nextexpected->{planneddate}; >+ >+ my ($issuenumber) = C4::Serials::GetFictiveIssueNumber($self->unblessed, $date); >+ my $dow = issue_number( dt_from_string($date), $frequency->unit ); >+ >+ if ( defined( $permanent_irregularities{$dow} ) ) { >+ push @irregularities, $issuenumber; >+ } >+ >+ while ( Delta_Days( split(/-/, $date), split(/-/, $enddate) ) >= 0 ) { >+ $issuenumber++; >+ $date = C4::Serials::GetNextDate($self->unblessed, $date); >+ $dow = issue_number( dt_from_string($date), $frequency->unit ); >+ >+ if ( defined( $permanent_irregularities{$dow} ) ) { >+ push @irregularities, $issuenumber; >+ } >+ } >+ >+ return @irregularities; >+} >+ > =head3 type > > =cut >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-renew.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-renew.tt >index 723bde0..8b64ff6 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-renew.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-renew.tt >@@ -84,7 +84,9 @@ > var irregularity = "[% subscription.irregularity %]"; > var more_than_one_serial = "[% more_than_one_serial %]"; > $(document).ready(function(){ >- testPredictionPattern(); >+ if (subscriptionid) { >+ testPredictionPattern(); >+ } > $(".close").on("click", function(e){ > e.preventDefault(); > window.opener.location.reload(false); >diff --git a/serials/subscription-renew.pl b/serials/subscription-renew.pl >index 602461c..0c71cbb 100755 >--- a/serials/subscription-renew.pl >+++ b/serials/subscription-renew.pl >@@ -101,6 +101,10 @@ if ( $op eq "renew" ) { > $subscription->{enddate}, $subscription->{numberlength}, > $subscription->{weeklength}, $subscription->{monthlength}, > ); >+ >+ $subscription = Koha::Subscriptions->find( $subscriptionid ); >+ my @irregularities = $subscription->guess_irregularities; >+ $subscription->irregularity( join(';', @irregularities) )->store; > } > } else { > my $subscriptionid = $subscriptionids[0]; >diff --git a/t/db_dependent/Koha/Subscription.t b/t/db_dependent/Koha/Subscription.t >index 2d9e096..76f51b5 100644 >--- a/t/db_dependent/Koha/Subscription.t >+++ b/t/db_dependent/Koha/Subscription.t >@@ -20,7 +20,6 @@ > use Modern::Perl; > > use Test::More tests => 4; >-use Test::More tests => 2; > use t::lib::TestBuilder; > > use Koha::Subscriptions; >diff --git a/t/db_dependent/Koha/Subscription/Irregularities.t b/t/db_dependent/Koha/Subscription/Irregularities.t >new file mode 100644 >index 0000000..a5b34c3 >--- /dev/null >+++ b/t/db_dependent/Koha/Subscription/Irregularities.t >@@ -0,0 +1,175 @@ >+#!/usr/bin/perl >+ >+# This file is part of Koha >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WIT HOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Test::More tests => 2; >+use t::lib::TestBuilder; >+ >+use C4::Serials; >+ >+use Koha::Database; >+use Koha::Subscriptions; >+ >+BEGIN { >+ use_ok('Koha::Subscriptions'); >+} >+ >+my $schema = Koha::Database->new->schema; >+my $builder = t::lib::TestBuilder->new; >+ >+$schema->storage->txn_begin; >+ >+my $biblio = $builder->build({ >+ source => 'Biblio', >+}); >+ >+my $frequency = $builder->build({ >+ source => 'SubscriptionFrequency', >+ value => { >+ unit => 'day', >+ unitsperissue => 1, >+ issuesperunit => 1 >+ } >+}); >+ >+my $number_pattern = $builder->build({ >+ source => 'SubscriptionNumberpattern', >+ value => { >+ numberingmethod => 'No.{X}', >+ add1 => 1, >+ every1 => 1, >+ whenmorethan1 => 99999, >+ setto1 => 1 >+ } >+}); >+ >+my $subscription = $builder->build({ >+ source => 'Subscription', >+ value => { >+ biblionumber => $biblio->{biblionumber}, >+ startdate => '2018-05-07', >+ weeklength => 0, >+ monthlength => 0, >+ numberlength => 7, >+ periodicity => $frequency->{id}, >+ countissuesperunit => 1, >+ status => 1, >+ lastvalue1 => 5, >+ lastvalue2 => 0, >+ innerloop1 => 0, >+ innerloop2 => 0, >+ innerloop3 => 0, >+ lastvalue3 => 0, >+ firstacquidate => '2018-05-07', >+ irregularity => '3;4', >+ permanent_irregularity => '3;4', >+ numberpattern => 7, >+ enddate => '2018-05-13', >+ closed => 0 >+ } >+}); >+ >+$builder->build({ >+ source => 'Serial', >+ value => { >+ biblionumber => $biblio->{biblionumber}, >+ subscriptionid => $subscription->{subscriptionid}, >+ serialseq => 'No.1', >+ serialseq_x => 1, >+ status => 2, >+ planneddate => '2018-05-07', >+ publisheddate => '2018-05-07', >+ } >+}); >+ >+$builder->build({ >+ source => 'Serial', >+ value => { >+ biblionumber => $biblio->{biblionumber}, >+ subscriptionid => $subscription->{subscriptionid}, >+ serialseq => 'No.2', >+ serialseq_x => 2, >+ status => 2, >+ planneddate => '2018-05-08', >+ publisheddate => '2018-05-08', >+ } >+}); >+ >+$builder->build({ >+ source => 'Serial', >+ value => { >+ biblionumber => $biblio->{biblionumber}, >+ subscriptionid => $subscription->{subscriptionid}, >+ serialseq => 'No.3', >+ serialseq_x => 3, >+ status => 2, >+ planneddate => '2018-05-11', >+ publisheddate => '2018-05-11', >+ } >+}); >+ >+$builder->build({ >+ source => 'Serial', >+ value => { >+ biblionumber => $biblio->{biblionumber}, >+ subscriptionid => $subscription->{subscriptionid}, >+ serialseq => 'No.4', >+ serialseq_x => 4, >+ status => 2, >+ planneddate => '2018-05-12', >+ publisheddate => '2018-05-12', >+ } >+}); >+ >+$builder->build({ >+ source => 'Serial', >+ value => { >+ biblionumber => $biblio->{biblionumber}, >+ subscriptionid => $subscription->{subscriptionid}, >+ serialseq => 'No.5', >+ serialseq_x => 5, >+ status => 2, >+ planneddate => '2018-05-13', >+ publisheddate => '2018-05-13', >+ } >+}); >+ >+$builder->build({ >+ source => 'Serial', >+ value => { >+ biblionumber => $biblio->{biblionumber}, >+ subscriptionid => $subscription->{subscriptionid}, >+ serialseq => 'No.6', >+ serialseq_x => 6, >+ status => 1, >+ planneddate => '2018-05-14', >+ publisheddate => '2018-05-14', >+ } >+}); >+ >+ReNewSubscription( >+ $subscription->{subscriptionid}, undef, >+ $subscription->{enddate}, $subscription->{numberlength}, >+ $subscription->{weeklength}, $subscription->{monthlength}, >+); >+ >+my $s = Koha::Subscriptions->find($subscription->{subscriptionid}); >+my $irregularities = join(';', $s->guess_irregularities); >+is($irregularities, '10;11', 'Irregularities have been updated'); >+ >+$schema->storage->txn_rollback; >\ No newline at end of file >-- >2.7.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 17656
:
68259
|
68261
|
68607
|
68608
|
68665
|
69124
|
69207
|
69279
|
69553
|
69814
|
69820
|
69915
|
70335
|
70336
|
70430
|
70619
|
75403
|
75404
|
75405
|
75406
|
75407
|
75408
|
75721
|
75722
|
75723
|
75724
|
75725
|
75726
|
75953
|
102724
|
102725
|
102726
|
102727
|
102728
|
102729
|
102730
|
102860
|
102861
|
102862
|
102863
|
102864
|
102865
|
102866
|
102867
|
102960
|
102961
|
102962
|
102963
|
102964
|
102965
|
102966
|
102967
|
102968
|
103623
|
103624
|
103625
|
103626
|
103627
|
103628
|
103629
|
103630
|
103631
|
103657
|
103658
|
103659
|
103660
|
103661
|
103662
|
103663
|
103664
|
103665
|
103667
|
117789
|
117790
|
117791
|
117792
|
117846
|
117851
|
117852
|
118856
|
119106
|
120863
|
121082
|
121083
|
121084
|
121085
|
121086
|
121087
|
121088
|
121192
|
121193
|
121194
|
121195
|
121196
|
121197
|
121198
|
121296
|
121297
|
121298
|
121299
|
121300
|
121301
|
121302
|
128489
|
128491
|
128492
|
128493
|
128494
|
128495
|
128496
|
128498
|
128499
|
128500
|
128501
|
128502
|
128503
|
128504
|
132412
|
132413
|
132415
|
132416
|
132417
|
132418
|
132447
|
132448
|
132692
|
132779