Bugzilla – Attachment 68259 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 - Keep irregularities during subscription renewals
Bug-17656---Keep-irregularities-during-subscriptio.patch (text/plain), 18.73 KB, created by
Alex Arnaud
on 2017-10-18 14:53:07 UTC
(
hide
)
Description:
Bug 17656 - Keep irregularities during subscription renewals
Filename:
MIME Type:
Creator:
Alex Arnaud
Created:
2017-10-18 14:53:07 UTC
Size:
18.73 KB
patch
obsolete
>From 9089664416af3325aceb056310ce37af519a623c Mon Sep 17 00:00:00 2001 >From: Alex Arnaud <alex.arnaud@biblibre.com> >Date: Wed, 18 Oct 2017 14:52:34 +0000 >Subject: [PATCH] Bug 17656 - Keep irregularities during subscription renewals > >When renewing a subscription, irregularities are lost. This patch >allows to keep them for monthly or daily serials ( 1 unit per issue >only). > >Test plan: > - Apply this patch, > - Launch installer/data/mysql/updatedatabase.pl > - Launch misc/devel/update_dbix_class_files.pl > > - Create a daily subscription. i.e: > - From: 2017-10-09, To: 2017-10-15, > - Frequency: 1/day, > - 7 issues, > - test prediction pattern > - check Wednesday and Thursday as irregularity, > - save > - Edit subscription, > - Check that Wednesday and Thursday are still checked > - Renew subscription from 2017-10-16 > - Edit subscription, > - Make sure that Wednesday and Thursday are still checked > with corresponding serials > > - Do the same for a monthly subscription >--- > C4/Serials.pm | 102 ++++++++------------- > Koha/Subscription.pm | 24 +++++ > .../Bug_17656-add-permanent-irregularities.sql | 1 + > .../en/modules/serials/showpredictionpattern.tt | 44 +++++---- > serials/showpredictionpattern.pl | 19 +++- > serials/subscription-add.pl | 13 ++- > t/db_dependent/Serials/SubscriptionIrregularity.pm | 35 +++++++ > 7 files changed, 145 insertions(+), 93 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/Bug_17656-add-permanent-irregularities.sql > create mode 100644 t/db_dependent/Serials/SubscriptionIrregularity.pm > >diff --git a/C4/Serials.pm b/C4/Serials.pm >index d79c0a5..635b9da 100644 >--- a/C4/Serials.pm >+++ b/C4/Serials.pm >@@ -1301,37 +1301,6 @@ sub ModNextExpected { > > } > >-=head2 GetSubscriptionIrregularities >- >-=over 4 >- >-=item @irreg = &GetSubscriptionIrregularities($subscriptionid); >-get the list of irregularities for a subscription >- >-=back >- >-=cut >- >-sub GetSubscriptionIrregularities { >- my $subscriptionid = shift; >- >- return unless $subscriptionid; >- >- my $dbh = C4::Context->dbh; >- my $query = qq{ >- SELECT irregularity >- FROM subscription >- WHERE subscriptionid = ? >- }; >- my $sth = $dbh->prepare($query); >- $sth->execute($subscriptionid); >- >- my ($result) = $sth->fetchrow_array; >- my @irreg = split /;/, $result; >- >- return @irreg; >-} >- > =head2 ModSubscription > > this function modifies a subscription. Put all new values on input args. >@@ -1342,23 +1311,23 @@ returns the number of rows affected > sub ModSubscription { > my ( > $auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $startdate, >- $periodicity, $firstacquidate, $irregularity, $numberpattern, $locale, >- $numberlength, $weeklength, $monthlength, $lastvalue1, $innerloop1, >- $lastvalue2, $innerloop2, $lastvalue3, $innerloop3, $status, >- $biblionumber, $callnumber, $notes, $letter, $manualhistory, >- $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount, >- $graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq, >- $itemtype, $previousitemtype >+ $periodicity, $firstacquidate, $irregularity, $permanent_irregularity, >+ $numberpattern, $locale, $numberlength, $weeklength, $monthlength, >+ $lastvalue1, $innerloop1, $lastvalue2, $innerloop2, $lastvalue3, >+ $innerloop3, $status, $biblionumber, $callnumber, $notes, $letter, >+ $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount, >+ $opacdisplaycount, $graceperiod, $location, $enddate, $subscriptionid, >+ $skip_serialseq, $itemtype, $previousitemtype > ) = @_; > > my $dbh = C4::Context->dbh; > my $query = "UPDATE subscription > SET librarian=?, branchcode=?, aqbooksellerid=?, cost=?, aqbudgetid=?, > startdate=?, periodicity=?, firstacquidate=?, irregularity=?, >- numberpattern=?, locale=?, numberlength=?, weeklength=?, monthlength=?, >- lastvalue1=?, innerloop1=?, lastvalue2=?, innerloop2=?, >- lastvalue3=?, innerloop3=?, status=?, biblionumber=?, >- callnumber=?, notes=?, letter=?, manualhistory=?, >+ permanent_irregularity=?, numberpattern=?, locale=?, numberlength=?, >+ weeklength=?, monthlength=?, lastvalue1=?, innerloop1=?, >+ lastvalue2=?, innerloop2=?, lastvalue3=?, innerloop3=?, status=?, >+ biblionumber=?, callnumber=?, notes=?, letter=?, manualhistory=?, > internalnotes=?, serialsadditems=?, staffdisplaycount=?, > opacdisplaycount=?, graceperiod=?, location = ?, enddate=?, > skip_serialseq=?, itemtype=?, previousitemtype=? >@@ -1366,17 +1335,19 @@ sub ModSubscription { > > my $sth = $dbh->prepare($query); > $sth->execute( >- $auser, $branchcode, $aqbooksellerid, $cost, >- $aqbudgetid, $startdate, $periodicity, $firstacquidate, >- $irregularity, $numberpattern, $locale, $numberlength, >- $weeklength, $monthlength, $lastvalue1, $innerloop1, >- $lastvalue2, $innerloop2, $lastvalue3, $innerloop3, >- $status, $biblionumber, $callnumber, $notes, >- $letter, ($manualhistory ? $manualhistory : 0), >- $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount, >- $graceperiod, $location, $enddate, $skip_serialseq, >- $itemtype, $previousitemtype, >- $subscriptionid >+ $auser, $branchcode, $aqbooksellerid, >+ $cost, $aqbudgetid, $startdate, >+ $periodicity, $firstacquidate, $irregularity, >+ $permanent_irregularity, $numberpattern, $locale, >+ $numberlength, $weeklength, $monthlength, >+ $lastvalue1, $innerloop1, $lastvalue2, >+ $innerloop2, $lastvalue3, $innerloop3, >+ $status, $biblionumber, $callnumber, >+ $notes, $letter, ($manualhistory ? $manualhistory : 0), >+ $internalnotes, $serialsadditems, $staffdisplaycount, >+ $opacdisplaycount, $graceperiod, $location, >+ $enddate, $skip_serialseq, $itemtype, >+ $previousitemtype, $subscriptionid > ); > my $rows = $sth->rows; > >@@ -1407,9 +1378,10 @@ sub NewSubscription { > $startdate, $periodicity, $numberlength, $weeklength, $monthlength, > $lastvalue1, $innerloop1, $lastvalue2, $innerloop2, $lastvalue3, > $innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity, >- $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes, >- $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod, >- $location, $enddate, $skip_serialseq, $itemtype, $previousitemtype >+ $permanent_irregularity, $numberpattern, $locale, $callnumber, >+ $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount, >+ $opacdisplaycount, $graceperiod, $location, $enddate, $skip_serialseq, >+ $itemtype, $previousitemtype > ) = @_; > my $dbh = C4::Context->dbh; > >@@ -1420,11 +1392,11 @@ sub NewSubscription { > biblionumber, startdate, periodicity, numberlength, weeklength, > monthlength, lastvalue1, innerloop1, lastvalue2, innerloop2, > lastvalue3, innerloop3, status, notes, letter, firstacquidate, >- irregularity, numberpattern, locale, callnumber, >- manualhistory, internalnotes, serialsadditems, staffdisplaycount, >- opacdisplaycount, graceperiod, location, enddate, skip_serialseq, >- itemtype, previousitemtype) >- VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) >+ irregularity, permanent_irregularity, numberpattern, locale, >+ callnumber, manualhistory, internalnotes, serialsadditems, >+ staffdisplaycount, opacdisplaycount, graceperiod, location, >+ enddate, skip_serialseq, itemtype, previousitemtype) >+ VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) > |; > my $sth = $dbh->prepare($query); > $sth->execute( >@@ -1432,10 +1404,10 @@ sub NewSubscription { > $startdate, $periodicity, $numberlength, $weeklength, > $monthlength, $lastvalue1, $innerloop1, $lastvalue2, $innerloop2, > $lastvalue3, $innerloop3, $status, $notes, $letter, >- $firstacquidate, $irregularity, $numberpattern, $locale, $callnumber, >- $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount, >- $opacdisplaycount, $graceperiod, $location, $enddate, $skip_serialseq, >- $itemtype, $previousitemtype >+ $firstacquidate, $irregularity, $permanent_irregularity, >+ $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes, >+ $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod, >+ $location, $enddate, $skip_serialseq, $itemtype, $previousitemtype > ); > > my $subscriptionid = $dbh->{'mysql_insertid'}; >diff --git a/Koha/Subscription.pm b/Koha/Subscription.pm >index 2a793e5..839f17a 100644 >--- a/Koha/Subscription.pm >+++ b/Koha/Subscription.pm >@@ -48,6 +48,30 @@ sub biblio { > return scalar Koha::Biblios->find($self->biblionumber); > } > >+=head2 irregularities >+ >+Returns an array containing irregularities >+ >+=cut >+ >+sub irregularities { >+ my ($self) = @_; >+ >+ return split(';', $self->irregularity); >+} >+ >+=head2 permanent_irregularities >+ >+Returns an array containing permanent irregularities >+ >+=cut >+ >+sub permanent_irregularities { >+ my ($self) = @_; >+ >+ return split(';', $self->permanent_irregularity); >+} >+ > =head3 type > > =cut >diff --git a/installer/data/mysql/atomicupdate/Bug_17656-add-permanent-irregularities.sql b/installer/data/mysql/atomicupdate/Bug_17656-add-permanent-irregularities.sql >new file mode 100644 >index 0000000..cb9cd1d >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/Bug_17656-add-permanent-irregularities.sql >@@ -0,0 +1 @@ >+ALTER TABLE `subscription` ADD permanent_irregularity text AFTER irregularity; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/showpredictionpattern.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/showpredictionpattern.tt >index 0df881a..8c4a060 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/showpredictionpattern.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/showpredictionpattern.tt >@@ -6,7 +6,7 @@ > [% END %] > [% IF (ask_for_irregularities) %] > <p><em>Please check issues that are NOT published (irregularities)</em></p> >- [% IF (daily_options) %] >+ [% IF (daily_options OR monthly_options) %] > <script type="text/javascript"> > //<![CDATA[ > function Check_boxes(dow) { >@@ -21,30 +21,34 @@ > } > } > $(document).ready(function(){ >- $(".skipday").on("change",function(){ >+ $(".skip").on("change",function(){ > Check_boxes( $(this).data("dow")); > }); >+ >+ nothing_checked = 1; >+ $("input[name='irregularity']").each(function() { >+ if ($(this).is(':checked')) { >+ nothing_checked = 0; >+ } >+ }); >+ >+ // No days/monthes are checked, could be after a renewal. >+ // So check them according to permanent irregularity >+ if (nothing_checked) { >+ $(".skipday").each(function() { >+ if ($(this).is(':checked')) { >+ Check_boxes( $(this).data("dow")); >+ } >+ }); >+ } > }); > //]]> > </script> >- <p><em> >- If there is a day (or more) in the week where issues are never >- published, you can check corresponding boxes below. >- </em></p> >- <input type="checkbox" id="monday" data-dow="1" class="skipday" /> >- <label for="monday">Monday</label> >- <input type="checkbox" id="tuesday" data-dow="2" class="skipday" /> >- <label for="tuesday">Tuesday</label> >- <input type="checkbox" id="wednesday" data-dow="3" class="skipday" /> >- <label for="wednesday">Wednesday</label> >- <input type="checkbox" id="thursday" data-dow="4" class="skipday" /> >- <label for="thursday">Thursday</label> >- <input type="checkbox" id="friday" data-dow="5" class="skipday" /> >- <label for="friday">Friday</label> >- <input type="checkbox" id="saturday" data-dow="6" class="skipday" /> >- <label for="saturday">Saturday</label> >- <input type="checkbox" id="sunday" data-dow="7" class="skipday" /> >- <label for="sunday">Sunday</label> >+ [% IF (daily_options) %] >+ [% INCLUDE 'serials/subscription_daily_choice.inc' %] >+ [% ELSIF (monthly_options) %] >+ [% INCLUDE 'serials/subscription_monthly_choice.inc' %] >+ [% END %] > [% END %] > [% END %] > [% IF (predictions_loop) %] >diff --git a/serials/showpredictionpattern.pl b/serials/showpredictionpattern.pl >index 6986b5e..1e3be11 100755 >--- a/serials/showpredictionpattern.pl >+++ b/serials/showpredictionpattern.pl >@@ -112,15 +112,20 @@ if(defined $subscriptionid) { > > my @predictions_loop; > my ($calculated) = GetSeq(\%subscription, \%pattern); >+( my $month_number = (split/-/, $date)[1] ) =~ s/^0//; >+my $dow = $frequency->{unit} == 'month' ? $month_number : Day_of_Week(split /-/, $date); > push @predictions_loop, { > number => $calculated, > publicationdate => $date, > issuenumber => $issuenumber, >- dow => Day_of_Week(split /-/, $date), >+ dow => $dow, > }; > my @irreg = (); >+my @permanent_irreg = (); > if(defined $subscriptionid) { >- @irreg = C4::Serials::GetSubscriptionIrregularities($subscriptionid); >+ my $subscription_o = Koha::Subscriptions->find($subscriptionid); >+ @irreg = $subscription_o->irregularities; >+ @permanent_irreg = $subscription_o->permanent_irregularities; > while(@irreg && $issuenumber > $irreg[0]) { > shift @irreg; > } >@@ -139,7 +144,10 @@ while( $i < 1000 ) { > } > if(defined $date){ > $line{'publicationdate'} = $date; >- $line{'dow'} = Day_of_Week(split /-/, $date); >+ ( my $month_number = (split/-/, $date)[1] ) =~ s/^0//; >+ $line{'dow'} = $frequency->{unit} == 'month' >+ ? $month_number >+ : Day_of_Week(split /-/, $date); > } > > # Check if we don't have exceed end date >@@ -177,6 +185,11 @@ if ( $frequency->{unit} and not $custompattern ) { > $template->param( ask_for_irregularities => 1 ); > if ( $frequency->{unit} eq 'day' and $frequency->{unitsperissue} == 1 ) { > $template->param( daily_options => 1 ); >+ $template->param( selected_days => \@permanent_irreg ); >+ } >+ if ( $frequency->{unit} eq 'month' and $frequency->{unitsperissue} == 1 ) { >+ $template->param( monthly_options => 1 ); >+ $template->param( selected_monthes => \@permanent_irreg ); > } > } > >diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl >index 16d397b..bb04ecd 100755 >--- a/serials/subscription-add.pl >+++ b/serials/subscription-add.pl >@@ -294,6 +294,7 @@ sub redirect_add_subscription { > my $aqbudgetid = $query->param('aqbudgetid'); > my $periodicity = $query->param('frequency'); > my @irregularity = $query->multi_param('irregularity'); >+ my @permanent_irregularity = $query->multi_param('permanent_irregularity'); > my $numberpattern = $query->param('numbering_pattern'); > my $locale = $query->param('locale'); > my $graceperiod = $query->param('graceperiod') || 0; >@@ -341,10 +342,10 @@ sub redirect_add_subscription { > $startdate, $periodicity, $numberlength, $weeklength, > $monthlength, $lastvalue1, $innerloop1, $lastvalue2, $innerloop2, > $lastvalue3, $innerloop3, $status, $notes, $letter, $firstacquidate, >- join(";",@irregularity), $numberpattern, $locale, $callnumber, >- $manualhistory, $internalnotes, $serialsadditems, >- $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate, >- $skip_serialseq >+ join(";",@irregularity), join(';', @permanent_irregularity), >+ $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes, >+ $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod, >+ $location, $enddate, $skip_serialseq > ); > > my $additional_fields = Koha::AdditionalField->all( { tablename => 'subscription' } ); >@@ -357,6 +358,7 @@ sub redirect_add_subscription { > sub redirect_mod_subscription { > my $subscriptionid = $query->param('subscriptionid'); > my @irregularity = $query->multi_param('irregularity'); >+ my @permanent_irregularity = $query->multi_param('permanent_irregularity'); > my $auser = $query->param('user'); > my $librarian => scalar $query->param('librarian'), > my $branchcode = $query->param('branchcode'); >@@ -423,7 +425,8 @@ sub redirect_mod_subscription { > ModSubscription( > $auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $startdate, > $periodicity, $firstacquidate, join(";",@irregularity), >- $numberpattern, $locale, $numberlength, $weeklength, $monthlength, $lastvalue1, >+ join(';', @permanent_irregularity), $numberpattern, $locale, >+ $numberlength, $weeklength, $monthlength, $lastvalue1, > $innerloop1, $lastvalue2, $innerloop2, $lastvalue3, $innerloop3, > $status, $biblionumber, $callnumber, $notes, $letter, > $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount, >diff --git a/t/db_dependent/Serials/SubscriptionIrregularity.pm b/t/db_dependent/Serials/SubscriptionIrregularity.pm >new file mode 100644 >index 0000000..2e81d0f >--- /dev/null >+++ b/t/db_dependent/Serials/SubscriptionIrregularity.pm >@@ -0,0 +1,35 @@ >+#!/usr/bin/perl >+ >+use Modern::Perl; >+ >+use t::lib::TestBuilder; >+use Test::More tests => 6; >+ >+use Koha::Database; >+ >+use_ok('Koha::Subscription'); >+ >+my $schema = Koha::Database->new->schema; >+$schema->storage->txn_begin; >+ >+my $builder = t::lib::TestBuilder->new(); >+ >+my $subscription = $builder->build({ >+ source => 'Subscription', >+ value => { >+ irregularity => '2;4;7', >+ permanent_irregularity => '1;2' >+ }, >+}); >+ >+my $subscription_o = Koha::Subscriptions->find($subscription->{subscriptionid}); >+my @irreg = $subscription_o->irregularities; >+is($irreg[0], 2, 'First element of irregularities is 2'); >+is($irreg[1], 4, 'Second element of irregularities is 4'); >+is($irreg[2], 7, 'Third element of irregularities is 7'); >+ >+my @permanent_irreg = $subscription_o->permanent_irregularities; >+is($permanent_irreg[0], 1, 'First element of permanent_irregularities is 1'); >+is($permanent_irreg[1], 2, 'Second element of permanent_irregularities is 2'); >+ >+$schema->storage->txn_rollback; >-- >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