Fehler in der Storno-Routine und beim Umwandeln einer Vorlage in einen neuen Beleg...
[kivitendo-erp.git] / bin / mozilla / ar.pl
index e867d89..104228f 100644 (file)
@@ -751,14 +751,14 @@ sub form_footer {
           <input class=submit type=submit name=action value="|
             . $locale->text('Delete') . qq|">
   |;
-  
+  }
       if ($transdate > $closedto) {
         print qq|
   <input class=submit type=submit name=action value="|
-          . $locale->text('Post as new') . qq|">
+          . $locale->text('Use As Template') . qq|">
   |;
       }
-    }
+    
   } else {
     if ($transdate > $closedto) {
       print qq|<input class=submit type=submit name=action value="|
@@ -868,7 +868,7 @@ sub update {
     ($form->{taxincluded}) ? $form->{invtotal} : $form->{invtotal} + $totaltax;
 
   for $i (1 .. $form->{paidaccounts}) {
-    if ($form->{"paid_$i"}) {
+    if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
       map {
         $form->{"${_}_$i"} =
           $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
@@ -917,7 +917,7 @@ sub post {
   delete($form->{AR});
 
   for $i (1 .. $form->{paidaccounts}) {
-    if ($form->{"paid_$i"}) {
+    if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
       $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
 
       $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
@@ -969,6 +969,18 @@ sub post_as_new {
   $lxdebug->leave_sub();
 }
 
+sub use_as_template {
+  $lxdebug->enter_sub();
+
+  map { delete $form->{$_} } qw(printed emailed queued invnumber invdate deliverydate id datepaid_1 source_1 memo_1 paid_1 exchangerate_1 AP_paid_1 storno);
+  $form->{paidaccounts} = 1;
+  $form->{rowcount}--;
+  $form->{invdate} = $form->current_date(\%myconfig);
+  &update;
+
+  $lxdebug->leave_sub();
+}
+
 sub delete {
   $lxdebug->enter_sub();