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

(-)a/C4/Acquisition.pm (-2 / +6 lines)
Lines 1510-1516 sub ModReceiveOrder { Link Here
1510
        $order->{datereceived} = $datereceived;
1510
        $order->{datereceived} = $datereceived;
1511
        $order->{invoiceid} = $invoice->{invoiceid};
1511
        $order->{invoiceid} = $invoice->{invoiceid};
1512
        $order->{orderstatus} = 'complete';
1512
        $order->{orderstatus} = 'complete';
1513
        $new_ordernumber = Koha::Acquisition::Order->new($order)->store->ordernumber; # TODO What if the store fails?
1513
        my @columns = Koha::Acquisition::Orders->columns;
1514
        my %filtered_order = map { exists $order->{$_} ? ($_ => $order->{$_}) : () } @columns;
1515
        $new_ordernumber = Koha::Acquisition::Order->new(\%filtered_order)->store->ordernumber;
1514
1516
1515
        if ($received_items) {
1517
        if ($received_items) {
1516
            foreach my $itemnumber (@$received_items) {
1518
            foreach my $itemnumber (@$received_items) {
Lines 2000-2006 sub TransferOrder { Link Here
2000
    delete $order->{parent_ordernumber};
2002
    delete $order->{parent_ordernumber};
2001
    $order->{'basketno'} = $basketno;
2003
    $order->{'basketno'} = $basketno;
2002
2004
2003
    my $newordernumber = Koha::Acquisition::Order->new($order)->store->ordernumber;
2005
    my @columns = Koha::Acquisition::Orders->columns;
2006
    my %filtered_order = map { exists $order->{$_} ? ($_ => $order->{$_}) : () } @columns;
2007
    my $newordernumber = Koha::Acquisition::Order->new(\%filtered_order)->store->ordernumber;
2004
2008
2005
    $query = q{
2009
    $query = q{
2006
        UPDATE aqorders_items
2010
        UPDATE aqorders_items
(-)a/Koha/Acquisition/Basket.pm (-4 / +22 lines)
Lines 19-25 package Koha::Acquisition::Basket; Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Koha::Database;
22
use Koha::Acquisition::Orders;
23
23
24
use base qw( Koha::Object );
24
use base qw( Koha::Object );
25
25
Lines 31-38 Koha::Acquisition::Basket - Koha Basket Object class Link Here
31
31
32
=head2 Class Methods
32
=head2 Class Methods
33
33
34
=cut
35
36
=head3 bookseller
34
=head3 bookseller
37
35
38
Returns the vendor
36
Returns the vendor
Lines 45-51 sub bookseller { Link Here
45
    return Koha::Acquisition::Bookseller->_new_from_dbic( $bookseller_rs );
43
    return Koha::Acquisition::Bookseller->_new_from_dbic( $bookseller_rs );
46
}
44
}
47
45
48
49
=head3 effective_create_items
46
=head3 effective_create_items
50
47
51
Returns C<create_items> for this basket, falling back to C<AcqCreateItem> if unset.
48
Returns C<create_items> for this basket, falling back to C<AcqCreateItem> if unset.
Lines 58-63 sub effective_create_items { Link Here
58
    return $self->create_items || C4::Context->preference('AcqCreateItem');
55
    return $self->create_items || C4::Context->preference('AcqCreateItem');
59
}
56
}
60
57
58
=head3 orders
59
60
Returns basket's orders
61
62
    # As an arrayref
63
    my $orders = $basket->orders;
64
65
    # As an array
66
    my @orders = $basket->orders;
67
68
=cut
69
70
sub orders {
71
    my ($self) = @_;
72
73
    $self->{_orders} ||= Koha::Acquisition::Orders->search({ basketno => $self->basketno });
74
75
    return wantarray ? $self->{_orders}->as_list : $self->{_orders};
76
}
77
78
61
=head2 Internal methods
79
=head2 Internal methods
62
80
63
=head3 _type
81
=head3 _type
(-)a/Koha/Basketgroup.pm (-4 / +4 lines)
Lines 1-4 Link Here
1
package Koha::Basketgroup;
1
package Koha::Acquisition::Basketgroup;
2
2
3
# This file is part of Koha.
3
# This file is part of Koha.
4
#
4
#
Lines 19-25 use Modern::Perl; Link Here
19
19
20
use List::MoreUtils qw/uniq/;
20
use List::MoreUtils qw/uniq/;
21
21
22
use Koha::Baskets;
22
use Koha::Acquisition::Baskets;
23
23
24
use base qw(Koha::Object);
24
use base qw(Koha::Object);
25
25
Lines 30-42 sub _type { Link Here
30
sub bookseller {
30
sub bookseller {
31
    my ($self) = @_;
31
    my ($self) = @_;
32
32
33
    return Koha::Booksellers->find($self->booksellerid);
33
    return scalar Koha::Acquisition::Booksellers->find($self->booksellerid);
34
}
34
}
35
35
36
sub baskets {
36
sub baskets {
37
    my ($self) = @_;
37
    my ($self) = @_;
38
38
39
    $self->{_baskets} ||= Koha::Baskets->search({ basketgroupid => $self->id });
39
    $self->{_baskets} ||= Koha::Acquisition::Baskets->search({ basketgroupid => $self->id });
40
40
41
    return wantarray ? $self->{_baskets}->as_list : $self->{_baskets};
41
    return wantarray ? $self->{_baskets}->as_list : $self->{_baskets};
42
}
42
}
(-)a/Koha/Basketgroups.pm (-3 / +3 lines)
Lines 1-4 Link Here
1
package Koha::Basketgroups;
1
package Koha::Acquisition::Basketgroups;
2
2
3
# This file is part of Koha.
3
# This file is part of Koha.
4
#
4
#
Lines 17-23 package Koha::Basketgroups; Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Koha::Basketgroup;
20
use Koha::Acquisition::Basketgroup;
21
21
22
use base qw(Koha::Objects);
22
use base qw(Koha::Objects);
23
23
Lines 26-32 sub _type { Link Here
26
}
26
}
27
27
28
sub object_class {
28
sub object_class {
29
    return 'Koha::Basketgroup';
29
    return 'Koha::Acquisition::Basketgroup';
30
}
30
}
31
31
32
1;
32
1;
(-)a/Koha/Acquisition/Baskets.pm (-27 / +1 lines)
Lines 1-7 Link Here
1
package Koha::Acquisition::Baskets;
1
package Koha::Acquisition::Baskets;
2
2
3
# Copyright 2017 Aleisha Amohia <aleisha@catalyst.net.nz>
4
#
5
# This file is part of Koha.
3
# This file is part of Koha.
6
#
4
#
7
# Koha is free software; you can redistribute it and/or modify it under the
5
# Koha is free software; you can redistribute it and/or modify it under the
Lines 19-58 package Koha::Acquisition::Baskets; Link Here
19
17
20
use Modern::Perl;
18
use Modern::Perl;
21
19
22
use Koha::Database;
23
use Koha::Acquisition::Basket;
20
use Koha::Acquisition::Basket;
24
21
25
use base qw( Koha::Objects );
22
use base qw(Koha::Objects);
26
27
=head1 NAME
28
29
Koha::Acquisition::Baskets - Koha Baskets object set class
30
31
=head1 API
32
33
=head2 Internal methods
34
35
=head3 _type
36
37
=cut
38
23
39
sub _type {
24
sub _type {
40
    return 'Aqbasket';
25
    return 'Aqbasket';
41
}
26
}
42
27
43
=head3 object_class
44
45
=cut
46
47
sub object_class {
28
sub object_class {
48
    return 'Koha::Acquisition::Basket';
29
    return 'Koha::Acquisition::Basket';
49
}
30
}
50
31
51
=head1 AUTHOR
52
53
Aleisha Amohia <aleisha@catalyst.net.nz>
54
Catalyst IT
55
56
=cut
57
58
1;
32
1;
(-)a/Koha/Acquisition/Order.pm (-3 / +8 lines)
Lines 16-27 package Koha::Acquisition::Order; Link Here
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
use Carp qw( croak );
19
20
20
use Carp qw( croak );
21
use Carp qw( croak );
21
22
22
use Koha::Acquisition::Baskets;
23
use Koha::Acquisition::Baskets;
23
use Koha::Database;
24
use Koha::Database;
24
use Koha::DateUtils qw( dt_from_string output_pref );
25
use Koha::DateUtils qw( dt_from_string output_pref );
26
use Koha::Acquisition::Baskets;
25
27
26
use base qw(Koha::Object);
28
use base qw(Koha::Object);
27
29
Lines 59-67 Overloaded I<store> method for backwards compatibility. Link Here
59
sub store {
61
sub store {
60
    my ($self) = @_;
62
    my ($self) = @_;
61
63
62
    my $schema  = Koha::Database->new->schema;
64
    if ($self->basketno) {
63
    # Override quantity for standing orders
65
        my $basket = Koha::Acquisition::Baskets->find($self->basketno);
64
    $self->quantity(1) if ( $self->basketno && $schema->resultset('Aqbasket')->find( $self->basketno )->is_standing );
66
        if ($basket->is_standing) {
67
            $self->quantity(1);
68
        }
69
    }
65
70
66
    # if these parameters are missing, we can't continue
71
    # if these parameters are missing, we can't continue
67
    for my $key (qw( basketno quantity biblionumber budget_id )) {
72
    for my $key (qw( basketno quantity biblionumber budget_id )) {
(-)a/Koha/Acquisition/Orders.pm (-20 lines)
Lines 17-50 package Koha::Acquisition::Orders; Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Carp;
21
22
use Koha::Database;
23
24
use Koha::Acquisition::Order;
20
use Koha::Acquisition::Order;
25
21
26
use base qw(Koha::Objects);
22
use base qw(Koha::Objects);
27
23
28
=head1 NAME
29
30
Koha::Acquisition::Orders object set class
31
32
=head1 API
33
34
=head2 Internal methods
35
36
=head3 _type (internal)
37
38
=cut
39
40
sub _type {
24
sub _type {
41
    return 'Aqorder';
25
    return 'Aqorder';
42
}
26
}
43
27
44
=head3 object_class (internal)
45
46
=cut
47
48
sub object_class {
28
sub object_class {
49
    return 'Koha::Acquisition::Order';
29
    return 'Koha::Acquisition::Order';
50
}
30
}
(-)a/Koha/Basket.pm (-36 lines)
Lines 1-36 Link Here
1
package Koha::Basket;
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::Orders;
21
22
use base qw(Koha::Object);
23
24
sub _type {
25
    return 'Aqbasket';
26
}
27
28
sub orders {
29
    my ($self) = @_;
30
31
    $self->{_orders} ||= Koha::Orders->search({ basketno => $self->basketno });
32
33
    return wantarray ? $self->{_orders}->as_list : $self->{_orders};
34
}
35
36
1;
(-)a/Koha/Baskets.pm (-32 lines)
Lines 1-32 Link Here
1
package Koha::Baskets;
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::Basket;
21
22
use base qw(Koha::Objects);
23
24
sub _type {
25
    return 'Aqbasket';
26
}
27
28
sub object_class {
29
    return 'Koha::Basket';
30
}
31
32
1;
(-)a/Koha/Bookseller.pm (-26 lines)
Lines 1-26 Link Here
1
package Koha::Bookseller;
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 base qw(Koha::Object);
21
22
sub _type {
23
    return 'Aqbookseller';
24
}
25
26
1;
(-)a/Koha/Booksellers.pm (-32 lines)
Lines 1-32 Link Here
1
package Koha::Booksellers;
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::Bookseller;
21
22
use base qw(Koha::Objects);
23
24
sub _type {
25
    return 'Aqbookseller';
26
}
27
28
sub object_class {
29
    return 'Koha::Bookseller';
30
}
31
32
1;
(-)a/Koha/Order.pm (-26 lines)
Lines 1-26 Link Here
1
package Koha::Order;
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 base qw(Koha::Object);
21
22
sub _type {
23
    return 'Aqorder';
24
}
25
26
1;
(-)a/Koha/Orders.pm (-32 lines)
Lines 1-32 Link Here
1
package Koha::Orders;
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::Order;
21
22
use base qw(Koha::Objects);
23
24
sub _type {
25
    return 'Aqorder';
26
}
27
28
sub object_class {
29
    return 'Koha::Order';
30
}
31
32
1;
(-)a/admin/currency.pl (+1 lines)
Lines 27-32 use C4::Output; Link Here
27
27
28
use Koha::Acquisition::Booksellers;
28
use Koha::Acquisition::Booksellers;
29
use Koha::Acquisition::Currencies;
29
use Koha::Acquisition::Currencies;
30
use Koha::Acquisition::Currency;
30
use Koha::Acquisition::Orders;
31
use Koha::Acquisition::Orders;
31
32
32
my $input         = CGI->new;
33
my $input         = CGI->new;
(-)a/t/db_dependent/Acquisition.t (-1 lines)
Lines 185-191 my @order_content = ( Link Here
185
            uncertainprice => 0,
185
            uncertainprice => 0,
186
            order_internalnote => "internal note",
186
            order_internalnote => "internal note",
187
            order_vendornote   => "vendor note",
187
            order_vendornote   => "vendor note",
188
            ordernumber => '',
189
        },
188
        },
190
        num => {
189
        num => {
191
            quantity  => 24,
190
            quantity  => 24,
(-)a/t/db_dependent/Acquisition/GetOrdersByBiblionumber.t (-6 / +3 lines)
Lines 41-47 my $budget = C4::Budgets::GetBudget( $budgetid ); Link Here
41
41
42
my ($biblionumber1, $biblioitemnumber1) = AddBiblio(MARC::Record->new, '');
42
my ($biblionumber1, $biblioitemnumber1) = AddBiblio(MARC::Record->new, '');
43
my ($biblionumber2, $biblioitemnumber2) = AddBiblio(MARC::Record->new, '');
43
my ($biblionumber2, $biblioitemnumber2) = AddBiblio(MARC::Record->new, '');
44
my $order1 = Koha::Acquisition::Order->new(
44
Koha::Acquisition::Order->new(
45
    {
45
    {
46
        basketno => $basketno,
46
        basketno => $basketno,
47
        quantity => 24,
47
        quantity => 24,
Lines 49-57 my $order1 = Koha::Acquisition::Order->new( Link Here
49
        budget_id => $budget->{budget_id},
49
        budget_id => $budget->{budget_id},
50
    }
50
    }
51
)->store;
51
)->store;
52
my $ordernumber1 = $order1->ordernumber;
53
52
54
my $order2 = Koha::Acquisition::Order->new(
53
Koha::Acquisition::Order->new(
55
    {
54
    {
56
        basketno => $basketno,
55
        basketno => $basketno,
57
        quantity => 42,
56
        quantity => 42,
Lines 59-67 my $order2 = Koha::Acquisition::Order->new( Link Here
59
        budget_id => $budget->{budget_id},
58
        budget_id => $budget->{budget_id},
60
    }
59
    }
61
)->store;
60
)->store;
62
my $ordernumber2 = $order2->ordernumber;
63
61
64
my $order3 = Koha::Acquisition::Order->new(
62
Koha::Acquisition::Order->new(
65
    {
63
    {
66
        basketno => $basketno,
64
        basketno => $basketno,
67
        quantity => 4,
65
        quantity => 4,
Lines 69-75 my $order3 = Koha::Acquisition::Order->new( Link Here
69
        budget_id => $budget->{budget_id},
67
        budget_id => $budget->{budget_id},
70
    }
68
    }
71
)->store;
69
)->store;
72
my $ordernumber3 = $order3->ordernumber;
73
70
74
my @orders = GetOrdersByBiblionumber();
71
my @orders = GetOrdersByBiblionumber();
75
is(scalar(@orders), 0, 'GetOrdersByBiblionumber : no argument, return undef');
72
is(scalar(@orders), 0, 'GetOrdersByBiblionumber : no argument, return undef');
(-)a/t/db_dependent/Acquisition/Invoices.t (-9 / +16 lines)
Lines 44-55 my $budgetid = C4::Budgets::AddBudget( Link Here
44
my $budget = C4::Budgets::GetBudget( $budgetid );
44
my $budget = C4::Budgets::GetBudget( $budgetid );
45
45
46
my $bibrec1 = MARC::Record->new();
46
my $bibrec1 = MARC::Record->new();
47
$bibrec1->append_fields(
47
if (C4::Context->preference('marcflavour') eq 'UNIMARC') {
48
    MARC::Field->new('020', '', '', 'a' => '1234567890'),
48
    $bibrec1->append_fields(
49
    MARC::Field->new('100', '', '', 'a' => 'Shakespeare,  Billy'),
49
        MARC::Field->new('010', '', '', 'a' => '1234567890'),
50
    MARC::Field->new('245', '', '', 'a' => 'Bug 8854'),
50
        MARC::Field->new('200', '', '', 'f' => 'Shakespeare,  Billy'),
51
    MARC::Field->new('260', '', '', 'b' => 'Scholastic Publishing', c => 'c2012'),
51
        MARC::Field->new('200', '', '', 'a' => 'Bug 8854'),
52
);
52
        MARC::Field->new('210', '', '', 'c' => 'Scholastic Publishing', d => '2012'),
53
    );
54
} else {
55
    $bibrec1->append_fields(
56
        MARC::Field->new('020', '', '', 'a' => '1234567890'),
57
        MARC::Field->new('100', '', '', 'a' => 'Shakespeare,  Billy'),
58
        MARC::Field->new('245', '', '', 'a' => 'Bug 8854'),
59
        MARC::Field->new('260', '', '', 'b' => 'Scholastic Publishing', c => '2012'),
60
    );
61
}
62
53
my ($biblionumber1, $biblioitemnumber1) = AddBiblio($bibrec1, '');
63
my ($biblionumber1, $biblioitemnumber1) = AddBiblio($bibrec1, '');
54
my ($biblionumber2, $biblioitemnumber2) = AddBiblio(MARC::Record->new, '');
64
my ($biblionumber2, $biblioitemnumber2) = AddBiblio(MARC::Record->new, '');
55
my ($biblionumber3, $biblioitemnumber3) = AddBiblio(MARC::Record->new, '');
65
my ($biblionumber3, $biblioitemnumber3) = AddBiblio(MARC::Record->new, '');
Lines 62-68 my $order1 = Koha::Acquisition::Order->new( Link Here
62
        budget_id => $budget->{budget_id},
72
        budget_id => $budget->{budget_id},
63
    }
73
    }
64
)->store;
74
)->store;
65
my $ordernumber1 = $order1->ordernumber;
66
75
67
my $order2 = Koha::Acquisition::Order->new(
76
my $order2 = Koha::Acquisition::Order->new(
68
    {
77
    {
Lines 72-78 my $order2 = Koha::Acquisition::Order->new( Link Here
72
        budget_id => $budget->{budget_id},
81
        budget_id => $budget->{budget_id},
73
    }
82
    }
74
)->store;
83
)->store;
75
my $ordernumber2 = $order2->ordernumber;
76
84
77
my $order3 = Koha::Acquisition::Order->new(
85
my $order3 = Koha::Acquisition::Order->new(
78
    {
86
    {
Lines 84-90 my $order3 = Koha::Acquisition::Order->new( Link Here
84
        rrp => 42,
92
        rrp => 42,
85
    }
93
    }
86
)->store;
94
)->store;
87
my $ordernumber3 = $order3->ordernumber;
88
95
89
my $invoiceid1 = AddInvoice(invoicenumber => 'invoice1', booksellerid => $booksellerid, unknown => "unknown");
96
my $invoiceid1 = AddInvoice(invoicenumber => 'invoice1', booksellerid => $booksellerid, unknown => "unknown");
90
my $invoiceid2 = AddInvoice(invoicenumber => 'invoice2', booksellerid => $booksellerid, unknown => "unknown",
97
my $invoiceid2 = AddInvoice(invoicenumber => 'invoice2', booksellerid => $booksellerid, unknown => "unknown",
(-)a/t/db_dependent/Acquisition/NewOrder.t (-1 / +1 lines)
Lines 84-90 $order = Koha::Acquisition::Order->new( Link Here
84
)->store;
84
)->store;
85
my $ordernumber = $order->ordernumber;
85
my $ordernumber = $order->ordernumber;
86
$order = Koha::Acquisition::Orders->find( $ordernumber );
86
$order = Koha::Acquisition::Orders->find( $ordernumber );
87
is( $order->quantityreceived, 0, 'Koha::Acquisition::Order->insert set quantityreceivedto 0 if undef is given' );
87
is( $order->quantityreceived, 0, 'Koha::Acquisition::Order->store set quantityreceivedto 0 if undef is given' );
88
is( $order->entrydate, output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), 'Koha::Acquisition::Order->store set entrydate to today' );
88
is( $order->entrydate, output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), 'Koha::Acquisition::Order->store set entrydate to today' );
89
89
90
$schema->storage->txn_rollback();
90
$schema->storage->txn_rollback();
(-)a/t/db_dependent/Acquisition/OrderFromSubscription.t (-5 / +3 lines)
Lines 31-37 my $bookseller = Koha::Acquisition::Bookseller->new( Link Here
31
)->store;
31
)->store;
32
32
33
my ($biblionumber, $biblioitemnumber) = AddBiblio(MARC::Record->new, '');
33
my ($biblionumber, $biblioitemnumber) = AddBiblio(MARC::Record->new, '');
34
my $budgetid;
35
my $bpid = AddBudgetPeriod({
34
my $bpid = AddBudgetPeriod({
36
    budget_period_startdate   => '2015-01-01',
35
    budget_period_startdate   => '2015-01-01',
37
    budget_period_enddate     => '2015-12-31',
36
    budget_period_enddate     => '2015-12-31',
Lines 56-68 my $subscriptionid = NewSubscription( Link Here
56
);
55
);
57
die unless $subscriptionid;
56
die unless $subscriptionid;
58
57
59
my ($basket, $basketno);
58
my $basketno;
60
ok($basketno = NewBasket($bookseller->id, 1), "NewBasket(  " . $bookseller->id . ", 1  ) returns $basketno");
59
ok($basketno = NewBasket($bookseller->id, 1), "NewBasket(  " . $bookseller->id . ", 1  ) returns $basketno");
61
60
62
my $cost = 42.00;
61
my $cost = 42.00;
63
my $subscription = GetSubscription( $subscriptionid );
62
my $subscription = GetSubscription( $subscriptionid );
64
63
65
my $order = Koha::Acquisition::Order->new({
64
Koha::Acquisition::Order->new({
66
    biblionumber => $subscription->{biblionumber},
65
    biblionumber => $subscription->{biblionumber},
67
    entrydate => '2013-01-01',
66
    entrydate => '2013-01-01',
68
    quantity => 1,
67
    quantity => 1,
Lines 75-86 my $order = Koha::Acquisition::Order->new({ Link Here
75
    subscriptionid => $subscription->{subscriptionid},
74
    subscriptionid => $subscription->{subscriptionid},
76
    budget_id => $budget_id,
75
    budget_id => $budget_id,
77
})->store;
76
})->store;
78
my $ordernumber = $order->ordernumber;
79
77
80
my $is_currently_on_order = subscriptionCurrentlyOnOrder( $subscription->{subscriptionid} );
78
my $is_currently_on_order = subscriptionCurrentlyOnOrder( $subscription->{subscriptionid} );
81
is ( $is_currently_on_order, 1, "The subscription is currently on order");
79
is ( $is_currently_on_order, 1, "The subscription is currently on order");
82
80
83
$order = GetLastOrderNotReceivedFromSubscriptionid( $subscription->{subscriptionid} );
81
my $order = GetLastOrderNotReceivedFromSubscriptionid( $subscription->{subscriptionid} );
84
is ( $order->{subscriptionid}, $subscription->{subscriptionid}, "test subscriptionid for the last order not received");
82
is ( $order->{subscriptionid}, $subscription->{subscriptionid}, "test subscriptionid for the last order not received");
85
ok( $order->{ecost} == $cost, "test cost for the last order not received");
83
ok( $order->{ecost} == $cost, "test cost for the last order not received");
86
84
(-)a/t/db_dependent/Acquisition/OrderUsers.t (-1 lines)
Lines 40-46 my $budgetid = C4::Budgets::AddBudget( Link Here
40
);
40
);
41
my $budget = C4::Budgets::GetBudget($budgetid);
41
my $budget = C4::Budgets::GetBudget($budgetid);
42
42
43
my @ordernumbers;
44
my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio( MARC::Record->new, '' );
43
my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio( MARC::Record->new, '' );
45
44
46
my $order = Koha::Acquisition::Order->new(
45
my $order = Koha::Acquisition::Order->new(
(-)a/t/db_dependent/Acquisition/close_reopen_basket.t (-2 / +2 lines)
Lines 47-53 my $budget = C4::Budgets::GetBudget( $budgetid ); Link Here
47
my ($biblionumber1, $biblioitemnumber1) = AddBiblio(MARC::Record->new, '');
47
my ($biblionumber1, $biblioitemnumber1) = AddBiblio(MARC::Record->new, '');
48
my ($biblionumber2, $biblioitemnumber2) = AddBiblio(MARC::Record->new, '');
48
my ($biblionumber2, $biblioitemnumber2) = AddBiblio(MARC::Record->new, '');
49
49
50
my $order1 = Koha::Acquisition::Order->new(
50
Koha::Acquisition::Order->new(
51
    {
51
    {
52
        basketno => $basketno,
52
        basketno => $basketno,
53
        quantity => 24,
53
        quantity => 24,
Lines 57-63 my $order1 = Koha::Acquisition::Order->new( Link Here
57
)->store;
57
)->store;
58
my $ordernumber1 = $order1->ordernumber;
58
my $ordernumber1 = $order1->ordernumber;
59
59
60
my $order2 = Koha::Acquisition::Order->new(
60
Koha::Acquisition::Order->new(
61
    {
61
    {
62
        basketno => $basketno,
62
        basketno => $basketno,
63
        quantity => 42,
63
        quantity => 42,
(-)a/t/db_dependent/Bookseller.t (-12 / +8 lines)
Lines 349-355 is(scalar(@subscriptions), 1, 'search for subscriptions by call number'); Link Here
349
is(scalar(@subscriptions), 1, 'search for subscriptions by location');
349
is(scalar(@subscriptions), 1, 'search for subscriptions by location');
350
350
351
#Add 4 orders
351
#Add 4 orders
352
my $order1 = Koha::Acquisition::Order->new(
352
Koha::Acquisition::Order->new(
353
    {
353
    {
354
        basketno         => $basketno1,
354
        basketno         => $basketno1,
355
        quantity         => 24,
355
        quantity         => 24,
Lines 358-364 my $order1 = Koha::Acquisition::Order->new( Link Here
358
        entrydate        => '2013-01-01',
358
        entrydate        => '2013-01-01',
359
        currency         => $curcode,
359
        currency         => $curcode,
360
        notes            => "This is a note1",
360
        notes            => "This is a note1",
361
        tax_rate          => 0.0500,
361
        tax_rate_on_ordering => 0.0500,
362
        orderstatus      => 1,
362
        orderstatus      => 1,
363
        subscriptionid   => $id_subscription1,
363
        subscriptionid   => $id_subscription1,
364
        quantityreceived => 2,
364
        quantityreceived => 2,
Lines 367-375 my $order1 = Koha::Acquisition::Order->new( Link Here
367
        datereceived     => '2013-06-01'
367
        datereceived     => '2013-06-01'
368
    }
368
    }
369
)->store;
369
)->store;
370
my $ordernumber1 = $order1->ordernumber;
371
370
372
my $order2 = Koha::Acquisition::Order->new(
371
Koha::Acquisition::Order->new(
373
    {
372
    {
374
        basketno       => $basketno2,
373
        basketno       => $basketno2,
375
        quantity       => 20,
374
        quantity       => 20,
Lines 378-393 my $order2 = Koha::Acquisition::Order->new( Link Here
378
        entrydate      => '2013-01-01',
377
        entrydate      => '2013-01-01',
379
        currency       => $curcode,
378
        currency       => $curcode,
380
        notes          => "This is a note2",
379
        notes          => "This is a note2",
381
        tax_rate        => 0.0500,
380
        tax_rate_on_ordering => 0.0500,
382
        orderstatus    => 1,
381
        orderstatus    => 1,
383
        subscriptionid => $id_subscription2,
382
        subscriptionid => $id_subscription2,
384
        rrp            => 10,
383
        rrp            => 10,
385
        ecost          => 10,
384
        ecost          => 10,
386
    }
385
    }
387
)->store;
386
)->store;
388
my $ordernumber2 = $order2->ordernumber;
389
387
390
my $order3 = Koha::Acquisition::Order->new(
388
Koha::Acquisition::Order->new(
391
    {
389
    {
392
        basketno       => $basketno3,
390
        basketno       => $basketno3,
393
        quantity       => 20,
391
        quantity       => 20,
Lines 396-411 my $order3 = Koha::Acquisition::Order->new( Link Here
396
        entrydate      => '2013-02-02',
394
        entrydate      => '2013-02-02',
397
        currency       => $curcode,
395
        currency       => $curcode,
398
        notes          => "This is a note3",
396
        notes          => "This is a note3",
399
        tax_rate        => 0.0500,
397
        tax_rate_on_ordering => 0.0500,
400
        orderstatus    => 2,
398
        orderstatus    => 2,
401
        subscriptionid => $id_subscription3,
399
        subscriptionid => $id_subscription3,
402
        rrp            => 11,
400
        rrp            => 11,
403
        ecost          => 11,
401
        ecost          => 11,
404
    }
402
    }
405
)->store;
403
)->store;
406
my $ordernumber3 = $order3->ordernumber;
407
404
408
my $order4 = Koha::Acquisition::Order->new(
405
Koha::Acquisition::Order->new(
409
    {
406
    {
410
        basketno         => $basketno4,
407
        basketno         => $basketno4,
411
        quantity         => 20,
408
        quantity         => 20,
Lines 414-420 my $order4 = Koha::Acquisition::Order->new( Link Here
414
        entrydate        => '2013-02-02',
411
        entrydate        => '2013-02-02',
415
        currency         => $curcode,
412
        currency         => $curcode,
416
        notes            => "This is a note3",
413
        notes            => "This is a note3",
417
        tax_rate          => 0.0500,
414
        tax_rate_on_ordering => 0.0500,
418
        orderstatus      => 2,
415
        orderstatus      => 2,
419
        subscriptionid   => $id_subscription3,
416
        subscriptionid   => $id_subscription3,
420
        rrp              => 11,
417
        rrp              => 11,
Lines 422-428 my $order4 = Koha::Acquisition::Order->new( Link Here
422
        quantityreceived => 20
419
        quantityreceived => 20
423
    }
420
    }
424
)->store;
421
)->store;
425
my $ordernumber4 = $order4->ordernumber;
426
422
427
#Test cases:
423
#Test cases:
428
# Sample datas :
424
# Sample datas :
(-)a/t/db_dependent/Budgets.t (-5 / +3 lines)
Lines 350-359 for my $infos (@order_infos) { Link Here
350
                order_internalnote => "internal note",
350
                order_internalnote => "internal note",
351
                order_vendornote   => "vendor note",
351
                order_vendornote   => "vendor note",
352
                quantity           => 2,
352
                quantity           => 2,
353
                cost_tax_included  => $item_price,
353
                ecost_tax_included => $item_price,
354
                rrp_tax_included   => $item_price,
354
                rrp_tax_included   => $item_price,
355
                listprice          => $item_price,
355
                listprice          => $item_price,
356
                ecost_tax_include  => $item_price,
356
                ecost_tax_included => $item_price,
357
                discount           => 0,
357
                discount           => 0,
358
                uncertainprice     => 0,
358
                uncertainprice     => 0,
359
            }
359
            }
Lines 371-377 for my $infos (@order_infos) { Link Here
371
                order_internalnote => "internal note",
371
                order_internalnote => "internal note",
372
                order_vendornote   => "vendor note",
372
                order_vendornote   => "vendor note",
373
                quantity           => $item_quantity,
373
                quantity           => $item_quantity,
374
                cost               => $item_price,
374
                ecost              => $item_price,
375
                rrp_tax_included   => $item_price,
375
                rrp_tax_included   => $item_price,
376
                listprice          => $item_price,
376
                listprice          => $item_price,
377
                ecost_tax_included => $item_price,
377
                ecost_tax_included => $item_price,
Lines 379-385 for my $infos (@order_infos) { Link Here
379
                uncertainprice     => 0,
379
                uncertainprice     => 0,
380
            }
380
            }
381
        )->store;
381
        )->store;
382
        my $ordernumber = $order->ordernumber;
383
        ModReceiveOrder({
382
        ModReceiveOrder({
384
              biblionumber     => $biblionumber,
383
              biblionumber     => $biblionumber,
385
              order            => $order->unblessed,
384
              order            => $order->unblessed,
386
- 

Return to bug 11708