]> wagnertech.de Git - kivitendo-erp.git/commitdiff
Steuerzonen ungültig machen
authorG. Richardson <information@kivitendo-premium.de>
Wed, 30 Jul 2014 18:38:28 +0000 (20:38 +0200)
committerG. Richardson <information@kivitendo-premium.de>
Mon, 4 Aug 2014 15:31:40 +0000 (17:31 +0200)
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
SL/Controller/Taxzones.pm
SL/DB/MetaSetup/TaxZone.pm
SL/Form.pm
bin/mozilla/is.pl
bin/mozilla/oe.pl
sql/Pg-upgrade2/tax_zones_obsolete.sql [new file with mode: 0644]
templates/webpages/buchungsgruppen/form.html
templates/webpages/is/form_header.html
templates/webpages/oe/form_header.html
templates/webpages/taxzones/form.html

index bbb5893838e8c5877e0b31ee46e6d38dc40c7b86..f3f07d58ad44fc1ff33333e8747179c903be49e2 100644 (file)
@@ -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 }) {
index 5f19ea6d3acfb7d74ac2237a7b74ef33eecd0004..9bdf3553b15752a5150da93d872777283a4180b7 100644 (file)
@@ -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) {
index 993d28f88ab17829a8e56270e9d9aa815289edf5..5529d892482f4caa6b5bdda6bf293f37e31e8fca 100644 (file)
@@ -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 },
 );
 
index b3138ac26036c0448cd61033d2431d2e0056b544..a36ffd5dfb955c4f0543e8f794a0012173811439 100644 (file)
@@ -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);
 
index b6c6298a0ab5bf471de0379f02c78e9f3a38adea..35b08b947088a96073b05d54ac2a43a4f9ef6e73 100644 (file)
@@ -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",
index 9a8aea41e2e4be5403c7b34b55d09a360d86368a..fb3a7ff504af1f4a1bc67808cb2135bd096ee870 100644 (file)
@@ -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 (file)
index 0000000..c6891a2
--- /dev/null
@@ -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;
index 5dad157dba283ccb9918330e7a5dc0c6e1cf9d57..88c19f320e9a8496f92994ed2b85416ef4101c1b 100644 (file)
@@ -10,7 +10,7 @@
   </tr>
   <tr>
     <th align="right">[% 'Inventory account' | $T8 %]</th>
-    [%- IF SELF.config.id %]
+    [%- IF SELF.config.id AND linked_parts != 0 %]
     <td>[%- CHARTLIST.inventory_accno %] -- [%- CHARTLIST.inventory_accno_description %]</td>
     [%- ELSE %]
     <td>[%- L.select_tag("config.inventory_accno_id", ACCOUNTS.ic, title_sub=\account_label, default=SELF.config.inventory_accno_id) %]</td>
@@ -19,7 +19,7 @@
 [%- FOREACH tz = TAXZONES %]
   <tr>
     <th align="right">[% 'Revenue' | $T8 %] [% HTML.escape(tz.description) %]</th>
-    [%- IF SELF.config.id %]
+    [%- IF SELF.config.id AND linked_parts != 0 %]
     <td>[% CHARTLIST.${tz.id}.income_accno %] -- [% CHARTLIST.${tz.id}.income_accno_description %]</td>
     [%- ELSE %]
     <td>[%- L.select_tag('income_accno_id_' _ tz.id, ACCOUNTS.ic_income, title_sub=\account_label, default=CHARTLIST.${tz.id}.income_accno_id) %]</td>
@@ -27,7 +27,7 @@
   </tr>
   <tr>
     <th align="right">[% 'Expense' | $T8 %] [% HTML.escape(tz.description) %]</th>
-    [%- IF SELF.config.id %]
+    [%- IF SELF.config.id AND linked_parts != 0 %]
     <td>[% CHARTLIST.${tz.id}.expense_accno %] -- [% CHARTLIST.${tz.id}.expense_accno_description %]</td>
     [%- ELSE %]
     <td>[%- L.select_tag('expense_accno_id_' _ tz.id, ACCOUNTS.ic_expense, title_sub=\account_label, default=CHARTLIST.${tz.id}.expense_accno_id) %]</td>
index 5fa5bb10502d40af86f7ed4e58c0415d0314d1b7..0d4a255becb368f20009e28e5f7aa5d283f64728 100644 (file)
         <tr>
           <th align="right">[% 'Steuersatz' | $T8 %]</th>
           <td>
-            [% 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 %]
           <input type='hidden' name='taxzone_id' value='[% taxzone_id %]'>
   [%- END %]
index e01734932548bc32f525e139c0a18844a7bb29db..644879c1b7f151a15b24756056a0d033189ff8c7 100644 (file)
                   <tr>
                     <th align="right">[% 'Steuersatz' | $T8 %]</th>
                     <td>
-                      [% 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') %]
                     </td>
                   </tr>
 [%- IF ALL_DEPARTMENTS %]
index 4e1c89ebc5ac7ab59c7e212fabfe53486af3e3b2..72b8327aca9bc62b438d08bc868bcf6a744bda9c 100644 (file)
@@ -28,6 +28,8 @@
 [%- END %]
 </table>
 
+[% LxERP.t8('Obsolete') %]: [% L.checkbox_tag('config.obsolete', checked = SELF.config.obsolete, for_submit=1) %]
+
  <p>
   [% L.hidden_tag("action", "Taxzones/dispatch") %]
   [% L.submit_tag("action_" _  (SELF.config.id ? "update" : "create"), LxERP.t8('Save'), onclick="return check_prerequisites();") %]