From 4dbf683ed9d849c9fb1df421f72c8e73a5342d37 Mon Sep 17 00:00:00 2001
From: Kyle M Hall
Date: Wed, 8 Feb 2012 12:16:20 -0500
Subject: [PATCH] Bug 7112 - Having two prices in 020$c causes basket creation to fail from staged marc import
The root problem here is that the price is being pulled from the MARC record
and is then run through Number::Format::unformat_number. This routine is
really being misused, and should only be used to reverse the effects of
Number::Format on a number string. We are apparently using it to strip
out currency characters and the like.
Number::Format::unformat_number will choke if there is more than one period (.)
in the price field. MARC standards do not limit this field to a single period,
so unless there is only one period, we should skip number unformatting.
Examples of that break unformat_number include '18.95 (U.S.)', and
'$5.99 ($7.75 CAN)', both of which are perfectly valid.
This commit tests to see of $price contains more than one period,
if it does have multiple periods, it will skip running the string
though number_unformat.
The variable $price may fail to have an actual price, in which case
the price then defauls to '0.00', which would be rarely if ever the
correct price. To combat this, I have added highlighting to any
price in the Order Details table that begins with 0 ( i.e. '0.00' ).
Also, fixed the incomplete table footer, adding a new td with a
span of 3 to fill in the nonexistant cells.
---
acqui/addorderiso2709.pl | 7 ++++++-
.../intranet-tmpl/prog/en/modules/acqui/basket.tt | 9 +++++----
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/acqui/addorderiso2709.pl b/acqui/addorderiso2709.pl
index bbfd3b7..feabc39 100755
--- a/acqui/addorderiso2709.pl
+++ b/acqui/addorderiso2709.pl
@@ -207,9 +207,14 @@ if ($op eq ""){
# filter by storing only the 1st number
# we suppose the currency is correct, as we have no possibilities to get it.
my $price= GetMarcPrice($marcrecord, C4::Context->preference('marcflavour'));
- if ($price){
+
+ ## unformat_number will choke if there is more than one period (.) in $price
+ ## MARC standards do not limit this field to a single period, so unless there
+ ## is only one period, skip number unformatting.
+ unless ( $price =~ /\..*\./ ) {
$price = $num->unformat_number($price);
}
+
if ($price){
$orderinfo{'listprice'} = $price;
eval {
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt
index aaea6c0..85e0ac6 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt
@@ -269,6 +269,7 @@
|
[% qty_total %] |
[% total_est_gsti %] |
+ |
[% END %]
@@ -285,10 +286,10 @@
[% IF ( books_loo.publicationyear ) %], [% books_loo.publicationyear %][% END %]
- [% books_loo.rrp %] |
- [% books_loo.ecost %] |
- [% books_loo.quantity %] |
- [% books_loo.line_total %] |
+ [% books_loo.rrp %] |
+ [% books_loo.ecost %] |
+ [% books_loo.quantity %] |
+ [% books_loo.line_total %] |
[% books_loo.budget_name %] |
[% IF ( active ) %]
[% UNLESS ( closedate ) %]
--
1.7.2.5