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

(-)a/C4/Acquisition.pm (-2 / +8 lines)
Lines 1380-1387 sub ModReceiveOrder { Link Here
1380
                        );
1380
                        );
1381
    }
1381
    }
1382
1382
1383
    my $result_set = $dbh->selectrow_arrayref(
1384
            q{SELECT aqbasket.is_standing
1385
            FROM aqbasket
1386
            WHERE basketno=?},{ Slice => {} }, $order->{basketno});
1387
    my $is_standing = $result_set->[0];  # we assume we have a unique basket
1388
1383
    my $new_ordernumber = $order->{ordernumber};
1389
    my $new_ordernumber = $order->{ordernumber};
1384
    if ( $order->{quantity} > $quantrec ) {
1390
    if ( $is_standing || $order->{quantity} > $quantrec ) {
1385
        # Split order line in two parts: the first is the original order line
1391
        # Split order line in two parts: the first is the original order line
1386
        # without received items (the quantity is decreased),
1392
        # without received items (the quantity is decreased),
1387
        # the second part is a new order line with quantity=quantityrec
1393
        # the second part is a new order line with quantity=quantityrec
Lines 1395-1401 sub ModReceiveOrder { Link Here
1395
        my $sth = $dbh->prepare($query);
1401
        my $sth = $dbh->prepare($query);
1396
1402
1397
        $sth->execute(
1403
        $sth->execute(
1398
            $order->{quantity} - $quantrec,
1404
            ( $is_standing ? 1 : ($order->{quantity} - $quantrec) ),
1399
            ( defined $order->{order_internalnote} ? $order->{order_internalnote} : () ),
1405
            ( defined $order->{order_internalnote} ? $order->{order_internalnote} : () ),
1400
            $order->{ordernumber}
1406
            $order->{ordernumber}
1401
        );
1407
        );
(-)a/t/db_dependent/Acquisition/StandingOrders.t (-11 / +23 lines)
Lines 56-68 is( $basket->{is_standing}, 1, 'basket correctly created as standing order baske Link Here
56
56
57
my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio( MARC::Record->new, '' );
57
my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio( MARC::Record->new, '' );
58
58
59
59
my $ordernumber = Koha::Acquisition::Order->new(
60
my $ordernumber = Koha::Acquisition::Order->new(
60
    {
61
    {
61
        basketno         => $basketno,
62
        basketno                 => $basketno,
62
        biblionumber     => $biblionumber,
63
        biblionumber             => $biblionumber,
63
        budget_id        => $budget->{budget_id},
64
        budget_id                => $budget->{budget_id},
64
        currency         => 'USD',
65
        currency                 => 'USD',
65
        quantity         => 0,
66
        quantity                 => 0,
67
        rrp                      => 42,
68
        rrp_tax_included         => 42,
69
        rrp_tax_excluded         => 42,
70
        ecost                    => 22,
71
        ecost_tax_included       => 22,
72
        ecost_tax_excluded       => 22,
73
        unitprice                => 12,
74
        unitprice_tax_included   => 12,
75
        unitprice_tax_excluded   => 12,
76
        tax_rate                 => 0,
77
        tax_rate_on_ordering     => 0,
78
        tax_rate_on_receiving    => 0,
66
    }
79
    }
67
)->insert->{ordernumber};
80
)->insert->{ordernumber};
68
81
Lines 85-105 my $invoiceid = AddInvoice( Link Here
85
    unknown       => "unknown"
98
    unknown       => "unknown"
86
);
99
);
87
100
101
my $order = Koha::Acquisition::Order->fetch( { ordernumber => $ordernumber } );
102
88
my ( $datereceived, $new_ordernumber ) = ModReceiveOrder(
103
my ( $datereceived, $new_ordernumber ) = ModReceiveOrder(
89
    {
104
    {
90
        biblionumber     => $biblionumber,
105
        biblionumber     => $biblionumber,
91
        ordernumber      => $ordernumber,
106
        order            => $order,
92
        quantityreceived => 2,
107
        quantityreceived => 2,
93
        cost             => 12,
94
        ecost            => 22,
95
        invoiceid        => $invoiceid,
108
        invoiceid        => $invoiceid,
96
        rrp              => 42,
97
    }
109
    }
98
);
110
);
99
111
100
isnt( $ordernumber, $new_ordernumber, "standing order split on receive" );
112
isnt( $ordernumber, $new_ordernumber, "standing order split on receive" );
101
113
102
my $order = Koha::Acquisition::Order->fetch( { ordernumber => $ordernumber } );
114
#order has been updated, refetch
115
$order = Koha::Acquisition::Order->fetch( { ordernumber => $ordernumber } );
103
my $neworder = Koha::Acquisition::Order->fetch( { ordernumber => $new_ordernumber } );
116
my $neworder = Koha::Acquisition::Order->fetch( { ordernumber => $new_ordernumber } );
104
117
105
is( $order->{orderstatus}, 'partial', 'original order set to partially received' );
118
is( $order->{orderstatus}, 'partial', 'original order set to partially received' );
106
- 

Return to bug 13321