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

(-)a/C4/Acquisition.pm (-10 / +10 lines)
Lines 31-37 use C4::Debug; Link Here
31
use C4::Templates qw(gettemplate);
31
use C4::Templates qw(gettemplate);
32
use Koha::DateUtils qw( dt_from_string output_pref );
32
use Koha::DateUtils qw( dt_from_string output_pref );
33
use Koha::Acquisition::Order;
33
use Koha::Acquisition::Order;
34
use Koha::Acquisition::Bookseller;
34
use Koha::Acquisition::Booksellers;
35
use Koha::Number::Price;
35
use Koha::Number::Price;
36
36
37
use Time::localtime;
37
use Time::localtime;
Lines 363-375 sub GetBasketGroupAsCSV { Link Here
363
        my $contract   = GetContract({
363
        my $contract   = GetContract({
364
            contractnumber => $basket->{contractnumber}
364
            contractnumber => $basket->{contractnumber}
365
        });
365
        });
366
        my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $basket->{booksellerid} });
366
        my $bookseller = Koha::Acquisition::Booksellers->find( $basket->{booksellerid} );
367
        my $basketgroup = GetBasketgroup( $$basket{basketgroupid} );
367
        my $basketgroup = GetBasketgroup( $$basket{basketgroupid} );
368
368
369
        foreach my $order (@orders) {
369
        foreach my $order (@orders) {
370
            my $bd = GetBiblioData( $order->{'biblionumber'} );
370
            my $bd = GetBiblioData( $order->{'biblionumber'} );
371
            my $row = {
371
            my $row = {
372
                clientnumber => $bookseller->{accountnumber},
372
                clientnumber => $bookseller->accountnumber,
373
                basketname => $basket->{basketname},
373
                basketname => $basket->{basketname},
374
                ordernumber => $order->{ordernumber},
374
                ordernumber => $order->{ordernumber},
375
                author => $bd->{author},
375
                author => $bd->{author},
Lines 381-394 sub GetBasketGroupAsCSV { Link Here
381
                quantity => $order->{quantity},
381
                quantity => $order->{quantity},
382
                rrp_tax_included => $order->{rrp_tax_included},
382
                rrp_tax_included => $order->{rrp_tax_included},
383
                rrp_tax_excluded => $order->{rrp_tax_excluded},
383
                rrp_tax_excluded => $order->{rrp_tax_excluded},
384
                discount => $bookseller->{discount},
384
                discount => $bookseller->discount,
385
                ecost_tax_included => $order->{ecost_tax_included},
385
                ecost_tax_included => $order->{ecost_tax_included},
386
                ecost_tax_excluded => $order->{ecost_tax_excluded},
386
                ecost_tax_excluded => $order->{ecost_tax_excluded},
387
                notes => $order->{order_vendornote},
387
                notes => $order->{order_vendornote},
388
                entrydate => $order->{entrydate},
388
                entrydate => $order->{entrydate},
389
                booksellername => $bookseller->{name},
389
                booksellername => $bookseller->name,
390
                bookselleraddress => $bookseller->{address1},
390
                bookselleraddress => $bookseller->address1,
391
                booksellerpostal => $bookseller->{postal},
391
                booksellerpostal => $bookseller->postal,
392
                contractnumber => $contract->{contractnumber},
392
                contractnumber => $contract->{contractnumber},
393
                contractname => $contract->{contractname},
393
                contractname => $contract->{contractname},
394
                basketgroupdeliveryplace => C4::Branch::GetBranchName( $basketgroup->{deliveryplace} ),
394
                basketgroupdeliveryplace => C4::Branch::GetBranchName( $basketgroup->{deliveryplace} ),
Lines 2842-2848 sub populate_order_with_prices { Link Here
2842
    my $booksellerid = $params->{booksellerid};
2842
    my $booksellerid = $params->{booksellerid};
2843
    return unless $booksellerid;
2843
    return unless $booksellerid;
2844
2844
2845
    my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
2845
    my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
2846
2846
2847
    my $receiving = $params->{receiving};
2847
    my $receiving = $params->{receiving};
2848
    my $ordering  = $params->{ordering};
2848
    my $ordering  = $params->{ordering};
Lines 2851-2857 sub populate_order_with_prices { Link Here
2851
2851
2852
    if ($ordering) {
2852
    if ($ordering) {
2853
        $order->{tax_rate_on_ordering} //= $order->{tax_rate};
2853
        $order->{tax_rate_on_ordering} //= $order->{tax_rate};
2854
        if ( $bookseller->{listincgst} ) {
2854
        if ( $bookseller->listincgst ) {
2855
            # The user entered the rrp tax included
2855
            # The user entered the rrp tax included
2856
            $order->{rrp_tax_included} = $order->{rrp};
2856
            $order->{rrp_tax_included} = $order->{rrp};
2857
2857
Lines 2887-2893 sub populate_order_with_prices { Link Here
2887
2887
2888
    if ($receiving) {
2888
    if ($receiving) {
2889
        $order->{tax_rate_on_receiving} //= $order->{tax_rate};
2889
        $order->{tax_rate_on_receiving} //= $order->{tax_rate};
2890
        if ( $bookseller->{invoiceincgst} ) {
2890
        if ( $bookseller->invoiceincgst ) {
2891
            # Trick for unitprice. If the unit price rounded value is the same as the ecost rounded value
2891
            # Trick for unitprice. If the unit price rounded value is the same as the ecost rounded value
2892
            # we need to keep the exact ecost value
2892
            # we need to keep the exact ecost value
2893
            if ( Koha::Number::Price->new( $order->{unitprice} )->round == Koha::Number::Price->new( $order->{ecost_tax_included} )->round ) {
2893
            if ( Koha::Number::Price->new( $order->{unitprice} )->round == Koha::Number::Price->new( $order->{ecost_tax_included} )->round ) {
(-)a/C4/Bookseller.pm (-136 lines)
Lines 29-37 use C4::Bookseller::Contact; Link Here
29
our $VERSION   = 3.07.00.049;
29
our $VERSION   = 3.07.00.049;
30
our @EXPORT_OK = qw(
30
our @EXPORT_OK = qw(
31
  GetBooksellersWithLateOrders
31
  GetBooksellersWithLateOrders
32
  ModBookseller
33
  DelBookseller
34
  AddBookseller
35
);
32
);
36
33
37
=head1 NAME
34
=head1 NAME
Lines 115-253 sub GetBooksellersWithLateOrders { Link Here
115
    return %supplierlist;
112
    return %supplierlist;
116
}
113
}
117
114
118
#--------------------------------------------------------------------#
119
120
=head2 AddBookseller
121
122
$id = &AddBookseller($bookseller);
123
124
Creates a new bookseller. C<$bookseller> is a reference-to-hash whose
125
keys are the fields of the aqbooksellers table in the Koha database.
126
All fields must be present.
127
128
Returns the ID of the newly-created bookseller.
129
130
=cut
131
132
sub AddBookseller {
133
    my ($data, $contacts) = @_;
134
    my $dbh    = C4::Context->dbh;
135
    my $query = q|
136
        INSERT INTO aqbooksellers
137
            (
138
                name,      address1,      address2,     address3, address4,
139
                postal,    phone,         accountnumber,fax,      url,
140
                active,    listprice,     invoiceprice, gstreg,
141
                listincgst,invoiceincgst, tax_rate,      discount, notes,
142
                deliverytime
143
            )
144
        VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) |
145
      ;
146
    my $sth = $dbh->prepare($query);
147
    $sth->execute(
148
        $data->{'name'},         $data->{'address1'},
149
        $data->{'address2'},     $data->{'address3'},
150
        $data->{'address4'},     $data->{'postal'},
151
        $data->{'phone'},        $data->{'accountnumber'},
152
        $data->{'fax'},          $data->{'url'},
153
        $data->{'active'},       $data->{'listprice'},
154
        $data->{'invoiceprice'}, $data->{'gstreg'},
155
        $data->{'listincgst'},   $data->{'invoiceincgst'},
156
        $data->{'tax_rate'},      $data->{'discount'},
157
        $data->{notes},          $data->{deliverytime},
158
    );
159
160
    # return the id of this new supplier
161
    my $id = $dbh->{'mysql_insertid'};
162
    if ($id && $contacts) {
163
        foreach my $contact (@$contacts) {
164
            $contact = C4::Bookseller::Contact->new( $contact )
165
                unless ref $contacts eq 'C4::Bookseller::Contact';
166
            $contact->bookseller($id);
167
            $contact->save();
168
        }
169
    }
170
    return $id;
171
}
172
173
#-----------------------------------------------------------------#
174
175
=head2 ModBookseller
176
177
ModBookseller($bookseller);
178
179
Updates the information for a given bookseller. C<$bookseller> is a
180
reference-to-hash whose keys are the fields of the aqbooksellers table
181
in the Koha database. It must contain entries for all of the fields.
182
The entry to modify is determined by C<$bookseller-E<gt>{id}>.
183
184
The easiest way to get all of the necessary fields is to look up a
185
book seller with C<Koha::Acquisition::Bookseller>, modify what's necessary, then call
186
C<&ModBookseller> with the result.
187
188
=cut
189
190
sub ModBookseller {
191
    my ($data, $contacts) = @_;
192
    my $dbh    = C4::Context->dbh;
193
    return unless $data->{'id'};
194
    my $query  = 'UPDATE aqbooksellers
195
        SET name=?,address1=?,address2=?,address3=?,address4=?,
196
            postal=?,phone=?,accountnumber=?,fax=?,url=?,
197
            active=?,listprice=?, invoiceprice=?,
198
            gstreg=?,listincgst=?,invoiceincgst=?,
199
            discount=?,notes=?,tax_rate=?,deliverytime=?
200
        WHERE id=?';
201
    my $sth = $dbh->prepare($query);
202
    my $cnt = $sth->execute(
203
        $data->{'name'},         $data->{'address1'},
204
        $data->{'address2'},     $data->{'address3'},
205
        $data->{'address4'},     $data->{'postal'},
206
        $data->{'phone'},        $data->{'accountnumber'},
207
        $data->{'fax'},          $data->{'url'},
208
        $data->{'active'},       $data->{'listprice'},
209
        $data->{'invoiceprice'}, $data->{'gstreg'},
210
        $data->{'listincgst'},   $data->{'invoiceincgst'},
211
        $data->{'discount'},     $data->{'notes'},
212
        $data->{'tax_rate'},      $data->{deliverytime},
213
        $data->{'id'}
214
    );
215
    $contacts ||= $data->{'contacts'};
216
    my $contactquery = "DELETE FROM aqcontacts WHERE booksellerid = ?";
217
    my @contactparams = ($data->{'id'});
218
    if ($contacts) {
219
        foreach my $contact (@$contacts) {
220
            $contact = C4::Bookseller::Contact->new( $contact )
221
                unless ref $contacts eq 'C4::Bookseller::Contact';
222
            $contact->bookseller($data->{'id'});
223
            $contact->save();
224
            push @contactparams, $contact->id if $contact->id;
225
        }
226
        if ($#contactparams > 0) {
227
            $contactquery .= ' AND id NOT IN (' . ('?, ' x ($#contactparams - 1)) . '?);';
228
        }
229
    }
230
    $sth = $dbh->prepare($contactquery);
231
    $sth->execute(@contactparams);
232
    return $cnt;
233
}
234
235
=head2 DelBookseller
236
237
DelBookseller($booksellerid);
238
239
delete the supplier record identified by $booksellerid
240
This sub assumes it is called only if the supplier has no order.
241
242
=cut
243
244
sub DelBookseller {
245
    my $id  = shift;
246
    my $dbh = C4::Context->dbh;
247
    my $sth = $dbh->prepare('DELETE FROM aqbooksellers WHERE id=?');
248
    return $sth->execute($id);
249
}
250
251
1;
115
1;
252
116
253
__END__
117
__END__
(-)a/Koha/Acquisition/Bookseller.pm (-94 / +23 lines)
Lines 3-124 package Koha::Acquisition::Bookseller; Link Here
3
use Modern::Perl;
3
use Modern::Perl;
4
4
5
use Koha::Database;
5
use Koha::Database;
6
use Koha::DateUtils qw( dt_from_string output_pref );
7
8
use Carp qw( croak );
9
6
10
use base qw( Class::Accessor );
7
use base qw( Koha::Object );
11
8
12
use C4::Bookseller::Contact;
9
use Koha::DateUtils qw( dt_from_string output_pref );
13
14
sub fetch {
15
    my ( $class, $params ) = @_;
16
    my $id = $params->{id};
17
    return unless $id;
18
    my $schema = Koha::Database->new->schema;
19
20
    my $bookseller =
21
      $schema->resultset('Aqbookseller')->find( { id => $id },
22
        { result_class => 'DBIx::Class::ResultClass::HashRefInflator' } );
23
24
    return unless $bookseller;
25
26
    my $self = $class->new( $bookseller );
27
    $self->contacts; # TODO: This should be generated on demand.
28
    return $self;
29
}
30
31
sub search {
32
    my ( $class, $params ) = @_;
33
34
    croak "Cannot search on other fields than aqbooksellers.name" if $params and grep { $_ !~ /^name$/ } keys %$params;
35
36
    my $schema = Koha::Database->new->schema;
37
38
    my $search_params;
39
    while ( my ( $field, $value ) = each %$params ) {
40
        if ( $field eq 'name' ) {
41
            # Use "like" if search on name
42
            $search_params->{name} = { -like => "%$value%" };
43
        } else {
44
            $search_params->{$field} = $value;
45
        }
46
    }
47
    my $rs = $schema->resultset('Aqbookseller')->search(
48
        $search_params,
49
        { order_by => 'name' }
50
    );
51
52
    my @booksellers;
53
    while ( my $b = $rs->next ) {
54
        my $t = Koha::Acquisition::Bookseller->fetch({ id => $b->id });
55
        push @booksellers, $t;
56
    }
57
    return @booksellers;
58
}
59
10
60
sub basket_count {
11
use Carp qw( croak );
61
    my ( $self ) = @_;
62
    my $schema = Koha::Database->new->schema;
63
12
64
    return $schema->resultset('Aqbasket')->count( { booksellerid => $self->{id} });
13
use Koha::Acquisition::Bookseller::Contact;
65
}
14
use Koha::Acquisition::Bookseller::Contacts;
66
15
67
sub subscription_count {
16
sub baskets {
68
    my ( $self ) = @_;
17
    my ( $self ) = @_;
69
18
    return $self->{_result}->aqbaskets;
70
    my $schema = Koha::Database->new->schema;
71
72
    return $schema->resultset('Subscription')->count( { aqbooksellerid => $self->{id} });
73
}
19
}
74
20
75
sub contacts {
21
sub contacts {
76
    my ( $self ) = @_;
22
    my ( $self ) = @_;
77
23
78
    return $self->{contacts} if $self->{contacts};
24
    $self->{contacts} = Koha::Acquisition::Bookseller::Contacts->search( { booksellerid => $self->id } );
79
    $self->{contacts} = C4::Bookseller::Contact->get_from_bookseller($self->{id});
80
    return $self->{contacts};
25
    return $self->{contacts};
81
}
26
}
82
27
83
sub insert {
28
sub store {
84
    my ($self) = @_;
29
    my ( $self ) = @_;
85
86
    # if these parameters are missing, we can't continue
87
    for my $key (qw( id )) {
88
        croak "Cannot insert bookseller: Mandatory parameter $key is missing"
89
          unless $self->{$key};
90
    }
91
30
92
    $self->{quantityreceived} ||= 0;
31
    if ( $self->{contacts} ) {
93
    $self->{entrydate} ||=
32
        $self->{contacts}->reset;
94
      output_pref( { dt => dt_from_string, dateformat => 'iso' } );
33
        while ( my $contact = $self->{contacts}->next ) {
95
34
            $contact->store;
96
    my $schema  = Koha::Database->new->schema;
97
    my @columns = $schema->source('Aqorder')->columns;
98
    my $rs = $schema->resultset('Aqorder')->create(
99
        {
100
            map {
101
                exists $self->{$_} ? ( $_ => $self->{$_} ) : ()
102
            } @columns
103
        }
35
        }
104
    );
105
    $self->{ordernumber} = $rs->id;
106
107
    unless ( $self->{parent_ordernumber} ) {
108
        $rs->update( { parent_ordernumber => $self->{ordernumber} } );
109
    }
36
    }
110
37
111
    return $self;
38
    return $self->SUPER::store;
112
}
39
}
113
40
114
# TODO Move code from ModBookseller
41
sub subscriptions {
115
sub update {
42
    my ( $self ) = @_;
116
    die "not implemented yet";
43
44
    my $schema = Koha::Database->new->schema;
45
46
    return $schema->resultset('Subscription')->search( { aqbooksellerid => $self->id } );
117
}
47
}
118
48
119
# TODO Move code from DelBookseller
49
sub type {
120
sub delete {
50
    return 'Aqbookseller';
121
    die "not implemented yet";
122
}
51
}
123
52
124
1;
53
1;
(-)a/Koha/Acquisition/Bookseller/Contact.pm (+13 lines)
Line 0 Link Here
1
package Koha::Acquisition::Bookseller::Contact;
2
3
use Modern::Perl;
4
5
use base qw( Koha::Object );
6
7
use Carp qw( croak );
8
9
sub type {
10
    return 'Aqcontact';
11
}
12
13
1;
(-)a/Koha/Acquisition/Bookseller/Contacts.pm (+17 lines)
Line 0 Link Here
1
package Koha::Acquisition::Bookseller::Contacts;
2
3
use Modern::Perl;
4
5
use Carp;
6
7
use base qw( Koha::Objects );
8
9
sub type {
10
    return 'Aqcontact';
11
}
12
13
sub object_class {
14
    return 'Koha::Acquisition::Bookseller::Contact';
15
}
16
17
1;
(-)a/Koha/Acquisition/Booksellers.pm (+37 lines)
Line 0 Link Here
1
package Koha::Acquisition::Booksellers;
2
3
use Modern::Perl;
4
5
use Carp;
6
7
use Koha::Database;
8
9
use base qw( Koha::Objects );
10
11
use Koha::Acquisition::Bookseller;
12
13
sub search {
14
    my ( $self, $params, $attributes ) = @_;
15
16
17
    while ( my ( $field, $value ) = each %$params ) {
18
        if ( $field eq 'name' ) {
19
            # Use "like" if search on name
20
            $params->{name} = { -like => "%$value%" };
21
        }
22
    }
23
24
    $attributes->{order_by} ||= { -asc => 'name' };
25
26
    return $self->SUPER::search( $params, $attributes );
27
}
28
29
sub type {
30
    return 'Aqbookseller';
31
}
32
33
sub object_class {
34
    return 'Koha::Acquisition::Bookseller';
35
}
36
37
1;
(-)a/Koha/Object.pm (+5 lines)
Lines 238-243 sub _columns { Link Here
238
    return $self->{_columns};
238
    return $self->{_columns};
239
}
239
}
240
240
241
sub as_hashref {
242
    my ( $self ) = @_;
243
    my %columns = $self->{_result}->get_columns;
244
    return \%columns;
245
}
241
246
242
=head3 AUTOLOAD
247
=head3 AUTOLOAD
243
248
(-)a/Koha/Objects.pm (-3 / +5 lines)
Lines 88-93 sub find { Link Here
88
88
89
    my $result = $self->_resultset()->find($id);
89
    my $result = $self->_resultset()->find($id);
90
90
91
    return unless $result;
92
91
    my $object = $self->object_class()->_new_from_dbic( $result );
93
    my $object = $self->object_class()->_new_from_dbic( $result );
92
94
93
    return $object;
95
    return $object;
Lines 100-116 my @objects = Koha::Objects->search($params); Link Here
100
=cut
102
=cut
101
103
102
sub search {
104
sub search {
103
    my ( $self, $params ) = @_;
105
    my ( $self, $params, $attributes ) = @_;
104
106
105
    if (wantarray) {
107
    if (wantarray) {
106
        my @dbic_rows = $self->_resultset()->search($params);
108
        my @dbic_rows = $self->_resultset()->search($params, $attributes);
107
109
108
        return $self->_wrap(@dbic_rows);
110
        return $self->_wrap(@dbic_rows);
109
111
110
    }
112
    }
111
    else {
113
    else {
112
        my $class = ref($self) ? ref($self) : $self;
114
        my $class = ref($self) ? ref($self) : $self;
113
        my $rs = $self->_resultset()->search($params);
115
        my $rs = $self->_resultset()->search($params, $attributes);
114
116
115
        return $class->_new_from_dbic($rs);
117
        return $class->_new_from_dbic($rs);
116
    }
118
    }
(-)a/acqui/addorderiso2709.pl (-8 / +8 lines)
Lines 45-51 use C4::Members; Link Here
45
45
46
use Koha::Number::Price;
46
use Koha::Number::Price;
47
use Koha::Acquisition::Order;
47
use Koha::Acquisition::Order;
48
use Koha::Acquisition::Bookseller;
48
use Koha::Acquisition::Booksellers;
49
49
50
my $input = new CGI;
50
my $input = new CGI;
51
my ($template, $loggedinuser, $cookie, $userflags) = get_template_and_user({
51
my ($template, $loggedinuser, $cookie, $userflags) = get_template_and_user({
Lines 60-71 my ($template, $loggedinuser, $cookie, $userflags) = get_template_and_user({ Link Here
60
my $cgiparams = $input->Vars;
60
my $cgiparams = $input->Vars;
61
my $op = $cgiparams->{'op'} || '';
61
my $op = $cgiparams->{'op'} || '';
62
my $booksellerid  = $input->param('booksellerid');
62
my $booksellerid  = $input->param('booksellerid');
63
my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
63
my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
64
my $data;
64
my $data;
65
65
66
$template->param(scriptname => "/cgi-bin/koha/acqui/addorderiso2709.pl",
66
$template->param(scriptname => "/cgi-bin/koha/acqui/addorderiso2709.pl",
67
                booksellerid => $booksellerid,
67
                booksellerid => $booksellerid,
68
                booksellername => $bookseller->{name},
68
                booksellername => $bookseller->name,
69
                );
69
                );
70
70
71
if ($cgiparams->{'import_batch_id'} && $op eq ""){
71
if ($cgiparams->{'import_batch_id'} && $op eq ""){
Lines 93-100 if ($op eq ""){ Link Here
93
    my $active_currency = GetCurrency();
93
    my $active_currency = GetCurrency();
94
    my $default_currency;
94
    my $default_currency;
95
    if (! $data->{currency} ) { # New order no currency set
95
    if (! $data->{currency} ) { # New order no currency set
96
        if ( $bookseller->{listprice} ) {
96
        if ( $bookseller->listprice ) {
97
            $default_currency = $bookseller->{listprice};
97
            $default_currency = $bookseller->listprice;
98
        }
98
        }
99
        else {
99
        else {
100
            $default_currency = $active_currency->{currency};
100
            $default_currency = $active_currency->{currency};
Lines 229-237 if ($op eq ""){ Link Here
229
            # in this case, the price will be x100 when unformatted ! Replace the . by a , to get a proper price calculation
229
            # in this case, the price will be x100 when unformatted ! Replace the . by a , to get a proper price calculation
230
            $price =~ s/\./,/ if C4::Context->preference("CurrencyFormat") eq "FR";
230
            $price =~ s/\./,/ if C4::Context->preference("CurrencyFormat") eq "FR";
231
            $price = Koha::Number::Price->new($price)->unformat;
231
            $price = Koha::Number::Price->new($price)->unformat;
232
            $orderinfo{tax_rate} = $bookseller->{tax_rate};
232
            $orderinfo{tax_rate} = $bookseller->tax_rate;
233
            my $c = $c_discount ? $c_discount : $bookseller->{discount} / 100;
233
            my $c = $c_discount ? $c_discount : $bookseller->discount / 100;
234
            if ( $bookseller->{listincgst} ) {
234
            if ( $bookseller->listincgst ) {
235
                if ( $c_discount ) {
235
                if ( $c_discount ) {
236
                    $orderinfo{ecost} = $price;
236
                    $orderinfo{ecost} = $price;
237
                    $orderinfo{rrp}   = $orderinfo{ecost} / ( 1 - $c );
237
                    $orderinfo{rrp}   = $orderinfo{ecost} / ( 1 - $c );
(-)a/acqui/basket.pl (-15 / +16 lines)
Lines 35-40 use C4::Biblio; Link Here
35
use C4::Members qw/GetMember/;  #needed for permissions checking for changing basketgroup of a basket
35
use C4::Members qw/GetMember/;  #needed for permissions checking for changing basketgroup of a basket
36
use C4::Items;
36
use C4::Items;
37
use C4::Suggestions;
37
use C4::Suggestions;
38
use Koha::Acquisition::Booksellers;
38
use Date::Calc qw/Add_Delta_Days/;
39
use Date::Calc qw/Add_Delta_Days/;
39
40
40
=head1 NAME
41
=head1 NAME
Lines 82-88 my ( $template, $loggedinuser, $cookie, $userflags ) = get_template_and_user( Link Here
82
83
83
my $basket = GetBasket($basketno);
84
my $basket = GetBasket($basketno);
84
$booksellerid = $basket->{booksellerid} unless $booksellerid;
85
$booksellerid = $basket->{booksellerid} unless $booksellerid;
85
my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
86
my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
86
87
87
unless (CanUserManageBasket($loggedinuser, $basket, $userflags)) {
88
unless (CanUserManageBasket($loggedinuser, $basket, $userflags)) {
88
    $template->param(
89
    $template->param(
Lines 90-96 unless (CanUserManageBasket($loggedinuser, $basket, $userflags)) { Link Here
90
        basketno => $basketno,
91
        basketno => $basketno,
91
        basketname => $basket->{basketname},
92
        basketname => $basket->{basketname},
92
        booksellerid => $booksellerid,
93
        booksellerid => $booksellerid,
93
        name => $bookseller->{name}
94
        name => $bookseller->name,
94
    );
95
    );
95
    output_html_with_http_headers $query, $cookie, $template->output;
96
    output_html_with_http_headers $query, $cookie, $template->output;
96
    exit;
97
    exit;
Lines 183-195 if ( $op eq 'delete_confirm' ) { Link Here
183
        closedate            => $basket->{closedate},
184
        closedate            => $basket->{closedate},
184
        deliveryplace        => $basket->{deliveryplace},
185
        deliveryplace        => $basket->{deliveryplace},
185
        billingplace         => $basket->{billingplace},
186
        billingplace         => $basket->{billingplace},
186
        active               => $bookseller->{'active'},
187
        active               => $bookseller->active,
187
        booksellerid         => $bookseller->{'id'},
188
        booksellerid         => $bookseller->id,
188
        name                 => $bookseller->{'name'},
189
        name                 => $bookseller->name,
189
        address1             => $bookseller->{'address1'},
190
        address1             => $bookseller->address1,
190
        address2             => $bookseller->{'address2'},
191
        address2             => $bookseller->address2,
191
        address3             => $bookseller->{'address3'},
192
        address3             => $bookseller->address3,
192
        address4             => $bookseller->{'address4'},
193
        address4             => $bookseller->address4,
193
      );
194
      );
194
} elsif ($op eq 'export') {
195
} elsif ($op eq 'export') {
195
    print $query->header(
196
    print $query->header(
Lines 311-317 if ( $op eq 'delete_confirm' ) { Link Here
311
    my $estimateddeliverydate;
312
    my $estimateddeliverydate;
312
    if( $basket->{closedate} ) {
313
    if( $basket->{closedate} ) {
313
        my ($year, $month, $day) = ($basket->{closedate} =~ /(\d+)-(\d+)-(\d+)/);
314
        my ($year, $month, $day) = ($basket->{closedate} =~ /(\d+)-(\d+)-(\d+)/);
314
        ($year, $month, $day) = Add_Delta_Days($year, $month, $day, $bookseller->{deliverytime});
315
        ($year, $month, $day) = Add_Delta_Days($year, $month, $day, $bookseller->deliverytime);
315
        $estimateddeliverydate = "$year-$month-$day";
316
        $estimateddeliverydate = "$year-$month-$day";
316
    }
317
    }
317
318
Lines 412-420 if ( $op eq 'delete_confirm' ) { Link Here
412
        estimateddeliverydate=> $estimateddeliverydate,
413
        estimateddeliverydate=> $estimateddeliverydate,
413
        deliveryplace        => C4::Branch::GetBranchName( $basket->{deliveryplace} ),
414
        deliveryplace        => C4::Branch::GetBranchName( $basket->{deliveryplace} ),
414
        billingplace         => C4::Branch::GetBranchName( $basket->{billingplace} ),
415
        billingplace         => C4::Branch::GetBranchName( $basket->{billingplace} ),
415
        active               => $bookseller->{'active'},
416
        active               => $bookseller->active,
416
        booksellerid         => $bookseller->{'id'},
417
        booksellerid         => $bookseller->id,
417
        name                 => $bookseller->{'name'},
418
        name                 => $bookseller->name,
418
        books_loop           => \@books_loop,
419
        books_loop           => \@books_loop,
419
        book_foot_loop       => \@book_foot_loop,
420
        book_foot_loop       => \@book_foot_loop,
420
        cancelledorders_loop => \@cancelledorders_loop,
421
        cancelledorders_loop => \@cancelledorders_loop,
Lines 423-429 if ( $op eq 'delete_confirm' ) { Link Here
423
        total_tax_included   => $total_tax_included,
424
        total_tax_included   => $total_tax_included,
424
        total_tax_value       => $total_tax_value,
425
        total_tax_value       => $total_tax_value,
425
        currency             => $cur->{'currency'},
426
        currency             => $cur->{'currency'},
426
        listincgst           => $bookseller->{listincgst},
427
        listincgst           => $bookseller->listincgst,
427
        basketgroups         => $basketgroups,
428
        basketgroups         => $basketgroups,
428
        basketgroup          => $basketgroup,
429
        basketgroup          => $basketgroup,
429
        grouped              => $basket->{basketgroupid},
430
        grouped              => $basket->{basketgroupid},
Lines 501-507 sub get_order_infos { Link Here
501
        if ($line{$key}) {
502
        if ($line{$key}) {
502
            my $order = GetOrder($line{$key});
503
            my $order = GetOrder($line{$key});
503
            my $basket = GetBasket($order->{basketno});
504
            my $basket = GetBasket($order->{basketno});
504
            my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $basket->{booksellerid} });
505
            my $bookseller = Koha::Acquisition::Booksellers->find( $basket->{booksellerid} );
505
            $line{$key} = {
506
            $line{$key} = {
506
                order => $order,
507
                order => $order,
507
                basket => $basket,
508
                basket => $basket,
(-)a/acqui/basketgroup.pl (-8 / +8 lines)
Lines 57-63 use C4::Acquisition qw/CloseBasketgroup ReOpenBasketgroup GetOrders GetBasketsBy Link Here
57
use C4::Branch qw/GetBranches/;
57
use C4::Branch qw/GetBranches/;
58
use C4::Members qw/GetMember/;
58
use C4::Members qw/GetMember/;
59
59
60
use Koha::Acquisition::Bookseller;
60
use Koha::Acquisition::Booksellers;
61
61
62
our $input=new CGI;
62
our $input=new CGI;
63
63
Lines 77-89 sub BasketTotal { Link Here
77
    my @orders = GetOrders($basketno);
77
    my @orders = GetOrders($basketno);
78
    for my $order (@orders){
78
    for my $order (@orders){
79
        # FIXME The following is wrong
79
        # FIXME The following is wrong
80
        if ( $bookseller->{listincgst} ) {
80
        if ( $bookseller->listincgst ) {
81
            $total = $total + ( $order->{ecost_tax_included} * $order->{quantity} );
81
            $total = $total + ( $order->{ecost_tax_included} * $order->{quantity} );
82
        } else {
82
        } else {
83
            $total = $total + ( $order->{ecost_tax_excluded} * $order->{quantity} );
83
            $total = $total + ( $order->{ecost_tax_excluded} * $order->{quantity} );
84
        }
84
        }
85
    }
85
    }
86
    $total .= " " . ($bookseller->{invoiceprice} // 0);
86
    $total .= " " . ($bookseller->invoiceprice // 0);
87
    return $total;
87
    return $total;
88
}
88
}
89
89
Lines 120-126 sub displaybasketgroups { Link Here
120
        }
120
        }
121
    }
121
    }
122
    $template->param(baskets => $baskets);
122
    $template->param(baskets => $baskets);
123
    $template->param( booksellername => $bookseller ->{'name'});
123
    $template->param( booksellername => $bookseller->name);
124
}
124
}
125
125
126
sub printbasketgrouppdf{
126
sub printbasketgrouppdf{
Lines 145-151 sub printbasketgrouppdf{ Link Here
145
    }
145
    }
146
    
146
    
147
    my $basketgroup = GetBasketgroup($basketgroupid);
147
    my $basketgroup = GetBasketgroup($basketgroupid);
148
    my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $basketgroup->{booksellerid} });
148
    my $bookseller = Koha::Acquisition::Booksellers->find( $basketgroup->{booksellerid} );
149
    my $baskets = GetBasketsByBasketgroup($basketgroupid);
149
    my $baskets = GetBasketsByBasketgroup($basketgroupid);
150
    
150
    
151
    my %orders;
151
    my %orders;
Lines 208-214 sub printbasketgrouppdf{ Link Here
208
        -type       => 'application/pdf',
208
        -type       => 'application/pdf',
209
        -attachment => ( $basketgroup->{name} || $basketgroupid ) . '.pdf'
209
        -attachment => ( $basketgroup->{name} || $basketgroupid ) . '.pdf'
210
    );
210
    );
211
    my $pdf = printpdf($basketgroup, $bookseller, $baskets, \%orders, $bookseller->{tax_rate} // C4::Context->preference("gist")) || die "pdf generation failed";
211
    my $pdf = printpdf($basketgroup, $bookseller, $baskets, \%orders, $bookseller->tax_rate // C4::Context->preference("gist")) || die "pdf generation failed";
212
    print $pdf;
212
    print $pdf;
213
213
214
}
214
}
Lines 233-239 if ( $op eq "add" ) { Link Here
233
# else, edit (if it is open) or display (if it is close) the basketgroup basketgroupid
233
# else, edit (if it is open) or display (if it is close) the basketgroup basketgroupid
234
# the template will know if basketgroup must be displayed or edited, depending on the value of closed key
234
# the template will know if basketgroup must be displayed or edited, depending on the value of closed key
235
#
235
#
236
    my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
236
    my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
237
    my $basketgroupid = $input->param('basketgroupid');
237
    my $basketgroupid = $input->param('basketgroupid');
238
    my $billingplace;
238
    my $billingplace;
239
    my $deliveryplace;
239
    my $deliveryplace;
Lines 380-386 if ( $op eq "add" ) { Link Here
380
}else{
380
}else{
381
# no param : display the list of all basketgroups for a given vendor
381
# no param : display the list of all basketgroups for a given vendor
382
    my $basketgroups = &GetBasketgroups($booksellerid);
382
    my $basketgroups = &GetBasketgroups($booksellerid);
383
    my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
383
    my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
384
    my $baskets = &GetBasketsByBookseller($booksellerid);
384
    my $baskets = &GetBasketsByBookseller($booksellerid);
385
385
386
    displaybasketgroups($basketgroups, $bookseller, $baskets);
386
    displaybasketgroups($basketgroups, $bookseller, $baskets);
(-)a/acqui/basketheader.pl (-4 / +4 lines)
Lines 55-61 use C4::Output; Link Here
55
use C4::Acquisition qw/GetBasket NewBasket ModBasketHeader/;
55
use C4::Acquisition qw/GetBasket NewBasket ModBasketHeader/;
56
use C4::Contract qw/GetContracts/;
56
use C4::Contract qw/GetContracts/;
57
57
58
use Koha::Acquisition::Bookseller;
58
use Koha::Acquisition::Booksellers;
59
59
60
my $input = new CGI;
60
my $input = new CGI;
61
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
61
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
Lines 106-123 if ( $op eq 'add_form' ) { Link Here
106
        });
106
        });
107
        push(@contractloop, @$contracts);
107
        push(@contractloop, @$contracts);
108
    }
108
    }
109
    my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
109
    my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
110
    my $count = scalar @contractloop;
110
    my $count = scalar @contractloop;
111
    if ( $count > 0) {
111
    if ( $count > 0) {
112
        $template->param(contractloop => \@contractloop,
112
        $template->param(contractloop => \@contractloop,
113
                         basketcontractnumber => $basket->{'contractnumber'});
113
                         basketcontractnumber => $basket->{'contractnumber'});
114
    }
114
    }
115
    my @booksellers = Koha::Acquisition::Bookseller->search;
115
    my @booksellers = Koha::Acquisition::Booksellers->search;
116
    $template->param( add_form => 1,
116
    $template->param( add_form => 1,
117
                    basketname => $basket->{'basketname'},
117
                    basketname => $basket->{'basketname'},
118
                    basketnote => $basket->{'note'},
118
                    basketnote => $basket->{'note'},
119
                    basketbooksellernote => $basket->{'booksellernote'},
119
                    basketbooksellernote => $basket->{'booksellernote'},
120
                    booksellername => $bookseller->{'name'},
120
                    booksellername => $bookseller->name,
121
                    booksellerid => $booksellerid,
121
                    booksellerid => $booksellerid,
122
                    basketno => $basketno,
122
                    basketno => $basketno,
123
                    booksellers => \@booksellers,
123
                    booksellers => \@booksellers,
(-)a/acqui/booksellers.pl (-10 / +10 lines)
Lines 63-69 use C4::Acquisition qw/ GetBasketsInfosByBookseller CanUserManageBasket /; Link Here
63
use C4::Members qw/GetMember/;
63
use C4::Members qw/GetMember/;
64
use C4::Context;
64
use C4::Context;
65
65
66
use Koha::Acquisition::Bookseller;
66
use Koha::Acquisition::Booksellers;
67
67
68
my $query = CGI->new;
68
my $query = CGI->new;
69
my ( $template, $loggedinuser, $cookie, $userflags ) = get_template_and_user(
69
my ( $template, $loggedinuser, $cookie, $userflags ) = get_template_and_user(
Lines 83-99 my $allbaskets= $query->param('allbaskets')||0; Link Here
83
my @suppliers;
83
my @suppliers;
84
84
85
if ($booksellerid) {
85
if ($booksellerid) {
86
    push @suppliers, Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
86
    push @suppliers, Koha::Acquisition::Booksellers->find( $booksellerid );
87
} else {
87
} else {
88
    @suppliers = Koha::Acquisition::Bookseller->search({ name => $supplier });
88
    @suppliers = Koha::Acquisition::Booksellers->search({ name => $supplier });
89
}
89
}
90
90
91
my $supplier_count = @suppliers;
91
my $supplier_count = @suppliers;
92
if ( $supplier_count == 1 ) {
92
if ( $supplier_count == 1 ) {
93
    $template->param(
93
    $template->param(
94
        supplier_name => $suppliers[0]->{'name'},
94
        supplier_name => $suppliers[0]->name,
95
        booksellerid  => $suppliers[0]->{'id'},
95
        booksellerid  => $suppliers[0]->id,
96
        basketcount   => $suppliers[0]->{'basketcount'}
96
        basketcount   => $suppliers[0]->baskets->count
97
    );
97
    );
98
}
98
}
99
99
Lines 123-129 foreach my $r (@{$budgets}) { Link Here
123
my $loop_suppliers = [];
123
my $loop_suppliers = [];
124
124
125
for my $vendor (@suppliers) {
125
for my $vendor (@suppliers) {
126
    my $baskets = GetBasketsInfosByBookseller( $vendor->{id}, $allbaskets );
126
    my $baskets = GetBasketsInfosByBookseller( $vendor->id, $allbaskets );
127
127
128
    my $loop_basket = [];
128
    my $loop_basket = [];
129
129
Lines 149-157 for my $vendor (@suppliers) { Link Here
149
149
150
    push @{$loop_suppliers},
150
    push @{$loop_suppliers},
151
      { loop_basket => $loop_basket,
151
      { loop_basket => $loop_basket,
152
        booksellerid  => $vendor->{id},
152
        booksellerid  => $vendor->id,
153
        name        => $vendor->{name},
153
        name        => $vendor->name,
154
        active      => $vendor->{active},
154
        active      => $vendor->active,
155
      };
155
      };
156
156
157
}
157
}
(-)a/acqui/finishreceive.pl (-4 / +1 lines)
Lines 28-38 use C4::Output; Link Here
28
use C4::Context;
28
use C4::Context;
29
use C4::Acquisition;
29
use C4::Acquisition;
30
use C4::Biblio;
30
use C4::Biblio;
31
use C4::Bookseller;
32
use C4::Items;
31
use C4::Items;
33
use C4::Search;
32
use C4::Search;
34
33
35
use Koha::Acquisition::Bookseller;
34
use Koha::Acquisition::Booksellers;
36
35
37
use List::MoreUtils qw/any/;
36
use List::MoreUtils qw/any/;
38
37
Lines 84-91 if ($quantityrec > $origquantityrec ) { Link Here
84
    $order->{tax_rate_on_receiving} = $input->param("tax_rate");
83
    $order->{tax_rate_on_receiving} = $input->param("tax_rate");
85
    $order->{unitprice} = $unitprice;
84
    $order->{unitprice} = $unitprice;
86
85
87
    my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
88
89
    $order = C4::Acquisition::populate_order_with_prices(
86
    $order = C4::Acquisition::populate_order_with_prices(
90
        {
87
        {
91
            order => $order,
88
            order => $order,
(-)a/acqui/invoice.pl (-3 / +3 lines)
Lines 35-41 use C4::Output; Link Here
35
use C4::Acquisition;
35
use C4::Acquisition;
36
use C4::Budgets;
36
use C4::Budgets;
37
37
38
use Koha::Acquisition::Bookseller;
38
use Koha::Acquisition::Booksellers;
39
use Koha::Misc::Files;
39
use Koha::Misc::Files;
40
40
41
my $input = new CGI;
41
my $input = new CGI;
Lines 110-116 elsif ( $op && $op eq 'delete' ) { Link Here
110
110
111
111
112
my $details = GetInvoiceDetails($invoiceid);
112
my $details = GetInvoiceDetails($invoiceid);
113
my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $details->{booksellerid} });
113
my $bookseller = Koha::Acquisition::Booksellers->find( $details->{booksellerid} );
114
my @orders_loop = ();
114
my @orders_loop = ();
115
my $orders = $details->{'orders'};
115
my $orders = $details->{'orders'};
116
my $qty_total;
116
my $qty_total;
Lines 176-182 $template->param( Link Here
176
    total_tax_value  => $total_tax_value,
176
    total_tax_value  => $total_tax_value,
177
    total_tax_excluded_shipment => $total_tax_excluded + $details->{shipmentcost},
177
    total_tax_excluded_shipment => $total_tax_excluded + $details->{shipmentcost},
178
    total_tax_included_shipment => $total_tax_included + $details->{shipmentcost},
178
    total_tax_included_shipment => $total_tax_included + $details->{shipmentcost},
179
    invoiceincgst    => $bookseller->{invoiceincgst},
179
    invoiceincgst    => $bookseller->invoiceincgst,
180
    currency         => GetCurrency()->{currency},
180
    currency         => GetCurrency()->{currency},
181
    budgets_loop     => \@budgets_loop,
181
    budgets_loop     => \@budgets_loop,
182
);
182
);
(-)a/acqui/modordernotes.pl (-4 / +4 lines)
Lines 33-39 use C4::Auth; Link Here
33
use C4::Output;
33
use C4::Output;
34
use C4::Acquisition;
34
use C4::Acquisition;
35
35
36
use Koha::Acquisition::Bookseller;
36
use Koha::Acquisition::Booksellers;
37
37
38
my $input = new CGI;
38
my $input = new CGI;
39
my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user( {
39
my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user( {
Lines 51-57 my $referrer = $input->param('referrer') || $input->referer(); Link Here
51
my $type = $input->param('type');
51
my $type = $input->param('type');
52
my $order = GetOrder($ordernumber);
52
my $order = GetOrder($ordernumber);
53
my $basket = GetBasket($order->{basketno});
53
my $basket = GetBasket($order->{basketno});
54
my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $basket->{booksellerid} });
54
my $bookseller = Koha::Acquisition::Booksellers->find( $basket->{booksellerid} );
55
55
56
56
57
if($op and $op eq 'save') {
57
if($op and $op eq 'save') {
Lines 79-86 if($op) { Link Here
79
$template->param(
79
$template->param(
80
    basketname           => $basket->{'basketname'},
80
    basketname           => $basket->{'basketname'},
81
    basketno             => $order->{basketno},
81
    basketno             => $order->{basketno},
82
    booksellerid         => $bookseller->{'id'},
82
    booksellerid         => $bookseller->id,
83
    booksellername       => $bookseller->{'name'},
83
    booksellername       => $bookseller->name,
84
    ordernumber => $ordernumber,
84
    ordernumber => $ordernumber,
85
    referrer => $referrer,
85
    referrer => $referrer,
86
    type => $type,
86
    type => $type,
(-)a/acqui/neworderbiblio.pl (-6 / +6 lines)
Lines 67-73 use C4::Koha; Link Here
67
use C4::Members qw/ GetMember /;
67
use C4::Members qw/ GetMember /;
68
use C4::Budgets qw/ GetBudgetHierarchy /;
68
use C4::Budgets qw/ GetBudgetHierarchy /;
69
69
70
use Koha::Acquisition::Bookseller;
70
use Koha::Acquisition::Booksellers;
71
71
72
my $input = new CGI;
72
my $input = new CGI;
73
73
Lines 80-86 my $results_per_page = $params->{'num'} || 20; Link Here
80
my $booksellerid     = $params->{'booksellerid'};
80
my $booksellerid     = $params->{'booksellerid'};
81
my $basketno         = $params->{'basketno'};
81
my $basketno         = $params->{'basketno'};
82
my $sub              = $params->{'sub'};
82
my $sub              = $params->{'sub'};
83
my $bookseller       = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
83
my $bookseller       = Koha::Acquisition::Booksellers->find( $booksellerid );
84
84
85
# getting the template
85
# getting the template
86
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
86
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
Lines 111-118 if (defined $error) { Link Here
111
    $template->param(
111
    $template->param(
112
        query_error => $error,
112
        query_error => $error,
113
        basketno             => $basketno,
113
        basketno             => $basketno,
114
        booksellerid     => $bookseller->{'id'},
114
        booksellerid     => $bookseller->id,
115
        name             => $bookseller->{'name'},
115
        name             => $bookseller->name,
116
    );
116
    );
117
    output_html_with_http_headers $input, $cookie, $template->output;
117
    output_html_with_http_headers $input, $cookie, $template->output;
118
    exit;
118
    exit;
Lines 143-150 foreach my $r (@{$budgets}) { Link Here
143
$template->param(
143
$template->param(
144
    has_budgets          => $has_budgets,
144
    has_budgets          => $has_budgets,
145
    basketno             => $basketno,
145
    basketno             => $basketno,
146
    booksellerid         => $bookseller->{'id'},
146
    booksellerid         => $bookseller->id,
147
    name                 => $bookseller->{'name'},
147
    name                 => $bookseller->name,
148
    resultsloop          => \@results,
148
    resultsloop          => \@results,
149
    total                => $total_hits,
149
    total                => $total_hits,
150
    query                => $query,
150
    query                => $query,
(-)a/acqui/neworderempty.pl (-10 / +10 lines)
Lines 91-97 use C4::Search qw/FindDuplicate/; Link Here
91
#needed for z3950 import:
91
#needed for z3950 import:
92
use C4::ImportBatch qw/GetImportRecordMarc SetImportRecordStatus/;
92
use C4::ImportBatch qw/GetImportRecordMarc SetImportRecordStatus/;
93
93
94
use Koha::Acquisition::Bookseller;
94
use Koha::Acquisition::Booksellers;
95
95
96
our $input           = new CGI;
96
our $input           = new CGI;
97
my $booksellerid    = $input->param('booksellerid');	# FIXME: else ERROR!
97
my $booksellerid    = $input->param('booksellerid');	# FIXME: else ERROR!
Lines 132-138 if(!$basketno) { Link Here
132
132
133
our $basket = GetBasket($basketno);
133
our $basket = GetBasket($basketno);
134
$booksellerid = $basket->{booksellerid} unless $booksellerid;
134
$booksellerid = $basket->{booksellerid} unless $booksellerid;
135
my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
135
my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
136
136
137
my $contract = GetContract({
137
my $contract = GetContract({
138
    contractnumber => $basket->{contractnumber}
138
    contractnumber => $basket->{contractnumber}
Lines 205-212 $suggestion = GetSuggestionInfo($suggestionid) if $suggestionid; Link Here
205
my $active_currency = GetCurrency();
205
my $active_currency = GetCurrency();
206
my $default_currency;
206
my $default_currency;
207
if (! $data->{currency} ) { # New order no currency set
207
if (! $data->{currency} ) { # New order no currency set
208
    if ( $bookseller->{listprice} ) {
208
    if ( $bookseller->listprice ) {
209
        $default_currency = $bookseller->{listprice};
209
        $default_currency = $bookseller->listprice;
210
    }
210
    }
211
    else {
211
    else {
212
        $default_currency = $active_currency->{currency};
212
        $default_currency = $active_currency->{currency};
Lines 364-378 $template->param( Link Here
364
    biblionumber         => $biblionumber,
364
    biblionumber         => $biblionumber,
365
    uncertainprice       => $data->{'uncertainprice'},
365
    uncertainprice       => $data->{'uncertainprice'},
366
    authorisedbyname     => $borrower->{'firstname'} . " " . $borrower->{'surname'},
366
    authorisedbyname     => $borrower->{'firstname'} . " " . $borrower->{'surname'},
367
    discount_2dp         => sprintf( "%.2f",  $bookseller->{'discount'} ) ,   # for display
367
    discount_2dp         => sprintf( "%.2f",  $bookseller->discount ) ,   # for display
368
    discount             => $bookseller->{'discount'},
368
    discount             => $bookseller->discount,
369
    orderdiscount_2dp    => sprintf( "%.2f", $data->{'discount'} || 0 ),
369
    orderdiscount_2dp    => sprintf( "%.2f", $data->{'discount'} || 0 ),
370
    orderdiscount        => $data->{'discount'},
370
    orderdiscount        => $data->{'discount'},
371
    order_internalnote   => $data->{'order_internalnote'},
371
    order_internalnote   => $data->{'order_internalnote'},
372
    order_vendornote     => $data->{'order_vendornote'},
372
    order_vendornote     => $data->{'order_vendornote'},
373
    listincgst       => $bookseller->{'listincgst'},
373
    listincgst       => $bookseller->listincgst,
374
    invoiceincgst    => $bookseller->{'invoiceincgst'},
374
    invoiceincgst    => $bookseller->invoiceincgst,
375
    name             => $bookseller->{'name'},
375
    name             => $bookseller->name,
376
    cur_active_sym   => $active_currency->{'symbol'},
376
    cur_active_sym   => $active_currency->{'symbol'},
377
    cur_active       => $active_currency->{'currency'},
377
    cur_active       => $active_currency->{'currency'},
378
    loop_currencies  => \@loop_currency,
378
    loop_currencies  => \@loop_currency,
Lines 390-396 $template->param( Link Here
390
    quantityrec      => $quantity,
390
    quantityrec      => $quantity,
391
    rrp              => $data->{'rrp'},
391
    rrp              => $data->{'rrp'},
392
    gst_values       => \@gst_values,
392
    gst_values       => \@gst_values,
393
    tax_rate         => $data->{tax_rate_on_ordering} ? $data->{tax_rate_on_ordering}+0.0 : $bookseller->{tax_rate} ? $bookseller->{tax_rate}+0.0 : 0,
393
    tax_rate         => $data->{tax_rate_on_ordering} ? $data->{tax_rate_on_ordering}+0.0 : $bookseller->tax_rate ? $bookseller->tax_rate+0.0 : 0,
394
    listprice        => sprintf( "%.2f", $data->{listprice} || $data->{price} || $listprice),
394
    listprice        => sprintf( "%.2f", $data->{listprice} || $data->{price} || $listprice),
395
    total            => sprintf( "%.2f", ($data->{ecost} || 0) * ($data->{'quantity'} || 0) ),
395
    total            => sprintf( "%.2f", ($data->{ecost} || 0) * ($data->{'quantity'} || 0) ),
396
    ecost            => sprintf( "%.2f", $data->{ecost} || 0),
396
    ecost            => sprintf( "%.2f", $data->{ecost} || 0),
(-)a/acqui/newordersubscription.pl (-3 / +3 lines)
Lines 26-32 use C4::Context; Link Here
26
use C4::Output;
26
use C4::Output;
27
use C4::Serials;
27
use C4::Serials;
28
28
29
use Koha::Acquisition::Bookseller;
29
use Koha::Acquisition::Booksellers;
30
30
31
my $query        = new CGI;
31
my $query        = new CGI;
32
my $title        = $query->param('title_filter');
32
my $title        = $query->param('title_filter');
Lines 53-59 my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( Link Here
53
53
54
my $basket = GetBasket($basketno);
54
my $basket = GetBasket($basketno);
55
$booksellerid = $basket->{booksellerid} unless $booksellerid;
55
$booksellerid = $basket->{booksellerid} unless $booksellerid;
56
my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
56
my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
57
57
58
my @subscriptions;
58
my @subscriptions;
59
if ($searched) {
59
if ($searched) {
Lines 102-107 $template->param( Link Here
102
    booksellerid     => $booksellerid,
102
    booksellerid     => $booksellerid,
103
    basketno         => $basket->{basketno},
103
    basketno         => $basket->{basketno},
104
    basketname       => $basket->{basketname},
104
    basketname       => $basket->{basketname},
105
    booksellername   => $bookseller->{name},
105
    booksellername   => $bookseller->name,
106
);
106
);
107
output_html_with_http_headers $query, $cookie, $template->output;
107
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/acqui/newordersuggestion.pl (-3 / +3 lines)
Lines 97-103 use C4::Output; Link Here
97
use C4::Suggestions;
97
use C4::Suggestions;
98
use C4::Biblio;
98
use C4::Biblio;
99
99
100
use Koha::Acquisition::Bookseller;
100
use Koha::Acquisition::Booksellers;
101
101
102
my $input = new CGI;
102
my $input = new CGI;
103
103
Lines 137-148 my $suggestions_loop = SearchSuggestion( Link Here
137
        STATUS        => 'ACCEPTED'
137
        STATUS        => 'ACCEPTED'
138
    }
138
    }
139
);
139
);
140
my $vendor = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
140
my $vendor = Koha::Acquisition::Booksellers->find( $booksellerid );
141
$template->param(
141
$template->param(
142
    suggestions_loop        => $suggestions_loop,
142
    suggestions_loop        => $suggestions_loop,
143
    basketno                => $basketno,
143
    basketno                => $basketno,
144
    booksellerid              => $booksellerid,
144
    booksellerid              => $booksellerid,
145
    name					=> $vendor->{'name'},
145
    name                    => $vendor->name,
146
    loggedinuser            => $borrowernumber,
146
    loggedinuser            => $borrowernumber,
147
    "op_$op"                => 1,
147
    "op_$op"                => 1,
148
);
148
);
(-)a/acqui/orderreceive.pl (-4 / +4 lines)
Lines 75-81 use C4::Items; Link Here
75
use C4::Biblio;
75
use C4::Biblio;
76
use C4::Suggestions;
76
use C4::Suggestions;
77
77
78
use Koha::Acquisition::Bookseller;
78
use Koha::Acquisition::Booksellers;
79
79
80
80
81
my $input      = new CGI;
81
my $input      = new CGI;
Lines 90-96 my $ordernumber = $input->param('ordernumber'); Link Here
90
90
91
$datereceived = $datereceived ? C4::Dates->new($datereceived, 'iso') : C4::Dates->new();
91
$datereceived = $datereceived ? C4::Dates->new($datereceived, 'iso') : C4::Dates->new();
92
92
93
my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
93
my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
94
my $results;
94
my $results;
95
$results = SearchOrders({
95
$results = SearchOrders({
96
    ordernumber => $ordernumber
96
    ordernumber => $ordernumber
Lines 165-171 $order->{quantityreceived} = '' if $order->{quantityreceived} == 0; Link Here
165
165
166
my $unitprice = $order->{unitprice};
166
my $unitprice = $order->{unitprice};
167
my ( $rrp, $ecost );
167
my ( $rrp, $ecost );
168
if ( $bookseller->{invoiceincgst} ) {
168
if ( $bookseller->invoiceincgst ) {
169
    $rrp = $order->{rrp_tax_included};
169
    $rrp = $order->{rrp_tax_included};
170
    $ecost = $order->{ecost_tax_included};
170
    $ecost = $order->{ecost_tax_included};
171
    unless ( $unitprice != 0 and defined $unitprice) {
171
    unless ( $unitprice != 0 and defined $unitprice) {
Lines 206-212 $template->param( Link Here
206
    subscriptionid        => $order->{subscriptionid},
206
    subscriptionid        => $order->{subscriptionid},
207
    booksellerid          => $order->{'booksellerid'},
207
    booksellerid          => $order->{'booksellerid'},
208
    freight               => $freight,
208
    freight               => $freight,
209
    name                  => $bookseller->{'name'},
209
    name                  => $bookseller->name,
210
    date                  => format_date($order->{entrydate}),
210
    date                  => format_date($order->{entrydate}),
211
    title                 => $order->{'title'},
211
    title                 => $order->{'title'},
212
    author                => $order->{'author'},
212
    author                => $order->{'author'},
(-)a/acqui/parcel.pl (-8 / +8 lines)
Lines 68-74 use C4::Dates qw/format_date format_date_in_iso/; Link Here
68
use C4::Suggestions;
68
use C4::Suggestions;
69
use C4::Reserves qw/GetReservesFromBiblionumber/;
69
use C4::Reserves qw/GetReservesFromBiblionumber/;
70
70
71
use Koha::Acquisition::Bookseller;
71
use Koha::Acquisition::Booksellers;
72
72
73
use JSON;
73
use JSON;
74
74
Lines 110-116 unless( $invoiceid and $invoice->{invoiceid} ) { Link Here
110
}
110
}
111
111
112
my $booksellerid = $invoice->{booksellerid};
112
my $booksellerid = $invoice->{booksellerid};
113
my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
113
my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
114
my $datereceived = C4::Dates->new();
114
my $datereceived = C4::Dates->new();
115
115
116
my @orders        = @{ $invoice->{orders} };
116
my @orders        = @{ $invoice->{orders} };
Lines 125-135 my $subtotal_for_funds; Link Here
125
for my $order ( @orders ) {
125
for my $order ( @orders ) {
126
    $order->{'unitprice'} += 0;
126
    $order->{'unitprice'} += 0;
127
127
128
    if ( $bookseller->{listincgst} and not $bookseller->{invoiceincgst} ) {
128
    if ( $bookseller->listincgst and not $bookseller->invoiceincgst ) {
129
        $order->{ecost}     = $order->{ecost_tax_excluded};
129
        $order->{ecost}     = $order->{ecost_tax_excluded};
130
        $order->{unitprice} = $order->{unitprice_tax_excluded};
130
        $order->{unitprice} = $order->{unitprice_tax_excluded};
131
    }
131
    }
132
    elsif ( not $bookseller->{listinct} and $bookseller->{invoiceincgst} ) {
132
    elsif ( not $bookseller->listinct and $bookseller->invoiceincgst ) {
133
        $order->{ecost}     = $order->{ecost_tax_included};
133
        $order->{ecost}     = $order->{ecost_tax_included};
134
        $order->{unitprice} = $order->{unitprice_tax_included};
134
        $order->{unitprice} = $order->{unitprice_tax_included};
135
    } else {
135
    } else {
Lines 225-233 unless( defined $invoice->{closedate} ) { Link Here
225
    for (my $i = 0 ; $i < $countpendings ; $i++) {
225
    for (my $i = 0 ; $i < $countpendings ; $i++) {
226
        my $order = $pendingorders->[$i];
226
        my $order = $pendingorders->[$i];
227
227
228
        if ( $bookseller->{listincgst} and not $bookseller->{invoiceincgst} ) {
228
        if ( $bookseller->listincgst and not $bookseller->invoiceincgst ) {
229
            $order->{ecost} = $order->{ecost_tax_excluded};
229
            $order->{ecost} = $order->{ecost_tax_excluded};
230
        } elsif ( not $bookseller->{listinct} and $bookseller->{invoiceincgst} ) {
230
        } elsif ( not $bookseller->listinct and $bookseller->invoiceincgst ) {
231
            $order->{ecost} = $order->{ecost_tax_included};
231
            $order->{ecost} = $order->{ecost_tax_included};
232
        } else {
232
        } else {
233
            $order->{ecost} = $order->{ecost_tax_excluded};
233
            $order->{ecost} = $order->{ecost_tax_excluded};
Lines 290-297 $template->param( Link Here
290
    datereceived          => $datereceived->output('iso'),
290
    datereceived          => $datereceived->output('iso'),
291
    invoicedatereceived   => $datereceived->output('iso'),
291
    invoicedatereceived   => $datereceived->output('iso'),
292
    formatteddatereceived => $datereceived->output(),
292
    formatteddatereceived => $datereceived->output(),
293
    name                  => $bookseller->{'name'},
293
    name                  => $bookseller->name,
294
    booksellerid          => $bookseller->{id},
294
    booksellerid          => $bookseller->id,
295
    loop_received         => \@loop_received,
295
    loop_received         => \@loop_received,
296
    loop_orders           => \@loop_orders,
296
    loop_orders           => \@loop_orders,
297
    book_foot_loop        => \@book_foot_loop,
297
    book_foot_loop        => \@book_foot_loop,
(-)a/acqui/parcels.pl (-3 / +3 lines)
Lines 76-82 use C4::Dates qw/format_date/; Link Here
76
use C4::Acquisition;
76
use C4::Acquisition;
77
use C4::Budgets;
77
use C4::Budgets;
78
78
79
use Koha::Acquisition::Bookseller;
79
use Koha::Acquisition::Booksellers;
80
80
81
my $input          = CGI->new;
81
my $input          = CGI->new;
82
my $booksellerid     = $input->param('booksellerid');
82
my $booksellerid     = $input->param('booksellerid');
Lines 141-147 if ($op and $op eq 'confirm') { Link Here
141
    }
141
    }
142
}
142
}
143
143
144
my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
144
my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
145
my @parcels = GetInvoices(
145
my @parcels = GetInvoices(
146
    supplierid => $booksellerid,
146
    supplierid => $booksellerid,
147
    invoicenumber => $code,
147
    invoicenumber => $code,
Lines 205-211 $template->param( Link Here
205
    datefrom                 => $datefrom,
205
    datefrom                 => $datefrom,
206
    dateto                   => $dateto,
206
    dateto                   => $dateto,
207
    resultsperpage           => $resultsperpage,
207
    resultsperpage           => $resultsperpage,
208
    name                     => $bookseller->{'name'},
208
    name                     => $bookseller->name,
209
    shipmentdate_today       => C4::Dates->new()->output(),
209
    shipmentdate_today       => C4::Dates->new()->output(),
210
    booksellerid             => $booksellerid,
210
    booksellerid             => $booksellerid,
211
    GST                      => C4::Context->preference('gist'),
211
    GST                      => C4::Context->preference('gist'),
(-)a/acqui/pdfformat/layout2pages.pm (-6 / +6 lines)
Lines 202-218 sub printhead { Link Here
202
    
202
    
203
    # print bookseller infos
203
    # print bookseller infos
204
    $text->translate(100/mm, ($height-180)/mm);
204
    $text->translate(100/mm, ($height-180)/mm);
205
    $text->text($bookseller->{name});
205
    $text->text($bookseller->name);
206
    $text->translate(100/mm, ($height-185)/mm);
206
    $text->translate(100/mm, ($height-185)/mm);
207
    $text->text($bookseller->{postal});
207
    $text->text($bookseller->postal);
208
    $text->translate(100/mm, ($height-190)/mm);
208
    $text->translate(100/mm, ($height-190)/mm);
209
    $text->text($bookseller->{address1});
209
    $text->text($bookseller->address1);
210
    $text->translate(100/mm, ($height-195)/mm);
210
    $text->translate(100/mm, ($height-195)/mm);
211
    $text->text($bookseller->{address2});
211
    $text->text($bookseller->address2);
212
    $text->translate(100/mm, ($height-200)/mm);
212
    $text->translate(100/mm, ($height-200)/mm);
213
    $text->text($bookseller->{address3});
213
    $text->text($bookseller->address3);
214
    $text->translate(100/mm, ($height-205)/mm);
214
    $text->translate(100/mm, ($height-205)/mm);
215
    $text->text($bookseller->{accountnumber});
215
    $text->text($bookseller->accountnumber);
216
    
216
    
217
    # print delivery infos
217
    # print delivery infos
218
    $text->font( $pdf->corefont("Times-Bold", -encoding => "utf8"), 4/mm );
218
    $text->font( $pdf->corefont("Times-Bold", -encoding => "utf8"), 4/mm );
(-)a/acqui/pdfformat/layout2pagesde.pm (-6 / +6 lines)
Lines 202-218 sub printhead { Link Here
202
    
202
    
203
    # print bookseller infos
203
    # print bookseller infos
204
    $text->translate(100/mm, ($height-180)/mm);
204
    $text->translate(100/mm, ($height-180)/mm);
205
    $text->text($bookseller->{name});
205
    $text->text($bookseller->name);
206
    $text->translate(100/mm, ($height-185)/mm);
206
    $text->translate(100/mm, ($height-185)/mm);
207
    $text->text($bookseller->{postal});
207
    $text->text($bookseller->postal);
208
    $text->translate(100/mm, ($height-190)/mm);
208
    $text->translate(100/mm, ($height-190)/mm);
209
    $text->text($bookseller->{address1});
209
    $text->text($bookseller->address1);
210
    $text->translate(100/mm, ($height-195)/mm);
210
    $text->translate(100/mm, ($height-195)/mm);
211
    $text->text($bookseller->{address2});
211
    $text->text($bookseller->address2);
212
    $text->translate(100/mm, ($height-200)/mm);
212
    $text->translate(100/mm, ($height-200)/mm);
213
    $text->text($bookseller->{address3});
213
    $text->text($bookseller->address3);
214
    $text->translate(100/mm, ($height-205)/mm);
214
    $text->translate(100/mm, ($height-205)/mm);
215
    $text->text($bookseller->{accountnumber});
215
    $text->text($bookseller->accountnumber);
216
    
216
    
217
    # print delivery infos
217
    # print delivery infos
218
    $text->font( $pdf->corefont("Times-Bold", -encoding => "utf8"), 4/mm );
218
    $text->font( $pdf->corefont("Times-Bold", -encoding => "utf8"), 4/mm );
(-)a/acqui/pdfformat/layout3pages.pm (-6 / +6 lines)
Lines 366-382 sub printhead { Link Here
366
    
366
    
367
    # print bookseller infos
367
    # print bookseller infos
368
    $text->translate(100/mm,  ($height-180)/mm);
368
    $text->translate(100/mm,  ($height-180)/mm);
369
    $text->text($bookseller->{name});
369
    $text->text($bookseller->name);
370
    $text->translate(100/mm,  ($height-185)/mm);
370
    $text->translate(100/mm,  ($height-185)/mm);
371
    $text->text($bookseller->{postal});
371
    $text->text($bookseller->postal);
372
    $text->translate(100/mm,  ($height-190)/mm);
372
    $text->translate(100/mm,  ($height-190)/mm);
373
    $text->text($bookseller->{address1});
373
    $text->text($bookseller->address1);
374
    $text->translate(100/mm,  ($height-195)/mm);
374
    $text->translate(100/mm,  ($height-195)/mm);
375
    $text->text($bookseller->{address2});
375
    $text->text($bookseller->address2);
376
    $text->translate(100/mm,  ($height-200)/mm);
376
    $text->translate(100/mm,  ($height-200)/mm);
377
    $text->text($bookseller->{address3});
377
    $text->text($bookseller->address3);
378
    $text->translate(100/mm, ($height-205)/mm);
378
    $text->translate(100/mm, ($height-205)/mm);
379
    $text->text($bookseller->{accountnumber});
379
    $text->text($bookseller->accountnumber);
380
    
380
    
381
    # print delivery infos
381
    # print delivery infos
382
    $text->font( $pdf->corefont("Times-Bold", -encoding => "utf8"), 4/mm );
382
    $text->font( $pdf->corefont("Times-Bold", -encoding => "utf8"), 4/mm );
(-)a/acqui/pdfformat/layout3pagesfr.pm (-6 / +6 lines)
Lines 366-382 sub printhead { Link Here
366
366
367
    # print bookseller infos
367
    # print bookseller infos
368
    $text->translate(100/mm,  ($height-180)/mm);
368
    $text->translate(100/mm,  ($height-180)/mm);
369
    $text->text($bookseller->{name});
369
    $text->text($bookseller->name);
370
    $text->translate(100/mm,  ($height-185)/mm);
370
    $text->translate(100/mm,  ($height-185)/mm);
371
    $text->text($bookseller->{postal});
371
    $text->text($bookseller->postal);
372
    $text->translate(100/mm,  ($height-190)/mm);
372
    $text->translate(100/mm,  ($height-190)/mm);
373
    $text->text($bookseller->{address1});
373
    $text->text($bookseller->address1);
374
    $text->translate(100/mm,  ($height-195)/mm);
374
    $text->translate(100/mm,  ($height-195)/mm);
375
    $text->text($bookseller->{address2});
375
    $text->text($bookseller->address2);
376
    $text->translate(100/mm,  ($height-200)/mm);
376
    $text->translate(100/mm,  ($height-200)/mm);
377
    $text->text($bookseller->{address3});
377
    $text->text($bookseller->address3);
378
    $text->translate(100/mm, ($height-205)/mm);
378
    $text->translate(100/mm, ($height-205)/mm);
379
    $text->text($bookseller->{accountnumber});
379
    $text->text($bookseller->accountnumber);
380
380
381
    # print delivery infos
381
    # print delivery infos
382
    $text->font( $pdf->corefont("Times-Bold", -encoding => "utf8"), 4/mm );
382
    $text->font( $pdf->corefont("Times-Bold", -encoding => "utf8"), 4/mm );
(-)a/acqui/supplier.pl (-24 / +32 lines)
Lines 48-58 use C4::Biblio; Link Here
48
use C4::Output;
48
use C4::Output;
49
use CGI qw ( -utf8 );
49
use CGI qw ( -utf8 );
50
50
51
use C4::Bookseller qw( DelBookseller );
52
use C4::Bookseller::Contact;
51
use C4::Bookseller::Contact;
53
use C4::Budgets;
52
use C4::Budgets;
54
53
55
use Koha::Acquisition::Bookseller;
54
use Koha::Acquisition::Booksellers;
56
55
57
my $query    = CGI->new;
56
my $query    = CGI->new;
58
my $op = $query->param('op') || 'display';
57
my $op = $query->param('op') || 'display';
Lines 66-99 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
66
    }
65
    }
67
);
66
);
68
my $booksellerid       = $query->param('booksellerid');
67
my $booksellerid       = $query->param('booksellerid');
69
my $supplier = {};
68
my $supplier;
70
if ($booksellerid) {
69
if ($booksellerid) {
71
    $supplier = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
70
    $supplier = Koha::Acquisition::Booksellers->find( $booksellerid );
72
    foreach ( keys %{$supplier} ) {
71
    my $supplier_hashref = $supplier->as_hashref;
73
        $template->{'VARS'}->{$_} = $supplier->{$_};
72
    foreach ( keys %{$supplier_hashref} ) {
73
        $template->{'VARS'}->{$_} = $supplier->$_;
74
    }
74
    }
75
    $template->{'VARS'}->{'booksellerid'} = $booksellerid;
75
    $template->{'VARS'}->{'booksellerid'} = $booksellerid;
76
    $template->{'VARS'}->{'contacts'} = $supplier->contacts;
76
}
77
}
77
$template->{'VARS'}->{'contacts'} = C4::Bookseller::Contact->new() unless $template->{'VARS'}->{'contacts'};
78
78
79
#build array for currencies
79
#build array for currencies
80
if ( $op eq 'display' ) {
80
if ( $op eq 'display' ) {
81
    my $contracts = GetContracts( { booksellerid => $booksellerid } );
81
    my $contracts = GetContracts( { booksellerid => $booksellerid } );
82
82
83
    $template->param(
83
    $template->param(
84
        active        => $supplier->{'active'},
84
        active        => $supplier->active,
85
        tax_rate       => $supplier->{'tax_rate'} + 0.0,
85
        tax_rate      => $supplier->tax_rate + 0.0,
86
        invoiceprice  => $supplier->{'invoiceprice'},
86
        invoiceprice  => $supplier->invoiceprice,
87
        listprice     => $supplier->{'listprice'},
87
        listprice     => $supplier->listprice,
88
        basketcount   => $supplier->{'basketcount'},
88
        basketcount   => $supplier->baskets->count,
89
        subscriptioncount   => $supplier->{'subscriptioncount'},
89
        subscriptioncount   => $supplier->subscriptions->count,
90
        contracts     => $contracts,
90
        contracts     => $contracts,
91
    );
91
    );
92
} elsif ( $op eq 'delete' ) {
92
} elsif ( $op eq 'delete' ) {
93
    # no further message needed for the user
93
    # no further message needed for the user
94
    # the DELETE button only appears in the template if basketcount == 0
94
    # the DELETE button only appears in the template if basketcount == 0
95
    if ( $supplier->{'basketcount'} == 0 ) {
95
    if ( $supplier->basketcount == 0 ) {
96
        DelBookseller($booksellerid);
96
        Koha::Acquisition::Booksellers->find($booksellerid)->delete;
97
    }
97
    }
98
    print $query->redirect('/cgi-bin/koha/acqui/acqui-home.pl');
98
    print $query->redirect('/cgi-bin/koha/acqui/acqui-home.pl');
99
    exit;
99
    exit;
Lines 101-114 if ( $op eq 'display' ) { Link Here
101
    my @currencies = GetCurrencies();
101
    my @currencies = GetCurrencies();
102
    my $loop_currency;
102
    my $loop_currency;
103
    my $active_currency = GetCurrency();
103
    my $active_currency = GetCurrency();
104
    my $active_listprice = $supplier->{'listprice'};
104
    my ( $active_listprice, $active_invoiceprice );
105
    my $active_invoiceprice = $supplier->{'invoiceprice'};
105
    if ( $supplier ) {
106
    if (!$supplier->{listprice}) {
106
        my $active_listprice = $supplier->listprice;
107
        $active_listprice =  $active_currency->{currency};
107
        my $active_invoiceprice = $supplier->invoiceprice;
108
    }
108
        if (!$supplier->listprice) {
109
    if (!$supplier->{invoiceprice}) {
109
            $active_listprice =  $active_currency->{currency};
110
        $active_invoiceprice =  $active_currency->{currency};
110
        }
111
        if (!$supplier->invoiceprice) {
112
            $active_invoiceprice =  $active_currency->{currency};
113
        }
114
        $template->param(
115
            active       => $booksellerid ? $supplier->active : 1,
116
            gstrate       => $supplier->gstrate ? $supplier->gstrate + 0.0 : 0,
117
        );
111
    }
118
    }
119
112
    for (@currencies) {
120
    for (@currencies) {
113
        push @{$loop_currency},
121
        push @{$loop_currency},
114
            { 
122
            { 
Lines 125-132 if ( $op eq 'display' ) { Link Here
125
133
126
    $template->param(
134
    $template->param(
127
        # set active ON by default for supplier add (id empty for add)
135
        # set active ON by default for supplier add (id empty for add)
128
        active       => $booksellerid ? $supplier->{'active'} : 1,
136
        active        => $booksellerid ? $supplier->active : 1,
129
        tax_rate       => $supplier->{tax_rate} ? $supplier->{'tax_rate'}+0.0 : 0,
137
        tax_rate      => $supplier->tax_rate ? $supplier->tax_rate+0.0 : 0,
130
        gst_values    => \@gst_values,
138
        gst_values    => \@gst_values,
131
        loop_currency => $loop_currency,
139
        loop_currency => $loop_currency,
132
        enter         => 1,
140
        enter         => 1,
(-)a/acqui/transferorder.pl (-9 / +10 lines)
Lines 28-33 use C4::Context; Link Here
28
use C4::Acquisition;
28
use C4::Acquisition;
29
use C4::Members;
29
use C4::Members;
30
use C4::Dates qw/format_date_in_iso/;
30
use C4::Dates qw/format_date_in_iso/;
31
use Koha::Acquisition::Booksellers;
31
use Date::Calc qw/Today/;
32
use Date::Calc qw/Today/;
32
33
33
my $input = new CGI;
34
my $input = new CGI;
Lines 54-76 if($order) { Link Here
54
    $bookselleridfrom = $basket->{booksellerid} if $basket;
55
    $bookselleridfrom = $basket->{booksellerid} if $basket;
55
}
56
}
56
57
57
my $booksellerfrom = Koha::Acquisition::Bookseller->fetch({ id => $bookselleridfrom });
58
my $booksellerfrom = Koha::Acquisition::Booksellers->find( $bookselleridfrom );
58
my $booksellerfromname;
59
my $booksellerfromname;
59
if($booksellerfrom){
60
if($booksellerfrom){
60
    $booksellerfromname = $booksellerfrom->{name};
61
    $booksellerfromname = $booksellerfrom->name;
61
}
62
}
62
my $booksellerto = Koha::Acquisition::Bookseller->fetch({ id => $bookselleridto });
63
my $booksellerto = Koha::Acquisition::Booksellers->find( $bookselleridto );
63
my $booksellertoname;
64
my $booksellertoname;
64
if($booksellerto){
65
if($booksellerto){
65
    $booksellertoname = $booksellerto->{name};
66
    $booksellertoname = $booksellerto->name;
66
}
67
}
67
68
68
if( $basketno && $ordernumber) {
69
if( $basketno && $ordernumber) {
69
    # Transfer order and exit
70
    # Transfer order and exit
70
    my $order = GetOrder( $ordernumber );
71
    my $order = GetOrder( $ordernumber );
71
    my $basket = GetBasket($order->{basketno});
72
    my $basket = GetBasket($order->{basketno});
72
    my $booksellerfrom = Koha::Acquisition::Bookseller->fetch({ id => $basket->{booksellerid} });
73
    my $booksellerfrom = Koha::Acquisition::Booksellers->find( $basket->{booksellerid} );
73
    my $bookselleridfrom = $booksellerfrom->{id};
74
    my $bookselleridfrom = $booksellerfrom->id;
74
75
75
    TransferOrder($ordernumber, $basketno);
76
    TransferOrder($ordernumber, $basketno);
76
77
Lines 79-86 if( $basketno && $ordernumber) { Link Here
79
    # Show open baskets for this bookseller
80
    # Show open baskets for this bookseller
80
    my $order = GetOrder( $ordernumber );
81
    my $order = GetOrder( $ordernumber );
81
    my $basketfrom = GetBasket( $order->{basketno} );
82
    my $basketfrom = GetBasket( $order->{basketno} );
82
    my $booksellerfrom = Koha::Acquisition::Bookseller->fetch({ id => $basketfrom->{booksellerid} });
83
    my $booksellerfrom = Koha::Acquisition::Booksellers->find( $basketfrom->{booksellerid} );
83
    $booksellerfromname = $booksellerfrom->{name};
84
    $booksellerfromname = $booksellerfrom->name;
84
    my $baskets = GetBasketsByBookseller( $bookselleridto );
85
    my $baskets = GetBasketsByBookseller( $bookselleridto );
85
    my $basketscount = scalar @$baskets;
86
    my $basketscount = scalar @$baskets;
86
    my @basketsloop = ();
87
    my @basketsloop = ();
Lines 116-122 if( $basketno && $ordernumber) { Link Here
116
    # Search for booksellers to transfer from/to
117
    # Search for booksellers to transfer from/to
117
    $op = '' unless $op;
118
    $op = '' unless $op;
118
    if( $op eq "do_search" ) {
119
    if( $op eq "do_search" ) {
119
        my @booksellers = Koha::Acquisition::Bookseller->search({ name => $query });
120
        my @booksellers = Koha::Acquisition::Booksellers->search({ name => $query });
120
        $template->param(
121
        $template->param(
121
            query => $query,
122
            query => $query,
122
            do_search => 1,
123
            do_search => 1,
(-)a/acqui/uncertainprice.pl (-17 / +17 lines)
Lines 55-61 use C4::Bookseller::Contact; Link Here
55
use C4::Acquisition qw/SearchOrders GetOrder ModOrder/;
55
use C4::Acquisition qw/SearchOrders GetOrder ModOrder/;
56
use C4::Biblio qw/GetBiblioData/;
56
use C4::Biblio qw/GetBiblioData/;
57
57
58
use Koha::Acquisition::Bookseller;
58
use Koha::Acquisition::Booksellers;
59
59
60
my $input=new CGI;
60
my $input=new CGI;
61
61
Lines 72-78 my $booksellerid = $input->param('booksellerid'); Link Here
72
my $basketno     = $input->param('basketno');
72
my $basketno     = $input->param('basketno');
73
my $op = $input->param('op');
73
my $op = $input->param('op');
74
my $owner = $input->param('owner') || 0 ; # flag to see only "my" orders, or everyone orders
74
my $owner = $input->param('owner') || 0 ; # flag to see only "my" orders, or everyone orders
75
my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
75
my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
76
76
77
#show all orders that have uncertain price for the bookseller
77
#show all orders that have uncertain price for the bookseller
78
my $pendingorders = SearchOrders({
78
my $pendingorders = SearchOrders({
Lines 107-113 if ( $op eq 'validate' ) { Link Here
107
        my $ordernumber = $order->{ordernumber};
107
        my $ordernumber = $order->{ordernumber};
108
        my $order_as_from_db=GetOrder($order->{ordernumber});
108
        my $order_as_from_db=GetOrder($order->{ordernumber});
109
        $order->{'listprice'} = $input->param('price'.$ordernumber);
109
        $order->{'listprice'} = $input->param('price'.$ordernumber);
110
        $order->{'ecost'}= $input->param('price'.$ordernumber) - (($input->param('price'.$ordernumber) /100) * $bookseller->{'discount'});
110
        $order->{'ecost'}= $input->param('price'.$ordernumber) - (($input->param('price'.$ordernumber) /100) * $bookseller->discount);
111
        $order->{'rrp'} = $input->param('price'.$ordernumber);
111
        $order->{'rrp'} = $input->param('price'.$ordernumber);
112
        $order->{'quantity'}=$input->param('qty'.$ordernumber);
112
        $order->{'quantity'}=$input->param('qty'.$ordernumber);
113
        $order->{'uncertainprice'}=$input->param('uncertainprice'.$ordernumber);
113
        $order->{'uncertainprice'}=$input->param('uncertainprice'.$ordernumber);
Lines 116-135 if ( $op eq 'validate' ) { Link Here
116
}
116
}
117
117
118
$template->param( uncertainpriceorders => \@orders,
118
$template->param( uncertainpriceorders => \@orders,
119
                                   booksellername => "".$bookseller->{'name'},
119
                                   booksellername => "".$bookseller->name,
120
                                   booksellerid => $bookseller->{'id'},
120
                                   booksellerid => $bookseller->id,
121
                                   booksellerpostal =>$bookseller->{'postal'},
121
                                   booksellerpostal =>$bookseller->postal,
122
                                   bookselleraddress1 => $bookseller->{'address1'},
122
                                   bookselleraddress1 => $bookseller->address1,
123
                                   bookselleraddress2 => $bookseller->{'address2'},
123
                                   bookselleraddress2 => $bookseller->address2,
124
                                   bookselleraddress3 => $bookseller->{'address3'},
124
                                   bookselleraddress3 => $bookseller->address3,
125
                                   bookselleraddress4 => $bookseller->{'address4'},
125
                                   bookselleraddress4 => $bookseller->address4,
126
                                   booksellerphone =>$bookseller->{'phone'},
126
                                   booksellerphone =>$bookseller->phone,
127
                                   booksellerfax => $bookseller->{'fax'},
127
                                   booksellerfax => $bookseller->fax,
128
                                   booksellerurl => $bookseller->{'url'},
128
                                   booksellerurl => $bookseller->url,
129
                                   booksellernotes => $bookseller->{'notes'},
129
                                   booksellernotes => $bookseller->notes,
130
                                   basketcount   => $bookseller->{'basketcount'},
130
                                   basketcount   => $bookseller->baskets->count,
131
                                   subscriptioncount   => $bookseller->{'subscriptioncount'},
131
                                   subscriptioncount   => $bookseller->subscriptions->count,
132
                                   owner => $owner,
132
                                   owner => $owner,
133
                                   scriptname => "/cgi-bin/koha/acqui/uncertainprice.pl");
133
                                   scriptname => "/cgi-bin/koha/acqui/uncertainprice.pl");
134
$template->{'VARS'}->{'contacts'} = $bookseller->{'contacts'};
134
$template->{'VARS'}->{'contacts'} = $bookseller->contacts;
135
output_html_with_http_headers $input, $cookie, $template->output;
135
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/acqui/updatesupplier.pl (-7 / +24 lines)
Lines 52-61 use List::Util; Link Here
52
use C4::Context;
52
use C4::Context;
53
use C4::Auth;
53
use C4::Auth;
54
54
55
use C4::Bookseller qw( ModBookseller AddBookseller );
56
use C4::Bookseller::Contact;
55
use C4::Bookseller::Contact;
57
use C4::Biblio;
56
use C4::Biblio;
58
use C4::Output;
57
use C4::Output;
58
59
use Koha::Acquisition::Bookseller;
60
use Koha::Acquisition::Booksellers;
59
use CGI qw ( -utf8 );
61
use CGI qw ( -utf8 );
60
62
61
my $input=new CGI;
63
my $input=new CGI;
Lines 115-129 for my $cnt (0..scalar(@{$contact_info{'id'}})) { Link Here
115
        $contact{$_} = $contact_info{$_}->[$cnt];
117
        $contact{$_} = $contact_info{$_}->[$cnt];
116
        $real_contact = 1 if $contact{$_};
118
        $real_contact = 1 if $contact{$_};
117
    }
119
    }
118
    push @contacts, C4::Bookseller::Contact->new(\%contact) if $real_contact;
120
    push @contacts, \%contact if $real_contact;
119
}
121
}
120
122
121
if($data{'name'}) {
123
if($data{'name'}) {
122
	if ($data{'id'}){
124
    if ( $data{id} ) {
123
        ModBookseller(\%data, \@contacts);
125
        # Update
124
	} else {
126
        my $bookseller = Koha::Acquisition::Booksellers->find( $data{id} )->set(\%data)->store;
125
        $data{id}=AddBookseller(\%data, \@contacts);
127
        my $contacts = $bookseller->contacts;
126
	}
128
        # Delete existing contacts
129
        while ( my $contact = $contacts->next ) {
130
            $contact->delete;
131
        }
132
    } else {
133
        # Insert
134
        delete $data{id}; # Remove the key if exists
135
        my $bookseller = Koha::Acquisition::Bookseller->new( \%data )->store;
136
        $data{id} = $bookseller->id;
137
    }
138
    # Insert contacts
139
    for my $contact ( @contacts ) {
140
        $contact->{booksellerid} = $data{id};
141
        Koha::Acquisition::Bookseller::Contact->new( $contact )->store
142
    }
143
127
    #redirect to booksellers.pl
144
    #redirect to booksellers.pl
128
    print $input->redirect("booksellers.pl?booksellerid=".$data{id});
145
    print $input->redirect("booksellers.pl?booksellerid=".$data{id});
129
} else {
146
} else {
(-)a/acqui/z3950_search.pl (-3 / +3 lines)
Lines 29-35 use C4::Context; Link Here
29
use C4::Breeding;
29
use C4::Breeding;
30
use C4::Koha;
30
use C4::Koha;
31
31
32
use Koha::Acquisition::Bookseller;
32
use Koha::Acquisition::Booksellers;
33
33
34
my $input           = new CGI;
34
my $input           = new CGI;
35
my $biblionumber    = $input->param('biblionumber')||0;
35
my $biblionumber    = $input->param('biblionumber')||0;
Lines 63-69 foreach my $thisframeworkcode ( keys %$frameworks ) { Link Here
63
    push @frameworkcodeloop, \%row;
63
    push @frameworkcodeloop, \%row;
64
}
64
}
65
65
66
my $vendor = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
66
my $vendor = Koha::Acquisition::Booksellers->find( $booksellerid );
67
67
68
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
68
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
69
    {
69
    {
Lines 78-84 $template->param( Link Here
78
        frameworkcodeloop => \@frameworkcodeloop,
78
        frameworkcodeloop => \@frameworkcodeloop,
79
        booksellerid => $booksellerid,
79
        booksellerid => $booksellerid,
80
        basketno     => $basketno,
80
        basketno     => $basketno,
81
        name         => $vendor->{'name'},
81
        name         => $vendor->name,
82
        isbn         => $isbn,
82
        isbn         => $isbn,
83
        issn         => $issn,
83
        issn         => $issn,
84
        lccn         => $lccn,
84
        lccn         => $lccn,
(-)a/admin/aqcontract.pl (-5 / +5 lines)
Lines 29-42 use C4::Output; Link Here
29
use C4::Dates qw/format_date format_date_in_iso/;
29
use C4::Dates qw/format_date format_date_in_iso/;
30
use C4::Contract;
30
use C4::Contract;
31
31
32
use Koha::Acquisition::Bookseller;
32
use Koha::Acquisition::Booksellers;
33
33
34
my $input          = new CGI;
34
my $input          = new CGI;
35
my $contractnumber = $input->param('contractnumber');
35
my $contractnumber = $input->param('contractnumber');
36
my $booksellerid   = $input->param('booksellerid');
36
my $booksellerid   = $input->param('booksellerid');
37
my $op             = $input->param('op') || 'list';
37
my $op             = $input->param('op') || 'list';
38
38
39
my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
39
my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
40
40
41
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
41
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
42
    {   template_name   => "admin/aqcontract.tt",
42
    {   template_name   => "admin/aqcontract.tt",
Lines 51-59 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
51
$template->param(
51
$template->param(
52
    contractnumber => $contractnumber,
52
    contractnumber => $contractnumber,
53
    booksellerid   => $booksellerid,
53
    booksellerid   => $booksellerid,
54
    booksellername => $bookseller->{name},
54
    booksellername => $bookseller->name,
55
    basketcount   => $bookseller->{'basketcount'},
55
    basketcount   => $bookseller->baskets->count,
56
    subscriptioncount   => $bookseller->{'subscriptioncount'},
56
    subscriptioncount   => $bookseller->subscriptions->count,
57
);
57
);
58
58
59
#ADD_FORM: called if $op is 'add_form'. Used to create form to add or  modify a record
59
#ADD_FORM: called if $op is 'add_form'. Used to create form to add or  modify a record
(-)a/catalogue/moredetail.pl (-3 / +3 lines)
Lines 36-42 use C4::Search; # enabled_staff_search_views Link Here
36
use C4::Members qw/GetHideLostItemsPreference/;
36
use C4::Members qw/GetHideLostItemsPreference/;
37
use C4::Reserves qw(GetReservesFromBiblionumber);
37
use C4::Reserves qw(GetReservesFromBiblionumber);
38
38
39
use Koha::Acquisition::Bookseller;
39
use Koha::Acquisition::Booksellers;
40
use Koha::DateUtils;
40
use Koha::DateUtils;
41
41
42
my $query=new CGI;
42
my $query=new CGI;
Lines 162-169 foreach my $item (@items){ Link Here
162
    $item->{'orderdate'}               = $order->{'entrydate'};
162
    $item->{'orderdate'}               = $order->{'entrydate'};
163
    if ($item->{'basketno'}){
163
    if ($item->{'basketno'}){
164
	    my $basket = GetBasket($item->{'basketno'});
164
	    my $basket = GetBasket($item->{'basketno'});
165
        my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $basket->{booksellerid} });
165
        my $bookseller = Koha::Acquisition::Booksellers->find( $basket->{booksellerid} );
166
	    $item->{'vendor'} = $bookseller->{'name'};
166
        $item->{'vendor'} = $bookseller->name;
167
    }
167
    }
168
    $item->{'invoiceid'}               = $order->{'invoiceid'};
168
    $item->{'invoiceid'}               = $order->{'invoiceid'};
169
    if($item->{invoiceid}) {
169
    if($item->{invoiceid}) {
(-)a/serials/subscription-detail.pl (-6 / +6 lines)
Lines 27-33 use C4::Output; Link Here
27
use C4::Context;
27
use C4::Context;
28
use C4::Search qw/enabled_staff_search_views/;
28
use C4::Search qw/enabled_staff_search_views/;
29
29
30
use Koha::Acquisition::Bookseller;
30
use Koha::Acquisition::Booksellers;
31
31
32
use Date::Calc qw/Today Day_of_Year Week_of_Year Add_Delta_Days/;
32
use Date::Calc qw/Today Day_of_Year Week_of_Year Add_Delta_Days/;
33
use Carp;
33
use Carp;
Lines 119-125 if ( defined $subscriptionid ) { Link Here
119
    my $lastOrderReceived = GetLastOrderReceivedFromSubscriptionid $subscriptionid;
119
    my $lastOrderReceived = GetLastOrderReceivedFromSubscriptionid $subscriptionid;
120
    if ( defined $lastOrderNotReceived ) {
120
    if ( defined $lastOrderNotReceived ) {
121
        my $basket = GetBasket $lastOrderNotReceived->{basketno};
121
        my $basket = GetBasket $lastOrderNotReceived->{basketno};
122
        my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $basket->{booksellerid} });
122
        my $bookseller = Koha::Acquisition::Booksellers->find( $basket->{booksellerid} );
123
        ( $tmpl_infos->{value_tax_included_ordered}, $tmpl_infos->{value_tax_excluded_ordered} ) = get_value_with_gst_params ( $lastOrderNotReceived->{ecost}, $lastOrderNotReceived->{tax_rate}, $bookseller );
123
        ( $tmpl_infos->{value_tax_included_ordered}, $tmpl_infos->{value_tax_excluded_ordered} ) = get_value_with_gst_params ( $lastOrderNotReceived->{ecost}, $lastOrderNotReceived->{tax_rate}, $bookseller );
124
        $tmpl_infos->{value_tax_included_ordered} = sprintf( "%.2f", $tmpl_infos->{value_tax_included_ordered} );
124
        $tmpl_infos->{value_tax_included_ordered} = sprintf( "%.2f", $tmpl_infos->{value_tax_included_ordered} );
125
        $tmpl_infos->{value_tax_excluded_ordered} = sprintf( "%.2f", $tmpl_infos->{value_tax_excluded_ordered} );
125
        $tmpl_infos->{value_tax_excluded_ordered} = sprintf( "%.2f", $tmpl_infos->{value_tax_excluded_ordered} );
Lines 129-135 if ( defined $subscriptionid ) { Link Here
129
    }
129
    }
130
    if ( defined $lastOrderReceived ) {
130
    if ( defined $lastOrderReceived ) {
131
        my $basket = GetBasket $lastOrderReceived->{basketno};
131
        my $basket = GetBasket $lastOrderReceived->{basketno};
132
        my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $basket->{booksellerid} });
132
        my $bookseller = Koha::Acquisition::Booksellers->find( $basket->{booksellerid} );
133
        ( $tmpl_infos->{value_tax_included_spent}, $tmpl_infos->{value_tax_excluded_spent} ) = get_value_with_gst_params ( $lastOrderReceived->{unitprice}, $lastOrderReceived->{tax_rate}, $bookseller );
133
        ( $tmpl_infos->{value_tax_included_spent}, $tmpl_infos->{value_tax_excluded_spent} ) = get_value_with_gst_params ( $lastOrderReceived->{unitprice}, $lastOrderReceived->{tax_rate}, $bookseller );
134
        $tmpl_infos->{value_tax_included_spent} = sprintf( "%.2f", $tmpl_infos->{value_tax_included_spent} );
134
        $tmpl_infos->{value_tax_included_spent} = sprintf( "%.2f", $tmpl_infos->{value_tax_included_spent} );
135
        $tmpl_infos->{value_tax_excluded_spent} = sprintf( "%.2f", $tmpl_infos->{value_tax_excluded_spent} );
135
        $tmpl_infos->{value_tax_excluded_spent} = sprintf( "%.2f", $tmpl_infos->{value_tax_excluded_spent} );
Lines 182-188 sub get_value_with_gst_params { Link Here
182
    my $value = shift;
182
    my $value = shift;
183
    my $tax_rate = shift;
183
    my $tax_rate = shift;
184
    my $bookseller = shift;
184
    my $bookseller = shift;
185
    if ( $bookseller->{listincgst} ) {
185
    if ( $bookseller->listincgst ) {
186
        return ( $value, $value / ( 1 + $tax_rate ) );
186
        return ( $value, $value / ( 1 + $tax_rate ) );
187
    } else {
187
    } else {
188
        return ( $value * ( 1 + $tax_rate ), $value );
188
        return ( $value * ( 1 + $tax_rate ), $value );
Lines 193-199 sub get_tax_excluded { Link Here
193
    my $value = shift;
193
    my $value = shift;
194
    my $tax_rate = shift;
194
    my $tax_rate = shift;
195
    my $bookseller = shift;
195
    my $bookseller = shift;
196
    if ( $bookseller->{invoiceincgst} ) {
196
    if ( $bookseller->invoiceincgst ) {
197
        return $value / ( 1 + $tax_rate );
197
        return $value / ( 1 + $tax_rate );
198
    } else {
198
    } else {
199
        return $value;
199
        return $value;
Lines 204-210 sub get_gst { Link Here
204
    my $value = shift;
204
    my $value = shift;
205
    my $tax_rate = shift;
205
    my $tax_rate = shift;
206
    my $bookseller = shift;
206
    my $bookseller = shift;
207
    if ( $bookseller->{invoiceincgst} ) {
207
    if ( $bookseller->invoiceincgst ) {
208
        return $value / ( 1 + $tax_rate ) * $tax_rate;
208
        return $value / ( 1 + $tax_rate ) * $tax_rate;
209
    } else {
209
    } else {
210
        return $value * ( 1 + $tax_rate ) - $value;
210
        return $value * ( 1 + $tax_rate ) - $value;
(-)a/t/db_dependent/Acquisition.t (-7 / +6 lines)
Lines 23-34 use Test::More tests => 87; Link Here
23
23
24
BEGIN {
24
BEGIN {
25
    use_ok('C4::Acquisition');
25
    use_ok('C4::Acquisition');
26
    use_ok('C4::Bookseller');
27
    use_ok('C4::Biblio');
26
    use_ok('C4::Biblio');
28
    use_ok('C4::Budgets');
27
    use_ok('C4::Budgets');
29
    use_ok('C4::Bookseller');
30
    use_ok('Koha::Acquisition::Order');
28
    use_ok('Koha::Acquisition::Order');
31
    use_ok('Koha::Acquisition::Bookseller');
29
    use_ok('Koha::Acquisition::Bookseller');
30
    use_ok('Koha::Acquisition::Booksellers');
32
}
31
}
33
32
34
# Sub used for testing C4::Acquisition subs returning order(s):
33
# Sub used for testing C4::Acquisition subs returning order(s):
Lines 121-127 $dbh->{AutoCommit} = 0; Link Here
121
$dbh->{RaiseError} = 1;
120
$dbh->{RaiseError} = 1;
122
121
123
# Creating some orders
122
# Creating some orders
124
my $booksellerid = C4::Bookseller::AddBookseller(
123
my $bookseller = Koha::Acquisition::Bookseller->new(
125
    {
124
    {
126
        name         => "my vendor",
125
        name         => "my vendor",
127
        address1     => "bookseller's address",
126
        address1     => "bookseller's address",
Lines 129-139 my $booksellerid = C4::Bookseller::AddBookseller( Link Here
129
        active       => 1,
128
        active       => 1,
130
        deliverytime => 5,
129
        deliverytime => 5,
131
    }
130
    }
132
);
131
)->store;
133
132
my $booksellerid = $bookseller->id;
134
my $booksellerinfo = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
135
133
136
is( $booksellerinfo->{deliverytime},
134
my $booksellerinfo = Koha::Acquisition::Booksellers->find( $booksellerid );
135
is( $booksellerinfo->deliverytime,
137
    5, 'set deliverytime when creating vendor (Bug 10556)' );
136
    5, 'set deliverytime when creating vendor (Bug 10556)' );
138
137
139
my ( $basket, $basketno );
138
my ( $basket, $basketno );
(-)a/t/db_dependent/Acquisition/CancelReceipt.t (-4 / +5 lines)
Lines 7-35 use C4::Context; Link Here
7
use C4::Acquisition;
7
use C4::Acquisition;
8
use C4::Biblio;
8
use C4::Biblio;
9
use C4::Items;
9
use C4::Items;
10
use C4::Bookseller;
11
use C4::Budgets;
10
use C4::Budgets;
12
use t::lib::Mocks;
11
use t::lib::Mocks;
13
12
14
use Koha::DateUtils;
13
use Koha::DateUtils;
15
use Koha::Acquisition::Order;
14
use Koha::Acquisition::Order;
15
use Koha::Acquisition::Bookseller;
16
use MARC::Record;
16
use MARC::Record;
17
17
18
my $dbh = C4::Context->dbh;
18
my $dbh = C4::Context->dbh;
19
$dbh->{RaiseError} = 1;
19
$dbh->{RaiseError} = 1;
20
$dbh->{AutoCommit} = 0;
20
$dbh->{AutoCommit} = 0;
21
21
22
my $booksellerid1 = C4::Bookseller::AddBookseller(
22
my $bookseller = Koha::Acquisition::Bookseller->new(
23
    {
23
    {
24
        name => "my vendor 1",
24
        name => "my vendor 1",
25
        address1 => "bookseller's address",
25
        address1 => "bookseller's address",
26
        phone => "0123456",
26
        phone => "0123456",
27
        active => 1
27
        active => 1
28
    }
28
    }
29
);
29
)->store;
30
my $booksellerid = $bookseller->id;
30
31
31
my $basketno1 = C4::Acquisition::NewBasket(
32
my $basketno1 = C4::Acquisition::NewBasket(
32
    $booksellerid1
33
    $booksellerid
33
);
34
);
34
35
35
my $budgetid = C4::Budgets::AddBudget(
36
my $budgetid = C4::Budgets::AddBudget(
(-)a/t/db_dependent/Acquisition/GetBasketsInfosByBookseller.t (-3 / +4 lines)
Lines 6-22 use Data::Dumper; Link Here
6
6
7
use C4::Acquisition qw( NewBasket GetBasketsInfosByBookseller );
7
use C4::Acquisition qw( NewBasket GetBasketsInfosByBookseller );
8
use C4::Biblio qw( AddBiblio );
8
use C4::Biblio qw( AddBiblio );
9
use C4::Bookseller qw( AddBookseller );
10
use C4::Budgets qw( AddBudget );
9
use C4::Budgets qw( AddBudget );
11
use C4::Context;
10
use C4::Context;
12
11
13
use Koha::Acquisition::Order;
12
use Koha::Acquisition::Order;
13
use Koha::Acquisition::Bookseller;
14
14
15
my $dbh = C4::Context->dbh;
15
my $dbh = C4::Context->dbh;
16
$dbh->{AutoCommit} = 0;
16
$dbh->{AutoCommit} = 0;
17
$dbh->{RaiseError} = 1;
17
$dbh->{RaiseError} = 1;
18
18
19
my $supplierid = C4::Bookseller::AddBookseller(
19
my $supplier = Koha::Acquisition::Bookseller->new(
20
    {
20
    {
21
        name => 'my vendor',
21
        name => 'my vendor',
22
        address1 => 'bookseller\'s address',
22
        address1 => 'bookseller\'s address',
Lines 24-30 my $supplierid = C4::Bookseller::AddBookseller( Link Here
24
        active => 1,
24
        active => 1,
25
        deliverytime => 5,
25
        deliverytime => 5,
26
    }
26
    }
27
);
27
)->store;
28
my $supplierid = $supplier->id;
28
29
29
my $basketno;
30
my $basketno;
30
ok($basketno = NewBasket($supplierid, 1), 'NewBasket(  $supplierid , 1  ) returns $basketno');
31
ok($basketno = NewBasket($supplierid, 1), 'NewBasket(  $supplierid , 1  ) returns $basketno');
(-)a/t/db_dependent/Acquisition/GetOrdersByBiblionumber.t (-3 / +4 lines)
Lines 5-14 use Modern::Perl; Link Here
5
use Test::More;
5
use Test::More;
6
use C4::Acquisition;
6
use C4::Acquisition;
7
use C4::Biblio;
7
use C4::Biblio;
8
use C4::Bookseller;
9
use C4::Budgets;
8
use C4::Budgets;
10
9
11
use Koha::Acquisition::Order;
10
use Koha::Acquisition::Order;
11
use Koha::Acquisition::Bookseller;
12
12
13
use MARC::Record;
13
use MARC::Record;
14
14
Lines 17-30 my $dbh = C4::Context->dbh; Link Here
17
$dbh->{AutoCommit} = 0;
17
$dbh->{AutoCommit} = 0;
18
$dbh->{RaiseError} = 1;
18
$dbh->{RaiseError} = 1;
19
19
20
my $booksellerid = C4::Bookseller::AddBookseller(
20
my $bookseller = Koha::Acquisition::Bookseller->new(
21
    {
21
    {
22
        name => "my vendor",
22
        name => "my vendor",
23
        address1 => "bookseller's address",
23
        address1 => "bookseller's address",
24
        phone => "0123456",
24
        phone => "0123456",
25
        active => 1
25
        active => 1
26
    }
26
    }
27
);
27
)->store;
28
my $booksellerid = $bookseller->id;
28
29
29
my $basketno = C4::Acquisition::NewBasket(
30
my $basketno = C4::Acquisition::NewBasket(
30
    $booksellerid
31
    $booksellerid
(-)a/t/db_dependent/Acquisition/Invoices.t (-4 / +5 lines)
Lines 3-12 Link Here
3
use Modern::Perl;
3
use Modern::Perl;
4
4
5
use C4::Biblio qw( AddBiblio );
5
use C4::Biblio qw( AddBiblio );
6
use C4::Bookseller qw( AddBookseller );
7
6
8
use Koha::Acquisition::Order;
7
use Koha::Acquisition::Order;
9
use Koha::Acquisition::Bookseller;
8
use Koha::Acquisition::Bookseller;
9
use Koha::Acquisition::Booksellers;
10
10
11
use Test::More tests => 24;
11
use Test::More tests => 24;
12
12
Lines 20-35 $dbh->{RaiseError} = 1; Link Here
20
20
21
$dbh->do(q{DELETE FROM aqinvoices});
21
$dbh->do(q{DELETE FROM aqinvoices});
22
22
23
my $booksellerid = C4::Bookseller::AddBookseller(
23
my $bookseller = Koha::Acquisition::Bookseller->new(
24
    {
24
    {
25
        name => "my vendor",
25
        name => "my vendor",
26
        address1 => "bookseller's address",
26
        address1 => "bookseller's address",
27
        phone => "0123456",
27
        phone => "0123456",
28
        active => 1
28
        active => 1
29
    }
29
    }
30
);
30
)->store;
31
my $booksellerid = $bookseller->id;
31
32
32
my $booksellerinfo = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
33
my $booksellerinfo = Koha::Acquisition::Booksellers->find( $booksellerid );
33
my $basketno = NewBasket($booksellerid, 1);
34
my $basketno = NewBasket($booksellerid, 1);
34
my $basket   = GetBasket($basketno);
35
my $basket   = GetBasket($basketno);
35
36
(-)a/t/db_dependent/Acquisition/NewOrder.t (-3 / +4 lines)
Lines 5-28 use Modern::Perl; Link Here
5
use Test::More tests => 7;
5
use Test::More tests => 7;
6
use C4::Acquisition;
6
use C4::Acquisition;
7
use C4::Biblio;
7
use C4::Biblio;
8
use C4::Bookseller;
9
use C4::Budgets;
8
use C4::Budgets;
10
use MARC::Record;
9
use MARC::Record;
11
use Koha::DateUtils qw( dt_from_string output_pref );
10
use Koha::DateUtils qw( dt_from_string output_pref );
12
use Koha::Acquisition::Order;
11
use Koha::Acquisition::Order;
12
use Koha::Acquisition::Bookseller;
13
13
14
my $dbh = C4::Context->dbh;
14
my $dbh = C4::Context->dbh;
15
$dbh->{AutoCommit} = 0;
15
$dbh->{AutoCommit} = 0;
16
$dbh->{RaiseError} = 1;
16
$dbh->{RaiseError} = 1;
17
17
18
my $booksellerid = C4::Bookseller::AddBookseller(
18
my $bookseller = Koha::Acquisition::Bookseller->new(
19
    {
19
    {
20
        name => "my vendor",
20
        name => "my vendor",
21
        address1 => "bookseller's address",
21
        address1 => "bookseller's address",
22
        phone => "0123456",
22
        phone => "0123456",
23
        active => 1
23
        active => 1
24
    }
24
    }
25
);
25
)->store;
26
my $booksellerid = $bookseller->id;
26
27
27
my $basketno = C4::Acquisition::NewBasket(
28
my $basketno = C4::Acquisition::NewBasket(
28
    $booksellerid
29
    $booksellerid
(-)a/t/db_dependent/Acquisition/OrderFromSubscription.t (-3 / +4 lines)
Lines 4-12 use Test::More tests => 13; Link Here
4
4
5
use_ok('C4::Acquisition');
5
use_ok('C4::Acquisition');
6
use_ok('C4::Biblio');
6
use_ok('C4::Biblio');
7
use_ok('C4::Bookseller');
8
use_ok('C4::Budgets');
7
use_ok('C4::Budgets');
9
use_ok('C4::Serials');
8
use_ok('C4::Serials');
9
use_ok('Koha::Acquisition::Bookseller');
10
10
11
use Koha::Acquisition::Order;
11
use Koha::Acquisition::Order;
12
12
Lines 15-28 my $dbh = C4::Context->dbh; Link Here
15
$dbh->{AutoCommit} = 0;
15
$dbh->{AutoCommit} = 0;
16
$dbh->{RaiseError} = 1;
16
$dbh->{RaiseError} = 1;
17
17
18
my $booksellerid = C4::Bookseller::AddBookseller(
18
my $bookseller = Koha::Acquisition::Bookseller->new(
19
    {
19
    {
20
        name => "my vendor",
20
        name => "my vendor",
21
        address1 => "bookseller's address",
21
        address1 => "bookseller's address",
22
        phone => "0123456",
22
        phone => "0123456",
23
        active => 1
23
        active => 1
24
    }
24
    }
25
);
25
)->store;
26
my $booksellerid = $bookseller->id;
26
27
27
my ($biblionumber, $biblioitemnumber) = AddBiblio(MARC::Record->new, '');
28
my ($biblionumber, $biblioitemnumber) = AddBiblio(MARC::Record->new, '');
28
my $budgetid;
29
my $budgetid;
(-)a/t/db_dependent/Acquisition/TransferOrder.t (-5 / +7 lines)
Lines 7-43 use C4::Context; Link Here
7
use C4::Acquisition;
7
use C4::Acquisition;
8
use C4::Biblio;
8
use C4::Biblio;
9
use C4::Items;
9
use C4::Items;
10
use C4::Bookseller;
11
use C4::Budgets;
10
use C4::Budgets;
12
use Koha::DateUtils;
11
use Koha::DateUtils;
13
use Koha::Acquisition::Order;
12
use Koha::Acquisition::Order;
13
use Koha::Acquisition::Bookseller;
14
use MARC::Record;
14
use MARC::Record;
15
15
16
my $dbh = C4::Context->dbh;
16
my $dbh = C4::Context->dbh;
17
$dbh->{RaiseError} = 1;
17
$dbh->{RaiseError} = 1;
18
$dbh->{AutoCommit} = 0;
18
$dbh->{AutoCommit} = 0;
19
19
20
my $booksellerid1 = C4::Bookseller::AddBookseller(
20
my $bookseller1 = Koha::Acquisition::Bookseller->new(
21
    {
21
    {
22
        name => "my vendor 1",
22
        name => "my vendor 1",
23
        address1 => "bookseller's address",
23
        address1 => "bookseller's address",
24
        phone => "0123456",
24
        phone => "0123456",
25
        active => 1
25
        active => 1
26
    }
26
    }
27
);
27
)->store;
28
my $booksellerid1 = $bookseller1->id;
28
29
29
my $basketno1 = C4::Acquisition::NewBasket(
30
my $basketno1 = C4::Acquisition::NewBasket(
30
    $booksellerid1
31
    $booksellerid1
31
);
32
);
32
33
33
my $booksellerid2 = C4::Bookseller::AddBookseller(
34
my $bookseller2 = Koha::Acquisition::Bookseller->new(
34
    {
35
    {
35
        name => "my vendor 2",
36
        name => "my vendor 2",
36
        address1 => "bookseller's address",
37
        address1 => "bookseller's address",
37
        phone => "0123456",
38
        phone => "0123456",
38
        active => 1
39
        active => 1
39
    }
40
    }
40
);
41
)->store;
42
my $booksellerid2 = $bookseller2->id;
41
43
42
my $basketno2 = C4::Acquisition::NewBasket(
44
my $basketno2 = C4::Acquisition::NewBasket(
43
    $booksellerid2
45
    $booksellerid2
(-)a/t/db_dependent/Acquisition/close_reopen_basket.t (-3 / +4 lines)
Lines 5-13 use Modern::Perl; Link Here
5
use Test::More tests => 6;
5
use Test::More tests => 6;
6
use C4::Acquisition;
6
use C4::Acquisition;
7
use C4::Biblio qw( AddBiblio DelBiblio );
7
use C4::Biblio qw( AddBiblio DelBiblio );
8
use C4::Bookseller;
9
use C4::Budgets;
8
use C4::Budgets;
10
use C4::Context;
9
use C4::Context;
10
use Koha::Acquisition::Bookseller;
11
11
12
use Koha::Acquisition::Order;
12
use Koha::Acquisition::Order;
13
13
Lines 20-33 $dbh->do(q{ Link Here
20
    DELETE FROM aqorders;
20
    DELETE FROM aqorders;
21
});
21
});
22
22
23
my $booksellerid = C4::Bookseller::AddBookseller(
23
my $bookseller = Koha::Acquisition::Bookseller->new(
24
    {
24
    {
25
        name => "my vendor",
25
        name => "my vendor",
26
        address1 => "bookseller's address",
26
        address1 => "bookseller's address",
27
        phone => "0123456",
27
        phone => "0123456",
28
        active => 1
28
        active => 1
29
    }
29
    }
30
);
30
)->store;
31
my $booksellerid = $bookseller->id;
31
32
32
my $basketno = C4::Acquisition::NewBasket(
33
my $basketno = C4::Acquisition::NewBasket(
33
    $booksellerid
34
    $booksellerid
(-)a/t/db_dependent/Bookseller.t (-92 / +98 lines)
Lines 19-33 use Koha::Acquisition::Order; Link Here
19
BEGIN {
19
BEGIN {
20
    use_ok('C4::Bookseller');
20
    use_ok('C4::Bookseller');
21
    use_ok('Koha::Acquisition::Bookseller');
21
    use_ok('Koha::Acquisition::Bookseller');
22
    use_ok('Koha::Acquisition::Booksellers');
22
}
23
}
23
24
24
can_ok(
25
can_ok(
25
26
26
    'C4::Bookseller', qw(
27
    'C4::Bookseller', qw(
27
      AddBookseller
28
      DelBookseller
29
      GetBooksellersWithLateOrders
28
      GetBooksellersWithLateOrders
30
      ModBookseller )
29
    )
31
);
30
);
32
31
33
#Start transaction
32
#Start transaction
Lines 42-48 $dbh->do(q|DELETE FROM aqbooksellers|); Link Here
42
$dbh->do(q|DELETE FROM subscription|);
41
$dbh->do(q|DELETE FROM subscription|);
43
42
44
#Test AddBookseller
43
#Test AddBookseller
45
my $count            = scalar( Koha::Acquisition::Bookseller->search() );
44
my $count            = Koha::Acquisition::Booksellers->search()->count();
46
my $sample_supplier1 = {
45
my $sample_supplier1 = {
47
    name          => 'Name1',
46
    name          => 'Name1',
48
    address1      => 'address1_1',
47
    address1      => 'address1_1',
Lines 84-120 my $sample_supplier2 = { Link Here
84
    deliverytime  => 2
83
    deliverytime  => 2
85
};
84
};
86
85
87
my $id_supplier1 = C4::Bookseller::AddBookseller($sample_supplier1);
86
my $supplier1 = Koha::Acquisition::Bookseller->new($sample_supplier1)->store;
88
my $id_supplier2 = C4::Bookseller::AddBookseller($sample_supplier2);
87
my $id_supplier1 = $supplier1->id;
89
88
my $supplier2 = Koha::Acquisition::Bookseller->new($sample_supplier2)->store;
90
#my $id_bookseller3 = C4::Bookseller::AddBookseller();# NOTE : Doesn't work because the field name cannot be null
89
my $id_supplier2 = $supplier2->id;
91
90
92
like( $id_supplier1, '/^\d+$/', "AddBookseller for supplier1 return an id" );
91
like( $id_supplier1, '/^\d+$/', "AddBookseller for supplier1 return an id" );
93
like( $id_supplier2, '/^\d+$/', "AddBookseller for supplier2 return an id" );
92
like( $id_supplier2, '/^\d+$/', "AddBookseller for supplier2 return an id" );
94
my @b = Koha::Acquisition::Bookseller->search();
93
is( Koha::Acquisition::Booksellers->search()->count,
95
is ( scalar(@b),
96
    $count + 2, "Supplier1 and Supplier2 have been added" );
94
    $count + 2, "Supplier1 and Supplier2 have been added" );
97
95
98
#Test DelBookseller
96
#Test DelBookseller
99
my $del = C4::Bookseller::DelBookseller($id_supplier1);
97
my $del = $supplier1->delete;
100
is( $del, 1, "DelBookseller returns 1 - 1 supplier has been deleted " );
98
is( $del, 1, "DelBookseller returns 1 - 1 supplier has been deleted " );
101
my $b = Koha::Acquisition::Bookseller->fetch({id => $id_supplier1});
99
my $b = Koha::Acquisition::Booksellers->find( $id_supplier1 );
102
is( $b,
100
is( $b,
103
    undef, "Supplier1  has been deleted - id_supplier1 $id_supplier1 doesnt exist anymore" );
101
    undef, "Supplier1  has been deleted - id_supplier1 $id_supplier1 doesnt exist anymore" );
104
102
105
#Test get bookseller
103
#Test get bookseller
106
my @bookseller2 = Koha::Acquisition::Bookseller->search({name => $sample_supplier2->{name} });
104
my @bookseller2 = Koha::Acquisition::Booksellers->search({name => $sample_supplier2->{name} });
107
is( scalar(@bookseller2), 1, "Get only  Supplier2" );
105
is( scalar(@bookseller2), 1, "Get only  Supplier2" );
108
$bookseller2[0] = field_filter( $bookseller2[0] );
106
for my $bookseller ( @bookseller2 ) {
107
    $bookseller = field_filter( $bookseller->as_hashref );
108
}
109
109
110
$sample_supplier2->{id} = $id_supplier2;
110
$sample_supplier2->{id} = $id_supplier2;
111
is_deeply( $bookseller2[0], $sample_supplier2,
111
is_deeply( $bookseller2[0], $sample_supplier2,
112
    "Koha::Acquisition::Bookseller->search returns the right informations about $sample_supplier2" );
112
    "Koha::Acquisition::Booksellers->search returns the right informations about supplier $sample_supplier2->{name}" );
113
113
114
$id_supplier1 = C4::Bookseller::AddBookseller($sample_supplier1);
114
$supplier1 = Koha::Acquisition::Bookseller->new($sample_supplier1)->store;
115
my @booksellers = Koha::Acquisition::Bookseller->search(); #NOTE :without params, it returns all the booksellers
115
$id_supplier1 = $supplier1->id;
116
for my $i ( 0 .. scalar(@booksellers) - 1 ) {
116
my @booksellers = Koha::Acquisition::Booksellers->search();
117
    $booksellers[$i] = field_filter( $booksellers[$i] );
117
for my $bookseller ( @booksellers ) {
118
    $bookseller = field_filter( $bookseller->as_hashref );
118
}
119
}
119
120
120
$sample_supplier1->{id} = $id_supplier1;
121
$sample_supplier1->{id} = $id_supplier1;
Lines 123-152 my @tab = ( $sample_supplier1, $sample_supplier2 ); Link Here
123
is_deeply( \@booksellers, \@tab,
124
is_deeply( \@booksellers, \@tab,
124
    "Returns right fields of Supplier1 and Supplier2" );
125
    "Returns right fields of Supplier1 and Supplier2" );
125
126
126
#Test basket_count
127
#Test baskets
127
my @bookseller1 = Koha::Acquisition::Bookseller->search({name => $sample_supplier1->{name} });
128
my @bookseller1 = Koha::Acquisition::Booksellers->search({name => $sample_supplier1->{name} });
128
is( $bookseller1[0]->basket_count, 0, 'Supplier1 has 0 basket' );
129
is( $bookseller1[0]->baskets->count, 0, 'Supplier1 has 0 basket' );
129
my $basketno1 =
130
my $basketno1 =
130
  C4::Acquisition::NewBasket( $id_supplier1, 'authorisedby1', 'basketname1' );
131
  C4::Acquisition::NewBasket( $id_supplier1, 'authorisedby1', 'basketname1' );
131
my $basketno2 =
132
my $basketno2 =
132
  C4::Acquisition::NewBasket( $id_supplier1, 'authorisedby2', 'basketname2' );
133
  C4::Acquisition::NewBasket( $id_supplier1, 'authorisedby2', 'basketname2' );
133
@bookseller1 = Koha::Acquisition::Bookseller::search({ name => $sample_supplier1->{name} });
134
@bookseller1 = Koha::Acquisition::Booksellers->search({ name => $sample_supplier1->{name} });
134
is( $bookseller1[0]->basket_count, 2, 'Supplier1 has 2 baskets' );
135
is( $bookseller1[0]->baskets->count, 2, 'Supplier1 has 2 baskets' );
135
136
136
#Test Koha::Acquisition::Bookseller->new using id
137
#Test Koha::Acquisition::Bookseller->new using id
137
my $bookseller1fromid = Koha::Acquisition::Bookseller->fetch;
138
my $bookseller1fromid = Koha::Acquisition::Booksellers->find;
138
is( $bookseller1fromid, undef,
139
is( $bookseller1fromid, undef,
139
    "fetch returns undef if no id given" );
140
    "find returns undef if no id given" );
140
$bookseller1fromid = Koha::Acquisition::Bookseller->fetch({ id => $id_supplier1});
141
$bookseller1fromid = Koha::Acquisition::Booksellers->find( $id_supplier1 );
141
$bookseller1fromid = field_filter($bookseller1fromid);
142
$bookseller1fromid = field_filter($bookseller1fromid->as_hashref);
142
is_deeply( $bookseller1fromid, $sample_supplier1,
143
is_deeply( $bookseller1fromid, $sample_supplier1,
143
    "Get Supplier1 (fetch a bookseller by id)" );
144
    "Get Supplier1 (find a bookseller by id)" );
144
145
145
#Test basket_count
146
$bookseller1fromid = Koha::Acquisition::Booksellers->find( $id_supplier1 );
146
$bookseller1fromid = Koha::Acquisition::Bookseller->fetch({ id => $id_supplier1});
147
is( $bookseller1fromid->baskets->count, 2, 'Supplier1 has 2 baskets' );
147
is( $bookseller1fromid->basket_count, 2, 'Supplier1 has 2 baskets' );
148
148
149
#Test subscription_count
149
#Test subscriptions
150
my $dt_today    = dt_from_string;
150
my $dt_today    = dt_from_string;
151
my $today       = output_pref({ dt => $dt_today, dateformat => 'iso', timeformat => '24hr', dateonly => 1 });
151
my $today       = output_pref({ dt => $dt_today, dateformat => 'iso', timeformat => '24hr', dateonly => 1 });
152
152
Lines 173-180 $bib->append_fields( Link Here
173
    MARC::Field->new('500', ' ', ' ', a => 'bib notes'),
173
    MARC::Field->new('500', ' ', ' ', a => 'bib notes'),
174
);
174
);
175
my ($biblionumber, $biblioitemnumber) = AddBiblio($bib, '');
175
my ($biblionumber, $biblioitemnumber) = AddBiblio($bib, '');
176
$bookseller1fromid = Koha::Acquisition::Bookseller->fetch({ id => $id_supplier1 });
176
$bookseller1fromid = Koha::Acquisition::Booksellers->find( $id_supplier1 );
177
is( $bookseller1fromid->subscription_count,
177
is( $bookseller1fromid->subscriptions->count,
178
    0, 'Supplier1 has 0 subscription' );
178
    0, 'Supplier1 has 0 subscription' );
179
179
180
my $id_subscription1 = NewSubscription(
180
my $id_subscription1 = NewSubscription(
Lines 198-205 my $id_subscription2 = NewSubscription( Link Here
198
    undef, undef, 0,          undef,         '2013-07-31', 0
198
    undef, undef, 0,          undef,         '2013-07-31', 0
199
);
199
);
200
200
201
$bookseller1fromid = Koha::Acquisition::Bookseller->fetch({ id => $id_supplier1 });
201
$bookseller1fromid = Koha::Acquisition::Booksellers->find( $id_supplier1 );
202
is( $bookseller1fromid->subscription_count,
202
is( $bookseller1fromid->subscriptions->count,
203
    2, 'Supplier1 has 2 subscriptions' );
203
    2, 'Supplier1 has 2 subscriptions' );
204
204
205
#Test ModBookseller
205
#Test ModBookseller
Lines 225-246 $sample_supplier2 = { Link Here
225
    deliverytime  => 2,
225
    deliverytime  => 2,
226
};
226
};
227
227
228
my $modif1 = C4::Bookseller::ModBookseller();
228
my $modif1 = Koha::Acquisition::Booksellers->find($id_supplier2)->set($sample_supplier2)->store;
229
is( $modif1, undef,
229
is( ref $modif1, 'Koha::Acquisition::Bookseller', "ModBookseller has updated the bookseller" );
230
    "ModBookseller returns undef if no params given - Nothing happened" );
230
is( Koha::Acquisition::Booksellers->search->count,
231
$modif1 = C4::Bookseller::ModBookseller($sample_supplier2);
232
is( $modif1, 1, "ModBookseller modifies only the supplier2" );
233
is( scalar( Koha::Acquisition::Bookseller->search ),
234
    $count + 2, "Supplier2 has been modified - Nothing added" );
231
    $count + 2, "Supplier2 has been modified - Nothing added" );
235
232
$supplier2 = Koha::Acquisition::Booksellers->find($id_supplier2);
236
$modif1 = C4::Bookseller::ModBookseller(
233
is( $supplier2->name, 'Name2 modified', "supplier's name should have been modified" );
237
    {
238
        id   => -1,
239
        name => 'name3'
240
    }
241
);
242
#is( $modif1, '0E0',
243
#    "ModBookseller returns OEO if the id doesnt exist - Nothing modified" );
244
234
245
#Test GetBooksellersWithLateOrders
235
#Test GetBooksellersWithLateOrders
246
#Add 2 suppliers
236
#Add 2 suppliers
Lines 283-290 my $sample_supplier4 = { Link Here
283
    discount      => '3.0000',
273
    discount      => '3.0000',
284
    notes         => 'notes3',
274
    notes         => 'notes3',
285
};
275
};
286
my $id_supplier3 = C4::Bookseller::AddBookseller($sample_supplier3);
276
my $supplier3 = Koha::Acquisition::Bookseller->new($sample_supplier3)->store;
287
my $id_supplier4 = C4::Bookseller::AddBookseller($sample_supplier4);
277
my $id_supplier3 = $supplier3->id;
278
my $supplier4 = Koha::Acquisition::Bookseller->new($sample_supplier4)->store;
279
my $id_supplier4 = $supplier4->id;
288
280
289
#Add 2 baskets
281
#Add 2 baskets
290
my $basketno3 =
282
my $basketno3 =
Lines 676-744 is( Link Here
676
    3,
668
    3,
677
    'superlibrarian can see all subscriptions with IndependentBranches on (bug 12048)'
669
    'superlibrarian can see all subscriptions with IndependentBranches on (bug 12048)'
678
);
670
);
671
679
#Test contact editing
672
#Test contact editing
680
my $booksellerid = C4::Bookseller::AddBookseller(
673
my $sample_supplier = {
681
    {
682
        name     => "my vendor",
674
        name     => "my vendor",
683
        address1 => "bookseller's address",
675
        address1 => "bookseller's address",
684
        phone    => "0123456",
676
        phone    => "0123456",
685
        active   => 1
677
        active   => 1
686
    },
678
    };
687
    [
679
my $supplier = Koha::Acquisition::Bookseller->new($sample_supplier)->store;
688
        { name => 'John Smith',  phone => '0123456x1' },
680
my $booksellerid = $supplier->id;
689
        { name => 'Leo Tolstoy', phone => '0123456x2' },
681
my $contact1 = Koha::Acquisition::Bookseller::Contact->new({
690
    ]
682
        name => 'John Smith',
691
);
683
        phone => '0123456x1',
692
684
        booksellerid => $booksellerid,
693
@booksellers = Koha::Acquisition::Bookseller->search({ name => 'my vendor' });
685
})->store;
686
my $contact2 = Koha::Acquisition::Bookseller::Contact->new({
687
        name => 'Leo Tolstoy',
688
        phone => '0123456x2',
689
        booksellerid => $booksellerid,
690
})->store;
691
692
@booksellers = Koha::Acquisition::Booksellers->search({ name => 'my vendor' });
694
ok(
693
ok(
695
    ( grep { $_->{'id'} == $booksellerid } @booksellers ),
694
    ( grep { $_->id == $booksellerid } @booksellers ),
696
    'Koha::Acquisition::Bookseller->search returns correct record when passed a name'
695
    'Koha::Acquisition::Booksellers->search returns correct record when passed a name'
697
);
696
);
698
697
699
my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
698
my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
700
is( $bookseller->{'id'}, $booksellerid, 'Retrieved desired record' );
699
is( $bookseller->id, $booksellerid, 'Retrieved desired record' );
701
is( $bookseller->{'phone'}, '0123456', 'New bookseller has expected phone' );
700
is( $bookseller->phone, '0123456', 'New bookseller has expected phone' );
702
my $contacts = $bookseller->contacts;
701
my $contacts = $bookseller->contacts;
703
is( ref $bookseller->contacts,
702
is( $contacts->count,
704
    'ARRAY', 'Koha::Acquisition::Bookseller->fetch returns arrayref of contacts' );
703
    2, 'bookseller should have 2 contacts' );
704
my $first_contact = $contacts->next;
705
is(
705
is(
706
    ref $bookseller->{'contacts'}->[0],
706
    ref $first_contact,
707
    'C4::Bookseller::Contact',
707
    'Koha::Acquisition::Bookseller::Contact',
708
    'First contact is a contact object'
708
    'First contact is a AqContact'
709
);
709
);
710
is( $bookseller->{'contacts'}->[0]->phone,
710
is( $first_contact->phone,
711
    '0123456x1', 'Contact has expected phone number' );
711
    '0123456x1', 'Contact has expected phone number' );
712
is( scalar @{ $bookseller->{'contacts'} }, 2, 'Saved two contacts' );
713
712
714
pop @{ $bookseller->{'contacts'} };
713
my $second_contact = $contacts->next;
715
$bookseller->{'name'} = 'your vendor';
714
$second_contact->delete;
716
$bookseller->{'contacts'}->[0]->phone('654321');
715
$bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
717
C4::Bookseller::ModBookseller($bookseller);
716
$bookseller->name('your vendor');
718
719
$bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
720
$contacts = $bookseller->contacts;
717
$contacts = $bookseller->contacts;
721
is( $bookseller->{'name'}, 'your vendor',
718
$first_contact = $contacts->next;
719
$first_contact->phone('654321');
720
$bookseller->store;
721
722
$bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
723
is( $bookseller->name, 'your vendor',
722
    'Successfully changed name of vendor' );
724
    'Successfully changed name of vendor' );
723
is( $contacts->[0]->phone,
725
$contacts = $bookseller->contacts;
726
is( $contacts->count,
727
    1, 'Only one contact after modification' );
728
$first_contact = $contacts->next;
729
is( $first_contact->phone,
724
    '654321',
730
    '654321',
725
    'Successfully changed contact phone number by modifying bookseller hash' );
731
    'Successfully changed contact phone number by modifying bookseller hash' );
726
is( scalar @$contacts,
727
    1, 'Only one contact after modification' );
728
732
729
C4::Bookseller::ModBookseller( $bookseller,
733
$first_contact->name( 'John Jacob Jingleheimer Schmidt' );
730
    [ { name => 'John Jacob Jingleheimer Schmidt' } ] );
734
$first_contact->phone(undef);
735
$bookseller->store;
731
736
732
$bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
737
$bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
733
$contacts = $bookseller->contacts;
738
$contacts = $bookseller->contacts;
739
$first_contact = $contacts->next;
734
is(
740
is(
735
    $contacts->[0]->name,
741
    $first_contact->name,
736
    'John Jacob Jingleheimer Schmidt',
742
    'John Jacob Jingleheimer Schmidt',
737
    'Changed name of contact'
743
    'Changed name of contact'
738
);
744
);
739
is( $contacts->[0]->phone,
745
is( $first_contact->phone,
740
    undef, 'Removed phone number from contact' );
746
    undef, 'Removed phone number from contact' );
741
is( scalar @$contacts,
747
is( $contacts->count,
742
    1, 'Only one contact after modification' );
748
    1, 'Only one contact after modification' );
743
749
744
#End transaction
750
#End transaction
(-)a/t/db_dependent/Budgets.t (-3 / +4 lines)
Lines 6-16 BEGIN { Link Here
6
}
6
}
7
use C4::Context;
7
use C4::Context;
8
use C4::Biblio;
8
use C4::Biblio;
9
use C4::Bookseller;
10
use C4::Acquisition;
9
use C4::Acquisition;
11
use C4::Dates;
10
use C4::Dates;
12
use C4::Members qw( AddMember );
11
use C4::Members qw( AddMember );
13
12
13
use Koha::Acquisition::Bookseller;
14
use Koha::Acquisition::Order;
14
use Koha::Acquisition::Order;
15
15
16
use YAML;
16
use YAML;
Lines 263-269 my $budget_id21 = AddBudget( Link Here
263
    }
263
    }
264
);
264
);
265
265
266
my $booksellerid = C4::Bookseller::AddBookseller(
266
my $bookseller = Koha::Acquisition::Bookseller->new(
267
    {
267
    {
268
        name         => "my vendor",
268
        name         => "my vendor",
269
        address1     => "bookseller's address",
269
        address1     => "bookseller's address",
Lines 271-277 my $booksellerid = C4::Bookseller::AddBookseller( Link Here
271
        active       => 1,
271
        active       => 1,
272
        deliverytime => 5,
272
        deliverytime => 5,
273
    }
273
    }
274
);
274
)->store;
275
my $booksellerid = $bookseller->id;
275
276
276
my $basketno = C4::Acquisition::NewBasket( $booksellerid, 1 );
277
my $basketno = C4::Acquisition::NewBasket( $booksellerid, 1 );
277
my ( $biblionumber, $biblioitemnumber ) =
278
my ( $biblionumber, $biblioitemnumber ) =
(-)a/t/db_dependent/Contract.t (-3 / +5 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
use C4::Context;
21
use C4::Context;
22
use C4::Bookseller;
22
use Koha::Acquisition::Bookseller;
23
23
24
use Test::More tests => 43;
24
use Test::More tests => 43;
25
25
Lines 36-44 $dbh->do(q|DELETE FROM aqcontract|); Link Here
36
$dbh->do(q|DELETE FROM aqbooksellers|);
36
$dbh->do(q|DELETE FROM aqbooksellers|);
37
37
38
38
39
my $bookseller_id1 = C4::Bookseller::AddBookseller( { name => 'My first bookseller' } );
39
my $bookseller1 = Koha::Acquisition::Bookseller->new( { name => 'My first bookseller' } )->store;
40
my $bookseller_id1 = $bookseller1->id;
40
isnt( $bookseller_id1, undef, 'AddBookseller does not return undef' );
41
isnt( $bookseller_id1, undef, 'AddBookseller does not return undef' );
41
my $bookseller_id2 = C4::Bookseller::AddBookseller( { name => 'My second bookseller' } );
42
my $bookseller2 = Koha::Acquisition::Bookseller->new( { name => 'My second bookseller' } )->store;
43
my $bookseller_id2 = $bookseller2->id;
42
isnt( $bookseller_id2, undef, 'AddBookseller does not return undef' );
44
isnt( $bookseller_id2, undef, 'AddBookseller does not return undef' );
43
my $contracts = GetContracts();
45
my $contracts = GetContracts();
44
is( @$contracts, 0, 'GetContracts returns the correct number of contracts' );
46
is( @$contracts, 0, 'GetContracts returns the correct number of contracts' );
(-)a/t/db_dependent/Letters.t (-12 / +14 lines)
Lines 18-24 Link Here
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
use Test::More tests => 58;
21
use Test::More tests => 57;
22
use Test::MockModule;
22
use Test::MockModule;
23
use Test::Warn;
23
use Test::Warn;
24
24
Lines 39-50 use_ok('C4::Members'); Link Here
39
use_ok('C4::Branch');
39
use_ok('C4::Branch');
40
use_ok('C4::Acquisition');
40
use_ok('C4::Acquisition');
41
use_ok('C4::Biblio');
41
use_ok('C4::Biblio');
42
use_ok('C4::Bookseller');
43
use_ok('C4::Letters');
42
use_ok('C4::Letters');
44
use t::lib::Mocks;
43
use t::lib::Mocks;
45
use Koha::DateUtils qw( dt_from_string output_pref );
44
use Koha::DateUtils qw( dt_from_string output_pref );
46
use Koha::Acquisition::Order;
45
use Koha::Acquisition::Order;
47
use Koha::Acquisition::Bookseller;
46
use Koha::Acquisition::Bookseller;
47
use Koha::Acquisition::Booksellers;
48
48
49
my $dbh = C4::Context->dbh;
49
my $dbh = C4::Context->dbh;
50
50
Lines 277-283 is( $prepared_letter->{content}, $my_content_letter, 'GetPreparedLetter returns Link Here
277
277
278
$dbh->do(q{INSERT INTO letter (module, code, name, title, content) VALUES ('claimacquisition','TESTACQCLAIM','Acquisition Claim','Item Not Received','<<aqbooksellers.name>>|<<aqcontacts.name>>|<order>Ordernumber <<aqorders.ordernumber>> (<<biblio.title>>) (<<aqorders.quantity>> ordered)</order>');});
278
$dbh->do(q{INSERT INTO letter (module, code, name, title, content) VALUES ('claimacquisition','TESTACQCLAIM','Acquisition Claim','Item Not Received','<<aqbooksellers.name>>|<<aqcontacts.name>>|<order>Ordernumber <<aqorders.ordernumber>> (<<biblio.title>>) (<<aqorders.quantity>> ordered)</order>');});
279
279
280
my $booksellerid = C4::Bookseller::AddBookseller(
280
my $bookseller = Koha::Acquisition::Bookseller->new(
281
    {
281
    {
282
        name => "my vendor",
282
        name => "my vendor",
283
        address1 => "bookseller's address",
283
        address1 => "bookseller's address",
Lines 285-295 my $booksellerid = C4::Bookseller::AddBookseller( Link Here
285
        active => 1,
285
        active => 1,
286
        deliverytime => 5,
286
        deliverytime => 5,
287
    },
287
    },
288
    [
288
)->store;
289
        { name => 'John Smith',  phone => '0123456x1', claimacquisition => 1 },
289
my $booksellerid = $bookseller->id;
290
        { name => 'Leo Tolstoy', phone => '0123456x2', claimissues => 1 },
290
291
    ]
291
Koha::Acquisition::Bookseller::Contact->new( { name => 'John Smith',  phone => '0123456x1', claimacquisition => 1, booksellerid => $booksellerid } )->store;
292
);
292
Koha::Acquisition::Bookseller::Contact->new( { name => 'Leo Tolstoy', phone => '0123456x2', claimissues      => 1, booksellerid => $booksellerid } )->store;
293
my $basketno = NewBasket($booksellerid, 1);
293
my $basketno = NewBasket($booksellerid, 1);
294
294
295
my $budgetid = C4::Budgets::AddBudget({
295
my $budgetid = C4::Budgets::AddBudget({
Lines 327-336 warning_like { Link Here
327
    "SendAlerts prints a warning";
327
    "SendAlerts prints a warning";
328
is($err->{'error'}, 'no_email', "Trying to send an alert when there's no e-mail results in an error");
328
is($err->{'error'}, 'no_email', "Trying to send an alert when there's no e-mail results in an error");
329
329
330
my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
330
$bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
331
$bookseller->contacts->[0]->email('testemail@mydomain.com');
331
my $contacts = $bookseller->contacts;
332
C4::Bookseller::ModBookseller($bookseller);
332
my $contact = $contacts->next;
333
$bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
333
$contact->email('testemail@mydomain.com');
334
$bookseller->store;
335
$bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
334
336
335
warning_is {
337
warning_is {
336
    $err = SendAlerts( 'claimacquisition', [ $ordernumber ], 'TESTACQCLAIM' ) }
338
    $err = SendAlerts( 'claimacquisition', [ $ordernumber ], 'TESTACQCLAIM' ) }
(-)a/t/db_dependent/Serials.t (-3 / +4 lines)
Lines 11-20 use C4::Serials; Link Here
11
use C4::Serials::Frequency;
11
use C4::Serials::Frequency;
12
use C4::Serials::Numberpattern;
12
use C4::Serials::Numberpattern;
13
use C4::Debug;
13
use C4::Debug;
14
use C4::Bookseller;
15
use C4::Biblio;
14
use C4::Biblio;
16
use C4::Budgets;
15
use C4::Budgets;
17
use Koha::DateUtils;
16
use Koha::DateUtils;
17
use Koha::Acquisition::Bookseller;
18
use Test::More tests => 43;
18
use Test::More tests => 43;
19
19
20
BEGIN {
20
BEGIN {
Lines 27-40 my $dbh = C4::Context->dbh; Link Here
27
$dbh->{AutoCommit} = 0;
27
$dbh->{AutoCommit} = 0;
28
$dbh->{RaiseError} = 1;
28
$dbh->{RaiseError} = 1;
29
29
30
my $booksellerid = C4::Bookseller::AddBookseller(
30
my $bookseller = Koha::Acquisition::Bookseller->new(
31
    {
31
    {
32
        name => "my vendor",
32
        name => "my vendor",
33
        address1 => "bookseller's address",
33
        address1 => "bookseller's address",
34
        phone => "0123456",
34
        phone => "0123456",
35
        active => 1
35
        active => 1
36
    }
36
    }
37
);
37
)->store;
38
my $booksellerid = $bookseller->id;
38
39
39
my ($biblionumber, $biblioitemnumber) = AddBiblio(MARC::Record->new, '');
40
my ($biblionumber, $biblioitemnumber) = AddBiblio(MARC::Record->new, '');
40
41
(-)a/t/db_dependent/Serials/Claims.t (-4 / +5 lines)
Lines 2-12 use Modern::Perl; Link Here
2
use Test::More tests => 13;
2
use Test::More tests => 13;
3
3
4
use C4::Acquisition;
4
use C4::Acquisition;
5
use C4::Bookseller;
6
use C4::Budgets;
5
use C4::Budgets;
7
use_ok('C4::Serials');
6
use_ok('C4::Serials');
8
7
9
use Koha::DateUtils qw( dt_from_string output_pref );
8
use Koha::DateUtils qw( dt_from_string output_pref );
9
use Koha::Acquisition::Bookseller;
10
10
11
my $dbh = C4::Context->dbh;
11
my $dbh = C4::Context->dbh;
12
$dbh->{AutoCommit} = 0;
12
$dbh->{AutoCommit} = 0;
Lines 74-81 my $sample_supplier2 = { Link Here
74
    deliverytime  => 2
74
    deliverytime  => 2
75
};
75
};
76
76
77
my $supplier_id1 = C4::Bookseller::AddBookseller($sample_supplier1);
77
my $supplier1 = Koha::Acquisition::Bookseller->new($sample_supplier1)->store;
78
my $supplier_id2 = C4::Bookseller::AddBookseller($sample_supplier2);
78
my $supplier2 = Koha::Acquisition::Bookseller->new($sample_supplier2)->store;
79
my $supplier_id1 = $supplier1->id;
80
my $supplier_id2 = $supplier2->id;
79
81
80
my $supplierlist = eval { GetSuppliersWithLateIssues() };
82
my $supplierlist = eval { GetSuppliersWithLateIssues() };
81
is( length($@), 0, "No SQL problem in GetSuppliersWithLateIssues" );
83
is( length($@), 0, "No SQL problem in GetSuppliersWithLateIssues" );
82
- 

Return to bug 13726