From 2b80e290c059319d3a01e670463a337daa3544a9 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 4d61598..61834d8 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -2870,6 +2870,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}; @@ -2877,6 +2883,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.7.0