From 49490dddbc99b799be6d528eba822068e29a27cc Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 17 Jun 2013 14:56:22 +0200 Subject: [PATCH] Bug 10481: FIX No enrollment fee when changing patron category. 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. --- C4/Members.pm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/C4/Members.pm b/C4/Members.pm index 3221f53..95f4a85 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,6 +732,24 @@ 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 ) { + # 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( $data{categorycode} ); + my ($enrolmentfee) = $sth->fetchrow; + if ($enrolmentfee && $enrolmentfee > 0) { + # insert fee in patron debts + C4::Accounts::manualinvoice($data{borrowernumber}, '', '', 'A', $enrolmentfee); + } + } + logaction("MEMBERS", "MODIFY", $data{'borrowernumber'}, "UPDATE (executed w/ arg: $data{'borrowernumber'})") if C4::Context->preference("BorrowersLog"); } return $execute_success; -- 1.7.10.4