From: Sarah E. Chodrow Date: Wed, 14 Sep 2011 13:15:14 +0000 (-0400) Subject: Initial patch from Sarah Chodrow on LP bug 849447. X-Git-Tag: sprint4-merge-nov22~4905 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=9eaadfeda3506e52651c8b8695da1e569765ec7c;p=working%2FEvergreen.git Initial patch from Sarah Chodrow on LP bug 849447. Also check for standing penalties and expired cards when checking if it is ok for the patron to checkout, charge_ok. Developer's Certificate of Origin 1.1 By making a contribution to this project, I certify that: (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. (d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. Signed-off-by: Sarah E. Chodrow (sarah.chodrow@bibliotheca-itg.com) Signed-off-by: Jason Stephenson Signed-off-by: Thomas Berezansky --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm b/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm index 17389fa0b8..4c1323c627 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm @@ -275,15 +275,31 @@ sub language { } # How much more detail do we need to check here? +# sec: adding logic to return false if user is barred, has a circulation block +# or an expired card sub charge_ok { my $self = shift; my $u = $self->{user}; - return - $u->barred eq 'f' and + + # compute expiration date for borrowing privileges + my $expire = DateTime::Format::ISO8601->new->parse_datetime(cleanse_ISO8601($u->expire_date)); + + # determine whether patron should be allowed to circulate materials: + # not barred, doesn't owe too much wrt fines/fees, privileges haven't + # expired + my $no_circ = 't' if + (($u->barred eq 't') or + ($u->standing_penalties and @{$u->standing_penalties}) or + (CORE::time > $expire->epoch)); + + return + !$no_circ and $u->active eq 't' and $u->card->active eq 't'; } + + # How much more detail do we need to check here? sub renew_ok { my $self = shift;