Lines 82-87
BEGIN {
Link Here
|
82 |
&GetXmlBiblio |
82 |
&GetXmlBiblio |
83 |
&GetCOinSBiblio |
83 |
&GetCOinSBiblio |
84 |
&GetMarcPrice |
84 |
&GetMarcPrice |
|
|
85 |
&MungeMarcPrice |
85 |
&GetMarcQuantity |
86 |
&GetMarcQuantity |
86 |
|
87 |
|
87 |
&GetAuthorisedValueDesc |
88 |
&GetAuthorisedValueDesc |
Lines 1382-1393
sub GetMarcPrice {
Link Here
|
1382 |
for my $field ( $record->field(@listtags) ) { |
1383 |
for my $field ( $record->field(@listtags) ) { |
1383 |
for my $subfield_value ($field->subfield($subfield)){ |
1384 |
for my $subfield_value ($field->subfield($subfield)){ |
1384 |
#check value |
1385 |
#check value |
|
|
1386 |
$subfield_value = MungeMarcPrice( $subfield_value ); |
1385 |
return $subfield_value if ($subfield_value); |
1387 |
return $subfield_value if ($subfield_value); |
1386 |
} |
1388 |
} |
1387 |
} |
1389 |
} |
1388 |
return 0; # no price found |
1390 |
return 0; # no price found |
1389 |
} |
1391 |
} |
1390 |
|
1392 |
|
|
|
1393 |
=head2 MungeMarcPrice |
1394 |
|
1395 |
Return the best guess at what the actual price is from a price field. |
1396 |
=cut |
1397 |
|
1398 |
sub MungeMarcPrice { |
1399 |
my ( $price ) = @_; |
1400 |
|
1401 |
return unless ( $price =~ m/\d/ ); ## No digits means no price. |
1402 |
|
1403 |
## Look for the currency symbol of the active currency, if it's there, |
1404 |
## start the price string right after the symbol. This allows us to prefer |
1405 |
## this native currency price over other currency prices, if possible. |
1406 |
my $active_currency = C4::Context->dbh->selectrow_hashref( 'SELECT * FROM currency WHERE active = 1', {} ); |
1407 |
my $symbol = quotemeta( $active_currency->{'symbol'} ); |
1408 |
if ( $price =~ m/$symbol/ ) { |
1409 |
my @parts = split(/$symbol/, $price ); |
1410 |
$price = $parts[1]; |
1411 |
} |
1412 |
|
1413 |
## Grab the first number in the string ( can use commas or periods for thousands separator and/or decimal separator ) |
1414 |
( $price ) = $price =~ m/([\d\,\.]+[[\,\.]\d\d]?)/; |
1415 |
|
1416 |
## Split price into array on periods and commas |
1417 |
my @parts = split(/[\,\.]/, $price); |
1418 |
|
1419 |
## If the last grouping of digits is more than 2 characters, assume there is no decimal value and put it back. |
1420 |
my $decimal = pop( @parts ); |
1421 |
if ( length( $decimal ) > 2 ) { |
1422 |
push( @parts, $decimal ); |
1423 |
$decimal = ''; |
1424 |
} |
1425 |
|
1426 |
$price = join('', @parts ); |
1427 |
|
1428 |
if ( $decimal ) { |
1429 |
$price .= ".$decimal"; |
1430 |
} |
1431 |
|
1432 |
return $price; |
1433 |
} |
1434 |
|
1435 |
|
1391 |
=head2 GetMarcQuantity |
1436 |
=head2 GetMarcQuantity |
1392 |
|
1437 |
|
1393 |
return the quantity of a book. Used in acquisition only, when importing a file an iso2709 from a bookseller |
1438 |
return the quantity of a book. Used in acquisition only, when importing a file an iso2709 from a bookseller |