Bug 35074: Add support for category_code to writeoff_debts
This patch adds support for passing category_code as a limiter for the writeoff_debts script. Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
6f693a2420
commit
508d55eb7b
|
|
@ -11,15 +11,16 @@ use Koha::DateUtils qw( dt_from_string );
|
|||
|
||||
use Koha::Script -cron;
|
||||
|
||||
my ( $help, $verbose, @type, $before, $after, $file, $confirm );
|
||||
my ( $help, $verbose, @type, $before, $after, @category_code, $file, $confirm );
|
||||
GetOptions(
|
||||
'h|help' => \$help,
|
||||
'v|verbose+' => \$verbose,
|
||||
't|type:s' => \@type,
|
||||
'ab|added_before|added-before:s' => \$before,
|
||||
'aa|added_after|added-after:s' => \$after,
|
||||
'f|file:s' => \$file,
|
||||
'c|confirm' => \$confirm,
|
||||
'h|help' => \$help,
|
||||
'v|verbose+' => \$verbose,
|
||||
't|type:s' => \@type,
|
||||
'ab|added_before|added-before:s' => \$before,
|
||||
'aa|added_after|added-after:s' => \$after,
|
||||
'cc|category_code|category-code:s' => \@category_code,
|
||||
'f|file:s' => \$file,
|
||||
'c|confirm' => \$confirm,
|
||||
);
|
||||
@type = split( /,/, join( ',', @type ) );
|
||||
|
||||
|
|
@ -59,6 +60,11 @@ if ($after) {
|
|||
$where->{date}->{'>'} = $dtf->format_datetime($added_after);
|
||||
}
|
||||
|
||||
if (@category_code) {
|
||||
$where->{'patron.categorycode'}->{'-in'} = \@category_code;
|
||||
push @{ $attr->{'join'} }, 'patron';
|
||||
}
|
||||
|
||||
my $lines = Koha::Account::Lines->search( $where, $attr );
|
||||
if ( $verbose ) {
|
||||
print "Attempting to write off " . $lines->count . " debts";
|
||||
|
|
@ -168,6 +174,12 @@ Writeoff debts added after the date passed.
|
|||
Dates should be in ISO format, e.g., 2013-07-19, and can be generated
|
||||
with `date -d '-3 month' --iso-8601`.
|
||||
|
||||
=item B<--category-code>
|
||||
|
||||
Writeoff debts for patrons belonging to the passed categories.
|
||||
|
||||
Can be used multiple times for additional category codes.
|
||||
|
||||
=item B<--type>
|
||||
|
||||
Writeoff debts of the passed type. Accepts a list of CREDIT_TYPE_CODEs.
|
||||
|
|
|
|||
Loading…
Reference in New Issue