From 7095e128e682ad036239d6352f84a40a2062f838 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. --- C4/Acquisition.pm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index c731169..8b6d153 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -2855,6 +2855,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}; @@ -2862,6 +2868,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