Bugzilla – Attachment 165654 Details for
Bug 23426
Empty AV field returned in 'patron info' in addition to those requested
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
BUG 23426: Add fine items to patron information response in SIP2
BUG-23426-Add-fine-items-to-patron-information-res.patch (text/plain), 6.06 KB, created by
Jan Kissig
on 2024-04-26 12:46:34 UTC
(
hide
)
Description:
BUG 23426: Add fine items to patron information response in SIP2
Filename:
MIME Type:
Creator:
Jan Kissig
Created:
2024-04-26 12:46:34 UTC
Size:
6.06 KB
patch
obsolete
>From aee2c5cbcac5f14486dc9528bb007b845607b04f Mon Sep 17 00:00:00 2001 >From: Jan Kissig <jkissig@th-wildau.de> >Date: Thu, 25 Apr 2024 11:13:55 +0200 >Subject: [PATCH] BUG 23426: Add fine items to patron information response in > SIP2 > >This patch adds fine items (AV) to patron information response in SIP2 >In addition the active currency we be part of the response (BH) >This also fixes the number of items in the response which are specified in BP and BQ in the request > >to test: >a) create a manual invoice for patron 23529000035676 : http://localhost:8081/cgi-bin/koha/members/maninvoice.pl?borrowernumber=19 >b) in ktd call: perl /usr/share/koha/bin/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su term1 -sp term1 -l CPL --patron 23529000035676 -m patron_information -s " Y " >c) verify that no |AV field is in response >d) apply patch >e) in ktd call: perl /usr/share/koha/bin/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su term1 -sp term1 -l CPL --patron 23529000035676 -m patron_information -s " Y " >f) verify that response includes fields like '|AVManual fee ' >--- > C4/SIP/ILS/Patron.pm | 48 +++++++++++++++---------------------------- > C4/SIP/Sip/MsgType.pm | 18 ++++++++++++---- > 2 files changed, 30 insertions(+), 36 deletions(-) > >diff --git a/C4/SIP/ILS/Patron.pm b/C4/SIP/ILS/Patron.pm >index f3dfea74bd..f61c855ed2 100644 >--- a/C4/SIP/ILS/Patron.pm >+++ b/C4/SIP/ILS/Patron.pm >@@ -121,6 +121,9 @@ sub new { > } > } > >+ # Get currency 3 chars max >+ my $currency = substr Koha::Acquisition::Currencies->get_active->currency, 0, 3; >+ > my $circ_blocked =( C4::Context->preference('OverduesBlockCirc') ne "noblock" && defined $flags->{ODUES}->{itemlist} ) ? 1 : 0; > { > no warnings; # any of these $kp->{fields} being concat'd could be undef >@@ -164,6 +167,7 @@ sub new { > fine_blocked => $fine_blocked, > fee_limit => $fee_limit, > userid => $kp->{userid}, >+ currency => $currency, > ); > } > >@@ -205,9 +209,17 @@ sub new { > } > } > >- # FIXME: populate fine_items recall_items >+ # FIXME: populate recall_items > $ilspatron{unavail_holds} = _get_outstanding_holds($kp->{borrowernumber}); > >+ # fine items >+ my $debits = $patron->account->outstanding_debits; >+ my @fine_items; >+ while ( my $debit = $debits->next ) { >+ push @fine_items, { account_line => sprintf '%s %.02f', $debit->description, $debit->amountoutstanding }; >+ } >+ $ilspatron{fine_items} =\@fine_items; >+ > my $pending_checkouts = $patron->pending_checkouts; > my @barcodes; > while ( my $c = $pending_checkouts->next ) { >@@ -390,6 +402,7 @@ sub x_items { > > my $item_list = []; > if ($self->{$array_var}) { >+ > if ($start && $start > 1) { > --$start; > } >@@ -397,6 +410,7 @@ sub x_items { > $start = 0; > } > if ( $end && $end < @{$self->{$array_var}} ) { >+ --$end; > } > else { > $end = @{$self->{$array_var}}; >@@ -430,38 +444,8 @@ sub charged_items { > return $self->x_items('items', @_); > } > sub fine_items { >- require Koha::Database; >- require Template; >- > my $self = shift; >- 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 - 1 : scalar @fees - 1; >- >- my $av_field_template = $server ? $server->{account}->{av_field_template} : undef; >- $av_field_template ||= "[% accountline.description %] [% accountline.amountoutstanding | format('%.2f') %]"; >- >- my @return_values; >- for ( my $i = $start; $i <= $end; $i++ ) { >- my $fee = $fees[$i]; >- >- next unless $fee; >- >- my $output = process_tt( $av_field_template, { accountline => $fee } ); >- push( @return_values, { barcode => $output } ); >- } >- >- return \@return_values; >+ return $self->x_items('fine_items', @_); > } > sub recall_items { > my $self = shift; >diff --git a/C4/SIP/Sip/MsgType.pm b/C4/SIP/Sip/MsgType.pm >index 3c52df30f4..ffd4a6fb22 100644 >--- a/C4/SIP/Sip/MsgType.pm >+++ b/C4/SIP/Sip/MsgType.pm >@@ -954,11 +954,12 @@ sub summary_info { > { func => $patron->can("fine_items"), fid => FID_FINE_ITEMS }, > { func => $patron->can("recall_items"), fid => FID_RECALL_ITEMS }, > { func => $patron->can("unavail_holds"), fid => FID_UNAVAILABLE_HOLD_ITEMS }, >+ { func => $patron->can("fine_items"), fid => FID_FINE_ITEMS }, > ); > > my $summary_type = index( $summary, 'Y' ); > return q{} if $summary_type == -1; # No detailed information required. >- return q{} if $summary_type > 5; # Positions 6-9 are not defined in the sip spec, >+ return q{} if $summary_type > 6; # Positions 7-9 are not defined in the sip spec, > # and we have no extensions to handle them. > > siplog( "LOG_DEBUG", "Summary_info: index == '%d', field '%s'", $summary_type, $summary_map[$summary_type]->{fid} ); >@@ -967,9 +968,18 @@ sub summary_info { > my $fid = $summary_map[$summary_type]->{fid}; > my $itemlist = &$func( $patron, $start, $end, $server ); > >- siplog( "LOG_DEBUG", "summary_info: list = (%s)", join( ", ", map{ $_->{barcode} } @{$itemlist} ) ); >- foreach my $i ( @{$itemlist} ) { >- $resp .= add_field( $fid, $i->{barcode}, $server ); >+ # fine items use account_line as key >+ if ( $summary_type == 6 ) { >+ siplog( "LOG_DEBUG", "summary_info: list = (%s)", join( ", ", map { $_->{account_line} } @{$itemlist} ) ); >+ foreach my $i ( @{$itemlist} ) { >+ $resp .= add_field( $fid, $i->{account_line}, $server ); >+ } >+ } >+ else { >+ siplog( "LOG_DEBUG", "summary_info: list = (%s)", join( ", ", map{ $_->{barcode} } @{$itemlist} ) ); >+ foreach my $i ( @{$itemlist} ) { >+ $resp .= add_field( $fid, $i->{barcode}, $server ); >+ } > } > > return $resp; >-- >2.34.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 23426
:
91992
|
165507
|
165508
|
165509
|
165654
|
166240
|
169272
|
170931
|
172383
|
172384
|
174232
|
174233
|
174234
|
174464
|
174465
|
174479