Debitorenrechnungen: Beim Erstellen einer neuen Debitorenrechnung das richtige Steuer...
authorMoritz Bunkus <m.bunkus@linet-services.de>
Tue, 6 Mar 2007 16:00:31 +0000 (16:00 +0000)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Tue, 6 Mar 2007 16:00:31 +0000 (16:00 +0000)
SL/IS.pm
bin/mozilla/ar.pl
bin/mozilla/gl.pl

index 1ee47f2..2766ce2 100644 (file)
--- a/SL/IS.pm
+++ b/SL/IS.pm
@@ -1844,7 +1844,7 @@ sub get_customer {
 
   # setup last accounts used for this customer
   if (!$form->{id} && $form->{type} !~ /_(order|quotation)/) {
-    $query = qq|SELECT c.accno, c.description, c.link, c.category
+    $query = qq|SELECT c.id, c.accno, c.description, c.link, c.category
                 FROM chart c
                JOIN acc_trans ac ON (ac.chart_id = c.id)
                JOIN ar a ON (a.id = ac.trans_id)
@@ -1860,6 +1860,18 @@ sub get_customer {
       if ($ref->{category} eq 'I') {
         $i++;
         $form->{"AR_amount_$i"} = "$ref->{accno}--$ref->{description}";
+
+        if ($form->{initial_transdate}) {
+          my $tax_query =
+            qq|SELECT tk.tax_id, t.rate FROM taxkeys tk | .
+            qq|LEFT JOIN tax t ON tk.tax_id = t.id | .
+            qq|WHERE tk.chart_id = ? AND startdate <= ? | .
+            qq|ORDER BY tk.startdate DESC LIMIT 1|;
+          my ($tax_id, $rate) =
+            selectrow_query($form, $dbh, $tax_query, $ref->{id},
+                            $form->{initial_transdate});
+          $form->{"taxchart_$i"} = "${tax_id}--${rate}";
+        }
       }
       if ($ref->{category} eq 'A') {
         $form->{ARselected} = $form->{AR_1} = $ref->{accno};
index 9f003d3..04ddffe 100644 (file)
@@ -89,8 +89,10 @@ sub add {
     "$form->{script}?action=add&path=$form->{path}&login=$form->{login}&password=$form->{password}"
     unless $form->{callback};
 
-  &create_links;
   AR->get_transdate(\%myconfig, $form);
+  $form->{initial_transdate} = $form->{transdate};
+  &create_links;
+  $form->{transdate} = $form->{initial_transdate};
   &display_form;
   $lxdebug->leave_sub();
 }
@@ -257,8 +259,6 @@ sub create_links {
     }
   }
 
-  $lxdebug->message(0, "1 ARselected $form->{ARselected}");
-
   $form->{taxincluded}  = $taxincluded if ($form->{id});
   $form->{paidaccounts} = 1            if not defined $form->{paidaccounts};
 
@@ -627,7 +627,6 @@ $jsscript
     if ($previous_accno &&
         ($previous_accno eq $selected_accno) &&
         ($previous_tax_id ne $selected_tax_id)) {
-      $lxdebug->message(0, "yeah");
       my $item = $taxcharts{$selected_tax_id};
       $selected_taxchart = "$item->{id}--$item->{rate}";
     }
index 253b97e..0a7d44f 100644 (file)
@@ -1127,7 +1127,6 @@ sub display_rows {
     if ($previous_accno &&
         ($previous_accno eq $selected_accno) &&
         ($previous_tax_id ne $selected_tax_id)) {
-      $lxdebug->message(0, "yeah");
       my $item = $taxcharts{$selected_tax_id};
       $selected_taxchart = "$item->{id}--$item->{rate}";
     }