Bug 13321: Recalculate tax_value for partially received orders

Test plan:
1. Create an order with at least 2 items
2. Receive only 1 item
3. Check that the tax value of the received order line is correct on
   the parcel and invoice pages
4. Check that the tax value of the original order line is correct (on
   the basket page for example)
5. Cancel the receipt
6. Check that the tax value of the original order line is correct

Signed-off-by: Sonia Bouis <koha@univ-lyon3.fr>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
Julian Maurice 2016-09-05 11:11:44 +02:00 committed by Kyle M Hall
parent b8872515cc
commit 1a05ec58cd

View file

@ -1400,10 +1400,18 @@ sub ModReceiveOrder {
$order->{ordernumber}
);
# Recalculate tax_value
$dbh->do(q|
UPDATE aqorders
SET tax_value = quantity * ecost_tax_excluded * tax_rate
WHERE ordernumber = ?
|, undef, $order->{ordernumber});
delete $order->{ordernumber};
$order->{budget_id} = ( $budget_id || $order->{budget_id} );
$order->{quantity} = $quantrec;
$order->{quantityreceived} = $quantrec;
$order->{tax_value} = $order->{quantity} * $order->{unitprice_tax_excluded} * $order->{tax_rate};
$order->{datereceived} = $datereceived;
$order->{invoiceid} = $invoice->{invoiceid};
$order->{orderstatus} = 'complete';
@ -1556,6 +1564,14 @@ sub CancelReceipt {
" receipt";
return;
}
# Recalculate tax_value
$dbh->do(q|
UPDATE aqorders
SET tax_value = quantity * ecost_tax_excluded * tax_rate
WHERE ordernumber = ?
|, undef, $parent_ordernumber);
_cancel_items_receipt( $ordernumber, $parent_ordernumber );
# Delete order line
$query = qq{