|
Lines 254-282
or "Final Notice". But CalcFine never defined any value.
Link Here
|
| 254 |
sub CalcFine { |
254 |
sub CalcFine { |
| 255 |
my ( $item, $bortype, $branchcode, $due_dt, $end_date ) = @_; |
255 |
my ( $item, $bortype, $branchcode, $due_dt, $end_date ) = @_; |
| 256 |
my $start_date = $due_dt->clone(); |
256 |
my $start_date = $due_dt->clone(); |
| 257 |
my $dbh = C4::Context->dbh; |
|
|
| 258 |
my $amount = 0; |
| 259 |
my $charge_duration; |
| 260 |
# get issuingrules (fines part will be used) |
257 |
# get issuingrules (fines part will be used) |
| 261 |
my $data = C4::Circulation::GetIssuingRule($bortype, $item->{itemtype}, $branchcode); |
258 |
my $data = C4::Circulation::GetIssuingRule($bortype, $item->{itemtype}, $branchcode); |
| 262 |
if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') { |
|
|
| 263 |
my $calendar = Koha::Calendar->new( branchcode => $branchcode ); |
| 264 |
$charge_duration = $calendar->days_between( $start_date, $end_date ); |
| 265 |
} else { |
| 266 |
$charge_duration = $end_date - $start_date; |
| 267 |
} |
| 268 |
# correct for grace period. |
| 269 |
my $fine_unit = $data->{lengthunit}; |
259 |
my $fine_unit = $data->{lengthunit}; |
| 270 |
$fine_unit ||= 'days'; |
260 |
$fine_unit ||= 'days'; |
| 271 |
my $chargeable_units; |
261 |
|
| 272 |
if ($fine_unit eq 'hours') { |
262 |
my $chargeable_units = _get_chargeable_units($fine_unit, $start_date, $end_date, $branchcode); |
| 273 |
$chargeable_units = $charge_duration->hours(); # TODO closed times??? |
|
|
| 274 |
} |
| 275 |
else { |
| 276 |
$chargeable_units = $charge_duration->days; |
| 277 |
} |
| 278 |
my $days_minus_grace = $chargeable_units - $data->{firstremind}; |
263 |
my $days_minus_grace = $chargeable_units - $data->{firstremind}; |
| 279 |
if ($data->{'chargeperiod'} && $days_minus_grace ) { |
264 |
my $amount = 0; |
|
|
265 |
if ($data->{'chargeperiod'} && $days_minus_grace ) { |
| 280 |
$amount = int($chargeable_units / $data->{'chargeperiod'}) * $data->{'fine'};# TODO fine calc should be in cents |
266 |
$amount = int($chargeable_units / $data->{'chargeperiod'}) * $data->{'fine'};# TODO fine calc should be in cents |
| 281 |
} else { |
267 |
} else { |
| 282 |
# a zero (or null) chargeperiod means no charge. |
268 |
# a zero (or null) chargeperiod means no charge. |
|
Lines 288-293
sub CalcFine {
Link Here
|
| 288 |
# FIXME: chargename is NEVER populated anywhere. |
274 |
# FIXME: chargename is NEVER populated anywhere. |
| 289 |
} |
275 |
} |
| 290 |
|
276 |
|
|
|
277 |
sub _get_chargeable_units { |
| 278 |
my ($unit, $dt1, $dt2, $branchcode) = @_; |
| 279 |
my $charge_units = 0; |
| 280 |
my $charge_duration; |
| 281 |
if ($unit eq 'hours') { |
| 282 |
if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') { |
| 283 |
my $calendar = Koha::Calendar->new( branchcode => $branchcode ); |
| 284 |
$charge_duration = $calendar->hours_between( $dt1, $dt2 ); |
| 285 |
} else { |
| 286 |
$charge_duration = $dt2->delta_ms( $dt1 ); |
| 287 |
} |
| 288 |
return $charge_duration->in_units('hours'); |
| 289 |
} |
| 290 |
else { # days |
| 291 |
if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') { |
| 292 |
my $calendar = Koha::Calendar->new( branchcode => $branchcode ); |
| 293 |
$charge_duration = $calendar->days_between( $dt1, $dt2 ); |
| 294 |
} else { |
| 295 |
$charge_duration = $dt2->delta_days( $dt1 ); |
| 296 |
} |
| 297 |
return $charge_duration->in_units('days'); |
| 298 |
} |
| 299 |
} |
| 300 |
|
| 291 |
|
301 |
|
| 292 |
=head2 GetSpecialHolidays |
302 |
=head2 GetSpecialHolidays |
| 293 |
|
303 |
|