From e82db1a7b5f8cfce019012e60a689c9142851a63 Mon Sep 17 00:00:00 2001 From: Niclas Zimmermann Date: Mon, 22 Apr 2013 18:45:56 +0200 Subject: [PATCH] Filtert Steuern bei Dialogbuchungen MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Bei Dialogbuchungen kam es in der Vergangenheit zu Verwechslungen von Umsatz- und Vorsteuer. Für jedes Konto werden daher nun Steuern nur noch angezeigt, wenn die Steuer so eingestellt ist, dass sie für die Kontoart des ausgewählten Kontos angezeigt wird. Implementiert #2249. --- SL/AM.pm | 19 ++++-- SL/GL.pm | 19 ++++++ bin/mozilla/am.pl | 15 +++++ bin/mozilla/gl.pl | 27 ++++++-- locale/de/all | 1 + templates/webpages/am/edit_tax.html | 66 +++++++++++++++++++ templates/webpages/gl/form_header.html | 46 ++++++++----- .../webpages/gl/update_tax_accounts.html | 3 + 8 files changed, 173 insertions(+), 23 deletions(-) create mode 100644 templates/webpages/gl/update_tax_accounts.html diff --git a/SL/AM.pm b/SL/AM.pm index 502ebd905..0c3c835b3 100644 --- a/SL/AM.pm +++ b/SL/AM.pm @@ -1777,6 +1777,7 @@ sub get_tax { taxdescription, round(rate * 100, 2) AS rate, chart_id, + chart_categories, (id IN (SELECT tax_id FROM acc_trans)) AS tax_already_used FROM tax @@ -1834,14 +1835,23 @@ sub save_tax { $form->{rate} = $form->{rate} / 100; - my @values = ($form->{taxkey}, $form->{taxdescription}, $form->{rate}, $form->{chart_id}, $form->{chart_id} ); + my $chart_categories = ''; + $chart_categories .= 'A' if $form->{asset}; + $chart_categories .= 'L' if $form->{liability}; + $chart_categories .= 'Q' if $form->{equity}; + $chart_categories .= 'I' if $form->{revenue}; + $chart_categories .= 'E' if $form->{expense}; + $chart_categories .= 'C' if $form->{costs}; + + my @values = ($form->{taxkey}, $form->{taxdescription}, $form->{rate}, $form->{chart_id}, $form->{chart_id}, $chart_categories); if ($form->{id} ne "") { $query = qq|UPDATE tax SET taxkey = ?, taxdescription = ?, rate = ?, chart_id = ?, - taxnumber = (SELECT accno FROM chart WHERE id= ? ) + taxnumber = (SELECT accno FROM chart WHERE id= ? ), + chart_categories = ? WHERE id = ?|; push(@values, $form->{id}); @@ -1852,9 +1862,10 @@ sub save_tax { taxdescription, rate, chart_id, - taxnumber + taxnumber, + chart_categories ) - VALUES (?, ?, ?, ?, (SELECT accno FROM chart WHERE id = ?) )|; + VALUES (?, ?, ?, ?, (SELECT accno FROM chart WHERE id = ?), ? )|; } do_query($form, $dbh, $query, @values); diff --git a/SL/GL.pm b/SL/GL.pm index 1fc1f3a42..a42287735 100644 --- a/SL/GL.pm +++ b/SL/GL.pm @@ -801,5 +801,24 @@ sub get_chart_balances { $main::lxdebug->leave_sub(); } +sub get_tax_dropdown { + my $myconfig = \%main::myconfig; + my $form = $main::form; + + my $dbh = $form->get_standard_dbh($myconfig); + + my $query = qq|SELECT category FROM chart WHERE accno = ?|; + my ($category) = selectrow_query($form, $dbh, $query, $form->{accno}); + + $query = qq|SELECT * FROM tax WHERE chart_categories like '%$category%' order by taxkey, rate|; + + my $sth = prepare_execute_query($form, $dbh, $query); + + $form->{TAX_ACCOUNTS} = []; + while (my $ref = $sth->fetchrow_hashref("NAME_lc")) { + push(@{ $form->{TAX_ACCOUNTS} }, $ref); + } + +} 1; diff --git a/bin/mozilla/am.pl b/bin/mozilla/am.pl index 68f8e162b..ebe7ed187 100644 --- a/bin/mozilla/am.pl +++ b/bin/mozilla/am.pl @@ -1461,6 +1461,13 @@ sub add_tax { _get_taxaccount_selection(); + $form->{asset} = 1; + $form->{liability} = 1; + $form->{equity} = 1; + $form->{revenue} = 1; + $form->{expense} = 1; + $form->{costs} = 1; + $form->header(); my $parameters_ref = { @@ -1485,8 +1492,16 @@ sub edit_tax { $form->{title} = $locale->text('Edit'); AM->get_tax(\%myconfig, \%$form); + _get_taxaccount_selection(); + $form->{asset} = $form->{chart_categories} =~ 'A' ? 1 : 0; + $form->{liability} = $form->{chart_categories} =~ 'L' ? 1 : 0; + $form->{equity} = $form->{chart_categories} =~ 'Q' ? 1 : 0; + $form->{revenue} = $form->{chart_categories} =~ 'I' ? 1 : 0; + $form->{expense} = $form->{chart_categories} =~ 'E' ? 1 : 0; + $form->{costs} = $form->{chart_categories} =~ 'C' ? 1 : 0; + $form->{rate} = $form->format_amount(\%myconfig, $form->{rate}, 2); $form->header(); diff --git a/bin/mozilla/gl.pl b/bin/mozilla/gl.pl index 0d9a92b5d..4c97bd028 100644 --- a/bin/mozilla/gl.pl +++ b/bin/mozilla/gl.pl @@ -686,7 +686,7 @@ sub display_rows { my %taxchart_labels = (); my @taxchart_values = (); my %taxcharts = (); - foreach my $item (@{ $form->{ALL_TAXCHARTS} }) { + foreach my $item (@{ $form->{TAX_ACCOUNTS} }) { my $key = $item->{id} . "--" . $item->{rate}; $taxchart_init = $key if ($taxchart_init == $item->{id}); push(@taxchart_values, $key); @@ -730,7 +730,7 @@ sub display_rows { my $accno = qq|| . NTI($cgi->popup_menu('-name' => "accno_$i", '-id' => "accno_$i", - '-onChange' => "setTaxkey($i)", + '-onChange' => "updateTaxes($i);", '-style' => 'width:200px', '-values' => \@chart_values, '-labels' => \%chart_labels, @@ -862,8 +862,10 @@ sub form_header { "all" => 0, "old_id" => \@old_project_ids }, "charts" => { "key" => "ALL_CHARTS", - "transdate" => $::form->{transdate} }, - "taxcharts" => "ALL_TAXCHARTS"); + "transdate" => $::form->{transdate} }); + + $::form->{accno} = $::form->{ALL_CHARTS}[0]->{accno}; + GL->get_tax_dropdown(); GL->get_chart_balances('charts' => $::form->{ALL_CHARTS}); @@ -1219,4 +1221,21 @@ sub continue { call_sub($main::form->{nextsub}); } +sub get_tax_dropdown { + + my $form = $main::form; + $main::lxdebug->enter_sub(); + GL->get_tax_dropdown(); + + foreach my $item (@{ $form->{TAX_ACCOUNTS} }) { + $item->{taxdescription} = $::locale->{iconv_utf8}->convert($item->{taxdescription}); + $item->{taxdescription} .= ' ' . $form->round_amount($item->{rate} * 100); + } + + print $form->ajax_response_header, $form->parse_html_template("gl/update_tax_accounts"); + + $main::lxdebug->leave_sub(); + +} + 1; diff --git a/locale/de/all b/locale/de/all index 823045a14..92518771d 100755 --- a/locale/de/all +++ b/locale/de/all @@ -97,6 +97,7 @@ $self->{texts} = { 'Account Nummer' => 'Kontonummer', 'Account Type' => 'Kontoart', 'Account Type missing!' => 'Kontoart fehlt!', + 'Account categories' => 'Kontoarten', 'Account deleted!' => 'Konto gelöscht!', 'Account for fees' => 'Konto für Gebühren', 'Account for interest' => 'Konto für Zinsen', diff --git a/templates/webpages/am/edit_tax.html b/templates/webpages/am/edit_tax.html index 69ac744ff..f7e7cf9e1 100644 --- a/templates/webpages/am/edit_tax.html +++ b/templates/webpages/am/edit_tax.html @@ -1,5 +1,6 @@ [%- USE T8 %] [%- USE HTML %] +[%- USE L %]
@@ -33,6 +34,71 @@ + [% 'Account categories' | $T8 %] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
[% IF asset %] + [% L.checkbox_tag('asset', value => 1, checked => 1, class => 'checkbox') %] + [% ELSE %] + [% L.checkbox_tag('asset', value => 1, checked => 0, class => 'checkbox') %] + [% END %] + [% 'Asset' | $T8 %] (A)[% IF liability %] + [% L.checkbox_tag('liability', value => 1, checked => 1, class => 'checkbox') %] + [% ELSE %] + [% L.checkbox_tag('liability', value => 1, checked => 0, class => 'checkbox') %] + [% END %] + [% 'Liability' | $T8 %] (L)[% IF equity %] + [% L.checkbox_tag('equity', value => 1, checked => 1, class => 'checkbox') %] + [% ELSE %] + [% L.checkbox_tag('equity', value => 1, checked => 0, class => 'checkbox') %] + [% END %] + [% 'Equity' | $T8 %] (Q)[% IF revenue %] + [% L.checkbox_tag('revenue', value => 1, checked => 1, class => 'checkbox') %] + [% ELSE %] + [% L.checkbox_tag('revenue', value => 1, checked => 0, class => 'checkbox') %] + [% END %] + [% 'Revenue' | $T8 %] (I)[% IF expense %] + [% L.checkbox_tag('expense', value => 1, checked => 1, class => 'checkbox') %] + [% ELSE %] + [% L.checkbox_tag('expense', value => 1, checked => 0, class => 'checkbox') %] + [% END %] + [% 'Expense' | $T8 %] (E)[% IF costs %] + [% L.checkbox_tag('costs', value => 1, checked => 1, class => 'checkbox') %] + [% ELSE %] + [% L.checkbox_tag('costs', value => 1, checked => 0, class => 'checkbox') %] + [% END %] + [% 'Costs' | $T8 %] (C)
+ + + + [% UNLESS orphaned %] diff --git a/templates/webpages/gl/form_header.html b/templates/webpages/gl/form_header.html index 728c80fc7..d73380e3d 100644 --- a/templates/webpages/gl/form_header.html +++ b/templates/webpages/gl/form_header.html @@ -4,22 +4,38 @@ [%- USE L %]