Bug 14402: Add function purge_zero_balance_fees to C4/Accounts.pm

http://bugs.koha-community.org/show_bug.cgi?id=14402

Signed-off-by: Nancy Keener <nkeener@washoecounty.us>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Barton Chittenden 2015-07-18 11:41:38 -07:00 committed by Tomas Cohen Arazi
parent 2443e5b0a7
commit 2df3334705

View file

@ -46,9 +46,10 @@ BEGIN {
&getrefunds
&chargelostitem
&ReversePayment
&makepartialpayment
&recordpayment_selectaccts
&WriteOffFee
&makepartialpayment
&recordpayment_selectaccts
&WriteOffFee
&purge_zero_balance_fees
);
}
@ -824,6 +825,31 @@ sub WriteOffFee {
}
=head2 purge_zero_balance_fees
purge_zero_balance_fees( $days );
Delete accountlines entries where amountoutstanding is 0 which are more than a given number of days old.
B<$days> -- Zero balance fees older than B<$days> days old will be deleted.
=cut
sub purge_zero_balance_fees {
my $days = shift;
my $count = 0;
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare(
q{
DELETE FROM accountlines
WHERE date < date_sub(curdate(), INTERVAL ? DAY)
AND amountoutstanding = 0;
}
);
$sth->execute($days) or die $dbh->errstr;
}
END { } # module clean-up code here (global destructor)
1;