LP#1731021: Support fine detail enhancement to SIP.
authorDan Pearl <dpearl@cwmars.org>
Thu, 25 May 2017 18:10:01 +0000 (14:10 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Fri, 6 Sep 2019 21:53:44 +0000 (17:53 -0400)
The particular flavor of 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.

Testing: See the /openils/conf/oils_sip.xml file and test all supported
values for the av_format option.  You should also test the case where
the option is omitted, or a non-supported value.  I am not sure what
happens if you supply more than one option with same or different
values, but this is a non-supported degenerate case.

For each test value, ensure tha the fine item detail is the expected
format.

Signed-off-by: Dan Pearl <dpearl@cwmars.org>
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>

Open-ILS/examples/oils_sip.xml.example
Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm
docs/RELEASE_NOTES_NEXT/SIP/AV_format.adoc [new file with mode: 0644]

index 57ebda4..fd7f831 100644 (file)
                                                flag instead of always returning not-OK
                                        <option name='patron_calculate_recal_ok' value='true' />
                                        -->
+                   <!-- 
+                       Fine Item Detail returned by the Patron Information Request is  
+                       manufacturer-specific.  We support the following formats: 
+                          3m,  Swyer_A, Swyer_B, and EG_Legacy (default)
+                       Specify which treatment you want in the av_format option.
+                   <option name='av_format' value='eg_legacy' />
+                    -->
 
                                </options>
 
index 3b458cb..3118bf5 100644 (file)
@@ -846,23 +846,76 @@ sub charged_items_impl {
 sub fine_items {
     my ($self, $start, $end, $ids_only) = @_;
     my @fines;
+    my ($AV_format_orig, $AV_format, $line);
+
     eval {
+       $AV_format_orig = OpenILS::SIP->get_option_value('av_format') || '';
+       $AV_format_orig = "eg_legacy" if $AV_format_orig == '';
+
+       $AV_format = lc $AV_format_orig;  # For case-insensitivity
+
+        # Do a prescan for validity and default to eg_legacy
+       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 = "eg_legacy";
+       }
+
        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;
-           }
-           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, $line;
+                $line = $xact;
+           
+           #-------------------
+          #  eg_legacy 
+           #-------------------
+           } elsif ($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;
+              }        
+       
+           #-------------------
+          #  3m  or  swyer_a
+           #-------------------
+          } 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;
+              }
+
+
+           #-------------------
+          #  swyer_b
+           #-------------------
+          } 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, $line;
        }
     };
+
     my $log_status = $@ ? 'ERROR: ' . $@ : 'OK';
     syslog('LOG_DEBUG', 'OILS: Patron->fine_items() ' . $log_status);
     return (defined $start and defined $end) ? 
diff --git a/docs/RELEASE_NOTES_NEXT/SIP/AV_format.adoc b/docs/RELEASE_NOTES_NEXT/SIP/AV_format.adoc
new file mode 100644 (file)
index 0000000..f1c2a94
--- /dev/null
@@ -0,0 +1,33 @@
+Fine Item Detail Enhancements
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+SIP now suppports enhancements for the Fine Item Detail returned by by Patron Information
+Response (code 64).  Different manufacturers of self-check systems specify the format
+of the fine item detail differently.  A new option allows you to select the format to
+return.
+
+Configuration
++++++++++++++
+After installation of Evergreen and SIP, in the Evergreen configuration directory (typically
+/openils/conf) the SIP configuration file oils_sip.xml awaits your modifications to use this
+feature.
+
+In the <implementation_config><options> section, you can place an option of the form +
+        `<option name='av_format' value='`__<value>__`'>` +
+where __<value>__ is one of thsee values:
+
+* `3m`
+* `eg_legacy`
+* `swyer_a`
+* `swyer_b`
+
+If you omit the option, the default will act as though you wrote +
+        `<option name='av_format' value='eg_legacy'>`
+
+Currently, the behaviour of `eg_legacy` is close to, but not precisely that of `3m`.  The
+`eg_legacy` produces the pre-enhancement behavior in Evergreen.   Currently, the
+`swyer_a` behavior
+is identical to that of `3m`, but there is no guarantee that this will always be the case.
+
+If you change the brand of your self-check equipment, you may need to change the value
+of the option to be consistent with the new brand.
+