+
+sub _skip_borrowers_with_nonzero_balance {
+ my $borrowers = shift;
+ my $balance;
+ @$borrowers = map {
+ my $patron = Koha::Patrons->find( $_->{borrowernumber} );
+ my $balance = $patron->account->balance;
+ (defined $balance && $balance != 0) ? (): ($_);
+ } @$borrowers;
+}
+
+sub _get_selection_params {
+ my ($not_borrowed_since, $borrower_dateexpiry, $borrower_lastseen,
+ $borrower_categorycode, $patron_list_id, $branch) = @_;
+
+ my $params = {};
+ $params->{not_borrowed_since} = output_pref({
+ dt => $not_borrowed_since,
+ dateformat => 'iso',
+ dateonly => 1
+ }) if $not_borrowed_since;
+ $params->{expired_before} = output_pref({
+ dt => $borrower_dateexpiry,
+ dateformat => 'iso',
+ dateonly => 1
+ }) if $borrower_dateexpiry;
+ $params->{last_seen} = output_pref({
+ dt => $borrower_lastseen,
+ dateformat => 'iso',
+ dateonly => 1
+ }) if $borrower_lastseen;
+ $params->{category_code} = $borrower_categorycode if $borrower_categorycode;
+ $params->{patron_list_id} = $patron_list_id if $patron_list_id;
+
+ if ( defined $branch and $branch ne '*' ) {
+ $params->{ branchcode } = $branch;
+ }
+
+ return $params;
+};