Bug 5466 On new orders get currency from vendor

Previous patch for this bug was ignoring vendor currency on
new orders. In most cases should be the default

Changed variable name from cur to active_currency
Clarity is a virtue!

Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
This commit is contained in:
Colin Campbell 2011-03-18 17:11:02 +01:00 committed by Chris Cormack
parent 589aac1540
commit 5f9bd8a01e
1 changed files with 26 additions and 11 deletions

View File

@ -173,7 +173,6 @@ if ( $ordernumber eq '' and defined $params->{'breedingid'}){
}
my $cur = GetCurrency();
if ( $ordernumber eq '' ) { # create order
$new = 'yes';
@ -201,18 +200,35 @@ else { #modify order
}
# get currencies (for change rates calcs if needed)
my $active_currency = GetCurrency();
my $default_currency;
if (! $data->{currency} ) { # New order no currency set
if ( $bookseller->{listprice} ) {
$default_currency = $bookseller->{listprice};
}
else {
$default_currency = $active_currency->{currency};
}
}
my @rates = GetCurrencies();
my $count = scalar @rates;
# ## @rates
my @loop_currency = ();
for ( my $i = 0 ; $i < $count ; $i++ ) {
my %line;
$line{currcode} = $rates[$i]->{'currency'};
$line{rate} = $rates[$i]->{'rate'};
$line{selected} = 1 if ($line{currcode} eq $data->{currency});
push @loop_currency, \%line;
for my $curr ( @rates ) {
my $selected;
if ($data->{currency} ) {
$selected = $curr->{currency} eq $data->{currency};
}
else {
$selected = $curr->{currency} eq $default_currency;
}
push @loop_currency, {
currcode => $curr->{currency},
rate => $curr->{rate},
selected => $selected,
}
}
# build branches list
@ -341,9 +357,8 @@ $template->param(
listincgst => $bookseller->{'listincgst'},
invoiceincgst => $bookseller->{'invoiceincgst'},
name => $bookseller->{'name'},
cur_active_sym => $cur->{'symbol'},
cur_active => $cur->{'currency'},
# currency => $bookseller->{'listprice'} || $cur->{'currency'}, # eg: 'EUR'
cur_active_sym => $active_currency->{'symbol'},
cur_active => $active_currency->{'currency'},
loop_currencies => \@loop_currency,
orderexists => ( $new eq 'yes' ) ? 0 : 1,
title => $data->{'title'},