Bugzilla – Attachment 103661 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.63 KB, created by
David Nind
on 2020-04-24 11:40:33 UTC
(
hide
)
Description:
Bug 17656: Update irregularities on multi-renewals
Filename:
MIME Type:
Creator:
David Nind
Created:
2020-04-24 11:40:33 UTC
Size:
8.63 KB
patch
obsolete
>From 6b600c3dad73b7d538bc9a7b98cc5745ebb61c21 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 > >Signed-off-by: David Nind <david@davidnind.com> >--- > Koha/Subscription.pm | 41 +++++ > .../prog/en/modules/serials/subscription-renew.tt | 4 +- > serials/subscription-renew.pl | 4 + > t/db_dependent/Koha/Subscription/Irregularities.t | 175 +++++++++++++++++++++ > 4 files changed, 223 insertions(+), 1 deletion(-) > create mode 100644 t/db_dependent/Koha/Subscription/Irregularities.t > >diff --git a/Koha/Subscription.pm b/Koha/Subscription.pm >index b5f8bb2e24..c395517870 100644 >--- a/Koha/Subscription.pm >+++ b/Koha/Subscription.pm >@@ -28,7 +28,9 @@ use Koha::Biblioitems; > use Koha::Subscriptions; > use Koha::Subscription::Frequencies; > use Koha::Subscription::Numberpatterns; >+use Koha::DateUtils; > use JSON; >+use Date::Calc qw( Delta_Days ); > > use base qw(Koha::Object Koha::Object::Mixin::AdditionalFields); > >@@ -243,6 +245,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 f2f3b59f2a..b202c1f969 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 >@@ -117,7 +117,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 2c4f959923..d3edaf302a 100755 >--- a/serials/subscription-renew.pl >+++ b/serials/subscription-renew.pl >@@ -122,6 +122,10 @@ if ( $op eq "renew" ) { > monthlength => $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/Irregularities.t b/t/db_dependent/Koha/Subscription/Irregularities.t >new file mode 100644 >index 0000000000..a5b34c377b >--- /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.11.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 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