From e0174c3372169624c162adf4d8a53d491e12bf08 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Mon, 5 Sep 2016 11:11:44 +0200 Subject: [PATCH] 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 --- C4/Acquisition.pm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 1b16390..2c5af75 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -1390,10 +1390,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'; @@ -1546,6 +1554,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{ -- 2.1.4