Bug 31306: Allow to pass params and attributes to search_ordered
[srvgit] / t / Edifact.t
index 6dedeac..21109af 100755 (executable)
@@ -3,7 +3,8 @@ use strict;
 use warnings;
 use FindBin qw( $Bin );
 
-use Test::More tests => 35;
+use Test::More tests => 40;
+use Koha::EDI;
 
 BEGIN { use_ok('Koha::Edifact') }
 
@@ -52,6 +53,8 @@ my $test_line = $lin->[-1];
 is( $test_line->line_item_number, 18, 'correct line number returned' );
 is( $test_line->item_number_id, '9780273761006', 'correct ean returned' );
 is( $test_line->quantity, 1, 'quantity returned' );
+is( $test_line->price_info, 114.97, 'price returned' );
+is( $test_line->price_info_inclusive, undef, 'discounted price undefined as expected' );
 
 my $test_title = 'International business [electronic resource]';
 my $marcrec    = $test_line->marc_record;
@@ -77,8 +80,8 @@ my $branch = $test_line->girfield('branch');
 is( $branch, 'ELIB', "branch returned" );
 my $fund_allocation = $test_line->girfield('fund_allocation');
 is( $fund_allocation, '660BOO_2013', "fund_allocation returned" );
-my $collection_code = $test_line->girfield('collection_code');
-is( $collection_code, 'EBOO', "collection_code returned" );
+my $sequence_code = $test_line->girfield('sequence_code');
+is( $sequence_code, 'EBOO', "sequence_code returned" );
 
 #my $shelfmark = $test_line->girfield('shelfmark');
 #my $classification = $test_line->girfield('classification');
@@ -115,8 +118,18 @@ is( $y, 'REF', 'Copy fund returned' );
 $y = $ol->girfield( 'branch', 4 );
 is( $y, 'SOU', 'Copy Branch returned' );
 
-$y = $ol->girfield( 'collection_code', 4 );
-is( $y, 'ANF', 'Collection code returned' );
+$y = $ol->girfield( 'sequence_code', 4 );
+is( $y, 'ANF', 'Sequence code returned' );
 
 $y = $ol->girfield( 'stock_category', 4 );
 is( $y, 'RS', 'Copy stock category returned' );
+
+# test internal routines for prices
+my $dp =  Koha::EDI::_discounted_price(33.0, 9);
+is( $dp, 6.03, 'Discount calculated' );
+
+$dp =  Koha::EDI::_discounted_price(0.0, 9);
+is( $dp, 9.0, 'Discount calculated with discount = 0' );
+
+$dp =  Koha::EDI::_discounted_price(0.0, 9, 8.0);
+is( $dp, 8.0, 'Discount overridden by incoming calculated value');