From: djfiander Date: Tue, 16 May 2006 01:37:29 +0000 (+0000) Subject: Code cleanups X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=5e8e75abb6ef780ecb04cbaa16c7ab0aaf38763b;p=working%2FSIPServer.git Code cleanups --- diff --git a/ILS/Patron.pm b/ILS/Patron.pm index c3003fe..92fa0d4 100644 --- a/ILS/Patron.pm +++ b/ILS/Patron.pm @@ -35,7 +35,6 @@ our %patron_db = ( recall_ok => 0, hold_ok => 1, card_lost => 0, - items_charged => 0, claims_returned => 0, fines => 100, fees => 0, @@ -150,42 +149,12 @@ sub card_lost { return $self->{card_lost}; } -sub items_charged { - my $self = shift; - - return scalar @{$self->{items}}; -} - -sub claims_returned { - my $self = shift; - - return $self->{claims_returned}; -} - -sub fines { - my $self = shift; - - return $self->{fines}; -} - -sub fees { - my $self = shift; - - return $self->{fees}; -} - sub recall_overdue { my $self = shift; return $self->{recall_overdue}; } -sub items_billed { - my $self = shift; - - return $self->{items_billed}; -} - sub check_password { my ($self, $pwd) = @_; @@ -275,7 +244,7 @@ sub hold_items { $start = 1 if !defined($start); $end = scalar @{$self->{hold_items}} if !defined($end); - return map $_->{item_id}, @{$self->{hold_items}}[$start-1 .. $end-1]; + return [@{$self->{hold_items}}[$start-1 .. $end-1]]; } # @@ -300,96 +269,60 @@ sub overdue_items { my ($self, $start, $end) = @_; $start = 1 if !defined($start); - $end = $self->overdue_items_count if !defined($end); - - return @{$self->{overdue_items}}[$start-1 .. $end-1]; -} + $end = scalar @{$self->{overdue_items}} if !defined($end); -sub overdue_items_count { - my $self = shift; - - return scalar @{$self->{overdue_items}}; + return [@{$self->{overdue_items}}[$start-1 .. $end-1]]; } sub charged_items { my ($self, $start, $end) = shift; $start = 1 if !defined($start); - $end = $self->charged_items_count if !defined($end); + $end = scalar @{$self->{items}} if !defined($end); syslog("LOG_DEBUG", "charged_items: start = %d, end = %d", $start, $end); syslog("LOG_DEBUG", "charged_items: items = (%s)", join(', ', @{$self->{items}})); - return @{$self->{items}}[$start-1 .. $end-1]; -} - -sub charged_items_count { - my $self = shift; - - return scalar @{$self->{items}}; + return [@{$self->{items}}[$start-1 .. $end-1]]; } sub fine_items { my ($self, $start, $end) = @_; $start = 1 if !defined($start); - $end = $self->fine_items_count if !defined($end); + $end = scalar @{$self->{fine_items}} if !defined($end); - return @{$self->{fine_items}}[$start-1 .. $end-1]; -} - -sub fine_items_count { - my $self = shift; - - return scalar @{$self->{fine_items}}; + return [@{$self->{fine_items}}[$start-1 .. $end-1]]; } sub recall_items { my ($self, $start, $end) = @_; $start = 1 if !defined($start); - $end = $self->recall_items_count if !defined($end); - - return @{$self->{recall_items}}[$start-1 .. $end-1]; -} - -sub recall_items_count { - my $self = shift; + $end = scalar @{$self->{recall_items}} if !defined($end); - return scalar @{$self->{recall_items}}; + return [@{$self->{recall_items}}[$start-1 .. $end-1]]; } sub unavail_holds { my ($self, $start, $end) = @_; $start = 1 if !defined($start); - $end = $self->unavail_holds_count if !defined($end); + $end = scalar @{$self->{unavail_holds}} if !defined($end); - return @{$self->{unavail_holds}}[$start-1 .. $end-1]; -} - -sub unavail_holds_count { - my $self = shift; - - return scalar @{$self->{unavail_holds}}; + return [@{$self->{unavail_holds}}[$start-1 .. $end-1]]; } sub fee_items { my ($self, $start, $end) = @_; $start = 1 if !defined($start); - $end = $self->fee_items_count if !defined($end); + $end = scalar @{$self->fee_items} if !defined($end); return @{$self->{fee_items}}[$start-1 .. $end-1]; } -sub fee_items_count { - my $self = shift; - - return scalar @{$self->{fee_items}}; -} - sub block { my ($self, $card_retained, $blocked_card_msg) = @_; diff --git a/Sip/MsgType.pm b/Sip/MsgType.pm index 7580c30..1cbfdd0 100644 --- a/Sip/MsgType.pm +++ b/Sip/MsgType.pm @@ -894,17 +894,17 @@ sub handle_patron_info { $resp .= $lang . Sip::timestamp(); $resp .= add_count('patron_info/hold_items', - scalar $patron->hold_items); + scalar @{$patron->hold_items}); $resp .= add_count('patron_info/overdue_items', - $patron->overdue_items_count); + scalar @{$patron->overdue_items}); $resp .= add_count('patron_info/charged_items', - $patron->charged_items_count); + scalar @{$patron->charged_items}); $resp .= add_count('patron_info/fine_items', - $patron->fine_items_count); + scalar @{$patron->fine_items}); $resp .= add_count('patron_info/recall_items', - $patron->recall_items_count); + scalar @{$patron->recall_items}); $resp .= add_count('patron_info/unavail_holds', - $patron->unavail_holds_count); + scalar @{$patron->unavail_holds}); # while the patron ID we got from the SC is valid, let's # use the one returned from the ILS, just in case...