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

(-)a/Koha/Acquisition/Invoice.pm (+40 lines)
Line 0 Link Here
1
package Koha::Acquisition::Invoice;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 3 of the License, or (at your option) any later
8
# version.
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with Koha; if not, write to the Free Software Foundation, Inc.,
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18
use Modern::Perl;
19
20
use Koha::Database;
21
22
use base qw(Koha::Object);
23
24
=head1 NAME
25
26
Koha::Acquisition::Invoice object class
27
28
=head1 API
29
30
=head2 Internal methods
31
32
=head3 _type
33
34
=cut
35
36
sub _type {
37
    return 'Aqinvoice';
38
}
39
40
1;
(-)a/Koha/Acquisition/Invoices.pm (+50 lines)
Line 0 Link Here
1
package Koha::Acquisition::Invoices;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 3 of the License, or (at your option) any later
8
# version.
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with Koha; if not, write to the Free Software Foundation, Inc.,
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18
use Modern::Perl;
19
20
use Koha::Database;
21
22
use Koha::Acquisition::Invoice;
23
24
use base qw(Koha::Objects);
25
26
=head1 NAME
27
28
Koha::Acquisition::Invoices object set class
29
30
=head1 API
31
32
=head2 Internal methods
33
34
=head3 _type (internal)
35
36
=cut
37
38
sub _type {
39
    return 'Aqinvoice';
40
}
41
42
=head3 object_class (internal)
43
44
=cut
45
46
sub object_class {
47
    return 'Koha::Acquisition::Invoice';
48
}
49
50
1;
(-)a/Koha/Acquisition/Order.pm (+16 lines)
Lines 21-26 use Carp qw( croak ); Link Here
21
21
22
use Koha::Acquisition::Baskets;
22
use Koha::Acquisition::Baskets;
23
use Koha::Acquisition::Funds;
23
use Koha::Acquisition::Funds;
24
use Koha::Acquisition::Invoices;
24
use Koha::Database;
25
use Koha::Database;
25
use Koha::DateUtils qw( dt_from_string output_pref );
26
use Koha::DateUtils qw( dt_from_string output_pref );
26
27
Lines 135-140 sub fund { Link Here
135
    return Koha::Acquisition::Fund->_new_from_dbic( $fund_rs );
136
    return Koha::Acquisition::Fund->_new_from_dbic( $fund_rs );
136
}
137
}
137
138
139
=head3 invoice
140
141
    my $invoice = $order->invoice
142
143
Returns the invoice associated to the order.
144
145
=cut
146
147
sub invoice {
148
    my ( $self )  = @_;
149
    my $invoice_rs = $self->_result->invoiceid;
150
    return unless $invoice_rs;
151
    return Koha::Acquisition::Invoice->_new_from_dbic( $invoice_rs );
152
}
153
138
=head2 Internal methods
154
=head2 Internal methods
139
155
140
=head3 _type
156
=head3 _type
(-)a/t/db_dependent/Koha/Acquisition/Order.t (-2 / +30 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 3;
22
use Test::More tests => 4;
23
23
24
use t::lib::TestBuilder;
24
use t::lib::TestBuilder;
25
use t::lib::Mocks;
25
use t::lib::Mocks;
Lines 114-116 subtest 'fund' => sub { Link Here
114
        '->fund should return a Koha::Acquisition::Fund object' );
114
        '->fund should return a Koha::Acquisition::Fund object' );
115
    $schema->storage->txn_rollback;
115
    $schema->storage->txn_rollback;
116
};
116
};
117
- 
117
118
subtest 'invoice' => sub {
119
    plan tests => 2;
120
121
    $schema->storage->txn_begin;
122
    my $o = $builder->build_object(
123
        {
124
            class => 'Koha::Acquisition::Orders',
125
            value => { cancellationreason => 'XXXXXXXX', invoiceid => undef }, # not received yet
126
        }
127
    );
128
129
    my $order = Koha::Acquisition::Orders->find( $o->ordernumber );
130
    is( $order->invoice, undef,
131
        '->invoice should return undef if no invoice defined yet');
132
133
    my $invoice = $builder->build_object(
134
        {
135
            class => 'Koha::Acquisition::Invoices',
136
        },
137
    );
138
139
    $o->invoiceid( $invoice->invoiceid )->store;
140
    $order = Koha::Acquisition::Orders->find( $o->ordernumber );
141
    is( ref( $order->invoice ), 'Koha::Acquisition::Invoice',
142
        '->invoice should return a Koha::Acquisition::Invoice object if an invoice is defined');
143
144
    $schema->storage->txn_rollback;
145
};

Return to bug 20726