From: Moritz Bunkus Date: Fri, 5 Mar 2010 15:23:56 +0000 (+0100) Subject: Nicht mit Wechselkursen arbeiten, wenn keine Währungen konfiguriert sind X-Git-Tag: release-2.6.1beta1~12^2~3 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=bea3f989a3bb5d1b734cf4e606a668213755e2e0;p=kivitendo-erp.git Nicht mit Wechselkursen arbeiten, wenn keine Währungen konfiguriert sind Fix für Bug 1349 --- diff --git a/SL/AP.pm b/SL/AP.pm index c2ed2b5e3..fce222dc0 100644 --- a/SL/AP.pm +++ b/SL/AP.pm @@ -54,6 +54,7 @@ sub post_transaction { my $exchangerate = 0; $form->{defaultcurrency} = $form->get_default_currency($myconfig); + delete $form->{currency} unless $form->{defaultcurrency}; ($null, $form->{department_id}) = split(/--/, $form->{department}); $form->{department_id} *= 1; @@ -587,11 +588,9 @@ sub post_payment { $self->setup_form($form); - ($form->{defaultcurrency}) = selectrow_query($form, $dbh, qq|SELECT curr FROM defaults|); - $form->{defaultcurrency} = (split m/:/, $form->{defaultcurrency})[0]; - $form->{currency} = $form->{defaultcurrency} if ($form->{defaultcurrency} && ($form->{currency} =~ m/^\s*$/)); - - $form->{exchangerate} = $form->format_amount($myconfig, $form->{exchangerate}); + $form->{exchangerate} = $form->format_amount($myconfig, $form->{exchangerate}); + $form->{defaultcurrency} = $form->get_default_currency($myconfig); + delete $form->{currency} unless $form->{defaultcurrency}; # Get the AP accno. $query = diff --git a/SL/AR.pm b/SL/AR.pm index 8cc5ea6d8..df470761c 100644 --- a/SL/AR.pm +++ b/SL/AR.pm @@ -54,6 +54,7 @@ sub post_transaction { my $dbh = $provided_dbh ? $provided_dbh : $form->dbconnect_noauto($myconfig); $form->{defaultcurrency} = $form->get_default_currency($myconfig); + delete $form->{currency} unless $form->{default_currency}; # set exchangerate $form->{exchangerate} = ($form->{currency} eq $form->{defaultcurrency}) ? 1 : @@ -346,11 +347,9 @@ sub post_payment { $self->setup_form($form); - ($form->{defaultcurrency}) = selectrow_query($form, $dbh, qq|SELECT curr FROM defaults|); - $form->{defaultcurrency} = (split m/:/, $form->{defaultcurrency})[0]; - $form->{currency} = $form->{defaultcurrency} if ($form->{defaultcurrency} && ($form->{currency} =~ m/^\s*$/)); - - $form->{exchangerate} = $form->format_amount($myconfig, $form->{exchangerate}); + $form->{exchangerate} = $form->format_amount($myconfig, $form->{exchangerate}); + $form->{defaultcurrency} = $form->get_default_currency($myconfig); + delete $form->{currency} unless $form->{default_currency}; # Get the AR accno (which is normally done by Form::create_links()). $query = diff --git a/SL/Form.pm b/SL/Form.pm index c1cc2abb1..905c629db 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -1738,7 +1738,7 @@ sub check_exchangerate { return $exchangerate; } -sub get_default_currency { +sub get_all_currencies { $main::lxdebug->enter_sub(); my ($self, $myconfig) = @_; @@ -1746,14 +1746,24 @@ sub get_default_currency { my $query = qq|SELECT curr FROM defaults|; - my ($curr) = selectrow_query($self, $dbh, $query); - my ($defaultcurrency) = split m/:/, $curr; + my ($curr) = selectrow_query($self, $dbh, $query); + my @currencies = grep { $_ } map { s/\s//g; $_ } split m/:/, $curr; $main::lxdebug->leave_sub(); - return $defaultcurrency; + return @currencies; } +sub get_default_currency { + $main::lxdebug->enter_sub(); + + my ($self, $myconfig) = @_; + my @currencies = $self->get_all_currencies($myconfig); + + $main::lxdebug->leave_sub(); + + return $currencies[0]; +} sub set_payment_options { $main::lxdebug->enter_sub(); diff --git a/bin/mozilla/ap.pl b/bin/mozilla/ap.pl index fba5ba1b6..62edff23e 100644 --- a/bin/mozilla/ap.pl +++ b/bin/mozilla/ap.pl @@ -156,11 +156,9 @@ sub create_links { $form->{notes} = $form->{intnotes} unless $form->{notes}; # currencies - my @curr = split(/:/, $form->{currencies}); - chomp $curr[0]; - $form->{defaultcurrency} = $curr[0]; + $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); - map { $form->{selectcurrency} .= "