Bugzilla – Attachment 15615 Details for
Bug 9593
Prices not imported correctly from a staged file
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 9593 Prices not imported correctly from a staged file
Bug-9593-Prices-not-imported-correctly-from-a-stag.patch (text/plain), 2.82 KB, created by
Mathieu Saby
on 2013-02-22 11:21:47 UTC
(
hide
)
Description:
Bug 9593 Prices not imported correctly from a staged file
Filename:
MIME Type:
Creator:
Mathieu Saby
Created:
2013-02-22 11:21:47 UTC
Size:
2.82 KB
patch
obsolete
>From 2f4c253f5dccd762e1e79155bb9b46549b5403f1 Mon Sep 17 00:00:00 2001 >From: Lyon3 Team <koha@univ-lyon3.fr> >Date: Thu, 21 Feb 2013 15:30:55 +0100 >Subject: [PATCH] Bug 9593 Prices not imported correctly from a staged file >Content-Type: text/plain; charset="utf-8" > >When there's a round price with no decimals after it, >or when the symbol is after the digits, the price is not captured >by regular expression and the variable is not initialized. > >Signed-off-by: Mathieu Saby <mathieu.saby@univ-rennes2.fr> >--- > C4/Biblio.pm | 48 +++++------------------------------------------- > 1 file changed, 5 insertions(+), 43 deletions(-) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index 2c7170c..dc47d53 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -1483,55 +1483,17 @@ sub GetMarcPrice { > for my $field ( $record->field(@listtags) ) { > for my $subfield_value ($field->subfield($subfield)){ > #check value >- $subfield_value = MungeMarcPrice( $subfield_value ); >+ ( $subfield_value ) = $subfield_value =~ m/(\d[\d\,\. ]*\d{0,2})/; >+ # remove comma,dot or space when used as separators from hundreds >+ $subfield_value =~s/[\,\. ](\d{3})/$1/; >+ # convert comma to dot to ensure correct display of decimals if existing >+ $subfield_value =~s/,/./; > return $subfield_value if ($subfield_value); > } > } > return 0; # no price found > } > >-=head2 MungeMarcPrice >- >-Return the best guess at what the actual price is from a price field. >-=cut >- >-sub MungeMarcPrice { >- my ( $price ) = @_; >- >- return unless ( $price =~ m/\d/ ); ## No digits means no price. >- >- ## Look for the currency symbol of the active currency, if it's there, >- ## start the price string right after the symbol. This allows us to prefer >- ## this native currency price over other currency prices, if possible. >- my $active_currency = C4::Context->dbh->selectrow_hashref( 'SELECT * FROM currency WHERE active = 1', {} ); >- my $symbol = quotemeta( $active_currency->{'symbol'} ); >- if ( $price =~ m/$symbol/ ) { >- my @parts = split(/$symbol/, $price ); >- $price = $parts[1]; >- } >- >- ## Grab the first number in the string ( can use commas or periods for thousands separator and/or decimal separator ) >- ( $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 ) { >- push( @parts, $decimal ); >- $decimal = ''; >- } >- >- $price = join('', @parts ); >- >- if ( $decimal ) { >- $price .= ".$decimal"; >- } >- >- return $price; >-} >- > > =head2 GetMarcQuantity > >-- >1.7.9.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 9593
:
15269
|
15270
|
15569
|
15587
|
15615
|
17923
|
17948
|
17949
|
18070
|
18075
|
18265
|
18405
|
18640
|
21274
|
21477
|
22151
|
22541
|
22820
|
23580
|
24086
|
25984
|
26125
|
26127
|
27006
|
27009
|
27123
|
27124
|
27391
|
27392
|
27657
|
27658