@@ -, +, @@
---
C4/Circulation.pm | 6 +++++-
installer/data/mysql/atomicupdate/bug_24380.perl | 9 +++++++++
installer/data/mysql/sysprefs.sql | 1 +
.../prog/en/modules/admin/preferences/circulation.pref | 6 ++++++
t/db_dependent/Circulation/Returns.t | 3 ++-
5 files changed, 23 insertions(+), 2 deletions(-)
create mode 100644 installer/data/mysql/atomicupdate/bug_24380.perl
--- a/C4/Circulation.pm
+++ a/C4/Circulation.pm
@@ -1973,7 +1973,11 @@ sub AddReturn {
MarkIssueReturned( $borrowernumber, $item->itemnumber, $return_date, $patron->privacy );
};
unless ( $@ ) {
- if ( ( $return_date_specified || C4::Context->preference('CalculateFinesOnReturn') ) && !$item->itemlost ) {
+ my $calc_fine = C4::Context->preference('CalculateFinesOnReturn');
+ $calc_fine ||= $return_date_specified && C4::Context->preference('CalculateFinesOnBackdate');
+ $calc_fine &&= !$item->itemlost;
+
+ if ( $calc_fine ) {
_CalculateAndUpdateFine( { issue => $issue, item => $item->unblessed, borrower => $patron_unblessed, return_date => $return_date } );
}
} else {
--- a/installer/data/mysql/atomicupdate/bug_24380.perl
+++ a/installer/data/mysql/atomicupdate/bug_24380.perl
@@ -0,0 +1,9 @@
+$DBversion = 'XXX'; # will be replaced by the RM
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q{
+ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
+ ('CalculateFinesOnBackdate','1','','Switch to control if overdue fines are calculated on return when backdating','YesNo');
+ });
+
+ NewVersion( $DBversion, 24380, "Add syspref CalculateFinesOnBackdate");
+}
--- a/installer/data/mysql/sysprefs.sql
+++ a/installer/data/mysql/sysprefs.sql
@@ -108,6 +108,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
('BranchTransferLimitsType','ccode','itemtype|ccode','When using branch transfer limits, choose whether to limit by itemtype or collection code.','Choice'),
('BrowseResultSelection','0',NULL,'Enable/Disable browsing search results fromt the bibliographic record detail page in staff client','YesNo'),
('CalculateFinesOnReturn','1','','Switch to control if overdue fines are calculated on return or not','YesNo'),
+('CalculateFinesOnBackdate','1','','Switch to control if overdue fines are calculated on return when backdating','YesNo'),
('CalendarFirstDayOfWeek','0','0|1|2|3|4|5|6','Select the first day of week to use in the calendar.','Choice'),
('CanMarkHoldsToPullAsLost','do_not_allow','do_not_allow|allow|allow_and_notify','Add a button to the "Holds to pull" screen to mark an item as lost and notify the patron.','Choice'),
('canreservefromotherbranches','1','','With Independent branches on, can a user from one library place a hold on an item from another library','YesNo'),
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
@@ -546,6 +546,12 @@ Circulation:
- calculate and update overdue charges when an item is returned.
- "
NOTE: If you are doing hourly loans then you should have this on."
- "
NOTE: This system preference requires FinesMode to be set to 'Calculate and charge.'"
+ -
+ - pref: CalculateFinesOnBackdate
+ choices:
+ yes: Do
+ no: "Don't"
+ - calculate and update overdue charges when an item is returned with a backdated return date.
-
- pref: UpdateItemLocationOnCheckin
type: textarea
--- a/t/db_dependent/Circulation/Returns.t
+++ a/t/db_dependent/Circulation/Returns.t
@@ -402,7 +402,8 @@ subtest 'BranchTransferLimitsType' => sub {
subtest 'Backdated returns should reduce fine if needed' => sub {
plan tests => 1;
- t::lib::Mocks::mock_preference( "CalculateFinesOnReturn", 0 );
+ t::lib::Mocks::mock_preference( "CalculateFinesOnReturn", 0 );
+ t::lib::Mocks::mock_preference( "CalculateFinesOnBackdate", 1 );
my $biblio = $builder->build_object( { class => 'Koha::Biblios' } );
my $item = $builder->build_object(
--