Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use strict;
- use warnings;
- use OpenILS::Utils::Cronscript;
- use Data::Dumper;
- use DBI;
- my $apputils = 'OpenILS::Application::AppUtils';
- my $script = OpenILS::Utils::Cronscript->new({nolockfile=>1});
- my $login = {
- username => $ARGV[0],
- password => $ARGV[1],
- workstation => $ARGV[2],
- type => 'staff'
- };
- my $authtoken = $script->authenticate($login);
- die "failed to authenticate" unless($authtoken);
- END {
- $script->logout();
- }
- my $settings = {
- host => "next-db01",
- db => "evergreen",
- user => "evergreen"
- };
- my $dbh = DBI->connect('DBI:Pg:dbname=' . $settings->{'db'} . ';host=' . $settings->{'host'}, $settings->{'user'},
- undef,
- {
- RaiseError => 1,
- ShowErrorStatement => 0,
- AutoCommit => 0
- }
- ) or die DBI->errstr;
- my $query = "select * from csharp.okrls_forgive_fines_2018_11_07";
- my $sth = $dbh->prepare($query);
- $sth->execute();
- my @payments;
- my $xacts = $sth->fetchall_hashref("xact_id");
- #print Dumper $xacts;
- my @payments = ();
- foreach my $xact (%$xacts) {
- printf("\t%d : %.2f\n", $xact->xact_id, $xact->balance_owed);
- push(@payments, [$xact->xact_id, $xact->balance_owed])
- if ($xact->balance_owed > 0.0);
- }
- # if (@payments) {
- # my $r = forgive_bills($user, \@payments);
- # print Dumper $r;
- # }
- #print Dumper @payments;
- #sub forgive_bills {
- # my $user = shift;
- # my $paymentref = shift;
- #
- # my $result = $apputils->simplereq(
- # 'open-ils.circ',
- # 'open-ils.circ.money.payment',
- # $authtoken,
- # {
- # payment_type => "forgive_payment",
- # userid => $user->id,
- # note => "Bills forgiven per OKRLS Board action 11/5/2018",
- # payments => $paymentref
- # },
- # $user->last_xact_id
- # );
- # return $result;
- #}
- #
- $sth->finish();
- $dbh->disconnect();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement