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

(-)a/Koha/Acquisition/Basket.pm (+13 lines)
Lines 80-85 sub basket_group { Link Here
80
    return Koha::Acquisition::BasketGroup->_new_from_dbic($basket_group_rs);
80
    return Koha::Acquisition::BasketGroup->_new_from_dbic($basket_group_rs);
81
}
81
}
82
82
83
=head3 contract
84
85
Returns the contract associated to this basket
86
87
=cut
88
89
sub contract {
90
    my ($self) = @_;
91
    my $rs = $self->_result->contractnumber;
92
    return unless $rs;
93
    return Koha::Acquisition::Contract->_new_from_dbic($rs);
94
}
95
83
=head3 orders
96
=head3 orders
84
97
85
    my $orders = $basket->orders;
98
    my $orders = $basket->orders;
(-)a/acqui/basket.pl (-7 / +3 lines)
Lines 31-37 use C4::Suggestions qw( GetSuggestion GetSuggestionInfoFromBiblionumber GetSugge Link Here
31
use Koha::Biblios;
31
use Koha::Biblios;
32
use Koha::Acquisition::Baskets;
32
use Koha::Acquisition::Baskets;
33
use Koha::Acquisition::Booksellers;
33
use Koha::Acquisition::Booksellers;
34
use Koha::Acquisition::Contracts;
35
use Koha::Acquisition::Orders;
34
use Koha::Acquisition::Orders;
36
use Koha::Libraries;
35
use Koha::Libraries;
37
use C4::Letters qw( SendAlerts );
36
use C4::Letters qw( SendAlerts );
Lines 400-407 if ( $op eq 'list' ) { Link Here
400
        push @cancelledorders_loop, $line;
399
        push @cancelledorders_loop, $line;
401
    }
400
    }
402
401
403
    my $contract = Koha::Acquisition::Contracts->find( $basket->{contractnumber} );
404
405
    if ( $basket->{basketgroupid} ) {
402
    if ( $basket->{basketgroupid} ) {
406
        $basketgroup = GetBasketgroup( $basket->{basketgroupid} );
403
        $basketgroup = GetBasketgroup( $basket->{basketgroupid} );
407
    }
404
    }
Lines 418-431 if ( $op eq 'list' ) { Link Here
418
    my $edi_order  = $basket_obj->edi_order;
415
    my $edi_order  = $basket_obj->edi_order;
419
416
420
    $template->param(
417
    $template->param(
421
        basketno              => $basketno,
418
        basketno   => $basketno,
422
        basket                => $basket,
419
        basket     => $basket,       # FIXME Remove basket_obj and use the Koha::Acq::Basket object in the template
420
        basket_obj => $basket_obj,
423
        basketname            => $basket->{'basketname'},
421
        basketname            => $basket->{'basketname'},
424
        basketbranchcode      => $basket->{branch},
422
        basketbranchcode      => $basket->{branch},
425
        basketnote            => $basket->{note},
423
        basketnote            => $basket->{note},
426
        basketbooksellernote  => $basket->{booksellernote},
424
        basketbooksellernote  => $basket->{booksellernote},
427
        basketcontractno      => $basket->{contractnumber},
428
        basketcontractname    => $contract->contractname,
429
        branches_loop         => \@branches_loop,
425
        branches_loop         => \@branches_loop,
430
        creationdate          => $basket->{creationdate},
426
        creationdate          => $basket->{creationdate},
431
        edi_order             => $edi_order,
427
        edi_order             => $edi_order,
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt (-2 / +3 lines)
Lines 318-327 Link Here
318
                                        [% IF ( basketbooksellernote ) %]
318
                                        [% IF ( basketbooksellernote ) %]
319
                                            <li><span class="label">Vendor note:</span> [% basketbooksellernote | html %]</li>
319
                                            <li><span class="label">Vendor note:</span> [% basketbooksellernote | html %]</li>
320
                                        [% END %]
320
                                        [% END %]
321
                                        [% IF ( basketcontractno ) %]
321
                                        [% SET contract = basket_obj.contract %]
322
                                        [% IF contract %]
322
                                            <li
323
                                            <li
323
                                                ><span class="label">Contract name:</span>
324
                                                ><span class="label">Contract name:</span>
324
                                                <a href="../admin/aqcontract.pl?op=add_form&amp;contractnumber=[% basketcontractno | uri %]&amp;booksellerid=[% booksellerid | uri %]">[% basketcontractname | html %]</a></li
325
                                                <a href="../admin/aqcontract.pl?op=add_form&amp;contractnumber=[% contract.contractnumber| uri %]&amp;booksellerid=[% contract.booksellerid | uri %]">[% contract.contractname| html %]</a></li
325
                                            >
326
                                            >
326
                                        [% END %]
327
                                        [% END %]
327
                                        [% IF deliveryplace %]
328
                                        [% IF deliveryplace %]
(-)a/t/db_dependent/Koha/Acquisition/Basket.t (-2 / +31 lines)
Lines 20-26 Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::NoWarnings;
22
use Test::NoWarnings;
23
use Test::More tests => 14;
23
use Test::More tests => 15;
24
use Test::Exception;
24
use Test::Exception;
25
25
26
use t::lib::TestBuilder;
26
use t::lib::TestBuilder;
Lines 125-130 subtest 'basket_group' => sub { Link Here
125
    $schema->storage->txn_rollback;
125
    $schema->storage->txn_rollback;
126
};
126
};
127
127
128
subtest 'contract' => sub {
129
130
    plan tests => 2;
131
132
    $schema->storage->txn_begin;
133
134
    my $basket = $builder->build_object(
135
        {
136
            class => 'Koha::Acquisition::Baskets',
137
            value => { contractnumber => undef }
138
        }
139
    );
140
    is( $basket->contract, undef, '->contract returns undef is no contract for this basket' );
141
142
    my $contract = $builder->build_object(
143
        {
144
            class => 'Koha::Acquisition::Contracts',
145
        }
146
    );
147
148
    $basket->contractnumber( $contract->contractnumber )->store;
149
150
    is(
151
        ref( $basket->contract ), 'Koha::Acquisition::Contract',
152
        '->contract should return a Koha::Acquisition::Contract object if linked to a contract'
153
    );
154
155
    $schema->storage->txn_rollback;
156
};
157
128
subtest 'creator() tests' => sub {
158
subtest 'creator() tests' => sub {
129
159
130
    plan tests => 4;
160
    plan tests => 4;
131
- 

Return to bug 39711