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

(-)a/C4/Circulation.pm (-33 / +28 lines)
Lines 1457-1474 sub AddIssue { Link Here
1457
                }
1457
                }
1458
            }
1458
            }
1459
1459
1460
            ModItem(
1460
            $item_object->issues(($item_object->issues || 0) + 1);
1461
                {
1461
            $item_object->holdingbranch(C4::Context->userenv->{'branch'});
1462
                    issues        => ( $item_object->issues || 0 ) + 1,
1462
            $item_object->itemlost(0);
1463
                    holdingbranch => C4::Context->userenv->{'branch'},
1463
            $item_object->onloan($datedue->ymd());
1464
                    itemlost      => 0,
1464
            $item_object->datelastborrowed(DateTime->now( time_zone => C4::Context->tz() )->ymd()); # FIXME we should use dt_from_string here
1465
                    onloan        => $datedue->ymd(),
1465
            $item_object->store({log_action => 0});
1466
                    datelastborrowed => DateTime->now( time_zone => C4::Context->tz() )->ymd(),
1467
                },
1468
                $item_object->biblionumber,
1469
                $item_object->itemnumber,
1470
                { log_action => 0 }
1471
            );
1472
            ModDateLastSeen( $item_object->itemnumber );
1466
            ModDateLastSeen( $item_object->itemnumber );
1473
1467
1474
            # If it costs to borrow this book, charge it to the patron's account.
1468
            # If it costs to borrow this book, charge it to the patron's account.
Lines 1866-1872 sub AddReturn { Link Here
1866
                . Dumper($issue->unblessed) . "\n";
1860
                . Dumper($issue->unblessed) . "\n";
1867
    } else {
1861
    } else {
1868
        $messages->{'NotIssued'} = $barcode;
1862
        $messages->{'NotIssued'} = $barcode;
1869
        ModItem({ onloan => undef }, $item->biblionumber, $item->itemnumber) if defined $item->onloan;
1863
        $item->onloan(undef)->store if defined $item->onloan;
1864
1870
        # even though item is not on loan, it may still be transferred;  therefore, get current branch info
1865
        # even though item is not on loan, it may still be transferred;  therefore, get current branch info
1871
        $doreturn = 0;
1866
        $doreturn = 0;
1872
        # No issue, no borrowernumber.  ONLY if $doreturn, *might* you have a $borrower later.
1867
        # No issue, no borrowernumber.  ONLY if $doreturn, *might* you have a $borrower later.
Lines 1877-1883 sub AddReturn { Link Here
1877
        }
1872
        }
1878
    }
1873
    }
1879
1874
1880
    my $item_unblessed = $item->unblessed;
1881
        # full item data, but no borrowernumber or checkout info (no issue)
1875
        # full item data, but no borrowernumber or checkout info (no issue)
1882
    my $hbr = GetBranchItemRule($item->homebranch, $itemtype)->{'returnbranch'} || "homebranch";
1876
    my $hbr = GetBranchItemRule($item->homebranch, $itemtype)->{'returnbranch'} || "homebranch";
1883
        # get the proper branch to which to return the item
1877
        # get the proper branch to which to return the item
Lines 1895-1901 sub AddReturn { Link Here
1895
            if ($update_loc_rules->{_ALL_} eq '_BLANK_') { $update_loc_rules->{_ALL_} = ''; }
1889
            if ($update_loc_rules->{_ALL_} eq '_BLANK_') { $update_loc_rules->{_ALL_} = ''; }
1896
            if ( $item->location ne $update_loc_rules->{_ALL_}) {
1890
            if ( $item->location ne $update_loc_rules->{_ALL_}) {
1897
                $messages->{'ItemLocationUpdated'} = { from => $item->location, to => $update_loc_rules->{_ALL_} };
1891
                $messages->{'ItemLocationUpdated'} = { from => $item->location, to => $update_loc_rules->{_ALL_} };
1898
                ModItem( { location => $update_loc_rules->{_ALL_} }, undef, $itemnumber );
1892
                $item->location($update_loc_rules->{_ALL_})->store;
1899
            }
1893
            }
1900
        }
1894
        }
1901
        else {
1895
        else {
Lines 1904-1910 sub AddReturn { Link Here
1904
                if ( $update_loc_rules->{$key} eq '_BLANK_') { $update_loc_rules->{$key} = '' ;}
1898
                if ( $update_loc_rules->{$key} eq '_BLANK_') { $update_loc_rules->{$key} = '' ;}
1905
                if ( ($item->location eq $key && $item->location ne $update_loc_rules->{$key}) || ($key eq '_BLANK_' && $item->location eq '' && $update_loc_rules->{$key} ne '') ) {
1899
                if ( ($item->location eq $key && $item->location ne $update_loc_rules->{$key}) || ($key eq '_BLANK_' && $item->location eq '' && $update_loc_rules->{$key} ne '') ) {
1906
                    $messages->{'ItemLocationUpdated'} = { from => $item->location, to => $update_loc_rules->{$key} };
1900
                    $messages->{'ItemLocationUpdated'} = { from => $item->location, to => $update_loc_rules->{$key} };
1907
                    ModItem( { location => $update_loc_rules->{$key} }, undef, $itemnumber );
1901
                    $item->location($update_loc_rules->{$key})->store;
1908
                    last;
1902
                    last;
1909
                }
1903
                }
1910
            }
1904
            }
Lines 1923-1929 sub AddReturn { Link Here
1923
            foreach my $key ( keys %$rules ) {
1917
            foreach my $key ( keys %$rules ) {
1924
                if ( $item->notforloan eq $key ) {
1918
                if ( $item->notforloan eq $key ) {
1925
                    $messages->{'NotForLoanStatusUpdated'} = { from => $item->notforloan, to => $rules->{$key} };
1919
                    $messages->{'NotForLoanStatusUpdated'} = { from => $item->notforloan, to => $rules->{$key} };
1926
                    ModItem( { notforloan => $rules->{$key} }, undef, $itemnumber, { log_action => 0 } );
1920
                    $item->notforloan($rules->{$key})->store({ log_action => 0 });
1927
                    last;
1921
                    last;
1928
                }
1922
                }
1929
            }
1923
            }
Lines 1931-1937 sub AddReturn { Link Here
1931
    }
1925
    }
1932
1926
1933
    # check if the return is allowed at this branch
1927
    # check if the return is allowed at this branch
1934
    my ($returnallowed, $message) = CanBookBeReturned($item_unblessed, $branch);
1928
    my ($returnallowed, $message) = CanBookBeReturned($item->unblessed, $branch);
1935
    unless ($returnallowed){
1929
    unless ($returnallowed){
1936
        $messages->{'Wrongbranch'} = {
1930
        $messages->{'Wrongbranch'} = {
1937
            Wrongbranch => $branch,
1931
            Wrongbranch => $branch,
Lines 1961-1967 sub AddReturn { Link Here
1961
            };
1955
            };
1962
            unless ( $@ ) {
1956
            unless ( $@ ) {
1963
                if ( C4::Context->preference('CalculateFinesOnReturn') && !$item->itemlost ) {
1957
                if ( C4::Context->preference('CalculateFinesOnReturn') && !$item->itemlost ) {
1964
                    _CalculateAndUpdateFine( { issue => $issue, item => $item_unblessed, borrower => $patron_unblessed, return_date => $return_date } );
1958
                    _CalculateAndUpdateFine( { issue => $issue, item => $item->unblessed, borrower => $patron_unblessed, return_date => $return_date } );
1965
                }
1959
                }
1966
            } else {
1960
            } else {
1967
                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 );
1961
                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 1974-1980 sub AddReturn { Link Here
1974
1968
1975
        }
1969
        }
1976
1970
1977
        ModItem( { onloan => undef }, $item->biblionumber, $item->itemnumber, { log_action => 0 } );
1971
        $item->onloan(undef)->store({ log_action => 0 });
1978
    }
1972
    }
1979
1973
1980
    # the holdingbranch is updated if the document is returned to another location.
1974
    # the holdingbranch is updated if the document is returned to another location.
Lines 1982-1988 sub AddReturn { Link Here
1982
    my $item_holding_branch = $item->holdingbranch;
1976
    my $item_holding_branch = $item->holdingbranch;
1983
    if ($item->holdingbranch ne $branch) {
1977
    if ($item->holdingbranch ne $branch) {
1984
        UpdateHoldingbranch($branch, $item->itemnumber);
1978
        UpdateHoldingbranch($branch, $item->itemnumber);
1985
        $item_unblessed->{'holdingbranch'} = $branch; # update item data holdingbranch too # FIXME I guess this is for the _debar_user_on_return call later
1979
        $item->holdingbranch($branch); # update item data holdingbranch too # FIXME I guess this is for the _debar_user_on_return call later
1986
    }
1980
    }
1987
1981
1988
    my $leave_item_lost = C4::Context->preference("BlockReturnOfLostItems") ? 1 : 0;
1982
    my $leave_item_lost = C4::Context->preference("BlockReturnOfLostItems") ? 1 : 0;
Lines 2036-2042 sub AddReturn { Link Here
2036
2030
2037
        if ( $issue and $issue->is_overdue ) {
2031
        if ( $issue and $issue->is_overdue ) {
2038
        # fix fine days
2032
        # fix fine days
2039
            my ($debardate,$reminder) = _debar_user_on_return( $patron_unblessed, $item_unblessed, dt_from_string($issue->date_due), $return_date );
2033
            my ($debardate,$reminder) = _debar_user_on_return( $patron_unblessed, $item->unblessed, dt_from_string($issue->date_due), $return_date );
2040
            if ($reminder){
2034
            if ($reminder){
2041
                $messages->{'PrevDebarred'} = $debardate;
2035
                $messages->{'PrevDebarred'} = $debardate;
2042
            } else {
2036
            } else {
Lines 2089-2095 sub AddReturn { Link Here
2089
        if ($doreturn && $circulation_alert->is_enabled_for(\%conditions)) {
2083
        if ($doreturn && $circulation_alert->is_enabled_for(\%conditions)) {
2090
            SendCirculationAlert({
2084
            SendCirculationAlert({
2091
                type     => 'CHECKIN',
2085
                type     => 'CHECKIN',
2092
                item     => $item_unblessed,
2086
                item     => $item->unblessed,
2093
                borrower => $patron->unblessed,
2087
                borrower => $patron->unblessed,
2094
                branch   => $branch,
2088
                branch   => $branch,
2095
            });
2089
            });
Lines 2117-2123 sub AddReturn { Link Here
2117
             ! IsBranchTransferAllowed($branch, $returnbranch, $item->$BranchTransferLimitsType )
2111
             ! IsBranchTransferAllowed($branch, $returnbranch, $item->$BranchTransferLimitsType )
2118
           )) {
2112
           )) {
2119
            $debug and warn sprintf "about to call ModItemTransfer(%s, %s, %s)", $item->itemnumber,$branch, $returnbranch;
2113
            $debug and warn sprintf "about to call ModItemTransfer(%s, %s, %s)", $item->itemnumber,$branch, $returnbranch;
2120
            $debug and warn "item: " . Dumper($item_unblessed);
2114
            $debug and warn "item: " . Dumper($item->unblessed);
2121
            ModItemTransfer($item->itemnumber, $branch, $returnbranch);
2115
            ModItemTransfer($item->itemnumber, $branch, $returnbranch);
2122
            $messages->{'WasTransfered'} = 1;
2116
            $messages->{'WasTransfered'} = 1;
2123
        } else {
2117
        } else {
Lines 2206-2212 sub MarkIssueReturned { Link Here
2206
        # And finally delete the issue
2200
        # And finally delete the issue
2207
        $issue->delete;
2201
        $issue->delete;
2208
2202
2209
        ModItem( { 'onloan' => undef }, undef, $itemnumber, { log_action => 0 } );
2203
        $issue->item->onloan(undef)->store({ log_action => 0 });
2210
2204
2211
        if ( C4::Context->preference('StoreLastBorrower') ) {
2205
        if ( C4::Context->preference('StoreLastBorrower') ) {
2212
            my $item = Koha::Items->find( $itemnumber );
2206
            my $item = Koha::Items->find( $itemnumber );
Lines 2499-2504 sub _FixAccountForLostAndReturned { Link Here
2499
    $accountline->discard_changes->status('RETURNED');
2493
    $accountline->discard_changes->status('RETURNED');
2500
    $accountline->store;
2494
    $accountline->store;
2501
2495
2496
    $accountline->item->paidfor('')->store({ log_action => 0 });
2497
2502
    if ( defined $account and C4::Context->preference('AccountAutoReconcile') ) {
2498
    if ( defined $account and C4::Context->preference('AccountAutoReconcile') ) {
2503
        $account->reconcile_balance;
2499
        $account->reconcile_balance;
2504
    }
2500
    }
Lines 2941-2947 sub AddRenewal { Link Here
2941
2937
2942
        # Update the renewal count on the item, and tell zebra to reindex
2938
        # Update the renewal count on the item, and tell zebra to reindex
2943
        $renews = ( $item_object->renewals || 0 ) + 1;
2939
        $renews = ( $item_object->renewals || 0 ) + 1;
2944
        ModItem( { renewals => $renews, onloan => $datedue->strftime('%Y-%m-%d %H:%M')}, $item_object->biblionumber, $itemnumber, { log_action => 0 } );
2940
        $item_object->renewals($renews);
2941
        $item_object->onloan($datedue);
2942
        $item_object->store({ log_action => 0 });
2945
2943
2946
        # Charge a new rental fee, if applicable
2944
        # Charge a new rental fee, if applicable
2947
        my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber );
2945
        my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber );
Lines 3755-3761 sub LostItem{ Link Here
3755
3753
3756
    #When item is marked lost automatically cancel its outstanding transfers and set items holdingbranch to the transfer source branch (frombranch)
3754
    #When item is marked lost automatically cancel its outstanding transfers and set items holdingbranch to the transfer source branch (frombranch)
3757
    if (my ( $datesent,$frombranch,$tobranch ) = GetTransfers($itemnumber)) {
3755
    if (my ( $datesent,$frombranch,$tobranch ) = GetTransfers($itemnumber)) {
3758
        ModItem({holdingbranch => $frombranch}, undef, $itemnumber);
3756
        Koha::Items->find($itemnumber)->holdingbranch($frombranch)->store;
3759
    }
3757
    }
3760
    my $transferdeleted = DeleteTransfer($itemnumber);
3758
    my $transferdeleted = DeleteTransfer($itemnumber);
3761
}
3759
}
Lines 3823-3834 sub ProcessOfflineReturn { Link Here
3823
                $itemnumber,
3821
                $itemnumber,
3824
                $operation->{timestamp},
3822
                $operation->{timestamp},
3825
            );
3823
            );
3826
            ModItem(
3824
            $item->renewals(0);
3827
                { renewals => 0, onloan => undef },
3825
            $item->onloan(undef);
3828
                $issue->{'biblionumber'},
3826
            $item->store({ log_action => 0 });
3829
                $itemnumber,
3830
                { log_action => 0 }
3831
            );
3832
            return "Success.";
3827
            return "Success.";
3833
        } else {
3828
        } else {
3834
            return "Item not issued.";
3829
            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 499-505 sub ModItemTransfer { Link Here
499
        VALUES (?, ?, NOW(), ?)");
501
        VALUES (?, ?, NOW(), ?)");
500
    $sth->execute($itemnumber, $frombranch, $tobranch);
502
    $sth->execute($itemnumber, $frombranch, $tobranch);
501
503
502
    ModItem({ holdingbranch => $frombranch }, undef, $itemnumber, { log_action => 0 });
504
    # FIXME we are fetching the item twice in the 2 next statements!
505
    Koha::Items->find($itemnumber)->holdingbranch($frombranch)->store({ log_action => 0 });
503
    ModDateLastSeen($itemnumber);
506
    ModDateLastSeen($itemnumber);
504
    return;
507
    return;
505
}
508
}
Lines 519-529 sub ModDateLastSeen { Link Here
519
522
520
    my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
523
    my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
521
524
522
    my $params;
525
    my $item = Koha::Items->find($itemnumber);
523
    $params->{datelastseen} = $today;
526
    $item->datelastseen($today);
524
    $params->{itemlost} = 0 unless $leave_item_lost;
527
    $item->itemlost(0) unless $leave_item_lost;
525
528
    $item->store({ log_action => 0 });
526
    ModItem( $params, undef, $itemnumber, { log_action => 0 } );
527
}
529
}
528
530
529
=head2 DelItem
531
=head2 DelItem
Lines 2505-2517 sub ToggleNewStatus { Link Here
2505
        while ( my $values = $sth->fetchrow_hashref ) {
2507
        while ( my $values = $sth->fetchrow_hashref ) {
2506
            my $biblionumber = $values->{biblionumber};
2508
            my $biblionumber = $values->{biblionumber};
2507
            my $itemnumber = $values->{itemnumber};
2509
            my $itemnumber = $values->{itemnumber};
2510
            my $item = Koha::Items->find($itemnumber);
2508
            for my $substitution ( @$substitutions ) {
2511
            for my $substitution ( @$substitutions ) {
2512
                my $field = $substitution->{item_field};
2513
                my $value = $substitution->{value};
2509
                next unless $substitution->{field};
2514
                next unless $substitution->{field};
2510
                next if ( defined $values->{ $substitution->{item_field} } and $values->{ $substitution->{item_field} } eq $substitution->{value} );
2515
                next if ( defined $values->{ $substitution->{item_field} } and $values->{ $substitution->{item_field} } eq $substitution->{value} );
2511
                C4::Items::ModItem( { $substitution->{item_field} => $substitution->{value} }, $biblionumber, $itemnumber )
2516
                $item->$field($value);
2512
                    unless $report_only;
2513
                push @{ $report->{$itemnumber} }, $substitution;
2517
                push @{ $report->{$itemnumber} }, $substitution;
2514
            }
2518
            }
2519
            $item->store unless $report_only;
2515
        }
2520
        }
2516
    }
2521
    }
2517
2522
(-)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($dateaccessioned);
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 / +7 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;
19
}
30
}
20
}
(-)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 466-475 subtest "CanBookBeRenewed tests" => sub { Link Here
466
    is( $renewokay, 1, 'Can renew item 2, item-level hold is on item 1');
466
    is( $renewokay, 1, 'Can renew item 2, item-level hold is on item 1');
467
467
468
    # Items can't fill hold for reasons
468
    # Items can't fill hold for reasons
469
    ModItem({ notforloan => 1 }, $biblio->biblionumber, $item_1->itemnumber);
469
    $item_1->notforloan(1)->store;
470
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber, 1);
470
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber, 1);
471
    is( $renewokay, 1, 'Can renew, item is marked not for loan, hold does not block');
471
    is( $renewokay, 1, 'Can renew, item is marked not for loan, hold does not block');
472
    ModItem({ notforloan => 0, itype => $itemtype }, $biblio->biblionumber, $item_1->itemnumber);
472
    $item_1->set({notforloan => 0, itype => $itemtype })->store;
473
473
474
    # FIXME: Add more for itemtype not for loan etc.
474
    # FIXME: Add more for itemtype not for loan etc.
475
475
Lines 1235-1241 subtest "AllowRenewalIfOtherItemsAvailable tests" => sub { Link Here
1235
    is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled' );
1235
    is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled' );
1236
1236
1237
    # Setting item not checked out to be not for loan but holdable
1237
    # Setting item not checked out to be not for loan but holdable
1238
    ModItem({ notforloan => -1 }, $biblio->biblionumber, $item_2->itemnumber);
1238
    $item_2->notforloan(-1)->store;
1239
1239
1240
    ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber );
1240
    ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber );
1241
    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' );
1241
    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 2139-2145 subtest '_FixAccountForLostAndReturned' => sub { Link Here
2139
        AddIssue( $patron->unblessed, $item->barcode );
2139
        AddIssue( $patron->unblessed, $item->barcode );
2140
2140
2141
        # Simulate item marked as lost
2141
        # Simulate item marked as lost
2142
        ModItem( { itemlost => 3 }, $biblio->biblionumber, $item->itemnumber );
2142
        $item->itemlost(3)->store;
2143
        LostItem( $item->itemnumber, 1 );
2143
        LostItem( $item->itemnumber, 1 );
2144
2144
2145
        my $processing_fee_lines = Koha::Account::Lines->search(
2145
        my $processing_fee_lines = Koha::Account::Lines->search(
Lines 2203-2209 subtest '_FixAccountForLostAndReturned' => sub { Link Here
2203
        AddIssue( $patron->unblessed, $item->barcode );
2203
        AddIssue( $patron->unblessed, $item->barcode );
2204
2204
2205
        # Simulate item marked as lost
2205
        # Simulate item marked as lost
2206
        ModItem( { itemlost => 1 }, $biblio->biblionumber, $item->itemnumber );
2206
        $item->itemlost(1)->store;
2207
        LostItem( $item->itemnumber, 1 );
2207
        LostItem( $item->itemnumber, 1 );
2208
2208
2209
        my $processing_fee_lines = Koha::Account::Lines->search(
2209
        my $processing_fee_lines = Koha::Account::Lines->search(
Lines 2273-2279 subtest '_FixAccountForLostAndReturned' => sub { Link Here
2273
        AddIssue( $patron->unblessed, $item->barcode );
2273
        AddIssue( $patron->unblessed, $item->barcode );
2274
2274
2275
        # Simulate item marked as lost
2275
        # Simulate item marked as lost
2276
        ModItem( { itemlost => 3 }, $biblio->biblionumber, $item->itemnumber );
2276
        $item->itemlost(3)->store;
2277
        LostItem( $item->itemnumber, 1 );
2277
        LostItem( $item->itemnumber, 1 );
2278
2278
2279
        my $processing_fee_lines = Koha::Account::Lines->search(
2279
        my $processing_fee_lines = Koha::Account::Lines->search(
Lines 2326-2332 subtest '_FixAccountForLostAndReturned' => sub { Link Here
2326
        AddIssue( $patron->unblessed, $item->barcode );
2326
        AddIssue( $patron->unblessed, $item->barcode );
2327
2327
2328
        # Simulate item marked as lost
2328
        # Simulate item marked as lost
2329
        ModItem( { itemlost => 1 }, $biblio->biblionumber, $item->itemnumber );
2329
        $item->itemlost(1)->store;
2330
        LostItem( $item->itemnumber, 1 );
2330
        LostItem( $item->itemnumber, 1 );
2331
2331
2332
        my $processing_fee_lines = Koha::Account::Lines->search(
2332
        my $processing_fee_lines = Koha::Account::Lines->search(
Lines 2426-2432 subtest '_FixAccountForLostAndReturned' => sub { Link Here
2426
                }
2426
                }
2427
            }
2427
            }
2428
        );
2428
        );
2429
        my $item_id = Koha::Item->new(
2429
        my $item = Koha::Item->new(
2430
            {
2430
            {
2431
                biblionumber     => $biblio->biblionumber,
2431
                biblionumber     => $biblio->biblionumber,
2432
                homebranch       => $library->branchcode,
2432
                homebranch       => $library->branchcode,
Lines 2435-2450 subtest '_FixAccountForLostAndReturned' => sub { Link Here
2435
                replacementprice => $replacement_amount,
2435
                replacementprice => $replacement_amount,
2436
                itype            => $item_type->itemtype
2436
                itype            => $item_type->itemtype
2437
            },
2437
            },
2438
        )->store->itemnumber;
2438
        )->store;
2439
2439
2440
        AddIssue( $patron->unblessed, $barcode );
2440
        AddIssue( $patron->unblessed, $barcode );
2441
2441
2442
        # Simulate item marked as lost
2442
        # Simulate item marked as lost
2443
        ModItem( { itemlost => 1 }, $biblio->biblionumber, $item_id );
2443
        $item->itemlost(1)->store;
2444
        LostItem( $item_id, 1 );
2444
        LostItem( $item->itemnumber, 1 );
2445
2445
2446
        my $lost_fee_lines = Koha::Account::Lines->search(
2446
        my $lost_fee_lines = Koha::Account::Lines->search(
2447
            { borrowernumber => $patron->id, itemnumber => $item_id, debit_type_code => 'LOST' } );
2447
            { borrowernumber => $patron->id, itemnumber => $item->itemnumber, debit_type_code => 'LOST' } );
2448
        is( $lost_fee_lines->count, 1, 'Only one lost item fee produced' );
2448
        is( $lost_fee_lines->count, 1, 'Only one lost item fee produced' );
2449
        my $lost_fee_line = $lost_fee_lines->next;
2449
        my $lost_fee_line = $lost_fee_lines->next;
2450
        is( $lost_fee_line->amount + 0, $replacement_amount, 'The right LOST amount is generated' );
2450
        is( $lost_fee_line->amount + 0, $replacement_amount, 'The right LOST amount is generated' );
Lines 2476-2482 subtest '_FixAccountForLostAndReturned' => sub { Link Here
2476
2476
2477
        t::lib::Mocks::mock_preference( 'AccountAutoReconcile', 1 );
2477
        t::lib::Mocks::mock_preference( 'AccountAutoReconcile', 1 );
2478
2478
2479
        my $credit_return_id = C4::Circulation::_FixAccountForLostAndReturned( $item_id, $patron->id );
2479
        my $credit_return_id = C4::Circulation::_FixAccountForLostAndReturned( $item->itemnumber, $patron->id );
2480
        my $credit_return = Koha::Account::Lines->find($credit_return_id);
2480
        my $credit_return = Koha::Account::Lines->find($credit_return_id);
2481
2481
2482
        is( $account->balance, $manual_debit_amount - $payment_amount, 'Balance is PROCESSING - payment (LOST_RETURN)' );
2482
        is( $account->balance, $manual_debit_amount - $payment_amount, 'Balance is PROCESSING - payment (LOST_RETURN)' );
(-)a/t/db_dependent/Circulation/Returns.t (-1 / +1 lines)
Lines 324-330 subtest 'BlockReturnOfLostItems' => sub { Link Here
324
    my $checkout = AddIssue( $patron->unblessed, $item->barcode );
324
    my $checkout = AddIssue( $patron->unblessed, $item->barcode );
325
325
326
    # Mark the item as lost
326
    # Mark the item as lost
327
    ModItem({itemlost => 1}, $biblio->biblionumber, $item->itemnumber);
327
    $item->itemlost(1)->store;
328
328
329
    t::lib::Mocks::mock_preference('BlockReturnOfLostItems', 1);
329
    t::lib::Mocks::mock_preference('BlockReturnOfLostItems', 1);
330
    my ( $doreturn, $messages, $issue ) = AddReturn($item->barcode);
330
    my ( $doreturn, $messages, $issue ) = AddReturn($item->barcode);
(-)a/t/db_dependent/Holds.t (-8 / +8 lines)
Lines 279-285 ok( Link Here
279
);
279
);
280
280
281
{
281
{
282
    my $item_bibnum;my $item_bibitemnum;
283
    # Regression test for bug 11336 # Test if ModReserve correctly recalculate the priorities
282
    # Regression test for bug 11336 # Test if ModReserve correctly recalculate the priorities
284
    $biblio = $builder->build_sample_biblio({ itemtype => 'DUMMY' });
283
    $biblio = $builder->build_sample_biblio({ itemtype => 'DUMMY' });
285
    $itemnumber = $builder->build_sample_item({ library => $branch_1, biblionumber => $biblio->biblionumber })->itemnumber;
284
    $itemnumber = $builder->build_sample_item({ library => $branch_1, biblionumber => $biblio->biblionumber })->itemnumber;
Lines 296-302 ok( Link Here
296
    is( $hold3->discard_changes->priority, 1, "After ModReserve, the 3rd reserve becomes the first on the waiting list" );
295
    is( $hold3->discard_changes->priority, 1, "After ModReserve, the 3rd reserve becomes the first on the waiting list" );
297
}
296
}
298
297
299
ModItem({ damaged => 1 }, $biblio->biblionumber, $itemnumber);
298
Koha::Items->find($itemnumber)->damaged(1)->store; # FIXME The $itemnumber is a bit confusing here
300
t::lib::Mocks::mock_preference( 'AllowHoldsOnDamagedItems', 1 );
299
t::lib::Mocks::mock_preference( 'AllowHoldsOnDamagedItems', 1 );
301
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber)->{status}, 'OK', "Patron can reserve damaged item with AllowHoldsOnDamagedItems enabled" );
300
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber)->{status}, 'OK', "Patron can reserve damaged item with AllowHoldsOnDamagedItems enabled" );
302
ok( defined( ( CheckReserves($itemnumber) )[1] ), "Hold can be trapped for damaged item with AllowHoldsOnDamagedItems enabled" );
301
ok( defined( ( CheckReserves($itemnumber) )[1] ), "Hold can be trapped for damaged item with AllowHoldsOnDamagedItems enabled" );
Lines 319-325 ok( !defined( ( CheckReserves($itemnumber) )[1] ), "Hold cannot be trapped for d Link Here
319
318
320
# Regression test for bug 9532
319
# Regression test for bug 9532
321
$biblio = $builder->build_sample_biblio({ itemtype => 'CANNOT' });
320
$biblio = $builder->build_sample_biblio({ itemtype => 'CANNOT' });
322
$itemnumber = $builder->build_sample_item({ library => $branch_1, itype => 'CANNOT', biblionumber => $biblio->biblionumber})->itemnumber;
321
$item = $builder->build_sample_item({ library => $branch_1, itype => 'CANNOT', biblionumber => $biblio->biblionumber});
323
AddReserve(
322
AddReserve(
324
    $branch_1,
323
    $branch_1,
325
    $borrowernumbers[0],
324
    $borrowernumbers[0],
Lines 328-346 AddReserve( Link Here
328
    1,
327
    1,
329
);
328
);
330
is(
329
is(
331
    CanItemBeReserved( $borrowernumbers[0], $itemnumber)->{status}, 'tooManyReserves',
330
    CanItemBeReserved( $borrowernumbers[0], $item->itemnumber)->{status}, 'tooManyReserves',
332
    "cannot request item if policy that matches on item-level item type forbids it"
331
    "cannot request item if policy that matches on item-level item type forbids it"
333
);
332
);
334
ModItem({ itype => 'CAN' }, $biblio->biblionumber, $itemnumber);
333
334
$item->itype('CAN')->store;
335
ok(
335
ok(
336
    CanItemBeReserved( $borrowernumbers[0], $itemnumber)->{status} eq 'OK',
336
    CanItemBeReserved( $borrowernumbers[0], $item->itemnumber)->{status} eq 'OK',
337
    "can request item if policy that matches on item type allows it"
337
    "can request item if policy that matches on item type allows it"
338
);
338
);
339
339
340
t::lib::Mocks::mock_preference('item-level_itypes', 0);
340
t::lib::Mocks::mock_preference('item-level_itypes', 0);
341
ModItem({ itype => undef }, $biblio->biblionumber, $itemnumber);
341
$item->itype(undef)->store;
342
ok(
342
ok(
343
    CanItemBeReserved( $borrowernumbers[0], $itemnumber)->{status} eq 'tooManyReserves',
343
    CanItemBeReserved( $borrowernumbers[0], $item->itemnumber)->{status} eq 'tooManyReserves',
344
    "cannot request item if policy that matches on bib-level item type forbids it (bug 9532)"
344
    "cannot request item if policy that matches on bib-level item type forbids it (bug 9532)"
345
);
345
);
346
346
(-)a/t/db_dependent/Items.t (-20 / +19 lines)
Lines 83-92 subtest 'General Add, Get and Del tests' => sub { Link Here
83
    # Do not modify anything, and do not explode!
83
    # Do not modify anything, and do not explode!
84
    my $dbh = C4::Context->dbh;
84
    my $dbh = C4::Context->dbh;
85
    local $dbh->{RaiseError} = 1;
85
    local $dbh->{RaiseError} = 1;
86
    ModItem({}, $biblio->biblionumber, $itemnumber);
86
    $getitem->set({})->store;
87
87
88
    # Modify item; setting barcode.
88
    # Modify item; setting barcode.
89
    ModItem({ barcode => '987654321' }, $biblio->biblionumber, $itemnumber);
89
    $getitem->barcode('987654321')->store;
90
    my $moditem = Koha::Items->find($itemnumber);
90
    my $moditem = Koha::Items->find($itemnumber);
91
    cmp_ok($moditem->barcode, '==', '987654321', 'Modified item barcode successfully to: '.$moditem->barcode . '.');
91
    cmp_ok($moditem->barcode, '==', '987654321', 'Modified item barcode successfully to: '.$moditem->barcode . '.');
92
92
Lines 108-119 subtest 'General Add, Get and Del tests' => sub { Link Here
108
    is( $getitem->location, $location, "The location should not have been modified" );
108
    is( $getitem->location, $location, "The location should not have been modified" );
109
    is( $getitem->permanent_location, 'my permanent location', "The permanent_location should not have modified" );
109
    is( $getitem->permanent_location, 'my permanent location', "The permanent_location should not have modified" );
110
110
111
    ModItem({ location => $location }, $biblio->biblionumber, $itemnumber);
111
    $getitem->location($location)->store;
112
    $getitem = Koha::Items->find($itemnumber);
112
    $getitem = Koha::Items->find($itemnumber);
113
    is( $getitem->location, $location, "The location should have been set to correct location" );
113
    is( $getitem->location, $location, "The location should have been set to correct location" );
114
    is( $getitem->permanent_location, $location, "The permanent_location should have been set to location" );
114
    is( $getitem->permanent_location, $location, "The permanent_location should have been set to location" );
115
115
116
    ModItem({ location => 'CART' }, $biblio->biblionumber, $itemnumber);
116
    $getitem->location('CART')->store;
117
    $getitem = Koha::Items->find($itemnumber);
117
    $getitem = Koha::Items->find($itemnumber);
118
    is( $getitem->location, 'CART', "The location should have been set to CART" );
118
    is( $getitem->location, 'CART', "The location should have been set to CART" );
119
    is( $getitem->permanent_location, $location, "The permanent_location should not have been set to CART" );
119
    is( $getitem->permanent_location, $location, "The permanent_location should not have been set to CART" );
Lines 134-141 subtest 'ModItem tests' => sub { Link Here
134
    $schema->storage->txn_begin;
134
    $schema->storage->txn_begin;
135
135
136
    my $builder = t::lib::TestBuilder->new;
136
    my $builder = t::lib::TestBuilder->new;
137
    my $item = $builder->build({
137
    my $item = $builder->build_object({
138
        source => 'Item',
138
        class  => 'Koha::Items',
139
        value  => {
139
        value  => {
140
            itemlost     => 0,
140
            itemlost     => 0,
141
            damaged      => 0,
141
            damaged      => 0,
Lines 148-162 subtest 'ModItem tests' => sub { Link Here
148
148
149
    my @fields = qw( itemlost withdrawn damaged );
149
    my @fields = qw( itemlost withdrawn damaged );
150
    for my $field (@fields) {
150
    for my $field (@fields) {
151
        $item->{$field} = 1;
151
        my $field_on = "${field}_on";
152
        ModItem( $item, $item->{biblionumber}, $item->{itemnumber} );
152
        $item->$field(1)->store;
153
        my $post_mod_item = Koha::Items->find({ itemnumber => $item->{itemnumber} })->unblessed;
153
        my $post_mod_item = $item->get_from_storage;
154
        is( output_pref({ str => $post_mod_item->{$field."_on"}, dateonly => 1 }), output_pref({ dt => dt_from_string(), dateonly => 1 }), "When updating $field, $field"."_on is updated" );
154
        is( output_pref({ str => $post_mod_item->$field_on, dateonly => 1 }), output_pref({ dt => dt_from_string(), dateonly => 1 }), "When updating $field, $field_on is updated" );
155
155
156
        $item->{$field} = 0;
156
        $item->$field(0)->store;
157
        ModItem( $item, $item->{biblionumber}, $item->{itemnumber} );
157
        $post_mod_item = $item->get_from_storage;
158
        $post_mod_item = Koha::Items->find({ itemnumber => $item->{itemnumber} })->unblessed;
158
        is( $post_mod_item->$field_on, undef, "When clearing $field, $field_on is cleared" );
159
        is( $post_mod_item->{$field."_on"}, undef, "When clearing $field, $field"."_on is cleared" );
160
    }
159
    }
161
160
162
    $schema->storage->txn_rollback;
161
    $schema->storage->txn_rollback;
Lines 957-984 subtest 'Test logging for ModItem' => sub { Link Here
957
    my $biblio = $builder->build_sample_biblio();
956
    my $biblio = $builder->build_sample_biblio();
958
957
959
    # Add an item.
958
    # Add an item.
960
    my $itemnumber = $builder->build_sample_item(
959
    my $item = $builder->build_sample_item(
961
        {
960
        {
962
            biblionumber => $biblio->biblionumber,
961
            biblionumber => $biblio->biblionumber,
963
            library      => $library->{homebranch},
962
            library      => $library->{homebranch},
964
            location     => $location,
963
            location     => $location,
965
            itype        => $itemtype->{itemtype}
964
            itype        => $itemtype->{itemtype}
966
        }
965
        }
967
    )->itemnumber;
966
    );
968
967
969
    # False means no logging
968
    # False means no logging
970
    $schema->resultset('ActionLog')->search()->delete();
969
    $schema->resultset('ActionLog')->search()->delete();
971
    ModItem({ location => $location }, $biblio->biblionumber, $itemnumber, { log_action => 0 });
970
    $item->location($location)->store({ log_action => 0 });
972
    is( $schema->resultset('ActionLog')->count(), 0, 'False value does not trigger logging' );
971
    is( $schema->resultset('ActionLog')->count(), 0, 'False value does not trigger logging' );
973
972
974
    # True means logging
973
    # True means logging
975
    $schema->resultset('ActionLog')->search()->delete();
974
    $schema->resultset('ActionLog')->search()->delete();
976
    ModItem({ location => $location }, $biblio->biblionumber, $itemnumber, { log_action => 1 });
975
    $item->location($location)->store({ log_action => 1 });
977
    is( $schema->resultset('ActionLog')->count(), 1, 'True value does trigger logging' );
976
    is( $schema->resultset('ActionLog')->count(), 1, 'True value does trigger logging' );
978
977
979
    # Undefined defaults to true
978
    # Undefined defaults to true
980
    $schema->resultset('ActionLog')->search()->delete();
979
    $schema->resultset('ActionLog')->search()->delete();
981
    ModItem({ location => $location }, $biblio->biblionumber, $itemnumber);
980
    $item->location($location)->store();
982
    is( $schema->resultset('ActionLog')->count(), 1, 'Undefined value defaults to true, triggers logging' );
981
    is( $schema->resultset('ActionLog')->count(), 1, 'Undefined value defaults to true, triggers logging' );
983
982
984
    $schema->storage->txn_rollback;
983
    $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/t/db_dependent/api/v1/holds.t (-1 / +1 lines)
Lines 504-507 subtest 'PUT /holds/{hold_id}/priority tests' => sub { Link Here
504
    is( $hold_3->discard_changes->priority, 3, 'Priority adjusted correctly' );
504
    is( $hold_3->discard_changes->priority, 3, 'Priority adjusted correctly' );
505
505
506
    $schema->storage->txn_rollback;
506
    $schema->storage->txn_rollback;
507
};
507
};
(-)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