From 9c108c32a3595015d31639a1330e9c957536a810 Mon Sep 17 00:00:00 2001 From: Rafal Kopaczka Date: Wed, 12 Mar 2014 15:54:34 +0100 Subject: [PATCH] Bug 9481 - charge not showing fines On 'Check out' and 'Details' screens in patron record fines for item aren't showing. Added new soubroutine to sum up all outstanding charges by borrower for this item including all historical issues and rent charges. Previous routine gets charge amount from system preferences instead of amount outstanding. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To test: 1/ Check out items with past due date 2/ Run fines.pl script (ensure finesMode is set to Calculate and Charge) 3/ Verify on Fines->Pay Fines screen that fines where calculated correct. 4/ Go to Patron record, charge column on Details and Check out screen should be 0 or rental charge amount only. But total amount row display right number, same as in pay fines screen. 4/ Apply patch. 5/ Now charges on display and check out screen shows all outstanding fees for each item. Signed-off-by: Holger Meißner --- C4/Overdues.pm | 20 ++++++++++++++++++++ circ/circulation.pl | 5 +++-- members/moremember.pl | 9 +++++---- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/C4/Overdues.pm b/C4/Overdues.pm index af83e0f..be0e0aa 100644 --- a/C4/Overdues.pm +++ b/C4/Overdues.pm @@ -45,6 +45,7 @@ BEGIN { &AmountNotify &UpdateFine &GetFine + &GetItemCharges &CheckItemNotify &GetOverduesForBranch @@ -658,6 +659,25 @@ sub GetFine { return 0; } +=head2 GetItemCharges + + $charges = GetItemCharges( $borrowernumber, $itemnumber ) + Gets fines and issue charge for item from accountlines. Icluding all outstanding amount for specific item, + also from previous issue of this item. + +=cut + +sub GetItemCharges { + my ( $borrowernumber, $itemnumber ) = @_; + + my $dbh = C4::Context->dbh(); + + my $query = "SELECT SUM(amountoutstanding) FROM accountlines WHERE borrowernumber = ? AND itemnumber = ? "; + my $sth = $dbh->prepare( $query ); + $sth->execute( $borrowernumber, $itemnumber ); + return $sth->fetchrow_arrayref()->[0]; +} + =head2 NumberNotifyId (@notify) = &NumberNotifyId($borrowernumber); diff --git a/circ/circulation.pl b/circ/circulation.pl index cdc40e3..131fe35 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -41,6 +41,7 @@ use C4::Context; use CGI::Session; use C4::Members::Attributes qw(GetBorrowerAttributes); use Koha::Borrower::Debarments qw(GetDebarments); +use C4::Overdues qw/GetItemCharges/; use Koha::DateUtils; use Date::Calc qw( @@ -478,8 +479,8 @@ sub build_issue_data { # set itemtype per item-level_itype syspref - FIXME this is an ugly hack $it->{'itemtype'} = ( C4::Context->preference( 'item-level_itypes' ) ) ? $it->{'itype'} : $it->{'itemtype'}; - ($it->{'charge'}, $it->{'itemtype_charge'}) = GetIssuingCharges( - $it->{'itemnumber'}, $it->{'borrowernumber'} + $it->{'charge'} = GetItemCharges( + $it->{'borrowernumber'}, $it->{'itemnumber'} ); $it->{'charge'} = sprintf("%.2f", $it->{'charge'}); my ($can_renew, $can_renew_error) = CanBookBeRenewed( diff --git a/members/moremember.pl b/members/moremember.pl index e794efa..e7ac52a 100755 --- a/members/moremember.pl +++ b/members/moremember.pl @@ -52,6 +52,7 @@ use C4::Form::MessagingPreferences; use List::MoreUtils qw/uniq/; use C4::Members::Attributes qw(GetBorrowerAttributes); use Koha::Borrower::Debarments qw(GetDebarments); +use C4::Overdues qw(GetItemCharges); #use Smart::Comments; #use Data::Dumper; use DateTime; @@ -502,11 +503,11 @@ sub build_issue_data { } } - #find the charge for an item - my ( $charge, $itemtype ) = - GetIssuingCharges( $issue->{itemnumber}, $borrowernumber ); + #find all charges for an item + my $charge = GetItemCharges( $borrowernumber, $issue->{itemnumber} ); - my $itemtypeinfo = getitemtypeinfo($itemtype); + my $getiteminfo = GetBiblioFromItemNumber( $issue->{'itemnumber'} ); + my $itemtypeinfo = getitemtypeinfo( (C4::Context->preference('item-level_itypes')) ? $getiteminfo->{'itype'} : $getiteminfo->{'itemtype'} ); $row{'itemtype_description'} = $itemtypeinfo->{description}; $row{'itemtype_image'} = $itemtypeinfo->{imageurl}; -- 1.7.10.4