From ec0fa8c0eff8af420c9f54f2a7b0bf95a9911bdd Mon Sep 17 00:00:00 2001 From: Arthur Suzuki Date: Thu, 7 Aug 2025 09:20:07 +0000 Subject: [PATCH] Bug 17656: (QA follow-up) perltidy + small fixes --- C4/Serials.pm | 8 ++++---- Koha/Subscription.pm | 12 +++++------- serials/showpredictionpattern.pl | 4 ++-- serials/subscription-add.pl | 6 +++--- serials/subscription-renew.pl | 14 ++++++-------- 5 files changed, 20 insertions(+), 24 deletions(-) diff --git a/C4/Serials.pm b/C4/Serials.pm index 5a00df60002..3c714902904 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -20,7 +20,7 @@ package C4::Serials; use Modern::Perl; -use Carp qw( croak ); +use Carp qw( croak ); use Date::Calc qw( Add_Delta_Days Add_Delta_YM @@ -30,14 +30,14 @@ use Date::Calc qw( Today ); use DateTime; -use POSIX qw( strftime ); +use POSIX qw( strftime ); use Scalar::Util qw( looks_like_number ); use Try::Tiny; -use C4::Auth qw( haspermission ); +use C4::Auth qw( haspermission ); use C4::Biblio qw( GetMarcFromKohaField ModBiblio ); use C4::Context; -use C4::Log qw( logaction ); # logaction +use C4::Log qw( logaction ); # logaction use C4::Serials::Frequency qw( GetSubscriptionFrequency ); use C4::Serials::Numberpattern; use Koha::AdditionalFieldValues; diff --git a/Koha/Subscription.pm b/Koha/Subscription.pm index f6fa74c5c48..98e6b2eae73 100644 --- a/Koha/Subscription.pm +++ b/Koha/Subscription.pm @@ -28,7 +28,7 @@ use Koha::Biblioitems; use Koha::Subscriptions; use Koha::Subscription::Frequencies; use Koha::Subscription::Numberpatterns; -use Koha::DateUtils; +use Koha::DateUtils qw( dt_from_string ); use JSON; use Date::Calc qw( Delta_Days Add_Delta_Days Add_Delta_YM ); @@ -254,23 +254,21 @@ sub guess_irregularities { 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 $frequency = $self->frequency; my $enddate = $self->enddate; my $nextexpected = C4::Serials::GetNextExpected( $self->id ); my $date = $nextexpected->{planneddate}; - my ($issuenumber) = C4::Serials::GetFictiveIssueNumber( $self->unblessed, $date ); + my ($issuenumber) = C4::Serials::GetFictiveIssueNumber( $self->unblessed, $date, $frequency->unblessed ); my $dow = C4::Serials::issue_number( dt_from_string($date), $frequency->unit ); if ( defined( $permanent_irregularities{$dow} ) ) { push @irregularities, $issuenumber; } - while ( Delta_Days( split( /-/, $date ), split( /-/, $enddate ) ) >= 0 ) { + while ( $date && Delta_Days( split( /-/, $date ), split( /-/, $enddate ) ) >= 0 ) { $issuenumber++; - $date = C4::Serials::GetNextDate( $self->unblessed, $date ); + $date = C4::Serials::GetNextDate( $self->unblessed, $date, $frequency->unblessed ); $dow = C4::Serials::issue_number( dt_from_string($date), $frequency->unit ); if ( defined( $permanent_irregularities{$dow} ) ) { diff --git a/serials/showpredictionpattern.pl b/serials/showpredictionpattern.pl index ec5156455fb..8b556ce9ee2 100755 --- a/serials/showpredictionpattern.pl +++ b/serials/showpredictionpattern.pl @@ -30,9 +30,9 @@ publication date, based on frequency and first publication date. use Modern::Perl; -use CGI qw ( -utf8 ); +use CGI qw ( -utf8 ); use Date::Calc qw( Add_Delta_Days Add_Delta_YM Day_of_Week Delta_Days ); -use C4::Auth qw( get_template_and_user ); +use C4::Auth qw( get_template_and_user ); use C4::Output qw( output_html_with_http_headers ); use C4::Serials qw( GetSubscription GetFictiveIssueNumber GetSeq GetSubscriptionIrregularities GetNextDate GetNextSeq issue_number ); diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl index bec13030e55..de62e8018ed 100755 --- a/serials/subscription-add.pl +++ b/serials/subscription-add.pl @@ -17,10 +17,10 @@ use Modern::Perl; -use CGI qw ( -utf8 ); +use CGI qw ( -utf8 ); use Date::Calc qw( Add_Delta_Days Add_Delta_YM ); -use C4::Koha qw( GetAuthorisedValues ); -use C4::Auth qw( get_template_and_user ); +use C4::Koha qw( GetAuthorisedValues ); +use C4::Auth qw( get_template_and_user ); use C4::Output qw( output_and_exit output_html_with_http_headers ); use C4::Context; use C4::Serials diff --git a/serials/subscription-renew.pl b/serials/subscription-renew.pl index 096a96eed31..7d993728002 100755 --- a/serials/subscription-renew.pl +++ b/serials/subscription-renew.pl @@ -44,18 +44,18 @@ Id of the subscription this script has to renew use Modern::Perl; -use CGI qw ( -utf8 ); +use CGI qw ( -utf8 ); use Carp qw( carp ); use C4::Koha; use C4::Auth qw( get_template_and_user ); use C4::Context; -use C4::Auth qw( get_template_and_user ); -use C4::Output qw( output_and_exit output_html_with_http_headers ); +use C4::Auth qw( get_template_and_user ); +use C4::Output qw( output_and_exit output_html_with_http_headers ); use C4::Serials qw( GetSubscription GetSubscriptionLength NewSubscription ReNewSubscription GetSerials GetNextExpected); use C4::Serials::Frequency; use C4::Serials::Numberpattern; use Koha::DateUtils qw( dt_from_string output_pref ); -use Date::Calc qw(Today Day_of_Year Week_of_Year Add_Delta_Days Add_Delta_YM); +use Date::Calc qw(Today Day_of_Year Week_of_Year Add_Delta_Days Add_Delta_YM); my $query = CGI->new; my $dbh = C4::Context->dbh; @@ -148,9 +148,8 @@ if ( $op eq "cud-renew" ) { print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid"); } - my $newstartdate = output_pref( { str => $subscription->{enddate}, dateonly => 1 } ) - or output_pref( { dt => dt_from_string, dateonly => 1 } ); - + my $newstartdate = output_pref( { str => $subscription->{enddate}, dateonly => 1, dateformat => 'iso' } ) + or output_pref( { dt => dt_from_string, dateonly => 1, dateformat => 'iso' } ); my ($serials_number) = GetSerials($subscriptionid); if ( $serials_number > 1 ) { $template->param( more_than_one_serial => 1 ); @@ -181,7 +180,6 @@ if ( $op eq "cud-renew" ) { my $numberpattern = GetSubscriptionNumberpattern( $subscription->{numberpattern} ); $template->param( - startdate => $newstartdate, subscription => $subscription, numberpattern => $numberpattern, startdate => $newstartdate, -- 2.39.5