Lines 84-89
BEGIN {
Link Here
|
84 |
&GetXmlBiblio |
84 |
&GetXmlBiblio |
85 |
&GetCOinSBiblio |
85 |
&GetCOinSBiblio |
86 |
&GetMarcPrice |
86 |
&GetMarcPrice |
|
|
87 |
&MungeMarcPrice |
87 |
&GetMarcQuantity |
88 |
&GetMarcQuantity |
88 |
|
89 |
|
89 |
&GetAuthorisedValueDesc |
90 |
&GetAuthorisedValueDesc |
Lines 1279-1290
sub GetMarcPrice {
Link Here
|
1279 |
for my $field ( $record->field(@listtags) ) { |
1280 |
for my $field ( $record->field(@listtags) ) { |
1280 |
for my $subfield_value ($field->subfield($subfield)){ |
1281 |
for my $subfield_value ($field->subfield($subfield)){ |
1281 |
#check value |
1282 |
#check value |
|
|
1283 |
$subfield_value = MungeMarcPrice( $subfield_value ); |
1282 |
return $subfield_value if ($subfield_value); |
1284 |
return $subfield_value if ($subfield_value); |
1283 |
} |
1285 |
} |
1284 |
} |
1286 |
} |
1285 |
return 0; # no price found |
1287 |
return 0; # no price found |
1286 |
} |
1288 |
} |
1287 |
|
1289 |
|
|
|
1290 |
=head2 MungeMarcPrice |
1291 |
|
1292 |
Return the best guess at what the actual price is from a price field. |
1293 |
=cut |
1294 |
|
1295 |
sub MungeMarcPrice { |
1296 |
my ( $price ) = @_; |
1297 |
|
1298 |
return unless ( $price =~ m/\d/ ); ## No digits means no price. |
1299 |
|
1300 |
## Look for the currency symbol of the active currency, if it's there, |
1301 |
## start the price string right after the symbol. This allows us to prefer |
1302 |
## this native currency price over other currency prices, if possible. |
1303 |
my $active_currency = C4::Context->dbh->selectrow_hashref( 'SELECT * FROM currency WHERE active = 1', {} ); |
1304 |
my $symbol = quotemeta( $active_currency->{'symbol'} ); |
1305 |
if ( $price =~ m/$symbol/ ) { |
1306 |
my @parts = split(/$symbol/, $price ); |
1307 |
$price = $parts[1]; |
1308 |
} |
1309 |
|
1310 |
## Grab the first number in the string ( can use commas or periods for thousands separator and/or decimal separator ) |
1311 |
( $price ) = $price =~ m/([\d\,\.]+[[\,\.]\d\d]?)/; |
1312 |
|
1313 |
## Split price into array on periods and commas |
1314 |
my @parts = split(/[\,\.]/, $price); |
1315 |
|
1316 |
## If the last grouping of digits is more than 2 characters, assume there is no decimal value and put it back. |
1317 |
my $decimal = pop( @parts ); |
1318 |
if ( length( $decimal ) > 2 ) { |
1319 |
push( @parts, $decimal ); |
1320 |
$decimal = ''; |
1321 |
} |
1322 |
|
1323 |
$price = join('', @parts ); |
1324 |
|
1325 |
if ( $decimal ) { |
1326 |
$price .= ".$decimal"; |
1327 |
} |
1328 |
|
1329 |
return $price; |
1330 |
} |
1331 |
|
1332 |
|
1288 |
=head2 GetMarcQuantity |
1333 |
=head2 GetMarcQuantity |
1289 |
|
1334 |
|
1290 |
return the quantity of a book. Used in acquisition only, when importing a file an iso2709 from a bookseller |
1335 |
return the quantity of a book. Used in acquisition only, when importing a file an iso2709 from a bookseller |