Bugzilla – Attachment 44600 Details for
Bug 14390
Fine not updated from 'FU' to 'F' on renewal
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14390 - On renewal, the last fine is not marked as accounttype 'F' when item is checked in.
Bug-14390---On-renewal-the-last-fine-is-not-marked.patch (text/plain), 7.91 KB, created by
Kyle M Hall (khall)
on 2015-11-06 18:24:10 UTC
(
hide
)
Description:
Bug 14390 - On renewal, the last fine is not marked as accounttype 'F' when item is checked in.
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2015-11-06 18:24:10 UTC
Size:
7.91 KB
patch
obsolete
>From 89c28e5bb4eb433d0a3b79a31c17d0abf11d7477 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Fri, 6 Nov 2015 13:20:56 -0500 >Subject: [PATCH] Bug 14390 - On renewal, the last fine is not marked as accounttype 'F' when item is checked in. > >Test Plan: >1) Find an overdue checkout with a fine >2) Renew item, note fine is not closed out (Account type F) >3) Apply this patch >4) Find another overdue checkout with a fine >5) Renew item, note fine is now correctly closed out >6) Backdate a checkout to be already overdue ( but not have a fine since > fines.pl hasn't run yet ) >7) Renew item, note a closed out fine is created >--- > C4/Circulation.pm | 129 ++++++++++++++++++++++++++++++----------------------- > 1 files changed, 73 insertions(+), 56 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 18cc9d5..3fdb4a2 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -1911,39 +1911,7 @@ sub AddReturn { > > if ($borrowernumber) { > if ( ( C4::Context->preference('CalculateFinesOnReturn') && $issue->{'overdue'} ) || $return_date ) { >- # we only need to calculate and change the fines if we want to do that on return >- # Should be on for hourly loans >- my $control = C4::Context->preference('CircControl'); >- my $control_branchcode = >- ( $control eq 'ItemHomeLibrary' ) ? $item->{homebranch} >- : ( $control eq 'PatronLibrary' ) ? $borrower->{branchcode} >- : $issue->{branchcode}; >- >- my $date_returned = >- $return_date ? dt_from_string($return_date) : $today; >- >- my ( $amount, $type, $unitcounttotal ) = >- C4::Overdues::CalcFine( $item, $borrower->{categorycode}, >- $control_branchcode, $datedue, $date_returned ); >- >- $type ||= q{}; >- >- if ( C4::Context->preference('finesMode') eq 'production' ) { >- if ( $amount > 0 ) { >- C4::Overdues::UpdateFine( $issue->{itemnumber}, >- $issue->{borrowernumber}, >- $amount, $type, output_pref($datedue) ); >- } >- elsif ($return_date) { >- >- # Backdated returns may have fines that shouldn't exist, >- # so in this case, we need to drop those fines to 0 >- >- C4::Overdues::UpdateFine( $issue->{itemnumber}, >- $issue->{borrowernumber}, >- 0, $type, output_pref($datedue) ); >- } >- } >+ _CalculateAndUpdateFine( { issue => $issue, item => $item, borrower => $borrower, return_date => $return_date } ); > } > > eval { >@@ -2873,10 +2841,7 @@ sub AddRenewal { > my $dbh = C4::Context->dbh; > > # Find the issues record for this book >- my $sth = >- $dbh->prepare("SELECT * FROM issues WHERE itemnumber = ?"); >- $sth->execute( $itemnumber ); >- my $issuedata = $sth->fetchrow_hashref; >+ my $issuedata = GetItemIssue($itemnumber); > > return unless ( $issuedata ); > >@@ -2887,12 +2852,18 @@ sub AddRenewal { > return; > } > >+ my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber ) or return; >+ >+ if ( C4::Context->preference('CalculateFinesOnReturn') && $issuedata->{overdue} ) { >+ _CalculateAndUpdateFine( { issue => $issuedata, item => $item, borrower => $borrower } ); >+ } >+ _FixOverduesOnReturn( $borrowernumber, $itemnumber ); >+ > # If the due date wasn't specified, calculate it by adding the > # book's loan length to today's date or the current due date > # based on the value of the RenewalPeriodBase syspref. > unless ($datedue) { > >- my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber ) or return; > my $itemtype = (C4::Context->preference('item-level_itypes')) ? $biblio->{'itype'} : $biblio->{'itemtype'}; > > $datedue = (C4::Context->preference('RenewalPeriodBase') eq 'date_due') ? >@@ -2904,7 +2875,7 @@ sub AddRenewal { > # Update the issues record to have the new due date, and a new count > # of how many times it has been renewed. > my $renews = $issuedata->{'renewals'} + 1; >- $sth = $dbh->prepare("UPDATE issues SET date_due = ?, renewals = ?, lastreneweddate = ? >+ my $sth = $dbh->prepare("UPDATE issues SET date_due = ?, renewals = ?, lastreneweddate = ? > WHERE borrowernumber=? > AND itemnumber=?" > ); >@@ -2934,23 +2905,25 @@ sub AddRenewal { > } > > # Send a renewal slip according to checkout alert preferencei >- if ( C4::Context->preference('RenewalSendNotice') eq '1') { >- my $borrower = C4::Members::GetMemberDetails( $borrowernumber, 0 ); >- my $circulation_alert = 'C4::ItemCirculationAlertPreference'; >- my %conditions = ( >- branchcode => $branch, >- categorycode => $borrower->{categorycode}, >- item_type => $item->{itype}, >- notification => 'CHECKOUT', >- ); >- if ($circulation_alert->is_enabled_for(\%conditions)) { >- SendCirculationAlert({ >- type => 'RENEWAL', >- item => $item, >- borrower => $borrower, >- branch => $branch, >- }); >- } >+ if ( C4::Context->preference('RenewalSendNotice') eq '1' ) { >+ $borrower = C4::Members::GetMemberDetails( $borrowernumber, 0 ); >+ my $circulation_alert = 'C4::ItemCirculationAlertPreference'; >+ my %conditions = ( >+ branchcode => $branch, >+ categorycode => $borrower->{categorycode}, >+ item_type => $item->{itype}, >+ notification => 'CHECKOUT', >+ ); >+ if ( $circulation_alert->is_enabled_for( \%conditions ) ) { >+ SendCirculationAlert( >+ { >+ type => 'RENEWAL', >+ item => $item, >+ borrower => $borrower, >+ branch => $branch, >+ } >+ ); >+ } > } > > # Remove any OVERDUES related debarment if the borrower has no overdues >@@ -4095,6 +4068,50 @@ sub GetTopIssues { > return @$rows; > } > >+sub _CalculateAndUpdateFine { >+ my ($params) = @_; >+ >+ my $borrower = $params->{borrower}; >+ my $item = $params->{item}; >+ my $issue = $params->{issue}; >+ my $return_date = $params->{return_date}; >+ >+ unless ($borrower) { carp "No borrower passed in!" && return; } >+ unless ($item) { carp "No item passed in!" && return; } >+ unless ($issue) { carp "No issue passed in!" && return; } >+ >+ my $datedue = $issue->{date_due}; >+ >+ # we only need to calculate and change the fines if we want to do that on return >+ # Should be on for hourly loans >+ my $control = C4::Context->preference('CircControl'); >+ my $control_branchcode = >+ ( $control eq 'ItemHomeLibrary' ) ? $item->{homebranch} >+ : ( $control eq 'PatronLibrary' ) ? $borrower->{branchcode} >+ : $issue->{branchcode}; >+ >+ my $date_returned = $return_date ? dt_from_string($return_date) : dt_from_string(); >+ >+ my ( $amount, $type, $unitcounttotal ) = >+ C4::Overdues::CalcFine( $item, $borrower->{categorycode}, $control_branchcode, $datedue, $date_returned ); >+ >+ $type ||= q{}; >+ >+ if ( C4::Context->preference('finesMode') eq 'production' ) { >+ if ( $amount > 0 ) { >+ C4::Overdues::UpdateFine( $issue->{itemnumber}, $issue->{borrowernumber}, >+ $amount, $type, output_pref($datedue) ); >+ } >+ elsif ($return_date) { >+ >+ # Backdated returns may have fines that shouldn't exist, >+ # so in this case, we need to drop those fines to 0 >+ >+ C4::Overdues::UpdateFine( $issue->{itemnumber}, $issue->{borrowernumber}, 0, $type, output_pref($datedue) ); >+ } >+ } >+} >+ > __END__ > > =head1 AUTHOR >-- >1.7.2.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 14390
:
41428
|
44600
|
44603
|
45280
|
45281
|
45285
|
47465
|
51627
|
51628
|
51629
|
54593
|
54594
|
54595
|
54596
|
54704
|
54778
|
54779
|
54821
|
54822
|
54823
|
54824
|
54825