Bugzilla – Attachment 85255 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: Add more tests and improve get_chargeable_units
Bug-14293-Add-more-tests-and-improve-getchargeable.patch (text/plain), 3.80 KB, created by
Arthur Suzuki
on 2019-02-18 17:53:44 UTC
(
hide
)
Description:
Bug 14293: Add more tests and improve get_chargeable_units
Filename:
MIME Type:
Creator:
Arthur Suzuki
Created:
2019-02-18 17:53:44 UTC
Size:
3.80 KB
patch
obsolete
>From 84da5ed0c00a6f6493702fa506d5980aa0d1b447 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Sat, 16 Feb 2019 14:32:15 -0300 >Subject: [PATCH] Bug 14293: Add more tests and improve get_chargeable_units > >Not sure at all about this change, especially because it could modify >CalcFine > >Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com> >--- > C4/Overdues.pm | 17 +++++--------- > .../Circulation/IssuingRules/maxsuspensiondays.t | 26 ++++++++++++++++++++-- > 2 files changed, 30 insertions(+), 13 deletions(-) > >diff --git a/C4/Overdues.pm b/C4/Overdues.pm >index 958fdd0077..ae92fbe865 100644 >--- a/C4/Overdues.pm >+++ b/C4/Overdues.pm >@@ -306,7 +306,6 @@ sub get_chargeable_units { > > my $charge_units = 0; > my $charge_duration; >- if ($unit eq 'hours') { > if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') { > my $calendar = Koha::Calendar->new( branchcode => $branchcode ); > $charge_duration = $calendar->hours_between( $date_due, $date_returned ); >@@ -316,16 +315,12 @@ sub get_chargeable_units { > if($charge_duration->in_units('hours') == 0 && $charge_duration->in_units('seconds') > 0){ > return 1; > } >- return $charge_duration->in_units('hours'); >- } >- else { # days >- if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') { >- my $calendar = Koha::Calendar->new( branchcode => $branchcode ); >- $charge_duration = $calendar->days_between( $date_due, $date_returned ); >- } else { >- $charge_duration = $date_returned->delta_days( $date_due ); >- } >- return $charge_duration->in_units('days'); >+ >+ my $hours = $charge_duration->in_units('hours'); >+ if ($unit eq 'hours') { >+ return $hours; >+ } else { >+ return ( $hours > 0 ? ceil($hours / 24) : 0 ); > } > } > >diff --git a/t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t b/t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t >index abdef9daad..fcdf44d845 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 => 3; >+use Test::More tests => 5; > > use MARC::Record; > use MARC::Field; >@@ -119,7 +119,6 @@ $builder->build( > } > ); > >-$daysafter10 = dt_from_string->add_duration(DateTime::Duration->new(days => 10)); > AddIssue( $borrower, $barcode, $daysago20 ); > AddReturn( $barcode, $branchcode ); > $debarments = GetDebarments({borrowernumber => $borrower->{borrowernumber}}); >@@ -130,6 +129,29 @@ is( > ); > DelDebarment( $debarments->[0]->{borrower_debarment_id} ); > >+my $yesterday = dt_from_string->subtract_duration(DateTime::Duration->new( days => 1 )); >+my $daysafter2 = dt_from_string->add_duration(DateTime::Duration->new( days => 2 )); >+AddIssue( $borrower, $barcode, $yesterday); >+AddReturn( $barcode, $branchcode ); >+$debarments = GetDebarments({borrowernumber => $borrower->{borrowernumber}}); >+is( >+ $debarments->[0]->{expiration}, >+ output_pref({ dt => $daysafter2, dateformat => 'iso', dateonly => 1 }), >+ 'calculate suspension with lengthunit hours.' >+); >+DelDebarment( $debarments->[0]->{borrower_debarment_id} ); >+ >+my $hoursago2= dt_from_string->subtract_duration(DateTime::Duration->new(hours => 2)); >+AddIssue( $borrower, $barcode, $hoursago2); >+AddReturn( $barcode, $branchcode ); >+$debarments = GetDebarments({borrowernumber => $borrower->{borrowernumber}}); >+is( >+ $debarments->[0]->{expiration}, >+ output_pref({ dt => $daysafter2, dateformat => 'iso', dateonly => 1 }), >+ 'calculate suspension with lengthunit hours.' >+); >+DelDebarment( $debarments->[0]->{borrower_debarment_id} ); >+ > $schema->storage->txn_rollback; > > # C4::Context->userenv >-- >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