Ersatzmuster für Lieferanten/Kundennamen, die \n und/oder \r enthalten eingefügt...
[kivitendo-erp.git] / bin / mozilla / ir.pl
index bb41989..e052258 100644 (file)
@@ -32,6 +32,7 @@
 #======================================================================
 
 use SL::IR;
+use SL::IS;
 use SL::PE;
 
 require "$form->{path}/io.pl";
@@ -276,7 +277,8 @@ sub form_header {
                                    "all" => 0,
                                    "old_id" => \@old_project_ids });
 
-  my (%labels, @values);
+  my %labels;
+  my @values = (undef);
   foreach my $item (@{ $form->{"ALL_CONTACTS"} }) {
     push(@values, $item->{"cp_id"});
     $labels{$item->{"cp_id"}} = $item->{"cp_name"} .
@@ -559,7 +561,7 @@ sub form_footer {
         $tax .= qq|
                <tr>
                  <th align=right>$form->{"${item}_description"}&nbsp;|
-                                 . $form->{"${item}_rate"} * 100 .qq|%</th>
+                    . $form->{"${item}_rate"} * 100 .qq|%</th>
                  <td align=right>$form->{"${item}_total"}</td>
                </tr>
 |;
@@ -601,7 +603,7 @@ sub form_footer {
         $tax .= qq|
              <tr>
                <th align=right>Enthaltene $form->{"${item}_description"}&nbsp;|
-                               . $form->{"${item}_rate"} * 100 .qq|%</th>
+                                   . $form->{"${item}_rate"} * 100 .qq|%</th>
                <td align=right>$form->{"${item}_total"}</td>
              </tr>
              <tr>
@@ -785,12 +787,14 @@ sub form_footer {
   $closedto = $form->datetonum($form->{closedto}, \%myconfig);
 
   if ($form->{id}) {
+    my $show_storno = !$form->{storno} && !IS->has_storno(\%myconfig, $form, "ap");
+
     print qq|<input class=submit type=submit name=action value="|
       . $locale->text('Post Payment') . qq|">
 |;
     print qq|<input class=submit type=submit name=action value="|
       . $locale->text('Storno') . qq|">
-| unless ($form->{storno});
+| if ($show_storno);
     if ($form->{radier}) {
     print qq|
     <input class=submit type=submit name=action value="|
@@ -881,7 +885,7 @@ sub update {
   }
 
   $i            = $form->{rowcount};
-  $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
+  $exchangerate = ($form->{exchangerate} * 1) ? $form->{exchangerate} * 1 : 1;
 
   if (   ($form->{"partnumber_$i"} eq "")
       && ($form->{"description_$i"} eq "")
@@ -972,6 +976,14 @@ sub storno {
     $form->error($locale->text('Cannot storno storno invoice!'));
   }
 
+  if (IS->has_storno(\%myconfig, $form, "ap")) {
+    $form->error($locale->text("Invoice has already been storno'd!"));
+  }
+
+  invoice_links();
+  prepare_invoice();
+  relink_accounts();
+
   $form->{storno_id} = $form->{id};
   $form->{storno} = 1;
   $form->{id} = "";
@@ -1088,7 +1100,7 @@ sub post {
                $form->save_history($form->dbconnect(\%myconfig));
        }
        # /saving the history
-    remove_draft();
+    remove_draft() if $form->{remove_draft};
        $form->redirect(  $locale->text('Invoice')
                   . " $form->{invnumber} "
                   . $locale->text('posted!'));