Add SIP support for Fine Items field
authorJeff Godin <jgodin@tadl.org>
Tue, 19 Jun 2012 19:31:08 +0000 (15:31 -0400)
committerDan Scott <dscott@laurentian.ca>
Thu, 2 Aug 2012 03:00:42 +0000 (23:00 -0400)
Add support for SIP Fine Items, msg 64 field AV.

Display outstanding balance, last_billing_type, and a description.

For circulation xacts, description is title / author from MODS.

For grocery xacts, description is last_billing_note.

Wishlist LP 1012328

Signed-off-by: Jeff Godin <jgodin@tadl.org>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Signed-off-by: Dan Scott <dscott@laurentian.ca>

Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm

index d446318..460e78d 100644 (file)
@@ -627,7 +627,21 @@ sub charged_items {
 sub fine_items {
        my ($self, $start, $end) = @_;
        my @fines;
-       syslog('LOG_DEBUG', 'OILS: Patron->fine_items()');
+    eval {
+           my $xacts = $U->simplereq('open-ils.actor', 'open-ils.actor.user.transactions.history.have_balance', $self->{authtoken}, $self->{user}->id);
+           foreach my $xact (@{$xacts}) {
+                my $line = $xact->balance_owed . " " . $xact->last_billing_type . " ";
+                if ($xact->xact_type eq 'circulation') {
+                    my $mods = $U->simplereq('open-ils.circ', 'open-ils.circ.circ_transaction.find_title', $self->{authtoken}, $xact->id);
+                    $line .= $mods->title . ' / ' . $mods->author;
+                } else {
+                    $line .= $xact->last_billing_note;
+                }
+                push @fines, OpenILS::SIP::clean_text($line);
+           }
+    };
+    my $log_status = $@ ? 'ERROR: ' . $@ : 'OK';
+       syslog('LOG_DEBUG', 'OILS: Patron->fine_items() ' . $log_status);
        return (defined $start and defined $end) ? 
                [ $fines[($start-1)..($end-1)] ] : \@fines;
 }