From 8a037612b134feaff41a014210e2dd81b8373eb2 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 6 Feb 2024 12:18:46 +0000 Subject: [PATCH] Bug 34077: Tidy the script Minimal changes were needed to bring the script up to date with current perltidy requirements. I opted to do a full tidy rather than just tidy the blocks changed. --- misc/cronjobs/writeoff_debts.pl | 37 ++++++++++++++------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/misc/cronjobs/writeoff_debts.pl b/misc/cronjobs/writeoff_debts.pl index 84543a8f6fd..96f077ab97d 100755 --- a/misc/cronjobs/writeoff_debts.pl +++ b/misc/cronjobs/writeoff_debts.pl @@ -4,7 +4,7 @@ use Modern::Perl; use feature 'say'; use Getopt::Long qw( GetOptions ); -use Pod::Usage qw( pod2usage ); +use Pod::Usage qw( pod2usage ); use Koha::Account::Lines; use Koha::DateUtils qw( dt_from_string ); @@ -27,12 +27,12 @@ GetOptions( pod2usage(1) if ( $help || !$file && !@type && !$before && !$after && !@category_code ); my $where = { 'amountoutstanding' => { '>' => 0 } }; -my $attr = {}; +my $attr = {}; if ($file) { my @accounts_from_file; open( my $fh, '<:encoding(UTF-8)', $file ) - or die "Could not open file '$file' $!"; + or die "Could not open file '$file' $!"; while ( my $line = <$fh> ) { chomp($line); push @accounts_from_file, $line; @@ -46,7 +46,7 @@ if (@type) { } my $dtf; -if ($before||$after) { +if ( $before || $after ) { $dtf = Koha::Database->new->schema->storage->datetime_parser; } @@ -67,22 +67,22 @@ if (@category_code) { my $lines = Koha::Account::Lines->search( $where, $attr ); -if ( $verbose ) { - print "Attempting to write off " . $lines->count . " debts" if $confirm; +if ($verbose) { + print "Attempting to write off " . $lines->count . " debts" if $confirm; print "With --confirm we would write off " . $lines->count . " debts" if !$confirm; - print " of type " . join(',',@type) if @type; - print " for patron categories " . join(', ', @category_code) if @category_code; - print " added before " . $before if $before; - print " added after " . $after if $after; - print " from the passed list" if $file; + print " of type " . join( ',', @type ) if @type; + print " for patron categories " . join( ', ', @category_code ) if @category_code; + print " added before " . $before if $before; + print " added after " . $after if $after; + print " from the passed list" if $file; print "\n"; } while ( my $line = $lines->next ) { say "Skipping " . $line->accountlines_id . "; Not a debt" and next - if $line->is_credit && $verbose > 1; + if $line->is_credit && $verbose > 1; say "Skipping " . $line->accountlines_id . "; Is a PAYOUT" and next - if $line->debit_type_code eq 'PAYOUT' && $verbose > 1; + if $line->debit_type_code eq 'PAYOUT' && $verbose > 1; if ($confirm) { $line->_result->result_source->schema->txn_do( @@ -112,11 +112,7 @@ while ( my $line = $lines->next ) { )->store(); # Link writeoff to charge - $writeoff->apply( - { - debits => [$line] - } - ); + $writeoff->apply( { debits => [$line] } ); $writeoff->status('APPLIED')->store(); # Update status of original debit @@ -128,8 +124,7 @@ while ( my $line = $lines->next ) { if ($verbose) { if ($confirm) { say "Accountline " . $line->accountlines_id . " written off"; - } - else { + } else { say "Accountline " . $line->accountlines_id . " will be written off"; } } @@ -201,7 +196,7 @@ This flag set the script to output logging for the actions it will perform. =item B<-c|--confirm> This flag must be provided in order for the script to actually -writeoff debts. +writeoff debts. =back -- 2.43.0