From 6e6038682b1a2b6e6bc74f1eee40eba21afcb7e9 Mon Sep 17 00:00:00 2001 From: "G. Richardson" Date: Wed, 30 Jul 2014 20:38:28 +0200 Subject: [PATCH] =?utf8?q?Steuerzonen=20ung=C3=BCltig=20machen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit jede Steuerzone kann man unter "System->Steuerzonen->auf Steuerzone klicken" individuell auf ungültig (obsolete) setzen. ungültig heißt: * Steuerzone erscheint nicht in der großen Buchungsgruppenübersicht * Steuerzone erscheint nicht im Drop-Down Menü für Steuerzonen bei neuen Belegen (Angebot-Rechnung) Bei alten Belegen, die erneut geöffnet werden, ist leider das Verhalten unterschiedlich: * bei schon gebuchten EK/VK-Rechnungen (id) ist das Drop-Down ausgegraut und disabled und es wird nur die ausgewählte Steuerzone angezeigt -> funktioniert * bei schon gebuchten Angeboten/Aufträgen müssen immer alle Steuerzonen angezeigt werden, da man die Steuerzone auch im Nachhinein ändern kann, aber auch alle alten Belege mit mittlerweile ungültigen Steuerzonen korrekt angezeigt werden müssen. Man kann also nicht einfach nach id fragen und entsprechend nach ungültig filtern. Bucht man also einen Auftrag mit einer bestimmten Steuerzone, setzt die Steuerzone auf ungültig, und generiert dann aus dem Auftrag z.B. eine Rechnung, würde die Steuerzone aus dem Auftrag nicht übernommen werden, sondern die erste Steuerzone aus der Liste standardmäßig ausgewählt sein. --- SL/Controller/Buchungsgruppen.pm | 13 ++++++++++--- SL/Controller/Taxzones.pm | 3 ++- SL/DB/MetaSetup/TaxZone.pm | 1 + SL/Form.pm | 4 +++- bin/mozilla/is.pl | 2 +- bin/mozilla/oe.pl | 3 +-- sql/Pg-upgrade2/tax_zones_obsolete.sql | 4 ++++ templates/webpages/buchungsgruppen/form.html | 6 +++--- templates/webpages/is/form_header.html | 2 +- templates/webpages/oe/form_header.html | 2 +- templates/webpages/taxzones/form.html | 2 ++ 11 files changed, 29 insertions(+), 13 deletions(-) create mode 100644 sql/Pg-upgrade2/tax_zones_obsolete.sql diff --git a/SL/Controller/Buchungsgruppen.pm b/SL/Controller/Buchungsgruppen.pm index bbb589383..f3f07d58a 100644 --- a/SL/Controller/Buchungsgruppen.pm +++ b/SL/Controller/Buchungsgruppen.pm @@ -25,7 +25,7 @@ sub action_list { my ($self) = @_; my $buchungsgruppen = SL::DB::Manager::Buchungsgruppe->get_all_sorted(); - my $taxzones = SL::DB::Manager::TaxZone->get_all_sorted(); + my $taxzones = SL::DB::Manager::TaxZone->get_all_sorted(query => [ obsolete => 0 ]); my %chartlist = (); foreach my $gruppe (@{ $buchungsgruppen }) { @@ -59,7 +59,11 @@ sub show_form { sub action_edit { my ($self) = @_; + # check whether buchungsgruppe is assigned to any parts + my $number_of_parts_with_buchungsgruppe = SL::DB::Manager::Part->get_objects_count(where => [ buchungsgruppen_id => $self->config->id]); + $self->show_form(title => t8('Edit Buchungsgruppe'), + linked_parts => $number_of_parts_with_buchungsgruppe, CHARTLIST => SL::DB::TaxzoneChart->get_all_accounts_by_buchungsgruppen_id($self->config->id)); } @@ -120,8 +124,11 @@ sub create_or_update { $self->config->save; - #Save taxzone_charts: - if ($is_new) { + # check whether there are any assigned parts + my $number_of_parts_with_buchungsgruppe = SL::DB::Manager::Part->get_objects_count(where => [ buchungsgruppen_id => $self->config->id]); + + # Save or update taxzone_charts: + if ($is_new or $number_of_parts_with_buchungsgruppe == 0) { my $taxzones = SL::DB::Manager::TaxZone->get_all_sorted(); foreach my $tz (@{ $taxzones }) { diff --git a/SL/Controller/Taxzones.pm b/SL/Controller/Taxzones.pm index 5f19ea6d3..9bdf3553b 100644 --- a/SL/Controller/Taxzones.pm +++ b/SL/Controller/Taxzones.pm @@ -54,7 +54,7 @@ sub show_form { sub action_edit { my ($self) = @_; - $self->show_form(title => t8('Edit custom variable'), + $self->show_form(title => t8('Edit taxzone'), CHARTLIST => SL::DB::TaxzoneChart->get_all_accounts_by_taxzone_id($self->config->id)); } @@ -115,6 +115,7 @@ sub create_or_update { } $self->config->save; + $self->config->obsolete($::form->{"obsolete"}); #Save taxzone_charts for new taxzones: if ($is_new) { diff --git a/SL/DB/MetaSetup/TaxZone.pm b/SL/DB/MetaSetup/TaxZone.pm index 993d28f88..5529d8924 100644 --- a/SL/DB/MetaSetup/TaxZone.pm +++ b/SL/DB/MetaSetup/TaxZone.pm @@ -11,6 +11,7 @@ __PACKAGE__->meta->table('tax_zones'); __PACKAGE__->meta->columns( description => { type => 'text' }, id => { type => 'integer', not_null => 1, sequence => 'id' }, + obsolete => { type => 'boolean', default => 'false' }, sortkey => { type => 'integer', not_null => 1 }, ); diff --git a/SL/Form.pm b/SL/Form.pm index b3138ac26..a36ffd5df 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -2145,8 +2145,10 @@ sub _get_taxzones { my ($self, $dbh, $key) = @_; $key = "all_taxzones" unless ($key); + my $tzfilter = ""; + $tzfilter = "WHERE obsolete is FALSE" if $key eq 'ALL_ACTIVE_TAXZONES'; - my $query = qq|SELECT * FROM tax_zones ORDER BY sortkey|; + my $query = qq|SELECT * FROM tax_zones $tzfilter ORDER BY sortkey|; $self->{$key} = selectall_hashref_query($self, $dbh, $query); diff --git a/bin/mozilla/is.pl b/bin/mozilla/is.pl index b6c6298a0..35b08b947 100644 --- a/bin/mozilla/is.pl +++ b/bin/mozilla/is.pl @@ -305,7 +305,7 @@ sub form_header { $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); - $form->get_lists("taxzones" => "ALL_TAXZONES", + $form->get_lists("taxzones" => ($form->{id} ? "ALL_TAXZONES" : "ALL_ACTIVE_TAXZONES"), "currencies" => "ALL_CURRENCIES", "customers" => "ALL_CUSTOMERS", "departments" => "all_departments", diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index 9a8aea41e..fb3a7ff50 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -350,8 +350,7 @@ sub form_header { my $vc = $form->{vc} eq "customer" ? "customers" : "vendors"; - # project ids - $form->get_lists("taxzones" => "ALL_TAXZONES", + $form->get_lists("taxzones" => ($form->{id} ? "ALL_TAXZONES" : "ALL_ACTIVE_TAXZONES"), "payments" => "ALL_PAYMENTS", "currencies" => "ALL_CURRENCIES", "departments" => "ALL_DEPARTMENTS", diff --git a/sql/Pg-upgrade2/tax_zones_obsolete.sql b/sql/Pg-upgrade2/tax_zones_obsolete.sql new file mode 100644 index 000000000..c6891a29d --- /dev/null +++ b/sql/Pg-upgrade2/tax_zones_obsolete.sql @@ -0,0 +1,4 @@ +-- @tag: tax_zones_obsolete +-- @description: Steuerzonen auf ungültig setzen können +-- @depends: change_taxzone_id_0 +ALTER TABLE tax_zones ADD COLUMN obsolete boolean DEFAULT FALSE; diff --git a/templates/webpages/buchungsgruppen/form.html b/templates/webpages/buchungsgruppen/form.html index 5dad157db..88c19f320 100644 --- a/templates/webpages/buchungsgruppen/form.html +++ b/templates/webpages/buchungsgruppen/form.html @@ -10,7 +10,7 @@ [% 'Inventory account' | $T8 %] - [%- IF SELF.config.id %] + [%- IF SELF.config.id AND linked_parts != 0 %] [%- CHARTLIST.inventory_accno %] -- [%- CHARTLIST.inventory_accno_description %] [%- ELSE %] [%- L.select_tag("config.inventory_accno_id", ACCOUNTS.ic, title_sub=\account_label, default=SELF.config.inventory_accno_id) %] @@ -19,7 +19,7 @@ [%- FOREACH tz = TAXZONES %] [% 'Revenue' | $T8 %] [% HTML.escape(tz.description) %] - [%- IF SELF.config.id %] + [%- IF SELF.config.id AND linked_parts != 0 %] [% CHARTLIST.${tz.id}.income_accno %] -- [% CHARTLIST.${tz.id}.income_accno_description %] [%- ELSE %] [%- L.select_tag('income_accno_id_' _ tz.id, ACCOUNTS.ic_income, title_sub=\account_label, default=CHARTLIST.${tz.id}.income_accno_id) %] @@ -27,7 +27,7 @@ [% 'Expense' | $T8 %] [% HTML.escape(tz.description) %] - [%- IF SELF.config.id %] + [%- IF SELF.config.id AND linked_parts != 0 %] [% CHARTLIST.${tz.id}.expense_accno %] -- [% CHARTLIST.${tz.id}.expense_accno_description %] [%- ELSE %] [%- L.select_tag('expense_accno_id_' _ tz.id, ACCOUNTS.ic_expense, title_sub=\account_label, default=CHARTLIST.${tz.id}.expense_accno_id) %] diff --git a/templates/webpages/is/form_header.html b/templates/webpages/is/form_header.html index 5fa5bb105..0d4a255be 100644 --- a/templates/webpages/is/form_header.html +++ b/templates/webpages/is/form_header.html @@ -113,7 +113,7 @@ [% 'Steuersatz' | $T8 %] - [% L.select_tag('taxzone_id', ALL_TAXZONES, default = taxzone_id, title_key = 'description', disabled = (id ? 1 : 0), style='width: 250px', onchange = "document.getElementById('update_button').click();") %] + [% L.select_tag('taxzone_id', ( id ? ALL_TAXZONES : ALL_ACTIVE_TAXZONES) , default = taxzone_id, title_key = 'description', disabled = (id ? 1 : 0), style='width: 250px', onchange = "document.getElementById('update_button').click();") %] [%- IF id %] [%- END %] diff --git a/templates/webpages/oe/form_header.html b/templates/webpages/oe/form_header.html index e01734932..644879c1b 100644 --- a/templates/webpages/oe/form_header.html +++ b/templates/webpages/oe/form_header.html @@ -108,7 +108,7 @@ [% 'Steuersatz' | $T8 %] - [% L.select_tag('taxzone_id', ALL_TAXZONES, default=taxzone_id, title_key='description', style='width: 250px') %] + [% L.select_tag('taxzone_id', ( id ? ALL_TAXZONES : ALL_ACTIVE_TAXZONES), default=taxzone_id, title_key='description', style='width: 250px') %] [%- IF ALL_DEPARTMENTS %] diff --git a/templates/webpages/taxzones/form.html b/templates/webpages/taxzones/form.html index 4e1c89ebc..72b8327ac 100644 --- a/templates/webpages/taxzones/form.html +++ b/templates/webpages/taxzones/form.html @@ -28,6 +28,8 @@ [%- END %] +[% LxERP.t8('Obsolete') %]: [% L.checkbox_tag('config.obsolete', checked = SELF.config.obsolete, for_submit=1) %] +

[% L.hidden_tag("action", "Taxzones/dispatch") %] [% L.submit_tag("action_" _ (SELF.config.id ? "update" : "create"), LxERP.t8('Save'), onclick="return check_prerequisites();") %] -- 2.20.1