Bug 19380: Use Koha::Item::get_transfer instead of GetTransfers
Signed-off-by: Josef Moravec <josef.moravec@gmail.com> Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
parent
1611c13e85
commit
6666918dd6
2 changed files with 25 additions and 22 deletions
|
@ -230,32 +230,36 @@ sub GetRecords {
|
|||
my $biblioitemnumber = $biblioitem->{'biblioitemnumber'};
|
||||
my $holds = $biblio->current_holds->unblessed;
|
||||
my $issues = GetBiblioIssues($biblionumber);
|
||||
my $items = $biblio->items->unblessed;
|
||||
my @items = $biblio->items;
|
||||
|
||||
$biblioitem->{items}->{item} = [];
|
||||
|
||||
# We loop over the items to clean them
|
||||
foreach my $item (@$items) {
|
||||
foreach my $item (@items) {
|
||||
my %item = %{ $item->unblessed };
|
||||
|
||||
# This hides additionnal XML subfields, we don't need these info
|
||||
delete $item->{'more_subfields_xml'};
|
||||
delete $item{'more_subfields_xml'};
|
||||
|
||||
# Display branch names instead of branch codes
|
||||
my $home_library = Koha::Libraries->find( $item->{homebranch} );
|
||||
my $holding_library = Koha::Libraries->find( $item->{holdingbranch} );
|
||||
$item->{'homebranchname'} = $home_library ? $home_library->branchname : '';
|
||||
$item->{'holdingbranchname'} = $holding_library ? $holding_library->branchname : '';
|
||||
my $home_library = $item->home_branch;
|
||||
my $holding_library = $item->holding_branch;
|
||||
$item{'homebranchname'} = $home_library ? $home_library->branchname : '';
|
||||
$item{'holdingbranchname'} = $holding_library ? $holding_library->branchname : '';
|
||||
|
||||
my ($transferDate, $transferFrom, $transferTo) = GetTransfers($item->{itemnumber});
|
||||
if ($transferDate) {
|
||||
$item->{transfer} = {
|
||||
datesent => $transferDate,
|
||||
frombranch => $transferFrom,
|
||||
tobranch => $transferTo,
|
||||
my $transfer = $item->get_transfer;
|
||||
if ($transfer) {
|
||||
$item{transfer} = {
|
||||
datesent => $transfer->datesent,
|
||||
frombranch => $transfer->frombranch,
|
||||
tobranch => $transfer->tobranch,
|
||||
};
|
||||
}
|
||||
|
||||
push @{ $biblioitem->{items}->{item} }, \%item;
|
||||
}
|
||||
|
||||
# Hashref building...
|
||||
$biblioitem->{'items'}->{'item'} = $items;
|
||||
$biblioitem->{'reserves'}->{'reserve'} = $holds;
|
||||
$biblioitem->{'issues'}->{'issue'} = $issues;
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ use t::lib::Mocks;
|
|||
use t::lib::TestBuilder;
|
||||
|
||||
use C4::Items qw( ModItemTransfer );
|
||||
use C4::Circulation qw( GetTransfers );
|
||||
|
||||
use Koha::AuthUtils;
|
||||
|
||||
|
@ -568,8 +567,8 @@ subtest 'GetRecords' => sub {
|
|||
biblionumber => $biblio->{biblionumber},
|
||||
},
|
||||
});
|
||||
my $item = $builder->build({
|
||||
source => 'Item',
|
||||
my $item = $builder->build_object({
|
||||
class => 'Koha::Items',
|
||||
value => {
|
||||
biblionumber => $biblio->{biblionumber},
|
||||
biblioitemnumber => $biblioitem->{biblioitemnumber},
|
||||
|
@ -578,7 +577,7 @@ subtest 'GetRecords' => sub {
|
|||
},
|
||||
});
|
||||
|
||||
ModItemTransfer($item->{itemnumber}, $branch1->{branchcode}, $branch2->{branchcode});
|
||||
ModItemTransfer($item->itemnumber, $branch1->{branchcode}, $branch2->{branchcode});
|
||||
|
||||
my $cgi = new CGI;
|
||||
$cgi->param(service => 'GetRecords');
|
||||
|
@ -586,11 +585,11 @@ subtest 'GetRecords' => sub {
|
|||
|
||||
my $reply = C4::ILSDI::Services::GetRecords($cgi);
|
||||
|
||||
my ($datesent, $frombranch, $tobranch) = GetTransfers($item->{itemnumber});
|
||||
my $transfer = $item->get_transfer;
|
||||
my $expected = {
|
||||
datesent => $datesent,
|
||||
frombranch => $frombranch,
|
||||
tobranch => $tobranch,
|
||||
datesent => $transfer->datesent,
|
||||
frombranch => $transfer->frombranch,
|
||||
tobranch => $transfer->tobranch,
|
||||
};
|
||||
is_deeply($reply->{record}->[0]->{items}->{item}->[0]->{transfer}, $expected,
|
||||
'GetRecords returns transfer informations');
|
||||
|
|
Loading…
Reference in a new issue