]> wagnertech.de Git - kivitendo-erp.git/blobdiff - bin/mozilla/oe.pl
Rabatt wurde fehlerhaft uebernommen beim Umwandeln von Angebot in Auftrag. Fixes...
[kivitendo-erp.git] / bin / mozilla / oe.pl
index b4760b284eb44a4081d01849b92d29406317248e..b16352fd6f66f74345c2c6fad4c8d61a888c7d8d 100644 (file)
@@ -140,7 +140,7 @@ sub order_links {
   # if multiple rowcounts (== collective order) then check if the
   # there were more than one customer (in that case OE::retrieve removes 
   # the content from the field)
-  if ($form->{rowcount} && $form->{type} eq 'sales_order' && $form->{customer} eq '') {
+  if ($form->{rowcount} && $form->{type} eq 'sales_order' && defined $form->{customer} && $form->{customer} eq '') {
 #    $main::lxdebug->message(0, "Detected Edit order with concurrent customers");
     $form->error($locale->text('Collective Orders only work for orders from one customer!'));
   }
@@ -217,7 +217,7 @@ sub order_links {
 
 sub prepare_order {
   $lxdebug->enter_sub();
-  $form->{format}   = "html";
+  $form->{format}   = "pdf";
   $form->{media}    = "screen";
   $form->{formname} = $form->{type};
 
@@ -231,13 +231,17 @@ sub prepare_order {
     }
     
     for my $i (1 .. $form->{rowcount}) {
-       $form->{"discount_$i"} =
-        $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100);
-
+      if ($form->{id}) {
+        $form->{"discount_$i"} =
+          $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100);
+      }
       ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);    
       $dec           = length $dec;
       $decimalplaces = ($dec > 2) ? $dec : 2;
 
+      # copy reqdate from deliverydate for invoice -> order conversion
+      $form->{"reqdate_$i"} = $form->{"deliverydate_$i"} unless $form->{"reqdate_$i"};
+
       $form->{"sellprice_$i"} =
         $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
                              $decimalplaces);
@@ -1913,6 +1917,9 @@ sub invoice {
     $dec           = length $dec;
     $decimalplaces = ($dec > 2) ? $dec : 2;
 
+    # copy delivery date from reqdate for order -> invoice conversion
+    $form->{"deliverydate_$i"} = $form->{"reqdate_$i"} unless $form->{"deliverydate_$i"};
+
     $form->{"sellprice_$i"} =
       $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
                            $decimalplaces);