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

(-)a/C4/Biblio.pm (+45 lines)
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
(-)a/acqui/addorderiso2709.pl (-1 / +6 lines)
Lines 207-215 if ($op eq ""){ Link Here
207
        # filter by storing only the 1st number
207
        # filter by storing only the 1st number
208
        # we suppose the currency is correct, as we have no possibilities to get it.
208
        # we suppose the currency is correct, as we have no possibilities to get it.
209
        my $price= GetMarcPrice($marcrecord, C4::Context->preference('marcflavour'));
209
        my $price= GetMarcPrice($marcrecord, C4::Context->preference('marcflavour'));
210
        if ($price){
210
211
        ## unformat_number will choke if there is more than one period (.) in $price
212
        ## MARC standards do not limit this field to a single period, so unless there
213
        ## is only one period, skip number unformatting.
214
        unless ( $price =~ /\..*\./ ) {
211
            $price = $num->unformat_number($price);
215
            $price = $num->unformat_number($price);
212
        }
216
        }
217
213
        if ($price){
218
        if ($price){
214
            $orderinfo{'listprice'} = $price;
219
            $orderinfo{'listprice'} = $price;
215
            eval {
220
            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 285-294 Link Here
285
                                    [% IF ( books_loo.publicationyear ) %], [% books_loo.publicationyear %][% END %]
286
                                    [% IF ( books_loo.publicationyear ) %], [% books_loo.publicationyear %][% END %]
286
                            </p>
287
                            </p>
287
                            </td>
288
                            </td>
288
                        <td class="number">[% books_loo.rrp %]</td>
289
                        <td class="number [% IF books_loo.rrp.search('^0') %]error[% END %]">[% books_loo.rrp %]</td>
289
                        <td class="number">[% books_loo.ecost %]</td>
290
                        <td class="number [% IF books_loo.ecost.search('^0') %]error[% END %]">[% books_loo.ecost %]</td>
290
                        <td class="number">[% books_loo.quantity %]</td>
291
                        <td class="number [% IF books_loo.quantity.search('^0') %]error[% END %]">[% books_loo.quantity %]</td>
291
                        <td class="number">[% books_loo.line_total %]</td>
292
                        <td class="number [% IF books_loo.line_total.search('^0') %]error[% END %]">[% books_loo.line_total %]</td>
292
                        <td>[% books_loo.budget_name %]</td>
293
                        <td>[% books_loo.budget_name %]</td>
293
                        [% IF ( active ) %]
294
                        [% IF ( active ) %]
294
                            [% UNLESS ( closedate ) %]
295
                            [% UNLESS ( closedate ) %]
295
- 

Return to bug 7112