View | Details | Raw Unified | Return to bug 22611
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 568-575 subtest 'GetRecords' => sub { Link Here
568
            biblionumber => $biblio->{biblionumber},
567
            biblionumber => $biblio->{biblionumber},
569
        },
568
        },
570
    });
569
    });
571
    my $item = $builder->build({
570
    my $item = $builder->build_object({
572
        source => 'Item',
571
        class => 'Koha::Items',
573
        value => {
572
        value => {
574
            biblionumber => $biblio->{biblionumber},
573
            biblionumber => $biblio->{biblionumber},
575
            biblioitemnumber => $biblioitem->{biblioitemnumber},
574
            biblioitemnumber => $biblioitem->{biblioitemnumber},
Lines 578-584 subtest 'GetRecords' => sub { Link Here
578
        },
577
        },
579
    });
578
    });
580
579
581
    ModItemTransfer($item->{itemnumber}, $branch1->{branchcode}, $branch2->{branchcode});
580
    ModItemTransfer($item->itemnumber, $branch1->{branchcode}, $branch2->{branchcode});
582
581
583
    my $cgi = new CGI;
582
    my $cgi = new CGI;
584
    $cgi->param(service => 'GetRecords');
583
    $cgi->param(service => 'GetRecords');
Lines 586-596 subtest 'GetRecords' => sub { Link Here
586
585
587
    my $reply = C4::ILSDI::Services::GetRecords($cgi);
586
    my $reply = C4::ILSDI::Services::GetRecords($cgi);
588
587
589
    my ($datesent, $frombranch, $tobranch) = GetTransfers($item->{itemnumber});
588
    my $transfer = $item->get_transfer;
590
    my $expected = {
589
    my $expected = {
591
        datesent => $datesent,
590
        datesent => $transfer->datesent,
592
        frombranch => $frombranch,
591
        frombranch => $transfer->frombranch,
593
        tobranch => $tobranch,
592
        tobranch => $transfer->tobranch,
594
    };
593
    };
595
    is_deeply($reply->{record}->[0]->{items}->{item}->[0]->{transfer}, $expected,
594
    is_deeply($reply->{record}->[0]->{items}->{item}->[0]->{transfer}, $expected,
596
        'GetRecords returns transfer informations');
595
        'GetRecords returns transfer informations');
597
- 

Return to bug 22611