View | Details | Raw Unified | Return to bug 27049
Collapse All | Expand All

(-)a/misc/cronjobs/writeoff_debts.pl (-13 / +13 lines)
Lines 1-6 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
use feature 'say';
4
5
5
use Getopt::Long;
6
use Getopt::Long;
6
use Pod::Usage;
7
use Pod::Usage;
Lines 12-23 use Koha::Script -cron; Link Here
12
13
13
my ( $help, $verbose, @type, $added, $file, $confirm );
14
my ( $help, $verbose, @type, $added, $file, $confirm );
14
GetOptions(
15
GetOptions(
15
    'h|help'         => \$help,
16
    'h|help'            => \$help,
16
    'v|verbose'      => \$verbose,
17
    'v|verbose+'        => \$verbose,
17
    'type:s'         => \@type,
18
    't|type:s'          => \@type,
18
    'added_before:s' => \$added,
19
    'ab|added_before:s' => \$added,
19
    'f|file:s'       => \$file,
20
    'f|file:s'          => \$file,
20
    'c|confirm'      => \$confirm,
21
    'c|confirm'         => \$confirm,
21
);
22
);
22
@type = split( /,/, join( ',', @type ) );
23
@type = split( /,/, join( ',', @type ) );
23
24
Lines 58-67 if ( $verbose ) { Link Here
58
}
59
}
59
60
60
while ( my $line = $lines->next ) {
61
while ( my $line = $lines->next ) {
61
    warn "Skipping " . $line->accountlines_id . "; Not a debt" and next
62
    say "Skipping " . $line->accountlines_id . "; Not a debt" and next
62
      if $line->is_credit;
63
      if $line->is_credit && $verbose > 1;
63
    warn "Skipping " . $line->accountlines_id . "; Is a PAYOUT" and next
64
    say "Skipping " . $line->accountlines_id . "; Is a PAYOUT" and next
64
      if $line->debit_type_code eq 'PAYOUT';
65
      if $line->debit_type_code eq 'PAYOUT' && $verbose > 1;
65
66
66
    if ($confirm) {
67
    if ($confirm) {
67
        $line->_result->result_source->schema->txn_do(
68
        $line->_result->result_source->schema->txn_do(
Lines 107-116 while ( my $line = $lines->next ) { Link Here
107
108
108
    if ($verbose) {
109
    if ($verbose) {
109
        if ($confirm) {
110
        if ($confirm) {
110
            print "Accountline " . $line->accountlines_id . " written off\n";
111
            say "Accountline " . $line->accountlines_id . " written off";
111
        }
112
        }
112
        else {
113
        else {
113
            print "Accountline " . $line->accountlines_id . " will be written off\n";
114
            say "Accountline " . $line->accountlines_id . " will be written off";
114
        }
115
        }
115
    }
116
    }
116
}
117
}
117
- 

Return to bug 27049