Merge branch 'master' of ssh://lx-office/~/lx-office-erp
authorHolger Lindemann <hli@lx-system.de>
Fri, 5 Mar 2010 00:54:13 +0000 (01:54 +0100)
committerHolger Lindemann <hli@lx-system.de>
Fri, 5 Mar 2010 00:54:13 +0000 (01:54 +0100)
23 files changed:
SL/AP.pm
SL/AR.pm
SL/CP.pm
SL/DO.pm
SL/Form.pm
bin/mozilla/ap.pl
bin/mozilla/ar.pl
bin/mozilla/cp.pl
bin/mozilla/do.pl
doc/changelog
doc/skr04-update-3804/konto3804.png [new file with mode: 0644]
doc/skr04-update-3804/konto4315.png [new file with mode: 0644]
doc/skr04-update-3804/skr04_3804_hinzufuegen.html [new file with mode: 0644]
doc/skr04-update-3804/steuer3803.png [new file with mode: 0644]
doc/skr04-update-3804/steuer3804.png [new file with mode: 0644]
doc/skr04-update-3804/steuerliste.png [new file with mode: 0644]
locale/de/all
locale/de/cp
sql/Pg-upgrade2/SKR04-3804-addition.pl [new file with mode: 0644]
templates/webpages/dbupgrade/SKR04_3804_already_exists_de.html [new file with mode: 0644]
templates/webpages/dbupgrade/SKR04_3804_already_exists_master.html [new file with mode: 0644]
templates/webpages/dbupgrade/SKR04_3804_update_de.html [new file with mode: 0644]
templates/webpages/dbupgrade/SKR04_3804_update_master.html [new file with mode: 0644]

index c2ed2b5..fce222d 100644 (file)
--- 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 =
index 8cc5ea6..df47076 100644 (file)
--- 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 =
index b7e6241..f6c8c1a 100644 (file)
--- 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 = <<SQL;
+    SELECT COUNT(*)
+    FROM $arap
+    WHERE (${vc}_id = ?)
+      AND (COALESCE(curr, '') <> ?)
+      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) {
index 73314bc..b5faeae 100644 (file)
--- 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"}),
index c1cc2ab..905c629 100644 (file)
@@ -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();
index fba5ba1..62edff2 100644 (file)
@@ -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} .= "<option>$_\n" } @curr;
+  map { $form->{selectcurrency} .= "<option>$_\n" } $form->get_all_currencies(\%myconfig);
 
   # vendors
   if (@{ $form->{all_vendor} || [] }) {
@@ -261,7 +259,7 @@ sub form_header {
   my $exchangerate = qq|
 <input type=hidden name=forex value=$form->{forex}>
 |;
-  if ($form->{currency} ne $form->{defaultcurrency}) {
+  if ($form->{defaultcurrency} && ($form->{currency} ne $form->{defaultcurrency})) {
     if ($form->{forex}) {
       $exchangerate .= qq|
             <tr>
@@ -639,7 +637,7 @@ $jsscript
 |;
 
   my @column_index;
-  if ($form->{currency} eq $form->{defaultcurrency}) {
+  if ($form->{defaultcurrency} && ($form->{currency} eq $form->{defaultcurrency})) {
     @column_index = qw(datepaid source memo paid AP_paid paid_project_id);
   } else {
     @column_index = qw(datepaid source memo paid exchangerate AP_paid paid_project_id);
@@ -692,7 +690,7 @@ $jsscript
     }
 
     $exchangerate = qq|&nbsp;|;
-    if ($form->{currency} ne $form->{defaultcurrency}) {
+    if ($form->{defaultcurrency} && ($form->{currency} ne $form->{defaultcurrency})) {
       if ($form->{"forex_$i"}) {
         $exchangerate =
           qq|<input type=hidden name="exchangerate_$i" value=$form->{"exchangerate_$i"}>$form->{"exchangerate_$i"}|;
@@ -985,7 +983,7 @@ sub post_payment {
       $form->error($locale->text('Cannot post payment for a closed period!'))
         if ($form->date_closed($form->{"datepaid_$i"}, \%myconfig));
 
-      if ($form->{currency} ne $form->{defaultcurrency}) {
+      if ($form->{defaultcurrency} && ($form->{currency} ne $form->{defaultcurrency})) {
         $form->{"exchangerate_$i"} = $form->{exchangerate}
           if ($invdate == $datepaid);
         $form->isblank("exchangerate_$i",
@@ -1034,7 +1032,7 @@ sub post {
   $form->error($locale->text('Zero amount posting!')) if $zero_amount_posting;
 
   $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
-    if ($form->{currency} ne $form->{defaultcurrency});
+    if ($form->{defaultcurrency} && ($form->{currency} ne $form->{defaultcurrency}));
   delete($form->{AP});
 
   for my $i (1 .. $form->{paidaccounts}) {
@@ -1046,7 +1044,7 @@ sub post {
       $form->error($locale->text('Cannot post payment for a closed period!'))
         if ($form->date_closed($form->{"datepaid_$i"}, \%myconfig));
 
-      if ($form->{currency} ne $form->{defaultcurrency}) {
+      if ($form->{defaultcurrency} && ($form->{currency} ne $form->{defaultcurrency})) {
         $form->{"exchangerate_$i"} = $form->{exchangerate}
           if ($transdate == $datepaid);
         $form->isblank("exchangerate_$i",
index a740728..f170407 100644 (file)
@@ -147,7 +147,7 @@ sub create_links {
   my $form     = $main::form;
   my %myconfig = %main::myconfig;
 
-  my ($duedate, $taxincluded, @curr);
+  my ($duedate, $taxincluded);
 
   $form->create_links("AR", \%myconfig, "customer");
   $duedate = $form->{duedate};
@@ -166,11 +166,9 @@ sub create_links {
   $form->{notes} = $form->{intnotes} unless $form->{notes};
 
   # currencies
-  @curr = split(/:/, $form->{currencies});
-  chomp $curr[0];
-  $form->{defaultcurrency} = $curr[0];
+  $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
 
-  map { $form->{selectcurrency} .= "<option>$_\n" } @curr;
+  map { $form->{selectcurrency} .= "<option>$_\n" } $form->get_all_currencies(\%myconfig);
 
   # customers
   if (@{ $form->{all_customer} || [] }) {
@@ -290,7 +288,7 @@ sub form_header {
   $exchangerate = qq|
 <input type=hidden name=forex value=$form->{forex}>
 |;
-  if ($form->{currency} ne $form->{defaultcurrency}) {
+  if ($form->{defaultcurrency} && ($form->{currency} ne $form->{defaultcurrency})) {
     if ($form->{forex}) {
       $exchangerate .= qq|
         <th align=right>| . $locale->text('Exchangerate') . qq|</th>
@@ -684,7 +682,7 @@ $jsscript
         </tr>
 |;
 
-  if ($form->{currency} eq $form->{defaultcurrency}) {
+  if ($form->{defaultcurrency} && ($form->{currency} eq $form->{defaultcurrency})) {
     @column_index = qw(datepaid source memo paid AR_paid paid_project_id);
   } else {
     @column_index = qw(datepaid source memo paid exchangerate AR_paid paid_project_id);
@@ -737,7 +735,7 @@ $jsscript
     }
 
     $exchangerate = qq|&nbsp;|;
-    if ($form->{currency} ne $form->{defaultcurrency}) {
+    if ($form->{defaultcurrency} && ($form->{currency} ne $form->{defaultcurrency})) {
       if ($form->{"forex_$i"}) {
         $exchangerate =
           qq|<input type=hidden name="exchangerate_$i" value=$form->{"exchangerate_$i"}>$form->{"exchangerate_$i"}|;
@@ -1048,7 +1046,7 @@ sub post_payment {
 
       $form->error($locale->text('Cannot post payment for a closed period!')) if ($form->date_closed($form->{"datepaid_$i"}, \%myconfig));
 
-      if ($form->{currency} ne $form->{defaultcurrency}) {
+      if ($form->{defaultcurrency} && ($form->{currency} ne $form->{defaultcurrency})) {
 #        $form->{"exchangerate_$i"} = $form->{exchangerate} if ($invdate == $datepaid);
         $form->isblank("exchangerate_$i", $locale->text('Exchangerate for payment missing!'));
       }
@@ -1099,7 +1097,7 @@ sub post {
     unless grep $_*1, map $form->parse_amount(\%myconfig, $form->{"amount_$_"}), 1..$form->{rowcount};
 
   $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
-    if ($form->{currency} ne $form->{defaultcurrency});
+    if ($form->{defaultcurrency} && ($form->{currency} ne $form->{defaultcurrency}));
 
   delete($form->{AR});
 
@@ -1112,7 +1110,7 @@ sub post {
       $form->error($locale->text('Cannot post payment for a closed period!'))
         if ($form->date_closed($form->{"datepaid_$i"}, \%myconfig));
 
-      if ($form->{currency} ne $form->{defaultcurrency}) {
+      if ($form->{defaultcurrency} && ($form->{currency} ne $form->{defaultcurrency})) {
         $form->{"exchangerate_$i"} = $form->{exchangerate} if ($transdate == $datepaid);
         $form->isblank("exchangerate_$i", $locale->text('Exchangerate for payment missing!'));
       }
index 5162433..f4a9efb 100644 (file)
@@ -317,6 +317,19 @@ sub form_header {
 $jsscript
 |;
 
+  if ($form->{openinvoices_other_currencies}) {
+    my $warning = $form->{vc} eq 'customer' ? $::locale->text('There are #1 more open invoices for this customer with other currencies.', $form->{openinvoices_other_currencies})
+                :                             $::locale->text('There are #1 more open invoices from this vendor with other currencies.',  $form->{openinvoices_other_currencies});
+
+    print qq|
+
+  <input type="hidden" name="openinvoices_other_currencies" value="| . H($form->{openinvoices_other_currencies}) . qq|">
+  <tr>
+   <td><b>| . $::locale->text('Note') . qq|: $warning</b></td>
+  </tr>
+|;
+  }
+
   $lxdebug->leave_sub();
 }
 
index 4ae7f45..a57022b 100644 (file)
@@ -183,6 +183,8 @@ sub order_links {
     IR->get_vendor(\%myconfig, \%$form);
   } else {
     IS->get_customer(\%myconfig, \%$form);
+    # OFFEN tritt bug 1284 auch bei vendor auf?
+    $form->{discount} = $form->{customer_discount};
   }
 
   $form->restore_vars(qw(payment_id language_id taxzone_id intnotes cp_id));
@@ -628,14 +630,9 @@ sub save {
   # wird die Maske mit dem falschen Rabatt wieder aufgebaut.
   # Wie immer: backup_vars verwenden um nichts anderes kaputt zu
   # machen. jan 03.03.2010
-  for my $i (1 .. $form->{rowcount}) {
-    $form->{"backup_discount_$i"} = $form->{"discount_$i"};
-  };
+  # nicht mehr notwendig da für bug 1284 der backend aufruf entsprechend
+  # geändert wurde
   DO->save();
-  for my $i (1 .. $form->{rowcount}) {
-    $form->{"discount_$i"} = $form->{"backup_discount_$i"};
-    delete $form->{"backup_discount_$i"};
-  };
   # saving the history
   if(!exists $form->{addition}) {
     $form->{snumbers} = qq|donumber_| . $form->{donumber};
@@ -734,6 +731,11 @@ sub invoice {
   }
 
   for my $i (1 .. $form->{rowcount}) {
+    # für bug 1284
+    if ($form->{discount}){ # Falls wir einen Kundenrabatt haben 
+      # und keinen anderen discount wert an $i ...
+      $form->{"discount_$i"} ||= $form->{discount}*100; # ... nehmen wir den kundenrabatt
+    }
     map { $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if $form->{"${_}_${i}"} } qw(ship qty sellprice listprice basefactor);
   }
 
index b52032f..a661723 100644 (file)
   1051 1055 1057 1058 1072 1073 1077 1079 1081 1082 1095 1098 1100 1101 1108
   1110 1118 1125 1127 1130 1133 1135 1136 1138 1144 1146 1147 1150 1151 1155
   1164 1170 1173 1177 1186 1188 1190 1191 1195 1197 1198 1199 1200 1201 1209
-  1213 1243 1248 1250 1262 1286 1287 1289 1290 1291 1294 1299 1331 1334 1336
-  1339 1340 1341 1342 1343 1350 1352 1399
+  1213 1243 1248 1250 1262 1284 1286 1287 1289 1290 1291 1294 1299 1331 1334
+  1336 1339 1340 1341 1342 1343 1350 1352 1399
 
 
 2009-06-02 - Version 2.6.0
diff --git a/doc/skr04-update-3804/konto3804.png b/doc/skr04-update-3804/konto3804.png
new file mode 100644 (file)
index 0000000..e66b66a
Binary files /dev/null and b/doc/skr04-update-3804/konto3804.png differ
diff --git a/doc/skr04-update-3804/konto4315.png b/doc/skr04-update-3804/konto4315.png
new file mode 100644 (file)
index 0000000..d9971cf
Binary files /dev/null and b/doc/skr04-update-3804/konto4315.png differ
diff --git a/doc/skr04-update-3804/skr04_3804_hinzufuegen.html b/doc/skr04-update-3804/skr04_3804_hinzufuegen.html
new file mode 100644 (file)
index 0000000..14a49ed
--- /dev/null
@@ -0,0 +1,54 @@
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<title>Lx-Office: SKR04 19% Umstellung für innergemeinschaftlichen Erwerb</title>
+</head>
+<body>
+
+<h1>Umsatzsteuer 19% für Verkauf mit Steuerschlüssel "EU ohne USt.-IdNr.":</h1>
+
+Die Umsatzsteuerumstellung auf 19% für SKR04 für die Steuerschlüssel "EU ohne
+USt-ID Nummer" ist erst 2010 erfolgt. Das Upgradeskript erstellt automatisch
+das Konto 3804 und stellt die Steuereinstellungen korrekt ein, hat der Benutzer
+aber schon selber das Konto 3804 angelegt, oder gab es schon Buchungen im
+Zeitraum nach dem 01.01.2007 auf das Konto 3803, wird das Upgradeskript
+vorsichtshalber nicht ausgeführt, da der Benutzer sich vielleicht schon selbst
+geholfen hat und mit seinen Änderungen zufrieden ist. Die korrekten
+Einstellungen kann man aber auch per Hand ausführen, nachfolgend werden die
+entsprechenden Schritte anhand von Screenshots dargestellt.
+
+Für den Fall, daß Buchungen mit der Steuerschlüssel "EU ohne USt.-IdNr." nach dem
+01.01.2007 erfolgt sind, ist davon auszugehen, daß diese mit dem alten
+Umsatzsteuersatz von 16% gebucht worden sind, und diese Buchungen sollten
+entsprechend kontrolliert werden.
+
+<h2>Lx-Office: 3804 hinzufügen</h2>
+Konto 3804 anlegen:<br>
+
+System -> Kontenübersicht -> Konto erfassen<br>
+
+<img src="konto3804.png" alt="konto3804.png">
+
+
+<h2>Steuergruppe 13 für Konto 3803 anpassen (16%):</h2>
+System -> Steuern -> bearbeiten -> Eintrag mit Steuerschlüssel 13 auswählen<br>
+
+<img src="steuer3803.png" alt="steuer3803.png">
+
+<h2>Neuen Eintrag mit Steuerschlüssel 13 für Konto 3804 (19%) anlegen</h2>
+System -> Steuern -> bearbeiten -> erfassen<br>
+
+<img src="steuer3804.png" alt="steuer3804.png">
+<h2>Alle Konten, die als Steuerautomatikkonto die 3803 haben, kriegen ab 1.1.2007 auch Steuerautomatik auf 3804</h2>
+
+Steuerschlüssel für Konto 4315 anpassen (das gleiche für 4726) <br>
+
+System -> Kontenübersicht -> Konten anzeigen -> 4315<br>
+
+<img src="konto4315.png" alt="konto4315.png">
+
+<h2>Steuerliste kontrolllieren</h2>
+System -> Steuern -> bearbeiten
+
+<img src="steuerliste.png" alt="steuerliste.png">
+
+</body></html>
diff --git a/doc/skr04-update-3804/steuer3803.png b/doc/skr04-update-3804/steuer3803.png
new file mode 100644 (file)
index 0000000..361c0b3
Binary files /dev/null and b/doc/skr04-update-3804/steuer3803.png differ
diff --git a/doc/skr04-update-3804/steuer3804.png b/doc/skr04-update-3804/steuer3804.png
new file mode 100644 (file)
index 0000000..fad5986
Binary files /dev/null and b/doc/skr04-update-3804/steuer3804.png differ
diff --git a/doc/skr04-update-3804/steuerliste.png b/doc/skr04-update-3804/steuerliste.png
new file mode 100644 (file)
index 0000000..2c4945c
Binary files /dev/null and b/doc/skr04-update-3804/steuerliste.png differ
index 4d3e039..442fb7b 100644 (file)
@@ -1184,6 +1184,7 @@ $self->{texts} = {
   'Please insert your longdescription below' => 'Bitte den Langtext eingeben',
   'Please install the below listed modules or ask your system administrator to.' => 'Bitte installieren Sie die unten aufgef&uuml;hrten Module, oder bitten Sie Ihren Administrator darum.',
   'Please re-run the analysis for broken general ledger entries by clicking this button:' => 'Bitte wiederholen Sie die Analyse der Hauptbucheinträge, indem Sie auf diesen Button klicken:',
+  'Please read the file'        => 'Bitte lesen Sie die Datei',
   'Please select a customer from the list below.' => 'Bitte einen Endkunden aus der Liste auswählen',
   'Please select a part from the list below.' => 'Bitte w&auml;hlen Sie einen Artikel aus der Liste aus.',
   'Please select a vendor from the list below.' => 'Bitte einen Händler aus der Liste auswählen',
@@ -1532,6 +1533,8 @@ $self->{texts} = {
   'The LDAP server "#1:#2" is unreachable. Please check config/authentication.pl.' => 'Der LDAP-Server "#1:#2" ist nicht erreichbar. Bitte &uuml;berpr&uuml;fen Sie die Angaben in config/authentication.pl.',
   'The SEPA export has been created.' => 'Der SEPA-Export wurde erstellt',
   'The access rights have been saved.' => 'Die Zugriffsrechte wurden gespeichert.',
+  'The account 3804 already exists, the update will be skipped.' => 'Das Konto 3804 existiert schon, das Update wird übersprungen.',
+  'The account 3804 will not be added automatically.' => 'Das Konto 3804 wird nicht automatisch hinzugefügt.',
   'The assembly has been created.' => 'Das Erzeugnis wurde hergestellt.',
   'The assistant could not find anything wrong with #1. Maybe the problem has been solved in the meantime.' => 'Der Korrekturassistent konnte kein Problem bei #1 feststellen. Eventuell wurde das Problem in der Zwischenzeit bereits behoben.',
   'The authentication configuration file &quot;config/authentication.pl&quot; does not exist. This Lx-Office installation has probably not been updated correctly yet. Please contact your administrator.' => 'Die Konfigurationsdatei f&uuml;r die Authentifizierung &quot;config/authentication.pl&quot; wurde nicht gefunden. Diese Lx-Office-Installation wurde vermutlich noch nicht vollst&auml;ndig aktualisiert oder eingerichtet. Bitte wenden Sie sich an Ihren Administrator.',
@@ -1644,7 +1647,10 @@ $self->{texts} = {
   'The wrong taxkeys for AP and AR transactions have been fixed.' => 'Die Probleme mit falschen Steuerschlüssel bei Kreditoren- und Debitorenbuchungen wurden behoben.',
   'The wrong taxkeys for inventory transactions for sales and purchase invoices have been fixed.' => 'Die falschen Steuerschlüssel für Warenbestandsbuchungen bei Einkaufs- und Verkaufsrechnungen wurden behoben.',
   'The wrong taxkeys have been fixed.' => 'Die Steuerschlüssel wurden nach Ihrer Auswahl korrigiert.',
+  'There are #1 more open invoices for this customer with other currencies.' => 'Es gibt #1 weitere offene Rechnungen für diesen Kunden, die in anderen Währungen ausgestellt wurden.',
+  'There are #1 more open invoices from this vendor with other currencies.' => 'Es gibt #1 weitere offene Rechnungen von diesem Lieferanten, die in anderen Währungen ausgestellt wurden.',
   'There are #1 unfinished follow-ups of which #2 are due.' => 'Es gibt #1 Wiedervorlage(n), von denen #2 fällig ist/sind.',
+  'There are bookings to the account 3803 after 01.01.2007. If you didn\'t change this account manually to 19% the bookings are probably incorrect.' => 'Das Konto 3803 wurde nach dem 01.01.2007 bebucht. Falls Sie dieses Konto nicht manuell auf 19% gestellt haben sind die Buchungen wahrscheinlich mit falscher Umsatzsteuer gebucht worden.',
   'There are four tax zones.'   => 'Es gibt vier Steuerzonen.',
   'There are no items in stock.' => 'Dieser Artikel ist nicht eingelagert.',
   'There are no items on your TODO list at the moment.' => 'Ihre Aufgabenliste enth&auml;lt momentan keine Eintr&auml;ge.',
@@ -1753,6 +1759,7 @@ $self->{texts} = {
   'Update'                      => 'Erneuern',
   'Update Dataset'              => 'Datenbank aktualisieren',
   'Update Prices'               => 'Preise aktualisieren',
+  'Update SKR04: new tax account 3804 (19%)' => 'Update SKR04: neues Steuerkonto 3804 (19%) für innergemeinschaftlichen Erwerb',
   'Update complete'             => 'Update beendet.',
   'Update prices'               => 'Preise aktualisieren',
   'Update?'                     => 'Aktualisieren?',
index 9de006c..11ee888 100644 (file)
@@ -106,6 +106,7 @@ $self->{texts} = {
   'No or an unknown authenticantion module specified in "config/authentication.pl".' => 'Es wurde kein oder ein unbekanntes Authentifizierungsmodul in "config/authentication.pl" angegeben.',
   'No part was found matching the search parameters.' => 'Es wurde kein Artikel gefunden, auf den die Suchparameter zutreffen.',
   'No vendor has been selected yet.' => 'Es wurde noch kein Lieferant ausgewählt.',
+  'Note'                        => 'Hinweis',
   'Number'                      => 'Nummer',
   'Others'                      => 'Andere',
   'PAYMENT POSTED'              => 'Rechung gebucht',
@@ -159,6 +160,8 @@ $self->{texts} = {
   'The connection to the authentication database failed:' => 'Die Verbindung zur Authentifizierungsdatenbank schlug fehl:',
   'The connection to the template database failed:' => 'Die Verbindung zur Vorlagendatenbank schlug fehl:',
   'The creation of the authentication database failed:' => 'Das Anlegen der Authentifizierungsdatenbank schlug fehl:',
+  'There are #1 more open invoices for this customer with other currencies.' => 'Es gibt #1 weitere offene Rechnungen für diesen Kunden, die in anderen Währungen ausgestellt wurden.',
+  'There are #1 more open invoices from this vendor with other currencies.' => 'Es gibt #1 weitere offene Rechnungen von diesem Lieferanten, die in anderen Währungen ausgestellt wurden.',
   'To (email)'                  => 'An',
   'Transactions, AR transactions, AP transactions' => 'Dialogbuchen, Debitorenrechnungen, Kreditorenrechnungen',
   'Trying to call a sub without a name' => 'Es wurde versucht, eine Unterfunktion ohne Namen aufzurufen.',
diff --git a/sql/Pg-upgrade2/SKR04-3804-addition.pl b/sql/Pg-upgrade2/SKR04-3804-addition.pl
new file mode 100644 (file)
index 0000000..ccea7e9
--- /dev/null
@@ -0,0 +1,136 @@
+# @tag: SKR04-3804-addition
+# @description: Konto 3804 zu SKR04 hinzufügen: Umsatzsteuer 19% für Steuerschlüssel 13 (Umsatzsteuer aus EG-Erwerb)
+# @depends:
+# @charset: UTF-8
+
+use strict;
+
+die("This script cannot be run from the command line.") unless ($main::form);
+
+sub mydberror {
+  my ($msg) = @_;
+  die($dbup_locale->text("Database update error:") . "<br>$msg<br>" . $DBI::errstr);
+}
+
+sub do_query {
+  my ($query, $may_fail) = @_;
+
+  if (!$dbh->do($query)) {
+    mydberror($query) unless ($may_fail);
+    $dbh->rollback();
+    $dbh->begin_work();
+  }
+}
+
+
+sub do_update {
+
+  # 1. Überprüfen ob Kontenrahmen SKR04 ist, wenn nicht alles überspringen
+  my ($kontenrahmen) = $dbh->selectrow_array("select coa from defaults");
+
+  unless ( $kontenrahmen eq 'Germany-DATEV-SKR04EU' ) {
+    print "Kontenrahmen ist nicht SKR04, überspringen<br>";
+    return 1;
+  };
+
+  # Mandant hat SKR04, erst prüfen wir, ob in der Vergangenheit Buchungen mit
+  # taxkey 13 erfolgt sind (Fall "EU ohne USt. ID), diese sind wahrscheinlich
+  # mit der falschen MwSt (16%) gebucht worden, wenn dies nicht manuell
+  # geändert worden ist
+
+  my ($anzahl_buchungen) = $dbh->selectrow_array("select count (*) from acc_trans where taxkey=13 and transdate >= '2007-01-01';");
+  if ( $anzahl_buchungen > 0 ) {
+    if ($main::form->{bookings_exist} ) {
+      # Benutzer hat Meldung bestätigt
+      print "Buchungen nach dem 01.01.2007 existierten, Upgrade überspringen";
+      return 1;  
+    } else {
+      # Meldung anzeigen und auf Rückgabe warten
+      print_past_booking_warning();
+      return 2;
+    };
+  } else {  # es gibt keine Buchungen mit taxkey 13 nach 01.01.2007
+  
+    # prüfen ob Konto 3804 schon existiert
+    my ($konto_existiert) = $dbh->selectrow_array("select count (*) from chart where accno = '3804'");
+    if ( $konto_existiert ) {
+      # 3804 existiert, wir gehen davon aus, daß der Benutzer das Konto schon selber angelegt hat und
+      # ordnungsgemäß benutzt
+
+      if ($main::form->{account_exists} ) {
+      # Benutzer hat Meldung bestätigt
+        print "Konto existiert, Upgrade überspringen\n";
+        return 1;  
+      } else {
+        # Meldung anzeigen und auf Rückgabe warten
+        print_3804_already_exists();
+        return 2;
+      };
+    } else {
+
+    # noch keine Buchungen mit taxkey 13 und Konto 3804 existiert noch nicht,
+    # also legen wir es an und machen noch die nötigen Einstellungen in tax und
+    # taxkeys
+
+        my $insert_chart = <<SQL;
+INSERT INTO chart (
+  accno, description,
+  charttype,   category,  link,
+  taxkey_id, pos_eur
+  )
+SELECT
+  '3804','Umsatzsteuer aus EG-Erwerb 19%',
+  'A','I','AR_tax:IC_taxpart:IC_taxservice',
+  0, (select pos_eur from chart where accno = '3803')
+WHERE EXISTS ( -- update only for SKR04, aber eigentlich schon überprüft
+    SELECT coa FROM defaults
+    WHERE defaults.coa='Germany-DATEV-SKR04EU'
+);
+SQL
+
+        do_query($insert_chart);
+
+        my $konto_anlegen = $dbh->prepare($insert_chart) || mydberror($insert_chart);
+
+
+        # 13-1 (16%) korrigieren:
+        my $edit_taxkey_13 = qq|UPDATE tax SET taxdescription = 'Steuerpflichtige EG-Lieferung zum vollen Steuersatz', rate = '0.16', chart_id = (select id FROM chart where accno = '3803'), taxnumber = 3803 WHERE taxkey = '13'|;
+        do_query($edit_taxkey_13);
+
+        # Sicherstellen, daß 3803 die richtige Bezeichnung hat
+        my $update_3803 = qq|update chart set description = 'Umsatzsteuer aus EG-Erwerb 16%' where accno = '3803'|;
+        do_query($update_3803);
+
+        # Zweiter  Eintrag für taxkey 13 in key: 19%
+        my $insert_taxkey_13_2 = qq|INSERT INTO tax ( taxkey, taxdescription, rate, chart_id, taxnumber ) VALUES ('13', 'Steuerpflichtige EG-Lieferung zum vollen Steuersatz', '0.19', (select id from chart where accno = '3804'), '3804')|;
+
+        do_query($insert_taxkey_13_2);
+
+        # alle Konten finden, bei denen 3803 das Steuerautomatikkonto ist,
+        # und dort den zweiten Eintrag ab 1.1.2007 für 19% einstellen
+        my $sth_query  = $dbh->prepare(qq|select c.id from chart c join taxkeys t on (c.id = t.chart_id) where tax_id = (select id from tax where taxnumber = '3803')|);
+        my $sth_insert = $dbh->prepare(qq|INSERT INTO taxkeys ( taxkey_id, chart_id, tax_id, pos_ustva, startdate )
+                                                       VALUES (13, ?, (select id from tax where taxkey = 13 and rate = '0.19'),
+            (select pos_ustva from taxkeys where tax_id = (select id from tax where taxnumber = '3803') and pos_ustva > 0 limit 1),
+            '01.01.2007')|);
+        $sth_query->execute();
+
+        while (my $ref = $sth_query->fetchrow_hashref()) {
+          $sth_insert->execute($ref->{id});
+        }
+        $sth_query->finish();
+        $sth_insert->finish();
+
+      }; # end code update
+  }; # end check if 3804 exists
+
+}; # end do_update
+
+sub print_past_booking_warning {
+  print $main::form->parse_html_template("dbupgrade/SKR04_3804_update");
+};
+sub print_3804_already_exists {
+  print $main::form->parse_html_template("dbupgrade/SKR04_3804_already_exists");
+};
+
+return do_update();
diff --git a/templates/webpages/dbupgrade/SKR04_3804_already_exists_de.html b/templates/webpages/dbupgrade/SKR04_3804_already_exists_de.html
new file mode 100644 (file)
index 0000000..7c2ecd0
--- /dev/null
@@ -0,0 +1,11 @@
+[% USE HTML %]<div class="listtop">Update SKR04: neues Steuerkonto 3804 (19%) für innergemeinschaftlichen Erwerb</div>
+
+<form action="[% script %]" method="POST">
+
+<p>Das Konto 3804 existiert schon, das Update wird übersprungen.</p>
+<p>Bitte lesen Sie die Dateidoc/skr04-update-3804/skr04_3804_hinzufuegen.html.
+
+<input type="hidden" name="account_exists" value="1">
+<input type="submit" value="Weiter">
+
+
diff --git a/templates/webpages/dbupgrade/SKR04_3804_already_exists_master.html b/templates/webpages/dbupgrade/SKR04_3804_already_exists_master.html
new file mode 100644 (file)
index 0000000..ba36b3e
--- /dev/null
@@ -0,0 +1,11 @@
+[% USE HTML %]<div class="listtop"><translate>Update SKR04: new tax account 3804 (19%)</translate></div>
+
+<form action="[% script %]" method="POST">
+
+<p><translate>The account 3804 already exists, the update will be skipped.</translate></p>
+<p><translate>Please read the file</translate>doc/skr04-update-3804/skr04_3804_hinzufuegen.html.
+
+<input type="hidden" name="account_exists" value="1">
+<input type="submit" value="<translate>Continue</translate>">
+
+
diff --git a/templates/webpages/dbupgrade/SKR04_3804_update_de.html b/templates/webpages/dbupgrade/SKR04_3804_update_de.html
new file mode 100644 (file)
index 0000000..2641022
--- /dev/null
@@ -0,0 +1,12 @@
+[% USE HTML %]<div class="listtop">Update SKR04: neues Steuerkonto 3804 (19%) für innergemeinschaftlichen Erwerb</div>
+
+<form action="[% script %]" method="POST">
+
+<p>Das Konto 3803 wurde nach dem 01.01.2007 bebucht. Falls Sie dieses Konto nicht manuell auf 19% gestellt haben sind die Buchungen wahrscheinlich mit falscher Umsatzsteuer gebucht worden.</p>
+<p>Das Konto 3804 wird nicht automatisch hinzugefügt.</p>
+<p>Bitte lesen Sie die Dateidoc/skr04-update-3804/skr04_3804_hinzufuegen.html</p>
+
+<input type="hidden" name="bookings_exist" value="1">
+<input type="submit" value="Weiter">
+
+
diff --git a/templates/webpages/dbupgrade/SKR04_3804_update_master.html b/templates/webpages/dbupgrade/SKR04_3804_update_master.html
new file mode 100644 (file)
index 0000000..b706a83
--- /dev/null
@@ -0,0 +1,12 @@
+[% USE HTML %]<div class="listtop"><translate>Update SKR04: new tax account 3804 (19%)</translate></div>
+
+<form action="[% script %]" method="POST">
+
+<p><translate>There are bookings to the account 3803 after 01.01.2007. If you didn't change this account manually to 19% the bookings are probably incorrect.</translate></p>
+<p><translate>The account 3804 will not be added automatically.</translate></p>
+<p><translate>Please read the file</translate>doc/skr04-update-3804/skr04_3804_hinzufuegen.html</p>
+
+<input type="hidden" name="bookings_exist" value="1">
+<input type="submit" value="<translate>Continue</translate>">
+
+