Bugzilla – Attachment 101431 Details for
Bug 21443
Add ability to exclude holidays when calculating rentals fees by time period
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21443: Remove the dependency on finesCalendar
Bug-21443-Remove-the-dependency-on-finesCalendar.patch (text/plain), 6.19 KB, created by
Kyle M Hall (khall)
on 2020-03-23 12:12:02 UTC
(
hide
)
Description:
Bug 21443: Remove the dependency on finesCalendar
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2020-03-23 12:12:02 UTC
Size:
6.19 KB
patch
obsolete
>From 1bfb89677746c94a78214b2f30c34738a43eb4a2 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Mon, 23 Mar 2020 08:06:08 -0400 >Subject: [PATCH] Bug 21443: Remove the dependency on finesCalendar > >Considering that the the use of finesCalendar for this calculation is >already a binary choice, it makes sense to remove the use of >finesCalendar here. It is an uneccessary complication that could >introduce confusion. Allowing this new setting to directly control >the behavior makes it clear and obvious what is going on. > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > Koha/Charges/Fees.pm | 4 ++-- > installer/data/mysql/atomicupdate/bug_21443.perl | 4 ++++ > koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt | 4 ++-- > t/db_dependent/Koha/Charges/Fees.t | 6 +++--- > 4 files changed, 11 insertions(+), 7 deletions(-) > >diff --git a/Koha/Charges/Fees.pm b/Koha/Charges/Fees.pm >index a3d2a12e39..7eff76ba79 100644 >--- a/Koha/Charges/Fees.pm >+++ b/Koha/Charges/Fees.pm >@@ -112,7 +112,7 @@ sub accumulate_rentalcharge { > my $calendar = Koha::Calendar->new( branchcode => $self->library->id ); > > if ( $units eq 'hours' ) { >- if ( $itemtype->rentalcharge_hourly_calendar && C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed' ) { >+ if ( $itemtype->rentalcharge_hourly_calendar ) { > $duration = $calendar->hours_between( > $self->from_date->truncate( to => 'minute' ), > $self->to_date->truncate( to => 'minute' ) >@@ -124,7 +124,7 @@ sub accumulate_rentalcharge { > } > } > else { >- if ( $itemtype->rentalcharge_daily_calendar && C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed' ) { >+ if ( $itemtype->rentalcharge_daily_calendar ) { > $duration = > $calendar->days_between( $self->from_date, $self->to_date ); > } >diff --git a/installer/data/mysql/atomicupdate/bug_21443.perl b/installer/data/mysql/atomicupdate/bug_21443.perl >index 74cf57f650..82329231c0 100644 >--- a/installer/data/mysql/atomicupdate/bug_21443.perl >+++ b/installer/data/mysql/atomicupdate/bug_21443.perl >@@ -16,6 +16,10 @@ if( CheckVersion( $DBversion ) ) { > }); > } > >+ my $finesCalendar = C4::Context->preference('finesCalendar'); >+ my $value = $finesCalendar eq 'noFinesWhenClosed' ? 1 : 0; >+ $dbh->do("UPDATE itemtypes SET rentalcharge_hourly_calendar = $value, rentalcharge_daily_calendar = $value"); >+ > # Always end with this (adjust the bug info) > SetVersion( $DBversion ); > print "Upgrade to $DBversion done (Bug 21443: Add ability to exclude holidays when calculating rentals fees by time period)\n"; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt >index 3ba8410352..a0240539fa 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt >@@ -248,7 +248,7 @@ Item types administration > [% ELSE %] > <input type="checkbox" id="rentalcharge_daily_calendar" name="rentalcharge_daily_calendar" value="1" /> > [% END %] >- <span class="hint">If checked, daily charge will be calculated based on the value of the system preference <i>finesCalendar</i>. If not checked, the fee will be calculated based on the number of days until due, directly.</span> >+ <span class="hint">If checked, daily charge will be calculated using the calendar to exclude holidays. If not checked, the fee will be calculated based on the number of days until due, directly.</span> > </li> > <li> > <label for="rentalcharge_hourly">Hourly rental charge: </label> >@@ -262,7 +262,7 @@ Item types administration > [% ELSE %] > <input type="checkbox" id="rentalcharge_hourly_calendar" name="rentalcharge_hourly_calendar" value="1" /> > [% END %] >- <span class="hint">If checked, hourly charge will be calculated based on the value of the system preference <i>finesCalendar</i>. If not checked, the fee will be calculated based on the number of hours until due, directly.</span> >+ <span class="hint">If checked, hourly charge will be calculated using the calendar to exclude holidays. If not checked, the fee will be calculated based on the number of hours until due, directly.</span> > </li> > <li> > <label for="defaultreplacecost">Default replacement cost: </label> >diff --git a/t/db_dependent/Koha/Charges/Fees.t b/t/db_dependent/Koha/Charges/Fees.t >index a28cc48f92..a204521b9a 100644 >--- a/t/db_dependent/Koha/Charges/Fees.t >+++ b/t/db_dependent/Koha/Charges/Fees.t >@@ -408,11 +408,11 @@ subtest 'accumulate_rentalcharge tests' => sub { > } > ); > >- t::lib::Mocks::mock_preference( 'finesCalendar', 'ignoreCalendar' ); >+ $itemtype->rentalcharge_hourly_calendar(0)->store(); > $charge = $fees->accumulate_rentalcharge(); > is( $charge, 24.00, 'Hourly rental charge calculated correctly (96h * 0.25u)' ); > >- t::lib::Mocks::mock_preference( 'finesCalendar', 'noFinesWhenClosed' ); >+ $itemtype->rentalcharge_hourly_calendar(1)->store(); > $charge = $fees->accumulate_rentalcharge(); > is( $charge, 18.00, > "Hourly rental charge calculated correctly with finesCalendar = noFinesWhenClosed and closed $dayname (96h - 24h * 0.25u)" >@@ -423,8 +423,8 @@ subtest 'accumulate_rentalcharge tests' => sub { > is( $charge, 24.00, > "Hourly rental charge calculated correctly with finesCalendar = noFinesWhenClosed and closed $dayname (96h - 24h * 0.25u) and rentalcharge_hourly_calendar = 0" > ); >- $itemtype->rentalcharge_hourly_calendar(1)->store(); > >+ $itemtype->rentalcharge_hourly_calendar(1)->store(); > $calendar->delete_holiday( weekday => $closed_day ); > $charge = $fees->accumulate_rentalcharge(); > is( $charge, 24.00, 'Hourly rental charge calculated correctly with finesCalendar = noFinesWhenClosed (96h - 0h * 0.25u)' ); >-- >2.21.1 (Apple Git-122.3)
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 21443
:
100402
|
100403
|
100404
|
100405
|
100744
|
100745
|
100746
|
100747
|
100748
|
101428
|
101429
|
101430
|
101431
|
101458
|
101459
|
101460
|
101461
|
101462
|
101463
|
101464
|
101465
|
101466
|
101467
|
101468
|
101469
|
101631