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) {
- $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 $login = OpenILS::SIP->login_account();
+ my $AV_format = lc($login->{av_format}) || 'eg_legacy';
+
+ # 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: ". $login->{av_format});
+ $AV_format = "eg_legacy";
+ }
+
+ my $xacts = $U->simplereq('open-ils.actor',
+ 'open-ils.actor.user.transactions.history.have_balance',
+ $self->{authtoken}, $self->{user}->id);
+
+ my $line;
+ foreach my $xact (@{$xacts}) {
+
+ if ($ids_only) {
+ push @fines, $xact->id;
+ next;
+ }
+
+ # fine item details requested
+
+ my $title;
+ my $author;
+ my $line;
+
+ if ($xact->xact_type eq 'circulation') {
+ my $e = OpenILS::SIP->editor();
+ my $circ = $e->retrieve_action_circulation([
+ $xact->id, {
+ flesh => 2,
+ flesh_fields => {
+ circ => ['target_copy'],
+ acp => ['call_number']
+ }
+ }
+ ]);
+
+ my $displays = $e->search_metabib_flat_display_entry({
+ source => $circ->target_copy->call_number->record,
+ name => ['title', 'author']
+ });
+
+ ($title) = map {$_->value} grep {$_->name eq 'title'} @$displays;
+ ($author) = map {$_->value} grep {$_->name eq 'author'} @$displays;
+
+ # Scrub "/" chars since they are used in some cases
+ # to delineate title/author.
+ if ($title) {
+ $title =~ s/\///g;
+ } else {
+ $title = '';
+ }
+
+ if ($author) {
+ $author =~ s/\///g;
+ } else {
+ $author = '';
+ }
+ }
+
+ if ($AV_format eq "eg_legacy") {
+
+ $line = $xact->balance_owed . " " . $xact->last_billing_type . " ";
+
+ if ($xact->xact_type eq 'circulation') {
+ $line .= "$title/$author";
+ } else {
+ $line .= $xact->last_billing_note;
+ }
+
+ } 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') {
+ $line .= "$title/$author";
+ } else {
+ $line .= $xact->last_billing_note;
+ }
+
+ } 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') {
+ $line .= ", Title: $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);
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.
+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.
+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 <accounts><login> sections, you can add an attribute of the form
+ `av_format="__<value>__"`
-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`
* `swyer_a`
* `swyer_b`
-If you omit the option, the default will act as though you wrote +
- `<option name='av_format' value='eg_legacy'>`
+For example:
+
+<login id="sipclient" password="password" institution="gapines" av_format="3m"/>
+
+If you omit the option, 'eg_legacy' will be used as the default.
+
+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.
-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.
-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.