Bug 11580 - If returnBeforeExpiry is ON, use calendar to calculate return date not on closed day (depending on useDaysMode)

Test plan:
1. ReturnBeforeExpiry is activated
2. useDaysMode is different from "circulation rules only"
3. Set expiry date of a patron to a near date
4. Set a closed day on calendar for this date
5. Do a checkout

Without patch, return date will be patron expiration date
With the patch, return date will be last open day before patron expiration day

Signed-off-by: Claire Gravely <claire_gravely@hotmail.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Sophie Meynieux 2016-11-16 16:46:04 +01:00 committed by Jonathan Druart
parent f24e339dd6
commit 391bf4f38d
1 changed files with 5 additions and 0 deletions

View File

@ -3513,6 +3513,11 @@ sub CalcDateDue {
$datedue = $expiry_dt->clone->set_time_zone( C4::Context->tz );
}
}
if ( C4::Context->preference('useDaysMode') ne 'Days' ) {
# Don't return on a closed day
my $calendar = Koha::Calendar->new( branchcode => $branch );
$datedue = $calendar->prev_open_day( $datedue );
}
}
return $datedue;