From 8f5ee4c91dba7f2c05a574e2e3639a5eeb86ddc6 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 13 Jan 2015 17:03:04 +0100 Subject: [PATCH] Bug 13321: Fix unitprice rounding We need to display the rounded value, but insert the exact value. The unit price can be change on receiving, so the input value can be modified. But if it's not, we must insert the exact (not rounded) unit price, which is the ecost value. Signed-off-by: Laurence Rault Signed-off-by: Francois Charbonnier Signed-off-by: Sonia Bouis Signed-off-by: Sonia Bouis Signed-off-by: Nick Clemens Signed-off-by: Kyle M Hall --- C4/Acquisition.pm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 31af6e5623..2a8a85c094 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -2878,6 +2878,12 @@ sub populate_order_with_prices { if ($receiving) { if ( $bookseller->{invoiceincgst} ) { + # Trick for unitprice. If the unit price rounded value is the same as the ecost rounded value + # we need to keep the exact ecost value + if ( Koha::Number::Price->new( $order->{unitprice} )->round == Koha::Number::Price->new( $order->{ecost_tax_included} )->round ) { + $order->{unitprice} = $order->{ecost_tax_included}; + } + # The user entered the unit price tax included $order->{unitprice_tax_included} = $order->{unitprice}; @@ -2885,6 +2891,12 @@ sub populate_order_with_prices { $order->{unitprice_tax_excluded} = $order->{unitprice_tax_included} / ( 1 + $order->{tax_rate} ); } else { + # Trick for unitprice. If the unit price rounded value is the same as the ecost rounded value + # we need to keep the exact ecost value + if ( Koha::Number::Price->new( $order->{unitprice} )->round == Koha::Number::Price->new( $order->{ecost_tax_excluded} )->round ) { + $order->{unitprice} = $order->{ecost_tax_excluded}; + } + # The user entered the unit price tax excluded $order->{unitprice_tax_excluded} = $order->{unitprice}; -- 2.39.5