Bugzilla – Attachment 172383 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.22 KB, created by
Marcel de Rooy
on 2024-10-04 09:38:26 UTC
(
hide
)
Description:
Bug 23426: Add fine items to patron information response in SIP2
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2024-10-04 09:38:26 UTC
Size:
6.22 KB
patch
obsolete
>From 6723f486b73d2ca2688cc260c0ecd66b4d091099 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 >Content-Type: text/plain; charset=utf-8 > >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 ' > >Signed-off-by: David Nind <david@davidnind.com> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >[EDIT] Tidied inline >--- > C4/SIP/ILS/Patron.pm | 48 +++++++++++++++---------------------------- > C4/SIP/Sip/MsgType.pm | 17 +++++++++++---- > 2 files changed, 29 insertions(+), 36 deletions(-) > >diff --git a/C4/SIP/ILS/Patron.pm b/C4/SIP/ILS/Patron.pm >index b14a7e96c2..1483f0ebf9 100644 >--- a/C4/SIP/ILS/Patron.pm >+++ b/C4/SIP/ILS/Patron.pm >@@ -124,6 +124,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 >@@ -167,6 +170,7 @@ sub new { > fine_blocked => $fine_blocked, > fee_limit => $fee_limit, > userid => $kp->{userid}, >+ currency => $currency, > ); > } > >@@ -208,9 +212,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 ) { >@@ -393,6 +405,7 @@ sub x_items { > > my $item_list = []; > if ($self->{$array_var}) { >+ > if ($start && $start > 1) { > --$start; > } >@@ -400,6 +413,7 @@ sub x_items { > $start = 0; > } > if ( $end && $end < @{$self->{$array_var}} ) { >+ --$end; > } > else { > $end = @{$self->{$array_var}}; >@@ -433,38 +447,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 4fcd4e486a..12bfd526f5 100644 >--- a/C4/SIP/Sip/MsgType.pm >+++ b/C4/SIP/Sip/MsgType.pm >@@ -958,11 +958,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} ); >@@ -971,9 +972,17 @@ 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.39.5
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