View | Details | Raw Unified | Return to bug 7112
Collapse All | Expand All

(-)a/C4/Biblio.pm (+45 lines)
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
(-)a/acqui/addorderiso2709.pl (-7 / +3 lines)
Lines 203-215 if ($op eq ""){ Link Here
203
            "notes", $cgiparams->{'notes'}, "budget_id", $cgiparams->{'budget_id'},
203
            "notes", $cgiparams->{'notes'}, "budget_id", $cgiparams->{'budget_id'},
204
            "currency",$cgiparams->{'currency'},
204
            "currency",$cgiparams->{'currency'},
205
        );
205
        );
206
        # get the price if there is one.
206
207
        # filter by storing only the 1st number
207
        my $price = GetMarcPrice($marcrecord, C4::Context->preference('marcflavour'));
208
        # we suppose the currency is correct, as we have no possibilities to get it.
208
209
        my $price= GetMarcPrice($marcrecord, C4::Context->preference('marcflavour'));
210
        if ($price){
211
            $price = $num->unformat_number($price);
212
        }
213
        if ($price){
209
        if ($price){
214
            $orderinfo{'listprice'} = $price;
210
            $orderinfo{'listprice'} = $price;
215
            eval {
211
            eval {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt (-5 / +5 lines)
Lines 269-274 Link Here
269
                    <td>&nbsp;</td>
269
                    <td>&nbsp;</td>
270
                    <td>[% qty_total %]</td>
270
                    <td>[% qty_total %]</td>
271
                    <td>[% total_est_gsti %]</td>
271
                    <td>[% total_est_gsti %]</td>
272
                    <td colspan="3">&nbsp;</td>
272
                </tr>
273
                </tr>
273
                [% END %]
274
                [% END %]
274
                </tfoot>
275
                </tfoot>
Lines 291-300 Link Here
291
                                    [% IF ( books_loo.editionstatement ) %], [% books_loo.editionstatement %][% END %]
292
                                    [% IF ( books_loo.editionstatement ) %], [% books_loo.editionstatement %][% END %]
292
                            </p>
293
                            </p>
293
                            </td>
294
                            </td>
294
                        <td class="number">[% books_loo.rrp %]</td>
295
                        <td class="number [% IF books_loo.rrp.search('^0') %]error[% END %]">[% books_loo.rrp %]</td>
295
                        <td class="number">[% books_loo.ecost %]</td>
296
                        <td class="number [% IF books_loo.ecost.search('^0') %]error[% END %]">[% books_loo.ecost %]</td>
296
                        <td class="number">[% books_loo.quantity %]</td>
297
                        <td class="number [% IF books_loo.quantity.search('^0') %]error[% END %]">[% books_loo.quantity %]</td>
297
                        <td class="number">[% books_loo.line_total %]</td>
298
                        <td class="number [% IF books_loo.line_total.search('^0') %]error[% END %]">[% books_loo.line_total %]</td>
298
                        <td>[% books_loo.budget_name %]</td>
299
                        <td>[% books_loo.budget_name %]</td>
299
                        [% IF ( active ) %]
300
                        [% IF ( active ) %]
300
                            [% UNLESS ( closedate ) %]
301
                            [% UNLESS ( closedate ) %]
301
- 

Return to bug 7112