Standard-Auswahl für Umlaufvermögenskonto (Bank) mandantenweit setzen. Ferner yearend...
authorJan Büren <jan@lx-office-hosting.de>
Sat, 18 Dec 2010 13:13:07 +0000 (14:13 +0100)
committerJan Büren <jan@lx-office-hosting.de>
Sat, 18 Dec 2010 13:13:07 +0000 (14:13 +0100)
SL/AM.pm
SL/IS.pm
bin/mozilla/cp.pl
bin/mozilla/ir.pl
sql/Pg-upgrade2/add_ar_paid_defaults.sql [new file with mode: 0644]
templates/webpages/am/edit_defaults.html

index 12a4ad7..df7d9d2 100644 (file)
--- a/SL/AM.pm
+++ b/SL/AM.pm
@@ -1358,7 +1358,7 @@ sub save_defaults {
   my $dbh      = $params{dbh} || $form->get_standard_dbh($myconfig);
 
   my %accnos;
-  map { ($accnos{$_}) = split(m/--/, $form->{$_}) } qw(inventory_accno income_accno expense_accno fxgain_accno fxloss_accno);
+  map { ($accnos{$_}) = split(m/--/, $form->{$_}) } qw(inventory_accno income_accno expense_accno fxgain_accno fxloss_accno ar_paid_accno);
 
   $form->{curr}  =~ s/ //g;
   my @currencies =  grep { $_ ne '' } split m/:/, $form->{curr};
@@ -1373,6 +1373,7 @@ sub save_defaults {
         expense_accno_id   = (SELECT c.id FROM chart c WHERE c.accno = ?),
         fxgain_accno_id    = (SELECT c.id FROM chart c WHERE c.accno = ?),
         fxloss_accno_id    = (SELECT c.id FROM chart c WHERE c.accno = ?),
+        ar_paid_accno_id   = (SELECT c.id FROM chart c WHERE c.accno = ?),
         invnumber          = ?,
         cnnumber           = ?,
         sonumber           = ?,
@@ -1385,19 +1386,18 @@ sub save_defaults {
         servicenumber      = ?,
         sdonumber          = ?,
         pdonumber          = ?,
-        yearend            = ?,
         curr               = ?,
         businessnumber     = ?,
         weightunit         = ?|;
   my @values = ($accnos{inventory_accno}, $accnos{income_accno}, $accnos{expense_accno},
-                $accnos{fxgain_accno},    $accnos{fxloss_accno},
+                $accnos{fxgain_accno},    $accnos{fxloss_accno}, $accnos{ar_paid_accno},
                 $form->{invnumber},       $form->{cnnumber},
                 $form->{sonumber},        $form->{ponumber},
                 $form->{sqnumber},        $form->{rfqnumber},
                 $form->{customernumber},  $form->{vendornumber},
                 $form->{articlenumber},   $form->{servicenumber},
                 $form->{sdonumber},       $form->{pdonumber},
-                $form->{yearend},         $currency,
+                $currency,
                 $form->{businessnumber},  $form->{weightunit});
   do_query($form, $dbh, $query, @values);
 
@@ -1492,6 +1492,7 @@ sub defaultaccounts {
   $form->{defaults}{IC_expense}   = $form->{defaults}{expense_accno_id};
   $form->{defaults}{FX_gain}      = $form->{defaults}{fxgain_accno_id};
   $form->{defaults}{FX_loss}      = $form->{defaults}{fxloss_accno_id};
+  $form->{defaults}{AR_paid}      = $form->{defaults}{ar_paid_accno_id};
 
   $form->{defaults}{weightunit} ||= 'kg';
 
@@ -1571,6 +1572,24 @@ sub defaultaccounts {
       if $ref->{taxnumber};
     $form->{taxrates}{ $ref->{accno} }{rate} = $ref->{rate} if $ref->{rate};
   }
+  # Abfrage für Standard Umlaufvermögenskonto
+  $query =
+    qq|SELECT id, accno, description, link | .
+    qq|FROM chart | .
+    qq|WHERE link LIKE ? |.
+    qq|ORDER BY accno|;
+  $sth = prepare_execute_query($form, $dbh, $query, '%AR%');
+  $sth->execute || $form->dberror($query);#
+  while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
+    foreach my $item (split(/:/, $ref->{link})) {
+      if ($item eq "AR_paid") {
+        %{ $form->{IC}{AR_paid}{ $ref->{accno} } } = (
+                                             id          => $ref->{id},
+                                             description => $ref->{description}
+          );
+      }
+    }
+  }
 
   $sth->finish;
   $dbh->disconnect;
index 8e7dcc9..5909233 100644 (file)
--- a/SL/IS.pm
+++ b/SL/IS.pm
@@ -2159,4 +2159,21 @@ sub is_storno {
   return $result;
 }
 
+sub get_standard_accno_current_assets {
+  $main::lxdebug->enter_sub();
+
+  my ($self, $myconfig, $form) = @_;
+
+  my $dbh = $form->dbconnect($myconfig);
+
+  my $query = qq| SELECT accno FROM chart WHERE id = (SELECT ar_paid_accno_id FROM defaults)|;
+  my ($result) = selectrow_query($form, $dbh, $query);
+
+  $dbh->disconnect();
+
+  $main::lxdebug->leave_sub();
+
+  return $result;
+}
+
 1;
index b3efdec..721a4a8 100644 (file)
@@ -78,15 +78,21 @@ sub payment {
 
   CP->paymentaccounts(\%myconfig, \%$form);
 
+  # Standard Konto für Umlaufvermögen
+  my $accno_arap = IS->get_standard_accno_current_assets(\%myconfig, \%$form);
+
   $form->{selectaccount} = "";
   $form->{"select$form->{ARAP}"} = "";
 
-  map { $form->{selectaccount} .= "<option>$_->{accno}--$_->{description}\n" }
-    @{ $form->{PR}{"$form->{ARAP}_paid"} };
-  map {
-    $form->{"select$form->{ARAP}"} .=
-      "<option>$_->{accno}--$_->{description}\n"
-  } @{ $form->{PR}{ $form->{ARAP} } };
+  map { $form->{selectaccount} .= "<option>$_->{accno}--$_->{description}\n";
+        $form->{account}        = "$_->{accno}--$_->{description}" if ($_->{accno} eq $accno_arap) } @{ $form->{PR}{"$form->{ARAP}_paid"} };
+
+  # Braucht man das hier überhaupt? Erstmal auskommentieren .. jan 18.12.2010
+  #  map {
+  #    $form->{"select$form->{ARAP}"} .=
+  #      "<option>$_->{accno}--$_->{description}\n"
+  #  } @{ $form->{PR}{ $form->{ARAP} } };
+  # ENDE LOESCHMICH in 2012
 
   # currencies
   # oldcurrency ist zwar noch hier als fragment enthalten, wird aber bei
index 1dafe84..ced248f 100644 (file)
@@ -171,7 +171,7 @@ sub invoice_links {
   foreach my $key (keys %{ $form->{AP_links} }) {
 
     foreach my $ref (@{ $form->{AP_links}{$key} }) {
-      $form->{"select$key"} .= "<option>$ref->{accno}--$ref->{description}\n";
+      $form->{"select$key"} .= "<option>$ref->{accno}--$ref->{description}</option>";
     }
 
     next unless $form->{acc_trans}{$key};
@@ -393,9 +393,17 @@ sub form_footer {
   $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
   $form->{paid_indices} = [ 1 .. $form->{paidaccounts} ];
 
+  # Standard Konto für Umlaufvermögen
+  my $accno_arap = IS->get_standard_accno_current_assets(\%myconfig, \%$form);
+
   for my $i (1 .. $form->{paidaccounts}) {
     $form->{"selectAP_paid_$i"} = $form->{selectAP_paid};
-    $form->{"selectAP_paid_$i"} =~ s/option>\Q$form->{"AP_paid_$i"}\E/option selected>$form->{"AP_paid_$i"}/;
+    if (!$form->{"AP_paid_$i"}) {
+      $form->{"selectAP_paid_$i"} =~ s/option>$accno_arap--(.*?)>/option selected>$accno_arap--$1>/;
+    } else {
+      $form->{"selectAP_paid_$i"} =~ s/option>\Q$form->{"AP_paid_$i"}\E/option selected>$form->{"AP_paid_$i"}/;
+    }
+
     $totalpaid += $form->{"paid_$i"};
   }
 
diff --git a/sql/Pg-upgrade2/add_ar_paid_defaults.sql b/sql/Pg-upgrade2/add_ar_paid_defaults.sql
new file mode 100644 (file)
index 0000000..43b257e
--- /dev/null
@@ -0,0 +1,5 @@
+-- @tag: add_ar_paid_defaults 
+-- @description: Standardkonto für ar_paid (Umlaufvermögenskonto == Bank) in der Tabelle defaults hinzugefügt
+-- @depends: release_2_6_1
+-- @charset: utf-8
+ALTER TABLE defaults ADD COLUMN ar_paid_accno_id integer;
index 315673b..d346b89 100644 (file)
       </select>
      </td>
     </tr>
+     <tr>
+     <th align="right" nowrap>[% 'Current assets account' | $T8 %]</th>
+     <td colspan="3">
+      <select name="ar_paid_accno">
+       [%- FOREACH row = ACCNOS_AR_PAID %]
+       <option value="[% HTML.escape(row.value) %]"[% IF row.selected %] selected[% END %]>[% HTML.escape(row.name) %]</option>
+       [%- END %]
+      </select>
+     </td>
+    </tr>
 
     <tr class="listheading">
      <th colspan="4">[% 'Miscellaneous' | $T8 %]</th>