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

(-)a/C4/Acquisition.pm (-14 / +26 lines)
Lines 186-193 sub GetBasket { Link Here
186
186
187
=head3 NewBasket
187
=head3 NewBasket
188
188
189
  $basket = &NewBasket( $booksellerid, $authorizedby, $basketname, 
189
  $basket = &NewBasket( $booksellerid, $authorizedby, $basketname,
190
      $basketnote, $basketbooksellernote, $basketcontractnumber, $deliveryplace, $billingplace );
190
      $basketnote, $basketbooksellernote, $basketcontractnumber, $deliveryplace, $billingplace, $is_standing );
191
191
192
Create a new basket in aqbasket table
192
Create a new basket in aqbasket table
193
193
Lines 206-212 The other parameters are optional, see ModBasketHeader for more info on them. Link Here
206
sub NewBasket {
206
sub NewBasket {
207
    my ( $booksellerid, $authorisedby, $basketname, $basketnote,
207
    my ( $booksellerid, $authorisedby, $basketname, $basketnote,
208
        $basketbooksellernote, $basketcontractnumber, $deliveryplace,
208
        $basketbooksellernote, $basketcontractnumber, $deliveryplace,
209
        $billingplace ) = @_;
209
        $billingplace, $is_standing ) = @_;
210
    my $dbh = C4::Context->dbh;
210
    my $dbh = C4::Context->dbh;
211
    my $query =
211
    my $query =
212
        'INSERT INTO aqbasket (creationdate,booksellerid,authorisedby) '
212
        'INSERT INTO aqbasket (creationdate,booksellerid,authorisedby) '
Lines 218-224 sub NewBasket { Link Here
218
    $basketnote           ||= q{};
218
    $basketnote           ||= q{};
219
    $basketbooksellernote ||= q{};
219
    $basketbooksellernote ||= q{};
220
    ModBasketHeader( $basket, $basketname, $basketnote, $basketbooksellernote,
220
    ModBasketHeader( $basket, $basketname, $basketnote, $basketbooksellernote,
221
        $basketcontractnumber, $booksellerid, $deliveryplace, $billingplace );
221
        $basketcontractnumber, $booksellerid, $deliveryplace, $billingplace, $is_standing );
222
    return $basket;
222
    return $basket;
223
}
223
}
224
224
Lines 531-551 Modifies a basket's header. Link Here
531
531
532
=item C<$billingplace> is the "billingplace" field in the aqbasket table.
532
=item C<$billingplace> is the "billingplace" field in the aqbasket table.
533
533
534
=item C<$is_standing> is the "is_standing" field in the aqbasket table.
535
534
=back
536
=back
535
537
536
=cut
538
=cut
537
539
538
sub ModBasketHeader {
540
sub ModBasketHeader {
539
    my ($basketno, $basketname, $note, $booksellernote, $contractnumber, $booksellerid, $deliveryplace, $billingplace) = @_;
541
    my ($basketno, $basketname, $note, $booksellernote, $contractnumber, $booksellerid, $deliveryplace, $billingplace, $is_standing) = @_;
540
    my $query = qq{
542
    my $query = qq{
541
        UPDATE aqbasket
543
        UPDATE aqbasket
542
        SET basketname=?, note=?, booksellernote=?, booksellerid=?, deliveryplace=?, billingplace=?
544
        SET basketname=?, note=?, booksellernote=?, booksellerid=?, deliveryplace=?, billingplace=?, is_standing=?
543
        WHERE basketno=?
545
        WHERE basketno=?
544
    };
546
    };
545
547
546
    my $dbh = C4::Context->dbh;
548
    my $dbh = C4::Context->dbh;
547
    my $sth = $dbh->prepare($query);
549
    my $sth = $dbh->prepare($query);
548
    $sth->execute($basketname, $note, $booksellernote, $booksellerid, $deliveryplace, $billingplace, $basketno);
550
    $sth->execute($basketname, $note, $booksellernote, $booksellerid, $deliveryplace, $billingplace, $is_standing, $basketno);
549
551
550
    if ( $contractnumber ) {
552
    if ( $contractnumber ) {
551
        my $query2 ="UPDATE aqbasket SET contractnumber=? WHERE basketno=?";
553
        my $query2 ="UPDATE aqbasket SET contractnumber=? WHERE basketno=?";
Lines 1385-1391 sub ModReceiveOrder { Link Here
1385
    }
1387
    }
1386
1388
1387
    my $result_set = $dbh->selectall_arrayref(
1389
    my $result_set = $dbh->selectall_arrayref(
1388
q{SELECT * FROM aqorders WHERE biblionumber=? AND aqorders.ordernumber=?},
1390
q{SELECT *, aqbasket.is_standing FROM aqorders LEFT JOIN aqbasket USING (basketno) WHERE biblionumber=? AND aqorders.ordernumber=?},
1389
        { Slice => {} }, $biblionumber, $ordernumber
1391
        { Slice => {} }, $biblionumber, $ordernumber
1390
    );
1392
    );
1391
1393
Lines 1393-1399 q{SELECT * FROM aqorders WHERE biblionumber=? AND aqorders.ordernumber=?}, Link Here
1393
    my $order = $result_set->[0];
1395
    my $order = $result_set->[0];
1394
1396
1395
    my $new_ordernumber = $ordernumber;
1397
    my $new_ordernumber = $ordernumber;
1396
    if ( $order->{quantity} > $quantrec ) {
1398
    if ( $order->{is_standing} || $order->{quantity} > $quantrec ) {
1397
        # Split order line in two parts: the first is the original order line
1399
        # Split order line in two parts: the first is the original order line
1398
        # without received items (the quantity is decreased),
1400
        # without received items (the quantity is decreased),
1399
        # the second part is a new order line with quantity=quantityrec
1401
        # the second part is a new order line with quantity=quantityrec
Lines 1408-1414 q{SELECT * FROM aqorders WHERE biblionumber=? AND aqorders.ordernumber=?}, Link Here
1408
        my $sth = $dbh->prepare($query);
1410
        my $sth = $dbh->prepare($query);
1409
1411
1410
        $sth->execute(
1412
        $sth->execute(
1411
            $order->{quantity} - $quantrec,
1413
            ( $order->{quantity} < $quantrec ? 0 : ( $order->{quantity} - $quantrec ) ),
1412
            ( defined $order_internalnote ? $order_internalnote : () ),
1414
            ( defined $order_internalnote ? $order_internalnote : () ),
1413
            ( defined $order_vendornote ? $order_vendornote : () ),
1415
            ( defined $order_vendornote ? $order_vendornote : () ),
1414
            $ordernumber
1416
            $ordernumber
Lines 1684-1693 sub SearchOrders { Link Here
1684
    };
1686
    };
1685
1687
1686
    if ( $pending or $ordered ) {
1688
    if ( $pending or $ordered ) {
1687
        $query .= q{ AND (quantity > quantityreceived OR quantityreceived is NULL)};
1689
        $query .= q{
1688
    }
1690
            AND (
1689
    if ( $ordered ) {
1691
                ( aqbasket.is_standing AND aqorders.orderstatus IN ( "new", "ordered", "partial" ) )
1690
        $query .= q{ AND aqorders.orderstatus IN ( "ordered", "partial" )};
1692
                OR (
1693
                    ( quantity > quantityreceived OR quantityreceived is NULL )
1694
        };
1695
1696
        if ( $ordered ) {
1697
            $query .= q{ AND aqorders.orderstatus IN ( "ordered", "partial" )};
1698
        }
1699
        $query .= q{
1700
                )
1701
            )
1702
        };
1691
    }
1703
    }
1692
1704
1693
    my $userenv = C4::Context->userenv;
1705
    my $userenv = C4::Context->userenv;
(-)a/Koha/Acquisition/Order.pm (-2 / +6 lines)
Lines 27-42 sub insert { Link Here
27
    my ($self) = @_;
27
    my ($self) = @_;
28
28
29
    # if these parameters are missing, we can't continue
29
    # if these parameters are missing, we can't continue
30
    for my $key (qw( basketno quantity biblionumber budget_id )) {
30
    for my $key (qw( basketno biblionumber budget_id )) {
31
        croak "Cannot insert order: Mandatory parameter $key is missing"
31
        croak "Cannot insert order: Mandatory parameter $key is missing"
32
          unless $self->{$key};
32
          unless $self->{$key};
33
    }
33
    }
34
34
35
    my $schema  = Koha::Database->new->schema;
36
    if ( !$self->{quantity} && !$schema->resultset('Aqbasket')->find( $self->{basketno} )->is_standing ) {
37
        croak "Cannot insert order: Quantity is mandatory for non-standing orders";
38
    }
39
35
    $self->{quantityreceived} ||= 0;
40
    $self->{quantityreceived} ||= 0;
36
    $self->{entrydate} ||=
41
    $self->{entrydate} ||=
37
      output_pref( { dt => dt_from_string, dateformat => 'iso' } );
42
      output_pref( { dt => dt_from_string, dateformat => 'iso' } );
38
43
39
    my $schema  = Koha::Database->new->schema;
40
    my @columns = $schema->source('Aqorder')->columns;
44
    my @columns = $schema->source('Aqorder')->columns;
41
45
42
    $self->{ordernumber} ||= undef;
46
    $self->{ordernumber} ||= undef;
(-)a/Koha/Schema/Result/Aqbasket.pm (-2 / +10 lines)
Lines 106-111 __PACKAGE__->table("aqbasket"); Link Here
106
  is_nullable: 1
106
  is_nullable: 1
107
  size: 10
107
  size: 10
108
108
109
=head2 is_standing
110
111
  data_type: 'tinyint'
112
  default_value: 0
113
  is_nullable: 0
114
109
=cut
115
=cut
110
116
111
__PACKAGE__->add_columns(
117
__PACKAGE__->add_columns(
Lines 142-147 __PACKAGE__->add_columns( Link Here
142
  { data_type => "varchar", is_nullable => 1, size => 10 },
148
  { data_type => "varchar", is_nullable => 1, size => 10 },
143
  "branch",
149
  "branch",
144
  { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 },
150
  { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 },
151
  "is_standing",
152
  { data_type => "tinyint", default_value => 0, is_nullable => 0 },
145
);
153
);
146
154
147
=head1 PRIMARY KEY
155
=head1 PRIMARY KEY
Lines 289-296 Composing rels: L</aqbasketusers> -> borrowernumber Link Here
289
__PACKAGE__->many_to_many("borrowernumbers", "aqbasketusers", "borrowernumber");
297
__PACKAGE__->many_to_many("borrowernumbers", "aqbasketusers", "borrowernumber");
290
298
291
299
292
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2014-09-02 11:37:47
300
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-01-14 16:28:06
293
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:tsMzwP7eofOR27sfZSTqFQ
301
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:CuP/8SFJOD4h4XZf7AdeiA
294
302
295
303
296
# You can replace this text with custom content, and it will be preserved on regeneration
304
# You can replace this text with custom content, and it will be preserved on regeneration
(-)a/acqui/addorder.pl (-2 / +4 lines)
Lines 228-239 $orderinfo->{'list_price'} ||= 0; Link Here
228
$orderinfo->{'uncertainprice'} ||= 0;
228
$orderinfo->{'uncertainprice'} ||= 0;
229
$orderinfo->{subscriptionid} ||= undef;
229
$orderinfo->{subscriptionid} ||= undef;
230
230
231
my $basketno=$$orderinfo{basketno};
232
my $basket = GetBasket($basketno);
233
231
my $user = $input->remote_user;
234
my $user = $input->remote_user;
232
235
233
# create, modify or delete biblio
236
# create, modify or delete biblio
234
# create if $quantity>0 and $existing='no'
237
# create if $quantity>0 and $existing='no'
235
# modify if $quantity>0 and $existing='yes'
238
# modify if $quantity>0 and $existing='yes'
236
if ( $orderinfo->{quantity} ne '0' ) {
239
if ( $basket->{is_standing} || $orderinfo->{quantity} ne '0' ) {
237
    #TODO:check to see if biblio exists
240
    #TODO:check to see if biblio exists
238
    unless ( $$orderinfo{biblionumber} ) {
241
    unless ( $$orderinfo{biblionumber} ) {
239
        #if it doesn't create it
242
        #if it doesn't create it
Lines 319-325 if ( $orderinfo->{quantity} ne '0' ) { Link Here
319
322
320
}
323
}
321
324
322
my $basketno=$$orderinfo{basketno};
323
my $booksellerid=$$orderinfo{booksellerid};
325
my $booksellerid=$$orderinfo{booksellerid};
324
if (my $import_batch_id=$$orderinfo{import_batch_id}) {
326
if (my $import_batch_id=$$orderinfo{import_batch_id}) {
325
    print $input->redirect("/cgi-bin/koha/acqui/addorderiso2709.pl?import_batch_id=$import_batch_id&basketno=$basketno&booksellerid=$booksellerid");
327
    print $input->redirect("/cgi-bin/koha/acqui/addorderiso2709.pl?import_batch_id=$import_batch_id&basketno=$basketno&booksellerid=$booksellerid");
(-)a/acqui/basket.pl (-4 / +12 lines)
Lines 366-371 elsif ( $op eq 'ediorder' ) { Link Here
366
366
367
    $template->param(
367
    $template->param(
368
        basketno             => $basketno,
368
        basketno             => $basketno,
369
        basket               => $basket,
369
        basketname           => $basket->{'basketname'},
370
        basketname           => $basket->{'basketname'},
370
        basketbranchname     => C4::Branch::GetBranchName($basket->{branch}),
371
        basketbranchname     => C4::Branch::GetBranchName($basket->{branch}),
371
        basketnote           => $basket->{note},
372
        basketnote           => $basket->{note},
Lines 380-385 elsif ( $op eq 'ediorder' ) { Link Here
380
        users                => \@basketusers,
381
        users                => \@basketusers,
381
        closedate            => $basket->{closedate},
382
        closedate            => $basket->{closedate},
382
        estimateddeliverydate=> $estimateddeliverydate,
383
        estimateddeliverydate=> $estimateddeliverydate,
384
        is_standing          => $basket->{is_standing},
383
        deliveryplace        => C4::Branch::GetBranchName( $basket->{deliveryplace} ),
385
        deliveryplace        => C4::Branch::GetBranchName( $basket->{deliveryplace} ),
384
        billingplace         => C4::Branch::GetBranchName( $basket->{billingplace} ),
386
        billingplace         => C4::Branch::GetBranchName( $basket->{billingplace} ),
385
        active               => $bookseller->{'active'},
387
        active               => $bookseller->{'active'},
Lines 397-403 elsif ( $op eq 'ediorder' ) { Link Here
397
        basketgroups         => $basketgroups,
399
        basketgroups         => $basketgroups,
398
        basketgroup          => $basketgroup,
400
        basketgroup          => $basketgroup,
399
        grouped              => $basket->{basketgroupid},
401
        grouped              => $basket->{basketgroupid},
400
        unclosable           => @orders ? 0 : 1, 
402
        # The double negatives and booleans here mean:
403
        # "A basket cannot be closed if there are no orders in it or it's a standing order basket."
404
        #
405
        # (The template has another implicit restriction that the order cannot be closed if there
406
        # are any orders with uncertain prices.)
407
        unclosable           => @orders ? $basket->{is_standing} : 1,
401
        has_budgets          => $has_budgets,
408
        has_budgets          => $has_budgets,
402
        duplinbatch          => $duplinbatch,
409
        duplinbatch          => $duplinbatch,
403
    );
410
    );
Lines 410-419 sub get_order_infos { Link Here
410
    if ( !defined $order->{quantityreceived} ) {
417
    if ( !defined $order->{quantityreceived} ) {
411
        $order->{quantityreceived} = 0;
418
        $order->{quantityreceived} = 0;
412
    }
419
    }
413
    my $budget = GetBudget( $order->{'budget_id'} );
420
    my $budget = GetBudget($order->{budget_id});
421
    my $basket = GetBasket($order->{basketno});
414
422
415
    my %line = %{ $order };
423
    my %line = %{ $order };
416
    $line{order_received} = ( $qty == $order->{'quantityreceived'} );
424
    # Don't show unreceived standing orders as received
425
    $line{order_received} = ( $qty == $order->{'quantityreceived'} && ( $basket->{is_standing} ? $qty : 1 ) );
417
    $line{basketno}       = $basketno;
426
    $line{basketno}       = $basketno;
418
    $line{budget_name}    = $budget->{budget_name};
427
    $line{budget_name}    = $budget->{budget_name};
419
428
Lines 463-469 sub get_order_infos { Link Here
463
    foreach my $key (qw(transferred_from transferred_to)) {
472
    foreach my $key (qw(transferred_from transferred_to)) {
464
        if ($line{$key}) {
473
        if ($line{$key}) {
465
            my $order = GetOrder($line{$key});
474
            my $order = GetOrder($line{$key});
466
            my $basket = GetBasket($order->{basketno});
467
            my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $basket->{booksellerid} });
475
            my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $basket->{booksellerid} });
468
            $line{$key} = {
476
            $line{$key} = {
469
                order => $order,
477
                order => $order,
(-)a/acqui/basketheader.pl (+2 lines)
Lines 148-153 if ( $op eq 'add_form' ) { Link Here
148
            $input->param('basketbooksellerid'),
148
            $input->param('basketbooksellerid'),
149
            $input->param('deliveryplace'),
149
            $input->param('deliveryplace'),
150
            $input->param('billingplace'),
150
            $input->param('billingplace'),
151
            $input->param('is_standing') ? 1 : undef,
151
        );
152
        );
152
    } else { #New basket
153
    } else { #New basket
153
        $basketno = NewBasket(
154
        $basketno = NewBasket(
Lines 159-164 if ( $op eq 'add_form' ) { Link Here
159
            $input->param('basketcontractnumber') || undef,
160
            $input->param('basketcontractnumber') || undef,
160
            $input->param('deliveryplace'),
161
            $input->param('deliveryplace'),
161
            $input->param('billingplace'),
162
            $input->param('billingplace'),
163
            $input->param('is_standing') ? 1 : undef,
162
        );
164
        );
163
    }
165
    }
164
    print $input->redirect('basket.pl?basketno='.$basketno);
166
    print $input->redirect('basket.pl?basketno='.$basketno);
(-)a/acqui/neworderempty.pl (+1 lines)
Lines 324-329 $template->param( Link Here
324
    ordernumber           => $ordernumber,
324
    ordernumber           => $ordernumber,
325
    # basket informations
325
    # basket informations
326
    basketno             => $basketno,
326
    basketno             => $basketno,
327
    basket               => $basket,
327
    basketname           => $basket->{'basketname'},
328
    basketname           => $basket->{'basketname'},
328
    basketnote           => $basket->{'note'},
329
    basketnote           => $basket->{'note'},
329
    booksellerid         => $basket->{'booksellerid'},
330
    booksellerid         => $basket->{'booksellerid'},
(-)a/installer/data/mysql/atomicupdate/bug_15531-add_is_standing_to_aqbasket.sql (+1 lines)
Line 0 Link Here
1
ALTER TABLE aqbasket ADD COLUMN is_standing TINYINT(1) NOT NULL DEFAULT 0;
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 2883-2888 CREATE TABLE `aqbasket` ( -- stores data about baskets in acquisitions Link Here
2883
  `deliveryplace` varchar(10) default NULL, -- basket delivery place
2883
  `deliveryplace` varchar(10) default NULL, -- basket delivery place
2884
  `billingplace` varchar(10) default NULL, -- basket billing place
2884
  `billingplace` varchar(10) default NULL, -- basket billing place
2885
  branch varchar(10) default NULL, -- basket branch
2885
  branch varchar(10) default NULL, -- basket branch
2886
  is_standing TINYINT(1) NOT NULL DEFAULT 0, -- orders in this basket are standing
2886
  PRIMARY KEY  (`basketno`),
2887
  PRIMARY KEY  (`basketno`),
2887
  KEY `booksellerid` (`booksellerid`),
2888
  KEY `booksellerid` (`booksellerid`),
2888
  KEY `basketgroupid` (`basketgroupid`),
2889
  KEY `basketgroupid` (`basketgroupid`),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt (-1 / +4 lines)
Lines 316-321 Link Here
316
                [% IF ( creationdate ) %]<li><span class="label">Opened on:</span>  [% creationdate | $KohaDates %]</li>[% END %]
316
                [% IF ( creationdate ) %]<li><span class="label">Opened on:</span>  [% creationdate | $KohaDates %]</li>[% END %]
317
                [% IF ( closedate ) %]<li><span class="label">Closed on:</span> [% closedate | $KohaDates %]</li>[% END %]
317
                [% IF ( closedate ) %]<li><span class="label">Closed on:</span> [% closedate | $KohaDates %]</li>[% END %]
318
                [% IF ( estimateddeliverydate ) %]<li><span class="label">Estimated delivery date:</span> [% estimateddeliverydate | $KohaDates  %]</li>[% END %]
318
                [% IF ( estimateddeliverydate ) %]<li><span class="label">Estimated delivery date:</span> [% estimateddeliverydate | $KohaDates  %]</li>[% END %]
319
                [% IF ( estimateddeliverydate ) %]<li><span class="label">Estimated delivery date:</span> [% estimateddeliverydate | $KohaDates  %]</li>[% END %]
320
                <li><span class="label">Is standing order basket:</span> [% IF is_standing %]Yes[% ELSE %]No[% END %]</li>
321
319
322
320
                </ol>
323
                </ol>
321
                </div>
324
                </div>
Lines 516-522 Link Here
516
                        <td class="number gste [% IF books_loo.ecostgste.search(zero_regex) %]error[% END %]">[% books_loo.ecostgste | $Price%]</td>
519
                        <td class="number gste [% IF books_loo.ecostgste.search(zero_regex) %]error[% END %]">[% books_loo.ecostgste | $Price%]</td>
517
                        <td class="number gsti [% IF books_loo.rrpgsti.search(zero_regex) %]error[% END %]">[% books_loo.rrpgsti | $Price %]</td>
520
                        <td class="number gsti [% IF books_loo.rrpgsti.search(zero_regex) %]error[% END %]">[% books_loo.rrpgsti | $Price %]</td>
518
                        <td class="number gsti [% IF books_loo.ecostgsti.search(zero_regex) %]error[% END %]">[% books_loo.ecostgsti | $Price %]</td>
521
                        <td class="number gsti [% IF books_loo.ecostgsti.search(zero_regex) %]error[% END %]">[% books_loo.ecostgsti | $Price %]</td>
519
                        <td class="number [% IF books_loo.quantity.search(zero_regex) %]error[% END %]">[% books_loo.quantity %]</td>
522
                        <td class="number [% IF books_loo.quantity.search(zero_regex) %]error[% END %]">[% IF is_standing and books_loo.quantity == 0 %]N/A[% ELSE %][% books_loo.quantity or 'N/A' %][% END %]</td>
520
                        <td class="number gste [% IF books_loo.totalgste.search(zero_regex) %]error[% END %]">[% books_loo.totalgste | $Price %]</td>
523
                        <td class="number gste [% IF books_loo.totalgste.search(zero_regex) %]error[% END %]">[% books_loo.totalgste | $Price %]</td>
521
                        <td class="number gsti [% IF books_loo.totalgsti.search(zero_regex) %]error[% END %]">[% books_loo.totalgsti | $Price %]</td>
524
                        <td class="number gsti [% IF books_loo.totalgsti.search(zero_regex) %]error[% END %]">[% books_loo.totalgsti | $Price %]</td>
522
                        <td class="number">[% books_loo.gstrate * 100 | $Price %]</td>
525
                        <td class="number">[% books_loo.gstrate * 100 | $Price %]</td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tt (+5 lines)
Lines 113-118 Link Here
113
                        </select>
113
                        </select>
114
                    </li>
114
                    </li>
115
                [% END %]
115
                [% END %]
116
                <li>
117
                    <label for="is_standing">Orders are standing:</label>
118
                    <input type="checkbox" id="is_standing" name="is_standing"/>
119
                    <div class="hint">Standing orders do not close when received.</div>
120
                </li>
116
            </ol>
121
            </ol>
117
        </fieldset>
122
        </fieldset>
118
        <fieldset class="action">
123
        <fieldset class="action">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt (-20 / +24 lines)
Lines 43-52 function Check(ff) { Link Here
43
        _alertString += "\n- "+ _("You must select a fund");
43
        _alertString += "\n- "+ _("You must select a fund");
44
    }
44
    }
45
45
46
[% UNLESS basket.is_standing %]
46
    if (!(isNum(ff.quantity,0)) || ff.quantity.value == 0){
47
    if (!(isNum(ff.quantity,0)) || ff.quantity.value == 0){
47
        ok=1;
48
        ok=1;
48
                    _alertString += "\n- " + _("Quantity must be greater than '0'");
49
                    _alertString += "\n- " + _("Quantity must be greater than '0'");
49
    }
50
    }
51
[% END %]
50
52
51
    if (!(isNum(ff.listprice,0))){
53
    if (!(isNum(ff.listprice,0))){
52
        ok=1;
54
        ok=1;
Lines 459-488 $(document).ready(function() Link Here
459
    <fieldset class="rows">
461
    <fieldset class="rows">
460
        <legend>Accounting details</legend>
462
        <legend>Accounting details</legend>
461
        <ol>
463
        <ol>
462
            <li>
464
            [% UNLESS basket.is_standing %]
463
                [% IF ( close ) %]
465
                <li>
464
            <span class="label required">Quantity: </span>
466
                    [% IF ( close ) %]
465
                    <input type="hidden" name="quantity" value="[% quantity %]" />[% quantity %]
467
                        <span class="label required">Quantity: </span>
466
                [% ELSE %]
468
                        <input type="hidden" name="quantity" value="[% quantity %]" />[% quantity %]
467
                    <label class="required" for="quantity">Quantity: </label>
468
                    [% IF (AcqCreateItemOrdering) %]
469
                        [% IF subscriptionid %]
470
                            <input type="text" readonly="readonly" size="20" id="quantity" name="quantity" value="1" />
471
                        [% ELSE %]
472
                            <input type="text" readonly="readonly" size="20" id="quantity" name="quantity" value="0" />
473
                        [% END %]
474
                    [% ELSE %]
469
                    [% ELSE %]
475
                        [% IF subscriptionid %]
470
                        <label class="required" for="quantity">Quantity: </label>
476
                            <input type="text" readonly="readonly" size="20" id="quantity" name="quantity" value="1" />
471
                        [% IF (AcqCreateItemOrdering) %]
472
                            [% IF subscriptionid %]
473
                                <input type="text" readonly="readonly" size="20" id="quantity" name="quantity" value="1" />
474
                            [% ELSE %]
475
                                <input type="text" readonly="readonly" size="20" id="quantity" name="quantity" value="0" />
476
                            [% END %]
477
                        [% ELSE %]
477
                        [% ELSE %]
478
                            <input type="text" size="20" id="quantity" name="quantity" value="[% quantityrec %]" onchange="updateCosts();" />
478
                            [% IF subscriptionid %]
479
                                <input type="text" readonly="readonly" size="20" id="quantity" name="quantity" value="1" />
480
                            [% ELSE %]
481
                                <input type="text" size="20" id="quantity" name="quantity" value="[% quantityrec %]" onchange="updateCosts();" />
482
                            [% END %]
479
                        [% END %]
483
                        [% END %]
484
                        <span class="required">Required</span>
480
                    [% END %]
485
                    [% END %]
481
                    <span class="required">Required</span>
486
                    <!-- origquantityrec only here for javascript compatibility (additem.js needs it, useless here, usefull when receiveing an order -->
482
                [% END %]
487
                    <input id="origquantityrec" readonly="readonly" type="hidden" name="origquantityrec" value="1" />
483
                <!-- origquantityrec only here for javascript compatibility (additem.js needs it, useless here, usefull when receiveing an order -->
488
                </li>
484
                <input id="origquantityrec" readonly="readonly" type="hidden" name="origquantityrec" value="1" />
489
            [% END %]
485
            </li>
486
            <li>
490
            <li>
487
                [% IF ( close ) %]
491
                [% IF ( close ) %]
488
            <span class="label required">Fund: </span>
492
            <span class="label required">Fund: </span>
(-)a/t/db_dependent/Acquisition/NewOrder.t (-1 / +4 lines)
Lines 67-72 foreach my $mandatoryparams_key (@mandatoryparams_keys) { Link Here
67
    };
67
    };
68
    $return_error = $@;
68
    $return_error = $@;
69
    my $expected_error = "Cannot insert order: Mandatory parameter $mandatoryparams_key is missing";
69
    my $expected_error = "Cannot insert order: Mandatory parameter $mandatoryparams_key is missing";
70
    if ( $mandatoryparams_key eq 'quantity' ) {
71
        $expected_error = "Cannot insert order: Quantity is mandatory for non-standing orders";
72
    }
70
    ok(
73
    ok(
71
        ( !( defined $order ) )
74
        ( !( defined $order ) )
72
          && ( index( $return_error, $expected_error ) >= 0 ),
75
          && ( index( $return_error, $expected_error ) >= 0 ),
Lines 87-90 $order = Koha::Acquisition::Order->fetch({ ordernumber => $ordernumber }); Link Here
87
is( $order->{quantityreceived}, 0, 'Koha::Acquisition::Order->insert set quantityreceivedto 0 if undef is given' );
90
is( $order->{quantityreceived}, 0, 'Koha::Acquisition::Order->insert set quantityreceivedto 0 if undef is given' );
88
is( $order->{entrydate}, output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), 'Koha::Acquisition::Order->insert set entrydate to today' );
91
is( $order->{entrydate}, output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), 'Koha::Acquisition::Order->insert set entrydate to today' );
89
92
90
$schema->storage->txn_rollback();
93
$schema->storage->txn_rollback();
(-)a/t/db_dependent/Acquisition/StandingOrders.t (-1 / +136 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
use Modern::Perl;
4
5
use Test::More tests => 14;
6
use C4::Context;
7
use C4::Acquisition;
8
use C4::Biblio;
9
use C4::Items;
10
use C4::Bookseller;
11
use C4::Budgets;
12
use Koha::Acquisition::Order;
13
use t::lib::Mocks;
14
use t::lib::TestBuilder;
15
16
my $schema = Koha::Database->schema;
17
$schema->storage->txn_begin;
18
my $builder = t::lib::TestBuilder->new;
19
20
# Set up configuration data
21
22
my $branch = $builder->build( { source => 'Branch' } );
23
my $bookseller = $builder->build( { source => 'Aqbookseller' } );
24
my $budget = $builder->build( { source => 'Aqbudget' } );
25
my $staffmember = $builder->build( { source => 'Borrower' } );
26
27
# Create baskets and orders
28
29
my $basketno = NewBasket(
30
    $bookseller->{id},
31
    $staffmember->{borrowernumber},
32
    'Standing order basket', # basketname
33
    '', # basketnote
34
    '', # basketbooksellernote
35
    undef, # basketcontractnumber
36
    $branch->{branchcode}, # deliveryplace
37
    $branch->{branchcode}, # billingplace
38
    1 # is_standing
39
);
40
41
my $nonstandingbasketno = NewBasket(
42
    $bookseller->{id},
43
    $staffmember->{borrowernumber},
44
    'Non-standing order basket', # basketname
45
    '', # basketnote
46
    '', # basketbooksellernote
47
    undef, # basketcontractnumber
48
    $branch->{branchcode}, # deliveryplace
49
    $branch->{branchcode}, # billingplace
50
    0 # is_standing
51
);
52
53
my $basket = GetBasket($basketno);
54
55
is( $basket->{is_standing}, 1, 'basket correctly created as standing order basket' );
56
57
my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio( MARC::Record->new, '' );
58
59
my $ordernumber = Koha::Acquisition::Order->new(
60
    {
61
        basketno         => $basketno,
62
        biblionumber     => $biblionumber,
63
        budget_id        => $budget->{budget_id},
64
        currency         => 'USD',
65
        quantity         => 0,
66
    }
67
)->insert->{ordernumber};
68
69
isnt( $ordernumber, undef, 'standing order successfully created' );
70
71
eval {
72
    Koha::Acquisition::Order->new(
73
        {
74
            basketno         => $nonstandingbasketno,
75
            biblionumber     => $biblionumber,
76
            budget_id        => $budget->{budget_id},
77
            currency         => 'USD',
78
            quantity         => 0,
79
        }
80
    )->insert;
81
};
82
83
like( $@, qr/quantity/im, 'normal orders cannot be created without quantity' );
84
85
my $search_orders = SearchOrders( {
86
    basketno => $basketno,
87
    pending => 1,
88
    ordered => 1,
89
} );
90
91
ok(
92
    scalar @$search_orders == 1 && $search_orders->[0]->{ordernumber} == $ordernumber,
93
    'standing order counts as a pending/ordered order'
94
);
95
96
my $invoiceid = AddInvoice(
97
    invoicenumber => 'invoice',
98
    booksellerid  => $bookseller->{id},
99
    unknown       => "unknown"
100
);
101
102
my ( $datereceived, $new_ordernumber ) = ModReceiveOrder(
103
    {
104
        biblionumber     => $biblionumber,
105
        ordernumber      => $ordernumber,
106
        quantityreceived => 2,
107
        cost             => 12,
108
        ecost            => 22,
109
        invoiceid        => $invoiceid,
110
        rrp              => 42,
111
    }
112
);
113
114
isnt( $ordernumber, $new_ordernumber, "standing order split on receive" );
115
116
my $order = Koha::Acquisition::Order->fetch( { ordernumber => $ordernumber } );
117
my $neworder = Koha::Acquisition::Order->fetch( { ordernumber => $new_ordernumber } );
118
119
is( $order->{orderstatus}, 'partial', 'original order set to partially received' );
120
is( $order->{quantity}, 0, 'original order quantity unchanged' );
121
is( $order->{quantityreceived}, 0, 'original order has no received items' );
122
isnt( $order->{unitprice}, 12, 'original order does not get cost' );
123
is( $neworder->{orderstatus}, 'complete', 'new order set to complete' );
124
is( $neworder->{quantityreceived}, 2, 'new order has received items' );
125
cmp_ok( $neworder->{unitprice}, '==', 12, 'new order does get cost' );
126
127
$search_orders = SearchOrders( {
128
    basketno => $basketno,
129
    pending => 1,
130
    ordered => 1,
131
} );
132
133
is( scalar @$search_orders, 1, 'only one pending order after receive' );
134
is( $search_orders->[0]->{ordernumber}, $ordernumber, 'original order is only pending order' );
135
136
$schema->storage->txn_rollback();

Return to bug 15531