Support fine detail enhancement to SIP. The particular flavor of user/dpearl/fine_detail_SERV_A
authorDan Pearl <dpearl@cwmars.org>
Thu, 25 May 2017 18:10:01 +0000 (14:10 -0400)
committerDan Pearl <dpearl@cwmars.org>
Wed, 28 Jun 2017 19:53:22 +0000 (15:53 -0400)
fine detail output is manufacturer dependent, although 3m is popular, and
the default.  To configure the selection, modify the
/openils/conf/oils_sip.xml file.

Open-ILS/examples/oils_sip.xml.example
Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm

index c3843e3..69b192c 100644 (file)
                        timeout="60" />
        </listeners>
 
+        <!-- Fine Detail returned by the Patron Information Request is   -->
+        <!-- manufacturer-specific.  We support the following formats:   -->
+        <!--     3m (default), Swyer_A, Swyer_B, and EG_Legacy           -->
+        <!-- Specify which treatment you want in the AV_format attribute -->
+        <!-- in the <login>                                              -->
+     
        <accounts>
-               <login id="scclient" password="clientpwd" institution="gapines"/>
+               <login id="scclient" password="clientpwd" AV_format="3m" institution="gapines"/>
        </accounts>
 
        <!-- Institution tags will hold stuff used to interface to -->
index 0845084..6318dcd 100644 (file)
@@ -857,25 +857,74 @@ sub charged_items_impl {
 }
 
 sub fine_items {
-    my ($self, $start, $end, $ids_only) = @_;
+    my ($self, $start, $end, $ids_only, $server) = @_;
     my @fines;
+    my ($AV_format_orig, $AV_format, $line);
+
     eval {
+       $AV_format_orig = $server ? $server->{account}->{AV_format} : undef;
+       $AV_format_orig ||= "3m";
+       $AV_format = lc $AV_format_orig;  # For case-insensitivity
+
+        # Do a prescan for validity and default to 3M 
+       if ($AV_format ne "swyer_a" && 
+           $AV_format ne "swyer_b" && 
+           $AV_format ne "eg_legacy" && 
+           $AV_format ne "3m") {
+           syslog('LOG_WARNING', 
+                   "OILS: Unknown value for AV_format: %s", $AV_format_orig);
+           $AV_format = "3m";
+       }
+
        my $xacts = $U->simplereq('open-ils.actor', 'open-ils.actor.user.transactions.history.have_balance', $self->{authtoken}, $self->{user}->id);
+
        foreach my $xact (@{$xacts}) {
            if ($ids_only) {
-               push @fines, $xact;
-               next;
+                push @fines, $xact;
+                next;
            }
-           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);
+
+           if ($AV_format eq "eg_legacy") {
+                  $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);
+
+               # For now, swyer_a looks suspiciously like 3m!
+          } elsif ($AV_format eq "3m" or $AV_format eq "swyer_a") {
+                  $line = $xact->id . ' $' . $xact->balance_owed . ' "FINE" ' . $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);
+
+          } elsif ($AV_format eq "swyer_b") {
+                  $line =   "Charge-Number: " . $xact->id;
+                  $line .=  ", Amount-Due: "  . $xact->balance_owed;
+                  $line .=  ", Fine-Type: FINE";
+
+                  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 .= ", Title: " . $mods->title;
+                  } else {
+                      $line .= ", Title: " . $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) ?