From 9a8c0cc56c5f773c98e68c784434dce120928183 Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Thu, 31 Mar 2011 10:40:52 +1300 Subject: [PATCH] Bug 5632 SIP/ILS and Debarment fixes Squashed commit of the following: commit 7f6ff7d28b148d4eb054f0c67427dd2bd461fdc2 Author: Henri-Damien LAURENT Date: Wed Jan 19 21:38:59 2011 +0100 SIP Fixing debarment management debarred is now a date. We have to use the calculated flag DEBARRED rather than simply looking at the debarred field commit 773426c83b6c7cbeff12fcc096eb8fdb25322749 Author: Henri-Damien LAURENT Date: Wed Jan 19 21:38:58 2011 +0100 ILS/Transaction Conforming to APIs Checkout And Renew were not really using the full correct interface of AddIssue Renew is using AddIssue where it could/should use AddRenewal --- C4/SIP/ILS/Patron.pm | 31 ++++++++++++++++--------------- C4/SIP/ILS/Transaction/Checkout.pm | 3 ++- C4/SIP/ILS/Transaction/Renew.pm | 3 +++ 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/C4/SIP/ILS/Patron.pm b/C4/SIP/ILS/Patron.pm index 3f4e136..e8f9c63 100644 --- a/C4/SIP/ILS/Patron.pm +++ b/C4/SIP/ILS/Patron.pm @@ -38,21 +38,22 @@ sub new { my ($class, $patron_id) = @_; my $type = ref($class) || $class; my $self; - $kp = GetMember(cardnumber=>$patron_id); - $debug and warn "new Patron (GetMember): " . Dumper($kp); - unless (defined $kp) { - syslog("LOG_DEBUG", "new ILS::Patron(%s): no such patron", $patron_id); - return undef; - } - $kp = GetMemberDetails(undef,$patron_id); - $debug and warn "new Patron (GetMemberDetails): " . Dumper($kp); - my $pw = $kp->{password}; ### FIXME - md5hash -- deal with . - my $flags = $kp->{flags}; # or warn "Warning: No flags from patron object for '$patron_id'"; - my $debarred = $kp->{debarred}; # 1 if ($kp->{flags}->{DBARRED}->{noissues}); - $debug and warn sprintf("Debarred = %s : ", ($debarred||'undef')) . Dumper(%{$kp->{flags}}); - my ($day, $month, $year) = (localtime)[3,4,5]; - my $today = sprintf '%04d-%02d-%02d', $year+1900, $month+1, $day; - my $expired = ($today gt $kp->{dateexpiry}) ? 1 : 0; + $kp = GetMember( cardnumber => $patron_id ); + $debug and warn "new Patron (GetMember): " . Dumper($kp); + unless ( defined $kp ) { + syslog( "LOG_DEBUG", "new ILS::Patron(%s): no such patron", $patron_id ); + return undef; + } + $kp = GetMemberDetails( undef, $patron_id ); + $debug and warn "new Patron (GetMemberDetails): " . Dumper($kp); + my $pw = $kp->{password}; ### FIXME - md5hash -- deal with . + my $flags = $kp->{flags}; # or warn "Warning: No flags from patron object for '$patron_id'"; + my $debarred = defined($kp->{flags}->{DEBARRED}); # 1 if ($kp->{flags}->{DBARRED}->{noissues}); + $debug and warn sprintf( "Debarred = %s : ", ( $debarred || 'undef' ) ) . Dumper( %{ $kp->{flags} } ); + my ( $day, $month, $year ) = (localtime)[ 3, 4, 5 ]; + my $today = sprintf '%04d-%02d-%02d', $year + 1900, $month + 1, $day; + my $expired = ( $today gt $kp->{dateexpiry} ) ? 1 : 0; + if ($expired) { if ($kp->{opacnote} ) { $kp->{opacnote} .= q{ }; diff --git a/C4/SIP/ILS/Transaction/Checkout.pm b/C4/SIP/ILS/Transaction/Checkout.pm index 8a14877..7cd4ca9 100644 --- a/C4/SIP/ILS/Transaction/Checkout.pm +++ b/C4/SIP/ILS/Transaction/Checkout.pm @@ -60,6 +60,7 @@ sub do_checkout { $debug and warn "do_checkout borrower: . " . Dumper $borrower; my ($issuingimpossible,$needsconfirmation) = CanBookBeIssued( $borrower, $barcode ); my $noerror=1; + $debug and warn "do_checkout IssuingImpossible: . " , Dumper($issuingimpossible),"\n",Dumper($needsconfirmation); if (scalar keys %$issuingimpossible) { foreach (keys %$issuingimpossible) { # do something here so we pass these errors @@ -116,7 +117,7 @@ sub do_checkout { $debug and warn "do_checkout: calling AddIssue(\$borrower,$barcode, undef, 0)\n" # . "w/ \$borrower: " . Dumper($borrower) . "w/ C4::Context->userenv: " . Dumper(C4::Context->userenv); - my $c4due = AddIssue($borrower, $barcode, undef, 0); + my $c4due = AddIssue($borrower, $barcode, undef, 0,undef,1); my $due = $c4due->output('iso') || undef; $debug and warn "Item due: $due"; $self->{'due'} = $due; diff --git a/C4/SIP/ILS/Transaction/Renew.pm b/C4/SIP/ILS/Transaction/Renew.pm index 73acaa3..57d6c9d 100644 --- a/C4/SIP/ILS/Transaction/Renew.pm +++ b/C4/SIP/ILS/Transaction/Renew.pm @@ -37,6 +37,9 @@ sub do_renew_for ($$) { my $borrower = shift; my ($renewokay,$renewerror) = CanBookBeRenewed($borrower->{borrowernumber},$self->{item}->{itemnumber}); if ($renewokay){ + #Why not AddRenewal ???? + #my $datedue = AddRenewal( $borrower, $self->{item}->id, undef, 0 ); + my $datedue = AddIssue( $borrower, $self->{item}->id, undef, 0 ); $self->{due} = $datedue; $self->renewal_ok(1); -- 1.7.1