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' )
}
}
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 );
}
});
}
+ 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";
[% 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>
[% 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>
}
);
- 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)"
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)' );