From feb886dd774ce1e6effd313cf7670007f34d92ed Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@biblibre.com>
Date: Thu, 13 Dec 2012 14:26:54 +0100
Subject: [PATCH] Bug 9280: FIX price calculation adding an order from a staged file

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
---
 acqui/addorderiso2709.pl |   10 +++-------
 1 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/acqui/addorderiso2709.pl b/acqui/addorderiso2709.pl
index 4942571..0e0670f 100755
--- a/acqui/addorderiso2709.pl
+++ b/acqui/addorderiso2709.pl
@@ -189,7 +189,7 @@ if ($op eq ""){
             SetImportRecordStatus( $biblio->{'import_record_id'}, 'imported' );
         }
         # 3rd add order
-        my $patron = C4::Members->GetMember( borrowernumber => $loggedinuser );
+        my $patron = C4::Members::GetMember( borrowernumber => $loggedinuser );
         my $branch = C4::Branch->GetBranchDetail( $patron->{branchcode} );
         # get quantity in the MARC record (1 if none)
         my $quantity = GetMarcQuantity($marcrecord, C4::Context->preference('marcflavour')) || 1;
@@ -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};
-- 
1.7.2.5