From 69ace403dbc558e380e6d632ae5668d7c2627d37 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 17 Dec 2020 12:21:32 +0000 Subject: [PATCH] Bug 27203: [alternate] Calculate tax based on ecost if unitprice not set There is code in populate_order_with_prices that is intended to use ecost over unitprice, it just doens't seem to be working. Making it more explicit seems to take care of the issue. To test: 1 - Create a basket 2 - Add an order line, don't set 'Actual cost: ', but use vendor price and a discount. 3 - Save 4 - Display all columns, 'Actual cost tax inc.' are GST columns aren't set. 5 - Apply batch 6 - Redo 1,2, 3 7 - Display all columns, GST is calculated correctly, unitprice remains 0. --- C4/Acquisition.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 2ac15473b4..72c0bcd882 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -2798,8 +2798,8 @@ sub populate_order_with_prices { # tax value = quantity * ecost tax excluded * tax rate # we should use the unitprice if included - my $cost_tax_included = $order->{unitprice_tax_included} || $order->{ecost_tax_included}; - my $cost_tax_excluded = $order->{unitprice_tax_excluded} || $order->{ecost_tax_excluded}; + my $cost_tax_included = $order->{unitprice_tax_included} == 0 ? $order->{ecost_tax_included} : $order->{unitprice_tax_included}; + my $cost_tax_excluded = $order->{unitprice_tax_excluded} == 0 ? $order->{ecost_tax_excluded} : $order->{unitprice_tax_excluded}; $order->{tax_value_on_ordering} = ( get_rounded_price($cost_tax_included) - get_rounded_price($cost_tax_excluded) ) * $order->{quantity}; } @@ -2820,7 +2820,7 @@ sub populate_order_with_prices { # tax value = quantity * ecost tax included * tax rate # we should use the unitprice if included - my $cost_tax_excluded = $order->{unitprice_tax_excluded} || $order->{ecost_tax_excluded}; + my $cost_tax_excluded = $order->{unitprice_tax_excluded} == 0 ? $order->{ecost_tax_excluded} : $order->{unitprice_tax_excluded}; $order->{tax_value_on_ordering} = $order->{quantity} * get_rounded_price($cost_tax_excluded) * $order->{tax_rate_on_ordering}; } } -- 2.11.0