From 0fe43b3ad1f797fa502bbeb967c5c76e57774d51 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Thu, 13 Oct 2016 14:48:38 +0200 Subject: [PATCH] Bug 13323: 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 Signed-off-by: Nick Clemens Signed-off-by: Kyle M Hall --- C4/Acquisition.pm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 87e9189655..771f46872d 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -1409,7 +1409,9 @@ sub ModReceiveOrder { # Recalculate tax_value $dbh->do(q| UPDATE aqorders - SET tax_value = quantity * ecost_tax_excluded * tax_rate + SET + tax_value_on_ordering = quantity * ecost_tax_excluded * tax_rate_on_ordering, + tax_value_on_receiving = quantity * unitprice_tax_excluded * tax_rate_on_receiving WHERE ordernumber = ? |, undef, $order->{ordernumber}); @@ -1417,7 +1419,8 @@ sub ModReceiveOrder { $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->{tax_value_on_ordering} = $order->{quantity} * $order->{ecost_tax_excluded} * $order->{tax_rate_on_ordering}; + $order->{tax_value_on_receiving} = $order->{quantity} * $order->{unitprice_tax_excluded} * $order->{tax_rate_on_receiving}; $order->{datereceived} = $datereceived; $order->{invoiceid} = $invoice->{invoiceid}; $order->{orderstatus} = 'complete'; @@ -1577,7 +1580,9 @@ sub CancelReceipt { # Recalculate tax_value $dbh->do(q| UPDATE aqorders - SET tax_value = quantity * ecost_tax_excluded * tax_rate + SET + tax_value_on_ordering = quantity * ecost_tax_excluded * tax_rate_on_ordering, + tax_value_on_receiving = quantity * unitprice_tax_excluded * tax_rate_on_receiving WHERE ordernumber = ? |, undef, $parent_ordernumber); -- 2.20.1