From 35c84332adee833db93d4e8b2db81a031dc6c1dd Mon Sep 17 00:00:00 2001 From: Alex Arnaud Date: Thu, 11 Jan 2018 14:08:25 +0000 Subject: [PATCH] Bug 17656: Fix issues found by QA - Make day and month names translatable - Update unit tests - Fix a typo in C4/Serials.pm (GessEndDate) - Rename subtype subroutine to lengthtype - DB Change: add changes in kohastructure.sql and Bug_17656-add-permanent-irregularities.perl Signed-off-by: David Nind --- C4/Serials.pm | 4 ++-- Koha/Subscription.pm | 4 ++-- .../Bug_17656-add-permanent-irregularities.perl | 9 +++++++++ .../Bug_17656-add-permanent-irregularities.sql | 1 - installer/data/mysql/kohastructure.sql | 1 + .../en/includes/serials/subscription_daily_choice.inc | 14 +++++++++++++- .../includes/serials/subscription_monthly_choice.inc | 19 ++++++++++++++++++- .../prog/en/modules/serials/subscription-renew.tt | 2 +- serials/subscription-renew.pl | 4 ++-- t/Koha/DateUtils.t | 5 +++-- t/db_dependent/Koha/Subscription.t | 8 ++++---- 11 files changed, 55 insertions(+), 16 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/Bug_17656-add-permanent-irregularities.perl delete mode 100644 installer/data/mysql/atomicupdate/Bug_17656-add-permanent-irregularities.sql diff --git a/C4/Serials.pm b/C4/Serials.pm index 15d2ed710e..9737ea92e9 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -2664,9 +2664,9 @@ sub findSerialsByStatus { return @$serials; } -=head2 GessEnddate +=head2 GuessEnddate -my $enddate = GessEnddate($startdate_iso $frequencyid, $numberlength, $weeklength, $monthlength); +my $enddate = GuessEnddate($startdate_iso $frequencyid, $numberlength, $weeklength, $monthlength); =cut diff --git a/Koha/Subscription.pm b/Koha/Subscription.pm index 3d7c80e72c..b5f8bb2e24 100644 --- a/Koha/Subscription.pm +++ b/Koha/Subscription.pm @@ -221,13 +221,13 @@ sub permanent_irregularities { return split(';', $self->permanent_irregularity); } -=head3 subtype +=head3 lengthtype Return the length type (issues, weeks, months) =cut -sub subtype { +sub lengthtype { my ($self) = @_; if ($self->numberlength) { diff --git a/installer/data/mysql/atomicupdate/Bug_17656-add-permanent-irregularities.perl b/installer/data/mysql/atomicupdate/Bug_17656-add-permanent-irregularities.perl new file mode 100644 index 0000000000..fb6314dc82 --- /dev/null +++ b/installer/data/mysql/atomicupdate/Bug_17656-add-permanent-irregularities.perl @@ -0,0 +1,9 @@ +$DBversion = 'XXX'; +if( CheckVersion( $DBversion ) ) { + if( !column_exists( 'subscription', 'permanent_irregularity' ) ) { + $dbh->do( "ALTER TABLE `subscription` ADD permanent_irregularity MEDIUMTEXT AFTER irregularity" ); + } + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 17656 - Irregularities in serial prediction pattern are planned only for current subscription)\n"; +} diff --git a/installer/data/mysql/atomicupdate/Bug_17656-add-permanent-irregularities.sql b/installer/data/mysql/atomicupdate/Bug_17656-add-permanent-irregularities.sql deleted file mode 100644 index cb9cd1d40a..0000000000 --- a/installer/data/mysql/atomicupdate/Bug_17656-add-permanent-irregularities.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `subscription` ADD permanent_irregularity text AFTER irregularity; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 0b49e522e0..58ba443c84 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1955,6 +1955,7 @@ CREATE TABLE `subscription` ( -- information related to the subscription `firstacquidate` date default NULL, -- first issue received date `manualhistory` tinyint(1) NOT NULL default 0, -- yes or no to managing the history manually `irregularity` MEDIUMTEXT, -- any irregularities in the subscription + `permanent_irregularity` MEDIUMTEXT, skip_serialseq BOOLEAN NOT NULL DEFAULT 0, `letter` varchar(20) default NULL, `numberpattern` integer default null, -- the numbering pattern used links to subscription_numberpatterns.id diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/serials/subscription_daily_choice.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/serials/subscription_daily_choice.inc index 4e1688de1c..cf6f63efe3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/serials/subscription_daily_choice.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/serials/subscription_daily_choice.inc @@ -4,6 +4,18 @@

[% daily_choice = [ {name => 'monday', desc => 'Monday', value => 1}, {name => 'tuesday', desc => 'Tuesday', value => 2}, {name => 'wednesday', desc => 'Wednesday', value => 3}, {name => 'thursday', desc => 'Thursday', value => 4}, {name => 'friday', desc => 'Friday', value => 5}, {name => 'saturday', desc => 'Saturday', value => 6}, {name => 'sunday', desc => 'Sunday', value => 7} ] %] +[% BLOCK days %] + [% SWITCH d %] + [% CASE 'monday' %]Monday + [% CASE 'tuesday' %]Tuesday + [% CASE 'wednesday' %]Wednesday + [% CASE 'thursday' %]Thursday + [% CASE 'friday' %]Friday + [% CASE 'saturday' %]Saturday + [% CASE 'sunday' %]Sunday + [% END %] +[% END %] + [% FOREACH day IN daily_choice %] [% IF permanent_irreg.grep( day.value ).0 == day.value %] [% END %] - + [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/serials/subscription_monthly_choice.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/serials/subscription_monthly_choice.inc index 29bf9fdf56..fde9b605e8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/serials/subscription_monthly_choice.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/serials/subscription_monthly_choice.inc @@ -4,6 +4,23 @@

[% monthly_choice = [ {name => 'january', desc => 'January', value => 1}, {name => 'february', desc => 'February', value => 2}, {name => 'march', desc => 'March', value => 3}, {name => 'april', desc => 'April', value => 4}, {name => 'may', desc => 'May', value => 5}, {name => 'june', desc => 'June', value => 6}, {name => 'july', desc => 'July', value => 7}, {name => 'august', desc => 'August', value => 8}, {name => 'september', desc => 'September', value => 9}, {name => 'october', desc => 'October', value => 10}, {name => 'november', desc => 'November', value => 11}, {name => 'december', desc => 'December', value =>12} ] %] +[% BLOCK months %] + [% SWITCH m %] + [% CASE 'january' %]January + [% CASE 'february' %]February + [% CASE 'march' %]March + [% CASE 'april' %]April + [% CASE 'may' %]May + [% CASE 'june' %]June + [% CASE 'july' %]July + [% CASE 'august' %]August + [% CASE 'september' %]September + [% CASE 'october' %]October + [% CASE 'november' %]November + [% CASE 'december' %]December + [% END %] +[% END %] + [% FOREACH month IN monthly_choice %] [% IF permanent_irreg.grep( month.value ).0 == month.value %] [% END %] - + [% END %] 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 0b5cebf918..f2f3b59f2a 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 @@ -34,7 +34,7 @@ - + diff --git a/serials/subscription-renew.pl b/serials/subscription-renew.pl index 318c51c4be..2c4f959923 100755 --- a/serials/subscription-renew.pl +++ b/serials/subscription-renew.pl @@ -141,7 +141,7 @@ if ( $op eq "renew" ) { } my $subscription_o = Koha::Subscriptions->find($subscription->{subscriptionid}); - my $subtype = $subscription_o->subtype; + my $lengthtype = $subscription_o->lengthtype; my $nextexpected = GetNextExpected($subscriptionid); my $enddate = GuessEnddate($subscription->{enddate} || dt_from_string, $subscription->{periodicity}, @@ -166,7 +166,7 @@ if ( $op eq "renew" ) { startdate => $newstartdate, nextacquidate => $nextexpected->{planneddate}, enddate => $enddate, - subtype => $subtype, + lengthtype => $lengthtype, sublength => $sub_length, ); } diff --git a/t/Koha/DateUtils.t b/t/Koha/DateUtils.t index f0af15c404..fa47c0d491 100644 --- a/t/Koha/DateUtils.t +++ b/t/Koha/DateUtils.t @@ -17,7 +17,7 @@ use Modern::Perl; -use Test::More tests => 9; +use Test::More tests => 10; use Test::Warn; BEGIN { @@ -27,6 +27,7 @@ BEGIN { my $dt = DateTime->new(year => 2017, month => 1, day => 1); eval { issue_number('2017', 'day'); }; +is(ref($@), 'Koha::Exceptions::WrongParameter'); is($@, 'Date passed to issue_number is not a valid DateTime object'); is(issue_number($dt, 'day'), 7, '2017-01-01 is the seventh day of week'); @@ -41,6 +42,6 @@ is(issue_number($dt, 'day'), 6, '2022-09-17 is the sixth day of week'); is(issue_number($dt, 'week'), 37, '2022-09-17 is the week #37 of the year'); -is(issue_number($dt, 'month'), 9, '2017-09-17 is the ninth month of the year'); +is(issue_number($dt, 'month'), 9, '2022-09-17 is the ninth month of the year'); is(issue_number($dt, 'foo'), 0, 'issue_number return 0 for others issue type'); diff --git a/t/db_dependent/Koha/Subscription.t b/t/db_dependent/Koha/Subscription.t index 7220ca129e..ac641b9bc9 100644 --- a/t/db_dependent/Koha/Subscription.t +++ b/t/db_dependent/Koha/Subscription.t @@ -106,7 +106,7 @@ subtest 'Koha::Subscription->frequency' => sub { is( $subscription->frequency->id, $frequency->id, 'Koha::Subscription->frequency should return the correct frequency' ); }; -subtest 'Koha::Subscription::subtype' => sub { +subtest 'Koha::Subscription::lengthtype' => sub { plan tests => 3; my $subs = $builder->build({ @@ -118,7 +118,7 @@ subtest 'Koha::Subscription::subtype' => sub { } }); my $subscription = Koha::Subscriptions->find($subs->{subscriptionid}); - is($subscription->subtype, 'issues', 'Subscription with numberlength has issues type'); + is($subscription->lengthtype, 'issues', 'Subscription with numberlength has issues type'); my $subs2 = $builder->build({ source => 'Subscription', @@ -129,7 +129,7 @@ subtest 'Koha::Subscription::subtype' => sub { } }); my $subscription2 = Koha::Subscriptions->find($subs2->{subscriptionid}); - is($subscription2->subtype, 'weeks', 'Subscription with weeklength has weeks type'); + is($subscription2->lengthtype, 'weeks', 'Subscription with weeklength has weeks type'); my $subs3 = $builder->build({ source => 'Subscription', @@ -140,7 +140,7 @@ subtest 'Koha::Subscription::subtype' => sub { } }); my $subscription3 = Koha::Subscriptions->find($subs3->{subscriptionid}); - is($subscription3->subtype, 'months', 'Subscription with monthlength has months type'); + is($subscription3->lengthtype, 'months', 'Subscription with monthlength has months type'); }; my $nb_of_subs = Koha::Subscriptions->search->count; -- 2.11.0