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

(-)a/C4/Acquisition.pm (-3 / +7 lines)
Lines 28-34 use C4::Contract; Link Here
28
use C4::Debug;
28
use C4::Debug;
29
use C4::Templates qw(gettemplate);
29
use C4::Templates qw(gettemplate);
30
use Koha::DateUtils qw( dt_from_string output_pref );
30
use Koha::DateUtils qw( dt_from_string output_pref );
31
use Koha::Acquisition::Order;
31
use Koha::Acquisition::Orders;
32
use Koha::Acquisition::Booksellers;
32
use Koha::Acquisition::Booksellers;
33
use Koha::Number::Price;
33
use Koha::Number::Price;
34
use Koha::Libraries;
34
use Koha::Libraries;
Lines 1448-1454 sub ModReceiveOrder { Link Here
1448
        $order->{datereceived} = $datereceived;
1448
        $order->{datereceived} = $datereceived;
1449
        $order->{invoiceid} = $invoice->{invoiceid};
1449
        $order->{invoiceid} = $invoice->{invoiceid};
1450
        $order->{orderstatus} = 'complete';
1450
        $order->{orderstatus} = 'complete';
1451
        $new_ordernumber = Koha::Acquisition::Order->new($order)->insert->{ordernumber};
1451
        my @columns = Koha::Acquisition::Orders->columns;
1452
        my %filtered_order = map { exists $order->{$_} ? ($_ => $order->{$_}) : () } @columns;
1453
        $new_ordernumber = Koha::Acquisition::Order->new(\%filtered_order)->store->ordernumber;
1452
1454
1453
        if ($received_items) {
1455
        if ($received_items) {
1454
            foreach my $itemnumber (@$received_items) {
1456
            foreach my $itemnumber (@$received_items) {
Lines 1926-1932 sub TransferOrder { Link Here
1926
    delete $order->{parent_ordernumber};
1928
    delete $order->{parent_ordernumber};
1927
    $order->{'basketno'} = $basketno;
1929
    $order->{'basketno'} = $basketno;
1928
1930
1929
    my $newordernumber = Koha::Acquisition::Order->new($order)->insert->{ordernumber};
1931
    my @columns = Koha::Acquisition::Orders->columns;
1932
    my %filtered_order = map { exists $order->{$_} ? ($_ => $order->{$_}) : () } @columns;
1933
    my $newordernumber = Koha::Acquisition::Order->new(\%filtered_order)->store->ordernumber;
1930
1934
1931
    $query = q{
1935
    $query = q{
1932
        UPDATE aqorders_items
1936
        UPDATE aqorders_items
(-)a/Koha/Basket.pm (-3 / +3 lines)
Lines 1-4 Link Here
1
package Koha::Basket;
1
package Koha::Acquisition::Basket;
2
2
3
# This file is part of Koha.
3
# This file is part of Koha.
4
#
4
#
Lines 17-23 package Koha::Basket; Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Koha::Orders;
20
use Koha::Acquisition::Orders;
21
21
22
use base qw(Koha::Object);
22
use base qw(Koha::Object);
23
23
Lines 28-34 sub _type { Link Here
28
sub orders {
28
sub orders {
29
    my ($self) = @_;
29
    my ($self) = @_;
30
30
31
    $self->{_orders} ||= Koha::Orders->search({ basketno => $self->basketno });
31
    $self->{_orders} ||= Koha::Acquisition::Orders->search({ basketno => $self->basketno });
32
32
33
    return wantarray ? $self->{_orders}->as_list : $self->{_orders};
33
    return wantarray ? $self->{_orders}->as_list : $self->{_orders};
34
}
34
}
(-)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 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/Baskets.pm (-3 / +3 lines)
Lines 1-4 Link Here
1
package Koha::Baskets;
1
package Koha::Acquisition::Baskets;
2
2
3
# This file is part of Koha.
3
# This file is part of Koha.
4
#
4
#
Lines 17-23 package Koha::Baskets; Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Koha::Basket;
20
use Koha::Acquisition::Basket;
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::Basket';
29
    return 'Koha::Acquisition::Basket';
30
}
30
}
31
31
32
1;
32
1;
(-)a/Koha/Acquisition/Order.pm (-61 / +43 lines)
Lines 1-61 Link Here
1
package Koha::Acquisition::Order;
1
package Koha::Acquisition::Order;
2
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
3
use Modern::Perl;
18
use Modern::Perl;
19
use Carp qw( croak );
4
20
5
use Koha::Database;
21
use Koha::Database;
6
use Koha::DateUtils qw( dt_from_string output_pref );
22
use Koha::DateUtils qw( dt_from_string output_pref );
23
use Koha::Acquisition::Baskets;
7
24
8
use Carp qw( croak );
25
use base qw(Koha::Object);
9
10
use base qw( Class::Accessor );
11
12
# TODO fetch order from itemnumber (GetOrderFromItemnnumber)
13
# TODO Move code from GetOrder
14
sub fetch {
15
    my ( $class, $params ) = @_;
16
    my $ordernumber = $params->{ordernumber};
17
    return unless $ordernumber;
18
    my $schema = Koha::Database->new->schema;
19
26
20
    my $order =
27
sub store {
21
      $schema->resultset('Aqorder')->find( { ordernumber => $ordernumber },
22
        { result_class => 'DBIx::Class::ResultClass::HashRefInflator' } );
23
    return $class->new( $order );
24
}
25
26
sub insert {
27
    my ($self) = @_;
28
    my ($self) = @_;
28
29
29
    my $schema  = Koha::Database->new->schema;
30
    if ($self->basketno) {
30
    # Override quantity for standing orders
31
        my $basket = Koha::Acquisition::Baskets->find($self->basketno);
31
    $self->{quantity} = 1 if ( $self->{basketno} && $schema->resultset('Aqbasket')->find( $self->{basketno} )->is_standing );
32
        if ($basket->is_standing) {
33
            $self->quantity(1);
34
        }
35
    }
32
36
33
    # if these parameters are missing, we can't continue
37
    # if these parameters are missing, we can't continue
34
    for my $key (qw( basketno quantity biblionumber budget_id )) {
38
    for my $key (qw( basketno quantity biblionumber budget_id )) {
35
        croak "Cannot insert order: Mandatory parameter $key is missing"
39
        croak "Cannot insert order: Mandatory parameter $key is missing"
36
          unless $self->{$key};
40
          unless $self->${key};
37
    }
41
    }
38
42
39
    $self->{quantityreceived} ||= 0;
43
    unless ($self->quantityreceived) {
40
    $self->{entrydate} ||=
44
        $self->quantityreceived(0);
41
      output_pref( { dt => dt_from_string, dateformat => 'iso' } );
45
    }
42
43
    my @columns = $schema->source('Aqorder')->columns;
44
46
45
    $self->{ordernumber} ||= undef;
47
    unless ($self->entrydate) {
48
        $self->entrydate(output_pref( { dt => dt_from_string, dateformat => 'iso' } ));
49
    }
46
50
47
    my $rs = $schema->resultset('Aqorder')->create(
51
    $self = $self->SUPER::store($self);
48
        {
49
            map {
50
                exists $self->{$_} ? ( $_ => $self->{$_} ) : ()
51
            } @columns
52
        }
53
    );
54
    $self->{ordernumber} = $rs->id;
55
52
56
    unless ( $self->{parent_ordernumber} ) {
53
    if ($self && !$self->parent_ordernumber) {
57
        $self->{parent_ordernumber} = $self->{ordernumber};
54
        $self->parent_ordernumber($self->ordernumber);
58
        $rs->update( { parent_ordernumber => $self->{parent_ordernumber} } );
55
        $self = $self->SUPER::store($self);
59
    }
56
    }
60
57
61
    return $self;
58
    return $self;
Lines 63-95 sub insert { Link Here
63
60
64
sub add_item {
61
sub add_item {
65
    my ( $self, $itemnumber )  = @_;
62
    my ( $self, $itemnumber )  = @_;
63
66
    my $schema = Koha::Database->new->schema;
64
    my $schema = Koha::Database->new->schema;
67
    my $rs = $schema->resultset('AqordersItem');
65
    my $rs = $schema->resultset('AqordersItem');
68
    $rs->create({ ordernumber => $self->{ordernumber}, itemnumber => $itemnumber });
69
}
70
71
# TODO Move code from ModItemOrder
72
sub update_item {
73
    die "not implemented yet";
74
}
75
76
sub del_item {
77
    die "not implemented yet";
78
}
79
80
# TODO Move code from ModOrder
81
sub update {
82
    die "not implemented yet";
83
}
84
66
85
# TODO Move code from DelOrder
67
    $rs->create({
86
sub delete {
68
        ordernumber => $self->ordernumber,
87
    die "not implemented yet";
69
        itemnumber => $itemnumber,
70
    });
88
}
71
}
89
72
90
# TODO Move code from TransferOrder
73
sub _type {
91
sub transfer {
74
    return 'Aqorder';
92
    die "not implemented yet";
93
}
75
}
94
76
95
1;
77
1;
(-)a/Koha/Orders.pm (-3 / +3 lines)
Lines 1-4 Link Here
1
package Koha::Orders;
1
package Koha::Acquisition::Orders;
2
2
3
# This file is part of Koha.
3
# This file is part of Koha.
4
#
4
#
Lines 17-23 package Koha::Orders; Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Koha::Order;
20
use Koha::Acquisition::Order;
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::Order';
29
    return 'Koha::Acquisition::Order';
30
}
30
}
31
31
32
1;
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/acqui/addorder.pl (-1 / +1 lines)
Lines 286-292 if ( $basket->{is_standing} || $orderinfo->{quantity} ne '0' ) { Link Here
286
        ModOrderUsers( $orderinfo->{ordernumber}, @order_users );
286
        ModOrderUsers( $orderinfo->{ordernumber}, @order_users );
287
    }
287
    }
288
    else { # else, it's a new line
288
    else { # else, it's a new line
289
        $order->insert;
289
        $order->store;
290
    }
290
    }
291
291
292
    # now, add items if applicable
292
    # now, add items if applicable
(-)a/acqui/addorderiso2709.pl (-1 / +1 lines)
Lines 258-264 if ($op eq ""){ Link Here
258
            )
258
            )
259
        };
259
        };
260
260
261
        my $order = Koha::Acquisition::Order->new( \%orderinfo )->insert;
261
        my $order = Koha::Acquisition::Order->new( \%orderinfo )->store;
262
262
263
        # 4th, add items if applicable
263
        # 4th, add items if applicable
264
        # parse the item sent by the form, and create an item just for the import_record_id we are dealing with
264
        # parse the item sent by the form, and create an item just for the import_record_id we are dealing with
(-)a/acqui/finishreceive.pl (-1 / +2 lines)
Lines 32-37 use C4::Items; Link Here
32
use C4::Search;
32
use C4::Search;
33
33
34
use Koha::Acquisition::Booksellers;
34
use Koha::Acquisition::Booksellers;
35
use Koha::Acquisition::Orders;
35
36
36
use List::MoreUtils qw/any/;
37
use List::MoreUtils qw/any/;
37
38
Lines 131-137 if ($quantityrec > $origquantityrec ) { Link Here
131
            push @{$itemhash{$itemid[$i]}->{'ind_tag'}},$ind_tag[$i];
132
            push @{$itemhash{$itemid[$i]}->{'ind_tag'}},$ind_tag[$i];
132
            push @{$itemhash{$itemid[$i]}->{'indicator'}},$indicator[$i];
133
            push @{$itemhash{$itemid[$i]}->{'indicator'}},$indicator[$i];
133
        }
134
        }
134
        my $order = Koha::Acquisition::Order->fetch({ ordernumber => $new_ordernumber });
135
        my $order = Koha::Acquisition::Orders->find($new_ordernumber);
135
        foreach my $item (keys %itemhash){
136
        foreach my $item (keys %itemhash){
136
            my $xml = TransformHtmlToXml( $itemhash{$item}->{'tags'},
137
            my $xml = TransformHtmlToXml( $itemhash{$item}->{'tags'},
137
                                          $itemhash{$item}->{'subfields'},
138
                                          $itemhash{$item}->{'subfields'},
(-)a/admin/currency.pl (-3 / +2 lines)
Lines 26-31 use C4::Context; Link Here
26
use C4::Output;
26
use C4::Output;
27
27
28
use Koha::Acquisition::Booksellers;
28
use Koha::Acquisition::Booksellers;
29
use Koha::Acquisition::Orders;
29
use Koha::Acquisition::Currency;
30
use Koha::Acquisition::Currency;
30
use Koha::Acquisition::Currencies;
31
use Koha::Acquisition::Currencies;
31
32
Lines 92-100 if ( $op eq 'add_form' ) { Link Here
92
} elsif ( $op eq 'delete_confirm' ) {
93
} elsif ( $op eq 'delete_confirm' ) {
93
    my $currency = Koha::Acquisition::Currencies->find($currency_code);
94
    my $currency = Koha::Acquisition::Currencies->find($currency_code);
94
95
95
    # TODO rewrite the following when Koha::Acquisition::Orders will use Koha::Objects
96
    my $nb_of_orders = Koha::Acquisition::Orders->search->count;
96
    my $schema = Koha::Database->schema;
97
    my $nb_of_orders = $schema->resultset('Aqorder')->search( { currency => $currency->currency } )->count;
98
    my $nb_of_vendors = Koha::Acquisition::Booksellers->search( { -or => { listprice => $currency->currency, invoiceprice => $currency->currency } });
97
    my $nb_of_vendors = Koha::Acquisition::Booksellers->search( { -or => { listprice => $currency->currency, invoiceprice => $currency->currency } });
99
    $template->param(
98
    $template->param(
100
        currency     => $currency,
99
        currency     => $currency,
(-)a/t/db_dependent/Acquisition.t (-6 / +5 lines)
Lines 179-185 my @order_content = ( Link Here
179
            uncertainprice => 0,
179
            uncertainprice => 0,
180
            order_internalnote => "internal note",
180
            order_internalnote => "internal note",
181
            order_vendornote   => "vendor note",
181
            order_vendornote   => "vendor note",
182
            ordernumber => '',
183
        },
182
        },
184
        num => {
183
        num => {
185
            quantity  => 24,
184
            quantity  => 24,
Lines 187-193 my @order_content = ( Link Here
187
            ecost     => 38.15,
186
            ecost     => 38.15,
188
            rrp       => 40.15,
187
            rrp       => 40.15,
189
            discount  => 5.1111,
188
            discount  => 5.1111,
190
            tax_rate   => 0.0515
189
            tax_rate_on_ordering => 0.0515
191
        }
190
        }
192
    },
191
    },
193
    {
192
    {
Lines 215-221 my @order_content = ( Link Here
215
            ecost     => 38.1,
214
            ecost     => 38.1,
216
            rrp       => 11.0,
215
            rrp       => 11.0,
217
            discount  => 5.1,
216
            discount  => 5.1,
218
            tax_rate   => 0.1
217
            tax_rate_on_ordering   => 0.1
219
        }
218
        }
220
    },
219
    },
221
    {
220
    {
Lines 235-241 my @order_content = ( Link Here
235
            rrp            => 11.00,
234
            rrp            => 11.00,
236
            discount       => 0,
235
            discount       => 0,
237
            uncertainprice => 0,
236
            uncertainprice => 0,
238
            tax_rate        => 0
237
            tax_rate_on_ordering        => 0
239
        }
238
        }
240
    },
239
    },
241
    {
240
    {
Lines 255-261 my @order_content = ( Link Here
255
            rrp            => 10,
254
            rrp            => 10,
256
            discount       => 0,
255
            discount       => 0,
257
            uncertainprice => 0,
256
            uncertainprice => 0,
258
            tax_rate        => 0
257
            tax_rate_on_ordering        => 0
259
        }
258
        }
260
    }
259
    }
261
);
260
);
Lines 267-273 for ( 0 .. 4 ) { Link Here
267
      values %{ $order_content[$_]->{num} };
266
      values %{ $order_content[$_]->{num} };
268
    @ocontent{ keys %{ $order_content[$_]->{str} } } =
267
    @ocontent{ keys %{ $order_content[$_]->{str} } } =
269
      values %{ $order_content[$_]->{str} };
268
      values %{ $order_content[$_]->{str} };
270
    $ordernumbers[$_] = Koha::Acquisition::Order->new( \%ocontent )->insert->{ordernumber};
269
    $ordernumbers[$_] = Koha::Acquisition::Order->new( \%ocontent )->store->ordernumber;
271
    $order_content[$_]->{str}->{ordernumber} = $ordernumbers[$_];
270
    $order_content[$_]->{str}->{ordernumber} = $ordernumbers[$_];
272
}
271
}
273
272
(-)a/t/db_dependent/Acquisition/CancelReceipt.t (-10 / +10 lines)
Lines 74-86 my $order = Koha::Acquisition::Order->new( Link Here
74
        biblionumber => $biblionumber,
74
        biblionumber => $biblionumber,
75
        budget_id => $budget->{budget_id},
75
        budget_id => $budget->{budget_id},
76
    }
76
    }
77
)->insert;
77
)->store;
78
my $ordernumber = $order->{ordernumber};
78
my $ordernumber = $order->ordernumber;
79
79
80
ModReceiveOrder(
80
ModReceiveOrder(
81
    {
81
    {
82
        biblionumber     => $biblionumber,
82
        biblionumber     => $biblionumber,
83
        order            => $order,
83
        order            => $order->unblessed,
84
        quantityreceived => 2,
84
        quantityreceived => 2,
85
    }
85
    }
86
);
86
);
Lines 103-112 $order = Koha::Acquisition::Order->new( Link Here
103
        biblionumber => $biblionumber,
103
        biblionumber => $biblionumber,
104
        budget_id => $budget->{budget_id},
104
        budget_id => $budget->{budget_id},
105
    }
105
    }
106
)->insert;
106
)->store;
107
$ordernumber = $order->{ordernumber};
107
$ordernumber = $order->ordernumber;
108
108
109
is( $order->{parent_ordernumber}, $order->{ordernumber},
109
is( $order->parent_ordernumber, $order->ordernumber,
110
    "Insert an order should set parent_order=ordernumber, if no parent_ordernumber given"
110
    "Insert an order should set parent_order=ordernumber, if no parent_ordernumber given"
111
);
111
);
112
112
Lines 114-120 $order->add_item( $itemnumber1 ); Link Here
114
$order->add_item( $itemnumber2 );
114
$order->add_item( $itemnumber2 );
115
115
116
is(
116
is(
117
    scalar( GetItemnumbersFromOrder( $order->{ordernumber} ) ),
117
    scalar( GetItemnumbersFromOrder( $order->ordernumber ) ),
118
    2,
118
    2,
119
    "Create items on ordering: 2 items should be linked to the order before receiving"
119
    "Create items on ordering: 2 items should be linked to the order before receiving"
120
);
120
);
Lines 122-128 is( Link Here
122
my ( undef, $new_ordernumber ) = ModReceiveOrder(
122
my ( undef, $new_ordernumber ) = ModReceiveOrder(
123
    {
123
    {
124
        biblionumber     => $biblionumber,
124
        biblionumber     => $biblionumber,
125
        order            => $order,
125
        order            => $order->unblessed,
126
        quantityreceived => 1,
126
        quantityreceived => 1,
127
        received_items   => [ $itemnumber1 ],
127
        received_items   => [ $itemnumber1 ],
128
    }
128
    }
Lines 139-145 is( $new_order->{parent_ordernumber}, $ordernumber, Link Here
139
);
139
);
140
140
141
is(
141
is(
142
    scalar( GetItemnumbersFromOrder( $order->{ordernumber} ) ),
142
    scalar( GetItemnumbersFromOrder( $order->ordernumber ) ),
143
    1,
143
    1,
144
    "Create items on ordering: 1 item should still be linked to the original order after receiving"
144
    "Create items on ordering: 1 item should still be linked to the original order after receiving"
145
);
145
);
Lines 157-163 is( Link Here
157
    "Create items on ordering: no item should be linked to the cancelled order"
157
    "Create items on ordering: no item should be linked to the cancelled order"
158
);
158
);
159
is(
159
is(
160
    scalar( GetItemnumbersFromOrder( $order->{ordernumber} ) ),
160
    scalar( GetItemnumbersFromOrder( $order->ordernumber ) ),
161
    2,
161
    2,
162
    "Create items on ordering: items are not deleted after cancelling a receipt"
162
    "Create items on ordering: items are not deleted after cancelling a receipt"
163
);
163
);
(-)a/t/db_dependent/Acquisition/GetBasketsInfosByBookseller.t (-4 / +4 lines)
Lines 50-57 my $order1 = Koha::Acquisition::Order->new( Link Here
50
        biblionumber => $biblionumber1,
50
        biblionumber => $biblionumber1,
51
        budget_id => $budget->{budget_id},
51
        budget_id => $budget->{budget_id},
52
    }
52
    }
53
)->insert;
53
)->store;
54
my $ordernumber1 = $order1->{ordernumber};
54
my $ordernumber1 = $order1->ordernumber;
55
55
56
my $order2 = Koha::Acquisition::Order->new(
56
my $order2 = Koha::Acquisition::Order->new(
57
    {
57
    {
Lines 60-67 my $order2 = Koha::Acquisition::Order->new( Link Here
60
        biblionumber => $biblionumber2,
60
        biblionumber => $biblionumber2,
61
        budget_id => $budget->{budget_id},
61
        budget_id => $budget->{budget_id},
62
    }
62
    }
63
)->insert;
63
)->store;
64
my $ordernumber2 = $order2->{ordernumber};
64
my $ordernumber2 = $order2->ordernumber;
65
65
66
my $baskets = C4::Acquisition::GetBasketsInfosByBookseller( $supplierid );
66
my $baskets = C4::Acquisition::GetBasketsInfosByBookseller( $supplierid );
67
is( scalar(@$baskets), 1, 'Start: 1 basket' );
67
is( scalar(@$baskets), 1, 'Start: 1 basket' );
(-)a/t/db_dependent/Acquisition/GetOrdersByBiblionumber.t (-9 / +6 lines)
Lines 41-75 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,
48
        biblionumber => $biblionumber1,
48
        biblionumber => $biblionumber1,
49
        budget_id => $budget->{budget_id},
49
        budget_id => $budget->{budget_id},
50
    }
50
    }
51
)->insert;
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,
58
        biblionumber => $biblionumber2,
57
        biblionumber => $biblionumber2,
59
        budget_id => $budget->{budget_id},
58
        budget_id => $budget->{budget_id},
60
    }
59
    }
61
)->insert;
60
)->store;
62
my $ordernumber2 = $order1->{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,
68
        biblionumber => $biblionumber2,
66
        biblionumber => $biblionumber2,
69
        budget_id => $budget->{budget_id},
67
        budget_id => $budget->{budget_id},
70
    }
68
    }
71
)->insert;
69
)->store;
72
my $ordernumber3 = $order1->{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 (-15 / +22 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 61-68 my $order1 = Koha::Acquisition::Order->new( Link Here
61
        biblionumber => $biblionumber1,
71
        biblionumber => $biblionumber1,
62
        budget_id => $budget->{budget_id},
72
        budget_id => $budget->{budget_id},
63
    }
73
    }
64
)->insert;
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 71-78 my $order2 = Koha::Acquisition::Order->new( Link Here
71
        biblionumber => $biblionumber2,
80
        biblionumber => $biblionumber2,
72
        budget_id => $budget->{budget_id},
81
        budget_id => $budget->{budget_id},
73
    }
82
    }
74
)->insert;
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 83-90 my $order3 = Koha::Acquisition::Order->new( Link Here
83
        ecost => 42,
91
        ecost => 42,
84
        rrp => 42,
92
        rrp => 42,
85
    }
93
    }
86
)->insert;
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",
Lines 97-103 my $invoice2 = GetInvoice( $invoiceid2 ); Link Here
97
my ( $datereceived, $new_ordernumber ) = ModReceiveOrder(
104
my ( $datereceived, $new_ordernumber ) = ModReceiveOrder(
98
    {
105
    {
99
        biblionumber     => $biblionumber1,
106
        biblionumber     => $biblionumber1,
100
        order            => $order1,
107
        order            => $order1->unblessed,
101
        quantityreceived => 2,
108
        quantityreceived => 2,
102
        invoice          => $invoice1,
109
        invoice          => $invoice1,
103
    }
110
    }
Lines 106-112 my ( $datereceived, $new_ordernumber ) = ModReceiveOrder( Link Here
106
( $datereceived, $new_ordernumber ) = ModReceiveOrder(
113
( $datereceived, $new_ordernumber ) = ModReceiveOrder(
107
    {
114
    {
108
        biblionumber     => $biblionumber2,
115
        biblionumber     => $biblionumber2,
109
        order            => $order2,
116
        order            => $order2->unblessed,
110
        quantityreceived => 1,
117
        quantityreceived => 1,
111
        invoice          => $invoice2,
118
        invoice          => $invoice2,
112
        rrp              => 42
119
        rrp              => 42
Lines 116-122 my ( $datereceived, $new_ordernumber ) = ModReceiveOrder( Link Here
116
( $datereceived, $new_ordernumber ) = ModReceiveOrder(
123
( $datereceived, $new_ordernumber ) = ModReceiveOrder(
117
    {
124
    {
118
        biblionumber     => $biblionumber3,
125
        biblionumber     => $biblionumber3,
119
        order            => $order3,
126
        order            => $order3->unblessed,
120
        quantityreceived => 1,
127
        quantityreceived => 1,
121
        invoice          => $invoice2,
128
        invoice          => $invoice2,
122
    }
129
    }
(-)a/t/db_dependent/Acquisition/NewOrder.t (-8 / +8 lines)
Lines 10-16 use MARC::Record; Link Here
10
use Koha::Database;
10
use Koha::Database;
11
use Koha::DateUtils qw( dt_from_string output_pref );
11
use Koha::DateUtils qw( dt_from_string output_pref );
12
use Koha::Acquisition::Booksellers;
12
use Koha::Acquisition::Booksellers;
13
use Koha::Acquisition::Order;
13
use Koha::Acquisition::Orders;
14
14
15
my $schema = Koha::Database->new()->schema();
15
my $schema = Koha::Database->new()->schema();
16
$schema->storage->txn_begin();
16
$schema->storage->txn_begin();
Lines 44-50 my ($biblionumber2, $biblioitemnumber2) = AddBiblio(MARC::Record->new, ''); Link Here
44
44
45
45
46
# returns undef and croaks if basketno, quantity, biblionumber or budget_id is missing
46
# returns undef and croaks if basketno, quantity, biblionumber or budget_id is missing
47
my $order = eval { Koha::Acquisition::Order->new->insert };
47
my $order = eval { Koha::Acquisition::Order->new->store };
48
my $return_error = $@;
48
my $return_error = $@;
49
ok(
49
ok(
50
    ( ! defined $order )
50
    ( ! defined $order )
Lines 63-69 foreach my $mandatoryparams_key (@mandatoryparams_keys) { Link Here
63
    my %test_missing_mandatoryparams = %$mandatoryparams;
63
    my %test_missing_mandatoryparams = %$mandatoryparams;
64
    delete $test_missing_mandatoryparams{$mandatoryparams_key};
64
    delete $test_missing_mandatoryparams{$mandatoryparams_key};
65
    $order = eval {
65
    $order = eval {
66
          Koha::Acquisition::Order->new( \%test_missing_mandatoryparams )->insert;
66
          Koha::Acquisition::Order->new( \%test_missing_mandatoryparams )->store;
67
    };
67
    };
68
    $return_error = $@;
68
    $return_error = $@;
69
    my $expected_error = "Cannot insert order: Mandatory parameter $mandatoryparams_key is missing";
69
    my $expected_error = "Cannot insert order: Mandatory parameter $mandatoryparams_key is missing";
Lines 81-90 $order = Koha::Acquisition::Order->new( Link Here
81
        biblionumber => $biblionumber1,
81
        biblionumber => $biblionumber1,
82
        budget_id => $budget->{budget_id},
82
        budget_id => $budget->{budget_id},
83
    }
83
    }
84
)->insert;
84
)->store;
85
my $ordernumber = $order->{ordernumber};
85
my $ordernumber = $order->ordernumber;
86
$order = Koha::Acquisition::Order->fetch({ ordernumber => $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->insert 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 (-8 / +5 lines)
Lines 26-32 my $bookseller = Koha::Acquisition::Bookseller->new( Link Here
26
)->store;
26
)->store;
27
27
28
my ($biblionumber, $biblioitemnumber) = AddBiblio(MARC::Record->new, '');
28
my ($biblionumber, $biblioitemnumber) = AddBiblio(MARC::Record->new, '');
29
my $budgetid;
30
my $bpid = AddBudgetPeriod({
29
my $bpid = AddBudgetPeriod({
31
    budget_period_startdate   => '01-01-2015',
30
    budget_period_startdate   => '01-01-2015',
32
    budget_period_enddate     => '12-31-2015',
31
    budget_period_enddate     => '12-31-2015',
Lines 51-83 my $subscriptionid = NewSubscription( Link Here
51
);
50
);
52
die unless $subscriptionid;
51
die unless $subscriptionid;
53
52
54
my ($basket, $basketno);
53
my $basketno;
55
ok($basketno = NewBasket($bookseller->id, 1), "NewBasket(  " . $bookseller->id . ", 1  ) returns $basketno");
54
ok($basketno = NewBasket($bookseller->id, 1), "NewBasket(  " . $bookseller->id . ", 1  ) returns $basketno");
56
55
57
my $cost = 42.00;
56
my $cost = 42.00;
58
my $subscription = GetSubscription( $subscriptionid );
57
my $subscription = GetSubscription( $subscriptionid );
59
58
60
my $order = Koha::Acquisition::Order->new({
59
Koha::Acquisition::Order->new({
61
    biblionumber => $subscription->{biblionumber},
60
    biblionumber => $subscription->{biblionumber},
62
    entrydate => '01-01-2013',
61
    entrydate => '01-01-2013',
63
    quantity => 1,
62
    quantity => 1,
64
    currency => 'USD',
63
    currency => 'USD',
65
    listprice => $cost,
64
    listprice => $cost,
66
    notes => "This is a note",
67
    basketno => $basketno,
65
    basketno => $basketno,
68
    rrp => $cost,
66
    rrp => $cost,
69
    ecost => $cost,
67
    ecost => $cost,
70
    tax_rate => 0.0500,
68
    tax_rate_on_ordering => 0.0500,
71
    orderstatus => 'new',
69
    orderstatus => 'new',
72
    subscriptionid => $subscription->{subscriptionid},
70
    subscriptionid => $subscription->{subscriptionid},
73
    budget_id => $budget_id,
71
    budget_id => $budget_id,
74
})->insert;
72
})->store;
75
my $ordernumber = $order->{ordernumber};
76
73
77
my $is_currently_on_order = subscriptionCurrentlyOnOrder( $subscription->{subscriptionid} );
74
my $is_currently_on_order = subscriptionCurrentlyOnOrder( $subscription->{subscriptionid} );
78
is ( $is_currently_on_order, 1, "The subscription is currently on order");
75
is ( $is_currently_on_order, 1, "The subscription is currently on order");
79
76
80
$order = GetLastOrderNotReceivedFromSubscriptionid( $subscription->{subscriptionid} );
77
my $order = GetLastOrderNotReceivedFromSubscriptionid( $subscription->{subscriptionid} );
81
is ( $order->{subscriptionid}, $subscription->{subscriptionid}, "test subscriptionid for the last order not received");
78
is ( $order->{subscriptionid}, $subscription->{subscriptionid}, "test subscriptionid for the last order not received");
82
ok( $order->{ecost} == $cost, "test cost for the last order not received");
79
ok( $order->{ecost} == $cost, "test cost for the last order not received");
83
80
(-)a/t/db_dependent/Acquisition/OrderUsers.t (-10 / +8 lines)
Lines 5-11 use C4::Acquisition; Link Here
5
use C4::Biblio;
5
use C4::Biblio;
6
use C4::Letters;
6
use C4::Letters;
7
use Koha::Database;
7
use Koha::Database;
8
use Koha::Acquisition::Order;
8
use Koha::Acquisition::Orders;
9
use Koha::Acquisition::Booksellers;
9
use Koha::Acquisition::Booksellers;
10
10
11
use t::lib::TestBuilder;
11
use t::lib::TestBuilder;
Lines 38-44 my $budgetid = C4::Budgets::AddBudget( Link Here
38
);
38
);
39
my $budget = C4::Budgets::GetBudget($budgetid);
39
my $budget = C4::Budgets::GetBudget($budgetid);
40
40
41
my @ordernumbers;
42
my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio( MARC::Record->new, '' );
41
my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio( MARC::Record->new, '' );
43
42
44
my $order = Koha::Acquisition::Order->new(
43
my $order = Koha::Acquisition::Order->new(
Lines 49-63 my $order = Koha::Acquisition::Order->new( Link Here
49
        budget_id        => $budgetid,
48
        budget_id        => $budgetid,
50
        entrydate        => '01-01-2014',
49
        entrydate        => '01-01-2014',
51
        currency         => 'EUR',
50
        currency         => 'EUR',
52
        notes            => "This is a note1",
51
        tax_rate_on_ordering => 0.0500,
53
        gstrate          => 0.0500,
54
        orderstatus      => 1,
52
        orderstatus      => 1,
55
        quantityreceived => 0,
53
        quantityreceived => 0,
56
        rrp              => 10,
54
        rrp              => 10,
57
        ecost            => 10,
55
        ecost            => 10,
58
    }
56
    }
59
)->insert;
57
)->store;
60
my $ordernumber = $order->{ordernumber};
58
my $ordernumber = $order->ordernumber;
61
59
62
my $invoiceid = AddInvoice(
60
my $invoiceid = AddInvoice(
63
    invoicenumber => 'invoice',
61
    invoicenumber => 'invoice',
Lines 83-93 C4::Acquisition::ModOrderUsers( $ordernumber, $borrowernumber ); Link Here
83
my $is_added = grep { /^$borrowernumber$/ } C4::Acquisition::GetOrderUsers( $ordernumber );
81
my $is_added = grep { /^$borrowernumber$/ } C4::Acquisition::GetOrderUsers( $ordernumber );
84
is( $is_added, 1, 'ModOrderUsers should link patrons to an order' );
82
is( $is_added, 1, 'ModOrderUsers should link patrons to an order' );
85
83
86
$order = Koha::Acquisition::Order->fetch({ ordernumber => $ordernumber });
84
$order = Koha::Acquisition::Orders->find($ordernumber);
87
ModReceiveOrder(
85
ModReceiveOrder(
88
    {
86
    {
89
        biblionumber      => $biblionumber,
87
        biblionumber      => $biblionumber,
90
        order             => $order,
88
        order             => $order->unblessed,
91
        quantityreceived  => 1,
89
        quantityreceived  => 1,
92
        cost              => 10,
90
        cost              => 10,
93
        ecost             => 10,
91
        ecost             => 10,
Lines 100-110 ModReceiveOrder( Link Here
100
my $messages = C4::Letters::GetQueuedMessages({ borrowernumber => $borrowernumber });
98
my $messages = C4::Letters::GetQueuedMessages({ borrowernumber => $borrowernumber });
101
is( scalar( @$messages ), 0, 'The letter has not been sent to message queue on receiving the order, the order is not entire received');
99
is( scalar( @$messages ), 0, 'The letter has not been sent to message queue on receiving the order, the order is not entire received');
102
100
103
$order = Koha::Acquisition::Order->fetch({ ordernumber => $ordernumber });
101
$order = Koha::Acquisition::Orders->find($ordernumber);
104
ModReceiveOrder(
102
ModReceiveOrder(
105
    {
103
    {
106
        biblionumber      => $biblionumber,
104
        biblionumber      => $biblionumber,
107
        order             => $order,
105
        order             => $order->unblessed,
108
        quantityreceived  => 1,
106
        quantityreceived  => 1,
109
        cost              => 10,
107
        cost              => 10,
110
        ecost             => 10,
108
        ecost             => 10,
(-)a/t/db_dependent/Acquisition/StandingOrders.t (-15 / +14 lines)
Lines 8-14 use C4::Acquisition; Link Here
8
use C4::Biblio;
8
use C4::Biblio;
9
use C4::Items;
9
use C4::Items;
10
use C4::Budgets;
10
use C4::Budgets;
11
use Koha::Acquisition::Order;
11
use Koha::Acquisition::Orders;
12
use t::lib::Mocks;
12
use t::lib::Mocks;
13
use t::lib::TestBuilder;
13
use t::lib::TestBuilder;
14
14
Lines 72-82 my $ordernumber = Koha::Acquisition::Order->new( Link Here
72
        unitprice                => 12,
72
        unitprice                => 12,
73
        unitprice_tax_included   => 12,
73
        unitprice_tax_included   => 12,
74
        unitprice_tax_excluded   => 12,
74
        unitprice_tax_excluded   => 12,
75
        tax_rate                 => 0,
76
        tax_rate_on_ordering     => 0,
75
        tax_rate_on_ordering     => 0,
77
        tax_rate_on_receiving    => 0,
76
        tax_rate_on_receiving    => 0,
78
    }
77
    }
79
)->insert->{ordernumber};
78
)->store->ordernumber;
80
79
81
isnt( $ordernumber, undef, 'standing order successfully created' );
80
isnt( $ordernumber, undef, 'standing order successfully created' );
82
81
Lines 97-108 my $invoiceid = AddInvoice( Link Here
97
    unknown       => "unknown"
96
    unknown       => "unknown"
98
);
97
);
99
98
100
my $order = Koha::Acquisition::Order->fetch( { ordernumber => $ordernumber } );
99
my $order = Koha::Acquisition::Orders->find($ordernumber);
101
100
102
my ( $datereceived, $new_ordernumber ) = ModReceiveOrder(
101
my ( $datereceived, $new_ordernumber ) = ModReceiveOrder(
103
    {
102
    {
104
        biblionumber     => $biblionumber,
103
        biblionumber     => $biblionumber,
105
        order            => $order,
104
        order            => $order->unblessed,
106
        quantityreceived => 2,
105
        quantityreceived => 2,
107
        invoiceid        => $invoiceid,
106
        invoiceid        => $invoiceid,
108
    }
107
    }
Lines 111-126 my ( $datereceived, $new_ordernumber ) = ModReceiveOrder( Link Here
111
isnt( $ordernumber, $new_ordernumber, "standing order split on receive" );
110
isnt( $ordernumber, $new_ordernumber, "standing order split on receive" );
112
111
113
#order has been updated, refetch
112
#order has been updated, refetch
114
$order = Koha::Acquisition::Order->fetch( { ordernumber => $ordernumber } );
113
$order = Koha::Acquisition::Orders->find($ordernumber);
115
my $neworder = Koha::Acquisition::Order->fetch( { ordernumber => $new_ordernumber } );
114
my $neworder = Koha::Acquisition::Orders->find($new_ordernumber);
116
115
117
is( $order->{orderstatus}, 'partial', 'original order set to partially received' );
116
is( $order->orderstatus, 'partial', 'original order set to partially received' );
118
is( $order->{quantity}, 1, 'original order quantity unchanged' );
117
is( $order->quantity, 1, 'original order quantity unchanged' );
119
is( $order->{quantityreceived}, 0, 'original order has no received items' );
118
is( $order->quantityreceived, 0, 'original order has no received items' );
120
isnt( $order->{unitprice}, 12, 'original order does not get cost' );
119
isnt( $order->unitprice, 12, 'original order does not get cost' );
121
is( $neworder->{orderstatus}, 'complete', 'new order set to complete' );
120
is( $neworder->orderstatus, 'complete', 'new order set to complete' );
122
is( $neworder->{quantityreceived}, 2, 'new order has received items' );
121
is( $neworder->quantityreceived, 2, 'new order has received items' );
123
cmp_ok( $neworder->{unitprice}, '==', 12, 'new order does get cost' );
122
cmp_ok( $neworder->unitprice, '==', 12, 'new order does get cost' );
124
123
125
$search_orders = SearchOrders( {
124
$search_orders = SearchOrders( {
126
    basketno => $basketno,
125
    basketno => $basketno,
(-)a/t/db_dependent/Acquisition/TransferOrder.t (-2 / +2 lines)
Lines 65-72 my $order = Koha::Acquisition::Order->new( Link Here
65
        biblionumber => $biblionumber,
65
        biblionumber => $biblionumber,
66
        budget_id => $budget->{budget_id},
66
        budget_id => $budget->{budget_id},
67
    }
67
    }
68
)->insert;
68
)->store;
69
my $ordernumber = $order->{ordernumber};
69
my $ordernumber = $order->ordernumber;
70
$order->add_item( $itemnumber );
70
$order->add_item( $itemnumber );
71
71
72
# Begin tests
72
# Begin tests
(-)a/t/db_dependent/Acquisition/close_reopen_basket.t (-6 / +4 lines)
Lines 47-71 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,
54
        biblionumber => $biblionumber1,
54
        biblionumber => $biblionumber1,
55
        budget_id => $budget->{budget_id},
55
        budget_id => $budget->{budget_id},
56
    }
56
    }
57
)->insert;
57
)->store;
58
my $ordernumber1 = $order1->{ordernumber};
59
58
60
my $order2 = Koha::Acquisition::Order->new(
59
Koha::Acquisition::Order->new(
61
    {
60
    {
62
        basketno => $basketno,
61
        basketno => $basketno,
63
        quantity => 42,
62
        quantity => 42,
64
        biblionumber => $biblionumber2,
63
        biblionumber => $biblionumber2,
65
        budget_id => $budget->{budget_id},
64
        budget_id => $budget->{budget_id},
66
    }
65
    }
67
)->insert;
66
)->store;
68
my $ordernumber2 = $order2->{ordernumber};
69
67
70
my $nb_biblio = C4::Acquisition::GetBiblioCountByBasketno( $basketno );
68
my $nb_biblio = C4::Acquisition::GetBiblioCountByBasketno( $basketno );
71
is ( $nb_biblio, 2, "There are 2 biblio for this basket" );
69
is ( $nb_biblio, 2, "There are 2 biblio for this basket" );
(-)a/t/db_dependent/Bookseller.t (-20 / +12 lines)
Lines 343-349 is(scalar(@subscriptions), 1, 'search for subscriptions by call number'); Link Here
343
is(scalar(@subscriptions), 1, 'search for subscriptions by location');
343
is(scalar(@subscriptions), 1, 'search for subscriptions by location');
344
344
345
#Add 4 orders
345
#Add 4 orders
346
my $order1 = Koha::Acquisition::Order->new(
346
Koha::Acquisition::Order->new(
347
    {
347
    {
348
        basketno         => $basketno1,
348
        basketno         => $basketno1,
349
        quantity         => 24,
349
        quantity         => 24,
Lines 351-358 my $order1 = Koha::Acquisition::Order->new( Link Here
351
        budget_id        => $id_budget,
351
        budget_id        => $id_budget,
352
        entrydate        => '01-01-2013',
352
        entrydate        => '01-01-2013',
353
        currency         => 'EUR',
353
        currency         => 'EUR',
354
        notes            => "This is a note1",
354
        tax_rate_on_ordering          => 0.0500,
355
        tax_rate          => 0.0500,
356
        orderstatus      => 1,
355
        orderstatus      => 1,
357
        subscriptionid   => $id_subscription1,
356
        subscriptionid   => $id_subscription1,
358
        quantityreceived => 2,
357
        quantityreceived => 2,
Lines 360-369 my $order1 = Koha::Acquisition::Order->new( Link Here
360
        ecost            => 10,
359
        ecost            => 10,
361
        datereceived     => '01-06-2013'
360
        datereceived     => '01-06-2013'
362
    }
361
    }
363
)->insert;
362
)->store;
364
my $ordernumber1 = $order1->{ordernumber};
365
363
366
my $order2 = Koha::Acquisition::Order->new(
364
Koha::Acquisition::Order->new(
367
    {
365
    {
368
        basketno       => $basketno2,
366
        basketno       => $basketno2,
369
        quantity       => 20,
367
        quantity       => 20,
Lines 371-387 my $order2 = Koha::Acquisition::Order->new( Link Here
371
        budget_id      => $id_budget,
369
        budget_id      => $id_budget,
372
        entrydate      => '01-01-2013',
370
        entrydate      => '01-01-2013',
373
        currency       => 'EUR',
371
        currency       => 'EUR',
374
        notes          => "This is a note2",
372
        tax_rate_on_ordering        => 0.0500,
375
        tax_rate        => 0.0500,
376
        orderstatus    => 1,
373
        orderstatus    => 1,
377
        subscriptionid => $id_subscription2,
374
        subscriptionid => $id_subscription2,
378
        rrp            => 10,
375
        rrp            => 10,
379
        ecost          => 10,
376
        ecost          => 10,
380
    }
377
    }
381
)->insert;
378
)->store;
382
my $ordernumber2 = $order2->{ordernumber};
383
379
384
my $order3 = Koha::Acquisition::Order->new(
380
Koha::Acquisition::Order->new(
385
    {
381
    {
386
        basketno       => $basketno3,
382
        basketno       => $basketno3,
387
        quantity       => 20,
383
        quantity       => 20,
Lines 389-405 my $order3 = Koha::Acquisition::Order->new( Link Here
389
        budget_id      => $id_budget,
385
        budget_id      => $id_budget,
390
        entrydate      => '02-02-2013',
386
        entrydate      => '02-02-2013',
391
        currency       => 'EUR',
387
        currency       => 'EUR',
392
        notes          => "This is a note3",
388
        tax_rate_on_ordering        => 0.0500,
393
        tax_rate        => 0.0500,
394
        orderstatus    => 2,
389
        orderstatus    => 2,
395
        subscriptionid => $id_subscription3,
390
        subscriptionid => $id_subscription3,
396
        rrp            => 11,
391
        rrp            => 11,
397
        ecost          => 11,
392
        ecost          => 11,
398
    }
393
    }
399
)->insert;
394
)->store;
400
my $ordernumber3 = $order3->{ordernumber};
401
395
402
my $order4 = Koha::Acquisition::Order->new(
396
Koha::Acquisition::Order->new(
403
    {
397
    {
404
        basketno         => $basketno4,
398
        basketno         => $basketno4,
405
        quantity         => 20,
399
        quantity         => 20,
Lines 407-422 my $order4 = Koha::Acquisition::Order->new( Link Here
407
        budget_id        => $id_budget,
401
        budget_id        => $id_budget,
408
        entrydate        => '02-02-2013',
402
        entrydate        => '02-02-2013',
409
        currency         => 'EUR',
403
        currency         => 'EUR',
410
        notes            => "This is a note3",
404
        tax_rate_on_ordering          => 0.0500,
411
        tax_rate          => 0.0500,
412
        orderstatus      => 2,
405
        orderstatus      => 2,
413
        subscriptionid   => $id_subscription3,
406
        subscriptionid   => $id_subscription3,
414
        rrp              => 11,
407
        rrp              => 11,
415
        ecost            => 11,
408
        ecost            => 11,
416
        quantityreceived => 20
409
        quantityreceived => 20
417
    }
410
    }
418
)->insert;
411
)->store;
419
my $ordernumber4 = $order4->{ordernumber};
420
412
421
#Test cases:
413
#Test cases:
422
# Sample datas :
414
# Sample datas :
(-)a/t/db_dependent/Budgets.t (-8 / +7 lines)
Lines 332-346 for my $infos (@order_infos) { Link Here
332
                order_internalnote => "internal note",
332
                order_internalnote => "internal note",
333
                order_vendornote   => "vendor note",
333
                order_vendornote   => "vendor note",
334
                quantity           => 2,
334
                quantity           => 2,
335
                cost_tax_included  => $item_price,
335
                ecost_tax_included => $item_price,
336
                rrp_tax_included   => $item_price,
336
                rrp_tax_included   => $item_price,
337
                listprice          => $item_price,
337
                listprice          => $item_price,
338
                ecost_tax_include  => $item_price,
338
                ecost_tax_included => $item_price,
339
                discount           => 0,
339
                discount           => 0,
340
                uncertainprice     => 0,
340
                uncertainprice     => 0,
341
            }
341
            }
342
        )->insert;
342
        )->store;
343
        my $ordernumber = $order->{ordernumber};
343
        my $ordernumber = $order->ordernumber;
344
        push @{ $budgets{$infos->{budget_id}} }, $ordernumber;
344
        push @{ $budgets{$infos->{budget_id}} }, $ordernumber;
345
        $number_of_orders_to_move++;
345
        $number_of_orders_to_move++;
346
    }
346
    }
Lines 353-370 for my $infos (@order_infos) { Link Here
353
                order_internalnote => "internal note",
353
                order_internalnote => "internal note",
354
                order_vendornote   => "vendor note",
354
                order_vendornote   => "vendor note",
355
                quantity           => $item_quantity,
355
                quantity           => $item_quantity,
356
                cost               => $item_price,
356
                ecost              => $item_price,
357
                rrp_tax_included   => $item_price,
357
                rrp_tax_included   => $item_price,
358
                listprice          => $item_price,
358
                listprice          => $item_price,
359
                ecost_tax_included => $item_price,
359
                ecost_tax_included => $item_price,
360
                discount           => 0,
360
                discount           => 0,
361
                uncertainprice     => 0,
361
                uncertainprice     => 0,
362
            }
362
            }
363
        )->insert;
363
        )->store;
364
        my $ordernumber = $order->{ordernumber};
365
        ModReceiveOrder({
364
        ModReceiveOrder({
366
              biblionumber     => $biblionumber,
365
              biblionumber     => $biblionumber,
367
              order            => $order,
366
              order            => $order->unblessed,
368
              budget_id        => $infos->{budget_id},
367
              budget_id        => $infos->{budget_id},
369
              quantityreceived => $item_quantity,
368
              quantityreceived => $item_quantity,
370
              invoice          => $invoice,
369
              invoice          => $invoice,
(-)a/t/db_dependent/Letters.t (-3 / +2 lines)
Lines 405-412 my $order = Koha::Acquisition::Order->new( Link Here
405
        biblionumber => $biblionumber,
405
        biblionumber => $biblionumber,
406
        budget_id => $budgetid,
406
        budget_id => $budgetid,
407
    }
407
    }
408
)->insert;
408
)->store;
409
my $ordernumber = $order->{ordernumber};
409
my $ordernumber = $order->ordernumber;
410
410
411
C4::Acquisition::CloseBasket( $basketno );
411
C4::Acquisition::CloseBasket( $basketno );
412
my $err;
412
my $err;
413
- 

Return to bug 11708