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

(-)a/C4/Acquisition.pm (-2 lines)
Lines 1222-1229 sub GetOrder { Link Here
1222
                biblioitems.publishercode,
1222
                biblioitems.publishercode,
1223
                aqorders.rrp              AS unitpricesupplier,
1223
                aqorders.rrp              AS unitpricesupplier,
1224
                aqorders.ecost            AS unitpricelib,
1224
                aqorders.ecost            AS unitpricelib,
1225
                aqorders.claims_count     AS claims_count,
1226
                aqorders.claimed_date     AS claimed_date,
1227
                aqbudgets.budget_name     AS budget,
1225
                aqbudgets.budget_name     AS budget,
1228
                aqbooksellers.name        AS supplier,
1226
                aqbooksellers.name        AS supplier,
1229
                aqbooksellers.id          AS supplierid,
1227
                aqbooksellers.id          AS supplierid,
(-)a/Koha/Acquisition/Basket.pm (+51 lines)
Lines 20-25 package Koha::Acquisition::Basket; Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Koha::Database;
22
use Koha::Database;
23
use Koha::DateUtils qw( dt_from_string );
23
use Koha::Acquisition::BasketGroups;
24
use Koha::Acquisition::BasketGroups;
24
use Koha::Patrons;
25
use Koha::Patrons;
25
26
Lines 88-93 sub effective_create_items { Link Here
88
    return $self->create_items || C4::Context->preference('AcqCreateItem');
89
    return $self->create_items || C4::Context->preference('AcqCreateItem');
89
}
90
}
90
91
92
=head3 estimated_delivery_date
93
94
my $estimated_delivery_date = $basket->estimated_delivery_date;
95
96
Return the estimated delivery date for this basket.
97
98
It is calculated adding the delivery time of the vendor to the close date of this basket.
99
100
Return implicit undef if the basket is not closed, or the vendor does not have a delivery time.
101
102
=cut
103
104
sub estimated_delivery_date {
105
    my ( $self ) = @_;
106
    return unless $self->closedate and $self->bookseller->deliverytime;
107
    return dt_from_string($self->closedate)->add( days => $self->bookseller->deliverytime);
108
}
109
110
=head3 late_since_days
111
112
my $number_of_days_late = $basket->late_since_days;
113
114
Return the number of days the basket is late.
115
116
Return implicit undef if the basket is not closed.
117
118
=cut
119
120
sub late_since_days {
121
    my ( $self ) = @_;
122
    return unless $self->closedate;
123
    return dt_from_string->delta_days(dt_from_string($self->closedate))->delta_days();
124
}
125
126
=head3 authorizer
127
128
my $authorizer = $basket->authorizer;
129
130
Returns the patron who authorized/created this basket.
131
132
=cut
133
134
sub authorizer {
135
    my ($self) = @_;
136
    # FIXME We should use a DBIC rs, but the FK is missing
137
    return unless $self->authorisedby;
138
    return scalar Koha::Patrons->find($self->authorisedby);
139
}
140
141
91
=head3 to_api
142
=head3 to_api
92
143
93
    my $json = $basket->to_api;
144
    my $json = $basket->to_api;
(-)a/Koha/Acquisition/Order.pm (+57 lines)
Lines 22-27 use Carp qw( croak ); Link Here
22
use Koha::Acquisition::Baskets;
22
use Koha::Acquisition::Baskets;
23
use Koha::Acquisition::Funds;
23
use Koha::Acquisition::Funds;
24
use Koha::Acquisition::Invoices;
24
use Koha::Acquisition::Invoices;
25
use Koha::Acquisition::Order::Claims;
25
use Koha::Database;
26
use Koha::Database;
26
use Koha::DateUtils qw( dt_from_string output_pref );
27
use Koha::DateUtils qw( dt_from_string output_pref );
27
use Koha::Biblios;
28
use Koha::Biblios;
Lines 239-244 sub biblio { Link Here
239
    return Koha::Biblio->_new_from_dbic( $biblio_rs );
240
    return Koha::Biblio->_new_from_dbic( $biblio_rs );
240
}
241
}
241
242
243
=head3 claims
244
245
    my $claims = $order->claims
246
247
Return the claims history for this order
248
249
=cut
250
251
sub claims {
252
    my ( $self ) = @_;
253
    my $claims_rs = $self->_result->aqorders_claims;
254
    return Koha::Acquisition::Order::Claims->_new_from_dbic( $claims_rs );
255
}
256
257
=head3 claim
258
259
    my $claim = $order->claim
260
261
Do claim for this order
262
263
=cut
264
265
sub claim {
266
    my ( $self ) = @_;
267
    my $claim_rs = $self->_result->create_related('aqorders_claims', {});
268
    return Koha::Acquisition::Order::Claim->_new_from_dbic($claim_rs);
269
}
270
271
=head3 claims_count
272
273
my $nb_of_claims = $order->claims_count;
274
275
This is the equivalent of $order->claims->count. Keeping it for retrocompatibilty.
276
277
=cut
278
279
sub claims_count {
280
    my ( $self ) = @_;
281
    return $self->claims->count;
282
}
283
284
=head3 claimed_date
285
286
my $last_claim_date = $order->claimed_date;
287
288
This is the equivalent of $order->claims->last->claimed_on. Keeping it for retrocompatibilty.
289
290
=cut
291
292
sub claimed_date {
293
    my ( $self ) = @_;
294
    my $last_claim = $self->claims->last;
295
    return unless $last_claim;
296
    return $last_claim->claimed_on;
297
}
298
242
=head3 duplicate_to
299
=head3 duplicate_to
243
300
244
    my $duplicated_order = $order->duplicate_to($basket, [$default_values]);
301
    my $duplicated_order = $order->duplicate_to($basket, [$default_values]);
(-)a/Koha/Acquisition/Order/Claim.pm (+2 lines)
Lines 31-36 Koha::Acquisition::Order::Claim - Koha Claim Object class Link Here
31
31
32
=head2 Class methods
32
=head2 Class methods
33
33
34
=cut
35
34
=head2 Internal methods
36
=head2 Internal methods
35
37
36
=head3 _type
38
=head3 _type
(-)a/Koha/Acquisition/Order/Claims.pm (-1 / +5 lines)
Lines 35-41 Koha::Cities - Koha Claim Object set class Link Here
35
35
36
=cut
36
=cut
37
37
38
=head3 type
38
=head3 _type
39
39
40
=cut
40
=cut
41
41
Lines 43-48 sub _type { Link Here
43
    return 'AqordersClaim';
43
    return 'AqordersClaim';
44
}
44
}
45
45
46
=head3 object_class
47
48
=cut
49
46
sub object_class {
50
sub object_class {
47
    return 'Koha::Acquisition::Order::Claim';
51
    return 'Koha::Acquisition::Order::Claim';
48
}
52
}
(-)a/Koha/Acquisition/Orders.pm (+99 lines)
Lines 21-26 use Carp; Link Here
21
21
22
use Koha::Database;
22
use Koha::Database;
23
23
24
use Koha::DateUtils qw( dt_from_string );
24
use Koha::Acquisition::Order;
25
use Koha::Acquisition::Order;
25
26
26
use base qw(Koha::Objects);
27
use base qw(Koha::Objects);
Lines 31-36 Koha::Acquisition::Orders object set class Link Here
31
32
32
=head1 API
33
=head1 API
33
34
35
=head2 Class Methods
36
37
=head3 filter_by_lates
38
39
my $late_orders = $orders->filter_by_lates($params);
40
41
Filter an order set given different parameters.
42
43
This is the équivalent method of the former GetLateOrders C4 subroutine
44
45
$params can be:
46
47
=over
48
49
=item C<delay> the number of days the basket has been closed
50
51
=item C<bookseller_id> the bookseller id
52
53
=item C<estimated_from> Beginning of the estimated delivery date
54
55
=item C<estimated_to> End of the estimated delivery date
56
57
=back
58
59
=cut
60
61
sub filter_by_lates {
62
    my ( $self, $params ) = @_;
63
    my $delay = $params->{delay};
64
    my $bookseller_id = $params->{bookseller_id};
65
    # my $branchcode = $params->{branchcode}; # FIXME do we really need this
66
    my $estimated_from = $params->{estimated_from};
67
    my $estimated_to = $params->{estimated_to};
68
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
69
70
    my @delivery_time_conditions;
71
    my $date_add = "DATE_ADD(basketno.closedate, INTERVAL COALESCE(booksellerid.deliverytime, booksellerid.deliverytime, 0) day)";
72
    if ( defined $estimated_from or defined $estimated_to ) {
73
        push @delivery_time_conditions, \[ "$date_add IS NOT NULL" ];
74
    }
75
    if ( defined $estimated_from ) {
76
        push @delivery_time_conditions, \[ "$date_add >= ?", $dtf->format_date($estimated_from) ];
77
    }
78
    if ( defined $estimated_to ) {
79
        push @delivery_time_conditions, \[ "$date_add <= ?", $dtf->format_date($estimated_to) ];
80
    }
81
    if ( defined $estimated_from and not defined $estimated_to ) {
82
        push @delivery_time_conditions, \[ "$date_add <= ?", $dtf->format_date(dt_from_string) ];
83
    }
84
85
    $self->search(
86
        {
87
            -or => [
88
                { datereceived => undef },
89
                quantityreceived => { '<' => \'quantity' }
90
            ],
91
            'basketno.closedate' => [
92
                -and =>
93
                { '!=' => undef },
94
                {
95
                    defined $delay
96
                    ? (
97
                        '<=' => $dtf->format_date(
98
                            dt_from_string->subtract( days => $delay )
99
                        )
100
                      )
101
                    : ()
102
                }
103
              ],
104
            'datecancellationprinted' => undef,
105
            (
106
                $bookseller_id
107
                ? ( 'basketno.booksellerid' => $bookseller_id )
108
                : ()
109
            ),
110
111
            # ( $branchcode ? ('borrower.branchcode')) # FIXME branch is not a filter we may not need to implement this
112
113
            ( @delivery_time_conditions ? ( -and => \@delivery_time_conditions ) : ()),
114
            (
115
                C4::Context->preference('IndependentBranches')
116
                  && !C4::Context->IsSuperLibrarian
117
                ? ( 'borrower.branchcode' => C4::Context->userenv->{branch} )
118
                : ()
119
            ),
120
121
            ( orderstatus => { '!=' => 'cancelled' } ),
122
123
        },
124
        {
125
            '+select' => [\"DATE_ADD(basketno.closedate, INTERVAL COALESCE(booksellerid.deliverytime, booksellerid.deliverytime, 0) day)"],
126
            '+as' => ['estimated_delivery_date'],
127
            join => { 'basketno' => 'booksellerid' },
128
            prefetch => {'basketno' => 'booksellerid'},
129
        }
130
    );
131
}
132
34
=head2 Internal methods
133
=head2 Internal methods
35
134
36
=head3 _type (internal)
135
=head3 _type (internal)
(-)a/acqui/basket.pl (+1 lines)
Lines 498-503 sub get_order_infos { Link Here
498
        $line{left_holds_on_order}  = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds );
498
        $line{left_holds_on_order}  = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds );
499
        $line{holds}                = $holds_count;
499
        $line{holds}                = $holds_count;
500
        $line{holds_on_order}       = $itemholds?$itemholds:$holds_count if $line{left_holds_on_order};
500
        $line{holds_on_order}       = $itemholds?$itemholds:$holds_count if $line{left_holds_on_order};
501
        $line{order_object}         = $order;
501
    }
502
    }
502
503
503
504
(-)a/acqui/lateorders-export.pl (-2 / +4 lines)
Lines 36-41 my @ordernumbers = $input->multi_param('ordernumber'); Link Here
36
my @orders;
36
my @orders;
37
for my $ordernumber ( @ordernumbers ) {
37
for my $ordernumber ( @ordernumbers ) {
38
    my $order = GetOrder $ordernumber;
38
    my $order = GetOrder $ordernumber;
39
    my $order_object = Koha::Acquisition::Orders->find($ordernumber);
40
    my $claims = $order_object->claims;
39
    push @orders, {
41
    push @orders, {
40
            orderdate => $order->{orderdate},
42
            orderdate => $order->{orderdate},
41
            latesince => $order->{latesince},
43
            latesince => $order->{latesince},
Lines 51-58 for my $ordernumber ( @ordernumbers ) { Link Here
51
            budget => $order->{budget},
53
            budget => $order->{budget},
52
            basketname => $order->{basketname},
54
            basketname => $order->{basketname},
53
            basketno => $order->{basketno},
55
            basketno => $order->{basketno},
54
            claims_count => $order->{claims_count},
56
            claims_count => $claims->count,
55
            claimed_date => $order->{claimed_date},
57
            claimed_date => $claims->count ? $claims->last->claimed_on : undef,
56
            internalnote => $order->{order_internalnote},
58
            internalnote => $order->{order_internalnote},
57
            vendornote   => $order->{order_vendornote},
59
            vendornote   => $order->{order_vendornote},
58
            isbn => $order->{isbn},
60
            isbn => $order->{isbn},
(-)a/acqui/lateorders.pl (-20 / +18 lines)
Lines 108-114 if ($op and $op eq "send_alert"){ Link Here
108
    eval {
108
    eval {
109
        $err = SendAlerts( 'claimacquisition', \@ordernums, $input->param("letter_code") );
109
        $err = SendAlerts( 'claimacquisition', \@ordernums, $input->param("letter_code") );
110
        if ( not ref $err or not exists $err->{error} ) {
110
        if ( not ref $err or not exists $err->{error} ) {
111
            AddClaim ( $_ ) for @ordernums;
111
            Koha::Acquisition::Orders->find($_)->claim() for @ordernums;
112
        }
112
        }
113
    };
113
    };
114
114
Lines 145-178 $template->param(SUPPLIER_LOOP => \@sloopy); Link Here
145
$template->param(Supplier=>$supplierlist{$booksellerid}) if ($booksellerid);
145
$template->param(Supplier=>$supplierlist{$booksellerid}) if ($booksellerid);
146
$template->param(booksellerid=>$booksellerid) if ($booksellerid);
146
$template->param(booksellerid=>$booksellerid) if ($booksellerid);
147
147
148
@parameters =
148
my $lateorders = Koha::Acquisition::Orders->filter_by_lates(
149
  ( $delay, $booksellerid, $branch );
149
    {
150
if ($estimateddeliverydatefrom_dt) {
150
        delay        => $delay,
151
    push @parameters, $estimateddeliverydatefrom_dt->ymd();
151
        booksellerid => $booksellerid,
152
}
152
        (
153
else {
153
            $estimateddeliverydatefrom_dt
154
    push @parameters, undef;
154
            ? ( estimated_from => $estimateddeliverydatefrom_dt )
155
}
155
            : ()
156
if ($estimateddeliverydateto_dt) {
156
        ),
157
    push @parameters, $estimateddeliverydateto_dt->ymd();
157
        (
158
}
158
            $estimateddeliverydateto_dt
159
my @lateorders = GetLateOrders( @parameters );
159
            ? ( estimated_to => $estimateddeliverydateto_dt )
160
160
            : ()
161
my $total;
161
        )
162
foreach (@lateorders){
162
    }
163
	$total += $_->{subtotal};
163
);
164
}
165
164
166
my $letters = GetLetters({ module => "claimacquisition" });
165
my $letters = GetLetters({ module => "claimacquisition" });
167
166
168
$template->param(ERROR_LOOP => \@errors) if (@errors);
167
$template->param(ERROR_LOOP => \@errors) if (@errors);
169
$template->param(
168
$template->param(
170
	lateorders => \@lateorders,
169
    lateorders => $lateorders,
171
	delay => $delay,
170
	delay => $delay,
172
    letters => $letters,
171
    letters => $letters,
173
    estimateddeliverydatefrom => $estimateddeliverydatefrom,
172
    estimateddeliverydatefrom => $estimateddeliverydatefrom,
174
    estimateddeliverydateto   => $estimateddeliverydateto,
173
    estimateddeliverydateto   => $estimateddeliverydateto,
175
	total => $total,
176
	intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
174
	intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
177
);
175
);
178
output_html_with_http_headers $input, $cookie, $template->output;
176
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt (+6 lines)
Lines 524-529 Link Here
524
                                </span>
524
                                </span>
525
                              </p>
525
                              </p>
526
                            [% END %]
526
                            [% END %]
527
                            [% SET claims = books_loo.order_object.claims %]
528
                            [% IF claims.count %]
529
                                <p>
530
                                    This order has been claimed [% claims.count | html %] times. On [% FOR c IN claims %][% c.claimed_on | $KohaDates %][% UNLESS loop.last %], [% END %][% END %]
531
                                </p>
532
                            [% END %]
527
                        </td>
533
                        </td>
528
                        [% SET zero_regex = "^0{1,}\.?0{1,}[^1-9]" %] [%# 0 or 0.0 or 0.00 or 00 or 00.0 or 00.00 or 0.000 ... %]
534
                        [% SET zero_regex = "^0{1,}\.?0{1,}[^1-9]" %] [%# 0 or 0.0 or 0.00 or 00 or 00.0 or 00.00 or 0.000 ... %]
529
                        [%# FIXME: use of a regexp is not ideal; bugs 9410 and 10929 suggest better way of handling this %]
535
                        [%# FIXME: use of a regexp is not ideal; bugs 9410 and 10929 suggest better way of handling this %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/csv/lateorders.tt (-2 / +2 lines)
Lines 6-19 Link Here
6
[%- INCLUDE empty_line.inc -%]
6
[%- INCLUDE empty_line.inc -%]
7
7
8
[%- FOREACH o IN orders -%]
8
[%- FOREACH o IN orders -%]
9
"[% o.orderdate | html %] ([% o.latesince | html %] days)"[%- delimiter | html -%]
9
"[% o.orderdate | $KohaDates %] ([% o.latesince | html %] days)"[%- delimiter | html -%]
10
"[% o.estimateddeliverydate | $KohaDates %]"[%- delimiter | html -%]
10
"[% o.estimateddeliverydate | $KohaDates %]"[%- delimiter | html -%]
11
"[% o.supplier (o.supplierid) | html %]"[%- delimiter | html -%]
11
"[% o.supplier (o.supplierid) | html %]"[%- delimiter | html -%]
12
"[% o.title | html %] [% IF o.author %]Author: [% o.author | html %].[% END %][% IF o.publisher %]Published by: [% o.publisher | html %].[% END %]"[%- delimiter | html -%]
12
"[% o.title | html %] [% IF o.author %]Author: [% o.author | html %].[% END %][% IF o.publisher %]Published by: [% o.publisher | html %].[% END %]"[%- delimiter | html -%]
13
"[% o.unitpricesupplier | html %] x [% o.quantity_to_receive | html %] = [% o.subtotal | html %] ([% o.budget | html %])"[%- delimiter | html -%]
13
"[% o.unitpricesupplier | html %] x [% o.quantity_to_receive | html %] = [% o.subtotal | html %] ([% o.budget | html %])"[%- delimiter | html -%]
14
"[% o.basketname | html %] ([% o.basketno | html %])"[%- delimiter | html -%]
14
"[% o.basketname | html %] ([% o.basketno | html %])"[%- delimiter | html -%]
15
"[% o.claims_count | html %]"[%- delimiter | html -%]
15
"[% o.claims_count | html %]"[%- delimiter | html -%]
16
"[% o.claimed_date | html %]"[%- delimiter | html -%]
16
"[% o.claimed_date | $KohaDates %]"[%- delimiter | html -%]
17
"[% o.internalnote | html %]"[%- delimiter | html -%]
17
"[% o.internalnote | html %]"[%- delimiter | html -%]
18
"[% o.vendornote | html %]"[%- delimiter | html -%]
18
"[% o.vendornote | html %]"[%- delimiter | html -%]
19
"[% o.isbn | html %]"
19
"[% o.isbn | html %]"
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt (-35 / +35 lines)
Lines 3-8 Link Here
3
[% USE KohaDates %]
3
[% USE KohaDates %]
4
[% USE Branches %]
4
[% USE Branches %]
5
[% USE ColumnsSettings %]
5
[% USE ColumnsSettings %]
6
[% USE Price %]
6
[% SET footerjs = 1 %]
7
[% SET footerjs = 1 %]
7
[% INCLUDE 'doc-head-open.inc' %]
8
[% INCLUDE 'doc-head-open.inc' %]
8
<title>Koha &rsaquo; Acquisitions &rsaquo; Late orders</title>
9
<title>Koha &rsaquo; Acquisitions &rsaquo; Late orders</title>
Lines 35-41 Link Here
35
[% IF info_claim %]
36
[% IF info_claim %]
36
    <div class="dialog message">Email has been sent.</div>
37
    <div class="dialog message">Email has been sent.</div>
37
[% END %]
38
[% END %]
38
[% IF ( lateorders ) %]
39
[% IF lateorders.count %]
39
<form action="lateorders.pl" name="claim" method="post">
40
<form action="lateorders.pl" name="claim" method="post">
40
  <input type="hidden" name="op" value="send_alert" />
41
  <input type="hidden" name="op" value="send_alert" />
41
  <input type="hidden" name="delay" value="[% delay | html %]" />
42
  <input type="hidden" name="delay" value="[% delay | html %]" />
Lines 48-53 Link Here
48
	  </select>
49
	  </select>
49
	</p>
50
	</p>
50
	[% END %]
51
	[% END %]
52
    [% SET total = 0 %]
51
    <table id="late_orders">
53
    <table id="late_orders">
52
      <thead>
54
      <thead>
53
        <tr>
55
        <tr>
Lines 77-147 Link Here
77
      [% FOREACH lateorder IN lateorders %]
79
      [% FOREACH lateorder IN lateorders %]
78
        <tr>
80
        <tr>
79
            <td>
81
            <td>
80
                <input type="checkbox" value="[% lateorder.ordernumber | html %]" data-booksellerid="[% lateorder.supplierid | html %]" name="ordernumber">
82
                <input type="checkbox" value="[% lateorder.ordernumber | html %]" data-booksellerid="[% lateorder.basket.booksellerid | html %]" name="ordernumber">
81
            </td>
83
            </td>
82
            <td>
84
            <td>
83
                [% lateorder.ordernumber | $raw %]
85
                [% lateorder.ordernumber | $raw %]
84
            </td>
86
            </td>
85
            <td>
87
            <td>
86
                <span title="[% lateorder.orderdate | html %]">[% lateorder.orderdate | $KohaDates %] ([% lateorder.latesince | html %] days)</span>
88
                <span title="[% lateorder.basket.closedate | html %]">[% lateorder.basket.closedate | $KohaDates %] ([% lateorder.basket.late_since_days | html %] days)</span>
87
            </td>
89
            </td>
88
            <td>
90
            <td>
89
                [% IF ( lateorder.estimateddeliverydate ) %]
91
                [% SET estimated_delivery_date = lateorder.get_column('estimated_delivery_date') %]
90
                    <span title="[% lateorder.estimateddeliverydate | html %]">[% lateorder.estimateddeliverydate | $KohaDates  %]</span>
92
                [% IF estimated_delivery_date %]
91
                [% ELSE %]
93
                    <span title="[% estimated_delivery_date | html %]">[% estimated_delivery_date | $KohaDates  %]</span>
92
                    <span title="0000-00-00"></span>
93
                [% END %]
94
                [% END %]
94
            </td>
95
            </td>
95
            <td>
96
            <td>
96
                [% lateorder.supplier | html %]
97
                [% lateorder.basket.bookseller.name | html %]
97
                ([% lateorder.supplierid | html %])
98
                ([% lateorder.basket.bookseller.id | html %])
98
            </td>
99
            </td>
99
            <td>
100
            <td>
100
                <b>[% lateorder.title | html %]</b>
101
                <b>[% lateorder.biblio.title | html %]</b>
101
                   [% IF ( lateorder.author ) %]<br/><i>Author:</i> [% lateorder.author | html %][% END %]
102
                   [% IF ( lateorder.biblio.author ) %]<br/><i>Author:</i> [% lateorder.biblio.author | html %][% END %]
102
                   [% IF ( lateorder.publisher ) %]
103
                   [% IF ( lateorder.biblio.biblioitem.publishercode ) %]
103
                        <br/><i>Published by:</i> [% lateorder.publisher | html %]
104
                        <br/><i>Published by:</i> [% lateorder.biblio.biblioitem.publishercode | html %]
104
                        [% IF ( lateorder.publicationyear ) %]
105
                        [% IF ( lateorder.biblio.biblioitem.publicationyear ) %]
105
                            <i> in </i>[% lateorder.publicationyear | html %]
106
                            <i> in </i>[% lateorder.biblio.biblioitem.publicationyear | html %]
106
                        [% END %]
107
                        [% END %]
107
                   [% END %]
108
                   [% END %]
108
            </td>
109
            </td>
109
            <td>
110
            <td>
110
                   [% lateorder.unitpricesupplier | html %]x[% lateorder.quantity | html %] = 
111
                [% SET subtotal = (lateorder.quantity - lateorder.quantityreceived) * lateorder.rrp %]
111
                   [% lateorder.subtotal | html %]
112
                [% SET total = total + subtotal %]
113
                [% lateorder.rrp | html %]x[% lateorder.quantity - lateorder.quantityreceived | html %] = [% subtotal | $Price %]
112
            </td>
114
            </td>
113
            <td>
115
            <td>
114
                [% IF ( CAN_user_acquisition_order_manage ) %]
116
                [% IF ( CAN_user_acquisition_order_manage ) %]
115
                    <a href="basket.pl?basketno=[% lateorder.basketno | uri %]" title="basket">[% lateorder.basketname | html %] ([% lateorder.basketno | html %])</a>
117
                    <a href="basket.pl?basketno=[% lateorder.basketno | uri %]" title="basket">[% lateorder.basket.basketname | html %] ([% lateorder.basketno | html %])</a>
116
                [% ELSE %]
118
                [% ELSE %]
117
                    [% lateorder.basketname | html %] ([% lateorder.basketno | html %])
119
                    [% lateorder.basket.basketname | html %] ([% lateorder.basketno | html %])
118
                [% END %]
120
                [% END %]
119
            </td>
121
            </td>
120
            <td>
122
            <td>
121
                [% IF ( lateorder.basketgroupid ) %]
123
                [% IF ( lateorder.basket.basketgroupid ) %]
122
                    [% IF ( CAN_user_acquisition_group_manage ) %]
124
                    [% IF ( CAN_user_acquisition_group_manage ) %]
123
                        <a href="basketgroup.pl?op=add&booksellerid=[% lateorder.supplierid | uri %]&basketgroupid=[% lateorder.basketgroupid | uri %]" title="basketgroup">[% lateorder.basketgroupname | html %] ([% lateorder.basketgroupid | html %])</a>
125
                        <a href="basketgroup.pl?op=add&booksellerid=[% lateorder.basket.booksellerid | uri %]&basketgroupid=[% lateorder.basket.basketgroupid | uri %]" title="basketgroup">[% lateorder.basket.basket_group.name | html %] ([% lateorder.basket.basketgroupid | html %])</a>
124
                    [% ELSE %]
126
                    [% ELSE %]
125
                        [% lateorder.basketgroupname | html %] ([% lateorder.basketgroupid | html %])</a>
127
                        [% lateorder.basket.basket_group.name | html %] ([% lateorder.basket.basketgroupid | html %])</a>
126
                    [% END %]
128
                    [% END %]
127
                [% END %]
129
                [% END %]
128
            </td>
130
            </td>
129
            <td>[% Branches.GetName( lateorder.branch ) | html %]
131
            <td>[% Branches.GetName( lateorder.basket.authorizer.branchcode ) | html %]
130
            </td>
132
            </td>
131
            <td>[% lateorder.budget | html %]
133
            <td>[% lateorder.fund.budget_name | html %]
132
            </td>
134
            </td>
133
            <td>[% lateorder.claims_count | html %]</td>
135
            <td>[% lateorder.claims.count | html %]</td>
134
            <td>
136
            <td>
135
                [% IF ( lateorder.claimed_date ) %]
137
                [% FOR claim IN lateorder.claims %]
136
                    <span title="[% lateorder.claimed_date | html %]">[% lateorder.claimed_date | $KohaDates %]</span>
138
                    <span title="[% lateorder.claims.last.claimed_on | html %]">[% claim.claimed_on | $KohaDates %]</span>
137
                [% ELSE %]
138
                    <span title="0000-00-00"></span>
139
                [% END %]
139
                [% END %]
140
            </td>
140
            </td>
141
            <td>
141
            <td>
142
                [% IF ( lateorder.internalnote ) %]
142
                [% IF lateorder.order_internalnote %]
143
                    <p class="ordernote">
143
                    <p class="ordernote">
144
                        <span id="internal-note-[% lateorder.ordernumber | html %]">[% lateorder.internalnote | html %]</span>
144
                        <span id="internal-note-[% lateorder.ordernumber | html %]">[% lateorder.order_internalnote | html %]</span>
145
                        <a class="edit_note noExport" data-ordernumber="[% lateorder.ordernumber | html %]" data-note_type="internal" href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% lateorder.ordernumber | html %]&type=internal" title="Edit internal note">
145
                        <a class="edit_note noExport" data-ordernumber="[% lateorder.ordernumber | html %]" data-note_type="internal" href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% lateorder.ordernumber | html %]&type=internal" title="Edit internal note">
146
                            <i class="fa fa-pencil"></i> Edit internal note
146
                            <i class="fa fa-pencil"></i> Edit internal note
147
                        </a>
147
                        </a>
Lines 153-161 Link Here
153
                [% END %]
153
                [% END %]
154
            </td>
154
            </td>
155
            <td>
155
            <td>
156
                [% IF ( lateorder.vendornote ) %]
156
                [% IF lateorder.order_vendornote %]
157
                    <p class="ordernote">
157
                    <p class="ordernote">
158
                        <span id="vendor-note-[% lateorder.ordernumber | html %]">[% lateorder.vendornote | html %]</span>
158
                        <span id="vendor-note-[% lateorder.ordernumber | html %]">[% lateorder.order_vendornote | html %]</span>
159
                        <a class="edit_note noExport" data-ordernumber="[% lateorder.ordernumber | html %]" data-note_type="vendor" href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% lateorder.ordernumber | html %]&type=vendor" title="Edit vendor note">
159
                        <a class="edit_note noExport" data-ordernumber="[% lateorder.ordernumber | html %]" data-note_type="vendor" href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% lateorder.ordernumber | html %]&type=vendor" title="Edit vendor note">
160
                            <i class="fa fa-pencil"></i> Edit vendor note
160
                            <i class="fa fa-pencil"></i> Edit vendor note
161
                        </a>
161
                        </a>
Lines 166-179 Link Here
166
                    </a>
166
                    </a>
167
                [% END %]
167
                [% END %]
168
            </td>
168
            </td>
169
            <td>[% lateorder.isbn | $raw %]</td>
169
            <td>[% lateorder.biblio.biblioitem.isbn | $raw %]</td>
170
        </tr>
170
        </tr>
171
      [% END %]
171
      [% END %]
172
      </tbody>
172
      </tbody>
173
      <tfoot>
173
      <tfoot>
174
        <tr>
174
        <tr>
175
            <th colspan="6">Total</th>
175
            <th colspan="6">Total</th>
176
            <th>[% total | html %]</th>
176
            <th>[% total | $Price %]</th>
177
            <th colspan="9">&nbsp;</th>
177
            <th colspan="9">&nbsp;</th>
178
        </tr>
178
        </tr>
179
      </tfoot>
179
      </tfoot>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/showorder.tt (-2 / +2 lines)
Lines 17-27 Link Here
17
                    </li>
17
                    </li>
18
                    <li>
18
                    <li>
19
                        <span class="label">Claims count: </span>
19
                        <span class="label">Claims count: </span>
20
                        [% order.claims_count | html %]
20
                        [% order.claims.count | html %]
21
                    </li>
21
                    </li>
22
                    <li>
22
                    <li>
23
                        <span class="label">Last claim date: </span>
23
                        <span class="label">Last claim date: </span>
24
                        [% order.claimed_date | html %]
24
                        [% order.claims.last.claimed_on | html %]
25
                    </li>
25
                    </li>
26
            </ol>
26
            </ol>
27
          </fieldset>
27
          </fieldset>
(-)a/t/db_dependent/Acquisition.t (-13 / +11 lines)
Lines 391-406 is( scalar (@$search_orders), 0, "SearchOrders takes into account the biblionumb Link Here
391
ok( GetBudgetByOrderNumber( $ordernumbers[0] )->{'budget_id'} eq $budgetid,
391
ok( GetBudgetByOrderNumber( $ordernumbers[0] )->{'budget_id'} eq $budgetid,
392
    "GetBudgetByOrderNumber returns expected budget" );
392
    "GetBudgetByOrderNumber returns expected budget" );
393
393
394
my @lateorders = GetLateOrders(0);
394
my $lateorders = Koha::Acquisition::Orders->filter_by_lates({ delay => 0 });
395
is( scalar grep ( $_->{basketno} eq $basketno, @lateorders ),
395
is( $lateorders->search({ 'me.basketno' => $basketno })->count,
396
    0, "GetLateOrders does not get orders from opened baskets" );
396
    0, "GetLateOrders does not get orders from opened baskets" );
397
C4::Acquisition::CloseBasket($basketno);
397
C4::Acquisition::CloseBasket($basketno);
398
@lateorders = GetLateOrders(0);
398
$lateorders = Koha::Acquisition::Orders->filter_by_lates({ delay => 0 });
399
isnt( scalar grep ( $_->{basketno} eq $basketno, @lateorders ),
399
isnt( $lateorders->search({ 'me.basketno' => $basketno })->count,
400
    0, "GetLateOrders gets orders from closed baskets" );
400
    0, "GetLateOrders gets orders from closed baskets" );
401
ok( !grep ( $_->{ordernumber} eq $ordernumbers[3], @lateorders ),
401
is( $lateorders->search({ ordernumber => $ordernumbers[3] })->count, 0,
402
    "GetLateOrders does not get cancelled orders" );
402
    "GetLateOrders does not get cancelled orders" );
403
ok( !grep ( $_->{ordernumber} eq $ordernumbers[4], @lateorders ),
403
is( $lateorders->search({ ordernumber => $ordernumbers[4] })->count, 0,
404
    "GetLateOrders does not get received orders" );
404
    "GetLateOrders does not get received orders" );
405
405
406
$search_orders = SearchOrders({
406
$search_orders = SearchOrders({
Lines 415-427 is( scalar (@$search_orders), 4, "SearchOrders with pending and ordered params g Link Here
415
# Test AddClaim
415
# Test AddClaim
416
#
416
#
417
417
418
my $order = $lateorders[0];
418
my $order = $lateorders->next;
419
AddClaim( $order->{ordernumber} );
419
$order->claim();
420
my $neworder = GetOrder( $order->{ordernumber} );
421
is(
420
is(
422
    $neworder->{claimed_date},
421
    output_pref({ str => $order->claimed_date, dateformat => 'iso', dateonly => 1 }),
423
    strftime( "%Y-%m-%d", localtime(time) ),
422
    strftime( "%Y-%m-%d", localtime(time) ),
424
    "AddClaim : Check claimed_date"
423
    "Koha::Acquisition::Order->claim: Check claimed_date"
425
);
424
);
426
425
427
my $order2 = Koha::Acquisition::Orders->find( $ordernumbers[1] )->unblessed;
426
my $order2 = Koha::Acquisition::Orders->find( $ordernumbers[1] )->unblessed;
Lines 449-455 is( Link Here
449
    "ModReceiveOrder only changes the supplied orders internal notes"
448
    "ModReceiveOrder only changes the supplied orders internal notes"
450
);
449
);
451
450
452
$neworder = GetOrder($new_ordernumber);
451
my $neworder = GetOrder($new_ordernumber);
453
is( $neworder->{'quantity'}, 2, '2 items on new order' );
452
is( $neworder->{'quantity'}, 2, '2 items on new order' );
454
is( $neworder->{'quantityreceived'},
453
is( $neworder->{'quantityreceived'},
455
    2, 'Splitting up order received items on new order' );
454
    2, 'Splitting up order received items on new order' );
456
- 

Return to bug 24161