From 94802c79cda890c12128a83bc931cb342aed470c Mon Sep 17 00:00:00 2001 From: Bernd Blessmann Date: Fri, 6 Jan 2012 12:00:06 +0100 Subject: [PATCH] =?utf8?q?Fix=20f=C3=BCr=20Bug=201759:=20(Verbesserung)=20?= =?utf8?q?W=C3=A4hrung=20bei=20Kunden=20/=20Lieferanten=20vorbelegen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Für Kunden und Lieferanten kann jetzt in den Stammdaten eine Währung eingestellt werden, die als Voreinstellung in den Ver- und Einkaufs- Masken dient. --- SL/CT.pm | 11 +++++++++-- SL/Form.pm | 6 ++++++ SL/IR.pm | 13 +++++++++++-- SL/IS.pm | 14 ++++++++++++-- bin/mozilla/ct.pl | 11 +++++++++-- bin/mozilla/io.pl | 2 ++ bin/mozilla/oe.pl | 3 ++- doc/changelog | 5 +++++ templates/webpages/ct/form_header.html | 4 ++++ 9 files changed, 60 insertions(+), 9 deletions(-) diff --git a/SL/CT.pm b/SL/CT.pm index 24bce2807..3be8ce94f 100644 --- a/SL/CT.pm +++ b/SL/CT.pm @@ -69,6 +69,9 @@ sub get_tuple { map { $form->{$_} = $ref->{$_} } keys %$ref; + # remove any trailing whitespace + $form->{curr} =~ s/\s*$//; + $sth->finish; if ( $form->{salesman_id} ) { my $query = @@ -315,7 +318,8 @@ sub save_customer { qq|taxzone_id = ?, | . qq|user_password = ?, | . qq|c_vendor_id = ?, | . - qq|klass = ? | . + qq|klass = ?, | . + qq|curr = ? | . qq|WHERE id = ?|; my @values = ( $form->{customernumber}, @@ -357,6 +361,7 @@ sub save_customer { $form->{user_password}, $form->{c_vendor_id}, conv_i($form->{klass}), + substr($form->{currency}, 0, 3), $form->{id} ); do_query( $form, $dbh, $query, @values ); @@ -524,7 +529,8 @@ sub save_vendor { qq| language_id = ?, | . qq| username = ?, | . qq| user_password = ?, | . - qq| v_customer_id = ? | . + qq| v_customer_id = ?, | . + qq| curr = ? | . qq|WHERE id = ?|; my @values = ( $form->{vendornumber}, @@ -564,6 +570,7 @@ sub save_vendor { $form->{username}, $form->{user_password}, $form->{v_customer_id}, + substr($form->{currency}, 0, 3), $form->{id} ); do_query($form, $dbh, $query, @values); diff --git a/SL/Form.pm b/SL/Form.pm index f873458e7..38d87ad01 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -2890,12 +2890,14 @@ sub lastname_used { "a.department_id" => "department_id", "d.description" => "department", "ct.name" => $table, + "ct.curr" => "cv_curr", "current_date + ct.terms" => "duedate", ); if ($self->{type} =~ /delivery_order/) { $arap = 'delivery_orders'; delete $column_map{"a.curr"}; + delete $column_map{"ct.curr"}; } elsif ($self->{type} =~ /_order/) { $arap = 'oe'; @@ -2931,6 +2933,10 @@ sub lastname_used { # remove any trailing whitespace $self->{currency} =~ s/\s*$// if $self->{currency}; + $self->{cv_curr} =~ s/\s*$// if $self->{cv_curr}; + + # if customer/vendor currency is set use this + $self->{currency} = $self->{cv_curr} if $self->{cv_curr}; $main::lxdebug->leave_sub(); } diff --git a/SL/IR.pm b/SL/IR.pm index 2c46e8f61..3b7f415f4 100644 --- a/SL/IR.pm +++ b/SL/IR.pm @@ -997,7 +997,7 @@ sub get_vendor { v.id AS vendor_id, v.name AS vendor, v.discount as vendor_discount, v.creditlimit, v.terms, v.notes AS intnotes, v.email, v.cc, v.bcc, v.language_id, v.payment_id, - v.street, v.zipcode, v.city, v.country, v.taxzone_id, + v.street, v.zipcode, v.city, v.country, v.taxzone_id, v.curr, $duedate + COALESCE(pt.terms_netto, 0) AS duedate, b.description AS business FROM vendor v @@ -1007,6 +1007,12 @@ sub get_vendor { my $ref = selectfirst_hashref_query($form, $dbh, $query, @values); map { $params->{$_} = $ref->{$_} } keys %$ref; + # remove any trailing whitespace + $form->{curr} =~ s/\s*$//; + + # use vendor currency if not empty + $form->{currency} = $form->{curr} if $form->{curr}; + $params->{creditremaining} = $params->{creditlimit}; $query = qq|SELECT SUM(amount - paid) FROM ap WHERE vendor_id = ?|; @@ -1289,7 +1295,8 @@ sub vendor_details { # get rest for the vendor # fax and phone and email as vendor* my $query = - qq|SELECT ct.*, cp.*, ct.notes as vendornotes, phone as vendorphone, fax as vendorfax, email as vendoremail + qq|SELECT ct.*, cp.*, ct.notes as vendornotes, phone as vendorphone, fax as vendorfax, email as vendoremail, + ct.curr AS currency FROM vendor ct LEFT JOIN contacts cp ON (ct.id = cp.cp_cv_id) WHERE (ct.id = ?) $contact @@ -1308,6 +1315,8 @@ sub vendor_details { } map { $form->{$_} = $ref->{$_} } keys %$ref; + # remove any trailing whitespace + $form->{currency} =~ s/\s*$// if ($form->{currency}); my $custom_variables = CVar->get_custom_variables('dbh' => $dbh, 'module' => 'CT', diff --git a/SL/IS.pm b/SL/IS.pm index 3aa0d3ca9..22c25c7ad 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -450,7 +450,8 @@ sub customer_details { # get rest for the customer my $query = qq|SELECT ct.*, cp.*, ct.notes as customernotes, - ct.phone AS customerphone, ct.fax AS customerfax, ct.email AS customeremail + ct.phone AS customerphone, ct.fax AS customerfax, ct.email AS customeremail, + ct.curr AS currency FROM customer ct LEFT JOIN contacts cp on ct.id = cp.cp_cv_id WHERE (ct.id = ?) $where @@ -470,6 +471,9 @@ sub customer_details { map { $form->{$_} = $ref->{$_} } keys %$ref; + # remove any trailing whitespace + $form->{currency} =~ s/\s*$// if ($form->{currency}); + if ($form->{delivery_customer_id}) { $query = qq|SELECT *, notes as customernotes @@ -1647,7 +1651,7 @@ sub get_customer { c.id AS customer_id, c.name AS customer, c.discount as customer_discount, c.creditlimit, c.terms, c.email, c.cc, c.bcc, c.language_id, c.payment_id, c.street, c.zipcode, c.city, c.country, - c.notes AS intnotes, c.klass as customer_klass, c.taxzone_id, c.salesman_id, + c.notes AS intnotes, c.klass as customer_klass, c.taxzone_id, c.salesman_id, c.curr, $duedate + COALESCE(pt.terms_netto, 0) AS duedate, b.discount AS tradediscount, b.description AS business FROM customer c @@ -1661,6 +1665,12 @@ sub get_customer { map { $form->{$_} = $ref->{$_} } keys %$ref; + # remove any trailing whitespace + $form->{curr} =~ s/\s*$//; + + # use customer currency if not empty + $form->{currency} = $form->{curr} if $form->{curr}; + $query = qq|SELECT sum(amount - paid) AS dunning_amount FROM ar diff --git a/bin/mozilla/ct.pl b/bin/mozilla/ct.pl index 33b0c8332..de0a43659 100644 --- a/bin/mozilla/ct.pl +++ b/bin/mozilla/ct.pl @@ -313,8 +313,9 @@ sub form_header { my %myconfig = %main::myconfig; my $locale = $main::locale; - $form->get_lists(employees => "ALL_EMPLOYEES", - taxzones => "ALL_TAXZONES"); + $form->get_lists(employees => "ALL_EMPLOYEES", + taxzones => "ALL_TAXZONES", + currencies => "ALL_CURRENCIES"); $form->get_pricegroup(\%myconfig, { all => 1 }); $form->get_lists(customers => { key => "ALL_SALESMAN_CUSTOMERS", business_is_salesman => 1 }) if $::lx_office_conf{features}->{vertreter}; @@ -345,6 +346,12 @@ sub form_header { } } + if (!$form->{'id'}) { + $form->{'currency'} = $form->get_default_currency(\%myconfig); + } else { + $form->{currency} = $form->{curr}; + } + $form->{CUSTOM_VARIABLES} = CVar->get_custom_variables('module' => 'CT', 'trans_id' => $form->{id}); CVar->render_inputs('variables' => $form->{CUSTOM_VARIABLES}) if (scalar @{ $form->{CUSTOM_VARIABLES} }); diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index 0e10b2212..b42ddde8f 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -1328,12 +1328,14 @@ sub print_form { my $salesman_id_saved = $form->{salesman_id}; my $cp_id_saved = $form->{cp_id}; my $taxzone_id_saved = $form->{taxzone_id}; + my $currency_saved = $form->{currency}; call_sub("$form->{vc}_details") if ($form->{vc}); $form->{language_id} = $language_saved; $form->{payment_id} = $payment_id_saved; $form->{taxzone_id} = $taxzone_id_saved; + $form->{currency} = $currency_saved; $form->{"email"} = $saved_email if ($saved_email); $form->{"cc"} = $saved_cc if ($saved_cc); diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index ac3451db1..59479931f 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -239,7 +239,7 @@ sub order_links { $form->{"$form->{vc}_id"} ||= $form->{"all_$form->{vc}"}->[0]->{id} if $form->{"all_$form->{vc}"}; - $form->backup_vars(qw(payment_id language_id taxzone_id salesman_id taxincluded cp_id intnotes shipto_id)); + $form->backup_vars(qw(payment_id language_id taxzone_id salesman_id taxincluded cp_id intnotes shipto_id currency)); $form->{shipto} = 1 if $form->{id}; # get customer / vendor @@ -247,6 +247,7 @@ sub order_links { IS->get_customer(\%myconfig, \%$form) if $form->{type} =~ /sales_(order|quotation)/; $form->restore_vars(qw(payment_id language_id taxzone_id intnotes cp_id shipto_id)); + $form->restore_vars(qw(currency)) if $form->{id}; $form->restore_vars(qw(taxincluded)) if $form->{id}; $form->restore_vars(qw(salesman_id)) if $editing; $form->{forex} = $form->{exchangerate}; diff --git a/doc/changelog b/doc/changelog index 6dad88e84..7f6515710 100644 --- a/doc/changelog +++ b/doc/changelog @@ -56,12 +56,17 @@ - Häkchen bei der Konto-Konfiguration f. Forderungen u. Verbindlichkeiten als Radio-Buttons. + - Für Kunden und Lieferanten kann jetzt in den Stammdaten eine Währung + eingestellt werden, die als Voreinstellung in den Ver- und Einkaufs- + Masken dient. + Liste gefixter Bugs aus dem Bugtracker: - Bugfix 1640: Buchungen werden falsch zugeordnet, wenn man Konten umkonfiguriert - Bugfix 1753: Benutzerdefinierte Variable f. Waren: bearbeitbar nicht auswählbar - Bugfix 1738: Entwürfe können nicht gelöscht werden + - Bugfix 1759: Währung bei Kunden / Lieferanten vorbelegen 2011-06-15 - Release 2.6.3 diff --git a/templates/webpages/ct/form_header.html b/templates/webpages/ct/form_header.html index 90e1a904e..9671cab24 100644 --- a/templates/webpages/ct/form_header.html +++ b/templates/webpages/ct/form_header.html @@ -213,6 +213,10 @@ [% 'BIC' | $T8 %] + [%- IF ALL_CURRENCIES.size %] + [% 'Currency' | $T8 %] + [% L.select_tag('currency', L.options_for_select(ALL_CURRENCIES, default=currency, with_empty=1)) %] + [%- END %] -- 2.20.1