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

(-)a/C4/ILSDI/Services.pm (-15 / +19 lines)
Lines 230-261 sub GetRecords { Link Here
230
        my $biblioitemnumber = $biblioitem->{'biblioitemnumber'};
230
        my $biblioitemnumber = $biblioitem->{'biblioitemnumber'};
231
        my $holds  = $biblio->current_holds->unblessed;
231
        my $holds  = $biblio->current_holds->unblessed;
232
        my $issues           = GetBiblioIssues($biblionumber);
232
        my $issues           = GetBiblioIssues($biblionumber);
233
        my $items            = $biblio->items->unblessed;
233
        my @items            = $biblio->items;
234
235
        $biblioitem->{items}->{item} = [];
234
236
235
        # We loop over the items to clean them
237
        # We loop over the items to clean them
236
        foreach my $item (@$items) {
238
        foreach my $item (@items) {
239
            my %item = %{ $item->unblessed };
237
240
238
            # This hides additionnal XML subfields, we don't need these info
241
            # This hides additionnal XML subfields, we don't need these info
239
            delete $item->{'more_subfields_xml'};
242
            delete $item{'more_subfields_xml'};
240
243
241
            # Display branch names instead of branch codes
244
            # Display branch names instead of branch codes
242
            my $home_library    = Koha::Libraries->find( $item->{homebranch} );
245
            my $home_library    = $item->home_branch;
243
            my $holding_library = Koha::Libraries->find( $item->{holdingbranch} );
246
            my $holding_library = $item->holding_branch;
244
            $item->{'homebranchname'}    = $home_library    ? $home_library->branchname    : '';
247
            $item{'homebranchname'}    = $home_library    ? $home_library->branchname    : '';
245
            $item->{'holdingbranchname'} = $holding_library ? $holding_library->branchname : '';
248
            $item{'holdingbranchname'} = $holding_library ? $holding_library->branchname : '';
246
249
247
            my ($transferDate, $transferFrom, $transferTo) = GetTransfers($item->{itemnumber});
250
            my $transfer = $item->get_transfer;
248
            if ($transferDate) {
251
            if ($transfer) {
249
                $item->{transfer} = {
252
                $item{transfer} = {
250
                    datesent => $transferDate,
253
                    datesent => $transfer->datesent,
251
                    frombranch => $transferFrom,
254
                    frombranch => $transfer->frombranch,
252
                    tobranch => $transferTo,
255
                    tobranch => $transfer->tobranch,
253
                };
256
                };
254
            }
257
            }
258
259
            push @{ $biblioitem->{items}->{item} }, \%item;
255
        }
260
        }
256
261
257
        # Hashref building...
262
        # Hashref building...
258
        $biblioitem->{'items'}->{'item'}       = $items;
259
        $biblioitem->{'reserves'}->{'reserve'} = $holds;
263
        $biblioitem->{'reserves'}->{'reserve'} = $holds;
260
        $biblioitem->{'issues'}->{'issue'}     = $issues;
264
        $biblioitem->{'issues'}->{'issue'}     = $issues;
261
265
(-)a/t/db_dependent/ILSDI_Services.t (-9 / +7 lines)
Lines 25-31 use t::lib::Mocks; Link Here
25
use t::lib::TestBuilder;
25
use t::lib::TestBuilder;
26
26
27
use C4::Items qw( ModItemTransfer );
27
use C4::Items qw( ModItemTransfer );
28
use C4::Circulation qw( GetTransfers );
29
28
30
use Koha::AuthUtils;
29
use Koha::AuthUtils;
31
30
Lines 476-483 subtest 'GetRecords' => sub { Link Here
476
            biblionumber => $biblio->{biblionumber},
475
            biblionumber => $biblio->{biblionumber},
477
        },
476
        },
478
    });
477
    });
479
    my $item = $builder->build({
478
    my $item = $builder->build_object({
480
        source => 'Item',
479
        class => 'Koha::Items',
481
        value => {
480
        value => {
482
            biblionumber => $biblio->{biblionumber},
481
            biblionumber => $biblio->{biblionumber},
483
            biblioitemnumber => $biblioitem->{biblioitemnumber},
482
            biblioitemnumber => $biblioitem->{biblioitemnumber},
Lines 486-492 subtest 'GetRecords' => sub { Link Here
486
        },
485
        },
487
    });
486
    });
488
487
489
    ModItemTransfer($item->{itemnumber}, $branch1->{branchcode}, $branch2->{branchcode});
488
    ModItemTransfer($item->itemnumber, $branch1->{branchcode}, $branch2->{branchcode});
490
489
491
    my $cgi = new CGI;
490
    my $cgi = new CGI;
492
    $cgi->param(service => 'GetRecords');
491
    $cgi->param(service => 'GetRecords');
Lines 494-504 subtest 'GetRecords' => sub { Link Here
494
493
495
    my $reply = C4::ILSDI::Services::GetRecords($cgi);
494
    my $reply = C4::ILSDI::Services::GetRecords($cgi);
496
495
497
    my ($datesent, $frombranch, $tobranch) = GetTransfers($item->{itemnumber});
496
    my $transfer = $item->get_transfer;
498
    my $expected = {
497
    my $expected = {
499
        datesent => $datesent,
498
        datesent => $transfer->datesent,
500
        frombranch => $frombranch,
499
        frombranch => $transfer->frombranch,
501
        tobranch => $tobranch,
500
        tobranch => $transfer->tobranch,
502
    };
501
    };
503
    is_deeply($reply->{record}->[0]->{items}->{item}->[0]->{transfer}, $expected,
502
    is_deeply($reply->{record}->[0]->{items}->{item}->[0]->{transfer}, $expected,
504
        'GetRecords returns transfer informations');
503
        'GetRecords returns transfer informations');
505
- 

Return to bug 19380