From d464378b288ccc60f1b8653ae94223dd390d7218 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 17 Dec 2020 12:21:32 +0000 Subject: [PATCH] Bug 27203: 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. Signed-off-by: Marjorie Signed-off-by: Victor Grousset/tuxayo Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart (cherry picked from commit 66d26fa301a8e5375998da513a0a18d21974ce94) Signed-off-by: Fridolin Somers (cherry picked from commit a103cdbf1fddc41597ef8b0632fbdd475bad439a) Signed-off-by: Andrew Fuerste-Henry --- C4/Acquisition.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 3aff14d667..a66f546472 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -2898,8 +2898,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}; } @@ -2920,7 +2920,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.39.5