From 6fecf47ea2fd970b20c7a5839d6bb45075b7f424 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 --- C4/Acquisition.pm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index dd385da..52a4ef4 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -2856,6 +2856,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}; @@ -2863,6 +2869,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}; -- 1.9.1