[Koha-bugs] [Bug 9593] Prices not imported correctly from a staged file

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Wed Feb 13 10:17:42 CET 2013


http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9593

--- Comment #4 from Koha Team Lyon 3 <koha at univ-lyon3.fr> ---
(En réponse au commentaire 3)
> My solution was changing these lines in MungeMarcPrice routine:
> 
> - ( $price ) = $price =~ m/([\d\,\.]+[[\,\.]\d\d]?)/;
> + ( $price ) = $price =~ m/([\d\,\.]+[\,|\.\d\d]?)/;
>      ## Split price into array on periods and commas
>      my @parts = split(/[\,\.]/, $price);
>      ## If the last grouping of digits is more than 2 characters, assume
> there is no decimal value and put it back.
>      my $decimal = pop( @parts );
> - if ( length( $decimal ) > 2 ) {
> + if ((scalar @parts == 0) or ( length( $decimal ) > 2 )) { 
> 
> 
> 
> 
> M. Saby

Bonjour Mathieu

Your solution will not work on prices with such pattern as :

1 000 EUR :
To get it work you must add a space in first alternative here
( $price ) = $price    =~ m/([\d\,\. ]+[\,|\.\d\d]?)/;
and there :
 my @parts = split(/[\,\. ]/, $price);

125 € :
You must delete the first part of the routine until the regular expression (may
be it was implied in what you showed ?).
Otherwise, when the symbol had been entered in mysql symbol field as "active
currency" and is typed after the digit(s), the variable $price in $price =
$parts[1]  will be undef.

£ 10 :
I don't know if it could be frequent but in case, the result will be ".10". To
avoid this, I add a mandatory digit at the beginning of regexp and replace + by
* after the first alternative.

Olivier Crouzet

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.


More information about the Koha-bugs mailing list