Wiederkehrende Rechnungen: Variablen Periodenstart-/-enddatum richtig setzen
[kivitendo-erp.git] / SL / AM.pm
index af47027..9ab6c80 100644 (file)
--- a/SL/AM.pm
+++ b/SL/AM.pm
@@ -107,7 +107,7 @@ sub get_account {
                                             startdate      => $taxkey->startdate->to_kivitendo,
                                             taxdescription => $taxkey->tax->taxdescription,
                                             rate           => $taxkey->tax->rate,
-                                            accno          => $taxkey->tax->chart->accno,
+                                            accno          => defined $taxkey->tax->chart_id ? $taxkey->tax->chart->accno : undef,
                                           };
     }
 
@@ -143,23 +143,15 @@ sub save_account {
     }
   }
 
-  $form->{link} = "";
-  foreach my $item ($form->{AR},            $form->{AR_amount},
-                    $form->{AR_tax},        $form->{AR_paid},
-                    $form->{AP},            $form->{AP_amount},
-                    $form->{AP_tax},        $form->{AP_paid},
-                    $form->{IC},            $form->{IC_sale},
-                    $form->{IC_cogs},       $form->{IC_taxpart},
-                    $form->{IC_income},     $form->{IC_expense},
-                    $form->{IC_taxservice}
-    ) {
-    $form->{link} .= "${item}:" if ($item);
-  }
-  chop $form->{link};
+  my @link_order = qw(AR AR_amount AR_tax AR_paid AP AP_amount AP_tax AP_paid IC IC_sale IC_cogs IC_taxpart IC_income IC_expense IC_taxservice);
+  $form->{link} = join ':', grep $_, map $form->{$_}, @link_order;
 
   # strip blanks from accno
   map { $form->{$_} =~ s/ //g; } qw(accno);
 
+  # collapse multiple (horizontal) whitespace in chart description (Ticket 148)
+  map { $form->{$_} =~ s/\h+/ /g } qw(description);
+
   my ($query, $sth);
 
   if ($form->{id} eq "NULL") {