Bugzilla – Attachment 9231 Details for
Bug 7849
Instant Fine Calculation at Checkin
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Adds instant fine calculation
0001-bug-7849-Instant-Fine-Calculation-n-Adds-functionali.patch (text/plain), 3.29 KB, created by
Elliott Davis
on 2012-04-17 15:38:57 UTC
(
hide
)
Description:
Adds instant fine calculation
Filename:
MIME Type:
Creator:
Elliott Davis
Created:
2012-04-17 15:38:57 UTC
Size:
3.29 KB
patch
obsolete
>From 8cae90e50465ab699bfccb380e3abe4421a54341 Mon Sep 17 00:00:00 2001 >From: Elliott Davis <tdavis@uttyler.edu> >Date: Tue, 17 Apr 2012 10:38:14 +0000 >Subject: [PATCH] bug 7849 Instant Fine Calculation\n Adds functionality of calculate fines instantly. This is very important for Hourly loans becuase of a loophole from the cron. > >--- > C4/Circulation.pm | 16 ++++++++++++++++ > C4/Overdues.pm | 6 +++++- > 2 files changed, 21 insertions(+), 1 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 6ca860d..1fb85f2 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -37,6 +37,7 @@ use C4::Debug; > use C4::Branch; # GetBranches > use C4::Log; # logaction > use C4::Koha qw(GetAuthorisedValueByCode); >+use C4::Overdues qw(CalcFine UpdateFine); > use Data::Dumper; > use Koha::DateUtils; > use Koha::Calendar; >@@ -1598,6 +1599,8 @@ sub AddReturn { > > # case of a return of document (deal with issues and holdingbranch) > if ($doreturn) { >+ my $today = DateTime->now( time_zone => C4::Context->tz() ); >+ my $datedue = $issue->{date_due}; > $borrower or warn "AddReturn without current borrower"; > my $circControlBranch; > if ($dropbox) { >@@ -1606,9 +1609,22 @@ sub AddReturn { > # FIXME: check issuedate > returndate, factoring in holidays > #$circControlBranch = _GetCircControlBranch($item,$borrower) unless ( $item->{'issuedate'} eq C4::Dates->today('iso') );; > $circControlBranch = _GetCircControlBranch($item,$borrower); >+ my $datedue = $issue->{date_due}; >+ $issue->{'overdue'} = DateTime->compare($issue->{'date_due'}, $today ) == -1 ? 1 : 0; > } > > if ($borrowernumber) { >+ if($issue->{'overdue'}){ >+ my ( $amount, $type, $daycounttotal ) = C4::Overdues::CalcFine( $item, $borrower->{categorycode},$branch, $datedue, $today ); >+ my $type ||= q{}; >+ if ( $amount > 0 && ( C4::Context->preference('finesMode') eq 'production' )) { >+ C4::Overdues::UpdateFine( >+ $issue->{itemnumber}, >+ $issue->{borrowernumber}, >+ $amount, $type, output_pref($datedue) >+ ); >+ } >+ } > MarkIssueReturned($borrowernumber, $item->{'itemnumber'}, $circControlBranch, '', $borrower->{'privacy'}); > $messages->{'WasReturned'} = 1; # FIXME is the "= 1" right? This could be the borrower hash. > } >diff --git a/C4/Overdues.pm b/C4/Overdues.pm >index 23e75f5..c7430c9 100644 >--- a/C4/Overdues.pm >+++ b/C4/Overdues.pm >@@ -255,7 +255,8 @@ sub CalcFine { > my ( $item, $bortype, $branchcode, $due_dt, $end_date ) = @_; > my $start_date = $due_dt->clone(); > # get issuingrules (fines part will be used) >- my $data = C4::Circulation::GetIssuingRule($bortype, $item->{itemtype}, $branchcode); >+ my $itemtype = $item->{itemtype} || $item->{itype}; >+ my $data = C4::Circulation::GetIssuingRule($bortype, $itemtype, $branchcode); > my $fine_unit = $data->{lengthunit}; > $fine_unit ||= 'days'; > >@@ -300,6 +301,9 @@ sub _get_chargeable_units { > } else { > $charge_duration = $dt2->delta_ms( $dt1 ); > } >+ if($charge_duration->in_units('hours') == 0 && $charge_duration->in_units('seconds') > 0){ >+ return 1; >+ } > return $charge_duration->in_units('hours'); > } > else { # days >-- >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 7849
:
8703
|
8781
|
8879
|
8907
|
9012
| 9231 |
9284