USTVA: Winston export ueberarbeitet. Kz vor die pos_ustva gesetzt, 'Kennzahl Nr'...
[kivitendo-erp.git] / bin / mozilla / is.pl
index 9140574..81ba521 100644 (file)
@@ -371,8 +371,8 @@ sub form_header {
   my $customers = qq|
       <th align="right">| . $locale->text('Customer') . qq|</th>
       <td>| . 
-        (($myconfig{vclimit} == 1 
-              ? qq|<input type="text" value="$form->{oldcustomer}" name="customer">| 
+        (($myconfig{vclimit} <=  scalar(@values)
+              ? qq|<input type="text" value="| . H($form->{"oldcustomer"}) . qq|" name="customer">| 
               : (NTI($cgi->popup_menu('-name' => 'customer', '-default' => $form->{oldcustomer}, 
                              '-onChange' => 'document.getElementById(\'update_button\').click();',
                              '-values' => \@values, '-labels' => \%labels)))) . qq|
@@ -719,7 +719,11 @@ print qq|
              <tr>
                <th align="right" nowrap>| . $locale->text('Ship via') . qq|</th>
                <td colspan="3"><input name="shipvia" size="35" value="$form->{shipvia}"></td>
-             </tr>|;
+             </tr>
+              <tr>
+                <th align="right">| . $locale->text('Transaction description') . qq|</th>
+                <td colspan="3">| . $cgi->textfield("-name" => "transaction_description", "-size" => 35, "-value" => $form->{transaction_description}) . qq|</td>
+              </tr>|;
 #               <tr>
 #                 <td colspan=4>
 #                   <table>
@@ -845,13 +849,13 @@ sub form_footer {
     qq|<textarea name="notes" rows="$rows" cols="26" wrap="soft">$form->{notes}</textarea>|;
   $intnotes =
     qq|<textarea name="intnotes" rows="$rows" cols="35" wrap="soft">$form->{intnotes}</textarea>|;
-
-  $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
+  $form->{taxincluded} = ($form->{taxincluded} ? "checked" : "");
 
   $taxincluded = "";
   if ($form->{taxaccounts}) {
     $taxincluded = qq|
-               <input name="taxincluded" class="checkbox" type="checkbox" value=$form->{taxincluded}> <b>|
+               <input name="taxincluded" class="checkbox" type="checkbox" $form->{taxincluded}> <b>|
       . $locale->text('Tax Included') . qq|</b><br><br>|;
   }
 
@@ -1208,10 +1212,19 @@ sub update {
     $form->{print_and_post} = 0;
   }
 
+  
+  if($form->{taxincluded}) {
+    $taxincluded = "checked";
+  }
   $form->{update} = 1;
 
   &check_name(customer);
 
+  if(!$form->{taxincluded}) {
+    $form->{taxincluded} = $taxincluded;
+  }
+
+
   $form->{exchangerate} = $exchangerate
     if (
         $form->{forex} = (
@@ -1399,6 +1412,9 @@ sub post {
   $form->isblank("invdate",  $locale->text('Invoice Date missing!'));
   $form->isblank("customer", $locale->text('Customer missing!'));
 
+  $form->{invnumber} =~ s/^\s*//g;
+  $form->{invnumber} =~ s/\s*$//g;
+
   # if oldcustomer ne customer redo form
   if (&check_name(customer)) {
     &update;
@@ -1509,21 +1525,25 @@ sub storno {
   }
 
   map({ my $key = $_; delete($form->{$key})
-          unless (grep({ $key eq $_ } qw(login password id type))); }
+          unless (grep({ $key eq $_ } qw(login password id stylesheet type))); }
       keys(%{ $form }));
 
-  &invoice_links;
-  &prepare_invoice;
+  invoice_links();
+  prepare_invoice();
   relink_accounts();
 
+  # Payments must not be recorded for the new storno invoice.
+  $form->{paidaccounts} = 0;
+  map { my $key = $_; delete $form->{$key} if grep { $key =~ /^$_/ } qw(datepaid_ source_ memo_ paid_ exchangerate_ AR_paid_) } keys %{ $form };
+
   $form->{storno_id} = $form->{id};
   $form->{storno} = 1;
   $form->{id} = "";
   $form->{invnumber} = "Storno zu " . $form->{invnumber};
+  $form->{rowcount}++;
 
-  &post();
+  post();
   $lxdebug->leave_sub();
-
 }
 
 sub preview {