Bug 9280: FIX price calculation adding an order from a staged file
authorJonathan Druart <jonathan.druart@biblibre.com>
Thu, 13 Dec 2012 13:26:54 +0000 (14:26 +0100)
committerJared Camins-Esakov <jcamins@cpbibliography.com>
Thu, 24 Jan 2013 13:41:19 +0000 (08:41 -0500)
Test plan:
Add an order from a staged file containing a price value (010$d for
UNIMARC user).
Check this patch with 2 different vendors (listprice=1 and listprice=0).
Check the calculated price (depending discount and gstrate).

Signed-off-by: mathieu saby <mathieu.saby@univ-rennes2.fr>
Signed-off-by: Elliott Davis <elliott@bywatersolions.com>
introduces no new bugs
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
I was unable to replicate the bug in MARC21, but the patch introduces
no regressions that I could find, so I am pushing it anyway.
Note: Acquisitions remains unusable under Plack. In order to test this
patch I first applied the patch on bug 9432.

acqui/addorderiso2709.pl

index c4f889f..0e0670f 100755 (executable)
@@ -222,12 +222,8 @@ if ($op eq ""){
             my $basket     = GetBasket( $orderinfo{basketno} );
             my $bookseller = GetBookSellerFromId( $basket->{booksellerid} );
             $orderinfo{gstrate} = $bookseller->{gstrate};
-            if ( $bookseller->{listincgst} ) {
-                $orderinfo{ecost} = $price;
-            } else {
-                $orderinfo{ecost} = $price * ( 1 + $orderinfo{gstrate} );
-            }
-            $orderinfo{rrp} = ( $orderinfo{ecost} * 100 ) / ( 100 - $bookseller->{discount} );
+            $orderinfo{rrp}   = $price;
+            $orderinfo{ecost} = $orderinfo{rrp} * ( 1 - $bookseller->{discount} / 100 );
             $orderinfo{listprice} = $orderinfo{rrp};
             $orderinfo{unitprice} = $orderinfo{ecost};
             $orderinfo{total} = $orderinfo{ecost};