From: Sven Schöling Date: Fri, 5 Mar 2010 15:35:37 +0000 (+0100) Subject: Merge branch 'master' of ssh://lx-office/~/lx-office-erp X-Git-Tag: release-2.6.1beta1~12 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=ad73be9c179367f2e85c2297297581ca092738f1;hp=a8b9381eb2372fc3352325aa819935f5fb81c75a;p=kivitendo-erp.git Merge branch 'master' of ssh://lx-office/~/lx-office-erp --- 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/CP.pm b/SL/CP.pm index b7e6241de..f6c8c1a8e 100644 --- a/SL/CP.pm +++ b/SL/CP.pm @@ -160,16 +160,14 @@ sub get_openinvoices { my $buysell = $form->{vc} eq 'customer' ? "buy" : "sell"; my $arap = $form->{arap} eq "ar" ? "ar" : "ap"; - my $curr_null = $form->{curreny} ? '' : ' OR a.curr IS NULL'; # fix: after sql-injection fix, curr is inserted as NULL, before that as '' - my $query = qq|SELECT a.id, a.invnumber, a.transdate, a.amount, a.paid, a.curr | . qq|FROM $arap a | . - qq|WHERE (a.${vc}_id = ?) AND (a.curr = ? $curr_null) AND NOT (a.amount = paid)| . + qq|WHERE (a.${vc}_id = ?) AND (COALESCE(a.curr, '') = ?) AND NOT (a.amount = a.paid)| . qq|ORDER BY a.id|; my $sth = prepare_execute_query($form, $dbh, $query, conv_i($form->{"${vc}_id"}), - $form->{currency}); + "$form->{currency}"); $form->{PR} = []; while (my $ref = $sth->fetchrow_hashref("NAME_lc")) { @@ -182,6 +180,16 @@ sub get_openinvoices { } $sth->finish; + + $query = < ?) + AND (amount <> paid) +SQL + ($form->{openinvoices_other_currencies}) = selectfirst_array_query($form, $dbh, $query, conv_i($form->{"${vc}_id"}), "$form->{currency}"); + $dbh->disconnect; $main::lxdebug->leave_sub(); @@ -363,7 +371,7 @@ sub process_payment { # Hier werden negativen Zahlungseingänge abgefangen # Besser: in Oberfläche schon prüfen # Zahlungsein- und ausgänge sind immer positiv - $dbh->rollback; + $dbh->rollback; $rc = 0; } if ($form->round_amount($paymentamount, 2) == 0) { diff --git a/SL/DO.pm b/SL/DO.pm index 73314bc2e..b5faeae8a 100644 --- a/SL/DO.pm +++ b/SL/DO.pm @@ -280,7 +280,7 @@ sub save { $form->{"lastcost_$i"} *= 1; # set values to 0 if nothing entered - $form->{"discount_$i"} = $form->parse_amount($myconfig, $form->{"discount_$i"}) / 100; + $form->{"discount_$i"} = $form->parse_amount($myconfig, $form->{"discount_$i"}); $form->{"sellprice_$i"} = $form->parse_amount($myconfig, $form->{"sellprice_$i"}); $price_factor = $price_factors{ $form->{"price_factor_id_$i"} } || 1; @@ -295,7 +295,7 @@ sub save { @values = (conv_i($item_id), conv_i($form->{id}), conv_i($form->{"id_$i"}), $form->{"description_$i"}, $form->{"longdescription_$i"}, $form->{"qty_$i"}, $baseqty, - $form->{"sellprice_$i"}, $form->{"discount_$i"}, + $form->{"sellprice_$i"}, $form->{"discount_$i"} / 100, $form->{"unit_$i"}, conv_date($reqdate), conv_i($form->{"project_id_$i"}), $form->{"serialnumber_$i"}, $form->{"ordnumber_$i"}, conv_date($form->{"transdate_$i"}), 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} .= "