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

(-)a/C4/Circulation.pm (-33 / +28 lines)
Lines 1460-1477 sub AddIssue { Link Here
1460
                }
1460
                }
1461
            }
1461
            }
1462
1462
1463
            ModItem(
1463
            $item_object->issues( ( $item_object->issues || 0 ) + 1);
1464
                {
1464
            $item_object->holdingbranch(C4::Context->userenv->{'branch'});
1465
                    issues        => ( $item_object->issues || 0 ) + 1,
1465
            $item_object->itemlost(0);
1466
                    holdingbranch => C4::Context->userenv->{'branch'},
1466
            $item_object->onloan($datedue->ymd());
1467
                    itemlost      => 0,
1467
            $item_object->datelastborrowed(DateTime->now( time_zone => C4::Context->tz() )->ymd()); # FIXME we should use dt_from_string here
1468
                    onloan        => $datedue->ymd(),
1468
            $item_object->store({log_action => 0});
1469
                    datelastborrowed => DateTime->now( time_zone => C4::Context->tz() )->ymd(),
1470
                },
1471
                $item_object->biblionumber,
1472
                $item_object->itemnumber,
1473
                { log_action => 0 }
1474
            );
1475
            ModDateLastSeen( $item_object->itemnumber );
1469
            ModDateLastSeen( $item_object->itemnumber );
1476
1470
1477
            # If it costs to borrow this book, charge it to the patron's account.
1471
            # If it costs to borrow this book, charge it to the patron's account.
Lines 1881-1887 sub AddReturn { Link Here
1881
                . Dumper($issue->unblessed) . "\n";
1875
                . Dumper($issue->unblessed) . "\n";
1882
    } else {
1876
    } else {
1883
        $messages->{'NotIssued'} = $barcode;
1877
        $messages->{'NotIssued'} = $barcode;
1884
        ModItem({ onloan => undef }, $item->biblionumber, $item->itemnumber) if defined $item->onloan;
1878
        $item->onloan(undef)->store if defined $item->onloan;
1879
1885
        # even though item is not on loan, it may still be transferred;  therefore, get current branch info
1880
        # even though item is not on loan, it may still be transferred;  therefore, get current branch info
1886
        $doreturn = 0;
1881
        $doreturn = 0;
1887
        # No issue, no borrowernumber.  ONLY if $doreturn, *might* you have a $borrower later.
1882
        # No issue, no borrowernumber.  ONLY if $doreturn, *might* you have a $borrower later.
Lines 1892-1898 sub AddReturn { Link Here
1892
        }
1887
        }
1893
    }
1888
    }
1894
1889
1895
    my $item_unblessed = $item->unblessed;
1896
        # full item data, but no borrowernumber or checkout info (no issue)
1890
        # full item data, but no borrowernumber or checkout info (no issue)
1897
    my $hbr = GetBranchItemRule($item->homebranch, $itemtype)->{'returnbranch'} || "homebranch";
1891
    my $hbr = GetBranchItemRule($item->homebranch, $itemtype)->{'returnbranch'} || "homebranch";
1898
        # get the proper branch to which to return the item
1892
        # get the proper branch to which to return the item
Lines 1911-1917 sub AddReturn { Link Here
1911
            if ($update_loc_rules->{_ALL_} eq '_BLANK_') { $update_loc_rules->{_ALL_} = ''; }
1905
            if ($update_loc_rules->{_ALL_} eq '_BLANK_') { $update_loc_rules->{_ALL_} = ''; }
1912
            if ( $item->location ne $update_loc_rules->{_ALL_}) {
1906
            if ( $item->location ne $update_loc_rules->{_ALL_}) {
1913
                $messages->{'ItemLocationUpdated'} = { from => $item->location, to => $update_loc_rules->{_ALL_} };
1907
                $messages->{'ItemLocationUpdated'} = { from => $item->location, to => $update_loc_rules->{_ALL_} };
1914
                ModItem( { location => $update_loc_rules->{_ALL_} }, undef, $itemnumber );
1908
                $item->location($update_loc_rules->{_ALL_})->store;
1915
            }
1909
            }
1916
        }
1910
        }
1917
        else {
1911
        else {
Lines 1920-1926 sub AddReturn { Link Here
1920
                if ( $update_loc_rules->{$key} eq '_BLANK_') { $update_loc_rules->{$key} = '' ;}
1914
                if ( $update_loc_rules->{$key} eq '_BLANK_') { $update_loc_rules->{$key} = '' ;}
1921
                if ( ($item->location eq $key && $item->location ne $update_loc_rules->{$key}) || ($key eq '_BLANK_' && $item->location eq '' && $update_loc_rules->{$key} ne '') ) {
1915
                if ( ($item->location eq $key && $item->location ne $update_loc_rules->{$key}) || ($key eq '_BLANK_' && $item->location eq '' && $update_loc_rules->{$key} ne '') ) {
1922
                    $messages->{'ItemLocationUpdated'} = { from => $item->location, to => $update_loc_rules->{$key} };
1916
                    $messages->{'ItemLocationUpdated'} = { from => $item->location, to => $update_loc_rules->{$key} };
1923
                    ModItem( { location => $update_loc_rules->{$key} }, undef, $itemnumber );
1917
                    $item->location($update_loc_rules->{$key})->store;
1924
                    last;
1918
                    last;
1925
                }
1919
                }
1926
            }
1920
            }
Lines 1939-1945 sub AddReturn { Link Here
1939
            foreach my $key ( keys %$rules ) {
1933
            foreach my $key ( keys %$rules ) {
1940
                if ( $item->notforloan eq $key ) {
1934
                if ( $item->notforloan eq $key ) {
1941
                    $messages->{'NotForLoanStatusUpdated'} = { from => $item->notforloan, to => $rules->{$key} };
1935
                    $messages->{'NotForLoanStatusUpdated'} = { from => $item->notforloan, to => $rules->{$key} };
1942
                    ModItem( { notforloan => $rules->{$key} }, undef, $itemnumber, { log_action => 0 } );
1936
                    $item->notforloan($rules->{$key})->store({ log_action => 0 });
1943
                    last;
1937
                    last;
1944
                }
1938
                }
1945
            }
1939
            }
Lines 1947-1953 sub AddReturn { Link Here
1947
    }
1941
    }
1948
1942
1949
    # check if the return is allowed at this branch
1943
    # check if the return is allowed at this branch
1950
    my ($returnallowed, $message) = CanBookBeReturned($item_unblessed, $branch);
1944
    my ($returnallowed, $message) = CanBookBeReturned($item->unblessed, $branch);
1951
    unless ($returnallowed){
1945
    unless ($returnallowed){
1952
        $messages->{'Wrongbranch'} = {
1946
        $messages->{'Wrongbranch'} = {
1953
            Wrongbranch => $branch,
1947
            Wrongbranch => $branch,
Lines 1977-1983 sub AddReturn { Link Here
1977
            };
1971
            };
1978
            unless ( $@ ) {
1972
            unless ( $@ ) {
1979
                if ( C4::Context->preference('CalculateFinesOnReturn') && !$item->itemlost ) {
1973
                if ( C4::Context->preference('CalculateFinesOnReturn') && !$item->itemlost ) {
1980
                    _CalculateAndUpdateFine( { issue => $issue, item => $item_unblessed, borrower => $patron_unblessed, return_date => $return_date } );
1974
                    _CalculateAndUpdateFine( { issue => $issue, item => $item->unblessed, borrower => $patron_unblessed, return_date => $return_date } );
1981
                }
1975
                }
1982
            } else {
1976
            } else {
1983
                carp "The checkin for the following issue failed, Please go to the about page, section 'data corrupted' to know how to fix this problem ($@)" . Dumper( $issue->unblessed );
1977
                carp "The checkin for the following issue failed, Please go to the about page, section 'data corrupted' to know how to fix this problem ($@)" . Dumper( $issue->unblessed );
Lines 1990-1996 sub AddReturn { Link Here
1990
1984
1991
        }
1985
        }
1992
1986
1993
        ModItem( { onloan => undef }, $item->biblionumber, $item->itemnumber, { log_action => 0 } );
1987
        $item->onloan(undef)->store({ log_action => 0 });
1994
    }
1988
    }
1995
1989
1996
    # the holdingbranch is updated if the document is returned to another location.
1990
    # the holdingbranch is updated if the document is returned to another location.
Lines 1998-2004 sub AddReturn { Link Here
1998
    my $item_holding_branch = $item->holdingbranch;
1992
    my $item_holding_branch = $item->holdingbranch;
1999
    if ($item->holdingbranch ne $branch) {
1993
    if ($item->holdingbranch ne $branch) {
2000
        UpdateHoldingbranch($branch, $item->itemnumber);
1994
        UpdateHoldingbranch($branch, $item->itemnumber);
2001
        $item_unblessed->{'holdingbranch'} = $branch; # update item data holdingbranch too # FIXME I guess this is for the _debar_user_on_return call later
1995
        $item->holdingbranch($branch); # update item data holdingbranch too # FIXME I guess this is for the _debar_user_on_return call later
2002
    }
1996
    }
2003
1997
2004
    my $leave_item_lost = C4::Context->preference("BlockReturnOfLostItems") ? 1 : 0;
1998
    my $leave_item_lost = C4::Context->preference("BlockReturnOfLostItems") ? 1 : 0;
Lines 2052-2058 sub AddReturn { Link Here
2052
2046
2053
        if ( $issue and $issue->is_overdue ) {
2047
        if ( $issue and $issue->is_overdue ) {
2054
        # fix fine days
2048
        # fix fine days
2055
            my ($debardate,$reminder) = _debar_user_on_return( $patron_unblessed, $item_unblessed, dt_from_string($issue->date_due), $return_date );
2049
            my ($debardate,$reminder) = _debar_user_on_return( $patron_unblessed, $item->unblessed, dt_from_string($issue->date_due), $return_date );
2056
            if ($reminder){
2050
            if ($reminder){
2057
                $messages->{'PrevDebarred'} = $debardate;
2051
                $messages->{'PrevDebarred'} = $debardate;
2058
            } else {
2052
            } else {
Lines 2111-2117 sub AddReturn { Link Here
2111
        if ($doreturn && $circulation_alert->is_enabled_for(\%conditions)) {
2105
        if ($doreturn && $circulation_alert->is_enabled_for(\%conditions)) {
2112
            SendCirculationAlert({
2106
            SendCirculationAlert({
2113
                type     => 'CHECKIN',
2107
                type     => 'CHECKIN',
2114
                item     => $item_unblessed,
2108
                item     => $item->unblessed,
2115
                borrower => $patron->unblessed,
2109
                borrower => $patron->unblessed,
2116
                branch   => $branch,
2110
                branch   => $branch,
2117
            });
2111
            });
Lines 2148-2154 sub AddReturn { Link Here
2148
             ! IsBranchTransferAllowed($branch, $returnbranch, $item->$BranchTransferLimitsType )
2142
             ! IsBranchTransferAllowed($branch, $returnbranch, $item->$BranchTransferLimitsType )
2149
           )) {
2143
           )) {
2150
            $debug and warn sprintf "about to call ModItemTransfer(%s, %s, %s, %s)", $item->itemnumber,$branch, $returnbranch, $transfer_trigger;
2144
            $debug and warn sprintf "about to call ModItemTransfer(%s, %s, %s, %s)", $item->itemnumber,$branch, $returnbranch, $transfer_trigger;
2151
            $debug and warn "item: " . Dumper($item_unblessed);
2145
            $debug and warn "item: " . Dumper($item->unblessed);
2152
            ModItemTransfer($item->itemnumber, $branch, $returnbranch, $transfer_trigger);
2146
            ModItemTransfer($item->itemnumber, $branch, $returnbranch, $transfer_trigger);
2153
            $messages->{'WasTransfered'} = 1;
2147
            $messages->{'WasTransfered'} = 1;
2154
        } else {
2148
        } else {
Lines 2238-2244 sub MarkIssueReturned { Link Here
2238
        # And finally delete the issue
2232
        # And finally delete the issue
2239
        $issue->delete;
2233
        $issue->delete;
2240
2234
2241
        ModItem( { 'onloan' => undef }, undef, $itemnumber, { log_action => 0 } );
2235
        $issue->item->onloan(undef)->store({ log_action => 0 });
2242
2236
2243
        if ( C4::Context->preference('StoreLastBorrower') ) {
2237
        if ( C4::Context->preference('StoreLastBorrower') ) {
2244
            my $item = Koha::Items->find( $itemnumber );
2238
            my $item = Koha::Items->find( $itemnumber );
Lines 2540-2545 sub _FixAccountForLostAndFound { Link Here
2540
    $accountline->discard_changes->status('FOUND');
2534
    $accountline->discard_changes->status('FOUND');
2541
    $accountline->store;
2535
    $accountline->store;
2542
2536
2537
    $accountline->item->paidfor('')->store({ log_action => 0 });
2538
2543
    if ( defined $account and C4::Context->preference('AccountAutoReconcile') ) {
2539
    if ( defined $account and C4::Context->preference('AccountAutoReconcile') ) {
2544
        $account->reconcile_balance;
2540
        $account->reconcile_balance;
2545
    }
2541
    }
Lines 3001-3007 sub AddRenewal { Link Here
3001
2997
3002
        # Update the renewal count on the item, and tell zebra to reindex
2998
        # Update the renewal count on the item, and tell zebra to reindex
3003
        $renews = ( $item_object->renewals || 0 ) + 1;
2999
        $renews = ( $item_object->renewals || 0 ) + 1;
3004
        ModItem( { renewals => $renews, onloan => $datedue->strftime('%Y-%m-%d %H:%M')}, $item_object->biblionumber, $itemnumber, { log_action => 0 } );
3000
        $item_object->renewals($renews);
3001
        $item_object->onloan($datedue);
3002
        $item_object->store({ log_action => 0 });
3005
3003
3006
        # Charge a new rental fee, if applicable
3004
        # Charge a new rental fee, if applicable
3007
        my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber );
3005
        my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber );
Lines 3833-3839 sub LostItem{ Link Here
3833
3831
3834
    #When item is marked lost automatically cancel its outstanding transfers and set items holdingbranch to the transfer source branch (frombranch)
3832
    #When item is marked lost automatically cancel its outstanding transfers and set items holdingbranch to the transfer source branch (frombranch)
3835
    if (my ( $datesent,$frombranch,$tobranch ) = GetTransfers($itemnumber)) {
3833
    if (my ( $datesent,$frombranch,$tobranch ) = GetTransfers($itemnumber)) {
3836
        ModItem({holdingbranch => $frombranch}, undef, $itemnumber);
3834
        Koha::Items->find($itemnumber)->holdingbranch($frombranch)->store;
3837
    }
3835
    }
3838
    my $transferdeleted = DeleteTransfer($itemnumber);
3836
    my $transferdeleted = DeleteTransfer($itemnumber);
3839
}
3837
}
Lines 3901-3912 sub ProcessOfflineReturn { Link Here
3901
                $itemnumber,
3899
                $itemnumber,
3902
                $operation->{timestamp},
3900
                $operation->{timestamp},
3903
            );
3901
            );
3904
            ModItem(
3902
            $item->renewals(0);
3905
                { renewals => 0, onloan => undef },
3903
            $item->onloan(undef);
3906
                $issue->{'biblionumber'},
3904
            $item->store({ log_action => 0 });
3907
                $itemnumber,
3908
                { log_action => 0 }
3909
            );
3910
            return "Success.";
3905
            return "Success.";
3911
        } else {
3906
        } else {
3912
            return "Item not issued.";
3907
            return "Item not issued.";
(-)a/C4/CourseReserves.pm (-11 / +8 lines)
Lines 20-26 use Modern::Perl; Link Here
20
use List::MoreUtils qw(any);
20
use List::MoreUtils qw(any);
21
21
22
use C4::Context;
22
use C4::Context;
23
use C4::Items qw(ModItem);
24
use C4::Circulation qw(GetOpenIssue);
23
use C4::Circulation qw(GetOpenIssue);
25
24
26
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $DEBUG @FIELDS);
25
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $DEBUG @FIELDS);
Lines 538-544 sub _UpdateCourseItem { Link Here
538
          : ()
537
          : ()
539
      } @FIELDS;
538
      } @FIELDS;
540
539
541
    ModItem( \%mod_params, undef, $course_item->{'itemnumber'} );
540
    Koha::Items->find( $course_item->{itemnumber} )
541
               ->set( \%mod_params )
542
               ->store;
542
}
543
}
543
544
544
=head2 _ModStoredFields
545
=head2 _ModStoredFields
Lines 587-600 sub _RevertFields { Link Here
587
    return unless ($ci_id);
588
    return unless ($ci_id);
588
589
589
    my $course_item = GetCourseItem( ci_id => $params{'ci_id'} );
590
    my $course_item = GetCourseItem( ci_id => $params{'ci_id'} );
590
591
    my $course_item_object;
591
    my $mod_item_params;
592
    foreach my $field ( @FIELDS ) {
592
    foreach my $field ( @FIELDS ) {
593
        next unless defined $course_item->{$field};
593
        next unless defined $course_item->{$field};
594
        $mod_item_params->{$field} = $course_item->{$field};
594
        $course_item->$field($course_item->{$field});
595
    }
595
    }
596
596
    $course_item_object->store;
597
    ModItem( $mod_item_params, undef, $course_item->{'itemnumber'} ) if $mod_item_params && %$mod_item_params;
598
}
597
}
599
598
600
=head2 _SwapAllFields
599
=head2 _SwapAllFields
Lines 610-625 sub _SwapAllFields { Link Here
610
    my $course_item = GetCourseItem( ci_id => $ci_id );
609
    my $course_item = GetCourseItem( ci_id => $ci_id );
611
    my $item = Koha::Items->find($course_item->{'itemnumber'});
610
    my $item = Koha::Items->find($course_item->{'itemnumber'});
612
611
613
    my %course_item_fields;
614
    my %item_fields;
612
    my %item_fields;
615
    foreach (@FIELDS) {
613
    foreach (@FIELDS) {
616
        if ( defined( $course_item->{$_} ) ) {
614
        if ( defined( $course_item->{$_} ) ) {
617
            $course_item_fields{$_} = $course_item->{$_};
618
            $item_fields{$_}        = $item->$_ || q{};
615
            $item_fields{$_}        = $item->$_ || q{};
616
            $item->$_($course_item->{$_});
619
        }
617
        }
620
    }
618
    }
621
619
    $item->store;
622
    ModItem( \%course_item_fields, undef, $course_item->{'itemnumber'} ) if %course_item_fields;
623
    _ModStoredFields( %item_fields, ci_id => $ci_id );
620
    _ModStoredFields( %item_fields, ci_id => $ci_id );
624
}
621
}
625
622
(-)a/C4/Items.pm (-11 / +16 lines)
Lines 134-140 sub CartToShelf { Link Here
134
134
135
    my $item = Koha::Items->find($itemnumber);
135
    my $item = Koha::Items->find($itemnumber);
136
    if ( $item->location eq 'CART' ) {
136
    if ( $item->location eq 'CART' ) {
137
        ModItem({ location => $item->permanent_location}, undef, $itemnumber);
137
        $item->location($item->permanent_location)->store;
138
    }
138
    }
139
}
139
}
140
140
Lines 368-375 sub ModItemFromMarc { Link Here
368
    }
368
    }
369
    my $unlinked_item_subfields = _get_unlinked_item_subfields( $localitemmarc, $frameworkcode );
369
    my $unlinked_item_subfields = _get_unlinked_item_subfields( $localitemmarc, $frameworkcode );
370
370
371
    ModItem( $item, $biblionumber, $itemnumber, { unlinked_item_subfields => $unlinked_item_subfields } );
371
    my $item_object = Koha::Items->find($itemnumber);
372
    return $item;
372
    $item_object->more_subfields_xml(_get_unlinked_subfields_xml($unlinked_item_subfields))->store;
373
374
    return $item_object->get_from_storage->unblessed;
373
}
375
}
374
376
375
=head2 ModItem
377
=head2 ModItem
Lines 498-504 sub ModItemTransfer { Link Here
498
        VALUES (?, ?, NOW(), ?, ?)");
500
        VALUES (?, ?, NOW(), ?, ?)");
499
    $sth->execute($itemnumber, $frombranch, $tobranch, $trigger);
501
    $sth->execute($itemnumber, $frombranch, $tobranch, $trigger);
500
502
501
    ModItem({ holdingbranch => $frombranch }, undef, $itemnumber, { log_action => 0 });
503
    # FIXME we are fetching the item twice in the 2 next statements!
504
    Koha::Items->find($itemnumber)->holdingbranch($frombranch)->store({ log_action => 0 });
502
    ModDateLastSeen($itemnumber);
505
    ModDateLastSeen($itemnumber);
503
    return;
506
    return;
504
}
507
}
Lines 518-528 sub ModDateLastSeen { Link Here
518
521
519
    my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
522
    my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
520
523
521
    my $params;
524
    my $item = Koha::Items->find($itemnumber);
522
    $params->{datelastseen} = $today;
525
    $item->datelastseen($today);
523
    $params->{itemlost} = 0 unless $leave_item_lost;
526
    $item->itemlost(0) unless $leave_item_lost;
524
527
    $item->store({ log_action => 0 });
525
    ModItem( $params, undef, $itemnumber, { log_action => 0 } );
526
}
528
}
527
529
528
=head2 DelItem
530
=head2 DelItem
Lines 2508-2520 sub ToggleNewStatus { Link Here
2508
        while ( my $values = $sth->fetchrow_hashref ) {
2510
        while ( my $values = $sth->fetchrow_hashref ) {
2509
            my $biblionumber = $values->{biblionumber};
2511
            my $biblionumber = $values->{biblionumber};
2510
            my $itemnumber = $values->{itemnumber};
2512
            my $itemnumber = $values->{itemnumber};
2513
            my $item = Koha::Items->find($itemnumber);
2511
            for my $substitution ( @$substitutions ) {
2514
            for my $substitution ( @$substitutions ) {
2515
                my $field = $substitution->{item_field};
2516
                my $value = $substitution->{value};
2512
                next unless $substitution->{field};
2517
                next unless $substitution->{field};
2513
                next if ( defined $values->{ $substitution->{item_field} } and $values->{ $substitution->{item_field} } eq $substitution->{value} );
2518
                next if ( defined $values->{ $substitution->{item_field} } and $values->{ $substitution->{item_field} } eq $substitution->{value} );
2514
                C4::Items::ModItem( { $substitution->{item_field} => $substitution->{value} }, $biblionumber, $itemnumber )
2519
                $item->$field($value);
2515
                    unless $report_only;
2516
                push @{ $report->{$itemnumber} }, $substitution;
2520
                push @{ $report->{$itemnumber} }, $substitution;
2517
            }
2521
            }
2522
            $item->store unless $report_only;
2518
        }
2523
        }
2519
    }
2524
    }
2520
2525
(-)a/Koha/Item.pm (-6 / +55 lines)
Lines 21-26 use Modern::Perl; Link Here
21
21
22
use Carp;
22
use Carp;
23
use List::MoreUtils qw(any);
23
use List::MoreUtils qw(any);
24
use Data::Dumper;
24
25
25
use Koha::Database;
26
use Koha::Database;
26
use Koha::DateUtils qw( dt_from_string );
27
use Koha::DateUtils qw( dt_from_string );
Lines 58-64 Koha::Item - Koha Item object class Link Here
58
=cut
59
=cut
59
60
60
sub store {
61
sub store {
61
    my ($self) = @_;
62
    my ($self, $params) = @_;
63
64
    my $log_action = $params->{log_action} // 1;
62
65
63
    # We do not want to oblige callers to pass this value
66
    # We do not want to oblige callers to pass this value
64
    # Dev conveniences vs performance?
67
    # Dev conveniences vs performance?
Lines 71-76 sub store { Link Here
71
        $self->itype($self->biblio->biblioitem->itemtype);
74
        $self->itype($self->biblio->biblioitem->itemtype);
72
    }
75
    }
73
76
77
    if ( $self->itemcallnumber ) { # This could be improved, we should recalculate it only if changed
78
        my $cn_sort = GetClassSort($self->cn_source, $self->itemcallnumber, "");
79
        $self->cn_sort($cn_sort);
80
    }
81
74
    my $today = dt_from_string;
82
    my $today = dt_from_string;
75
    unless ( $self->in_storage ) { #AddItem
83
    unless ( $self->in_storage ) { #AddItem
76
        unless ( $self->permanent_location ) {
84
        unless ( $self->permanent_location ) {
Lines 87-101 sub store { Link Here
87
            $self->dateaccessioned($today);
95
            $self->dateaccessioned($today);
88
        }
96
        }
89
97
90
        if ( $self->itemcallnumber ) { # This could be improved, we should recalculate it only if changed
98
        C4::Biblio::ModZebra( $self->biblionumber, "specialUpdate", "biblioserver" );
91
            my $cn_sort = GetClassSort($self->cn_source, $self->itemcallnumber, "");
99
92
            $self->cn_sort($cn_sort);
100
        logaction( "CATALOGUING", "ADD", $self->itemnumber, "item" )
101
          if $log_action && C4::Context->preference("CataloguingLog");
102
103
        $self->_after_item_action_hooks({ action => 'create' });
104
105
    } else { # ModItem
106
107
        { # Update *_on  fields if needed
108
          # Why not for AddItem as well?
109
            my @fields = qw( itemlost withdrawn damaged );
110
111
            # Only retrieve the item if we need to set an "on" date field
112
            if ( $self->itemlost || $self->withdrawn || $self->damaged ) {
113
                my $pre_mod_item = $self->get_from_storage;
114
                for my $field (@fields) {
115
                    if (    $self->$field
116
                        and not $pre_mod_item->$field )
117
                    {
118
                        my $field_on = "${field}_on";
119
                        $self->$field_on(
120
                          DateTime::Format::MySQL->format_datetime( dt_from_string() )
121
                        );
122
                    }
123
                }
124
            }
125
126
            # If the field is defined but empty, we are removing and,
127
            # and thus need to clear out the 'on' field as well
128
            for my $field (@fields) {
129
                if ( defined( $self->$field ) && !$self->$field ) {
130
                    my $field_on = "${field}_on";
131
                    $self->$field_on(undef);
132
                }
133
            }
134
        }
135
136
        if ( defined $self->location and $self->location ne 'CART' and $self->location ne 'PROC' and not $self->permanent_location ) {
137
            $self->permanent_location($self->location);
93
        }
138
        }
94
139
140
        $self->timestamp(undef) if $self->timestamp; # Maybe move this to Koha::Object->store?
141
95
        C4::Biblio::ModZebra( $self->biblionumber, "specialUpdate", "biblioserver" );
142
        C4::Biblio::ModZebra( $self->biblionumber, "specialUpdate", "biblioserver" );
96
143
97
        logaction( "CATALOGUING", "ADD", $self->itemnumber, "item" )
144
        $self->_after_item_action_hooks({ action => 'modify' });
98
          if C4::Context->preference("CataloguingLog");
145
146
        logaction( "CATALOGUING", "MODIFY", $self->itemnumber, "item " . Dumper($self->unblessed) )
147
          if $log_action && C4::Context->preference("CataloguingLog");
99
148
100
    }
149
    }
101
150
(-)a/acqui/finishreceive.pl (-12 / +7 lines)
Lines 172-189 if ($quantityrec > $origquantityrec ) { Link Here
172
my $new_order_object = Koha::Acquisition::Orders->find( $new_ordernumber ); # FIXME we should not need to refetch it
172
my $new_order_object = Koha::Acquisition::Orders->find( $new_ordernumber ); # FIXME we should not need to refetch it
173
my $items = $new_order_object->items;
173
my $items = $new_order_object->items;
174
while ( my $item = $items->next )  {
174
while ( my $item = $items->next )  {
175
    ModItem(
175
    $item->booksellerid($booksellerid); # TODO This should be done using ->set, but bug 21761 is not resolved
176
        {
176
    $item->dateaccessioned($datereceived);
177
            booksellerid         => $booksellerid,
177
    $item->datelastseen($datereceived);
178
            dateaccessioned      => $datereceived,
178
    $item->price($unitprice);
179
            datelastseen         => $datereceived,
179
    $item->replacementprice($replacementprice);
180
            price                => $unitprice,
180
    $item->replacementpricedate($datereceived);
181
            replacementprice     => $replacementprice,
181
    $item->store;
182
            replacementpricedate => $datereceived,
183
        },
184
        $biblionumber,
185
        $item->itemnumber,
186
    );
187
}
182
}
188
183
189
print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoiceid=$invoiceid&sticky_filters=1");
184
print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoiceid=$invoiceid&sticky_filters=1");
(-)a/catalogue/updateitem.pl (-8 / +8 lines)
Lines 45-51 my $confirm=$cgi->param('confirm'); Link Here
45
my $dbh = C4::Context->dbh;
45
my $dbh = C4::Context->dbh;
46
46
47
# get the rest of this item's information
47
# get the rest of this item's information
48
my $item_data_hashref = Koha::Items->find($itemnumber)->unblessed;
48
my $item = Koha::Items->find($itemnumber);
49
my $item_data_hashref = $item->unblessed;
49
50
50
# make sure item statuses are set to 0 if empty or NULL
51
# make sure item statuses are set to 0 if empty or NULL
51
for ($damaged,$itemlost,$withdrawn) {
52
for ($damaged,$itemlost,$withdrawn) {
Lines 55-85 for ($damaged,$itemlost,$withdrawn) { Link Here
55
}
56
}
56
57
57
# modify MARC item if input differs from items table.
58
# modify MARC item if input differs from items table.
58
my $item_changes = {};
59
if ( $op eq "set_non_public_note" ) {
59
if ( $op eq "set_non_public_note" ) {
60
    checkauth($cgi, 0, {editcatalogue => 'edit_items'}, 'intranet');
60
    checkauth($cgi, 0, {editcatalogue => 'edit_items'}, 'intranet');
61
    if ((not defined  $item_data_hashref->{'itemnotes_nonpublic'}) or $itemnotes_nonpublic ne $item_data_hashref->{'itemnotes_nonpublic'}) {
61
    if ((not defined  $item_data_hashref->{'itemnotes_nonpublic'}) or $itemnotes_nonpublic ne $item_data_hashref->{'itemnotes_nonpublic'}) {
62
        $item_changes->{'itemnotes_nonpublic'} = $itemnotes_nonpublic;
62
        $item->itemnotes_nonpublic($itemnotes_nonpublic);
63
    }
63
    }
64
}
64
}
65
elsif ( $op eq "set_public_note" ) { # i.e., itemnotes parameter passed from form
65
elsif ( $op eq "set_public_note" ) { # i.e., itemnotes parameter passed from form
66
    checkauth($cgi, 0, {editcatalogue => 'edit_items'}, 'intranet');
66
    checkauth($cgi, 0, {editcatalogue => 'edit_items'}, 'intranet');
67
    if ((not defined  $item_data_hashref->{'itemnotes'}) or $itemnotes ne $item_data_hashref->{'itemnotes'}) {
67
    if ((not defined  $item_data_hashref->{'itemnotes'}) or $itemnotes ne $item_data_hashref->{'itemnotes'}) {
68
        $item_changes->{'itemnotes'} = $itemnotes;
68
        $item->itemnotes($itemnotes);
69
    }
69
    }
70
} elsif ( $op eq "set_lost" && $itemlost ne $item_data_hashref->{'itemlost'}) {
70
} elsif ( $op eq "set_lost" && $itemlost ne $item_data_hashref->{'itemlost'}) {
71
    $item_changes->{'itemlost'} = $itemlost;
71
    $item->itemlost($itemlost);
72
} elsif ( $op eq "set_withdrawn" && $withdrawn ne $item_data_hashref->{'withdrawn'}) {
72
} elsif ( $op eq "set_withdrawn" && $withdrawn ne $item_data_hashref->{'withdrawn'}) {
73
    $item_changes->{'withdrawn'} = $withdrawn;
73
    $item->withdrawn($withdrawn);
74
} elsif ( $op eq "set_damaged" && $damaged ne $item_data_hashref->{'damaged'}) {
74
} elsif ( $op eq "set_damaged" && $damaged ne $item_data_hashref->{'damaged'}) {
75
    $item_changes->{'damaged'} = $damaged;
75
    $item->damaged($damaged);
76
} else {
76
} else {
77
    #nothings changed, so do nothing.
77
    #nothings changed, so do nothing.
78
    print $cgi->redirect("moredetail.pl?biblionumber=$biblionumber&itemnumber=$itemnumber#item$itemnumber");
78
    print $cgi->redirect("moredetail.pl?biblionumber=$biblionumber&itemnumber=$itemnumber#item$itemnumber");
79
	exit;
79
	exit;
80
}
80
}
81
81
82
ModItem($item_changes, $biblionumber, $itemnumber);
82
$item->store;
83
83
84
LostItem($itemnumber, 'moredetail') if $op eq "set_lost";
84
LostItem($itemnumber, 'moredetail') if $op eq "set_lost";
85
85
(-)a/cataloguing/additem.pl (-10 / +5 lines)
Lines 76-94 sub set_item_default_location { Link Here
76
    my $itemnumber = shift;
76
    my $itemnumber = shift;
77
    my $item       = Koha::Items->find($itemnumber);
77
    my $item       = Koha::Items->find($itemnumber);
78
    if ( C4::Context->preference('NewItemsDefaultLocation') ) {
78
    if ( C4::Context->preference('NewItemsDefaultLocation') ) {
79
        ModItem(
79
        $item->permanent_location($item->location);
80
            {
80
        $item->location(C4::Context->preference('NewItemsDefaultLocation'));
81
                permanent_location => $item->location,
82
                location => C4::Context->preference('NewItemsDefaultLocation')
83
            },
84
            undef,
85
            $itemnumber
86
        );
87
    }
81
    }
88
    else {
82
    else {
89
        ModItem( { permanent_location => $item->location }, undef, $itemnumber )
83
        # It seems that we are dealing with that in too many places
90
          unless defined $item->permanent_location;
84
        $item->permanent_location($item->location) unless defined $item->permanent_location;
91
    }
85
    }
86
    $item->store;
92
}
87
}
93
88
94
# NOTE: This code is subject to change in the future with the implemenation of ajax based autobarcode code
89
# NOTE: This code is subject to change in the future with the implemenation of ajax based autobarcode code
(-)a/circ/pendingreserves.pl (-2 / +5 lines)
Lines 26-32 use C4::Output; Link Here
26
use CGI qw ( -utf8 );
26
use CGI qw ( -utf8 );
27
use C4::Auth;
27
use C4::Auth;
28
use C4::Debug;
28
use C4::Debug;
29
use C4::Items qw( ModItem ModItemTransfer );
29
use C4::Items qw( ModItemTransfer );
30
use C4::Reserves qw( ModReserveCancelAll );
30
use C4::Reserves qw( ModReserveCancelAll );
31
use Koha::Biblios;
31
use Koha::Biblios;
32
use Koha::DateUtils;
32
use Koha::DateUtils;
Lines 114-120 if ( $op eq 'cancel_reserve' and $reserve_id ) { Link Here
114
            }
114
            }
115
            else {
115
            else {
116
                eval {
116
                eval {
117
                    C4::Items::ModItem( $assignments, undef, $item->itemnumber );
117
                    while ( my ( $f, $v ) = each( %$assignments ) ) {
118
                        $item->$f($v);
119
                    }
120
                    $item->store;
118
                };
121
                };
119
                warn "Unable to modify item itemnumber=" . $item->itemnumber . ": $@" if $@;
122
                warn "Unable to modify item itemnumber=" . $item->itemnumber . ": $@" if $@;
120
            }
123
            }
(-)a/misc/cronjobs/longoverdue.pl (-1 / +2 lines)
Lines 383-389 foreach my $startrange (sort keys %$lost) { Link Here
383
            }
383
            }
384
            printf ("Due %s: item %5s from borrower %5s to lost: %s\n", $row->{date_due}, $row->{itemnumber}, $row->{borrowernumber}, $lostvalue) if($verbose);
384
            printf ("Due %s: item %5s from borrower %5s to lost: %s\n", $row->{date_due}, $row->{itemnumber}, $row->{borrowernumber}, $lostvalue) if($verbose);
385
            if($confirm) {
385
            if($confirm) {
386
                ModItem({ itemlost => $lostvalue }, $row->{'biblionumber'}, $row->{'itemnumber'});
386
                Koha::Items->find( $row->{itemnumber} )->itemlost($lostvalue)
387
                  ->store;
387
                if ( $charge && $charge eq $lostvalue ) {
388
                if ( $charge && $charge eq $lostvalue ) {
388
                    LostItem( $row->{'itemnumber'}, 'cronjob', $mark_returned );
389
                    LostItem( $row->{'itemnumber'}, 'cronjob', $mark_returned );
389
                } elsif ( $mark_returned ) {
390
                } elsif ( $mark_returned ) {
(-)a/misc/maintenance/touch_all_items.pl (-1 / +3 lines)
Lines 32-37 use Getopt::Long; Link Here
32
use Koha::Script;
32
use Koha::Script;
33
use C4::Context;
33
use C4::Context;
34
use C4::Items;
34
use C4::Items;
35
use Koha::Items;
35
use Pod::Usage;
36
use Pod::Usage;
36
37
37
38
Lines 75-87 if (defined $outfile) { Link Here
75
   open(OUT, ">&STDOUT") || die ("Couldn't duplicate STDOUT: $!");
76
   open(OUT, ">&STDOUT") || die ("Couldn't duplicate STDOUT: $!");
76
}
77
}
77
78
79
# FIXME Would be better to call Koha::Items->search here
78
my $sth_fetch = $dbh->prepare("SELECT biblionumber, itemnumber, itemcallnumber FROM items $whereclause");
80
my $sth_fetch = $dbh->prepare("SELECT biblionumber, itemnumber, itemcallnumber FROM items $whereclause");
79
$sth_fetch->execute();
81
$sth_fetch->execute();
80
82
81
# fetch info from the search
83
# fetch info from the search
82
while (my ($biblionumber, $itemnumber, $itemcallnumber) = $sth_fetch->fetchrow_array){
84
while (my ($biblionumber, $itemnumber, $itemcallnumber) = $sth_fetch->fetchrow_array){
83
   
85
   
84
  eval { ModItem({itemcallnumber => $itemcallnumber}, $biblionumber, $itemnumber); };
86
  eval { Koha::Items->find($itemnumber)->itemcallnumber($itemcallnumber)->store; };
85
  my $modok = $@ ? 0 : 1;
87
  my $modok = $@ ? 0 : 1;
86
88
87
  if ($modok) {
89
  if ($modok) {
(-)a/misc/migration_tools/fix_onloan.pl (-17 / +6 lines)
Lines 1-13 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
use strict;
3
use Modern::Perl;
4
#use warnings; FIXME - Bug 2505
5
6
use Koha::Script;
4
use Koha::Script;
7
use C4::Context;
5
use Koha::Items;
8
use C4::Items;
9
use C4::Biblio;
10
11
#
6
#
12
# the items.onloan field did not exist in koha 2.2
7
# the items.onloan field did not exist in koha 2.2
13
# in koha 3.0, it's used to define item availability
8
# in koha 3.0, it's used to define item availability
Lines 15-30 use C4::Biblio; Link Here
15
# and put it in the MARC::Record of the item
10
# and put it in the MARC::Record of the item
16
#
11
#
17
12
18
my $dbh=C4::Context->dbh;
13
my $items = Koha::Items->({ onloan => { '!=' => undef } });
19
14
20
# if (C4::Context->preference("marcflavour") ne "UNIMARC") {
21
#     print "this script is for UNIMARC only\n";
22
#     exit;
23
# }
24
my $rqbiblios=$dbh->prepare("SELECT biblionumber,itemnumber,onloan FROM items WHERE items.onloan IS NOT NULL");
25
$rqbiblios->execute;
26
$|=1;
15
$|=1;
27
while (my ($biblionumber,$itemnumber,$onloan)= $rqbiblios->fetchrow){
16
while ( my $item = $items->next ) {
28
    ModItem({onloan => "$onloan"}, $biblionumber, $itemnumber);
17
    $item->store;
29
    print "Onloan : $onloan for $biblionumber / $itemnumber\n";
18
    print sprintf "Onloan : %s for %s / %s\n", $item->onloan, $item->biblionumber, $item->itemnumber;
30
}
19
}
(-)a/offline_circ/process_koc.pl (-1 / +1 lines)
Lines 339-345 sub kocReturnItem { Link Here
339
            $patron->privacy
339
            $patron->privacy
340
        );
340
        );
341
341
342
        ModItem({ onloan => undef }, $biblio->biblionumber, $item->itemnumber);
342
        $item->onloadn(undef)->store;
343
        ModDateLastSeen( $item->itemnumber );
343
        ModDateLastSeen( $item->itemnumber );
344
344
345
        push @output,
345
        push @output,
(-)a/serials/serials-edit.pl (-1 / +6 lines)
Lines 268-274 if ( $op and $op eq 'serialchangestatus' ) { Link Here
268
                    my $subscriptioninfos = GetSubscription($subscriptionids[$i]);
268
                    my $subscriptioninfos = GetSubscription($subscriptionids[$i]);
269
269
270
                    # Changing the status to "available" and the itemtype according to the previousitemtype db field
270
                    # Changing the status to "available" and the itemtype according to the previousitemtype db field
271
                    ModItem({notforloan => 0, itype => $subscriptioninfos->{'previousitemtype'} }, undef, $itemnumber);
271
                    $serialitem->set(
272
                        {
273
                            notforloan => 0,
274
                            itype => $subscriptioninfos->{'previousitemtype'}
275
                        }
276
                    )->store;
272
                }
277
                }
273
            }
278
            }
274
        }
279
        }
(-)a/svc/checkin (-1 lines)
Lines 24-30 use CGI; Link Here
24
use JSON qw(to_json);
24
use JSON qw(to_json);
25
25
26
use C4::Circulation;
26
use C4::Circulation;
27
use C4::Items qw(ModItem);
28
use C4::Context;
27
use C4::Context;
29
use C4::Auth qw(check_cookie_auth);
28
use C4::Auth qw(check_cookie_auth);
30
use Koha::Checkouts;
29
use Koha::Checkouts;
(-)a/t/db_dependent/Circulation.t (-13 / +13 lines)
Lines 487-496 subtest "CanBookBeRenewed tests" => sub { Link Here
487
    is( $renewokay, 1, 'Can renew item 2, item-level hold is on item 1');
487
    is( $renewokay, 1, 'Can renew item 2, item-level hold is on item 1');
488
488
489
    # Items can't fill hold for reasons
489
    # Items can't fill hold for reasons
490
    ModItem({ notforloan => 1 }, $biblio->biblionumber, $item_1->itemnumber);
490
    $item_1->notforloan(1)->store;
491
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber, 1);
491
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber, 1);
492
    is( $renewokay, 1, 'Can renew, item is marked not for loan, hold does not block');
492
    is( $renewokay, 1, 'Can renew, item is marked not for loan, hold does not block');
493
    ModItem({ notforloan => 0, itype => $itemtype }, $biblio->biblionumber, $item_1->itemnumber);
493
    $item_1->set({notforloan => 0, itype => $itemtype })->store;
494
494
495
    # FIXME: Add more for itemtype not for loan etc.
495
    # FIXME: Add more for itemtype not for loan etc.
496
496
Lines 1487-1493 subtest "AllowRenewalIfOtherItemsAvailable tests" => sub { Link Here
1487
    is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled' );
1487
    is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled' );
1488
1488
1489
    # Setting item not checked out to be not for loan but holdable
1489
    # Setting item not checked out to be not for loan but holdable
1490
    ModItem({ notforloan => -1 }, $biblio->biblionumber, $item_2->itemnumber);
1490
    $item_2->notforloan(-1)->store;
1491
1491
1492
    ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber );
1492
    ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber );
1493
    is( $renewokay, 0, 'Bug 14337 - Verify the borrower can not renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is enabled but the only available item is notforloan' );
1493
    is( $renewokay, 0, 'Bug 14337 - Verify the borrower can not renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is enabled but the only available item is notforloan' );
Lines 2455-2461 subtest '_FixAccountForLostAndFound' => sub { Link Here
2455
        AddIssue( $patron->unblessed, $item->barcode );
2455
        AddIssue( $patron->unblessed, $item->barcode );
2456
2456
2457
        # Simulate item marked as lost
2457
        # Simulate item marked as lost
2458
        ModItem( { itemlost => 3 }, $biblio->biblionumber, $item->itemnumber );
2458
        $item->itemlost(3)->store;
2459
        LostItem( $item->itemnumber, 1 );
2459
        LostItem( $item->itemnumber, 1 );
2460
2460
2461
        my $processing_fee_lines = Koha::Account::Lines->search(
2461
        my $processing_fee_lines = Koha::Account::Lines->search(
Lines 2519-2525 subtest '_FixAccountForLostAndFound' => sub { Link Here
2519
        AddIssue( $patron->unblessed, $item->barcode );
2519
        AddIssue( $patron->unblessed, $item->barcode );
2520
2520
2521
        # Simulate item marked as lost
2521
        # Simulate item marked as lost
2522
        ModItem( { itemlost => 1 }, $biblio->biblionumber, $item->itemnumber );
2522
        $item->itemlost(1)->store;
2523
        LostItem( $item->itemnumber, 1 );
2523
        LostItem( $item->itemnumber, 1 );
2524
2524
2525
        my $processing_fee_lines = Koha::Account::Lines->search(
2525
        my $processing_fee_lines = Koha::Account::Lines->search(
Lines 2589-2595 subtest '_FixAccountForLostAndFound' => sub { Link Here
2589
        AddIssue( $patron->unblessed, $item->barcode );
2589
        AddIssue( $patron->unblessed, $item->barcode );
2590
2590
2591
        # Simulate item marked as lost
2591
        # Simulate item marked as lost
2592
        ModItem( { itemlost => 3 }, $biblio->biblionumber, $item->itemnumber );
2592
        $item->itemlost(3)->store;
2593
        LostItem( $item->itemnumber, 1 );
2593
        LostItem( $item->itemnumber, 1 );
2594
2594
2595
        my $processing_fee_lines = Koha::Account::Lines->search(
2595
        my $processing_fee_lines = Koha::Account::Lines->search(
Lines 2642-2648 subtest '_FixAccountForLostAndFound' => sub { Link Here
2642
        AddIssue( $patron->unblessed, $item->barcode );
2642
        AddIssue( $patron->unblessed, $item->barcode );
2643
2643
2644
        # Simulate item marked as lost
2644
        # Simulate item marked as lost
2645
        ModItem( { itemlost => 1 }, $biblio->biblionumber, $item->itemnumber );
2645
        $item->itemlost(1)->store;
2646
        LostItem( $item->itemnumber, 1 );
2646
        LostItem( $item->itemnumber, 1 );
2647
2647
2648
        my $processing_fee_lines = Koha::Account::Lines->search(
2648
        my $processing_fee_lines = Koha::Account::Lines->search(
Lines 2742-2748 subtest '_FixAccountForLostAndFound' => sub { Link Here
2742
                }
2742
                }
2743
            }
2743
            }
2744
        );
2744
        );
2745
        my $item_id = Koha::Item->new(
2745
        my $item = Koha::Item->new(
2746
            {
2746
            {
2747
                biblionumber     => $biblio->biblionumber,
2747
                biblionumber     => $biblio->biblionumber,
2748
                homebranch       => $library->branchcode,
2748
                homebranch       => $library->branchcode,
Lines 2751-2766 subtest '_FixAccountForLostAndFound' => sub { Link Here
2751
                replacementprice => $replacement_amount,
2751
                replacementprice => $replacement_amount,
2752
                itype            => $item_type->itemtype
2752
                itype            => $item_type->itemtype
2753
            },
2753
            },
2754
        )->store->itemnumber;
2754
        )->store;
2755
2755
2756
        AddIssue( $patron->unblessed, $barcode );
2756
        AddIssue( $patron->unblessed, $barcode );
2757
2757
2758
        # Simulate item marked as lost
2758
        # Simulate item marked as lost
2759
        ModItem( { itemlost => 1 }, $biblio->biblionumber, $item_id );
2759
        $item->itemlost(1)->store;
2760
        LostItem( $item_id, 1 );
2760
        LostItem( $item->itemnumber, 1 );
2761
2761
2762
        my $lost_fee_lines = Koha::Account::Lines->search(
2762
        my $lost_fee_lines = Koha::Account::Lines->search(
2763
            { borrowernumber => $patron->id, itemnumber => $item_id, debit_type_code => 'LOST' } );
2763
            { borrowernumber => $patron->id, itemnumber => $item->itemnumber, debit_type_code => 'LOST' } );
2764
        is( $lost_fee_lines->count, 1, 'Only one lost item fee produced' );
2764
        is( $lost_fee_lines->count, 1, 'Only one lost item fee produced' );
2765
        my $lost_fee_line = $lost_fee_lines->next;
2765
        my $lost_fee_line = $lost_fee_lines->next;
2766
        is( $lost_fee_line->amount + 0, $replacement_amount, 'The right LOST amount is generated' );
2766
        is( $lost_fee_line->amount + 0, $replacement_amount, 'The right LOST amount is generated' );
Lines 2792-2798 subtest '_FixAccountForLostAndFound' => sub { Link Here
2792
2792
2793
        t::lib::Mocks::mock_preference( 'AccountAutoReconcile', 1 );
2793
        t::lib::Mocks::mock_preference( 'AccountAutoReconcile', 1 );
2794
2794
2795
        my $credit_return_id = C4::Circulation::_FixAccountForLostAndFound( $item_id, $patron->id );
2795
        my $credit_return_id = C4::Circulation::_FixAccountForLostAndFound( $item->itemnumber, $patron->id );
2796
        my $credit_return = Koha::Account::Lines->find($credit_return_id);
2796
        my $credit_return = Koha::Account::Lines->find($credit_return_id);
2797
2797
2798
        is( $account->balance, $manual_debit_amount - $payment_amount, 'Balance is PROCESSING - payment (LOST_FOUND)' );
2798
        is( $account->balance, $manual_debit_amount - $payment_amount, 'Balance is PROCESSING - payment (LOST_FOUND)' );
(-)a/t/db_dependent/Circulation/Returns.t (-1 / +1 lines)
Lines 335-341 subtest 'BlockReturnOfLostItems' => sub { Link Here
335
    my $checkout = AddIssue( $patron->unblessed, $item->barcode );
335
    my $checkout = AddIssue( $patron->unblessed, $item->barcode );
336
336
337
    # Mark the item as lost
337
    # Mark the item as lost
338
    ModItem({itemlost => 1}, $biblio->biblionumber, $item->itemnumber);
338
    $item->itemlost(1)->store;
339
339
340
    t::lib::Mocks::mock_preference('BlockReturnOfLostItems', 1);
340
    t::lib::Mocks::mock_preference('BlockReturnOfLostItems', 1);
341
    my ( $doreturn, $messages, $issue ) = AddReturn($item->barcode);
341
    my ( $doreturn, $messages, $issue ) = AddReturn($item->barcode);
(-)a/t/db_dependent/Holds.t (-7 / +8 lines)
Lines 323-329 ok( Link Here
323
    is( $hold3->discard_changes->priority, 1, "After ModReserve, the 3rd reserve becomes the first on the waiting list" );
323
    is( $hold3->discard_changes->priority, 1, "After ModReserve, the 3rd reserve becomes the first on the waiting list" );
324
}
324
}
325
325
326
ModItem({ damaged => 1 }, $biblio->biblionumber, $itemnumber);
326
Koha::Items->find($itemnumber)->damaged(1)->store; # FIXME The $itemnumber is a bit confusing here
327
t::lib::Mocks::mock_preference( 'AllowHoldsOnDamagedItems', 1 );
327
t::lib::Mocks::mock_preference( 'AllowHoldsOnDamagedItems', 1 );
328
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber)->{status}, 'OK', "Patron can reserve damaged item with AllowHoldsOnDamagedItems enabled" );
328
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber)->{status}, 'OK', "Patron can reserve damaged item with AllowHoldsOnDamagedItems enabled" );
329
ok( defined( ( CheckReserves($itemnumber) )[1] ), "Hold can be trapped for damaged item with AllowHoldsOnDamagedItems enabled" );
329
ok( defined( ( CheckReserves($itemnumber) )[1] ), "Hold can be trapped for damaged item with AllowHoldsOnDamagedItems enabled" );
Lines 346-352 ok( !defined( ( CheckReserves($itemnumber) )[1] ), "Hold cannot be trapped for d Link Here
346
346
347
# Regression test for bug 9532
347
# Regression test for bug 9532
348
$biblio = $builder->build_sample_biblio({ itemtype => 'CANNOT' });
348
$biblio = $builder->build_sample_biblio({ itemtype => 'CANNOT' });
349
$itemnumber = $builder->build_sample_item({ library => $branch_1, itype => 'CANNOT', biblionumber => $biblio->biblionumber})->itemnumber;
349
$item = $builder->build_sample_item({ library => $branch_1, itype => 'CANNOT', biblionumber => $biblio->biblionumber});
350
AddReserve(
350
AddReserve(
351
    {
351
    {
352
        branchcode     => $branch_1,
352
        branchcode     => $branch_1,
Lines 356-374 AddReserve( Link Here
356
    }
356
    }
357
);
357
);
358
is(
358
is(
359
    CanItemBeReserved( $borrowernumbers[0], $itemnumber)->{status}, 'tooManyReserves',
359
    CanItemBeReserved( $borrowernumbers[0], $item->itemnumber)->{status}, 'tooManyReserves',
360
    "cannot request item if policy that matches on item-level item type forbids it"
360
    "cannot request item if policy that matches on item-level item type forbids it"
361
);
361
);
362
ModItem({ itype => 'CAN' }, $biblio->biblionumber, $itemnumber);
362
363
$item->itype('CAN')->store;
363
ok(
364
ok(
364
    CanItemBeReserved( $borrowernumbers[0], $itemnumber)->{status} eq 'OK',
365
    CanItemBeReserved( $borrowernumbers[0], $item->itemnumber)->{status} eq 'OK',
365
    "can request item if policy that matches on item type allows it"
366
    "can request item if policy that matches on item type allows it"
366
);
367
);
367
368
368
t::lib::Mocks::mock_preference('item-level_itypes', 0);
369
t::lib::Mocks::mock_preference('item-level_itypes', 0);
369
ModItem({ itype => undef }, $biblio->biblionumber, $itemnumber);
370
$item->itype(undef)->store;
370
ok(
371
ok(
371
    CanItemBeReserved( $borrowernumbers[0], $itemnumber)->{status} eq 'tooManyReserves',
372
    CanItemBeReserved( $borrowernumbers[0], $item->itemnumber)->{status} eq 'tooManyReserves',
372
    "cannot request item if policy that matches on bib-level item type forbids it (bug 9532)"
373
    "cannot request item if policy that matches on bib-level item type forbids it (bug 9532)"
373
);
374
);
374
375
(-)a/t/db_dependent/Items.t (-13 / +11 lines)
Lines 82-91 subtest 'General Add, Get and Del tests' => sub { Link Here
82
    # Do not modify anything, and do not explode!
82
    # Do not modify anything, and do not explode!
83
    my $dbh = C4::Context->dbh;
83
    my $dbh = C4::Context->dbh;
84
    local $dbh->{RaiseError} = 1;
84
    local $dbh->{RaiseError} = 1;
85
    ModItem({}, $biblio->biblionumber, $itemnumber);
85
    $getitem->set({})->store;
86
86
87
    # Modify item; setting barcode.
87
    # Modify item; setting barcode.
88
    ModItem({ barcode => '987654321' }, $biblio->biblionumber, $itemnumber);
88
    $getitem->barcode('987654321')->store;
89
    my $moditem = Koha::Items->find($itemnumber);
89
    my $moditem = Koha::Items->find($itemnumber);
90
    cmp_ok($moditem->barcode, '==', '987654321', 'Modified item barcode successfully to: '.$moditem->barcode . '.');
90
    cmp_ok($moditem->barcode, '==', '987654321', 'Modified item barcode successfully to: '.$moditem->barcode . '.');
91
91
Lines 107-118 subtest 'General Add, Get and Del tests' => sub { Link Here
107
    is( $getitem->location, $location, "The location should not have been modified" );
107
    is( $getitem->location, $location, "The location should not have been modified" );
108
    is( $getitem->permanent_location, 'my permanent location', "The permanent_location should not have modified" );
108
    is( $getitem->permanent_location, 'my permanent location', "The permanent_location should not have modified" );
109
109
110
    ModItem({ location => $location }, $biblio->biblionumber, $itemnumber);
110
    $getitem->location($location)->store;
111
    $getitem = Koha::Items->find($itemnumber);
111
    $getitem = Koha::Items->find($itemnumber);
112
    is( $getitem->location, $location, "The location should have been set to correct location" );
112
    is( $getitem->location, $location, "The location should have been set to correct location" );
113
    is( $getitem->permanent_location, $location, "The permanent_location should have been set to location" );
113
    is( $getitem->permanent_location, $location, "The permanent_location should have been set to location" );
114
114
115
    ModItem({ location => 'CART' }, $biblio->biblionumber, $itemnumber);
115
    $getitem->location('CART')->store;
116
    $getitem = Koha::Items->find($itemnumber);
116
    $getitem = Koha::Items->find($itemnumber);
117
    is( $getitem->location, 'CART', "The location should have been set to CART" );
117
    is( $getitem->location, 'CART', "The location should have been set to CART" );
118
    is( $getitem->permanent_location, $location, "The permanent_location should not have been set to CART" );
118
    is( $getitem->permanent_location, $location, "The permanent_location should not have been set to CART" );
Lines 139-151 subtest 'ModItem tests' => sub { Link Here
139
    for my $field (@fields) {
139
    for my $field (@fields) {
140
        my $field_on = $field."_on";
140
        my $field_on = $field."_on";
141
141
142
        $item->$field(1);
142
        $item->$field(1)->store;
143
        ModItem( $item->unblessed, $item->biblionumber, $item->itemnumber );
144
        $item->discard_changes;
143
        $item->discard_changes;
145
        is( output_pref({ str => $item->$field_on, dateonly => 1 }), output_pref({ dt => dt_from_string(), dateonly => 1 }), "When updating $field, $field_on is updated" );
144
        is( output_pref({ str => $item->$field_on, dateonly => 1 }), output_pref({ dt => dt_from_string(), dateonly => 1 }), "When updating $field, $field_on is updated" );
146
145
147
        $item->$field(0);
146
        $item->$field(0)->store;
148
        ModItem( $item->unblessed, $item->biblionumber, $item->itemnumber );
149
        $item->discard_changes;
147
        $item->discard_changes;
150
        is( $item->$field_on, undef, "When clearing $field, $field_on is cleared" );
148
        is( $item->$field_on, undef, "When clearing $field, $field_on is cleared" );
151
    }
149
    }
Lines 997-1024 subtest 'Test logging for ModItem' => sub { Link Here
997
    my $biblio = $builder->build_sample_biblio();
995
    my $biblio = $builder->build_sample_biblio();
998
996
999
    # Add an item.
997
    # Add an item.
1000
    my $itemnumber = $builder->build_sample_item(
998
    my $item = $builder->build_sample_item(
1001
        {
999
        {
1002
            biblionumber => $biblio->biblionumber,
1000
            biblionumber => $biblio->biblionumber,
1003
            library      => $library->{homebranch},
1001
            library      => $library->{homebranch},
1004
            location     => $location,
1002
            location     => $location,
1005
            itype        => $itemtype->{itemtype}
1003
            itype        => $itemtype->{itemtype}
1006
        }
1004
        }
1007
    )->itemnumber;
1005
    );
1008
1006
1009
    # False means no logging
1007
    # False means no logging
1010
    $schema->resultset('ActionLog')->search()->delete();
1008
    $schema->resultset('ActionLog')->search()->delete();
1011
    ModItem({ location => $location }, $biblio->biblionumber, $itemnumber, { log_action => 0 });
1009
    $item->location($location)->store({ log_action => 0 });
1012
    is( $schema->resultset('ActionLog')->count(), 0, 'False value does not trigger logging' );
1010
    is( $schema->resultset('ActionLog')->count(), 0, 'False value does not trigger logging' );
1013
1011
1014
    # True means logging
1012
    # True means logging
1015
    $schema->resultset('ActionLog')->search()->delete();
1013
    $schema->resultset('ActionLog')->search()->delete();
1016
    ModItem({ location => $location }, $biblio->biblionumber, $itemnumber, { log_action => 1 });
1014
    $item->location($location)->store({ log_action => 1 });
1017
    is( $schema->resultset('ActionLog')->count(), 1, 'True value does trigger logging' );
1015
    is( $schema->resultset('ActionLog')->count(), 1, 'True value does trigger logging' );
1018
1016
1019
    # Undefined defaults to true
1017
    # Undefined defaults to true
1020
    $schema->resultset('ActionLog')->search()->delete();
1018
    $schema->resultset('ActionLog')->search()->delete();
1021
    ModItem({ location => $location }, $biblio->biblionumber, $itemnumber);
1019
    $item->location($location)->store();
1022
    is( $schema->resultset('ActionLog')->count(), 1, 'Undefined value defaults to true, triggers logging' );
1020
    is( $schema->resultset('ActionLog')->count(), 1, 'Undefined value defaults to true, triggers logging' );
1023
1021
1024
    $schema->storage->txn_rollback;
1022
    $schema->storage->txn_rollback;
(-)a/t/db_dependent/Items/AutomaticItemModificationByAge.t (-1 / +1 lines)
Lines 124-130 is( $marc_item->subfield($tagfield, $new_tagfield), 'updated_value', q|ToggleNew Link Here
124
my $dt_today = dt_from_string;
124
my $dt_today = dt_from_string;
125
my $days5ago = $dt_today->add_duration( DateTime::Duration->new( days => -5 ) );
125
my $days5ago = $dt_today->add_duration( DateTime::Duration->new( days => -5 ) );
126
126
127
C4::Items::ModItem( { dateaccessioned => $days5ago }, $biblionumber, $itemnumber );
127
$modified_item->dateaccessioned($days5ago)->store;
128
128
129
@rules = (
129
@rules = (
130
    {
130
    {
(-)a/t/db_dependent/Items_DelItemCheck.t (-15 / +15 lines)
Lines 80-88 my $biblio = $builder->build( Link Here
80
    }
80
    }
81
);
81
);
82
82
83
my $item = $builder->build(
83
my $item = $builder->build_object(
84
    {
84
    {
85
        source => 'Item',
85
        class => 'Koha::Items',
86
        value  => {
86
        value  => {
87
            biblionumber  => $biblio->{biblionumber},
87
            biblionumber  => $biblio->{biblionumber},
88
            homebranch    => $branch->{branchcode},
88
            homebranch    => $branch->{branchcode},
Lines 95-135 my $item = $builder->build( Link Here
95
95
96
# book_on_loan
96
# book_on_loan
97
97
98
AddIssue( $patron, $item->{barcode} );
98
AddIssue( $patron, $item->barcode );
99
99
100
is(
100
is(
101
    ItemSafeToDelete( $biblio->{biblionumber}, $item->{itemnumber} ),
101
    ItemSafeToDelete( $biblio->{biblionumber}, $item->itemnumber ),
102
    'book_on_loan',
102
    'book_on_loan',
103
    'ItemSafeToDelete reports item on loan',
103
    'ItemSafeToDelete reports item on loan',
104
);
104
);
105
105
106
is(
106
is(
107
    DelItemCheck( $biblio->{biblionumber}, $item->{itemnumber} ),
107
    DelItemCheck( $biblio->{biblionumber}, $item->itemnumber ),
108
    'book_on_loan',
108
    'book_on_loan',
109
    'item that is on loan cannot be deleted',
109
    'item that is on loan cannot be deleted',
110
);
110
);
111
111
112
AddReturn( $item->{barcode}, $branch->{branchcode} );
112
AddReturn( $item->barcode, $branch->{branchcode} );
113
113
114
# book_reserved is tested in t/db_dependent/Reserves.t
114
# book_reserved is tested in t/db_dependent/Reserves.t
115
115
116
# not_same_branch
116
# not_same_branch
117
t::lib::Mocks::mock_preference('IndependentBranches', 1);
117
t::lib::Mocks::mock_preference('IndependentBranches', 1);
118
ModItem( { homebranch => $branch2->{branchcode}, holdingbranch => $branch2->{branchcode} }, $biblio->{biblionumber}, $item->{itemnumber} );
118
$item->set( { homebranch => $branch2->{branchcode}, holdingbranch => $branch2->{branchcode} })->store;
119
119
120
is(
120
is(
121
    ItemSafeToDelete( $biblio->{biblionumber}, $item->{itemnumber} ),
121
    ItemSafeToDelete( $biblio->{biblionumber}, $item->itemnumber ),
122
    'not_same_branch',
122
    'not_same_branch',
123
    'ItemSafeToDelete reports IndependentBranches restriction',
123
    'ItemSafeToDelete reports IndependentBranches restriction',
124
);
124
);
125
125
126
is(
126
is(
127
    DelItemCheck( $biblio->{biblionumber}, $item->{itemnumber} ),
127
    DelItemCheck( $biblio->{biblionumber}, $item->itemnumber ),
128
    'not_same_branch',
128
    'not_same_branch',
129
    'IndependentBranches prevents deletion at another branch',
129
    'IndependentBranches prevents deletion at another branch',
130
);
130
);
131
131
132
ModItem( { homebranch => $branch->{branchcode}, holdingbranch => $branch->{branchcode} }, $biblio->{biblionumber}, $item->{itemnumber} );
132
$item->set( { homebranch => $branch->{branchcode}, holdingbranch => $branch->{branchcode} })->store;
133
133
134
# linked_analytics
134
# linked_analytics
135
135
Lines 139-151 ModItem( { homebranch => $branch->{branchcode}, holdingbranch => $branch->{branc Link Here
139
    $module->mock( GetAnalyticsCount => sub { return 1 } );
139
    $module->mock( GetAnalyticsCount => sub { return 1 } );
140
140
141
    is(
141
    is(
142
        ItemSafeToDelete( $biblio->{biblionumber}, $item->{itemnumber} ),
142
        ItemSafeToDelete( $biblio->{biblionumber}, $item->itemnumber ),
143
        'linked_analytics',
143
        'linked_analytics',
144
        'ItemSafeToDelete reports linked analytics',
144
        'ItemSafeToDelete reports linked analytics',
145
    );
145
    );
146
146
147
    is(
147
    is(
148
        DelItemCheck( $biblio->{biblionumber}, $item->{itemnumber} ),
148
        DelItemCheck( $biblio->{biblionumber}, $item->itemnumber ),
149
        'linked_analytics',
149
        'linked_analytics',
150
        'Linked analytics prevents deletion of item',
150
        'Linked analytics prevents deletion of item',
151
    );
151
    );
Lines 153-166 ModItem( { homebranch => $branch->{branchcode}, holdingbranch => $branch->{branc Link Here
153
}
153
}
154
154
155
is(
155
is(
156
    ItemSafeToDelete( $biblio->{biblionumber}, $item->{itemnumber} ),
156
    ItemSafeToDelete( $biblio->{biblionumber}, $item->itemnumber ),
157
    1,
157
    1,
158
    'ItemSafeToDelete shows item safe to delete'
158
    'ItemSafeToDelete shows item safe to delete'
159
);
159
);
160
160
161
DelItemCheck( $biblio->{biblionumber}, $item->{itemnumber} );
161
DelItemCheck( $biblio->{biblionumber}, $item->itemnumber );
162
162
163
my $test_item = Koha::Items->find( $item->{itemnumber} );
163
my $test_item = Koha::Items->find( $item->itemnumber );
164
164
165
is( $test_item, undef,
165
is( $test_item, undef,
166
    "DelItemCheck should delete item if ItemSafeToDelete returns true"
166
    "DelItemCheck should delete item if ItemSafeToDelete returns true"
(-)a/t/db_dependent/Labels/t_Label.t (-4 / +4 lines)
Lines 62-78 t::lib::Mocks::mock_userenv({ branchcode => $branch_1 }); Link Here
62
my $bibnum = $builder->build_sample_biblio({ frameworkcode => $frameworkcode })->biblionumber;
62
my $bibnum = $builder->build_sample_biblio({ frameworkcode => $frameworkcode })->biblionumber;
63
63
64
# Create a helper item instance for testing
64
# Create a helper item instance for testing
65
my $itemnumber = $builder->build_sample_item(
65
my $item = $builder->build_sample_item(
66
    {
66
    {
67
        biblionumber => $bibnum,
67
        biblionumber => $bibnum,
68
        library      => $branch_1,
68
        library      => $branch_1,
69
        itype        => $itemtype,
69
        itype        => $itemtype,
70
    }
70
    }
71
)->itemnumber;
71
);
72
72
73
# Modify item; setting barcode.
73
# Modify item; setting barcode.
74
my $testbarcode = '97531';
74
my $testbarcode = '97531';
75
ModItem( { barcode => $testbarcode }, $bibnum, $itemnumber );
75
$item->barcode($testbarcode)->store;
76
76
77
my $layout = C4::Labels::Layout->new( layout_name => 'TEST' );
77
my $layout = C4::Labels::Layout->new( layout_name => 'TEST' );
78
78
Lines 99-105 my $dummy_template_values = { Link Here
99
99
100
my $label = C4::Labels::Label->new(
100
my $label = C4::Labels::Label->new(
101
    batch_id         => $batch_id,
101
    batch_id         => $batch_id,
102
    item_number      => $itemnumber,
102
    item_number      => $item->itemnumber,
103
    llx              => $llx,
103
    llx              => $llx,
104
    lly              => $lly,
104
    lly              => $lly,
105
    width            => $dummy_template_values->{'label_width'},
105
    width            => $dummy_template_values->{'label_width'},
(-)a/t/db_dependent/Reserves.t (-2 / +2 lines)
Lines 85-91 t::lib::Mocks::mock_userenv({ branchcode => $branch_1 }); Link Here
85
my $bibnum = $builder->build_sample_biblio({frameworkcode => $frameworkcode})->biblionumber;
85
my $bibnum = $builder->build_sample_biblio({frameworkcode => $frameworkcode})->biblionumber;
86
86
87
# Create a helper item instance for testing
87
# Create a helper item instance for testing
88
my $itemnumber = $builder->build_sample_item({ biblionumber => $bibnum, library => $branch_1, itype => $itemtype })->itemnumber;
88
my $item = $builder->build_sample_item({ biblionumber => $bibnum, library => $branch_1, itype => $itemtype });
89
89
90
my $biblio_with_no_item = $builder->build({
90
my $biblio_with_no_item = $builder->build({
91
    source => 'Biblio'
91
    source => 'Biblio'
Lines 94-100 my $biblio_with_no_item = $builder->build({ Link Here
94
94
95
# Modify item; setting barcode.
95
# Modify item; setting barcode.
96
my $testbarcode = '97531';
96
my $testbarcode = '97531';
97
ModItem({ barcode => $testbarcode }, $bibnum, $itemnumber);
97
$item->barcode($testbarcode)->store; # FIXME We should not hardcode a barcode! Also, what's the purpose of this?
98
98
99
# Create a borrower
99
# Create a borrower
100
my %data = (
100
my %data = (
(-)a/tools/inventory.pl (-7 / +6 lines)
Lines 199-219 if ( $uploadbarcodes && length($uploadbarcodes) > 0 ) { Link Here
199
        } else {
199
        } else {
200
            my $item = Koha::Items->find({barcode => $barcode});
200
            my $item = Koha::Items->find({barcode => $barcode});
201
            if ( $item ) {
201
            if ( $item ) {
202
                $item = $item->unblessed;
202
                my $item_unblessed = $item->unblessed;
203
                # Modify date last seen for scanned items, remove lost status
203
                # Modify date last seen for scanned items, remove lost status
204
                ModItem( { itemlost => 0, datelastseen => $date }, undef, $item->{'itemnumber'} );
204
                $item->set({ itemlost => 0, datelastseen => $date })->store;
205
                $moddatecount++;
205
                $moddatecount++;
206
                # update item hash accordingly
206
                # update item hash accordingly
207
                $item->{itemlost} = 0;
207
                $item_unblessed->{itemlost} = 0;
208
                $item->{datelastseen} = $date;
208
                $item_unblessed->{datelastseen} = $date;
209
                unless ( $dont_checkin ) {
209
                unless ( $dont_checkin ) {
210
                    $qonloan->execute($barcode);
210
                    $qonloan->execute($barcode);
211
                    if ($qonloan->rows){
211
                    if ($qonloan->rows){
212
                        my $data = $qonloan->fetchrow_hashref;
212
                        my $data = $qonloan->fetchrow_hashref;
213
                        my ($doreturn, $messages, $iteminformation, $borrower) =AddReturn($barcode, $data->{homebranch});
213
                        my ($doreturn, $messages, $iteminformation, $borrower) =AddReturn($barcode, $data->{homebranch});
214
                        if( $doreturn ) {
214
                        if( $doreturn ) {
215
                            $item->{onloan} = undef;
215
                            $item_unblessed->{onloan} = undef;
216
                            $item->{datelastseen} = dt_from_string;
216
                            $item_unblessed->{datelastseen} = dt_from_string;
217
                        } else {
217
                        } else {
218
                            push @errorloop, { barcode => $barcode, ERR_ONLOAN_NOT_RET => 1 };
218
                            push @errorloop, { barcode => $barcode, ERR_ONLOAN_NOT_RET => 1 };
219
                        }
219
                        }
220
- 

Return to bug 23463