Bugzilla – Attachment 127463 Details for
Bug 28995
Add --added_after to writeoff_debts.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28995: Add `--added_after` filter to writeoff_debts script
Bug-28995-Add---addedafter-filter-to-writeoffdebts.patch (text/plain), 2.46 KB, created by
Martin Renvoize (ashimema)
on 2021-11-09 10:34:09 UTC
(
hide
)
Description:
Bug 28995: Add `--added_after` filter to writeoff_debts script
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-11-09 10:34:09 UTC
Size:
2.46 KB
patch
obsolete
>From f63bd5ab4e506372014d2eb4e066119a80140d61 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Tue, 9 Nov 2021 10:33:01 +0000 >Subject: [PATCH] Bug 28995: Add `--added_after` filter to writeoff_debts > script > >This adds, as requested, the `added_after` filter option to >writeoff_debts. >--- > misc/cronjobs/writeoff_debts.pl | 26 ++++++++++++++++++-------- > 1 file changed, 18 insertions(+), 8 deletions(-) > >diff --git a/misc/cronjobs/writeoff_debts.pl b/misc/cronjobs/writeoff_debts.pl >index 64e196b388..85c2dd465f 100755 >--- a/misc/cronjobs/writeoff_debts.pl >+++ b/misc/cronjobs/writeoff_debts.pl >@@ -11,18 +11,19 @@ use Koha::DateUtils qw( dt_from_string ); > > use Koha::Script -cron; > >-my ( $help, $verbose, @type, $added, $file, $confirm ); >+my ( $help, $verbose, @type, $before, $after, $file, $confirm ); > GetOptions( > 'h|help' => \$help, > 'v|verbose+' => \$verbose, > 't|type:s' => \@type, >- 'ab|added_before:s' => \$added, >+ 'ab|added_before:s' => \$before, >+ 'aa|added_after:s' => \$after, > 'f|file:s' => \$file, > 'c|confirm' => \$confirm, > ); > @type = split( /,/, join( ',', @type ) ); > >-pod2usage(1) if ( $help || !$confirm && !$verbose || !$file && !@type && !$added ); >+pod2usage(1) if ( $help || !$confirm && !$verbose || !$file && !@type && !$before && !$after ); > > my $where = { 'amountoutstanding' => { '>' => 0 } }; > my $attr = {}; >@@ -43,17 +44,26 @@ if (@type) { > $where->{debit_type_code} = \@type; > } > >-if ($added) { >- my $added_before = dt_from_string( $added, 'iso' ); >- my $dtf = Koha::Database->new->schema->storage->datetime_parser; >- $where->{date} = { '<' => $dtf->format_datetime($added_before) }; >+my $dtf; >+if ($before||$after) { >+ $dtf = Koha::Database->new->schema->storage->datetime_parser; >+} >+ >+if ($before) { >+ my $added_before = dt_from_string( $before, 'iso' ); >+ $where->{date}->{'<'} = $dtf->format_datetime($added_before); >+} >+ >+if ($after) { >+ my $added_after = dt_from_string( $after, 'iso' ); >+ $where->{date}->{'>'} = $dtf->format_datetime($added_after); > } > > my $lines = Koha::Account::Lines->search( $where, $attr ); > if ( $verbose ) { > print "Attempting to write off " . $lines->count . " debts"; > print " of type " . join(',',@type) if @type; >- print " added before " . $added if $added; >+ print " added before " . $before if $before; > print " from the passed list" if $file; > print "\n"; > } >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 28995
:
127463
|
127624
|
127625
|
152520
|
152521
|
155385
|
155386