Bug 23382: Truncate dates to minutes for comparison.
It's somewhat of a mess in C4::Circulation as to when dates are truncated and when they are not and as such Koha::Charges::Fees could not reliably assume that the dates passed in were consistent with each other. As such, we take the approach of always truncating to the greatest minute smaller than the passed in dates so we are comparing like for like. Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
parent
8f3093c9a0
commit
bbdee010aa
1 changed files with 12 additions and 6 deletions
|
@ -88,9 +88,9 @@ sub new {
|
|||
=cut
|
||||
|
||||
sub accumulate_rentalcharge {
|
||||
my ( $self ) = @_;
|
||||
my ($self) = @_;
|
||||
|
||||
my $itemtype = Koha::ItemTypes->find( $self->item->effective_itemtype );
|
||||
my $itemtype = Koha::ItemTypes->find( $self->item->effective_itemtype );
|
||||
my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule(
|
||||
{
|
||||
categorycode => $self->patron->categorycode,
|
||||
|
@ -99,7 +99,10 @@ sub accumulate_rentalcharge {
|
|||
}
|
||||
);
|
||||
my $units = $issuing_rule->lengthunit;
|
||||
my $rentalcharge_increment = ( $units eq 'days' ) ? $itemtype->rentalcharge_daily : $itemtype->rentalcharge_hourly;
|
||||
my $rentalcharge_increment =
|
||||
( $units eq 'days' )
|
||||
? $itemtype->rentalcharge_daily
|
||||
: $itemtype->rentalcharge_hourly;
|
||||
|
||||
return 0 unless $rentalcharge_increment && $rentalcharge_increment > 0;
|
||||
|
||||
|
@ -108,11 +111,14 @@ sub accumulate_rentalcharge {
|
|||
|
||||
if ( $units eq 'hours' ) {
|
||||
if ( C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed' ) {
|
||||
$duration =
|
||||
$calendar->hours_between( $self->from_date, $self->to_date );
|
||||
$duration = $calendar->hours_between(
|
||||
$self->from_date->truncate( to => 'minute' ),
|
||||
$self->to_date->truncate( to => 'minute' )
|
||||
);
|
||||
}
|
||||
else {
|
||||
$duration = $self->to_date->delta_ms($self->from_date);
|
||||
$duration = $self->to_date->truncate( to => 'minute' )
|
||||
->delta_ms( $self->from_date->truncate( to => 'minute' ) );
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Reference in a new issue