[Koha-bugs] [Bug 5789] Fines don't work when items have null homebranch

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Wed May 28 22:10:57 CEST 2014


http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=5789

Barton Chittenden <barton at bywatersolutions.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |barton at bywatersolutions.com

--- Comment #3 from Barton Chittenden <barton at bywatersolutions.com> ---
Fines.pl crashes with the following error messages when processing an item that
has a NULL homebranch:

Use of uninitialized value $branchcode in exists at
/home/koha/kohaclone/misc/cronjobs/fines.pl line 110.
No branchcode argument passed to Koha::Calendar->new at
/home/koha/kohaclone/misc/cronjobs/fines.pl line 169.

Here is the offending code at line 110:

109 # In final case, CircControl must be PickupLibrary. (branchcode comes from
issues table here).
110     if ( !exists $is_holiday{$branchcode} ) {
111         $is_holiday{$branchcode} = set_holiday( $branchcode, $today );
112     }

line 169:

166 sub set_holiday {
167     my ( $branch, $dt ) = @_;
168 
169     my $calendar = Koha::Calendar->new( branchcode => $branch );
170     return $calendar->is_holiday($dt);
171 }

$branchcode is set here:

104     my $branchcode =
105         ( $control eq 'ItemHomeLibrary' ) ? $overdue->{homebranch}
106       : ( $control eq 'PatronLibrary' )   ? $borrower->{branchcode}
107       :                                     $overdue->{branchcode};
108 

There should be error checking at the following points: 

after $branchcode is set at line 104 -- if $branchcode is not set, the current
item is not valid. A warning should be emitted, and further processing for this
record should be skipped.

in Koha::Calendar->new() -- If the value of 'branchcode' is not set, a warning
should be emitted, and the return value should be undef.

after $is_holiday{$branchcode} is set at line 111, it should be tested for
'defined'. If it is undefined, The value should be set to "''", so that !exists
$is_holiday{$branchcode} will test correctly on future iterations.

When testing, make sure that the 'CircControl' system preference is set to 
Use the checkout and fines rules of the library the item is from, otherwise the
borrower's branchcode may mask the bug.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
You are watching all bug changes.


More information about the Koha-bugs mailing list