Bugzilla – Attachment 85407 Details for
Bug 14293
Error in the calculation of the suspension of users per day
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14293: The suspension should be calculated in days
Bug-14293-The-suspension-should-be-calculated-in-d.patch (text/plain), 4.22 KB, created by
Arthur Suzuki
on 2019-02-20 19:43:14 UTC
(
hide
)
Description:
Bug 14293: The suspension should be calculated in days
Filename:
MIME Type:
Creator:
Arthur Suzuki
Created:
2019-02-20 19:43:14 UTC
Size:
4.22 KB
patch
obsolete
>From 7f8d844d542d216702cdda5b1cf44c39d3c19f52 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 4 Sep 2015 10:39:48 +0100 >Subject: [PATCH] Bug 14293: The suspension should be calculated in days > >There was a mismatch between bug 13909 and bug 5549. >The get_chargeable_units call from _debar_user_on_return should specify >that we want a suspension in days. > >However I don't understand the comment let by the author of bug 5549 >f61a9617184ec4b24100c1d99150bfd4ebf13336 > >1/ >> finedays is in days, so hourly loans must multiply by 24 >Yes but the suspension is in days, so no need to * 24 > >2/ And we should have a look on this one too: >> grace period is measured in the same units as the loan >But the grace period is always in days. On the circ rules the column is >"Fine grace period (day)". >I think we should replace > DateTime::Duration->new( $unit => $issuingrule->{firstremind} ); >with > DateTime::Duration->new( days => $issuingrule->{firstremind} ); > >Anyway, we definitelly need more tests in this area! > >Test plan: >1/ Define an issuing rule with a unit=hour >2/ Set a suspension in days >3/ Check an item out and specify a past due date. >4/ Check the item in >5/ The patron should be debarred correctly > >Signed-off-by: Nick Clemens <nick@quecheelibrary.org> >Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com> >--- > C4/Circulation.pm | 11 +++----- > .../Circulation/IssuingRules/maxsuspensiondays.t | 31 +++++++++++++++++++++- > 2 files changed, 34 insertions(+), 8 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index fa082104a1..d6b55ca0c1 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -2203,21 +2203,18 @@ sub _debar_user_on_return { > ); > my $finedays = $issuing_rule ? $issuing_rule->finedays : undef; > my $unit = $issuing_rule ? $issuing_rule->lengthunit : undef; >- my $chargeable_units = C4::Overdues::get_chargeable_units($unit, $dt_due, $return_date, $branchcode); > > if ($finedays) { > >- # finedays is in days, so hourly loans must multiply by 24 >- # thus 1 hour late equals 1 day suspension * finedays rate >- $finedays = $finedays * 24 if ( $unit eq 'hours' ); >- > # grace period is measured in the same units as the loan > my $grace = > DateTime::Duration->new( $unit => $issuing_rule->firstremind ); > >- my $deltadays = DateTime::Duration->new( >- days => $chargeable_units >+ my $deltadays = C4::Overdues::get_chargeable_units('days', $dt_due, $return_date, $branchcode); >+ $deltadays = DateTime::Duration->new( >+ days => $deltadays, > ); >+ > if ( $deltadays->subtract($grace)->is_positive() ) { > my $suspension_days = $deltadays * $finedays; > >diff --git a/t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t b/t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t >index d2602263f3..b969baa960 100644 >--- a/t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t >+++ b/t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t >@@ -1,5 +1,5 @@ > use Modern::Perl; >-use Test::More tests => 2; >+use Test::More tests => 3; > > use MARC::Record; > use MARC::Field; >@@ -101,4 +101,33 @@ is( > ); > DelDebarment( $debarments->[0]->{borrower_debarment_id} ); > >+# Test with lengthunit => 'hours' >+Koha::IssuingRules->search->delete; >+$builder->build( >+ { >+ source => 'Issuingrule', >+ value => { >+ categorycode => '*', >+ itemtype => '*', >+ branchcode => '*', >+ firstremind => 0, >+ finedays => 2, >+ lengthunit => 'hours', >+ suspension_chargeperiod => 1, >+ maxsuspensiondays => 100, >+ } >+ } >+); >+ >+$daysafter10 = dt_from_string->add_duration(DateTime::Duration->new(days => 10)); >+AddIssue( $borrower, $barcode, $daysago20 ); >+AddReturn( $barcode, $branchcode ); >+$debarments = GetDebarments({borrowernumber => $borrower->{borrowernumber}}); >+is( >+ $debarments->[0]->{expiration}, >+ output_pref({ dt => $daysafter40, dateformat => 'iso', dateonly => 1 }), >+ 'calculate suspension with lengthunit hours.' >+); >+DelDebarment( $debarments->[0]->{borrower_debarment_id} ); >+ > $schema->storage->txn_rollback; >-- >2.13.7
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 14293
:
42387
|
42492
|
85210
|
85211
|
85251
|
85252
|
85255
|
85407
|
85408
|
85788
|
90955
|
90956
|
90957
|
159075
|
159076
|
159128
|
159129
|
159277
|
159504
|
160924
|
160925