Browse Source

Bug 14512 - Add support for AV field to Koha's SIP2 Server

Koha's SIP2 server should have support for the AV field ( field items ).
The biggest problem with this field is that its' contents are not really
defined in SIP2 protocol specification. All it says is "this field
should be sent for each fine item". Due to this, I think the contents of
the field need to be configurable at the login level, so that the
contents can be defined based on the SIP2 devices requirements for the
AV field.

Test Plan:
1) Apply this patch
2) Find a patron with outstanding fines
3) Run a patron information request using misc/sip_cli_emulator.pl using the new -s option with the value "   Y      "
4) Note there is an AV field for each fee containing the description and amount
5) Edit your sip config, add an av_field_template parameter to the login you are using such as
    av_field_template="TEST [% accountline.description %] [% accountline.amountoutstanding | format('%.2f') %]"
6) Restart your SIP server
7) Repeat the patron information request
8) Note your custom AV field is being used!

Signed-off-by: Chris Davis <cgdavis@uintah.utah.gov>

Signed-off-by: Jesse Weaver <jweaver@bywatersolutions.com>

Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com>
new_12478_elasticsearch
Kyle Hall 7 years ago
committed by Brendan A Gallagher
parent
commit
59266cbd61
  1. 33
      C4/SIP/ILS/Patron.pm
  2. 6
      C4/SIP/Sip/MsgType.pm
  3. 3
      etc/SIPconfig.xml
  4. 17
      misc/sip_cli_emulator.pl

33
C4/SIP/ILS/Patron.pm

@ -299,8 +299,39 @@ sub charged_items {
return $self->x_items('items', @_);
}
sub fine_items {
require Koha::Database;
require Template;
my $self = shift;
return $self->x_items('fine_items', @_);
my $start = shift;
my $end = shift;
my $server = shift;
my @fees = Koha::Database->new()->schema()->resultset('Accountline')->search(
{
borrowernumber => $self->{borrowernumber},
amountoutstanding => { '>' => '0' },
}
);
$start = $start ? $start - 1 : 0;
$end = $end ? $end : scalar @fees - 1;
my $av_field_template = $server ? $server->{account}->{av_field_template} : undef;
$av_field_template ||= "[% accountline.description %] [% accountline.amountoutstanding | format('%.2f') %]";
my $tt = Template->new();
my @return_values;
for ( my $i = $start; $i <= $end; $i++ ) {
my $fee = $fees[$i];
my $output;
$tt->process( \$av_field_template, { accountline => $fee }, \$output );
push( @return_values, { barcode => $output } );
}
return \@return_values;
}
sub recall_items {
my $self = shift;

6
C4/SIP/Sip/MsgType.pm

@ -890,7 +890,7 @@ sub handle_login {
# and we're going to believe it.
#
sub summary_info {
my ( $ils, $patron, $summary, $start, $end ) = @_;
my ( $ils, $patron, $summary, $start, $end, $server ) = @_;
my $resp = '';
my $summary_type;
@ -915,7 +915,7 @@ sub summary_info {
my $func = $summary_map[$summary_type]->{func};
my $fid = $summary_map[$summary_type]->{fid};
my $itemlist = &$func( $patron, $start, $end );
my $itemlist = &$func( $patron, $start, $end, $server );
syslog( "LOG_DEBUG", "summary_info: list = (%s)", join( ", ", @{$itemlist} ) );
foreach my $i ( @{$itemlist} ) {
@ -987,7 +987,7 @@ sub handle_patron_info {
# fine_items
# recall_items
$resp .= summary_info( $ils, $patron, $summary, $start, $end );
$resp .= summary_info( $ils, $patron, $summary, $start, $end, $server );
$resp .= maybe_add( FID_HOME_ADDR, $patron->address );
$resp .= maybe_add( FID_EMAIL, $patron->email_addr );

3
etc/SIPconfig.xml

@ -42,7 +42,8 @@
<login id="lpl-sc" password="1234" institution="LPL" />
<login id="lpl-sc-beacock" password="xyzzy"
delimiter="|" error-detect="enabled" institution="LPL"
send_patron_home_library_in_af="1" >
send_patron_home_library_in_af="1"
av_field_template="[% accountline.description %] [% accountline.amountoutstanding | format('%.2f') %]" >
<screen_msg_regex find="Greetings from Koha." replace="Welcome to your library!" />
<screen_msg_regex find="Invalid patron barcode." replace="Barcode not found, are you sure this is your library card?" />
</login>

17
misc/sip_cli_emulator.pl

@ -40,6 +40,8 @@ my $location_code;
my $patron_identifier;
my $patron_password;
my $summary;
my $item_identifier;
my $fee_acknowledged = 0;
@ -55,13 +57,15 @@ GetOptions(
"sp|sip_pass=s" => \$login_password, # sip password
"l|location|location_code=s" => \$location_code, # sip location code
"patron=s" => \$patron_identifier, # patron cardnumber or login
"password=s" => \$patron_password, # patron's password
"patron=s" => \$patron_identifier, # patron cardnumber or login
"password=s" => \$patron_password, # patron's password
"i|item=s" => \$item_identifier,
"fa|fee-acknowledged" => \$fee_acknowledged,
"s|summary=s" => \$summary,
"t|terminator=s" => \$terminator,
"m|message=s" => \@messages,
@ -126,8 +130,9 @@ my $handlers = {
patron_identifier => $patron_identifier,
terminal_password => $terminal_password,
patron_password => $patron_password,
summary => $summary,
},
optional => [ 'patron_password', ],
optional => [ 'patron_password', 'summary' ],
},
item_information => {
name => 'Item Information',
@ -312,8 +317,9 @@ sub build_patron_information_command_message {
my $patron_identifier = $params->{patron_identifier};
my $terminal_password = $params->{terminal_password};
my $patron_password = $params->{patron_password};
my $summary = $params->{summary};
my $summary = " ";
$summary //= " ";
return
PATRON_INFO
@ -484,6 +490,9 @@ Options:
--patron ILS patron cardnumber or username
--password ILS patron password
-s --summary Optionally define the patron information request summary field.
Please refer to the SIP2 protocol specification for details
--item ILS item identifier ( item barcode )
-t --terminator SIP2 message terminator, either CR, or CRLF

Loading…
Cancel
Save