From cadb3ed3e65a2c572cb613dd8ddb295fe5412e83 Mon Sep 17 00:00:00 2001 From: Alex Arnaud Date: Thu, 11 Jan 2018 14:08:25 +0000 Subject: [PATCH] Bug 17656 - Fix QA comments - 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 --- 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 52bf2bb..8550c18 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -2713,9 +2713,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 8d5aeca..4b92c9d 100644 --- a/Koha/Subscription.pm +++ b/Koha/Subscription.pm @@ -72,13 +72,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 0000000..b4c6000 --- /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 text 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 cb9cd1d..0000000 --- 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 f031503..b9a58ff 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2095,6 +2095,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` text, -- any irregularities in the subscription + `permanent_irregularity` text, 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 4e1688d..cf6f63e 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 29bf9fd..fde9b60 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 05674ee..d8b82a3 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 @@ -29,7 +29,7 @@ - + diff --git a/serials/subscription-renew.pl b/serials/subscription-renew.pl index a997c64..ef15bf7 100755 --- a/serials/subscription-renew.pl +++ b/serials/subscription-renew.pl @@ -108,7 +108,7 @@ if ($serials_number > 1) { } 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}, @@ -137,7 +137,7 @@ $template->param( firstacquidate => $subscription->{firstacquidate}, nextacquidate => $nextexpected->{planneddate}, enddate => $enddate, - subtype => $subtype, + lengthtype => $lengthtype, sublength => $sub_length, numberingmethod => $numberpattern->{numberingmethod}, lastvalue1 => $subscription->{lastvalue1}, diff --git a/t/Koha/DateUtils.t b/t/Koha/DateUtils.t index f0af15c..fa47c0d 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 e47ca75..ff939f1 100644 --- a/t/db_dependent/Koha/Subscription.t +++ b/t/db_dependent/Koha/Subscription.t @@ -42,7 +42,7 @@ subtest 'Koha::Subscription::biblio' => sub { is($b->biblionumber, $biblio->biblionumber, 'Koha::Subscription::biblio returns the correct biblio'); }; -subtest 'Koha::Subscription::subtype' => sub { +subtest 'Koha::Subscription::lengthtype' => sub { plan tests => 3; my $subs = $builder->build({ @@ -54,7 +54,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', @@ -65,7 +65,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', @@ -76,7 +76,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'); }; $schema->storage->txn_rollback; -- 2.7.4