From 0638e30cf71bd27d53b83d818a9f3143766c827f 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 --- C4/Acquisition.pm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 2201028..5e63ed5 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -1403,7 +1403,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}); @@ -1411,7 +1413,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'; @@ -1571,7 +1574,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.1.4