View | Details | Raw Unified | Return to bug 21753
Collapse All | Expand All

(-)a/C4/Circulation.pm (-5 / +1 lines)
Lines 4088-4098 sub _CalculateAndUpdateFine { Link Here
4088
4088
4089
    my $date_returned = $return_date ? dt_from_string($return_date) : dt_from_string();
4089
    my $date_returned = $return_date ? dt_from_string($return_date) : dt_from_string();
4090
4090
4091
    my ( $amount, $type, $unitcounttotal ) =
4091
    my ( $amount, $unitcounttotal, $unitcount  ) =
4092
      C4::Overdues::CalcFine( $item, $borrower->{categorycode}, $control_branchcode, $datedue, $date_returned );
4092
      C4::Overdues::CalcFine( $item, $borrower->{categorycode}, $control_branchcode, $datedue, $date_returned );
4093
4093
4094
    $type ||= q{};
4095
4096
    if ( C4::Context->preference('finesMode') eq 'production' ) {
4094
    if ( C4::Context->preference('finesMode') eq 'production' ) {
4097
        if ( $amount > 0 ) {
4095
        if ( $amount > 0 ) {
4098
            C4::Overdues::UpdateFine({
4096
            C4::Overdues::UpdateFine({
Lines 4100-4106 sub _CalculateAndUpdateFine { Link Here
4100
                itemnumber     => $issue->itemnumber,
4098
                itemnumber     => $issue->itemnumber,
4101
                borrowernumber => $issue->borrowernumber,
4099
                borrowernumber => $issue->borrowernumber,
4102
                amount         => $amount,
4100
                amount         => $amount,
4103
                type           => $type,
4104
                due            => output_pref($datedue),
4101
                due            => output_pref($datedue),
4105
            });
4102
            });
4106
        }
4103
        }
Lines 4114-4120 sub _CalculateAndUpdateFine { Link Here
4114
                itemnumber     => $issue->itemnumber,
4111
                itemnumber     => $issue->itemnumber,
4115
                borrowernumber => $issue->borrowernumber,
4112
                borrowernumber => $issue->borrowernumber,
4116
                amount         => 0,
4113
                amount         => 0,
4117
                type           => $type,
4118
                due            => output_pref($datedue),
4114
                due            => output_pref($datedue),
4119
            });
4115
            });
4120
        }
4116
        }
(-)a/C4/Overdues.pm (-15 / +16 lines)
Lines 191-197 sub checkoverdues { Link Here
191
191
192
=head2 CalcFine
192
=head2 CalcFine
193
193
194
    ($amount, $chargename,  $units_minus_grace, $chargeable_units) = &CalcFine($item,
194
    ($amount, $units_minus_grace, $chargeable_units) = &CalcFine($item,
195
                                  $categorycode, $branch,
195
                                  $categorycode, $branch,
196
                                  $start_dt, $end_dt );
196
                                  $start_dt, $end_dt );
197
197
Lines 216-228 defining the date range over which to determine the fine. Link Here
216
216
217
Fines scripts should just supply the date range over which to calculate the fine.
217
Fines scripts should just supply the date range over which to calculate the fine.
218
218
219
C<&CalcFine> returns four values:
219
C<&CalcFine> returns three values:
220
220
221
C<$amount> is the fine owed by the patron (see above).
221
C<$amount> is the fine owed by the patron (see above).
222
222
223
C<$chargename> is the chargename field from the applicable record in
224
the categoryitem table, whatever that is.
225
226
C<$units_minus_grace> is the number of chargeable units minus the grace period
223
C<$units_minus_grace> is the number of chargeable units minus the grace period
227
224
228
C<$chargeable_units> is the number of chargeable units (days between start and end dates, Calendar adjusted where needed,
225
C<$chargeable_units> is the number of chargeable units (days between start and end dates, Calendar adjusted where needed,
Lines 268-276 sub CalcFine { Link Here
268
265
269
    $amount = $item->{replacementprice} if ( $issuing_rule->cap_fine_to_replacement_price && $item->{replacementprice} && $amount > $item->{replacementprice} );
266
    $amount = $item->{replacementprice} if ( $issuing_rule->cap_fine_to_replacement_price && $item->{replacementprice} && $amount > $item->{replacementprice} );
270
267
271
    $debug and warn sprintf("CalcFine returning (%s, %s, %s, %s)", $amount, $issuing_rule->chargename, $units_minus_grace, $chargeable_units);
268
    $debug and warn sprintf("CalcFine returning (%s, %s, %s, %s)", $amount, $units_minus_grace, $chargeable_units);
272
    return ($amount, $issuing_rule->chargename, $units_minus_grace, $chargeable_units);
269
    return ($amount, $units_minus_grace, $chargeable_units);
273
    # FIXME: chargename is NEVER populated anywhere.
274
}
270
}
275
271
276
272
Lines 470-476 sub GetIssuesIteminfo { Link Here
470
466
471
=head2 UpdateFine
467
=head2 UpdateFine
472
468
473
    &UpdateFine({ issue_id => $issue_id, itemnumber => $itemnumber, borrwernumber => $borrowernumber, amount => $amount, type => $type, $due => $date_due });
469
    &UpdateFine(
470
        {
471
            issue_id       => $issue_id,
472
            itemnumber     => $itemnumber,
473
            borrowernumber => $borrowernumber,
474
            amount         => $amount,
475
            due            => $date_due
476
        }
477
    );
474
478
475
(Note: the following is mostly conjecture and guesswork.)
479
(Note: the following is mostly conjecture and guesswork.)
476
480
Lines 483-490 has the book on loan. Link Here
483
487
484
C<$amount> is the current amount owed by the patron.
488
C<$amount> is the current amount owed by the patron.
485
489
486
C<$type> will be used in the description of the fine.
487
488
C<$due> is the due date formatted to the currently specified date format
490
C<$due> is the due date formatted to the currently specified date format
489
491
490
C<&UpdateFine> looks up the amount currently owed on the given item
492
C<&UpdateFine> looks up the amount currently owed on the given item
Lines 508-517 sub UpdateFine { Link Here
508
    my $itemnum        = $params->{itemnumber};
510
    my $itemnum        = $params->{itemnumber};
509
    my $borrowernumber = $params->{borrowernumber};
511
    my $borrowernumber = $params->{borrowernumber};
510
    my $amount         = $params->{amount};
512
    my $amount         = $params->{amount};
511
    my $type           = $params->{type};
512
    my $due            = $params->{due};
513
    my $due            = $params->{due};
513
514
514
    $debug and warn "UpdateFine({ itemnumber => $itemnum, borrowernumber => $borrowernumber, type => $type, due => $due, issue_id => $issue_id})";
515
    $debug and warn "UpdateFine({ itemnumber => $itemnum, borrowernumber => $borrowernumber, due => $due, issue_id => $issue_id})";
515
516
516
    unless ( $issue_id ) {
517
    unless ( $issue_id ) {
517
        carp("No issue_id passed in!");
518
        carp("No issue_id passed in!");
Lines 610-616 sub UpdateFine { Link Here
610
611
611
            my $nextaccntno = C4::Accounts::getnextacctno($borrowernumber);
612
            my $nextaccntno = C4::Accounts::getnextacctno($borrowernumber);
612
613
613
            my $desc = ( $type ? "$type " : '' ) . "$title $due";    # FIXEDME, avoid whitespace prefix on empty $type
614
            my $desc = "$title $due";
614
615
615
            my $accountline = Koha::Account::Line->new(
616
            my $accountline = Koha::Account::Line->new(
616
                {
617
                {
Lines 639-645 sub UpdateFine { Link Here
639
    # logging action
640
    # logging action
640
    &logaction(
641
    &logaction(
641
        "FINES",
642
        "FINES",
642
        $type,
643
        undef,
643
        $borrowernumber,
644
        $borrowernumber,
644
        "due=".$due."  amount=".$amount." itemnumber=".$itemnum
645
        "due=".$due."  amount=".$amount." itemnumber=".$itemnum
645
        ) if C4::Context->preference("FinesLog");
646
        ) if C4::Context->preference("FinesLog");
(-)a/misc/cronjobs/fines.pl (-5 / +3 lines)
Lines 76-82 cronlogaction(); Link Here
76
my @borrower_fields =
76
my @borrower_fields =
77
  qw(cardnumber categorycode surname firstname email phone address citystate);
77
  qw(cardnumber categorycode surname firstname email phone address citystate);
78
my @item_fields  = qw(itemnumber barcode date_due);
78
my @item_fields  = qw(itemnumber barcode date_due);
79
my @other_fields = qw(type days_overdue fine);
79
my @other_fields = qw(days_overdue fine);
80
my $libname      = C4::Context->preference('LibraryName');
80
my $libname      = C4::Context->preference('LibraryName');
81
my $control      = C4::Context->preference('CircControl');
81
my $control      = C4::Context->preference('CircControl');
82
my $mode         = C4::Context->preference('finesMode');
82
my $mode         = C4::Context->preference('finesMode');
Lines 122-131 for my $overdue ( @{$overdues} ) { Link Here
122
    }
122
    }
123
    ++$counted;
123
    ++$counted;
124
124
125
    my ( $amount, $type, $unitcounttotal ) =
125
    my ( $amount, $unitcounttotal, $unitcount ) =
126
      CalcFine( $overdue, $borrower->{categorycode},
126
      CalcFine( $overdue, $borrower->{categorycode},
127
        $branchcode, $datedue, $today );
127
        $branchcode, $datedue, $today );
128
    $type ||= q{};
129
128
130
    # Don't update the fine if today is a holiday.
129
    # Don't update the fine if today is a holiday.
131
    # This ensures that dropbox mode will remove the correct amount of fine.
130
    # This ensures that dropbox mode will remove the correct amount of fine.
Lines 137-143 for my $overdue ( @{$overdues} ) { Link Here
137
                    itemnumber     => $overdue->{itemnumber},
136
                    itemnumber     => $overdue->{itemnumber},
138
                    borrowernumber => $overdue->{borrowernumber},
137
                    borrowernumber => $overdue->{borrowernumber},
139
                    amount         => $amount,
138
                    amount         => $amount,
140
                    type           => $type,
141
                    due            => output_pref($datedue),
139
                    due            => output_pref($datedue),
142
                }
140
                }
143
            );
141
            );
Lines 149-155 for my $overdue ( @{$overdues} ) { Link Here
149
          map { defined $borrower->{$_} ? $borrower->{$_} : q{} }
147
          map { defined $borrower->{$_} ? $borrower->{$_} : q{} }
150
          @borrower_fields;
148
          @borrower_fields;
151
        push @cells, map { $overdue->{$_} } @item_fields;
149
        push @cells, map { $overdue->{$_} } @item_fields;
152
        push @cells, $type, $unitcounttotal, $amount;
150
        push @cells, $unitcounttotal, $amount;
153
        say {$fh} join $delim, @cells;
151
        say {$fh} join $delim, @cells;
154
    }
152
    }
155
}
153
}
(-)a/misc/cronjobs/staticfines.pl (-4 / +1 lines)
Lines 188-194 for ( my $i = 0 ; $i < scalar(@$data) ; $i++ ) { Link Here
188
    ( $datedue_days <= $today_days ) or next;    # or it's not overdue, right?
188
    ( $datedue_days <= $today_days ) or next;    # or it's not overdue, right?
189
189
190
    $overdueItemsCounted++;
190
    $overdueItemsCounted++;
191
    my ( $amount, $type, $unitcounttotal, $unitcount ) = CalcFine(
191
    my ( $amount, $unitcounttotal, $unitcount ) = CalcFine(
192
        $data->[$i],
192
        $data->[$i],
193
        $borrower->{'categorycode'},
193
        $borrower->{'categorycode'},
194
        $branchcode,
194
        $branchcode,
Lines 206-214 for ( my $i = 0 ; $i < scalar(@$data) ; $i++ ) { Link Here
206
        next;
206
        next;
207
    }
207
    }
208
208
209
    # FIXME: $type NEVER gets populated by anything.
210
    ( defined $type ) or $type = '';
211
212
    # Don't update the fine if today is a holiday.
209
    # Don't update the fine if today is a holiday.
213
    # This ensures that dropbox mode will remove the correct amount of fine.
210
    # This ensures that dropbox mode will remove the correct amount of fine.
214
    if ( $mode eq 'production' and !$borrowersalreadyapplied->{$data->[$i]->{'borrowernumber'}}) {
211
    if ( $mode eq 'production' and !$borrowersalreadyapplied->{$data->[$i]->{'borrowernumber'}}) {
(-)a/t/db_dependent/Circulation.t (-1 lines)
Lines 491-497 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
491
            itemnumber     => $itemnumber7,
491
            itemnumber     => $itemnumber7,
492
            borrowernumber => $renewing_borrower->{borrowernumber},
492
            borrowernumber => $renewing_borrower->{borrowernumber},
493
            amount         => $fine,
493
            amount         => $fine,
494
            type           => 'FU',
495
            due            => Koha::DateUtils::output_pref($five_weeks_ago)
494
            due            => Koha::DateUtils::output_pref($five_weeks_ago)
496
        }
495
        }
497
    );
496
    );
(-)a/t/db_dependent/Circulation/GetHardDueDate.t (-9 / +1 lines)
Lines 114-120 my $default = { Link Here
114
#Test GetIssuingRule
114
#Test GetIssuingRule
115
my $sampleissuingrule1 = {
115
my $sampleissuingrule1 = {
116
    reservecharge      => '0.000000',
116
    reservecharge      => '0.000000',
117
    chargename         => undef,
118
    restrictedtype     => 0,
117
    restrictedtype     => 0,
119
    accountsent        => 0,
118
    accountsent        => 0,
120
    maxissueqty        => 5,
119
    maxissueqty        => 5,
Lines 173-179 my $sampleissuingrule2 = { Link Here
173
    overduefinescap    => undef,
172
    overduefinescap    => undef,
174
    accountsent        => undef,
173
    accountsent        => undef,
175
    reservecharge      => undef,
174
    reservecharge      => undef,
176
    chargename         => undef,
177
    restrictedtype     => undef,
175
    restrictedtype     => undef,
178
    maxsuspensiondays  => 0,
176
    maxsuspensiondays  => 0,
179
    onshelfholds       => 1,
177
    onshelfholds       => 1,
Lines 206-212 my $sampleissuingrule3 = { Link Here
206
    overduefinescap    => undef,
204
    overduefinescap    => undef,
207
    accountsent        => undef,
205
    accountsent        => undef,
208
    reservecharge      => undef,
206
    reservecharge      => undef,
209
    chargename         => undef,
210
    restrictedtype     => undef,
207
    restrictedtype     => undef,
211
    maxsuspensiondays  => 0,
208
    maxsuspensiondays  => 0,
212
    onshelfholds       => 1,
209
    onshelfholds       => 1,
Lines 240-253 $query = 'INSERT INTO issuingrules ( Link Here
240
                overduefinescap,
237
                overduefinescap,
241
                accountsent,
238
                accountsent,
242
                reservecharge,
239
                reservecharge,
243
                chargename,
244
                restrictedtype,
240
                restrictedtype,
245
                maxsuspensiondays,
241
                maxsuspensiondays,
246
                onshelfholds,
242
                onshelfholds,
247
                opacitemholds,
243
                opacitemholds,
248
                cap_fine_to_replacement_price,
244
                cap_fine_to_replacement_price,
249
                article_requests
245
                article_requests
250
                ) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)';
246
                ) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)';
251
my $sth = $dbh->prepare($query);
247
my $sth = $dbh->prepare($query);
252
$sth->execute(
248
$sth->execute(
253
    $sampleissuingrule1->{branchcode},
249
    $sampleissuingrule1->{branchcode},
Lines 273-279 $sth->execute( Link Here
273
    $sampleissuingrule1->{overduefinescap},
269
    $sampleissuingrule1->{overduefinescap},
274
    $sampleissuingrule1->{accountsent},
270
    $sampleissuingrule1->{accountsent},
275
    $sampleissuingrule1->{reservecharge},
271
    $sampleissuingrule1->{reservecharge},
276
    $sampleissuingrule1->{chargename},
277
    $sampleissuingrule1->{restrictedtype},
272
    $sampleissuingrule1->{restrictedtype},
278
    $sampleissuingrule1->{maxsuspensiondays},
273
    $sampleissuingrule1->{maxsuspensiondays},
279
    $sampleissuingrule1->{onshelfholds},
274
    $sampleissuingrule1->{onshelfholds},
Lines 305-311 $sth->execute( Link Here
305
    $sampleissuingrule2->{overduefinescap},
300
    $sampleissuingrule2->{overduefinescap},
306
    $sampleissuingrule2->{accountsent},
301
    $sampleissuingrule2->{accountsent},
307
    $sampleissuingrule2->{reservecharge},
302
    $sampleissuingrule2->{reservecharge},
308
    $sampleissuingrule2->{chargename},
309
    $sampleissuingrule2->{restrictedtype},
303
    $sampleissuingrule2->{restrictedtype},
310
    $sampleissuingrule2->{maxsuspensiondays},
304
    $sampleissuingrule2->{maxsuspensiondays},
311
    $sampleissuingrule2->{onshelfholds},
305
    $sampleissuingrule2->{onshelfholds},
Lines 337-343 $sth->execute( Link Here
337
    $sampleissuingrule3->{overduefinescap},
331
    $sampleissuingrule3->{overduefinescap},
338
    $sampleissuingrule3->{accountsent},
332
    $sampleissuingrule3->{accountsent},
339
    $sampleissuingrule3->{reservecharge},
333
    $sampleissuingrule3->{reservecharge},
340
    $sampleissuingrule3->{chargename},
341
    $sampleissuingrule3->{restrictedtype},
334
    $sampleissuingrule3->{restrictedtype},
342
    $sampleissuingrule3->{maxsuspensiondays},
335
    $sampleissuingrule3->{maxsuspensiondays},
343
    $sampleissuingrule3->{onshelfholds},
336
    $sampleissuingrule3->{onshelfholds},
344
- 

Return to bug 21753