Bugzilla – Attachment 19694 Details for
Bug 10481
No enrollment fee when changing patron category
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 10481: FIX No enrollment fee when changing patron category.
SIGNED-OFF-Bug-10481-FIX-No-enrollment-fee-when-ch.patch (text/plain), 4.75 KB, created by
Owen Leonard
on 2013-07-16 15:51:40 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 10481: FIX No enrollment fee when changing patron category.
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2013-07-16 15:51:40 UTC
Size:
4.75 KB
patch
obsolete
>From 1a1b502a36a07ee2c65e2ab7298614ff28699cda Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Mon, 17 Jun 2013 14:56:22 +0200 >Subject: [PATCH] [SIGNED-OFF] Bug 10481: FIX No enrollment fee when changing > patron category. >Content-Type: text/plain; charset="utf-8" > >When a patron changes to a category with enrollment fee, they >are not generated. > >Test plan: >- Choose a category without fee (e.g. Kid) >- Add an enrollment fee for another category (e.g. Young adult) >- Choose a kid and change his category to "Young adult". >- Note the warning message "Fees & Charges: Patron has Outstanding fees > & charges of XX" on the check out page. > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >--- > C4/Members.pm | 65 +++++++++++++++++++++++++++++++++++++-------------------- > 1 file changed, 42 insertions(+), 23 deletions(-) > >diff --git a/C4/Members.pm b/C4/Members.pm >index 6d8d23a..aca8824 100644 >--- a/C4/Members.pm >+++ b/C4/Members.pm >@@ -721,6 +721,7 @@ sub ModMember { > $data{password} = md5_base64($data{password}); > } > } >+ my $old_categorycode = GetBorrowerCategorycode( $data{borrowernumber} ); > my $execute_success=UpdateInTable("borrowers",\%data); > if ($execute_success) { # only proceed if the update was a success > # ok if its an adult (type) it may have borrowers that depend on it as a guarantor >@@ -731,12 +732,17 @@ sub ModMember { > # is adult check guarantees; > UpdateGuarantees(%data); > } >+ >+ # If the patron changes to a category with enrollment fee, we add a fee >+ if ( $data{categorycode} and $data{categorycode} ne $old_categorycode ) { >+ AddEnrolmentFeeIfNeeded( $data{categorycode}, $data{borrowernumber} ); >+ } >+ > logaction("MEMBERS", "MODIFY", $data{'borrowernumber'}, "UPDATE (executed w/ arg: $data{'borrowernumber'})") if C4::Context->preference("BorrowersLog"); > } > return $execute_success; > } > >- > =head2 AddMember > > $borrowernumber = &AddMember(%borrower); >@@ -773,19 +779,8 @@ sub AddMember { > > # mysql_insertid is probably bad. not necessarily accurate and mysql-specific at best. > logaction("MEMBERS", "CREATE", $data{'borrowernumber'}, "") if C4::Context->preference("BorrowersLog"); >- >- # check for enrollment fee & add it if needed >- my $sth = $dbh->prepare("SELECT enrolmentfee FROM categories WHERE categorycode=?"); >- $sth->execute($data{'categorycode'}); >- my ($enrolmentfee) = $sth->fetchrow; >- if ($sth->err) { >- warn sprintf('Database returned the following error: %s', $sth->errstr); >- return; >- } >- if ($enrolmentfee && $enrolmentfee > 0) { >- # insert fee in patron debts >- manualinvoice($data{'borrowernumber'}, '', '', 'A', $enrolmentfee); >- } >+ >+ AddEnrolmentFeeIfNeeded( $data{categorycode}, $data{borrowernumber} ); > > return $data{'borrowernumber'}; > } >@@ -1845,15 +1840,10 @@ UPDATE borrowers > SET dateexpiry='$date' > WHERE borrowernumber='$borrowerid' > EOF >- # add enrolmentfee if needed >- $sth = $dbh->prepare("SELECT enrolmentfee FROM categories WHERE categorycode=?"); >- $sth->execute($borrower->{'categorycode'}); >- my ($enrolmentfee) = $sth->fetchrow; >- if ($enrolmentfee && $enrolmentfee > 0) { >- # insert fee in patron debts >- manualinvoice($borrower->{'borrowernumber'}, '', '', 'A', $enrolmentfee); >- } >- logaction("MEMBERS", "RENEW", $borrower->{'borrowernumber'}, "Membership renewed")if C4::Context->preference("BorrowersLog"); >+ >+ AddEnrolmentFeeIfNeeded( $borrower->{categorycode}, $borrower->{borrowernumber} ); >+ >+ logaction("MEMBERS", "RENEW", $borrower->{'borrowernumber'}, "Membership renewed")if C4::Context->preference("BorrowersLog"); > return $date if ($sth); > return 0; > } >@@ -2509,6 +2499,35 @@ sub AddMember_Opac { > return ( $borrowernumber, $password ); > } > >+=head2 AddEnroltmenFeeIfNeeded >+ >+ AddEnrolmentFeeIfNeeded( $borrower->{categorycode}, $borrower->{borrowernumber} ); >+ >+Add enrolment fee for a patron if needed. >+ >+=cut >+ >+sub AddEnrolmentFeeIfNeeded { >+ my ( $categorycode, $borrowernumber ) = @_; >+ # check for enrollment fee & add it if needed >+ my $dbh = C4::Context->dbh; >+ my $sth = $dbh->prepare(q{ >+ SELECT enrolmentfee >+ FROM categories >+ WHERE categorycode=? >+ }); >+ $sth->execute( $categorycode ); >+ if ( $sth->err ) { >+ warn sprintf('Database returned the following error: %s', $sth->errstr); >+ return; >+ } >+ my ($enrolmentfee) = $sth->fetchrow; >+ if ($enrolmentfee && $enrolmentfee > 0) { >+ # insert fee in patron debts >+ C4::Accounts::manualinvoice( $borrowernumber, '', '', 'A', $enrolmentfee ); >+ } >+} >+ > END { } # module clean-up code here (global destructor) > > 1; >-- >1.7.9.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 10481
:
19071
|
19556
|
19557
|
19694
|
19787
|
19797
|
20406
|
20407