@@ -, +, @@ --- C4/Serials.pm | 17 +++++++++-------- .../prog/en/modules/serials/subscription-renew.tt | 8 ++++---- serials/subscription-add.pl | 4 ++-- serials/subscription-renew.pl | 3 ++- t/db_dependent/Serials/ReNewSubscription.t | 17 ++++++++++++++++- 5 files changed, 33 insertions(+), 16 deletions(-) --- a/C4/Serials.pm +++ a/C4/Serials.pm @@ -74,7 +74,7 @@ BEGIN { &GetNextSeq &GetSeq &NewIssue &GetSerials &GetLatestSerials &ModSerialStatus &GetNextDate &GetSerials2 - &ReNewSubscription &GetLateOrMissingIssues + &getsublength &ReNewSubscription &GetLateOrMissingIssues &GetSerialInformation &AddItem2Serial &PrepareSerialsData &GetNextExpected &ModNextExpected &GetPreviousSerialid @@ -1483,20 +1483,21 @@ sub NewSubscription { return $subscriptionid; } -=head2 _get_sub_length -my ($numberlength, $weeklength, $monthlength) = _get_sub_length( $subtype, $sublength ); +=head2 getsublength -this function calculates the subscription length. +my ($numberlength, $weeklength, $monthlength) = getsublength( $subtype, $sublength ); + +This function calculates the subscription length. =cut -sub _get_sub_length { - my ($type, $subtype, $length) = @_; +sub getsublength { + my ($subtype, $length) = @_; return ( $subtype eq 'issues' ? $length : 0, - $subtype eq 'weeks' ? $length : 0, - $subtype eq 'months' ? $length : 0, + $subtype eq 'weeks' ? $length : 0, + $subtype eq 'months' ? $length : 0, ); } --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-renew.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-renew.tt @@ -35,9 +35,9 @@
[% INCLUDE 'date-format.inc' %]
-
  • - Subscription length: - [% FOREACH st IN subtypes %] [% SWITCH st %] [% CASE 'numberlength'%] @@ -61,7 +61,7 @@ [% END %] --- a/serials/subscription-add.pl +++ a/serials/subscription-add.pl @@ -320,7 +320,7 @@ sub redirect_add_subscription { my $subtype = $query->param('subtype'); my $sublength = $query->param('sublength'); my ( $numberlength, $weeklength, $monthlength ) - = C4::Serials->_get_sub_length( $subtype, $sublength ); + = C4::Serials->getsublength( $subtype, $sublength ); my $add1 = $query->param('add1'); my $lastvalue1 = $query->param('lastvalue1'); my $innerloop1 = $query->param('innerloop1'); @@ -433,7 +433,7 @@ sub redirect_mod_subscription { my $subtype = $query->param('subtype'); my $sublength = $query->param('sublength'); - my ($numberlength, $weeklength, $monthlength) = C4::Serials->get_sub_length( $subtype, $sublength ); + my ($numberlength, $weeklength, $monthlength) = C4::Serials->getsublength( $subtype, $sublength ); my $numberpattern = $query->param('numbering_pattern'); my $locale = $query->param('locale'); my $lastvalue1 = $query->param('lastvalue1'); --- a/serials/subscription-renew.pl +++ a/serials/subscription-renew.pl @@ -64,7 +64,7 @@ my @subscriptionids = $query->multi_param('subscriptionid'); my $branchcode = $query->param('branchcode'); my $sublength = $query->param('sublength'); my $subtype = $query->param('subtype'); -my ($numberlength, $weeklength, $monthlength) = C4::Serials->get_sub_length( $subtype, $sublength ); +my ($numberlength, $weeklength, $monthlength) = C4::Serials->getsublength( $subtype, $sublength ); my $done = 0; # for after form has been submitted my ( $template, $loggedinuser, $cookie ) = get_template_and_user( @@ -134,6 +134,7 @@ my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, ); $template->param( op => $op, libraries => $libraries, + subtypes => [ qw( numberlength weeklength monthlength ) ], ); output_html_with_http_headers $query, $cookie, $template->output; --- a/t/db_dependent/Serials/ReNewSubscription.t +++ a/t/db_dependent/Serials/ReNewSubscription.t @@ -3,6 +3,7 @@ # This script includes tests for ReNewSubscription # Copyright 2015 BibLibre, Paul Poulain +# Copyright 2018 Catalyst IT, Alex Buckley # # This file is part of Koha. # @@ -21,7 +22,7 @@ use Modern::Perl; -use Test::More tests => 1; +use Test::More tests => 4; use Test::MockModule; use t::lib::TestBuilder; use t::lib::Mocks; @@ -93,6 +94,20 @@ ReNewSubscription( monthlength => 12 } ); + +# Calculate the subscription length for the renewal for issues, days and months +my ($numberlength, $weeklength, $monthlength) = getsublength('issues', 7); +is ( $numberlength, 7, "Sub length is 7 issues"); + +($numberlength, $weeklength, $monthlength) = getsublength('weeks', 7); +is ( $weeklength, 7, "Sub length is 7 weeks"); + +($numberlength, $weeklength, $monthlength) = getsublength('months', 7); +is ( $monthlength, 7, "Sub length is 7 months"); + +# Renew the subscription and check that enddate has not been set + +ReNewSubscription($subscription->{subscriptionid},'',"2016-01-01",'','',12,''); my $history = Koha::Subscription::Histories->find($subscription->{subscriptionid}); is ( $history->histenddate(), undef, 'subscription history not empty after renewal'); --